[FFmpeg-devel] [PATCH] lavc/mpegvideo: make ff_MPV_common_init() return meaningful error codes

Stefano Sabatini stefasab at gmail.com
Sat Jun 30 00:07:49 CEST 2012


---
 libavcodec/mpegvideo.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 8710c65..2d06203 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -458,7 +458,7 @@ static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base)
 
     return 0;
 fail:
-    return -1; // free() through ff_MPV_common_end()
+    return AVERROR(ENOMEM); // free() through ff_MPV_common_end()
 }
 
 static void free_duplicate_context(MpegEncContext *s)
@@ -674,7 +674,7 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
     if (s->avctx->pix_fmt == PIX_FMT_NONE) {
         av_log(s->avctx, AV_LOG_ERROR,
                "decoding to 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)) {
@@ -690,7 +690,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);
 
     ff_dct_common_init(s);
 
@@ -863,7 +863,7 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
     return 0;
  fail:
     ff_MPV_common_end(s);
-    return -1;
+    return AVERROR(ENOMEM);
 }
 
 /* init common structure for both encoder and decoder */
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list