* commit '9dbbda235d93d628777b986e502213f1ed390973':
vb: return meaningful error codes.
ptx: return meaningful error codes.
tiff: return meaningful error codes.
vqavideo: return meaningful error codes.
mss2: return meaningful error codes.
v210dec: return meaningful error codes
indeo2: cosmetics, reformat
Conflicts:
libavcodec/indeo2.c
libavcodec/tiff.c
libavcodec/v210dec.c
libavcodec/vb.c
libavcodec/vqavideo.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -47,8 +47,8 @@ static inline int ir2_get_code(GetBitContext *gb) |
47 | 47 |
return get_vlc2(gb, ir2_vlc.table, CODE_VLC_BITS, 1) + 1; |
48 | 48 |
} |
49 | 49 |
|
50 |
-static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, |
|
51 |
- const uint8_t *table) |
|
50 |
+static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, |
|
51 |
+ int stride, const uint8_t *table) |
|
52 | 52 |
{ |
53 | 53 |
int i; |
54 | 54 |
int j; |
... | ... |
@@ -56,15 +56,15 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst |
56 | 56 |
int c; |
57 | 57 |
int t; |
58 | 58 |
|
59 |
- if(width&1) |
|
59 |
+ if (width & 1) |
|
60 | 60 |
return AVERROR_INVALIDDATA; |
61 | 61 |
|
62 | 62 |
/* first line contain absolute values, other lines contain deltas */ |
63 |
- while (out < width){ |
|
63 |
+ while (out < width) { |
|
64 | 64 |
c = ir2_get_code(&ctx->gb); |
65 |
- if(c >= 0x80) { /* we have a run */ |
|
65 |
+ if (c >= 0x80) { /* we have a run */ |
|
66 | 66 |
c -= 0x7F; |
67 |
- if(out + c*2 > width) |
|
67 |
+ if (out + c*2 > width) |
|
68 | 68 |
return AVERROR_INVALIDDATA; |
69 | 69 |
for (i = 0; i < c * 2; i++) |
70 | 70 |
dst[out++] = 0x80; |
... | ... |
@@ -75,25 +75,25 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst |
75 | 75 |
} |
76 | 76 |
dst += stride; |
77 | 77 |
|
78 |
- for (j = 1; j < height; j++){ |
|
78 |
+ for (j = 1; j < height; j++) { |
|
79 | 79 |
out = 0; |
80 |
- while (out < width){ |
|
80 |
+ while (out < width) { |
|
81 | 81 |
c = ir2_get_code(&ctx->gb); |
82 |
- if(c >= 0x80) { /* we have a skip */ |
|
82 |
+ if (c >= 0x80) { /* we have a skip */ |
|
83 | 83 |
c -= 0x7F; |
84 |
- if(out + c*2 > width) |
|
84 |
+ if (out + c*2 > width) |
|
85 | 85 |
return AVERROR_INVALIDDATA; |
86 | 86 |
for (i = 0; i < c * 2; i++) { |
87 | 87 |
dst[out] = dst[out - stride]; |
88 | 88 |
out++; |
89 | 89 |
} |
90 | 90 |
} else { /* add two deltas from table */ |
91 |
- t = dst[out - stride] + (table[c * 2] - 128); |
|
92 |
- t= av_clip_uint8(t); |
|
91 |
+ t = dst[out - stride] + (table[c * 2] - 128); |
|
92 |
+ t = av_clip_uint8(t); |
|
93 | 93 |
dst[out] = t; |
94 | 94 |
out++; |
95 |
- t = dst[out - stride] + (table[(c * 2) + 1] - 128); |
|
96 |
- t= av_clip_uint8(t); |
|
95 |
+ t = dst[out - stride] + (table[(c * 2) + 1] - 128); |
|
96 |
+ t = av_clip_uint8(t); |
|
97 | 97 |
dst[out] = t; |
98 | 98 |
out++; |
99 | 99 |
} |
... | ... |
@@ -103,31 +103,31 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst |
103 | 103 |
return 0; |
104 | 104 |
} |
105 | 105 |
|
106 |
-static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, |
|
107 |
- const uint8_t *table) |
|
106 |
+static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, |
|
107 |
+ int stride, const uint8_t *table) |
|
108 | 108 |
{ |
109 | 109 |
int j; |
110 | 110 |
int out = 0; |
111 | 111 |
int c; |
112 | 112 |
int t; |
113 | 113 |
|
114 |
- if(width&1) |
|
114 |
+ if (width & 1) |
|
115 | 115 |
return AVERROR_INVALIDDATA; |
116 | 116 |
|
117 |
- for (j = 0; j < height; j++){ |
|
117 |
+ for (j = 0; j < height; j++) { |
|
118 | 118 |
out = 0; |
119 |
- while (out < width){ |
|
119 |
+ while (out < width) { |
|
120 | 120 |
c = ir2_get_code(&ctx->gb); |
121 |
- if(c >= 0x80) { /* we have a skip */ |
|
122 |
- c -= 0x7F; |
|
121 |
+ if (c >= 0x80) { /* we have a skip */ |
|
122 |
+ c -= 0x7F; |
|
123 | 123 |
out += c * 2; |
124 | 124 |
} else { /* add two deltas from table */ |
125 |
- t = dst[out] + (((table[c * 2] - 128)*3) >> 2); |
|
126 |
- t= av_clip_uint8(t); |
|
125 |
+ t = dst[out] + (((table[c * 2] - 128)*3) >> 2); |
|
126 |
+ t = av_clip_uint8(t); |
|
127 | 127 |
dst[out] = t; |
128 | 128 |
out++; |
129 |
- t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2); |
|
130 |
- t= av_clip_uint8(t); |
|
129 |
+ t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2); |
|
130 |
+ t = av_clip_uint8(t); |
|
131 | 131 |
dst[out] = t; |
132 | 132 |
out++; |
133 | 133 |
} |
... | ... |
@@ -141,11 +141,11 @@ static int ir2_decode_frame(AVCodecContext *avctx, |
141 | 141 |
void *data, int *got_frame, |
142 | 142 |
AVPacket *avpkt) |
143 | 143 |
{ |
144 |
- const uint8_t *buf = avpkt->data; |
|
145 |
- int buf_size = avpkt->size; |
|
146 | 144 |
Ir2Context * const s = avctx->priv_data; |
147 |
- AVFrame *picture = data; |
|
148 |
- AVFrame * const p = &s->picture; |
|
145 |
+ const uint8_t *buf = avpkt->data; |
|
146 |
+ int buf_size = avpkt->size; |
|
147 |
+ AVFrame *picture = data; |
|
148 |
+ AVFrame * const p = &s->picture; |
|
149 | 149 |
int start, ret; |
150 | 150 |
|
151 | 151 |
p->reference = 3; |
... | ... |
@@ -209,7 +209,8 @@ static int ir2_decode_frame(AVCodecContext *avctx, |
209 | 209 |
return buf_size; |
210 | 210 |
} |
211 | 211 |
|
212 |
-static av_cold int ir2_decode_init(AVCodecContext *avctx){ |
|
212 |
+static av_cold int ir2_decode_init(AVCodecContext *avctx) |
|
213 |
+{ |
|
213 | 214 |
Ir2Context * const ic = avctx->priv_data; |
214 | 215 |
static VLC_TYPE vlc_tables[1 << CODE_VLC_BITS][2]; |
215 | 216 |
|
... | ... |
@@ -233,7 +234,8 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx){ |
233 | 233 |
return 0; |
234 | 234 |
} |
235 | 235 |
|
236 |
-static av_cold int ir2_decode_end(AVCodecContext *avctx){ |
|
236 |
+static av_cold int ir2_decode_end(AVCodecContext *avctx) |
|
237 |
+{ |
|
237 | 238 |
Ir2Context * const ic = avctx->priv_data; |
238 | 239 |
AVFrame *pic = &ic->picture; |
239 | 240 |
|
... | ... |
@@ -163,7 +163,7 @@ static int decode_pal_v2(MSS12Context *ctx, const uint8_t *buf, int buf_size) |
163 | 163 |
|
164 | 164 |
ncol = *buf++; |
165 | 165 |
if (ncol > ctx->free_colours || buf_size < 2 + ncol * 3) |
166 |
- return -1; |
|
166 |
+ return AVERROR_INVALIDDATA; |
|
167 | 167 |
for (i = 0; i < ncol; i++) |
168 | 168 |
*pal++ = AV_RB24(buf + 3 * i); |
169 | 169 |
|
... | ... |
@@ -189,7 +189,7 @@ static int decode_555(GetByteContext *gB, uint16_t *dst, int stride, |
189 | 189 |
READ_PAIR(y, endy) |
190 | 190 |
|
191 | 191 |
if (endx >= w || endy >= h || x > endx || y > endy) |
192 |
- return -1; |
|
192 |
+ return AVERROR_INVALIDDATA; |
|
193 | 193 |
dst += x + stride * y; |
194 | 194 |
w = endx - x + 1; |
195 | 195 |
h = endy - y + 1; |
... | ... |
@@ -373,13 +373,14 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, |
373 | 373 |
VC1Context *v = avctx->priv_data; |
374 | 374 |
MpegEncContext *s = &v->s; |
375 | 375 |
AVFrame *f; |
376 |
+ int ret; |
|
376 | 377 |
|
377 | 378 |
ff_mpeg_flush(avctx); |
378 | 379 |
|
379 | 380 |
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { |
380 | 381 |
int i = ff_find_unused_picture(s, 0); |
381 | 382 |
if (i < 0) |
382 |
- return -1; |
|
383 |
+ return i; |
|
383 | 384 |
s->current_picture_ptr = &s->picture[i]; |
384 | 385 |
} |
385 | 386 |
|
... | ... |
@@ -399,10 +400,10 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, |
399 | 399 |
|
400 | 400 |
avctx->pix_fmt = AV_PIX_FMT_YUV420P; |
401 | 401 |
|
402 |
- if (ff_MPV_frame_start(s, avctx) < 0) { |
|
402 |
+ if ((ret = ff_MPV_frame_start(s, avctx)) < 0) { |
|
403 | 403 |
av_log(v->s.avctx, AV_LOG_ERROR, "ff_MPV_frame_start error\n"); |
404 | 404 |
avctx->pix_fmt = AV_PIX_FMT_RGB24; |
405 |
- return -1; |
|
405 |
+ return ret; |
|
406 | 406 |
} |
407 | 407 |
|
408 | 408 |
ff_er_frame_start(s); |
... | ... |
@@ -617,7 +618,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
617 | 617 |
ctx->last_pic.linesize[0] * (avctx->height - 1); |
618 | 618 |
} else { |
619 | 619 |
av_log(avctx, AV_LOG_ERROR, "Missing keyframe\n"); |
620 |
- return -1; |
|
620 |
+ return AVERROR_INVALIDDATA; |
|
621 | 621 |
} |
622 | 622 |
} else { |
623 | 623 |
if (ctx->last_pic.data[0]) |
... | ... |
@@ -753,6 +754,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
753 | 753 |
static av_cold int wmv9_init(AVCodecContext *avctx) |
754 | 754 |
{ |
755 | 755 |
VC1Context *v = avctx->priv_data; |
756 |
+ int ret; |
|
756 | 757 |
|
757 | 758 |
v->s.avctx = avctx; |
758 | 759 |
avctx->flags |= CODEC_FLAG_EMU_EDGE; |
... | ... |
@@ -761,8 +763,8 @@ static av_cold int wmv9_init(AVCodecContext *avctx) |
761 | 761 |
if (avctx->idct_algo == FF_IDCT_AUTO) |
762 | 762 |
avctx->idct_algo = FF_IDCT_WMV2; |
763 | 763 |
|
764 |
- if (ff_vc1_init_common(v) < 0) |
|
765 |
- return -1; |
|
764 |
+ if ((ret = ff_vc1_init_common(v)) < 0) |
|
765 |
+ return ret; |
|
766 | 766 |
ff_vc1dsp_init(&v->vc1dsp); |
767 | 767 |
|
768 | 768 |
v->profile = PROFILE_MAIN; |
... | ... |
@@ -802,9 +804,9 @@ static av_cold int wmv9_init(AVCodecContext *avctx) |
802 | 802 |
|
803 | 803 |
ff_vc1_init_transposed_scantables(v); |
804 | 804 |
|
805 |
- if (ff_msmpeg4_decode_init(avctx) < 0 || |
|
806 |
- ff_vc1_decode_init_alloc_tables(v) < 0) |
|
807 |
- return -1; |
|
805 |
+ if ((ret = ff_msmpeg4_decode_init(avctx)) < 0 || |
|
806 |
+ (ret = ff_vc1_decode_init_alloc_tables(v)) < 0) |
|
807 |
+ return ret; |
|
808 | 808 |
|
809 | 809 |
/* error concealment */ |
810 | 810 |
v->s.me.qpel_put = v->s.dsp.put_qpel_pixels_tab; |
... | ... |
@@ -46,6 +46,7 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
46 | 46 |
AVFrame *picture = data; |
47 | 47 |
AVFrame * const p = &s->picture; |
48 | 48 |
unsigned int offset, w, h, y, stride, bytes_per_pixel; |
49 |
+ int ret; |
|
49 | 50 |
uint8_t *ptr; |
50 | 51 |
|
51 | 52 |
if (buf_end - buf < 14) |
... | ... |
@@ -72,13 +73,13 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
72 | 72 |
if (p->data[0]) |
73 | 73 |
avctx->release_buffer(avctx, p); |
74 | 74 |
|
75 |
- if (av_image_check_size(w, h, 0, avctx)) |
|
76 |
- return -1; |
|
75 |
+ if ((ret = av_image_check_size(w, h, 0, avctx)) < 0) |
|
76 |
+ return ret; |
|
77 | 77 |
if (w != avctx->width || h != avctx->height) |
78 | 78 |
avcodec_set_dimensions(avctx, w, h); |
79 |
- if (ff_get_buffer(avctx, p) < 0) { |
|
79 |
+ if ((ret = ff_get_buffer(avctx, p)) < 0) { |
|
80 | 80 |
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
81 |
- return -1; |
|
81 |
+ return ret; |
|
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
p->pict_type = AV_PICTURE_TYPE_I; |
... | ... |
@@ -399,7 +399,7 @@ static void av_always_inline horizontal_fill(unsigned int bpp, uint8_t* dst, |
399 | 399 |
static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
400 | 400 |
const uint8_t *src, int size, int lines) |
401 | 401 |
{ |
402 |
- int c, line, pixels, code; |
|
402 |
+ int c, line, pixels, code, ret; |
|
403 | 403 |
const uint8_t *ssrc = src; |
404 | 404 |
int width = ((s->width * s->bpp) + 7) >> 3; |
405 | 405 |
|
... | ... |
@@ -434,7 +434,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
434 | 434 |
(unsigned long)width * lines, ret); |
435 | 435 |
av_free(src2); |
436 | 436 |
av_free(zbuf); |
437 |
- return -1; |
|
437 |
+ return AVERROR_UNKNOWN; |
|
438 | 438 |
} |
439 | 439 |
src = zbuf; |
440 | 440 |
for (line = 0; line < lines; line++) { |
... | ... |
@@ -465,9 +465,9 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
465 | 465 |
if (size > 1 && !src[0] && (src[1]&1)) { |
466 | 466 |
av_log(s->avctx, AV_LOG_ERROR, "Old style LZW is unsupported\n"); |
467 | 467 |
} |
468 |
- if (ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF) < 0) { |
|
468 |
+ if ((ret = ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF)) < 0) { |
|
469 | 469 |
av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n"); |
470 |
- return -1; |
|
470 |
+ return ret; |
|
471 | 471 |
} |
472 | 472 |
} |
473 | 473 |
if (s->compr == TIFF_CCITT_RLE || s->compr == TIFF_G3 |
... | ... |
@@ -485,7 +485,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
485 | 485 |
av_log(s->avctx, AV_LOG_ERROR, |
486 | 486 |
"Uncompressed fax mode is not supported (yet)\n"); |
487 | 487 |
av_free(src2); |
488 |
- return -1; |
|
488 |
+ return AVERROR_INVALIDDATA; |
|
489 | 489 |
} |
490 | 490 |
if (!s->fill_order) { |
491 | 491 |
memcpy(src2, src, size); |
... | ... |
@@ -513,7 +513,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
513 | 513 |
for (line = 0; line < lines; line++) { |
514 | 514 |
if (src - ssrc > size) { |
515 | 515 |
av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n"); |
516 |
- return -1; |
|
516 |
+ return AVERROR_INVALIDDATA; |
|
517 | 517 |
} |
518 | 518 |
switch (s->compr) { |
519 | 519 |
case TIFF_RAW: |
... | ... |
@@ -541,7 +541,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
541 | 541 |
if (pixels + code > width) { |
542 | 542 |
av_log(s->avctx, AV_LOG_ERROR, |
543 | 543 |
"Copy went out of bounds\n"); |
544 |
- return -1; |
|
544 |
+ return AVERROR_INVALIDDATA; |
|
545 | 545 |
} |
546 | 546 |
if (ssrc + size - src < code) { |
547 | 547 |
av_log(s->avctx, AV_LOG_ERROR, "Read went out of bounds\n"); |
... | ... |
@@ -556,7 +556,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
556 | 556 |
if (pixels + code > width) { |
557 | 557 |
av_log(s->avctx, AV_LOG_ERROR, |
558 | 558 |
"Run went out of bounds\n"); |
559 |
- return -1; |
|
559 |
+ return AVERROR_INVALIDDATA; |
|
560 | 560 |
} |
561 | 561 |
c = *src++; |
562 | 562 |
horizontal_fill(s->bpp * (s->avctx->pix_fmt == AV_PIX_FMT_PAL8), |
... | ... |
@@ -570,7 +570,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
570 | 570 |
if (pixels < width) { |
571 | 571 |
av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n", |
572 | 572 |
pixels, width); |
573 |
- return -1; |
|
573 |
+ return AVERROR_INVALIDDATA; |
|
574 | 574 |
} |
575 | 575 |
if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8) |
576 | 576 |
horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0); |
... | ... |
@@ -705,7 +705,7 @@ static int tiff_decode_tag(TiffContext *s) |
705 | 705 |
av_log(s->avctx, AV_LOG_ERROR, |
706 | 706 |
"This format is not supported (bpp=%d, %d components)\n", |
707 | 707 |
s->bpp, count); |
708 |
- return -1; |
|
708 |
+ return AVERROR_INVALIDDATA; |
|
709 | 709 |
} |
710 | 710 |
if (count == 1) |
711 | 711 |
s->bpp = value; |
... | ... |
@@ -719,7 +719,7 @@ static int tiff_decode_tag(TiffContext *s) |
719 | 719 |
case TIFF_LONG: |
720 | 720 |
s->bpp = 0; |
721 | 721 |
if (bytestream2_get_bytes_left(&s->gb) < type_sizes[type] * count) |
722 |
- return -1; |
|
722 |
+ return AVERROR_INVALIDDATA; |
|
723 | 723 |
for (i = 0; i < count; i++) |
724 | 724 |
s->bpp += tget(&s->gb, type, s->le); |
725 | 725 |
break; |
... | ... |
@@ -757,17 +757,17 @@ static int tiff_decode_tag(TiffContext *s) |
757 | 757 |
break; |
758 | 758 |
#else |
759 | 759 |
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n"); |
760 |
- return -1; |
|
760 |
+ return AVERROR(ENOSYS); |
|
761 | 761 |
#endif |
762 | 762 |
case TIFF_JPEG: |
763 | 763 |
case TIFF_NEWJPEG: |
764 | 764 |
av_log(s->avctx, AV_LOG_ERROR, |
765 | 765 |
"JPEG compression is not supported\n"); |
766 |
- return -1; |
|
766 |
+ return AVERROR_PATCHWELCOME; |
|
767 | 767 |
default: |
768 | 768 |
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", |
769 | 769 |
s->compr); |
770 |
- return -1; |
|
770 |
+ return AVERROR_INVALIDDATA; |
|
771 | 771 |
} |
772 | 772 |
break; |
773 | 773 |
case TIFF_ROWSPERSTRIP: |
... | ... |
@@ -776,7 +776,7 @@ static int tiff_decode_tag(TiffContext *s) |
776 | 776 |
if (value < 1) { |
777 | 777 |
av_log(s->avctx, AV_LOG_ERROR, |
778 | 778 |
"Incorrect value of rows per strip\n"); |
779 |
- return -1; |
|
779 |
+ return AVERROR_INVALIDDATA; |
|
780 | 780 |
} |
781 | 781 |
s->rps = value; |
782 | 782 |
break; |
... | ... |
@@ -793,7 +793,7 @@ static int tiff_decode_tag(TiffContext *s) |
793 | 793 |
if (s->strippos > bytestream2_size(&s->gb)) { |
794 | 794 |
av_log(s->avctx, AV_LOG_ERROR, |
795 | 795 |
"Tag referencing position outside the image\n"); |
796 |
- return -1; |
|
796 |
+ return AVERROR_INVALIDDATA; |
|
797 | 797 |
} |
798 | 798 |
break; |
799 | 799 |
case TIFF_STRIP_SIZE: |
... | ... |
@@ -809,7 +809,7 @@ static int tiff_decode_tag(TiffContext *s) |
809 | 809 |
if (s->stripsizesoff > bytestream2_size(&s->gb)) { |
810 | 810 |
av_log(s->avctx, AV_LOG_ERROR, |
811 | 811 |
"Tag referencing position outside the image\n"); |
812 |
- return -1; |
|
812 |
+ return AVERROR_INVALIDDATA; |
|
813 | 813 |
} |
814 | 814 |
break; |
815 | 815 |
case TIFF_TILE_BYTE_COUNTS: |
... | ... |
@@ -836,7 +836,7 @@ static int tiff_decode_tag(TiffContext *s) |
836 | 836 |
default: |
837 | 837 |
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n", |
838 | 838 |
value); |
839 |
- return -1; |
|
839 |
+ return AVERROR_INVALIDDATA; |
|
840 | 840 |
} |
841 | 841 |
break; |
842 | 842 |
case TIFF_FILL_ORDER: |
... | ... |
@@ -851,7 +851,7 @@ static int tiff_decode_tag(TiffContext *s) |
851 | 851 |
pal = (uint32_t *) s->palette; |
852 | 852 |
off = type_sizes[type]; |
853 | 853 |
if (count / 3 > 256 || bytestream2_get_bytes_left(&s->gb) < count / 3 * off * 3) |
854 |
- return -1; |
|
854 |
+ return AVERROR_INVALIDDATA; |
|
855 | 855 |
off = (type_sizes[type] - 1) << 3; |
856 | 856 |
for (k = 2; k >= 0; k--) { |
857 | 857 |
for (i = 0; i < count / 3; i++) { |
... | ... |
@@ -866,7 +866,7 @@ static int tiff_decode_tag(TiffContext *s) |
866 | 866 |
case TIFF_PLANAR: |
867 | 867 |
if (value == 2) { |
868 | 868 |
av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n"); |
869 |
- return -1; |
|
869 |
+ return AVERROR_PATCHWELCOME; |
|
870 | 870 |
} |
871 | 871 |
break; |
872 | 872 |
case TIFF_T4OPTIONS: |
... | ... |
@@ -959,7 +959,7 @@ static int tiff_decode_tag(TiffContext *s) |
959 | 959 |
|
960 | 960 |
bytestream2_seek(&s->gb, pos + s->geotags[i].offset, SEEK_SET); |
961 | 961 |
if (bytestream2_get_bytes_left(&s->gb) < s->geotags[i].count) |
962 |
- return -1; |
|
962 |
+ return AVERROR_INVALIDDATA; |
|
963 | 963 |
ap = av_malloc(s->geotags[i].count); |
964 | 964 |
if (!ap) { |
965 | 965 |
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); |
... | ... |
@@ -1040,7 +1040,7 @@ static int decode_frame(AVCodecContext *avctx, |
1040 | 1040 |
le = 0; |
1041 | 1041 |
else { |
1042 | 1042 |
av_log(avctx, AV_LOG_ERROR, "TIFF header not found\n"); |
1043 |
- return -1; |
|
1043 |
+ return AVERROR_INVALIDDATA; |
|
1044 | 1044 |
} |
1045 | 1045 |
s->le = le; |
1046 | 1046 |
// TIFF_BPP is not a required tag and defaults to 1 |
... | ... |
@@ -1058,7 +1058,7 @@ static int decode_frame(AVCodecContext *avctx, |
1058 | 1058 |
if (tget_short(&s->gb, le) != 42) { |
1059 | 1059 |
av_log(avctx, AV_LOG_ERROR, |
1060 | 1060 |
"The answer to life, universe and everything is not correct!\n"); |
1061 |
- return -1; |
|
1061 |
+ return AVERROR_INVALIDDATA; |
|
1062 | 1062 |
} |
1063 | 1063 |
// Reset these offsets so we can tell if they were set this frame |
1064 | 1064 |
s->stripsizesoff = s->strippos = 0; |
... | ... |
@@ -1073,8 +1073,8 @@ static int decode_frame(AVCodecContext *avctx, |
1073 | 1073 |
if (bytestream2_get_bytes_left(&s->gb) < entries * 12) |
1074 | 1074 |
return AVERROR_INVALIDDATA; |
1075 | 1075 |
for (i = 0; i < entries; i++) { |
1076 |
- if (tiff_decode_tag(s) < 0) |
|
1077 |
- return -1; |
|
1076 |
+ if ((ret = tiff_decode_tag(s)) < 0) |
|
1077 |
+ return ret; |
|
1078 | 1078 |
} |
1079 | 1079 |
|
1080 | 1080 |
for (i = 0; i<s->geotag_count; i++) { |
... | ... |
@@ -1096,7 +1096,7 @@ static int decode_frame(AVCodecContext *avctx, |
1096 | 1096 |
|
1097 | 1097 |
if (!s->strippos && !s->stripoff) { |
1098 | 1098 |
av_log(avctx, AV_LOG_ERROR, "Image data is missing\n"); |
1099 |
- return -1; |
|
1099 |
+ return AVERROR_INVALIDDATA; |
|
1100 | 1100 |
} |
1101 | 1101 |
/* now we have the data and may start decoding */ |
1102 | 1102 |
if ((ret = init_image(s)) < 0) |
... | ... |
@@ -1138,7 +1138,7 @@ static int decode_frame(AVCodecContext *avctx, |
1138 | 1138 |
|
1139 | 1139 |
if (soff > avpkt->size || ssize > avpkt->size - soff) { |
1140 | 1140 |
av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n"); |
1141 |
- return -1; |
|
1141 |
+ return AVERROR_INVALIDDATA; |
|
1142 | 1142 |
} |
1143 | 1143 |
if (tiff_unpack_strip(s, dst, stride, avpkt->data + soff, ssize, |
1144 | 1144 |
FFMIN(s->rps, s->height - i)) < 0) |
... | ... |
@@ -55,7 +55,7 @@ static av_cold int decode_init(AVCodecContext *avctx) |
55 | 55 |
|
56 | 56 |
if (avctx->width & 1) { |
57 | 57 |
av_log(avctx, AV_LOG_ERROR, "v210 needs even width\n"); |
58 |
- return -1; |
|
58 |
+ return AVERROR_INVALIDDATA; |
|
59 | 59 |
} |
60 | 60 |
avctx->pix_fmt = AV_PIX_FMT_YUV422P10; |
61 | 61 |
avctx->bits_per_raw_sample = 10; |
... | ... |
@@ -77,7 +77,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
77 | 77 |
{ |
78 | 78 |
V210DecContext *s = avctx->priv_data; |
79 | 79 |
|
80 |
- int h, w, stride, aligned_input; |
|
80 |
+ int h, w, ret, stride, aligned_input; |
|
81 | 81 |
AVFrame *pic = avctx->coded_frame; |
82 | 82 |
const uint8_t *psrc = avpkt->data; |
83 | 83 |
uint16_t *y, *u, *v; |
... | ... |
@@ -97,7 +97,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
97 | 97 |
s->stride_warning_shown = 1; |
98 | 98 |
} else { |
99 | 99 |
av_log(avctx, AV_LOG_ERROR, "packet too small\n"); |
100 |
- return -1; |
|
100 |
+ return AVERROR_INVALIDDATA; |
|
101 | 101 |
} |
102 | 102 |
} |
103 | 103 |
|
... | ... |
@@ -112,8 +112,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
112 | 112 |
avctx->release_buffer(avctx, pic); |
113 | 113 |
|
114 | 114 |
pic->reference = 0; |
115 |
- if (ff_get_buffer(avctx, pic) < 0) |
|
116 |
- return -1; |
|
115 |
+ if ((ret = ff_get_buffer(avctx, pic)) < 0) |
|
116 |
+ return ret; |
|
117 | 117 |
|
118 | 118 |
y = (uint16_t*)pic->data[0]; |
119 | 119 |
u = (uint16_t*)pic->data[1]; |
... | ... |
@@ -123,7 +123,7 @@ static int vb_decode_framedata(VBDecContext *c, int offset) |
123 | 123 |
if(!t){ //raw block |
124 | 124 |
if (bytestream2_get_bytes_left(&g) < 16) { |
125 | 125 |
av_log(c->avctx, AV_LOG_ERROR, "Insufficient data\n"); |
126 |
- return -1; |
|
126 |
+ return AVERROR_INVALIDDATA; |
|
127 | 127 |
} |
128 | 128 |
for(y = 0; y < 4; y++) |
129 | 129 |
bytestream2_get_buffer(&g, cur + y * width, 4); |
... | ... |
@@ -168,7 +168,7 @@ static int vb_decode_framedata(VBDecContext *c, int offset) |
168 | 168 |
break; |
169 | 169 |
case 3: |
170 | 170 |
av_log(c->avctx, AV_LOG_ERROR, "Invalid opcode seen @%d\n",blk); |
171 |
- return -1; |
|
171 |
+ return AVERROR_INVALIDDATA; |
|
172 | 172 |
} |
173 | 173 |
break; |
174 | 174 |
} |
... | ... |
@@ -190,7 +190,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
190 | 190 |
{ |
191 | 191 |
VBDecContext * const c = avctx->priv_data; |
192 | 192 |
uint8_t *outptr, *srcptr; |
193 |
- int i, j; |
|
193 |
+ int i, j, ret; |
|
194 | 194 |
int flags; |
195 | 195 |
uint32_t size; |
196 | 196 |
int offset = 0; |
... | ... |
@@ -200,9 +200,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
200 | 200 |
if(c->pic.data[0]) |
201 | 201 |
avctx->release_buffer(avctx, &c->pic); |
202 | 202 |
c->pic.reference = 3; |
203 |
- if(ff_get_buffer(avctx, &c->pic) < 0){ |
|
203 |
+ if ((ret = ff_get_buffer(avctx, &c->pic)) < 0) { |
|
204 | 204 |
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
205 |
- return -1; |
|
205 |
+ return ret; |
|
206 | 206 |
} |
207 | 207 |
|
208 | 208 |
flags = bytestream2_get_le16(&c->stream); |
... | ... |
@@ -122,7 +122,7 @@ typedef struct VqaContext { |
122 | 122 |
static av_cold int vqa_decode_init(AVCodecContext *avctx) |
123 | 123 |
{ |
124 | 124 |
VqaContext *s = avctx->priv_data; |
125 |
- int i, j, codebook_index; |
|
125 |
+ int i, j, codebook_index, ret; |
|
126 | 126 |
|
127 | 127 |
s->avctx = avctx; |
128 | 128 |
avctx->pix_fmt = AV_PIX_FMT_PAL8; |
... | ... |
@@ -130,7 +130,7 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) |
130 | 130 |
/* make sure the extradata made it */ |
131 | 131 |
if (s->avctx->extradata_size != VQA_HEADER_SIZE) { |
132 | 132 |
av_log(s->avctx, AV_LOG_ERROR, "expected extradata size of %d\n", VQA_HEADER_SIZE); |
133 |
- return AVERROR_INVALIDDATA; |
|
133 |
+ return AVERROR(EINVAL); |
|
134 | 134 |
} |
135 | 135 |
|
136 | 136 |
/* load up the VQA parameters from the header */ |
... | ... |
@@ -141,9 +141,9 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) |
141 | 141 |
} |
142 | 142 |
s->width = AV_RL16(&s->avctx->extradata[6]); |
143 | 143 |
s->height = AV_RL16(&s->avctx->extradata[8]); |
144 |
- if(av_image_check_size(s->width, s->height, 0, avctx)){ |
|
144 |
+ if ((ret = av_image_check_size(s->width, s->height, 0, avctx)) < 0) { |
|
145 | 145 |
s->width= s->height= 0; |
146 |
- return AVERROR_INVALIDDATA; |
|
146 |
+ return ret; |
|
147 | 147 |
} |
148 | 148 |
s->vector_width = s->avctx->extradata[10]; |
149 | 149 |
s->vector_height = s->avctx->extradata[11]; |
... | ... |
@@ -592,7 +592,7 @@ static int vqa_decode_frame(AVCodecContext *avctx, |
592 | 592 |
if (s->frame.data[0]) |
593 | 593 |
avctx->release_buffer(avctx, &s->frame); |
594 | 594 |
|
595 |
- if ((res = ff_get_buffer(avctx, &s->frame))) { |
|
595 |
+ if ((res = ff_get_buffer(avctx, &s->frame)) < 0) { |
|
596 | 596 |
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
597 | 597 |
return res; |
598 | 598 |
} |