[FFmpeg-cvslog] vc1dec: add avg & variable direction support to vc1_mc_4mv_chroma4()
Michael Niedermayer
git at videolan.org
Thu Apr 25 22:42:49 CEST 2013
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Apr 25 21:30:41 2013 +0200| [9b49d3974e9f8ff5f0e65710231e9daf839f699f] | committer: Michael Niedermayer
vc1dec: add avg & variable direction support to vc1_mc_4mv_chroma4()
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b49d3974e9f8ff5f0e65710231e9daf839f699f
---
libavcodec/vc1dec.c | 51 +++++++++++++++++++++++++++++++++++----------------
1 file changed, 35 insertions(+), 16 deletions(-)
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 3c29164..dc56952 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -965,7 +965,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
/** Do motion compensation for 4-MV interlaced frame chroma macroblock (both U and V)
*/
-static void vc1_mc_4mv_chroma4(VC1Context *v)
+static void vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
{
MpegEncContext *s = &v->s;
H264ChromaContext *h264chroma = &v->h264chroma;
@@ -977,17 +977,17 @@ static void vc1_mc_4mv_chroma4(VC1Context *v)
static const int s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
int v_dist = fieldmv ? 1 : 4; // vertical offset for lower sub-blocks
int v_edge_pos = s->v_edge_pos >> 1;
- int use_ic = v->last_use_ic;
+ int use_ic;
+ uint8_t (*lutuv)[256];
- if (!v->s.last_picture.f.data[0])
- return;
if (s->flags & CODEC_FLAG_GRAY)
return;
for (i = 0; i < 4; i++) {
- tx = s->mv[0][i][0];
+ int d = i<2 ? dir: dir2;
+ tx = s->mv[d][i][0];
uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
- ty = s->mv[0][i][1];
+ ty = s->mv[d][i][1];
if (fieldmv)
uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
else
@@ -1001,8 +1001,17 @@ static void vc1_mc_4mv_chroma4(VC1Context *v)
// FIXME: implement proper pull-back (see vc1cropmv.c, vc1CROPMV_ChromaPullBack())
uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
- srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
- srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
+ if (i < 2 ? dir : dir2) {
+ srcU = s->next_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
+ srcV = s->next_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
+ lutuv = v->next_lutuv;
+ use_ic = v->next_use_ic;
+ } else {
+ srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
+ srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
+ lutuv = v->last_lutuv;
+ use_ic = v->last_use_ic;
+ }
uvmx_field[i] = (uvmx_field[i] & 3) << 1;
uvmy_field[i] = (uvmy_field[i] & 3) << 1;
@@ -1028,20 +1037,29 @@ static void vc1_mc_4mv_chroma4(VC1Context *v)
if (use_ic) {
int i, j;
uint8_t *src, *src2;
- const uint8_t *lutuv = v->last_lutuv[v->ref_field_type[0]];
+ const uint8_t *lutuv1 = lutuv[v->ref_field_type[i<2 ? dir : dir2]];
src = srcU;
src2 = srcV;
for (j = 0; j < 5; j++) {
for (i = 0; i < 5; i++) {
- src[i] = lutuv[src[i]];
- src2[i] = lutuv[src2[i]];
+ src[i] = lutuv1[src[i]];
+ src2[i] = lutuv1[src2[i]];
}
src += s->uvlinesize << 1;
src2 += s->uvlinesize << 1;
}
}
}
+ if (avg) {
+ if (!v->rnd) {
+ h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
+ h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
+ } else {
+ v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
+ v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
+ }
+ } else {
if (!v->rnd) {
h264chroma->put_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
h264chroma->put_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
@@ -1049,6 +1067,7 @@ static void vc1_mc_4mv_chroma4(VC1Context *v)
v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
}
+ }
}
}
@@ -3865,7 +3884,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v)
vc1_pred_mv_intfr(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], 0);
vc1_mc_4mv_luma(v, i, 0, 0);
} else if (i == 4) {
- vc1_mc_4mv_chroma4(v);
+ vc1_mc_4mv_chroma4(v, 0, 0, 0);
}
}
} else if (twomv) {
@@ -3884,7 +3903,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v)
vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0], 0);
vc1_mc_4mv_luma(v, 2, 0, 0);
vc1_mc_4mv_luma(v, 3, 0, 0);
- vc1_mc_4mv_chroma4(v);
+ vc1_mc_4mv_chroma4(v, 0, 0, 0);
} else {
mvbp = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][2];
dmv_x = dmv_y = 0;
@@ -4533,7 +4552,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
vc1_mc_4mv_luma(v, i, 0, 0);
vc1_mc_4mv_luma(v, i, 1, 1);
}
- vc1_mc_4mv_chroma4(v);
+ vc1_mc_4mv_chroma4(v, 0, 0, 0);
} else {
vc1_mc_1mv(v, 0);
vc1_interp_mc(v);
@@ -4553,7 +4572,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
vc1_mc_4mv_luma(v, j+1, dir, dir);
}
- vc1_mc_4mv_chroma4(v);
+ vc1_mc_4mv_chroma4(v, 0, 0, 0);
} else if (bmvtype == BMV_TYPE_INTERPOLATED) {
mvbp = v->twomvbp;
dmv_x = dmv_y = 0;
@@ -4605,7 +4624,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
vc1_mc_4mv_luma(v, 1, dir, 0);
vc1_mc_4mv_luma(v, 2, dir2, 0);
vc1_mc_4mv_luma(v, 3, dir2, 0);
- vc1_mc_4mv_chroma4(v);
+ vc1_mc_4mv_chroma4(v, 0, 0, 0);
} else {
dir = bmvtype == BMV_TYPE_BACKWARD;
More information about the ffmpeg-cvslog
mailing list