Commit 28e508a9 authored by Alexandra Khirnova's avatar Alexandra Khirnova Committed by Vittorio Giovara

dnxhddec: return proper error code

Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
parent b0c2c097
...@@ -70,7 +70,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid) ...@@ -70,7 +70,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
if ((index = ff_dnxhd_get_cid_table(cid)) < 0) { if ((index = ff_dnxhd_get_cid_table(cid)) < 0) {
av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\n", cid); av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\n", cid);
return -1; return AVERROR(ENOSYS);
} }
ctx->cid_table = &ff_dnxhd_cid_table[index]; ctx->cid_table = &ff_dnxhd_cid_table[index];
...@@ -98,14 +98,14 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, ...@@ -98,14 +98,14 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
const uint8_t *buf, int buf_size, int first_field) const uint8_t *buf, int buf_size, int first_field)
{ {
static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 }; static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
int i, cid; int i, cid, ret;
if (buf_size < 0x280) if (buf_size < 0x280)
return -1; return AVERROR_INVALIDDATA;
if (memcmp(buf, header_prefix, 5)) { if (memcmp(buf, header_prefix, 5)) {
av_log(ctx->avctx, AV_LOG_ERROR, "error in header\n"); av_log(ctx->avctx, AV_LOG_ERROR, "error in header\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (buf[5] & 2) { /* interlaced */ if (buf[5] & 2) { /* interlaced */
ctx->cur_field = buf[5] & 1; ctx->cur_field = buf[5] & 1;
...@@ -140,12 +140,12 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, ...@@ -140,12 +140,12 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
cid = AV_RB32(buf + 0x28); cid = AV_RB32(buf + 0x28);
av_dlog(ctx->avctx, "compression id %d\n", cid); av_dlog(ctx->avctx, "compression id %d\n", cid);
if (dnxhd_init_vlc(ctx, cid) < 0) if ((ret = dnxhd_init_vlc(ctx, cid)) < 0)
return -1; return ret;
if (buf_size < ctx->cid_table->coding_unit_size) { if (buf_size < ctx->cid_table->coding_unit_size) {
av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size\n"); av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size\n");
return -1; return AVERROR_INVALIDDATA;
} }
ctx->mb_width = ctx->width>>4; ctx->mb_width = ctx->width>>4;
...@@ -159,7 +159,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, ...@@ -159,7 +159,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
if (ctx->mb_height > 68 || if (ctx->mb_height > 68 ||
(ctx->mb_height << frame->interlaced_frame) > (ctx->height+15)>>4) { (ctx->mb_height << frame->interlaced_frame) > (ctx->height+15)>>4) {
av_log(ctx->avctx, AV_LOG_ERROR, "mb height too big: %d\n", ctx->mb_height); av_log(ctx->avctx, AV_LOG_ERROR, "mb height too big: %d\n", ctx->mb_height);
return -1; return AVERROR_INVALIDDATA;
} }
for (i = 0; i < ctx->mb_height; i++) { for (i = 0; i < ctx->mb_height; i++) {
...@@ -167,7 +167,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, ...@@ -167,7 +167,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
av_dlog(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]); av_dlog(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]);
if (buf_size < ctx->mb_scan_index[i] + 0x280) { if (buf_size < ctx->mb_scan_index[i] + 0x280) {
av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n"); av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n");
return -1; return AVERROR_INVALIDDATA;
} }
} }
...@@ -338,8 +338,8 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -338,8 +338,8 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
av_dlog(avctx, "frame size %d\n", buf_size); av_dlog(avctx, "frame size %d\n", buf_size);
decode_coding_unit: decode_coding_unit:
if (dnxhd_decode_header(ctx, picture, buf, buf_size, first_field) < 0) if ((ret = dnxhd_decode_header(ctx, picture, buf, buf_size, first_field)) < 0)
return -1; return ret;
if ((avctx->width || avctx->height) && if ((avctx->width || avctx->height) &&
(ctx->width != avctx->width || ctx->height != avctx->height)) { (ctx->width != avctx->width || ctx->height != avctx->height)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment