Commit 03136539 authored by Michael Niedermayer's avatar Michael Niedermayer Committed by Martin Storsjö

vc1dec: Update destination pointers in context for fields

This replaces a large number of checks for the second field by
fixing the pointers when they are setup.

This should also fix I/BI field pictures.

Changes checksums for vc1_sa10143, the file becomes slightly closer
to what the reference decoder outputs.

Based on "vc1dec: the second field is written wrong to the picture"
by Sebastian Sandberg <sebastiand.sandberg@gmail.com>.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent e6c4ac7b
......@@ -73,6 +73,16 @@ enum Imode {
};
/** @} */ //imode defines
static void init_block_index(VC1Context *v)
{
MpegEncContext *s = &v->s;
ff_init_block_index(s);
if (v->field_mode && v->second_field) {
s->dest[0] += s->current_picture_ptr->f.linesize[0];
s->dest[1] += s->current_picture_ptr->f.linesize[1];
s->dest[2] += s->current_picture_ptr->f.linesize[2];
}
}
/** @} */ //Bitplane group
......@@ -495,13 +505,8 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
srcY += s->mspel * (1 + s->linesize);
}
if (v->field_mode && v->cur_field_type) {
off = s->current_picture_ptr->f.linesize[0];
off_uv = s->current_picture_ptr->f.linesize[1];
} else {
off = 0;
off_uv = 0;
}
if (s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off , srcY , s->linesize, v->rnd);
......@@ -631,8 +636,6 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir)
off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8;
else
off = s->linesize * 4 * (n & 2) + (n & 1) * 8;
if (v->field_mode && v->cur_field_type)
off += s->current_picture_ptr->f.linesize[0];
src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2);
if (!fieldmv)
......@@ -863,7 +866,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
srcU += s->current_picture_ptr->f.linesize[1];
srcV += s->current_picture_ptr->f.linesize[2];
}
off = v->cur_field_type ? s->current_picture_ptr->f.linesize[1] : 0;
off = 0;
}
if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
......@@ -1930,13 +1933,8 @@ static void vc1_interp_mc(VC1Context *v)
srcY += s->mspel * (1 + s->linesize);
}
if (v->field_mode && v->cur_field_type) {
off = s->current_picture_ptr->f.linesize[0];
off_uv = s->current_picture_ptr->f.linesize[1];
} else {
off = 0;
off_uv = 0;
}
if (s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
......@@ -3940,7 +3938,6 @@ static int vc1_decode_p_mb_intfi(VC1Context *v)
continue;
v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
off += v->cur_field_type ? ((i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]) : 0;
s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);
// TODO: loop filter
}
......@@ -3987,8 +3984,6 @@ static int vc1_decode_p_mb_intfi(VC1Context *v)
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
if (v->cur_field_type)
off += (i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0];
if (val) {
pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
first_block, s->dest[dst_idx] + off,
......@@ -4217,7 +4212,6 @@ static void vc1_decode_b_mb_intfi(VC1Context *v)
for (j = 0; j < 64; j++)
s->block[i][j] <<= 1;
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
off += v->cur_field_type ? ((i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]) : 0;
s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);
// TODO: yet to perform loop filter
}
......@@ -4299,8 +4293,6 @@ static void vc1_decode_b_mb_intfi(VC1Context *v)
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
if (v->cur_field_type)
off += (i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0];
if (val) {
vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
first_block, s->dest[dst_idx] + off,
......@@ -4359,7 +4351,7 @@ static void vc1_decode_i_blocks(VC1Context *v)
s->first_slice_line = 1;
for (s->mb_y = 0; s->mb_y < s->end_mb_y; s->mb_y++) {
s->mb_x = 0;
ff_init_block_index(s);
init_block_index(v);
for (; s->mb_x < v->end_mb_x; s->mb_x++) {
uint8_t *dst[6];
ff_update_block_index(s);
......@@ -4499,13 +4491,13 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
s->mb_y = s->start_mb_y;
if (s->start_mb_y) {
s->mb_x = 0;
ff_init_block_index(s);
init_block_index(v);
memset(&s->coded_block[s->block_index[0] - s->b8_stride], 0,
(1 + s->b8_stride) * sizeof(*s->coded_block));
}
for (; s->mb_y < s->end_mb_y; s->mb_y++) {
s->mb_x = 0;
ff_init_block_index(s);
init_block_index(v);
for (;s->mb_x < s->mb_width; s->mb_x++) {
int16_t (*block)[64] = v->block[v->cur_blk_idx];
ff_update_block_index(s);
......@@ -4576,7 +4568,8 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
/* raw bottom MB row */
s->mb_x = 0;
ff_init_block_index(s);
init_block_index(v);
for (;s->mb_x < s->mb_width; s->mb_x++) {
ff_update_block_index(s);
vc1_put_signed_blocks_clamped(v);
......@@ -4625,7 +4618,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
memset(v->cbp_base, 0, sizeof(v->cbp_base[0])*2*s->mb_stride);
for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
s->mb_x = 0;
ff_init_block_index(s);
init_block_index(v);
for (; s->mb_x < s->mb_width; s->mb_x++) {
ff_update_block_index(s);
......@@ -4653,7 +4646,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
}
if (apply_loop_filter) {
s->mb_x = 0;
ff_init_block_index(s);
init_block_index(v);
for (; s->mb_x < s->mb_width; s->mb_x++) {
ff_update_block_index(s);
vc1_apply_p_loop_filter(v);
......@@ -4697,7 +4690,7 @@ static void vc1_decode_b_blocks(VC1Context *v)
s->first_slice_line = 1;
for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
s->mb_x = 0;
ff_init_block_index(s);
init_block_index(v);
for (; s->mb_x < s->mb_width; s->mb_x++) {
ff_update_block_index(s);
......@@ -4734,7 +4727,7 @@ static void vc1_decode_skip_blocks(VC1Context *v)
s->first_slice_line = 1;
for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
s->mb_x = 0;
ff_init_block_index(s);
init_block_index(v);
ff_update_block_index(s);
memcpy(s->dest[0], s->last_picture.f.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16);
memcpy(s->dest[1], s->last_picture.f.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
......
#tb 0: 1/25
0, 0, 0, 1, 518400, 0x89407f55
0, 2, 2, 1, 518400, 0x1480849d
0, 2, 2, 1, 518400, 0x8611849c
0, 3, 3, 1, 518400, 0x0e69ff59
0, 4, 4, 1, 518400, 0x00d6db06
0, 4, 4, 1, 518400, 0xf31adb03
0, 5, 5, 1, 518400, 0x1a5b6a69
0, 6, 6, 1, 518400, 0xc1a1232e
0, 6, 6, 1, 518400, 0x6ae6232e
0, 7, 7, 1, 518400, 0x9a4e3c54
0, 8, 8, 1, 518400, 0x04122b44
0, 8, 8, 1, 518400, 0xe5852b45
0, 9, 9, 1, 518400, 0x0fcfeebc
0, 10, 10, 1, 518400, 0xc7882dc1
0, 10, 10, 1, 518400, 0x06e22dc3
0, 11, 11, 1, 518400, 0x9d79df09
0, 12, 12, 1, 518400, 0xff6b716f
0, 12, 12, 1, 518400, 0xcb2c716f
0, 13, 13, 1, 518400, 0x638a8746
0, 14, 14, 1, 518400, 0x07572efb
0, 14, 14, 1, 518400, 0xf7032efd
0, 15, 15, 1, 518400, 0x306f6cef
0, 16, 16, 1, 518400, 0xd7602518
0, 16, 16, 1, 518400, 0xe83d2518
0, 17, 17, 1, 518400, 0x49ab5bf5
0, 18, 18, 1, 518400, 0x3c736b6c
0, 18, 18, 1, 518400, 0x6b336b6f
0, 19, 19, 1, 518400, 0x95ae00c9
0, 20, 20, 1, 518400, 0x7b9ab64e
0, 20, 20, 1, 518400, 0x68ddb64f
0, 21, 21, 1, 518400, 0x5205ea68
0, 22, 22, 1, 518400, 0xb486e618
0, 22, 22, 1, 518400, 0xb088e617
0, 23, 23, 1, 518400, 0xa3217616
0, 24, 24, 1, 518400, 0xc66bbc56
0, 24, 24, 1, 518400, 0x1723bc53
0, 25, 25, 1, 518400, 0xf024872a
0, 26, 26, 1, 518400, 0x97d2a8ba
0, 26, 26, 1, 518400, 0x2e81a8bb
0, 27, 27, 1, 518400, 0xa3a2418e
0, 28, 28, 1, 518400, 0x08460005
0, 28, 28, 1, 518400, 0xb7beffed
0, 29, 29, 1, 518400, 0x50fb6c94
0, 30, 30, 1, 518400, 0x5584bb40
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