[FFmpeg-devel] [PATCH] ffmpeg_filter: don't try to autorotate frames with hwaccel pixel formats

Nicolas George george at nsup.org
Tue Sep 21 16:07:39 EEST 2021


James Almer (12021-09-21):
> The transpose, rotate, hflip, and vflip filters don't support them.
> Fixes ticket #9432.
> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> I'm surprised nobody tried to decode an mp4 video like those coming from a
> cellphone camera using a hwaccel decoder. This would have been noticed much
> earlier.
> 
>  fftools/ffmpeg_filter.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index da0d4faf54..cc3dc33246 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -699,6 +699,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
>  {
>      AVFilterContext *last_filter;
>      const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
> +    const AVPixFmtDescriptor *desc;
>      InputStream *ist = ifilter->ist;
>      InputFile     *f = input_files[ist->file_index];
>      AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
> @@ -756,7 +757,9 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
>      av_freep(&par);
>      last_filter = ifilter->filter;
>  
> -    if (ist->autorotate) {

> +    desc = av_pix_fmt_desc_get(ifilter->format);
> +    // TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
> +    if (ist->autorotate && desc && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {

I am rather unsure about the "&& desc". buffersink requires a valid
pixel format. If the code arrives there without one, either there is a
bug somewhere or there should be a clearer failure earlier.

So I think "av_assert0(desc);" would be more adequate.

>          int32_t *displaymatrix = ifilter->displaymatrix;
>          double theta;
>  

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210921/0fce2a76/attachment.sig>


More information about the ffmpeg-devel mailing list