[FFmpeg-devel] [PATCH] vc1dec: Fix destination pointers in context for fields
Michael Niedermayer
michaelni at gmx.at
Fri Feb 1 20:04:33 CET 2013
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
Based on "vc1dec: the second field is written wrong to the picture"
by Sebastian Sandberg <sebastiand.sandberg at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavcodec/vc1dec.c | 48 +++++++++++++++++++++---------------------------
1 file changed, 21 insertions(+), 27 deletions(-)
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 05307c1..1ec2d1b 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -73,6 +73,17 @@ 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
@@ -498,13 +509,8 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
srcY += s->mspel * (1 + s->linesize);
}
- if (v->field_mode && v->second_field) {
- 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);
@@ -640,8 +646,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->second_field)
- off += s->current_picture_ptr->f.linesize[0];
src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2);
if (!fieldmv)
@@ -878,7 +882,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->second_field ? s->current_picture_ptr->f.linesize[1] : 0;
+ off = 0;
}
if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
@@ -1948,13 +1952,8 @@ static void vc1_interp_mc(VC1Context *v)
srcY += s->mspel * (1 + s->linesize);
}
- if (v->field_mode && v->second_field) {
- 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);
@@ -3958,7 +3957,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->second_field ? ((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
}
@@ -4005,8 +4003,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->second_field)
- 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,
@@ -4235,7 +4231,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->second_field ? ((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
}
@@ -4317,8 +4312,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->second_field)
- 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,
@@ -4377,7 +4370,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);
@@ -4517,13 +4510,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);
@@ -4594,7 +4587,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);
@@ -4642,7 +4636,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);
@@ -4670,7 +4664,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
}
if (apply_loop_filter && v->fcm == PROGRESSIVE) {
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);
@@ -4714,7 +4708,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);
@@ -4751,7 +4745,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);
if (s->last_picture.f.data[0]) {
memcpy(s->dest[0], s->last_picture.f.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16);
--
1.7.9.5
More information about the ffmpeg-devel
mailing list