[FFmpeg-cvslog] rl2: return meaningful error codes

Paul B Mahol git at videolan.org
Sat Nov 24 11:34:24 CET 2012


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Nov 24 10:27:22 2012 +0000| [ed591ed842dad0e23e7ba83d854faa61d2e2eb0f] | committer: Paul B Mahol

rl2: return meaningful error codes

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ed591ed842dad0e23e7ba83d854faa61d2e2eb0f
---

 libavcodec/rl2.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c
index 5cffd52..c51fbd5 100644
--- a/libavcodec/rl2.c
+++ b/libavcodec/rl2.c
@@ -140,7 +140,7 @@ static av_cold int rl2_decode_init(AVCodecContext *avctx)
     /** parse extra data */
     if(!avctx->extradata || avctx->extradata_size < EXTRADATA1_SIZE){
         av_log(avctx, AV_LOG_ERROR, "invalid extradata size\n");
-        return -1;
+        return AVERROR_INVALIDDATA;
     }
 
     /** get frame_offset */
@@ -149,7 +149,7 @@ static av_cold int rl2_decode_init(AVCodecContext *avctx)
 
     if(s->video_base >= avctx->width * avctx->height){
         av_log(avctx, AV_LOG_ERROR, "invalid video_base\n");
-        return -1;
+        return AVERROR_INVALIDDATA;
     }
 
     /** initialize palette */
@@ -162,7 +162,7 @@ static av_cold int rl2_decode_init(AVCodecContext *avctx)
     if(back_size > 0){
         unsigned char* back_frame = av_mallocz(avctx->width*avctx->height);
         if(!back_frame)
-            return -1;
+            return AVERROR(ENOMEM);
         rl2_rle_decode(s,avctx->extradata + EXTRADATA1_SIZE,back_size,
                            back_frame,avctx->width,0);
         s->back_frame = back_frame;
@@ -178,15 +178,16 @@ static int rl2_decode_frame(AVCodecContext *avctx,
     const uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;
     Rl2Context *s = avctx->priv_data;
+    int ret;
 
     if(s->frame.data[0])
         avctx->release_buffer(avctx, &s->frame);
 
     /** get buffer */
     s->frame.reference= 0;
-    if(avctx->get_buffer(avctx, &s->frame)) {
+    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
         av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-        return -1;
+        return ret;
     }
 
     /** run length decode */



More information about the ffmpeg-cvslog mailing list