yuv xfer error for ffmpeg, improve ffmpeg filters for opts, motion layout
authorGood Guy <good1.2guy@gmail.com>
Wed, 7 Dec 2016 17:46:11 +0000 (10:46 -0700)
committerGood Guy <good1.2guy@gmail.com>
Wed, 7 Dec 2016 17:46:11 +0000 (10:46 -0700)
cinelerra-5.1/cinelerra/Makefile
cinelerra-5.1/cinelerra/ffmpeg.C
cinelerra-5.1/plugins/motion-cv/motionwindow-cv.C
cinelerra-5.1/plugins/motion/motionwindow.C

index 19907a9b59ce2ca244595e7f0a72bf285b12747e..c4706b3d707c5308e484e30a4d274397d7100e9a 100644 (file)
@@ -430,7 +430,7 @@ install:
        cp -a $(OBJDIR)/bdwrite $(BINDIR)/.
 
 tags:
-       ctags -R -h default --langmap=c:+.inc . ../guicast/ ../libzmpeg3 ../plugins
+       ctags -R -h default --langmap=c:+.inc . ../guicast/ ../libzmpeg3 ../plugins ../thirdparty/ffmpeg-*
 
 
 $(OBJDIR)/%.o:         %.C
index 9b468bf4f8ea599718bb195e0e94c908b9ada180..b5b4a57116ed3de19628b2b6fb02805476071391 100644 (file)
@@ -883,6 +883,27 @@ int FFVideoConvert::convert_picture_vframe(VFrame *frame,
 {
        // try bc_xfer methods
        int imodel = pix_fmt_to_color_model(ifmt);
+       // if not compatible with xfer
+       switch( imodel ) {
+       case BC_YUV420P:
+       case BC_YUV420PI:
+       case BC_YUV422P:
+               if( ip->linesize[0] != ip->linesize[1]*2 ||
+                   ip->linesize[0] != ip->linesize[2]*2 )
+                       imodel = -1;
+               break;
+       case BC_YUV410P:
+       case BC_YUV411P:
+               if( ip->linesize[0] != ip->linesize[1]*4 ||
+                   ip->linesize[0] != ip->linesize[2]*4 )
+                       imodel = -1;
+               break;
+       case BC_YUV444P:
+               if( ip->linesize[0] != ip->linesize[1] ||
+                   ip->linesize[0] != ip->linesize[2] )
+                       imodel = -1;
+               break;
+       }
        if( imodel >= 0 ) {
                long y_ofs = 0, u_ofs = 0, v_ofs = 0;
                uint8_t *data = ip->data[0];
@@ -1562,8 +1583,8 @@ int FFMPEG::open_decoder()
                printf("FFMPEG::open_decoder: some stream times estimated\n");
 
        ff_lock("FFMPEG::open_decoder");
-       int bad_time = 0;
-       for( int i=0; i<(int)fmt_ctx->nb_streams; ++i ) {
+       int ret = 0, bad_time = 0;
+       for( int i=0; !ret && i<(int)fmt_ctx->nb_streams; ++i ) {
                AVStream *st = fmt_ctx->streams[i];
                if( st->duration == AV_NOPTS_VALUE ) bad_time = 1;
                AVCodecContext *avctx = st->codec;
@@ -1588,7 +1609,7 @@ int FFMPEG::open_decoder()
                        vid->nudge = st->start_time;
                        vid->reading = -1;
                        if( opt_video_filter )
-                               vid->create_filter(opt_video_filter, avctx,avctx);
+                               ret = vid->create_filter(opt_video_filter, avctx,avctx);
                }
                else if( avctx->codec_type == AVMEDIA_TYPE_AUDIO ) {
                        if( avctx->channels < 1 ) continue;
@@ -1616,13 +1637,13 @@ int FFMPEG::open_decoder()
                        aud->nudge = st->start_time;
                        aud->reading = -1;
                        if( opt_audio_filter )
-                               aud->create_filter(opt_audio_filter, avctx,avctx);
+                               ret = aud->create_filter(opt_audio_filter, avctx,avctx);
                }
        }
        if( bad_time )
                printf("FFMPEG::open_decoder: some stream have bad times\n");
        ff_unlock();
-       return 0;
+       return ret < 0 ? -1 : 0;
 }
 
 
@@ -2302,7 +2323,12 @@ int FFVideoStream::create_filter(const char *filter_spec,
                AVCodecContext *src_ctx, AVCodecContext *sink_ctx)
 {
        avfilter_register_all();
-       AVFilter *filter = avfilter_get_by_name(filter_spec);
+       const char *sp = filter_spec;
+       char filter_name[BCSTRLEN], *np = filter_name;
+       int i = sizeof(filter_name);
+       while( --i>=0 && *sp!=0 && !strchr(" \t:=",*sp) ) *np++ = *sp++;
+       *np = 0;
+       AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
        if( !filter || avfilter_pad_get_type(filter->inputs,0) != AVMEDIA_TYPE_VIDEO ) {
                ff_err(AVERROR(EINVAL), "FFVideoStream::create_filter: %s\n", filter_spec);
                return -1;
@@ -2331,14 +2357,19 @@ int FFVideoStream::create_filter(const char *filter_spec,
                ff_err(ret, "FFVideoStream::create_filter");
        else
                ret = FFStream::create_filter(filter_spec);
-       return ret >= 0 ? 0 : 1;
+       return ret >= 0 ? 0 : -1;
 }
 
 int FFAudioStream::create_filter(const char *filter_spec,
                AVCodecContext *src_ctx, AVCodecContext *sink_ctx)
 {
        avfilter_register_all();
-       AVFilter *filter = avfilter_get_by_name(filter_spec);
+       const char *sp = filter_spec;
+       char filter_name[BCSTRLEN], *np = filter_name;
+       int i = sizeof(filter_name);
+       while( --i>=0 && *sp!=0 && !strchr(" \t:=",*sp) ) *np++ = *sp++;
+       *np = 0;
+       AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
        if( !filter || avfilter_pad_get_type(filter->inputs,0) != AVMEDIA_TYPE_AUDIO ) {
                ff_err(AVERROR(EINVAL), "FFAudioStream::create_filter: %s\n", filter_spec);
                return -1;
@@ -2373,7 +2404,7 @@ int FFAudioStream::create_filter(const char *filter_spec,
                ff_err(ret, "FFAudioStream::create_filter");
        else
                ret = FFStream::create_filter(filter_spec);
-       return ret >= 0 ? 0 : 1;
+       return ret >= 0 ? 0 : -1;
 }
 
 int FFStream::create_filter(const char *filter_spec)
@@ -2398,8 +2429,11 @@ int FFStream::create_filter(const char *filter_spec)
        if( ret >= 0 )
                ret = avfilter_graph_config(filter_graph, NULL);
 
-       if( ret < 0 )
+       if( ret < 0 ) {
                ff_err(ret, "FFStream::create_filter");
+               avfilter_graph_free(&filter_graph);
+               filter_graph = 0;
+       }
        avfilter_inout_free(&inputs);
        avfilter_inout_free(&outputs);
        return ret;
index 3b33646910bc4a96af7f3dd4a52e32292326d1d2..859a43018e96baac3d958c8b8ef7efa4ab42ec1f 100644 (file)
@@ -31,7 +31,7 @@
 #include "pluginserver.h"
 
 MotionCVWindow::MotionCVWindow(MotionCVMain *plugin)
- : PluginClientWindow(plugin, 815, 660, 815, 660, 0)
+ : PluginClientWindow(plugin, 815, 575, 815, 575, 0)
 {
        this->plugin = plugin;
 }
@@ -100,7 +100,12 @@ void MotionCVWindow::create_objects()
                        this, x + title->get_w() + 10, y));
        mode3->create_objects();
 
-       y += 40;
+       add_subwindow(title = new BC_Title(x2, y, _("Tracking file:")));
+       add_subwindow(tracking_file = new MotionCVTrackingFile(plugin,
+                       plugin->config.  tracking_file, this,
+                       x2 + title->get_w() + 20, y));
+
+       y += 40;  int y1 = y;
        add_subwindow(title = new BC_Title(x, y + 10, _("Block X:")));
        add_subwindow(block_x = new MotionCVBlockX(plugin, this,
                        x + title->get_w() + 10, y));
@@ -114,30 +119,34 @@ void MotionCVWindow::create_objects()
        add_subwindow(block_y_text = new MotionCVBlockYText(plugin, this,
                        x + title->get_w() + 10 + block_y->get_w() + 10, y + 10));
 
-       y += 50;
-       add_subwindow(title = new BC_Title(x, y + 10, _("Maximum absolute offset:")));
+       add_subwindow(title = new BC_Title(x2, y1 + 10, _("Maximum absolute offset:")));
        add_subwindow(magnitude = new MotionCVMagnitude(plugin,
-                       x + title->get_w() + 10, y));
+                       x2 + title->get_w() + 10, y1));
 
-       y += 40;
-       add_subwindow(title = new BC_Title(x, y + 10, _("Settling speed:")));
+       y1 += 40;
+       add_subwindow(title = new BC_Title(x2, y1 + 10, _("Settling speed:")));
        add_subwindow(return_speed = new MotionCVReturnSpeed(plugin,
-                       x + title->get_w() + 10, y));
+                       x2 + title->get_w() + 10, y1));
 
