Browse code

avcodec/pgssubdec: better error codes

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

John Stebbins authored on 2014/06/19 05:38:36
Showing 1 changed files
... ...
@@ -122,7 +122,7 @@ static int decode_rle(AVCodecContext *avctx, AVSubtitleRect *rect,
122 122
     rect->pict.data[0] = av_malloc(rect->w * rect->h);
123 123
 
124 124
     if (!rect->pict.data[0])
125
-        return -1;
125
+        return AVERROR(ENOMEM);
126 126
 
127 127
     pixel_count = 0;
128 128
     line_count  = 0;
... ...
@@ -159,7 +159,7 @@ static int decode_rle(AVCodecContext *avctx, AVSubtitleRect *rect,
159 159
 
160 160
     if (pixel_count < rect->w * rect->h) {
161 161
         av_log(avctx, AV_LOG_ERROR, "Insufficient RLE data for subtitle\n");
162
-        return -1;
162
+        return AVERROR_INVALIDDATA;
163 163
     }
164 164
 
165 165
     av_dlog(avctx, "Pixel Count = %d, Area = %d\n", pixel_count, rect->w * rect->h);
... ...
@@ -188,7 +188,7 @@ static int parse_picture_segment(AVCodecContext *avctx,
188 188
     uint16_t picture_id;
189 189
 
190 190
     if (buf_size <= 4)
191
-        return -1;
191
+        return AVERROR_INVALIDDATA;
192 192
     buf_size -= 4;
193 193
 
194 194
     picture_id = bytestream_get_be16(&buf);
... ...
@@ -202,7 +202,7 @@ static int parse_picture_segment(AVCodecContext *avctx,
202 202
     if (!(sequence_desc & 0x80)) {
203 203
         /* Additional RLE data */
204 204
         if (buf_size > ctx->pictures[picture_id].rle_remaining_len)
205
-            return -1;
205
+            return AVERROR_INVALIDDATA;
206 206
 
207 207
         memcpy(ctx->pictures[picture_id].rle + ctx->pictures[picture_id].rle_data_len, buf, buf_size);
208 208
         ctx->pictures[picture_id].rle_data_len += buf_size;
... ...
@@ -212,7 +212,7 @@ static int parse_picture_segment(AVCodecContext *avctx,
212 212
     }
213 213
 
214 214
     if (buf_size <= 7)
215
-        return -1;
215
+        return AVERROR_INVALIDDATA;
216 216
     buf_size -= 7;
217 217
 
218 218
     /* Decode rle bitmap length, stored size includes width/height data */
... ...
@@ -225,7 +225,7 @@ static int parse_picture_segment(AVCodecContext *avctx,
225 225
     /* Make sure the bitmap is not too large */
226 226
     if (avctx->width < width || avctx->height < height) {
227 227
         av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n");
228
-        return -1;
228
+        return AVERROR_INVALIDDATA;
229 229
     }
230 230
 
231 231
     if (buf_size > rle_bitmap_len) {
... ...
@@ -239,7 +239,7 @@ static int parse_picture_segment(AVCodecContext *avctx,
239 239
     av_fast_padded_malloc(&ctx->pictures[picture_id].rle, &ctx->pictures[picture_id].rle_buffer_size, rle_bitmap_len);
240 240
 
241 241
     if (!ctx->pictures[picture_id].rle)
242
-        return -1;
242
+        return AVERROR(ENOMEM);
243 243
 
244 244
     memcpy(ctx->pictures[picture_id].rle, buf, buf_size);
245 245
     ctx->pictures[picture_id].rle_data_len      = buf_size;