History

dnxhddec: return proper error code

Alexandra Khirnova committed 12 years ago

Commit 28e508a1 parent b0c2c091 file · +11 −11Browse files

Unified · Split

libavcodec/dnxhddec.c+11−11
@@ -70,7 +70,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid) · 69 unmodified lines
70 70
71 if ((index = ff_dnxhd_get_cid_table(cid)) < 0) {71 if ((index = ff_dnxhd_get_cid_table(cid)) < 0) {
72 av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\n", cid);72 av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\n", cid);
73 return -1;73 return AVERROR(ENOSYS);
74 }74 }
75 ctx->cid_table = &ff_dnxhd_cid_table[index];75 ctx->cid_table = &ff_dnxhd_cid_table[index];
76 76
@@ -98,14 +98,14 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, · 21 unmodified lines
98 const uint8_t *buf, int buf_size, int first_field)98 const uint8_t *buf, int buf_size, int first_field)
99{99{
100 static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };100 static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
101 int i, cid;101 int i, cid, ret;
102 102
103 if (buf_size < 0x280)103 if (buf_size < 0x280)
104 return -1;104 return AVERROR_INVALIDDATA;
105 105
106 if (memcmp(buf, header_prefix, 5)) {106 if (memcmp(buf, header_prefix, 5)) {
107 av_log(ctx->avctx, AV_LOG_ERROR, "error in header\n");107 av_log(ctx->avctx, AV_LOG_ERROR, "error in header\n");
108 return -1;108 return AVERROR_INVALIDDATA;
109 }109 }
110 if (buf[5] & 2) { /* interlaced */110 if (buf[5] & 2) { /* interlaced */
111 ctx->cur_field = buf[5] & 1;111 ctx->cur_field = buf[5] & 1;
@@ -140,12 +140,12 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, · 28 unmodified lines
140 cid = AV_RB32(buf + 0x28);140 cid = AV_RB32(buf + 0x28);
141 av_dlog(ctx->avctx, "compression id %d\n", cid);141 av_dlog(ctx->avctx, "compression id %d\n", cid);
142 142
143 if (dnxhd_init_vlc(ctx, cid) < 0)143 if ((ret = dnxhd_init_vlc(ctx, cid)) < 0)
144 return -1;144 return ret;
145 145
146 if (buf_size < ctx->cid_table->coding_unit_size) {146 if (buf_size < ctx->cid_table->coding_unit_size) {
147 av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size\n");147 av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size\n");
148 return -1;148 return AVERROR_INVALIDDATA;
149 }149 }
150 150
151 ctx->mb_width = ctx->width>>4;151 ctx->mb_width = ctx->width>>4;
@@ -159,7 +159,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, · 7 unmodified lines
159 if (ctx->mb_height > 68 ||159 if (ctx->mb_height > 68 ||
160 (ctx->mb_height << frame->interlaced_frame) > (ctx->height+15)>>4) {160 (ctx->mb_height << frame->interlaced_frame) > (ctx->height+15)>>4) {
161 av_log(ctx->avctx, AV_LOG_ERROR, "mb height too big: %d\n", ctx->mb_height);161 av_log(ctx->avctx, AV_LOG_ERROR, "mb height too big: %d\n", ctx->mb_height);
162 return -1;162 return AVERROR_INVALIDDATA;
163 }163 }
164 164
165 for (i = 0; i < ctx->mb_height; i++) {165 for (i = 0; i < ctx->mb_height; i++) {
@@ -167,7 +167,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, · 1 unmodified line
167 av_dlog(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]);167 av_dlog(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]);
168 if (buf_size < ctx->mb_scan_index[i] + 0x280) {168 if (buf_size < ctx->mb_scan_index[i] + 0x280) {
169 av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n");169 av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n");
170 return -1;170 return AVERROR_INVALIDDATA;
171 }171 }
172 }172 }
173 173
@@ -338,8 +338,8 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, · 164 unmodified lines
338 av_dlog(avctx, "frame size %d\n", buf_size);338 av_dlog(avctx, "frame size %d\n", buf_size);
339 339
340 decode_coding_unit:340 decode_coding_unit:
341 if (dnxhd_decode_header(ctx, picture, buf, buf_size, first_field) < 0)341 if ((ret = dnxhd_decode_header(ctx, picture, buf, buf_size, first_field)) < 0)
342 return -1;342 return ret;
343 343
344 if ((avctx->width || avctx->height) &&344 if ((avctx->width || avctx->height) &&
345 (ctx->width != avctx->width || ctx->height != avctx->height)) {345 (ctx->width != avctx->width || ctx->height != avctx->height)) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t