From 96de7cbf98b4fc79dccfb6d09313e2c7c7e2384e Mon Sep 17 00:00:00 2001 From: Good Guy Date: Wed, 7 Dec 2016 10:46:11 -0700 Subject: [PATCH] yuv xfer error for ffmpeg, improve ffmpeg filters for opts, motion layout --- cinelerra-5.1/cinelerra/Makefile | 2 +- cinelerra-5.1/cinelerra/ffmpeg.C | 54 +++++++++++++---- .../plugins/motion-cv/motionwindow-cv.C | 59 +++++++++---------- cinelerra-5.1/plugins/motion/motionwindow.C | 34 +++++------ 4 files changed, 88 insertions(+), 61 deletions(-) diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile index 19907a9b..c4706b3d 100644 --- a/cinelerra-5.1/cinelerra/Makefile +++ b/cinelerra-5.1/cinelerra/Makefile @@ -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 diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C index 9b468bf4..b5b4a571 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.C +++ b/cinelerra-5.1/cinelerra/ffmpeg.C @@ -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; diff --git a/cinelerra-5.1/plugins/motion-cv/motionwindow-cv.C b/cinelerra-5.1/plugins/motion-cv/motionwindow-cv.C index 3b336469..859a4301 100644 --- a/cinelerra-5.1/plugins/motion-cv/motionwindow-cv.C +++ b/cinelerra-5.1/plugins/motion-cv/motionwindow-cv.C @@ -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)); diff --git a/cinelerra-5.1/plugins/motion/motionwindow.C b/cinelerra-5.1/plugins/motion/motionwindow.C index 78097b8c..86948858 100644 --- a/cinelerra-5.1/plugins/motion/motionwindow.C +++ b/cinelerra-5.1/plugins/motion/motionwindow.C @@ -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)); -- 2.26.2