Commit c5f74b1e authored by Jerome Borsboom's avatar Jerome Borsboom Committed by Paul B Mahol

avcodec/vc1: store additional bitstream elements during MB decoding

The new loop filter needs additional MB properties to make its filtering
decisions.
Signed-off-by: 's avatarJerome Borsboom <jerome.borsboom@carpalis.nl>
parent ded52f6e
...@@ -1595,6 +1595,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) ...@@ -1595,6 +1595,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v)
s->dest[dst_idx] + off, s->dest[dst_idx] + off,
stride_y); stride_y);
//TODO: loop filter //TODO: loop filter
block_cbp |= 0xf << (i << 2);
} }
} else { // inter MB } else { // inter MB
...@@ -1690,9 +1691,11 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) ...@@ -1690,9 +1691,11 @@ static int vc1_decode_p_mb_intfr(VC1Context *v)
v->blk_mv_type[s->block_index[3]] = 0; v->blk_mv_type[s->block_index[3]] = 0;
ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 0); ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 0);
ff_vc1_mc_1mv(v, 0); ff_vc1_mc_1mv(v, 0);
v->fieldtx_plane[mb_pos] = 0;
} }
if (s->mb_x == s->mb_width - 1) v->cbp[s->mb_x] = block_cbp;
memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride); v->ttblk[s->mb_x] = block_tt;
return 0; return 0;
} }
...@@ -1756,6 +1759,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) ...@@ -1756,6 +1759,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v)
(i & 4) ? s->uvlinesize (i & 4) ? s->uvlinesize
: s->linesize); : s->linesize);
// TODO: loop filter // TODO: loop filter
block_cbp |= 0xf << (i << 2);
} }
} else { } else {
s->mb_intra = v->is_intra[s->mb_x] = 0; s->mb_intra = v->is_intra[s->mb_x] = 0;
...@@ -1810,8 +1814,9 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) ...@@ -1810,8 +1814,9 @@ static int vc1_decode_p_mb_intfi(VC1Context *v)
} }
} }
} }
if (s->mb_x == s->mb_width - 1) v->cbp[s->mb_x] = block_cbp;
memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride); v->ttblk[s->mb_x] = block_tt;
return 0; return 0;
} }
...@@ -1988,6 +1993,7 @@ static void vc1_decode_b_mb_intfi(VC1Context *v) ...@@ -1988,6 +1993,7 @@ static void vc1_decode_b_mb_intfi(VC1Context *v)
int fwd; int fwd;
int dmv_x[2], dmv_y[2], pred_flag[2]; int dmv_x[2], dmv_y[2], pred_flag[2];
int bmvtype = BMV_TYPE_BACKWARD; int bmvtype = BMV_TYPE_BACKWARD;
int block_cbp = 0, pat, block_tt = 0;
int idx_mbmode; int idx_mbmode;
mquant = v->pq; /* Lossy initialization */ mquant = v->pq; /* Lossy initialization */
...@@ -2118,16 +2124,19 @@ static void vc1_decode_b_mb_intfi(VC1Context *v) ...@@ -2118,16 +2124,19 @@ static void vc1_decode_b_mb_intfi(VC1Context *v)
val = ((cbp >> (5 - i)) & 1); val = ((cbp >> (5 - i)) & 1);
off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize; off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
if (val) { if (val) {
vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
first_block, s->dest[dst_idx] + off, first_block, s->dest[dst_idx] + off,
(i & 4) ? s->uvlinesize : s->linesize, (i & 4) ? s->uvlinesize : s->linesize,
CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), NULL); CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
block_cbp |= pat << (i << 2);
if (!v->ttmbf && ttmb < 8) if (!v->ttmbf && ttmb < 8)
ttmb = -1; ttmb = -1;
first_block = 0; first_block = 0;
} }
} }
} }
v->cbp[s->mb_x] = block_cbp;
v->ttblk[s->mb_x] = block_tt;
} }
/** Decode one B-frame MB (in interlaced frame B picture) /** Decode one B-frame MB (in interlaced frame B picture)
...@@ -2468,12 +2477,12 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) ...@@ -2468,12 +2477,12 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
if (direct || bmvtype == BMV_TYPE_INTERPOLATED) { if (direct || bmvtype == BMV_TYPE_INTERPOLATED) {
ff_vc1_interp_mc(v); ff_vc1_interp_mc(v);
} }
v->fieldtx_plane[mb_pos] = 0;
} }
} }
if (s->mb_x == s->mb_width - 1)
memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride);
v->cbp[s->mb_x] = block_cbp; v->cbp[s->mb_x] = block_cbp;
v->ttblk[s->mb_x] = block_tt; v->ttblk[s->mb_x] = block_tt;
return 0; return 0;
} }
...@@ -2703,6 +2712,8 @@ static void vc1_decode_i_blocks_adv(VC1Context *v) ...@@ -2703,6 +2712,8 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
s->c_dc_scale = s->c_dc_scale_table[mquant]; s->c_dc_scale = s->c_dc_scale_table[mquant];
for (k = 0; k < 6; k++) { for (k = 0; k < 6; k++) {
v->mb_type[0][s->block_index[k]] = 1;
val = ((cbp >> (5 - k)) & 1); val = ((cbp >> (5 - k)) & 1);
if (k < 4) { if (k < 4) {
...@@ -2799,7 +2810,7 @@ static void vc1_decode_p_blocks(VC1Context *v) ...@@ -2799,7 +2810,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY) && apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY) &&
v->fcm == PROGRESSIVE; v->fcm == PROGRESSIVE;
s->first_slice_line = 1; s->first_slice_line = 1;
memset(v->cbp_base, 0, sizeof(v->cbp_base[0])*2*s->mb_stride); memset(v->cbp_base, 0, sizeof(v->cbp_base[0]) * 3 * s->mb_stride);
for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
s->mb_x = 0; s->mb_x = 0;
init_block_index(v); init_block_index(v);
...@@ -2825,10 +2836,18 @@ static void vc1_decode_p_blocks(VC1Context *v) ...@@ -2825,10 +2836,18 @@ static void vc1_decode_p_blocks(VC1Context *v)
inc_blk_idx(v->left_blk_idx); inc_blk_idx(v->left_blk_idx);
inc_blk_idx(v->cur_blk_idx); inc_blk_idx(v->cur_blk_idx);
} }
memmove(v->cbp_base, v->cbp, sizeof(v->cbp_base[0]) * s->mb_stride); memmove(v->cbp_base,
memmove(v->ttblk_base, v->ttblk, sizeof(v->ttblk_base[0]) * s->mb_stride); v->cbp - s->mb_stride,
memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride); sizeof(v->cbp_base[0]) * 2 * s->mb_stride);
memmove(v->luma_mv_base, v->luma_mv, sizeof(v->luma_mv_base[0]) * s->mb_stride); memmove(v->ttblk_base,
v->ttblk - s->mb_stride,
sizeof(v->ttblk_base[0]) * 2 * s->mb_stride);
memmove(v->is_intra_base,
v->is_intra - s->mb_stride,
sizeof(v->is_intra_base[0]) * 2 * s->mb_stride);
memmove(v->luma_mv_base,
v->luma_mv - s->mb_stride,
sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride);
if (s->mb_y != s->start_mb_y) if (s->mb_y != s->start_mb_y)
ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16); ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
s->first_slice_line = 0; s->first_slice_line = 0;
...@@ -2899,6 +2918,15 @@ static void vc1_decode_b_blocks(VC1Context *v) ...@@ -2899,6 +2918,15 @@ static void vc1_decode_b_blocks(VC1Context *v)
if (v->s.loop_filter) if (v->s.loop_filter)
ff_vc1_loop_filter_iblk(v, v->pq); ff_vc1_loop_filter_iblk(v, v->pq);
} }
memmove(v->cbp_base,
v->cbp - s->mb_stride,
sizeof(v->cbp_base[0]) * 2 * s->mb_stride);
memmove(v->ttblk_base,
v->ttblk - s->mb_stride,
sizeof(v->ttblk_base[0]) * 2 * s->mb_stride);
memmove(v->is_intra_base,
v->is_intra - s->mb_stride,
sizeof(v->is_intra_base[0]) * 2 * s->mb_stride);
if (!v->s.loop_filter) if (!v->s.loop_filter)
ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16); ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
else if (s->mb_y) else if (s->mb_y)
......
...@@ -340,22 +340,22 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v) ...@@ -340,22 +340,22 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
v->n_allocated_blks = s->mb_width + 2; v->n_allocated_blks = s->mb_width + 2;
v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks); v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks);
v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride); v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 3 * s->mb_stride);
if (!v->block || !v->cbp_base) if (!v->block || !v->cbp_base)
goto error; goto error;
v->cbp = v->cbp_base + s->mb_stride; v->cbp = v->cbp_base + 2 * s->mb_stride;
v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride); v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 3 * s->mb_stride);
if (!v->ttblk_base) if (!v->ttblk_base)
goto error; goto error;
v->ttblk = v->ttblk_base + s->mb_stride; v->ttblk = v->ttblk_base + 2 * s->mb_stride;
v->is_intra_base = av_mallocz(sizeof(v->is_intra_base[0]) * 2 * s->mb_stride); v->is_intra_base = av_mallocz(sizeof(v->is_intra_base[0]) * 3 * s->mb_stride);
if (!v->is_intra_base) if (!v->is_intra_base)
goto error; goto error;
v->is_intra = v->is_intra_base + s->mb_stride; v->is_intra = v->is_intra_base + 2 * s->mb_stride;
v->luma_mv_base = av_mallocz(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride); v->luma_mv_base = av_mallocz(sizeof(v->luma_mv_base[0]) * 3 * s->mb_stride);
if (!v->luma_mv_base) if (!v->luma_mv_base)
goto error; goto error;
v->luma_mv = v->luma_mv_base + s->mb_stride; v->luma_mv = v->luma_mv_base + 2 * s->mb_stride;
/* allocate block type info in that way so it could be used with s->block_index[] */ /* 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 * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2); v->mb_type_base = av_malloc(s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2);
......
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