From patchwork Fri Jul 19 16:26:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 13996 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id A7C3B44A094 for ; Fri, 19 Jul 2019 19:26:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8369B68ACB2; Fri, 19 Jul 2019 19:26:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 81C8968AC9C for ; Fri, 19 Jul 2019 19:26:24 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2019 09:26:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,283,1559545200"; d="scan'208";a="168597800" Received: from media_lj_kbl.sh.intel.com ([10.239.13.115]) by fmsmga008.fm.intel.com with ESMTP; 19 Jul 2019 09:26:22 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Sat, 20 Jul 2019 00:26:06 +0800 Message-Id: <20190719162606.25235-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH, v2 1/2] fftools/ffmpeg_filter: add -autoscale to disable/enable the default scale X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Linjie Fu , "U . Artie Eoff" MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Currently, ffmpeg inserts scale filter by default in the filter graph to force the whole decoded stream to scale into the same size with the first frame. It's not quite make sense in resolution changing cases if user wants the rawvideo without any scale. Using autoscale/noautoscale to indicate whether auto inserting the scale filter in the filter graph: -noautoscale or -autoscale 0: disable the default auto scale filter inserting. Signed-off-by: U. Artie Eoff Signed-off-by: Linjie Fu --- fftools/ffmpeg.c | 1 + fftools/ffmpeg.h | 4 ++++ fftools/ffmpeg_filter.c | 2 +- fftools/ffmpeg_opt.c | 8 ++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 01f04103cf..5d52430b1e 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2133,6 +2133,7 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) /* determine if the parameters for this input changed */ need_reinit = ifilter->format != frame->format; + fg->autoscale = ifilter->ist->autoscale; switch (ifilter->ist->st->codecpar->codec_type) { case AVMEDIA_TYPE_AUDIO: diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7b6f802082..1602406581 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -133,6 +133,8 @@ typedef struct OptionsContext { int nb_hwaccel_output_formats; SpecifierOpt *autorotate; int nb_autorotate; + SpecifierOpt *autoscale; + int nb_autoscale; /* output options */ StreamMap *stream_maps; @@ -285,6 +287,7 @@ typedef struct FilterGraph { AVFilterGraph *graph; int reconfiguration; + int autoscale; InputFilter **inputs; int nb_inputs; @@ -335,6 +338,7 @@ typedef struct InputStream { int guess_layout_max; int autorotate; + int autoscale; int fix_sub_duration; struct { /* previous decoded subtitle and related variables */ diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 72838de1e2..2a2eb080eb 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -469,7 +469,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, if (ret < 0) return ret; - if (ofilter->width || ofilter->height) { + if ((ofilter->width || ofilter->height) && fg->autoscale) { char args[255]; AVFilterContext *filter; AVDictionaryEntry *e = NULL; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index f5ca18aa64..41cb676dad 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -742,7 +742,9 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st); ist->autorotate = 1; + ist->autoscale = 1; MATCH_PER_STREAM_OPT(autorotate, i, ist->autorotate, ic, st); + MATCH_PER_STREAM_OPT(autoscale, i, ist->autoscale, ic, st); MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); if (codec_tag) { @@ -3640,6 +3642,12 @@ const OptionDef options[] = { { "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(autorotate) }, "automatically insert correct rotate filters" }, + { "autoscale", HAS_ARG | OPT_BOOL | OPT_SPEC | + OPT_EXPERT | OPT_INPUT, { .off = OFFSET(autoscale) }, + "automatically insert a scale filter at the end of the filter graph if a resolution" + "change is detected. This ensures all frames are the same resolution as the first frame" + "when they leave the filter chain (this option is enabled by default)." + "If disabled, some encoders/muxers may not support this mode."}, /* audio options */ { "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_frames },