-       y += 40;
-       add_subwindow(vectors = new MotionCVDrawVectors(plugin, this, x, y));
-
-       add_subwindow(title = new BC_Title(x2, y, _("Tracking file:")));
-       add_subwindow(tracking_file = new MotionCVTrackingFile(plugin,
-                       plugin->config.  tracking_file, this,
-                       x2 + title->get_w() + 20, y));
+       y1 += 40;
+       add_subwindow(vectors = new MotionCVDrawVectors(plugin, this, x2, y1));
+       y = y1 + vectors->get_h() + 10;
 
-       y += 40;
-       x1 = x;  int y1 = y;
+       x1 = x;  y1 = y;
        add_subwindow(track_single =
                new TrackSingleFrame(plugin, this, x1, y1));
+       y += 20;
+       add_subwindow(track_previous = new TrackPreviousFrame(plugin, this, x, y));
+       y += 20;
+       add_subwindow(previous_same = new PreviousFrameSameBlock(plugin, this, x, y));
+
+       y += 40;
+       add_subwindow(title = new BC_Title(x, y, _("Master layer:")));
+       add_subwindow(master_layer = new MasterLayer(plugin, this,
+                       x + title->get_w() + 10, y));
+       master_layer->create_objects();
        add_subwindow(title =
-               new BC_Title(x1=x2, y1, _("Frame number:")));
+               new BC_Title(x1=x2, y1=y, _("Frame number:")));
        add_subwindow(track_frame_number =
                new TrackFrameNumber(plugin, this, x1 += title->get_w(), y1));
        add_subwindow(addtrackedframeoffset =
@@ -150,25 +159,13 @@ void MotionCVWindow::create_objects()
                        _("Currently using: Play every frame"), MEDIUMFONT,
                !pef ? RED : GREEN));
 
