aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/rv40.c
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-12-08 02:50:25 +0000
committerMans Rullgard <mans@mansr.com>2011-12-14 11:26:30 +0000
commitd8edf1b515ae9fbcea2103305241d130c16e1003 (patch)
tree23d8acfa2c850f88be9282aec478c5a6d758359d /libavcodec/rv40.c
parent3e0b1c9a816185b755f79b195d58f9a057bac0b2 (diff)
downloadffmpeg-d8edf1b515ae9fbcea2103305241d130c16e1003.tar.gz
rv40: rearrange loop filter functions
This splits the loop filter functions into smaller, more SIMD-friendly functions. Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/rv40.c')
-rw-r--r--libavcodec/rv40.c69
1 files changed, 49 insertions, 20 deletions
diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
index 3216e838ef..bde63e19a5 100644
--- a/libavcodec/rv40.c
+++ b/libavcodec/rv40.c
@@ -294,6 +294,34 @@ enum RV40BlockPos{
static const int neighbour_offs_x[4] = { 0, 0, -1, 0 };
static const int neighbour_offs_y[4] = { 0, -1, 0, 1 };
+static void rv40_adaptive_loop_filter(RV34DSPContext *rdsp,
+ uint8_t *src, int stride, int dmode,
+ int lim_q1, int lim_p1,
+ int alpha, int beta, int beta2,
+ int chroma, int edge, int dir)
+{
+ int filter_p1, filter_q1;
+ int strong;
+ int lims;
+
+ strong = rdsp->rv40_loop_filter_strength[dir](src, stride, beta, beta2,
+ edge, &filter_p1, &filter_q1);
+
+ lims = filter_p1 + filter_q1 + ((lim_q1 + lim_p1) >> 1) + 1;
+
+ if (strong) {
+ rdsp->rv40_strong_loop_filter[dir](src, stride, alpha,
+ lims, dmode, chroma);
+ } else if (filter_p1 & filter_q1) {
+ rdsp->rv40_weak_loop_filter[dir](src, stride, 1, 1, alpha, beta,
+ lims, lim_q1, lim_p1);
+ } else if (filter_p1 | filter_q1) {
+ rdsp->rv40_weak_loop_filter[dir](src, stride, filter_p1, filter_q1,
+ alpha, beta, lims >> 1, lim_q1 >> 1,
+ lim_p1 >> 1);
+ }
+}
+
/**
* RV40 loop filtering function
*/
@@ -430,10 +458,11 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
// if bottom block is coded then we can filter its top edge
// (or bottom edge of this block, which is the same)
if(y_h_deblock & (MASK_BOTTOM << ij)){
- r->rdsp.rv40_h_loop_filter(Y+4*s->linesize, s->linesize, dither,
- y_to_deblock & (MASK_BOTTOM << ij) ? clip[POS_CUR] : 0,
- clip_cur,
- alpha, beta, betaY, 0, 0);
+ rv40_adaptive_loop_filter(&r->rdsp, Y+4*s->linesize,
+ s->linesize, dither,
+ y_to_deblock & (MASK_BOTTOM << ij) ? clip[POS_CUR] : 0,
+ clip_cur, alpha, beta, betaY,
+ 0, 0, 0);
}
// filter left block edge in ordinary mode (with low filtering strength)
if(y_v_deblock & (MASK_CUR << ij) && (i || !(mb_strong[POS_CUR] || mb_strong[POS_LEFT]))){
@@ -441,25 +470,25 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0;
else
clip_left = y_to_deblock & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0;
- r->rdsp.rv40_v_loop_filter(Y, s->linesize, dither,
- clip_cur,
- clip_left,
- alpha, beta, betaY, 0, 0);
+ rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither,
+ clip_cur,
+ clip_left,
+ alpha, beta, betaY, 0, 0, 1);
}
// filter top edge of the current macroblock when filtering strength is high
if(!j && y_h_deblock & (MASK_CUR << i) && (mb_strong[POS_CUR] || mb_strong[POS_TOP])){
- r->rdsp.rv40_h_loop_filter(Y, s->linesize, dither,
+ rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither,
clip_cur,
mvmasks[POS_TOP] & (MASK_TOP << i) ? clip[POS_TOP] : 0,
- alpha, beta, betaY, 0, 1);
+ alpha, beta, betaY, 0, 1, 0);
}
// filter left block edge in edge mode (with high filtering strength)
if(y_v_deblock & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] || mb_strong[POS_LEFT])){
clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0;
- r->rdsp.rv40_v_loop_filter(Y, s->linesize, dither,
+ rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither,
clip_cur,
clip_left,
- alpha, beta, betaY, 0, 1);
+ alpha, beta, betaY, 0, 1, 1);
}
}
}
@@ -471,34 +500,34 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
int clip_cur = c_to_deblock[k] & (MASK_CUR << ij) ? clip[POS_CUR] : 0;
if(c_h_deblock[k] & (MASK_CUR << (ij+2))){
int clip_bot = c_to_deblock[k] & (MASK_CUR << (ij+2)) ? clip[POS_CUR] : 0;
- r->rdsp.rv40_h_loop_filter(C+4*s->uvlinesize, s->uvlinesize, i*8,
+ rv40_adaptive_loop_filter(&r->rdsp, C+4*s->uvlinesize, s->uvlinesize, i*8,
clip_bot,
clip_cur,
- alpha, beta, betaC, 1, 0);
+ alpha, beta, betaC, 1, 0, 0);
}
if((c_v_deblock[k] & (MASK_CUR << ij)) && (i || !(mb_strong[POS_CUR] || mb_strong[POS_LEFT]))){
if(!i)
clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0;
else
clip_left = c_to_deblock[k] & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0;
- r->rdsp.rv40_v_loop_filter(C, s->uvlinesize, j*8,
+ rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, j*8,
clip_cur,
clip_left,
- alpha, beta, betaC, 1, 0);
+ alpha, beta, betaC, 1, 0, 1);
}
if(!j && c_h_deblock[k] & (MASK_CUR << ij) && (mb_strong[POS_CUR] || mb_strong[POS_TOP])){
int clip_top = uvcbp[POS_TOP][k] & (MASK_CUR << (ij+2)) ? clip[POS_TOP] : 0;
- r->rdsp.rv40_h_loop_filter(C, s->uvlinesize, i*8,
+ rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, i*8,
clip_cur,
clip_top,
- alpha, beta, betaC, 1, 1);
+ alpha, beta, betaC, 1, 1, 0);
}
if(c_v_deblock[k] & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] || mb_strong[POS_LEFT])){
clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0;
- r->rdsp.rv40_v_loop_filter(C, s->uvlinesize, j*8,
+ rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, j*8,
clip_cur,
clip_left,
- alpha, beta, betaC, 1, 1);
+ alpha, beta, betaC, 1, 1, 1);
}
}
}