mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/vc1: fix mb_height for field pictures
Fixes ticket2531 Tables are always allocated now with sufficient space for either progressive or interlaced content. The alternative would be to detect a change and reallocate. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
c65fe9e982
commit
017e234c20
@ -860,12 +860,17 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
|
||||
v->field_mode = field_mode;
|
||||
v->fcm = fcm;
|
||||
|
||||
av_assert0( v->s.mb_height == v->s.height + 15 >> 4
|
||||
|| v->s.mb_height == FFALIGN(v->s.height + 15 >> 4, 2));
|
||||
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;
|
||||
|
@ -5498,14 +5498,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);
|
||||
@ -5519,20 +5520,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) {
|
||||
@ -6105,6 +6106,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
continue;
|
||||
}
|
||||
v->second_field = 1;
|
||||
av_assert0((s->mb_height & 1) == 0);
|
||||
v->blocks_off = s->b8_stride * (s->mb_height&~1);
|
||||
v->mb_off = s->mb_stride * s->mb_height >> 1;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user