vc1: Fix mb_height for field pictures

Tables are always allocated now with sufficient space for either progressive
or interlaced content. The alternative would be to detect a change
and reallocate.

This fixes decoding of a sample.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Michael Niedermayer 2013-12-14 14:52:31 +01:00 committed by Martin Storsjö
parent bd316109b3
commit d8fd183683
2 changed files with 17 additions and 14 deletions

View File

@ -864,11 +864,13 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
v->fcm = fcm;
if (v->field_mode) {
v->s.mb_height = FFALIGN(v->s.height + 15 >> 4, 2);
v->fptype = get_bits(gb, 3);
v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
if (v->fptype & 4) // B-picture
v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
} else {
v->s.mb_height = v->s.height + 15 >> 4;
switch (get_unary(gb, 0, 4)) {
case 0:
v->s.pict_type = AV_PICTURE_TYPE_P;

View File

@ -5490,14 +5490,15 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
{
MpegEncContext *s = &v->s;
int i;
int mb_height = FFALIGN(s->mb_height, 2);
/* Allocate mb bitplanes */
v->mv_type_mb_plane = av_malloc (s->mb_stride * s->mb_height);
v->direct_mb_plane = av_malloc (s->mb_stride * s->mb_height);
v->forward_mb_plane = av_malloc (s->mb_stride * s->mb_height);
v->fieldtx_plane = av_mallocz(s->mb_stride * s->mb_height);
v->acpred_plane = av_malloc (s->mb_stride * s->mb_height);
v->over_flags_plane = av_malloc (s->mb_stride * s->mb_height);
v->mv_type_mb_plane = av_malloc (s->mb_stride * mb_height);
v->direct_mb_plane = av_malloc (s->mb_stride * mb_height);
v->forward_mb_plane = av_malloc (s->mb_stride * mb_height);
v->fieldtx_plane = av_mallocz(s->mb_stride * mb_height);
v->acpred_plane = av_malloc (s->mb_stride * mb_height);
v->over_flags_plane = av_malloc (s->mb_stride * mb_height);
v->n_allocated_blks = s->mb_width + 2;
v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks);
@ -5511,20 +5512,20 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
v->luma_mv = v->luma_mv_base + s->mb_stride;
/* allocate block type info in that way so it could be used with s->block_index[] */
v->mb_type_base = av_malloc(s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
v->mb_type_base = av_malloc(s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2);
v->mb_type[0] = v->mb_type_base + s->b8_stride + 1;
v->mb_type[1] = v->mb_type_base + s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride + 1;
v->mb_type[2] = v->mb_type[1] + s->mb_stride * (s->mb_height + 1);
v->mb_type[1] = v->mb_type_base + s->b8_stride * (mb_height * 2 + 1) + s->mb_stride + 1;
v->mb_type[2] = v->mb_type[1] + s->mb_stride * (mb_height + 1);
/* allocate memory to store block level MV info */
v->blk_mv_type_base = av_mallocz( s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
v->blk_mv_type_base = av_mallocz( s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2);
v->blk_mv_type = v->blk_mv_type_base + s->b8_stride + 1;
v->mv_f_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
v->mv_f_base = av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2));
v->mv_f[0] = v->mv_f_base + s->b8_stride + 1;
v->mv_f[1] = v->mv_f[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
v->mv_f_next_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
v->mv_f[1] = v->mv_f[0] + (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2);
v->mv_f_next_base = av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2));
v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1;
v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2);
/* Init coded blocks info */
if (v->profile == PROFILE_ADVANCED) {