[FFmpeg-devel] [PATCH] RV40 Loop Filter

Kostya kostya.shishkov
Tue Oct 21 08:23:21 CEST 2008


$subj
I've tested it and looks like filter is invoked properly now,
filtering workflow should be also correct, but there is some
non-bitexactness elsewhere, so result picture is still a bit
wrong.
-------------- next part --------------
Index: libavcodec/rv40.c
===================================================================
--- libavcodec/rv40.c	(revision 15305)
+++ libavcodec/rv40.c	(working copy)
@@ -247,7 +247,472 @@
     return 0;
 }
 
+#define CLIP_SYMM(a, b) av_clip(a, -(b), b)
 /**
+ * weaker deblocking very similar to the one described in 4.4.2 of JVT-A003r1
+ */
+static inline void rv40_weak_loop_filter(uint8_t *src, const int step,
+                            const int flag0, const int flag1, const int mult,
+                            const int lim0, const int lim1, const int lim2, const int thr0,
+                            const int S0, const int S1, const int S2, const int S3)
+{
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    int t, u, diff;
+
+    t = src[0*step] - src[-1*step];
+    if(!t) return;
+    u = (mult * FFABS(t)) >> 7;
+    if(u > 3 - (flag0 && flag1)) return;
+
+    t <<= 2;
+    if(flag0 && flag1)
+        t += src[-2*step] - src[1*step];
+    diff = CLIP_SYMM((t + 4) >> 3, lim2);
+    src[-1*step] = cm[src[-1*step] + diff];
+    src[ 0*step] = cm[src[ 0*step] - diff];
+    if(FFABS(S2) <= thr0 && flag0){
+        t = (S0 + S2 - diff) >> 1;
+        src[-2*step] = cm[src[-2*step] - CLIP_SYMM(t, lim1)];
+    }
+    if(FFABS(S3) <= thr0 && flag1){
+        t = (S1 + S3 + diff) >> 1;
+        src[ 1*step] = cm[src[ 1*step] - CLIP_SYMM(t, lim0)];
+    }
+}
+
+/**
+ * This macro is used for calculating 25*x0+26*x1+26*x2+26*x3+25*x4
+ * or 25*x0+26*x1+51*x2+26*x3
+ * @param  sub - index of the value with coefficient = 25
+ * @param last - index of the value with coefficient 25 or 51
+ */
+#define RV40_STRONG_FILTER(src, step, start, last, sub) \
+     26*(src[start*step] + src[(start+1)*step] + src[(start+2)*step] + src[(start+3)*step] + src[last*step]) - src[last*step] - src[sub*step]
+/**
+ * Deblocking filter, the alternated version from JVT-A003r1 H.26L draft.
+ */
+static inline void rv40_adaptive_loop_filter(uint8_t *src, const int step, const int stride, const int dmode, const int lim0, const int lim1, const int mult, const int thr0, const int thr1, const int chroma, const int edge)
+{
+    int diffs[4][4];
+    int s0 = 0, s1 = 0, s2 = 0, s3 = 0;
+    uint8_t *ptr;
+    int flag0 = 1, flag1 = 1;
+    int llim0 = 3, llim1 = 3;
+    int i, j, t, sflag;
+    int p0, p1;
+    int lims;
+    int diff[2];
+
+    for(i = 0, ptr = src; i < 4; i++, ptr += stride){
+        diffs[i][0] = ptr[-2*step] - ptr[-1*step];
+        diffs[i][1] = ptr[ 1*step] - ptr[ 0*step];
+        s0 += diffs[i][0];
+        s1 += diffs[i][1];
+    }
+    if(FFABS(s0) >= (thr0<<2)){
+        llim0 = 1;
+    }
+    if(FFABS(s1) >= (thr0<<2)){
+        llim1 = 1;
+    }
+    if(llim0 + llim1 <= 2)
+        return;
+
+    for(i = 0, ptr = src; i < 4; i++, ptr += stride){
+        diffs[i][2] = ptr[-2*step] - ptr[-3*step];
+        diffs[i][3] = ptr[ 1*step] - ptr[ 2*step];
+        s2 += diffs[i][2];
+        s3 += diffs[i][3];
+    }
+
+    if(!edge)
+        flag0 = flag1 = 0;
+    else{
+        flag0 = (llim0 == 3);
+        flag1 = (llim1 == 3);
+    }
+    if(flag0 && FFABS(s2) >= thr1)
+        flag0 = 0;
+    if(flag1 && FFABS(s3) >= thr1)
+        flag1 = 0;
+
+    lims = (lim0 + lim1 + llim0 + llim1) >> 1;
+    if(flag0 && flag1){ /* strong filtering */
+        for(i = 0; i < 4; i++, src += stride){
+            t = src[0*step] - src[-1*step];
+            if(!t) continue;
+            sflag = (mult * FFABS(t)) >> 7;
+            if(sflag > 1) continue;
+
+            p0 = (RV40_STRONG_FILTER(src, step, -3, 1, -3) + rv40_dither_l[dmode + i]) >> 7;
+            p1 = (RV40_STRONG_FILTER(src, step, -2, 2, -2) + rv40_dither_r[dmode + i]) >> 7;
+            diff[0] = src[-1*step];
+            diff[1] = src[ 0*step];
+            src[-1*step] = sflag ? av_clip(p0, src[-1*step] - lims, src[-1*step] + lims) : p0;
+            src[ 0*step] = sflag ? av_clip(p1, src[ 0*step] - lims, src[ 0*step] + lims) : p1;
+            diff[0] -= src[-1*step];
+            diff[1] -= src[ 0*step];
+            p0 = (RV40_STRONG_FILTER(src, step, -4, 0, -4) + rv40_dither_l[dmode + i] + diff[1]*25) >> 7;
+            p1 = (RV40_STRONG_FILTER(src, step, -1, 3, -1) + rv40_dither_r[dmode + i] + diff[0]*25) >> 7;
+            src[-2*step] = sflag ? av_clip(p0, src[-2*step] - lims, src[-2*step] + lims) : p0;
+            src[ 1*step] = sflag ? av_clip(p1, src[ 1*step] - lims, src[ 1*step] + lims) : p1;
+            if(!chroma){
+                src[-3*step] = (RV40_STRONG_FILTER(src, step, -4, -3, -1) + 64) >> 7;
+                src[ 2*step] = (RV40_STRONG_FILTER(src, step,  0,  2,  0) + 64) >> 7;
+            }
+        }
+    }else if(llim0 == 3 && llim1 == 3){
+        for(i = 0; i < 4; i++, src += stride)
+            rv40_weak_loop_filter(src, step, 1, 1, mult, lim0, lim1, lims, thr0,
+                                  diffs[i][0], diffs[i][1], diffs[i][2], diffs[i][3]);
+    }else{
+        for(i = 0; i < 4; i++, src += stride)
+            rv40_weak_loop_filter(src, step, llim0==3, llim1==3, mult, lim0>>1, lim1>>1, lims>>1, thr0,
+                                  diffs[i][0], diffs[i][1], diffs[i][2], diffs[i][3]);
+    }
+}
+
+static void rv40_v_loop_filter(uint8_t *src, int stride, int dmode, int lim0, int lim1, int mult, int thr0, int thr1, int chroma, int edge){
+    rv40_adaptive_loop_filter(src, 1, stride, dmode, lim0, lim1, mult, thr0, thr1, chroma, edge);
+}
+static void rv40_h_loop_filter(uint8_t *src, int stride, int dmode, int lim0, int lim1, int mult, int thr0, int thr1, int chroma, int edge){
+    rv40_adaptive_loop_filter(src, stride, 1, dmode, lim0, lim1, mult, thr0, thr1, chroma, edge);
+}
+
+static int rv40_set_deblock_coef(RV34DecContext *r)
+{
+    MpegEncContext *s = &r->s;
+    int mvmask = 0, i, j, dx, dy;
+    int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
+    if(s->pict_type == FF_I_TYPE)
+        return 0;
+    for(j = 0; j < 2; j++){
+        for(i = 0; i < 2; i++){
+            if(i || s->mb_x){
+                dx = FFABS(s->current_picture_ptr->motion_val[0][midx + i][0] - s->current_picture_ptr->motion_val[0][midx + i - 1][0]);
+                dy = FFABS(s->current_picture_ptr->motion_val[0][midx + i][1] - s->current_picture_ptr->motion_val[0][midx + i - 1][1]);
+                if(dx > 3 || dy > 3){
+                    mvmask |= 0x11 << (i*2 + j*8);
+                }
+            }
+            if(j || !s->first_slice_line){
+                dx = FFABS(s->current_picture_ptr->motion_val[0][midx + i][0] - s->current_picture_ptr->motion_val[0][midx + i - s->b8_stride][0]);
+                dy = FFABS(s->current_picture_ptr->motion_val[0][midx + i][1] - s->current_picture_ptr->motion_val[0][midx + i - s->b8_stride][1]);
+                if(dx > 3 || dy > 3){
+                    mvmask |= 0x03 << (i*2 + j*8);
+                }
+            }
+        }
+        midx += s->b8_stride;
+    }
+    return mvmask;
+}
+
+static void rv40_loop_filter(RV34DecContext *r)
+{
+    MpegEncContext *s = &r->s;
+    int mb_pos;
+    int i, j;
+    uint8_t *Y, *C;
+    int alpha, beta, betaY, betaC;
+    int q;
+    // 0 - cur block, 1 - top, 2 - left, 3 - bottom
+    int btype[4], clip[4], mvmasks[4], cbps[4], uvcbps[4][2];
+
+    if(s->pict_type == FF_B_TYPE)
+        return;
+
+    for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++){
+        mb_pos = s->mb_y * s->mb_stride;
+        for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++, mb_pos++){
+            int btype = s->current_picture_ptr->mb_type[mb_pos];
+            if(IS_INTRA(btype) || IS_SEPARATE_DC(btype)){
+                r->cbp_luma  [mb_pos] = 0xFFFF;
+            }
+            if(IS_INTRA(btype))
+                r->cbp_chroma[mb_pos] = 0xFF;
+        }
+    }
+    for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++){
+        mb_pos = s->mb_y * s->mb_stride;
+        for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++, mb_pos++){
+            int y_h_deblock, y_v_deblock, y_top_edge, y_left_edge;
+            int y_coded, y_left_coded, y_top_coded;
+            int c_left_edge[2], c_top_edge[2], c_v_deblock[2], c_h_deblock[2];
+            int c_top_coded[2], c_left_coded[2], c_coded[2];
+
+            ff_init_block_index(s);
+            ff_update_block_index(s);
+            Y = s->dest[0];
+            q = s->current_picture_ptr->qscale_table[mb_pos];
+            alpha = rv40_alpha_tab[q];
+            beta  = rv40_beta_tab [q];
+            betaY = betaC = beta * 3;
+            if(s->width * s->height <= 0x6300)
+                betaY += beta;
+
+            mvmasks[0] = r->deblock_coefs[mb_pos];
+            btype  [0] = s->current_picture_ptr->mb_type[mb_pos];
+            cbps   [0] = r->cbp_luma[mb_pos];
+            uvcbps[0][0] = r->cbp_chroma[mb_pos] & 0xF;
+            uvcbps[0][1] = r->cbp_chroma[mb_pos] >> 4;
+            if(s->mb_y){
+                mvmasks[1] = r->deblock_coefs[mb_pos - s->mb_stride] & 0xF000;
+                btype  [1] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride];
+                cbps   [1] = r->cbp_luma[mb_pos - s->mb_stride] & 0xF000;
+                uvcbps[1][0] =  r->cbp_chroma[mb_pos - s->mb_stride]       & 0xC;
+                uvcbps[1][1] = (r->cbp_chroma[mb_pos - s->mb_stride] >> 4) & 0xC;
+            }else{
+                mvmasks[1] = 0;
+                btype  [1] = btype[0];
+                cbps   [1] = 0;
+                uvcbps[1][0] = uvcbps[1][1] = 0;
+            }
+            if(s->mb_x){
+                mvmasks[2] = r->deblock_coefs[mb_pos - 1] & 0x8888;
+                btype  [2] = s->current_picture_ptr->mb_type[mb_pos - 1];
+                cbps   [2] = r->cbp_luma[mb_pos - 1] & 0x8888;
+                uvcbps[2][0] =  r->cbp_chroma[mb_pos - 1]       & 0xA;
+                uvcbps[2][1] = (r->cbp_chroma[mb_pos - 1] >> 4) & 0xA;
+            }else{
+                mvmasks[2] = 0;
+                btype  [2] = btype[0];
+                cbps   [2] = 0;
+                uvcbps[2][0] = uvcbps[2][1] = 0;
+            }
+            if(s->mb_y < s->mb_height - 1){
+                mvmasks[3] = r->deblock_coefs[mb_pos + s->mb_stride] & 0x000F;
+                btype  [3] = s->current_picture_ptr->mb_type[mb_pos + s->mb_stride];
+                cbps   [3] = r->cbp_luma[mb_pos + s->mb_stride] & 0x000F;
+                uvcbps[3][0] =  r->cbp_chroma[mb_pos + s->mb_stride]       & 0x3;
+                uvcbps[3][1] = (r->cbp_chroma[mb_pos + s->mb_stride] >> 4) & 0x3;
+            }else{
+                mvmasks[3] = 0;
+                btype  [3] = btype[0];
+                cbps   [3] = 0;
+                uvcbps[3][0] = uvcbps[3][1] = 0;
+            }
+            for(i = 0; i < 4; i++){
+                btype[i] = (IS_INTRA(btype[i]) || IS_SEPARATE_DC(btype[i])) ? 2 : 1;
+                clip[i] = rv40_filter_clip_tbl[btype[i]][q];
+            }
+            y_h_deblock = cbps[0] | ((cbps[0] << 4) & ~0x000F) | (cbps[1] >> 12)
+                        | ((cbps[3] << 20) & ~0x000F) | (cbps[3] << 16)
+                        | mvmasks[0] | (mvmasks[3] << 16);
+            y_v_deblock = ((cbps[0] << 1) & ~0x1111) | (cbps[2] >> 3)
+                        | cbps[0] | (cbps[3] << 16)
+                        | mvmasks[0] | (mvmasks[3] << 16);
+            if(!s->mb_x){
+                y_v_deblock &= ~0x1111;
+            }
+            if(!s->mb_y){
+                y_h_deblock &= ~0x000F;
+            }
+            if(s->mb_y == s->mb_height - 1 || (btype[0] == 2 || btype[3] == 2)){
+                y_h_deblock &= ~0xF0000;
+            }
+            y_coded = cbps[0] | (cbps[3] << 16)
+                    | mvmasks[0] | (mvmasks[3] << 16);
+            y_left_coded = cbps[2] | mvmasks[2];
+            y_top_coded = cbps[1] | mvmasks[1];
+            y_top_edge = (btype[0] == 2 || btype[1] == 2) ? 0x000F : 0;
+            y_left_edge = (btype[0] == 2 || btype[2] == 2) ? 0x1111 : 0;
+            for(i = 0; i < 2; i++){
+                c_left_edge[i] = (btype[0] == 2 || btype[2] == 2) ? 0x5 : 0;
+                c_top_edge[i] = (btype[0] == 2 || btype[1] == 2) ? 0x3 : 0;
+                c_v_deblock[i] = ((uvcbps[0][i] << 1) & ~0x5) | (uvcbps[2][i] >> 1)
+                               | (uvcbps[3][i] << 4) | uvcbps[0][i];
+                c_h_deblock[i] = (uvcbps[3][i] << 4) | uvcbps[0][i] | (uvcbps[1][i] >> 2)
+                               | (uvcbps[3][i] << 6) | (uvcbps[0][i] << 2);
+                c_top_coded[i] = uvcbps[1][i];
+                c_left_coded[i] = uvcbps[2][i];
+                c_coded[i] = (uvcbps[3][i] << 4) | uvcbps[0][i];
+                if(!s->mb_x){
+                    c_v_deblock[i] &= ~0x5;
+                }
+                if(!s->mb_y){
+                    c_h_deblock[i] &= ~0x3;
+                }
+                if(s->mb_y == s->mb_height - 1){
+                    c_h_deblock[i] &= ~0x30;
+                }
+                if(btype[0] == 2 || btype[3] == 2){
+                    c_h_deblock[i] &= ~0x30;
+                }
+            }
+
+            Y = s->dest[0];
+            if((y_h_deblock & 0x0010) && !(y_top_edge & 0x0010)){
+                rv40_h_loop_filter(Y+4*s->linesize, s->linesize, 0,
+                                   y_coded & 0x0010 ? clip[0] : 0,
+                                   y_coded & 0x0001 ? clip[0] : 0,
+                                   alpha, beta, betaY, 0, 0);
+            }
+            if((y_v_deblock & 0x0001) && !(y_left_edge & 0x0001)){
+                rv40_v_loop_filter(Y, s->linesize, 0,
+                                   y_coded & 0x0001 ? clip[0] : 0,
+                                   y_left_coded & 0x0008 ? clip[2] : 0,
+                                   alpha, beta, betaY, 0, 0);
+            }
+            if((y_h_deblock & 0x0001) &&  (y_top_edge & 0x0001)){
+                rv40_h_loop_filter(Y, s->linesize, 0,
+                                   y_coded & 0x0001 ? clip[0] : 0,
+                                   y_top_coded & 0x1000 ? clip[1] : 0,
+                                   alpha, beta, betaY, 0, 1);
+            }
+            if((y_v_deblock & 0x0001) &&  (y_left_edge & 0x0001)){
+                rv40_v_loop_filter(Y, s->linesize, 0,
+                                   y_coded & 0x0001 ? clip[0] : 0,
+                                   y_left_coded & 0x0008 ? clip[2] : 0,
+                                   alpha, beta, betaY, 0, 1);
+            }
+            for(i = 1; i < 4; i++){
+                Y += 4;
+                if((y_h_deblock & (0x0010<<i)) && !(y_top_edge & (0x0010<<i))){
+                    rv40_h_loop_filter(Y+4*s->linesize, s->linesize, i*4,
+                                       y_coded & (0x0010<<i) ? clip[0] : 0,
+                                       y_coded & (0x0001<<i) ? clip[0] : 0,
+                                       alpha, beta, betaY, 0, 0);
+                }
+                if((y_v_deblock & (0x0001<<i))){
+                    rv40_v_loop_filter(Y, s->linesize, i*4,
+                                       y_coded & (0x0001<<  i)   ? clip[0] : 0,
+                                       y_coded & (0x0001<<(i-1)) ? clip[0] : 0,
+                                       alpha, beta, betaY, 0, 0);
+                }
+                if((y_h_deblock & (0x0001<<i)) &&  (y_top_edge & (0x0001<<i))){
+                    rv40_h_loop_filter(Y, s->linesize, i*4,
+                                       y_coded     & (0x0001<<i) ? clip[0] : 0,
+                                       y_top_coded & (0x1000<<i) ? clip[1] : 0,
+                                       alpha, beta, betaY, 0, 1);
+                }                
+            }
+            for(j = 4; j < 16; j += 4){
+                Y = s->dest[0] + j*s->linesize;
+                if((y_h_deblock & (0x0010<<j))){
+                    rv40_h_loop_filter(Y+4*s->linesize, s->linesize, j,
+                                       y_coded & (0x0010<<j) ? clip[0] : 0,
+                                       y_coded & (0x0001<<j) ? clip[0] : 0,
+                                       alpha, beta, betaY, 0, 0);
+                }
+                if((y_v_deblock & (0x0001<<j)) && !(y_left_edge & (0x0001<<j))){
+                    rv40_v_loop_filter(Y, s->linesize, j,
+                                       y_coded      & (0x0001<<j) ? clip[0] : 0,
+                                       y_left_coded & (0x0008<<j) ? clip[2] : 0,
+                                       alpha, beta, betaY, 0, 0);
+                }
+                if((y_v_deblock & (0x0001<<j)) &&  (y_left_edge & (0x0001<<j))){
+                    rv40_v_loop_filter(Y, s->linesize, j,
+                                       y_coded      & (0x0001<<j) ? clip[0] : 0,
+                                       y_left_coded & (0x0008<<j) ? clip[2] : 0,
+                                       alpha, beta, betaY, 0, 1);
+                }                
+                for(i = 1; i < 4; i++){
+                    int ij = i+j;
+                    Y += 4;
+                    if((y_h_deblock & (0x0010<<ij))){
+                        rv40_h_loop_filter(Y+4*s->linesize, s->linesize, ij,
+                                           y_coded & (0x0010<<ij) ? clip[0] : 0,
+                                           y_coded & (0x0001<<ij) ? clip[0] : 0,
+                                           alpha, beta, betaY, 0, 0);
+                    }
+                    if((y_v_deblock & (0x0001<<ij))){
+                        rv40_v_loop_filter(Y, s->linesize, ij,
+                                           y_coded & (0x0001<< ij)    ? clip[0] : 0,
+                                           y_coded & (0x0001<<(ij-1)) ? clip[0] : 0,
+                                           alpha, beta, betaY, 0, 0);
+                    }
+                }
+            }
+            for(i = 0; i < 2; i++){
+                C = s->dest[i+1];
+                if((c_h_deblock[i] & 0x4) && !(c_top_edge[i] & 0x4)){
+                    rv40_h_loop_filter(C+4*s->uvlinesize, s->uvlinesize, 0,
+                                       c_coded[i] & 0x4 ? clip[0] : 0,
+                                       c_coded[i] & 0x1 ? clip[0] : 0,
+                                       alpha, beta, betaC, 1, 0);
+                }
+                if((c_v_deblock[i] & 0x1) && !(c_left_edge[i] & 0x1)){
+                    rv40_v_loop_filter(C, s->uvlinesize, 0,
+                                       c_coded[i]      & 0x1 ? clip[0] : 0,
+                                       c_left_coded[i] & 0x2 ? clip[2] : 0,
+                                       alpha, beta, betaC, 1, 0);
+                }
+                if((c_h_deblock[i] & 0x1) &&  (c_top_edge[i] & 0x1)){
+                    rv40_h_loop_filter(C, s->uvlinesize, 0,
+                                       c_coded[i]     & 0x1 ? clip[0] : 0,
+                                       c_top_coded[i] & 0x4 ? clip[1] : 0,
+                                       alpha, beta, betaC, 1, 1);
+                }
+                if((c_v_deblock[i] & 0x1) &&  (c_left_edge[i] & 0x1)){
+                    rv40_v_loop_filter(C, s->uvlinesize, 0,
+                                       c_coded[i]      & 0x1 ? clip[0] : 0,
+                                       c_left_coded[i] & 0x2 ? clip[2] : 0,
+                                       alpha, beta, betaC, 1, 1);
+                }
+            }
+            for(i = 0; i < 2; i++){
+                C = s->dest[i+1] + 4;
+                if((c_h_deblock[i] & 0x8) && !(c_top_edge[i] & 0x8)){
+                    rv40_h_loop_filter(C+4*s->uvlinesize, s->uvlinesize, 8,
+                                       c_coded[i] & 0x8 ? clip[0] : 0,
+                                       c_coded[i] & 0x2 ? clip[0] : 0,
+                                       alpha, beta, betaC, 1, 0);
+                }
+                if((c_v_deblock[i] & 0x2)){
+                    rv40_v_loop_filter(C, s->uvlinesize, 0,
+                                       c_coded[i] & 0x2 ? clip[0] : 0,
+                                       c_coded[i] & 0x1 ? clip[0] : 0,
+                                       alpha, beta, betaC, 1, 0);
+                }
+                if((c_h_deblock[i] & 0x2) &&  (c_top_edge[i] & 0x1)){
+                    rv40_h_loop_filter(C, s->uvlinesize, 8,
+                                       c_coded[i]     & 0x2 ? clip[0] : 0,
+                                       c_top_coded[i] & 0x8 ? clip[1] : 0,
+                                       alpha, beta, betaC, 1, 1);
+                }
+            }
+            for(i = 0; i < 2; i++){
+                C = s->dest[i+1] + 4*s->uvlinesize;
+                if((c_h_deblock[i] & 0x10)){
+                    rv40_h_loop_filter(C+4*s->uvlinesize, s->uvlinesize, 0,
+                                       c_coded[i] & 0x10? clip[0] : 0,
+                                       c_coded[i] & 0x04 ? clip[0] : 0,
+                                       alpha, beta, betaC, 1, 0);
+                }
+                if((c_v_deblock[i] & 0x4) && !(c_left_edge[i] & 0x4)){
+                    rv40_v_loop_filter(C, s->uvlinesize, 8,
+                                       c_coded[i]      & 0x4 ? clip[0] : 0,
+                                       c_left_coded[i] & 0x8 ? clip[2] : 0,
+                                       alpha, beta, betaC, 1, 0);
+                }
+                if((c_v_deblock[i] & 0x4) &&  (c_left_edge[i] & 0x4)){
+                    rv40_v_loop_filter(C, s->uvlinesize, 8,
+                                       c_coded[i]      & 0x4 ? clip[0] : 0,
+                                       c_left_coded[i] & 0x8 ? clip[2] : 0,
+                                       alpha, beta, betaC, 1, 1);
+                }
+            }
+            for(i = 0; i < 2; i++){
+                C = s->dest[i+1] + 4*s->uvlinesize + 4;
+                if((c_h_deblock[i] & 0x20)){
+                    rv40_h_loop_filter(C+4*s->uvlinesize, s->uvlinesize, 8,
+                                       c_coded[i] & 0x20? clip[3] : 0,
+                                       c_coded[i] & 0x8 ? clip[0] : 0,
+                                       alpha, beta, betaC, 1, 0);
+                }
+                if((c_v_deblock[i] & 0x8)){
+                    rv40_v_loop_filter(C, s->uvlinesize, 8,
+                                       c_coded[i] & 0x8 ? clip[0] : 0,
+                                       c_coded[i] & 0x4 ? clip[0] : 0,
+                                       alpha, beta, betaC, 1, 0);
+                }
+            }
+        }
+    }
+}
+
+/**
  * Initialize decoder.
  */
 static av_cold int rv40_decode_init(AVCodecContext *avctx)
@@ -261,6 +726,8 @@
     r->parse_slice_header = rv40_parse_slice_header;
     r->decode_intra_types = rv40_decode_intra_types;
     r->decode_mb_info     = rv40_decode_mb_info;
+    r->loop_filter        = rv40_loop_filter;
+    r->set_deblock_coef   = rv40_set_deblock_coef;
     r->luma_dc_quant_i = rv40_luma_dc_quant[0];
     r->luma_dc_quant_p = rv40_luma_dc_quant[1];
     return 0;



More information about the ffmpeg-devel mailing list