[FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter to disable/enable auto scale
mypopy at gmail.com
mypopy at gmail.com
Fri Jul 12 08:27:40 EEST 2019
On Fri, Jul 12, 2019 at 1:19 PM Linjie Fu <linjie.fu at intel.com> wrote:
>
> 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 <linjie.fu at intel.com>
> ---
> 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;
> }
> -
Unrelated change
> 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;
> --
> 2.17.1
>
Add an option to disable/enable "auto insert" is Ok for me, but I
think if you reuse the -reinit_filter option, you need to update doc
part at the same time.
More information about the ffmpeg-devel
mailing list