comparison dnxhddec.c @ 11424:02f402b73d62 libavcodec

Fix interlaced vc-3 decoding, issue #1753
author bcoudurier
date Tue, 09 Mar 2010 00:37:13 +0000
parents 98970e51365a
children 8a4984c5cacc
comparison
equal deleted inserted replaced
11423:c2e932f83f99 11424:02f402b73d62
124 } 124 }
125 125
126 ctx->mb_width = ctx->width>>4; 126 ctx->mb_width = ctx->width>>4;
127 ctx->mb_height = buf[0x16d]; 127 ctx->mb_height = buf[0x16d];
128 128
129 if (ctx->mb_height > 68) {
130 av_log(ctx->avctx, AV_LOG_ERROR, "mb height too big\n");
131 return -1;
132 }
133
134 dprintf(ctx->avctx, "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height); 129 dprintf(ctx->avctx, "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height);
130
131 if ((ctx->height+15)>>4 == ctx->mb_height && ctx->picture.interlaced_frame)
132 ctx->height <<= 1;
133
134 if (ctx->mb_height > 68 ||
135 (ctx->mb_height<<ctx->picture.interlaced_frame) > (ctx->height+15)>>4) {
136 av_log(ctx->avctx, AV_LOG_ERROR, "mb height too big: %d\n", ctx->mb_height);
137 return -1;
138 }
139
135 for (i = 0; i < ctx->mb_height; i++) { 140 for (i = 0; i < ctx->mb_height; i++) {
136 ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i<<2)); 141 ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i<<2));
137 dprintf(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]); 142 dprintf(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]);
138 if (buf_size < ctx->mb_scan_index[i] + 0x280) { 143 if (buf_size < ctx->mb_scan_index[i] + 0x280) {
139 av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n"); 144 av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n");
290 295
291 decode_coding_unit: 296 decode_coding_unit:
292 if (dnxhd_decode_header(ctx, buf, buf_size, first_field) < 0) 297 if (dnxhd_decode_header(ctx, buf, buf_size, first_field) < 0)
293 return -1; 298 return -1;
294 299
300 if ((avctx->width || avctx->height) &&
301 (ctx->width != avctx->width || ctx->height != avctx->height)) {
302 av_log(avctx, AV_LOG_WARNING, "frame size changed: %dx%d -> %dx%d\n",
303 avctx->width, avctx->height, ctx->width, ctx->height);
304 first_field = 1;
305 }
306
295 avctx->pix_fmt = PIX_FMT_YUV422P; 307 avctx->pix_fmt = PIX_FMT_YUV422P;
296 if (avcodec_check_dimensions(avctx, ctx->width, ctx->height)) 308 if (avcodec_check_dimensions(avctx, ctx->width, ctx->height))
297 return -1; 309 return -1;
298 avcodec_set_dimensions(avctx, ctx->width, ctx->height); 310 avcodec_set_dimensions(avctx, ctx->width, ctx->height);
299 311