Message ID | 20190712131845.25212-1-linjie.fu@intel.com |
---|---|
State | New |
Headers | show |
On Fri, Jul 12, 2019 at 1:19 PM Linjie Fu <linjie.fu@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@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.
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > Of mypopy@gmail.com > Sent: Friday, July 12, 2019 13:28 > To: FFmpeg development discussions and patches <ffmpeg- > devel@ffmpeg.org> > Cc: Fu, Linjie <linjie.fu@intel.com> > Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter > to disable/enable auto scale > > On Fri, Jul 12, 2019 at 1:19 PM Linjie Fu <linjie.fu@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@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 Yep, this should be recalled. > > > 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. I prefer to add a separate option, too. Depending on the comments, I'll either update doc for reinit_filter, or add a new option and related doc. Thanks.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > Of Fu, Linjie > Sent: Friday, July 12, 2019 1:36 PM > To: FFmpeg development discussions and patches > <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter > to disable/enable auto scale > > > -----Original Message----- > > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On > Behalf > > Of mypopy@gmail.com > > Sent: Friday, July 12, 2019 13:28 > > To: FFmpeg development discussions and patches <ffmpeg- > > devel@ffmpeg.org> > > Cc: Fu, Linjie <linjie.fu@intel.com> > > Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use > > -reinit_filter to disable/enable auto scale > > > > On Fri, Jul 12, 2019 at 1:19 PM Linjie Fu <linjie.fu@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@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 > > Yep, this should be recalled. > > > > > > 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. > > I prefer to add a separate option, too. > Depending on the comments, I'll either update doc for reinit_filter, or add a > new option and related doc. Since there is an existed option named "autorotate", add an new option "autoscale" looks can keep tune.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > Of Linjie Fu > Sent: Friday, July 12, 2019 9:19 PM > To: ffmpeg-devel@ffmpeg.org > Cc: Fu, Linjie <linjie.fu@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@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?
> -----Original Message----- > From: Li, Zhong > Sent: Friday, July 12, 2019 14:39 > To: FFmpeg development discussions and patches <ffmpeg- > devel@ffmpeg.org> > Cc: Fu, Linjie <linjie.fu@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@ffmpeg.org] On > Behalf > > Of Linjie Fu > > Sent: Friday, July 12, 2019 9:19 PM > > To: ffmpeg-devel@ffmpeg.org > > Cc: Fu, Linjie <linjie.fu@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@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.
> > > 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. > > > > I prefer to add a separate option, too. > > Depending on the comments, I'll either update doc for reinit_filter, or add a > > new option and related doc. > > Since there is an existed option named "autorotate", add an new option "autoscale" looks can keep tune. I like the idea of having a new option, too. The option name "reinit_filter" doesn't imply anything about "scaling"... it's just a side-effect. That is, reinit_filter could cause other filters to behave differently too, right? So an explicit option to enable/disable auto scale would imply a more obvious expectation to the user. U. Artie
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > Of Eoff, Ullysses A > Sent: Saturday, July 13, 2019 12:26 > To: FFmpeg development discussions and patches <ffmpeg- > devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter > to disable/enable auto scale > > > > > 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. > > > > > > I prefer to add a separate option, too. > > > Depending on the comments, I'll either update doc for reinit_filter, or > add a > > > new option and related doc. > > > > Since there is an existed option named "autorotate", add an new option > "autoscale" looks can keep tune. > > I like the idea of having a new option, too. The option name "reinit_filter" > doesn't imply anything > about "scaling"... it's just a side-effect. That is, reinit_filter could cause other > filters to behave > differently too, right? So an explicit option to enable/disable auto scale > would imply a more > obvious expectation to the user. > Thanks for the comments. Will refine new patches with a separate option and doc. - linjie
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;
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@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(-)