Commit e60e14ef authored by Jerome Borsboom's avatar Jerome Borsboom Committed by Paul B Mahol

avcodec/vc1: re-implement vc1_put_signed_blocks_clamped

The existing implementation only used vc1_put_signed_blocks_clamped for I and
BI frames. This rewritten version is also applicable to P frame both
progressive and frame/field-interlace.
Signed-off-by: 's avatarJerome Borsboom <jerome.borsboom@carpalis.nl>
parent 362ce2db
...@@ -69,70 +69,70 @@ static inline void init_block_index(VC1Context *v) ...@@ -69,70 +69,70 @@ static inline void init_block_index(VC1Context *v)
static void vc1_put_signed_blocks_clamped(VC1Context *v) static void vc1_put_signed_blocks_clamped(VC1Context *v)
{ {
MpegEncContext *s = &v->s; MpegEncContext *s = &v->s;
int topleft_mb_pos, top_mb_pos; uint8_t *dest;
int stride_y, fieldtx = 0; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
int v_dist; int fieldtx = 0;
int i;
/* The put pixels loop is always one MB row behind the decoding loop,
* because we can only put pixels when overlap filtering is done, and /* The put pixels loop is one MB row and one MB column behind the decoding
* for filtering of the bottom edge of a MB, we need the next MB row * loop because we can only put pixels when overlap filtering is done. For
* present as well. * interlaced frame pictures, however, the put pixels loop is only one
* Within the row, the put pixels loop is also one MB col behind the * column behind the decoding loop as interlaced frame pictures only need
* decoding loop. The reason for this is again, because for filtering * horizontal overlap filtering. */
* of the right MB edge, we need the next MB present. */ if (!s->first_slice_line && v->fcm != ILACE_FRAME) {
if (!s->first_slice_line) { if (s->mb_x) {
for (i = 0; i < block_count; i++) {
if (i > 3 ? v->mb_type[0][s->block_index[i] - s->block_wrap[i] - 1] :
v->mb_type[0][s->block_index[i] - 2 * s->block_wrap[i] - 2]) {
dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + ((i & 1) - 2) * 8;
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][i],
i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest,
i > 3 ? s->uvlinesize : s->linesize);
}
}
}
if (s->mb_x == s->mb_width - 1) {
for (i = 0; i < block_count; i++) {
if (i > 3 ? v->mb_type[0][s->block_index[i] - s->block_wrap[i]] :
v->mb_type[0][s->block_index[i] - 2 * s->block_wrap[i]]) {
dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + (i & 1) * 8;
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][i],
i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest,
i > 3 ? s->uvlinesize : s->linesize);
}
}
}
}
if (s->mb_y == s->end_mb_y - 1 || v->fcm == ILACE_FRAME) {
if (s->mb_x) { if (s->mb_x) {
topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1;
if (v->fcm == ILACE_FRAME) if (v->fcm == ILACE_FRAME)
fieldtx = v->fieldtx_plane[topleft_mb_pos]; fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x - 1];
stride_y = s->linesize << fieldtx; for (i = 0; i < block_count; i++) {
v_dist = (16 - fieldtx) >> (fieldtx == 0); if (i > 3 ? v->mb_type[0][s->block_index[i] - 1] :
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0], v->mb_type[0][s->block_index[i] - 2]) {
s->dest[0] - 16 * s->linesize - 16, if (fieldtx)
stride_y); dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + ((i & 1) - 2) * 8;
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1], else
s->dest[0] - 16 * s->linesize - 8, dest = s->dest[0] + (i & 2) * 4 * s->linesize + ((i & 1) - 2) * 8;
stride_y); s->idsp.put_signed_pixels_clamped(v->block[v->left_blk_idx][i],
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2], i > 3 ? s->dest[i - 3] - 8 : dest,
s->dest[0] - v_dist * s->linesize - 16, i > 3 ? s->uvlinesize : s->linesize << fieldtx);
stride_y); }
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3],
s->dest[0] - v_dist * s->linesize - 8,
stride_y);
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4],
s->dest[1] - 8 * s->uvlinesize - 8,
s->uvlinesize);
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][5],
s->dest[2] - 8 * s->uvlinesize - 8,
s->uvlinesize);
} }
} }
if (s->mb_x == s->mb_width - 1) { if (s->mb_x == s->mb_width - 1) {
top_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x;
if (v->fcm == ILACE_FRAME) if (v->fcm == ILACE_FRAME)
fieldtx = v->fieldtx_plane[top_mb_pos]; fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x];
stride_y = s->linesize << fieldtx; for (i = 0; i < block_count; i++) {
v_dist = fieldtx ? 15 : 8; if (v->mb_type[0][s->block_index[i]]) {
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0], if (fieldtx)
s->dest[0] - 16 * s->linesize, dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + (i & 1) * 8;
stride_y); else
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][1], dest = s->dest[0] + (i & 2) * 4 * s->linesize + (i & 1) * 8;
s->dest[0] - 16 * s->linesize + 8, s->idsp.put_signed_pixels_clamped(v->block[v->cur_blk_idx][i],
stride_y); i > 3 ? s->dest[i - 3] : dest,
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][2], i > 3 ? s->uvlinesize : s->linesize << fieldtx);
s->dest[0] - v_dist * s->linesize, }
stride_y);
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3],
s->dest[0] - v_dist * s->linesize + 8,
stride_y);
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4],
s->dest[1] - 8 * s->uvlinesize,
s->uvlinesize);
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][5],
s->dest[2] - 8 * s->uvlinesize,
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