[FFmpeg-devel] [PATCH] RV40 Loop Filter, hopefully final version

Michael Niedermayer michaelni
Sun Nov 23 14:49:18 CET 2008


On Sun, Nov 23, 2008 at 09:15:58AM +0200, Kostya wrote:
> On Sun, Nov 23, 2008 at 09:15:03AM +0200, Kostya wrote:
> [...]
> 
> And here's the patch itself.

> Index: libavcodec/rv40.c
> ===================================================================
> --- libavcodec/rv40.c	(revision 15827)
> +++ libavcodec/rv40.c	(working copy)
> @@ -1,4 +1,4 @@
> -/*
> +    /*
>   * RV40 decoder
>   * Copyright (c) 2007 Konstantin Shishkov
>   *

cosmetic


> @@ -285,7 +285,367 @@
>      }
>  }
>  

> +static inline void rv40_adaptive_loop_filter(uint8_t *src, const int step,
> +                                             const int stride, const int dmode,
> +                                             const int lim_q1, const int lim_p1,
> +                                             const int alpha,
> +                                             const int beta, const int beta2,
> +                                             const int chroma, const int edge)
> +{
> +    int diff_p1p0[4], diff_q1q0[4], diff_p1p2[4], diff_q1q2[4];
> +    int sum_p1p0 = 0, sum_q1q0 = 0, sum_p1p2 = 0, sum_q1q2 = 0;
> +    uint8_t *ptr;
> +    int flag_strong0 = 1, flag_strong1 = 1;
> +    int strength0 = 3, strength1 = 3;
> +    int i;
> +    int lims;
> +
> +    for(i = 0, ptr = src; i < 4; i++, ptr += stride){
> +        diff_p1p0[i] = ptr[-2*step] - ptr[-1*step];
> +        diff_q1q0[i] = ptr[ 1*step] - ptr[ 0*step];
> +        sum_p1p0 += diff_p1p0[i];
> +        sum_q1q0 += diff_q1q0[i];
> +    }
> +    if(FFABS(sum_p1p0) >= (beta<<2))
> +        strength0 = 1;
> +    if(FFABS(sum_q1q0) >= (beta<<2))
> +        strength1 = 1;

strength0/1 only have 2 values thus they could be 0/1 flags with appropriate
names


[...]
> +            /* This pattern contains bits signalling that horizontal edges of
> +             * the current block can be filtered.
> +             * That happens when either of adjacent subblocks is coded or lies on
> +             * the edge of 8x8 blocks with motion vectors differing by more than
> +             * 3/4 pel in any component (any edge orientation for some reason).
> +             */
> +            y_h_deblock =   cbp[POS_CUR]
> +                        |  (cbp[POS_BOTTOM]                        << 16)
> +                        | ((cbp[POS_CUR]                           <<  4) & ~MASK_Y_TOP_ROW)
> +                        | ((cbp[POS_TOP]        & MASK_Y_LAST_ROW) >> 12)
> +                        |   mvmasks[POS_CUR]
> +                        |  (mvmasks[POS_BOTTOM]                    << 16);
> +            /* This pattern contains bits signalling that vertical edges of
> +             * the current block can be filtered.
> +             * That happens when either of adjacent subblocks is coded or lies on
> +             * the edge of 8x8 blocks with motion vectors differing by more than
> +             * 3/4 pel in any component (any edge orientation for some reason).
> +             */
> +            y_v_deblock =   cbp[POS_CUR]
> +                        | ((cbp[POS_CUR]                      << 1) & ~MASK_Y_LEFT_COL)
> +                        | ((cbp[POS_LEFT] & MASK_Y_RIGHT_COL) >> 3)
> +                        |   mvmasks[POS_CUR];

> +            /* We should add motion vector mask and the bottom CBP to the current
> +             * CBP since it's checked in this combination afterwards.
> +             */
> +            cbp[POS_CUR] =  cbp[POS_CUR]
> +                         | (cbp[POS_BOTTOM]     << 16)
> +                         |  mvmasks[POS_CUR]
> +                         | (mvmasks[POS_BOTTOM] << 16);

if mvmasks is added it is no longer cbp



> +            if(!s->mb_x)
> +                y_v_deblock &= ~MASK_Y_LEFT_COL;
> +            if(!s->mb_y)
> +                y_h_deblock &= ~MASK_Y_TOP_ROW;
> +            if(s->mb_y == s->mb_height - 1 || (mb_strong[POS_CUR] || mb_strong[POS_BOTTOM]))
> +                y_h_deblock &= ~(MASK_Y_TOP_ROW << 16);
> +            /* Calculating chroma patterns is similar and easier since there is
> +             * no motion vector pattern for them.
> +             */
> +            for(i = 0; i < 2; i++){
> +                c_v_deblock[i] = ((uvcbp[POS_CUR][i]                        << 1) & ~MASK_C_RIGHT_COL)
> +                               | ((uvcbp[POS_LEFT][i]   & MASK_C_RIGHT_COL) >> 1)
> +                               |  (uvcbp[POS_BOTTOM][i]                     << 4)
> +                               | uvcbp[POS_CUR][i];
> +                c_h_deblock[i] =  (uvcbp[POS_BOTTOM][i]                     << 4)
> +                               | uvcbp[POS_CUR][i]
> +                               | ((uvcbp[POS_TOP][i]    & MASK_C_LAST_ROW)  >> 2)
> +                               | (uvcbp[POS_CUR][i]                         << 2);

> +                uvcbp[POS_CUR][i] = (uvcbp[POS_BOTTOM][i] << 4) | uvcbp[POS_CUR][i];

|=
and i think this can be done before the v/hdeblock

[...]
> +                            if(!i){
> +                                clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0;
> +                            }else{
> +                                clip_left = uvcbp[POS_CUR][k]  & (MASK_CUR << (ij-1))  ? clip[POS_CUR]  : 0;
> +                            }

if(i)
else
is clearer than if(!i) IMHO

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081123/47045690/attachment.pgp>



More information about the ffmpeg-devel mailing list