-       y += 20;
-       add_subwindow(track_previous = new TrackPreviousFrame(plugin, this, x, y));
-       y += 20;
-       add_subwindow(previous_same = new PreviousFrameSameBlock(plugin, this, x, y));
-
-       y += 40;
-       //int y1 = y;
-       add_subwindow(title = new BC_Title(x, y, _("Master layer:")));
-       add_subwindow(master_layer = new MasterLayer(plugin, this,
-                       x + title->get_w() + 10, y));
-       master_layer->create_objects();
        y += 30;
-
        add_subwindow(title = new BC_Title(x, y, _("Action:")));
        add_subwindow(mode1 = new Mode1(plugin, this,
                        x + title->get_w() + 10, y));
        mode1->create_objects();
-       y += 30;
 
+       y += 30;
        add_subwindow(title = new BC_Title(x, y, _("Calculation:")));
        add_subwindow(mode2 = new Mode2(plugin, this,
                        x + title->get_w() + 10, y));
index 78097b8c7e583238d99c9dff9ff46dcd28301093..86948858347b0fe05c6ce08f56fd84625399d434 100644 (file)
@@ -107,6 +107,10 @@ void MotionWindow::create_objects()
                y));
        track_direction->create_objects();
 
+       add_subwindow(title = new BC_Title(x2, y, _("Tracking file:")));
+       add_subwindow(tracking_file = new MotionTrackingFile(plugin,
+               plugin->config.tracking_file, this, x2+title->get_w() + 20, y));
+
        y += 40;
        add_subwindow(title = new BC_Title(x, y + 10, _("Block X:")));
        add_subwindow(block_x =
@@ -129,9 +133,10 @@ void MotionWindow::create_objects()
        add_subwindow(title = new BC_Title(x2, y + 10, _("Rotation settling speed:")));
        add_subwindow(rotate_return_speed =
                new MotionRReturnSpeed(plugin, x2 + title->get_w() + 10, y));
-
-       y = y1;
        y += 40;
+       add_subwindow(vectors = new MotionDrawVectors(plugin, this, x2, y));
+
+       y = y1 + 60;
        add_subwindow(title = new BC_Title(x, y + 10, _("Block Y:")));
        add_subwindow(block_y =
                new MotionBlockY(plugin, this, x + title->get_w() + 10, y));
@@ -151,16 +156,17 @@ void MotionWindow::create_objects()
                new MotionReturnSpeed(plugin, x + title->get_w() + 10, y));
 
        y += 40;
-       add_subwindow(vectors = new MotionDrawVectors(plugin, this, x, y));
-
-       add_subwindow(title = new BC_Title(x2, y, _("Tracking file:")));
-       add_subwindow(tracking_file = new MotionTrackingFile(plugin,
-               plugin->config.tracking_file, this, x2+title->get_w() + 20, y));
+       add_subwindow(track_single =
+               new TrackSingleFrame(plugin, this, x, y));
+       y += 20;
+       add_subwindow(track_previous =
+               new TrackPreviousFrame(plugin, this, x, y));
+       y += 20;
+       add_subwindow(previous_same =
+               new PreviousFrameSameBlock(plugin, this, x, y));
 
        y += 40;
        x1 = x;  y1 = y;
-       add_subwindow(track_single =
-               new TrackSingleFrame(plugin, this, x1, y1));
        add_subwindow(title =
                new BC_Title(x1=x2, y1, _("Frame number:")));
        add_subwindow(track_frame_number =
@@ -175,16 +181,6 @@ void MotionWindow::create_objects()
                        _("Currently using: Play every frame"), MEDIUMFONT,
                !pef ? RED : GREEN));
 
-       y += 20;
-       add_subwindow(track_previous =
-               new TrackPreviousFrame(plugin, this, x, y));
-
-       y += 20;
-       add_subwindow(previous_same =
-               new PreviousFrameSameBlock(plugin, this, x, y));
-
-       y += 40;
-       y1 = y;
        add_subwindow(title = new BC_Title(x, y, _("Master layer:")));
        add_subwindow(master_layer = new MasterLayer(plugin,
                this, x + title->get_w() + 10, y));