[FFmpeg-devel] [PATCH v2 5/5] avcodec/mpegvideo: return more specific error codes for init_duplicate_context()

Marton Balint cus at passwd.hu
Thu May 7 21:36:50 EEST 2020



On Thu, 7 May 2020, lance.lmwang at gmail.com wrote:

> From: Limin Wang <lance.lmwang at gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
> libavcodec/mpegvideo.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index b5ddb1b..8a74a45 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -359,7 +359,7 @@ static int init_duplicate_context(MpegEncContext *s)
>     int y_size = s->b8_stride * (2 * s->mb_height + 1);
>     int c_size = s->mb_stride * (s->mb_height + 1);
>     int yc_size = y_size + 2 * c_size;
> -    int i;
> +    int i, ret = AVERROR(ENOMEM);

ret is uncecessary.

>
>     if (s->mb_height & 1)
>         yc_size += 2*s->b8_stride + 2*s->mb_stride;
> @@ -408,7 +408,7 @@ static int init_duplicate_context(MpegEncContext *s)
>
>     return 0;
> fail:
> -    return -1; // free() through ff_mpv_common_end()
> +    return ret; // free() through ff_mpv_common_end()

Simply return AVERROR(ENOMEM) because all failures are ENOMEM-s.

> }
> 
> static void free_duplicate_context(MpegEncContext *s)
> --

Regards,
Marton


More information about the ffmpeg-devel mailing list