Returning 0 for failure is misleading.
CC: libav-stable@libav.org
... | ... |
@@ -49,18 +49,18 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, |
49 | 49 |
{ |
50 | 50 |
vp56_rac_gets(c, 8); |
51 | 51 |
if(vp56_rac_gets(c, 5) > 5) |
52 |
- return 0; |
|
52 |
+ return AVERROR_INVALIDDATA; |
|
53 | 53 |
vp56_rac_gets(c, 2); |
54 | 54 |
if (vp56_rac_get(c)) { |
55 | 55 |
av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n"); |
56 |
- return 0; |
|
56 |
+ return AVERROR_PATCHWELCOME; |
|
57 | 57 |
} |
58 | 58 |
rows = vp56_rac_gets(c, 8); /* number of stored macroblock rows */ |
59 | 59 |
cols = vp56_rac_gets(c, 8); /* number of stored macroblock cols */ |
60 | 60 |
if (!rows || !cols) { |
61 | 61 |
av_log(s->avctx, AV_LOG_ERROR, "Invalid size %dx%d\n", |
62 | 62 |
cols << 4, rows << 4); |
63 |
- return 0; |
|
63 |
+ return AVERROR_INVALIDDATA; |
|
64 | 64 |
} |
65 | 65 |
vp56_rac_gets(c, 8); /* number of displayed macroblock rows */ |
66 | 66 |
vp56_rac_gets(c, 8); /* number of displayed macroblock cols */ |
... | ... |
@@ -69,11 +69,11 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, |
69 | 69 |
16*cols != s->avctx->coded_width || |
70 | 70 |
16*rows != s->avctx->coded_height) { |
71 | 71 |
avcodec_set_dimensions(s->avctx, 16*cols, 16*rows); |
72 |
- return 2; |
|
72 |
+ return VP56_SIZE_CHANGE; |
|
73 | 73 |
} |
74 | 74 |
} else if (!s->macroblocks) |
75 |
- return 0; |
|
76 |
- return 1; |
|
75 |
+ return AVERROR_INVALIDDATA; |
|
76 |
+ return 0; |
|
77 | 77 |
} |
78 | 78 |
|
79 | 79 |
static void vp5_parse_vector_adjustment(VP56Context *s, VP56mv *vect) |
... | ... |
@@ -514,10 +514,10 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
514 | 514 |
s->modelp = &s->models[is_alpha]; |
515 | 515 |
|
516 | 516 |
res = s->parse_header(s, buf, remaining_buf_size, &golden_frame); |
517 |
- if (!res) |
|
518 |
- return -1; |
|
517 |
+ if (res < 0) |
|
518 |
+ return res; |
|
519 | 519 |
|
520 |
- if (res == 2) { |
|
520 |
+ if (res == VP56_SIZE_CHANGE) { |
|
521 | 521 |
int i; |
522 | 522 |
for (i = 0; i < 4; i++) { |
523 | 523 |
if (s->frames[i].data[0]) |
... | ... |
@@ -536,7 +536,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
536 | 536 |
return -1; |
537 | 537 |
} |
538 | 538 |
|
539 |
- if (res == 2) |
|
539 |
+ if (res == VP56_SIZE_CHANGE) |
|
540 | 540 |
if (vp56_size_changed(avctx)) { |
541 | 541 |
avctx->release_buffer(avctx, p); |
542 | 542 |
return -1; |
... | ... |
@@ -52,7 +52,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, |
52 | 52 |
int vrt_shift = 0; |
53 | 53 |
int sub_version; |
54 | 54 |
int rows, cols; |
55 |
- int res = 1; |
|
55 |
+ int res = 0; |
|
56 | 56 |
int separated_coeff = buf[0] & 1; |
57 | 57 |
|
58 | 58 |
s->framep[VP56_FRAME_CURRENT]->key_frame = !(buf[0] & 0x80); |
... | ... |
@@ -61,7 +61,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, |
61 | 61 |
if (s->framep[VP56_FRAME_CURRENT]->key_frame) { |
62 | 62 |
sub_version = buf[1] >> 3; |
63 | 63 |
if (sub_version > 8) |
64 |
- return 0; |
|
64 |
+ return AVERROR_INVALIDDATA; |
|
65 | 65 |
s->filter_header = buf[1] & 0x06; |
66 | 66 |
if (buf[1] & 1) { |
67 | 67 |
av_log_missing_feature(s->avctx, "Interlacing", 0); |
... | ... |
@@ -79,7 +79,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, |
79 | 79 |
/* buf[5] is number of displayed macroblock cols */ |
80 | 80 |
if (!rows || !cols) { |
81 | 81 |
av_log(s->avctx, AV_LOG_ERROR, "Invalid size %dx%d\n", cols << 4, rows << 4); |
82 |
- return 0; |
|
82 |
+ return AVERROR_INVALIDDATA; |
|
83 | 83 |
} |
84 | 84 |
|
85 | 85 |
if (!s->macroblocks || /* first frame */ |
... | ... |
@@ -90,7 +90,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, |
90 | 90 |
s->avctx->width -= s->avctx->extradata[0] >> 4; |
91 | 91 |
s->avctx->height -= s->avctx->extradata[0] & 0x0F; |
92 | 92 |
} |
93 |
- res = 2; |
|
93 |
+ res = VP56_SIZE_CHANGE; |
|
94 | 94 |
} |
95 | 95 |
|
96 | 96 |
ff_vp56_init_range_decoder(c, buf+6, buf_size-6); |
... | ... |
@@ -102,7 +102,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, |
102 | 102 |
s->sub_version = sub_version; |
103 | 103 |
} else { |
104 | 104 |
if (!s->sub_version || !s->avctx->coded_width || !s->avctx->coded_height) |
105 |
- return 0; |
|
105 |
+ return AVERROR_INVALIDDATA; |
|
106 | 106 |
|
107 | 107 |
if (separated_coeff || !s->filter_header) { |
108 | 108 |
coeff_offset = AV_RB16(buf+1) - 2; |
... | ... |
@@ -146,7 +146,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, |
146 | 146 |
if (buf_size < 0) { |
147 | 147 |
if (s->framep[VP56_FRAME_CURRENT]->key_frame) |
148 | 148 |
avcodec_set_dimensions(s->avctx, 0, 0); |
149 |
- return 0; |
|
149 |
+ return AVERROR_INVALIDDATA; |
|
150 | 150 |
} |
151 | 151 |
if (s->use_huffman) { |
152 | 152 |
s->parse_coeff = vp6_parse_coeff_huffman; |