diff options
author | Limin Wang <lance.lmwang@gmail.com> | 2020-05-08 06:57:58 +0800 |
---|---|---|
committer | Limin Wang <lance.lmwang@gmail.com> | 2020-05-09 09:33:49 +0800 |
commit | 18e2c0e732047e8e636f8b76509ae4f1f947ce5b (patch) | |
tree | 47e98b05815129cc3e99d883b636cc67f68eee3c /libavcodec | |
parent | 0032ca45ff0740cb8f7d70a3283348673a234a5a (diff) | |
download | ffmpeg-18e2c0e732047e8e636f8b76509ae4f1f947ce5b.tar.gz |
avcodec/mpegvideo: return more specific error codes for ff_mpv_common_init()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mpegvideo.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 22cab2854b..d174d1282e 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -907,7 +907,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) { av_log(s->avctx, AV_LOG_ERROR, "decoding to AV_PIX_FMT_NONE is not supported.\n"); - return -1; + return AVERROR(EINVAL); } if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && s->mb_height)) { @@ -923,7 +923,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if ((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx)) - return -1; + return AVERROR(EINVAL); dct_init(s); @@ -935,27 +935,27 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) return ret; FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, - MAX_PICTURE_COUNT * sizeof(Picture), fail); + MAX_PICTURE_COUNT * sizeof(Picture), fail_nomem); for (i = 0; i < MAX_PICTURE_COUNT; i++) { s->picture[i].f = av_frame_alloc(); if (!s->picture[i].f) - goto fail; + goto fail_nomem; } s->next_picture.f = av_frame_alloc(); if (!s->next_picture.f) - goto fail; + goto fail_nomem; s->last_picture.f = av_frame_alloc(); if (!s->last_picture.f) - goto fail; + goto fail_nomem; s->current_picture.f = av_frame_alloc(); if (!s->current_picture.f) - goto fail; + goto fail_nomem; s->new_picture.f = av_frame_alloc(); if (!s->new_picture.f) - goto fail; + goto fail_nomem; - if (init_context_frame(s)) - goto fail; + if ((ret = init_context_frame(s))) + goto fail_nomem; s->parse_context.state = -1; @@ -969,9 +969,9 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (i) { s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext)); if (!s->thread_context[i]) - goto fail; + goto fail_nomem; } - if (init_duplicate_context(s->thread_context[i]) < 0) + if ((ret = init_duplicate_context(s->thread_context[i])) < 0) goto fail; s->thread_context[i]->start_mb_y = (s->mb_height * (i) + nb_slices / 2) / nb_slices; @@ -979,7 +979,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; } } else { - if (init_duplicate_context(s) < 0) + if ((ret = init_duplicate_context(s)) < 0) goto fail; s->start_mb_y = 0; s->end_mb_y = s->mb_height; @@ -988,9 +988,11 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) // } return 0; + fail_nomem: + ret = AVERROR(ENOMEM); fail: ff_mpv_common_end(s); - return -1; + return ret; } /** |