From 3992526b3c43278945d00fac6e2ba5cb8f810ef3 Mon Sep 17 00:00:00 2001 From: David Conrad Date: Wed, 15 Apr 2009 06:22:17 +0000 Subject: [PATCH] Split VC1 loop filter into separate functions for h/v and size Originally committed as revision 18521 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/dsputil.h | 7 ++++++- libavcodec/vc1.c | 42 +++++++++++++++++++++--------------------- libavcodec/vc1dsp.c | 39 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 24 deletions(-) diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 3599259f8e..60b2f22991 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -482,7 +482,12 @@ typedef struct DSPContext { void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block); void (*vc1_v_overlap)(uint8_t* src, int stride); void (*vc1_h_overlap)(uint8_t* src, int stride); - void (*vc1_loop_filter)(uint8_t *src, int step, int stride, int len, int pq); + void (*vc1_v_loop_filter4)(uint8_t *src, int stride, int pq); + void (*vc1_h_loop_filter4)(uint8_t *src, int stride, int pq); + void (*vc1_v_loop_filter8)(uint8_t *src, int stride, int pq); + void (*vc1_h_loop_filter8)(uint8_t *src, int stride, int pq); + void (*vc1_v_loop_filter16)(uint8_t *src, int stride, int pq); + void (*vc1_h_loop_filter16)(uint8_t *src, int stride, int pq); /* put 8x8 block with bicubic interpolation and quarterpel precision * last argument is actually round value instead of height */ diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 604ab0a4a0..0add2c7f55 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -314,15 +314,15 @@ static void vc1_loop_filter_iblk(MpegEncContext *s, int pq) { int i, j; if(!s->first_slice_line) - s->dsp.vc1_loop_filter(s->dest[0], 1, s->linesize, 16, pq); - s->dsp.vc1_loop_filter(s->dest[0] + 8*s->linesize, 1, s->linesize, 16, pq); + s->dsp.vc1_v_loop_filter16(s->dest[0], s->linesize, pq); + s->dsp.vc1_v_loop_filter16(s->dest[0] + 8*s->linesize, s->linesize, pq); for(i = !s->mb_x*8; i < 16; i += 8) - s->dsp.vc1_loop_filter(s->dest[0] + i, s->linesize, 1, 16, pq); + s->dsp.vc1_h_loop_filter16(s->dest[0] + i, s->linesize, pq); for(j = 0; j < 2; j++){ if(!s->first_slice_line) - s->dsp.vc1_loop_filter(s->dest[j+1], 1, s->uvlinesize, 8, pq); + s->dsp.vc1_v_loop_filter8(s->dest[j+1], s->uvlinesize, pq); if(s->mb_x) - s->dsp.vc1_loop_filter(s->dest[j+1], s->uvlinesize, 1, 8, pq); + s->dsp.vc1_h_loop_filter8(s->dest[j+1], s->uvlinesize, pq); } } @@ -2982,9 +2982,9 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan s->dsp.vc1_inv_trans_8x8(block); s->dsp.add_pixels_clamped(block, dst, linesize); if(apply_filter && cbp_top & 0xC) - s->dsp.vc1_loop_filter(dst, 1, linesize, 8, mquant); + s->dsp.vc1_v_loop_filter8(dst, linesize, mquant); if(apply_filter && cbp_left & 0xA) - s->dsp.vc1_loop_filter(dst, linesize, 1, 8, mquant); + s->dsp.vc1_h_loop_filter8(dst, linesize, mquant); } break; case TT_4X4: @@ -3006,9 +3006,9 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan if(!(subblkpat & (1 << (3 - j))) && !skip_block){ s->dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off); if(apply_filter && (j&2 ? pat & (1<<(j-2)) : (cbp_top & (1 << (j + 2))))) - s->dsp.vc1_loop_filter(dst + (j&1)*4 + (j&2)*2*linesize, 1, linesize, 4, mquant); + s->dsp.vc1_v_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, mquant); if(apply_filter && (j&1 ? pat & (1<<(j-1)) : (cbp_left & (1 << (j + 1))))) - s->dsp.vc1_loop_filter(dst + (j&1)*4 + (j&2)*2*linesize, linesize, 1, 4, mquant); + s->dsp.vc1_h_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, mquant); } } break; @@ -3031,9 +3031,9 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan if(!(subblkpat & (1 << (1 - j))) && !skip_block){ s->dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off); if(apply_filter && j ? pat & 0x3 : (cbp_top & 0xC)) - s->dsp.vc1_loop_filter(dst + j*4*linesize, 1, linesize, 8, mquant); + s->dsp.vc1_v_loop_filter8(dst + j*4*linesize, linesize, mquant); if(apply_filter && cbp_left & (2 << j)) - s->dsp.vc1_loop_filter(dst + j*4*linesize, linesize, 1, 4, mquant); + s->dsp.vc1_h_loop_filter4(dst + j*4*linesize, linesize, mquant); } } break; @@ -3056,9 +3056,9 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan if(!(subblkpat & (1 << (1 - j))) && !skip_block){ s->dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off); if(apply_filter && cbp_top & (2 << j)) - s->dsp.vc1_loop_filter(dst + j*4, 1, linesize, 4, mquant); + s->dsp.vc1_v_loop_filter4(dst + j*4, linesize, mquant); if(apply_filter && j ? pat & 0x5 : (cbp_left & 0xA)) - s->dsp.vc1_loop_filter(dst + j*4, linesize, 1, 8, mquant); + s->dsp.vc1_h_loop_filter8(dst + j*4, linesize, mquant); } } break; @@ -3181,9 +3181,9 @@ static int vc1_decode_p_mb(VC1Context *v) top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4)); } if(left_cbp & 0xC) - s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, 1, i & 4 ? s->uvlinesize : s->linesize, 8, mquant); + s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, mquant); if(top_cbp & 0xA) - s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, 1, 8, mquant); + s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, mquant); } block_cbp |= 0xF << (i << 2); } else if(val) { @@ -3198,9 +3198,9 @@ static int vc1_decode_p_mb(VC1Context *v) top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4)); } if(left_cbp & 0xC) - s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, 1, i & 4 ? s->uvlinesize : s->linesize, 8, mquant); + s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, mquant); if(top_cbp & 0xA) - s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, 1, 8, mquant); + s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, mquant); } pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp); block_cbp |= pat << (i << 2); @@ -3312,9 +3312,9 @@ static int vc1_decode_p_mb(VC1Context *v) top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4)); } if(left_cbp & 0xC) - s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, 1, i & 4 ? s->uvlinesize : s->linesize, 8, mquant); + s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, mquant); if(top_cbp & 0xA) - s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, 1, 8, mquant); + s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, mquant); } block_cbp |= 0xF << (i << 2); } else if(is_coded[i]) { @@ -3329,9 +3329,9 @@ static int vc1_decode_p_mb(VC1Context *v) top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4)); } if(left_cbp & 0xC) - s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, 1, i & 4 ? s->uvlinesize : s->linesize, 8, mquant); + s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, mquant); if(top_cbp & 0xA) - s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, 1, 8, mquant); + s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, mquant); } pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp); block_cbp |= pat << (i << 2); diff --git a/libavcodec/vc1dsp.c b/libavcodec/vc1dsp.c index 5420e7e260..5773ab1e3c 100644 --- a/libavcodec/vc1dsp.c +++ b/libavcodec/vc1dsp.c @@ -130,7 +130,7 @@ static av_always_inline int vc1_filter_line(uint8_t* src, int stride, int pq){ * @param pq block quantizer * @see 8.6 */ -static void vc1_loop_filter(uint8_t* src, int step, int stride, int len, int pq) +static inline void vc1_loop_filter(uint8_t* src, int step, int stride, int len, int pq) { int i; int filt3; @@ -146,6 +146,36 @@ static void vc1_loop_filter(uint8_t* src, int step, int stride, int len, int pq) } } +static void vc1_v_loop_filter4_c(uint8_t *src, int stride, int pq) +{ + vc1_loop_filter(src, 1, stride, 4, pq); +} + +static void vc1_h_loop_filter4_c(uint8_t *src, int stride, int pq) +{ + vc1_loop_filter(src, stride, 1, 4, pq); +} + +static void vc1_v_loop_filter8_c(uint8_t *src, int stride, int pq) +{ + vc1_loop_filter(src, 1, stride, 8, pq); +} + +static void vc1_h_loop_filter8_c(uint8_t *src, int stride, int pq) +{ + vc1_loop_filter(src, stride, 1, 8, pq); +} + +static void vc1_v_loop_filter16_c(uint8_t *src, int stride, int pq) +{ + vc1_loop_filter(src, 1, stride, 16, pq); +} + +static void vc1_h_loop_filter16_c(uint8_t *src, int stride, int pq) +{ + vc1_loop_filter(src, stride, 1, 16, pq); +} + /** Do inverse transform on 8x8 block */ static void vc1_inv_trans_8x8_c(DCTELEM block[64]) @@ -517,7 +547,12 @@ void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) { dsp->vc1_inv_trans_4x4 = vc1_inv_trans_4x4_c; dsp->vc1_h_overlap = vc1_h_overlap_c; dsp->vc1_v_overlap = vc1_v_overlap_c; - dsp->vc1_loop_filter = vc1_loop_filter; + dsp->vc1_v_loop_filter4 = vc1_v_loop_filter4_c; + dsp->vc1_h_loop_filter4 = vc1_h_loop_filter4_c; + dsp->vc1_v_loop_filter8 = vc1_v_loop_filter8_c; + dsp->vc1_h_loop_filter8 = vc1_h_loop_filter8_c; + dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_c; + dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_c; dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_c; dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_c;