diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-04-24 20:40:12 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-04-24 21:07:26 +0200 |
commit | 782ebd611824c95201123aeccc85809ce1554e6e (patch) | |
tree | 1e0d981915f02ac5ff3e52dd2ea83802e8d84bb9 /libavcodec/vc1dec.c | |
parent | 73050df2402cbe09f490145991442dd2baa83ec7 (diff) |
vc1dec: redesign the intensity compensation
The existing implementation had little to do with VC1.
This could be implemented by adjusting the reference frames
ithemselfs but that would make frame multi-threading difficult.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vc1dec.c')
-rw-r--r-- | libavcodec/vc1dec.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index d79d484c7e..050bd99405 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -351,6 +351,7 @@ static void vc1_mc_1mv(VC1Context *v, int dir) int off, off_uv; int v_edge_pos = s->v_edge_pos >> v->field_mode; int i; + const uint8_t *luty, *lutuv; if ((!v->field_mode || (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) && @@ -389,15 +390,21 @@ static void vc1_mc_1mv(VC1Context *v, int dir) srcY = s->current_picture.f.data[0]; srcU = s->current_picture.f.data[1]; srcV = s->current_picture.f.data[2]; + luty = v->curr_luty [v->ref_field_type[dir]]; + lutuv= v->curr_lutuv[v->ref_field_type[dir]]; } else { srcY = s->last_picture.f.data[0]; srcU = s->last_picture.f.data[1]; srcV = s->last_picture.f.data[2]; + luty = v->last_luty [v->ref_field_type[dir]]; + lutuv= v->last_lutuv[v->ref_field_type[dir]]; } } else { srcY = s->next_picture.f.data[0]; srcU = s->next_picture.f.data[1]; srcV = s->next_picture.f.data[2]; + luty = v->next_luty [v->ref_field_type[dir]]; + lutuv= v->next_lutuv[v->ref_field_type[dir]]; } if(!srcY) @@ -484,15 +491,15 @@ static void vc1_mc_1mv(VC1Context *v, int dir) src = srcY; for (j = 0; j < 17 + s->mspel * 2; j++) { for (i = 0; i < 17 + s->mspel * 2; i++) - src[i] = v->luty[src[i]]; + src[i] = luty[src[i]]; src += s->linesize; } src = srcU; src2 = srcV; for (j = 0; j < 9; j++) { for (i = 0; i < 9; i++) { - src[i] = v->lutuv[src[i]]; - src2[i] = v->lutuv[src2[i]]; + src[i] = lutuv[src[i]]; + src2[i] = lutuv[src2[i]]; } src += s->uvlinesize; src2 += s->uvlinesize; @@ -552,6 +559,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) int off; int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0; int v_edge_pos = s->v_edge_pos >> v->field_mode; + const uint8_t *luty; if ((!v->field_mode || (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) && @@ -564,10 +572,15 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) if (!dir) { if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) { srcY = s->current_picture.f.data[0]; - } else + luty = v->curr_luty[v->ref_field_type[dir]]; + } else { srcY = s->last_picture.f.data[0]; - } else + luty = v->last_luty[v->ref_field_type[dir]]; + } + } else { srcY = s->next_picture.f.data[0]; + luty = v->next_luty[v->ref_field_type[dir]]; + } if(!srcY) return; @@ -699,7 +712,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) src = srcY; for (j = 0; j < 9 + s->mspel * 2; j++) { for (i = 0; i < 9 + s->mspel * 2; i++) - src[i] = v->luty[src[i]]; + src[i] = luty[src[i]]; src += s->linesize << fieldmv; } } @@ -787,6 +800,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir) int valid_count; int chroma_ref_type = v->cur_field_type, off = 0; int v_edge_pos = s->v_edge_pos >> v->field_mode; + const uint8_t *lutuv; if (!v->field_mode && !v->s.last_picture.f.data[0]) return; @@ -852,13 +866,16 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir) if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) { srcU = s->current_picture.f.data[1]; srcV = s->current_picture.f.data[2]; + lutuv= v->curr_lutuv[chroma_ref_type]; } else { srcU = s->last_picture.f.data[1]; srcV = s->last_picture.f.data[2]; + lutuv= v->last_lutuv[chroma_ref_type]; } } else { srcU = s->next_picture.f.data[1]; srcV = s->next_picture.f.data[2]; + lutuv= v->next_lutuv[chroma_ref_type]; } if(!srcU) @@ -913,8 +930,8 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir) src2 = srcV; for (j = 0; j < 9; j++) { for (i = 0; i < 9; i++) { - src[i] = v->lutuv[src[i]]; - src2[i] = v->lutuv[src2[i]]; + src[i] = lutuv[src[i]]; + src2[i] = lutuv[src2[i]]; } src += s->uvlinesize; src2 += s->uvlinesize; @@ -998,13 +1015,14 @@ static void vc1_mc_4mv_chroma4(VC1Context *v) if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int i, j; uint8_t *src, *src2; + const uint8_t *lutuv = v->last_lutuv[v->ref_field_type[0]]; src = srcU; src2 = srcV; for (j = 0; j < 5; j++) { for (i = 0; i < 5; i++) { - src[i] = v->lutuv[src[i]]; - src2[i] = v->lutuv[src2[i]]; + src[i] = lutuv[src[i]]; + src2[i] = lutuv[src2[i]]; } src += s->uvlinesize << 1; src2 += s->uvlinesize << 1; @@ -1998,29 +2016,30 @@ static av_always_inline int scale_mv(int value, int bfrac, int inv, int qs) static inline void vc1_b_mc(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mode) { - if (v->use_ic) { + int use_ic = v->next_use_ic || v->curr_use_ic || v->last_use_ic; + if (use_ic) { v->mv_mode2 = v->mv_mode; v->mv_mode = MV_PMODE_INTENSITY_COMP; } if (direct) { vc1_mc_1mv(v, 0); vc1_interp_mc(v); - if (v->use_ic) + if (use_ic) v->mv_mode = v->mv_mode2; return; } if (mode == BMV_TYPE_INTERPOLATED) { vc1_mc_1mv(v, 0); vc1_interp_mc(v); - if (v->use_ic) + if (use_ic) v->mv_mode = v->mv_mode2; return; } - if (v->use_ic && (mode == BMV_TYPE_BACKWARD)) + if (use_ic && (mode == BMV_TYPE_BACKWARD)) v->mv_mode = v->mv_mode2; vc1_mc_1mv(v, (mode == BMV_TYPE_BACKWARD)); - if (v->use_ic) + if (use_ic) v->mv_mode = v->mv_mode2; } |