1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-19 05:49:09 +02:00

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: Jerome Borsboom <jerome.borsboom@carpalis.nl>
This commit is contained in:
Jerome Borsboom 2018-04-23 20:59:49 +02:00 committed by Paul B Mahol
parent 362ce2db4b
commit e60e14ef92

View File

@ -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, /* The put pixels loop is one MB row and one MB column behind the decoding
* because we can only put pixels when overlap filtering is done, and * loop because we can only put pixels when overlap filtering is done. For
* for filtering of the bottom edge of a MB, we need the next MB row * interlaced frame pictures, however, the put pixels loop is only one
* present as well. * column behind the decoding loop as interlaced frame pictures only need
* Within the row, the put pixels loop is also one MB col behind the * horizontal overlap filtering. */
* decoding loop. The reason for this is again, because for filtering if (!s->first_slice_line && v->fcm != ILACE_FRAME) {
* of the right MB edge, we need the next MB present. */
if (!s->first_slice_line) {
if (s->mb_x) { if (s->mb_x) {
topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1; for (i = 0; i < block_count; i++) {
if (v->fcm == ILACE_FRAME) if (i > 3 ? v->mb_type[0][s->block_index[i] - s->block_wrap[i] - 1] :
fieldtx = v->fieldtx_plane[topleft_mb_pos]; v->mb_type[0][s->block_index[i] - 2 * s->block_wrap[i] - 2]) {
stride_y = s->linesize << fieldtx; dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + ((i & 1) - 2) * 8;
v_dist = (16 - fieldtx) >> (fieldtx == 0); s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][i],
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0], i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest,
s->dest[0] - 16 * s->linesize - 16, i > 3 ? s->uvlinesize : s->linesize);
stride_y); }
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1],
s->dest[0] - 16 * s->linesize - 8,
stride_y);
s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2],
s->dest[0] - v_dist * s->linesize - 16,
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; 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 (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 - 1];
stride_y = s->linesize << fieldtx; for (i = 0; i < block_count; i++) {
v_dist = fieldtx ? 15 : 8; if (i > 3 ? v->mb_type[0][s->block_index[i] - 1] :
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0], v->mb_type[0][s->block_index[i] - 2]) {
s->dest[0] - 16 * s->linesize, 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->top_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->top_blk_idx][2], i > 3 ? s->dest[i - 3] - 8 : dest,
s->dest[0] - v_dist * s->linesize, i > 3 ? s->uvlinesize : s->linesize << fieldtx);
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 (s->mb_x == s->mb_width - 1) {
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { if (v->fcm == ILACE_FRAME)
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4], fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x];
s->dest[1] - 8 * s->uvlinesize, for (i = 0; i < block_count; i++) {
s->uvlinesize); if (v->mb_type[0][s->block_index[i]]) {
s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][5], if (fieldtx)
s->dest[2] - 8 * s->uvlinesize, dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + (i & 1) * 8;
s->uvlinesize); else
dest = s->dest[0] + (i & 2) * 4 * s->linesize + (i & 1) * 8;
s->idsp.put_signed_pixels_clamped(v->block[v->cur_blk_idx][i],
i > 3 ? s->dest[i - 3] : dest,
i > 3 ? s->uvlinesize : s->linesize << fieldtx);
}
} }
} }
} }