[FFmpeg-devel] [PATCH 2/3] lavc/libxvid: return meaningful error codes

Lukasz Marek lukasz.m.luki2 at gmail.com
Mon Nov 24 01:17:29 CET 2014


Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
---
 libavcodec/libxvid.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 020af32..70d52b9 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -488,6 +488,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
         if (!x->twopassbuffer || !x->old_twopassbuffer) {
             av_log(avctx, AV_LOG_ERROR,
                    "Xvid: Cannot allocate 2-pass log buffers\n");
+            ret = AVERROR(ENOMEM);
             goto fail;
         }
         x->twopassbuffer[0]     =
@@ -503,6 +504,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
         fd = av_tempfile("xvidff.", &x->twopassfile, 0, avctx);
         if (fd == -1) {
             av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n");
+            ret = AVERROR(EIO);
             goto fail;
         }
         x->twopassfd = fd;
@@ -510,12 +512,14 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
         if (!avctx->stats_in) {
             av_log(avctx, AV_LOG_ERROR,
                    "Xvid: No 2-pass information loaded for second pass\n");
+            ret = AVERROR(EINVAL);
             goto fail;
         }
 
         if (strlen(avctx->stats_in) >
             write(fd, avctx->stats_in, strlen(avctx->stats_in))) {
             av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write to 2-pass pipe\n");
+            ret = AVERROR(EIO);
             goto fail;
         }
 
-- 
1.9.1



More information about the ffmpeg-devel mailing list