Commit 7e30bfcb authored by Michael Niedermayer's avatar Michael Niedermayer

vc1dec: Fix mixed field/frame intensity compensation

Fixes Ticket2523
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 90c2e40e
...@@ -351,7 +351,7 @@ static void vc1_mc_1mv(VC1Context *v, int dir) ...@@ -351,7 +351,7 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
int off, off_uv; int off, off_uv;
int v_edge_pos = s->v_edge_pos >> v->field_mode; int v_edge_pos = s->v_edge_pos >> v->field_mode;
int i; int i;
const uint8_t *luty, *lutuv; uint8_t (*luty)[256], (*lutuv)[256];
int use_ic; int use_ic;
if ((!v->field_mode || if ((!v->field_mode ||
...@@ -391,23 +391,23 @@ static void vc1_mc_1mv(VC1Context *v, int dir) ...@@ -391,23 +391,23 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
srcY = s->current_picture.f.data[0]; srcY = s->current_picture.f.data[0];
srcU = s->current_picture.f.data[1]; srcU = s->current_picture.f.data[1];
srcV = s->current_picture.f.data[2]; srcV = s->current_picture.f.data[2];
luty = v->curr_luty [v->ref_field_type[dir]]; luty = v->curr_luty;
lutuv= v->curr_lutuv[v->ref_field_type[dir]]; lutuv= v->curr_lutuv;
use_ic=v->curr_use_ic; use_ic=v->curr_use_ic;
} else { } else {
srcY = s->last_picture.f.data[0]; srcY = s->last_picture.f.data[0];
srcU = s->last_picture.f.data[1]; srcU = s->last_picture.f.data[1];
srcV = s->last_picture.f.data[2]; srcV = s->last_picture.f.data[2];
luty = v->last_luty [v->ref_field_type[dir]]; luty = v->last_luty ;
lutuv= v->last_lutuv[v->ref_field_type[dir]]; lutuv= v->last_lutuv;
use_ic=v->last_use_ic; use_ic=v->last_use_ic;
} }
} else { } else {
srcY = s->next_picture.f.data[0]; srcY = s->next_picture.f.data[0];
srcU = s->next_picture.f.data[1]; srcU = s->next_picture.f.data[1];
srcV = s->next_picture.f.data[2]; srcV = s->next_picture.f.data[2];
luty = v->next_luty [v->ref_field_type[dir]]; luty = v->next_luty ;
lutuv= v->next_lutuv[v->ref_field_type[dir]]; lutuv= v->next_lutuv;
use_ic=v->next_use_ic; use_ic=v->next_use_ic;
} }
...@@ -494,16 +494,18 @@ static void vc1_mc_1mv(VC1Context *v, int dir) ...@@ -494,16 +494,18 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
src = srcY; src = srcY;
for (j = 0; j < 17 + s->mspel * 2; j++) { for (j = 0; j < 17 + s->mspel * 2; j++) {
int f = v->field_mode ? v->ref_field_type[dir] : ((j + src_y - s->mspel)&1) ;
for (i = 0; i < 17 + s->mspel * 2; i++) for (i = 0; i < 17 + s->mspel * 2; i++)
src[i] = luty[src[i]]; src[i] = luty[f][src[i]];
src += s->linesize; src += s->linesize;
} }
src = srcU; src = srcU;
src2 = srcV; src2 = srcV;
for (j = 0; j < 9; j++) { for (j = 0; j < 9; j++) {
int f = v->field_mode ? v->ref_field_type[dir] : ((j + uvsrc_y)&1);
for (i = 0; i < 9; i++) { for (i = 0; i < 9; i++) {
src[i] = lutuv[src[i]]; src[i] = lutuv[f][src[i]];
src2[i] = lutuv[src2[i]]; src2[i] = lutuv[f][src2[i]];
} }
src += s->uvlinesize; src += s->uvlinesize;
src2 += s->uvlinesize; src2 += s->uvlinesize;
...@@ -563,7 +565,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) ...@@ -563,7 +565,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
int off; int off;
int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0; 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; int v_edge_pos = s->v_edge_pos >> v->field_mode;
const uint8_t *luty; uint8_t (*luty)[256];
int use_ic; int use_ic;
if ((!v->field_mode || if ((!v->field_mode ||
...@@ -577,16 +579,16 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) ...@@ -577,16 +579,16 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
if (!dir) { if (!dir) {
if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) { if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
srcY = s->current_picture.f.data[0]; srcY = s->current_picture.f.data[0];
luty = v->curr_luty[v->ref_field_type[dir]]; luty = v->curr_luty;
use_ic=v->curr_use_ic; use_ic=v->curr_use_ic;
} else { } else {
srcY = s->last_picture.f.data[0]; srcY = s->last_picture.f.data[0];
luty = v->last_luty[v->ref_field_type[dir]]; luty = v->last_luty;
use_ic=v->last_use_ic; use_ic=v->last_use_ic;
} }
} else { } else {
srcY = s->next_picture.f.data[0]; srcY = s->next_picture.f.data[0];
luty = v->next_luty[v->ref_field_type[dir]]; luty = v->next_luty;
use_ic=v->next_use_ic; use_ic=v->next_use_ic;
} }
...@@ -719,8 +721,9 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) ...@@ -719,8 +721,9 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
src = srcY; src = srcY;
for (j = 0; j < 9 + s->mspel * 2; j++) { for (j = 0; j < 9 + s->mspel * 2; j++) {
int f = v->field_mode ? v->ref_field_type[dir] : (((j<<fieldmv)+src_y - (s->mspel << fieldmv))&1);
for (i = 0; i < 9 + s->mspel * 2; i++) for (i = 0; i < 9 + s->mspel * 2; i++)
src[i] = luty[src[i]]; src[i] = luty[f][src[i]];
src += s->linesize << fieldmv; src += s->linesize << fieldmv;
} }
} }
...@@ -808,7 +811,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir) ...@@ -808,7 +811,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
int valid_count; int valid_count;
int chroma_ref_type = v->cur_field_type, off = 0; int chroma_ref_type = v->cur_field_type, off = 0;
int v_edge_pos = s->v_edge_pos >> v->field_mode; int v_edge_pos = s->v_edge_pos >> v->field_mode;
const uint8_t *lutuv; uint8_t (*lutuv)[256];
int use_ic; int use_ic;
if (!v->field_mode && !v->s.last_picture.f.data[0]) if (!v->field_mode && !v->s.last_picture.f.data[0])
...@@ -875,18 +878,18 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir) ...@@ -875,18 +878,18 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) { if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) {
srcU = s->current_picture.f.data[1]; srcU = s->current_picture.f.data[1];
srcV = s->current_picture.f.data[2]; srcV = s->current_picture.f.data[2];
lutuv= v->curr_lutuv[chroma_ref_type]; lutuv= v->curr_lutuv;
use_ic=v->curr_use_ic; use_ic=v->curr_use_ic;
} else { } else {
srcU = s->last_picture.f.data[1]; srcU = s->last_picture.f.data[1];
srcV = s->last_picture.f.data[2]; srcV = s->last_picture.f.data[2];
lutuv= v->last_lutuv[chroma_ref_type]; lutuv= v->last_lutuv;
use_ic=v->last_use_ic; use_ic=v->last_use_ic;
} }
} else { } else {
srcU = s->next_picture.f.data[1]; srcU = s->next_picture.f.data[1];
srcV = s->next_picture.f.data[2]; srcV = s->next_picture.f.data[2];
lutuv= v->next_lutuv[chroma_ref_type]; lutuv= v->next_lutuv;
use_ic=v->next_use_ic; use_ic=v->next_use_ic;
} }
...@@ -941,9 +944,10 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir) ...@@ -941,9 +944,10 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
src = srcU; src = srcU;
src2 = srcV; src2 = srcV;
for (j = 0; j < 9; j++) { for (j = 0; j < 9; j++) {
int f = v->field_mode ? chroma_ref_type : ((j + uvsrc_y)&1);
for (i = 0; i < 9; i++) { for (i = 0; i < 9; i++) {
src[i] = lutuv[src[i]]; src[i] = lutuv[f][src[i]];
src2[i] = lutuv[src2[i]]; src2[i] = lutuv[f][src2[i]];
} }
src += s->uvlinesize; src += s->uvlinesize;
src2 += s->uvlinesize; src2 += s->uvlinesize;
...@@ -1992,23 +1996,25 @@ static void vc1_interp_mc(VC1Context *v) ...@@ -1992,23 +1996,25 @@ static void vc1_interp_mc(VC1Context *v)
} }
if (use_ic) { if (use_ic) {
const uint8_t *luty = v->next_luty [v->ref_field_type[1]]; uint8_t (*luty )[256] = v->next_luty;
const uint8_t *lutuv= v->next_lutuv[v->ref_field_type[1]]; uint8_t (*lutuv)[256] = v->next_lutuv;
int i, j; int i, j;
uint8_t *src, *src2; uint8_t *src, *src2;
src = srcY; src = srcY;
for (j = 0; j < 17 + s->mspel * 2; j++) { for (j = 0; j < 17 + s->mspel * 2; j++) {
int f = v->field_mode ? v->ref_field_type[1] : ((j+src_y - s->mspel)&1);
for (i = 0; i < 17 + s->mspel * 2; i++) for (i = 0; i < 17 + s->mspel * 2; i++)
src[i] = luty[src[i]]; src[i] = luty[f][src[i]];
src += s->linesize; src += s->linesize;
} }
src = srcU; src = srcU;
src2 = srcV; src2 = srcV;
for (j = 0; j < 9; j++) { for (j = 0; j < 9; j++) {
int f = v->field_mode ? v->ref_field_type[1] : ((j+uvsrc_y)&1);
for (i = 0; i < 9; i++) { for (i = 0; i < 9; i++) {
src[i] = lutuv[src[i]]; src[i] = lutuv[f][src[i]];
src2[i] = lutuv[src2[i]]; src2[i] = lutuv[f][src2[i]];
} }
src += s->uvlinesize; src += s->uvlinesize;
src2 += s->uvlinesize; src2 += s->uvlinesize;
......
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