[FFmpeg-devel] [PATCH 2/2] avcodec/arbc: Use ff_reget_buffer()

James Almer jamrial at gmail.com
Thu Aug 29 22:33:43 EEST 2019


On 8/29/2019 4:04 PM, Michael Niedermayer wrote:
> Fixes: Timeout (20sec -> 0.5sec)
> Fixes: 16404/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARBC_fuzzer-5660216355454976
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>  libavcodec/arbc.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c
> index 06970f140b..f0de50e243 100644
> --- a/libavcodec/arbc.c
> +++ b/libavcodec/arbc.c
> @@ -136,15 +136,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
>      if (7 * nb_segments > bytestream2_get_bytes_left(&s->gb))
>          return AVERROR_INVALIDDATA;
>  
> -    if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
> +    if ((ret = ff_reget_buffer(avctx, s->prev_frame)) < 0)
>          return ret;
>  
> -    if (s->prev_frame->data[0]) {
> -        ret = av_frame_copy(frame, s->prev_frame);
> -        if (ret < 0)
> -            return ret;
> -    }
> -
>      for (int i = 0; i < nb_segments; i++) {
>          int resolution_flag;
>          int fill;
> @@ -161,19 +155,18 @@ static int decode_frame(AVCodecContext *avctx, void *data,
>          resolution_flag = bytestream2_get_byte(&s->gb);
>  
>          if (resolution_flag & 0x10)
> -            prev_pixels -= fill_tileX(avctx, 1024, 1024, fill, frame);
> +            prev_pixels -= fill_tileX(avctx, 1024, 1024, fill, s->prev_frame);
>          if (resolution_flag & 0x08)
> -            prev_pixels -= fill_tileX(avctx, 256, 256, fill, frame);
> +            prev_pixels -= fill_tileX(avctx, 256, 256, fill, s->prev_frame);
>          if (resolution_flag & 0x04)
> -            prev_pixels -= fill_tileX(avctx, 64, 64, fill, frame);
> +            prev_pixels -= fill_tileX(avctx, 64, 64, fill, s->prev_frame);
>          if (resolution_flag & 0x02)
> -            prev_pixels -= fill_tileX(avctx, 16, 16, fill, frame);
> +            prev_pixels -= fill_tileX(avctx, 16, 16, fill, s->prev_frame);
>          if (resolution_flag & 0x01)
> -            prev_pixels -= fill_tile4(avctx, fill, frame);
> +            prev_pixels -= fill_tile4(avctx, fill, s->prev_frame);
>      }
>  
> -    av_frame_unref(s->prev_frame);
> -    if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
> +    if ((ret = av_frame_ref(frame, s->prev_frame)) < 0)
>          return ret;
>  
>      frame->pict_type = prev_pixels <= 0 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;

You could while at it revert 8b10f09fd53, then implement d70bbdc5fa for
this decoder as part of this patch.


More information about the ffmpeg-devel mailing list