[FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter to disable/enable auto scale
Fu, Linjie
linjie.fu at intel.com
Fri Jul 12 10:29:50 EEST 2019
> -----Original Message-----
> From: Li, Zhong
> Sent: Friday, July 12, 2019 14:39
> To: FFmpeg development discussions and patches <ffmpeg-
> devel at ffmpeg.org>
> Cc: Fu, Linjie <linjie.fu at intel.com>
> Subject: RE: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter
> to disable/enable auto scale
>
> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces at ffmpeg.org] On
> Behalf
> > Of Linjie Fu
> > Sent: Friday, July 12, 2019 9:19 PM
> > To: ffmpeg-devel at ffmpeg.org
> > Cc: Fu, Linjie <linjie.fu at intel.com>
> > Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter to
> > disable/enable auto scale
> >
> > 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;
> > }
> > -
> > 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
>
> Is there any big difference with https://patchwork.ffmpeg.org/patch/8173/,
> especially for the purpose of disabling scaling for HWACCEL?
It's a bit different IMHO.
This patch enables disable/enable scale as user's purpose, both software/hardware
would obey and meet user's expectation.
And the attached patch seems to disable scale for hw encoder to make the transcode
pipeline work. But this will lead to different results between software deocde and
hardware decode.
More information about the ffmpeg-devel
mailing list