From patchwork Fri Jul 12 13:18:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 13905 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 586434478E4 for ; Fri, 12 Jul 2019 08:19:24 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 27A7D68AA0D; Fri, 12 Jul 2019 08:19:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE4A468A274 for ; Fri, 12 Jul 2019 08:19:17 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2019 22:19:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,481,1557212400"; d="scan'208";a="365500946" Received: from media_lj_kbl.sh.intel.com ([10.239.13.115]) by fmsmga006.fm.intel.com with ESMTP; 11 Jul 2019 22:19:14 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 Jul 2019 21:18:45 +0800 Message-Id: <20190712131845.25212-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter to disable/enable auto 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Currently, ffmpeg inserts scale filter 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. Option -reinit_filter 0 could be used to realize similar function, but it fails when ifilter has hw_frame_ctx. Add auto_scale flag set by -reinit_filter to indicate whether auto inserting the scale filter in the filter graph. Signed-off-by: Linjie Fu --- Request for comments. As we have discussed in the rawdump filter patch, here is a simpler solution based on -reinit_filter, and reuse this option.(maybe it's not easy to be accepted to add a separate option) fftools/ffmpeg.c | 2 +- fftools/ffmpeg.h | 1 + fftools/ffmpeg_filter.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 01f04103cf..5305b87bd4 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->auto_scale = ifilter->ist->reinit_filters; switch (ifilter->ist->st->codecpar->codec_type) { case AVMEDIA_TYPE_AUDIO: @@ -2145,7 +2146,6 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) ifilter->height != frame->height; break; } - if (!ifilter->ist->reinit_filters && fg->graph) need_reinit = 0; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7b6f802082..0c289b439f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -285,6 +285,7 @@ typedef struct FilterGraph { AVFilterGraph *graph; int reconfiguration; + int auto_scale; InputFilter **inputs; int nb_inputs; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 72838de1e2..856ba48de7 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->auto_scale) { char args[255]; AVFilterContext *filter; AVDictionaryEntry *e = NULL;