[FFmpeg-devel] [RFC] RV30 1/3pel MC functions

Michael Niedermayer michaelni
Sun Dec 23 17:36:56 CET 2007


On Sun, Dec 23, 2007 at 04:33:04PM +0200, Kostya wrote:
> Here is my attempt to use RV30 1/3pel MC in the same way as
> standard H.264 ones.

[...]
> +#define MOD3(a) ((((a) % 3) + 3) % 3)
> +
>  /**
>   * generic motion compensation function
>   *

> @@ -572,21 +574,15 @@
>      int is16x16 = 1;
>  
>      if(thirdpel){
> -#if 0 /// todo
>          int lx, ly;
>  
>          mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] / 3;
>          my = s->current_picture_ptr->motion_val[dir][mv_pos][1] / 3;
> -        lx = ((s->current_picture_ptr->motion_val[dir][mv_pos][0] % 3) + 3) % 3;
> -        ly = ((s->current_picture_ptr->motion_val[dir][mv_pos][1] % 3) + 3) % 3;
> -        dxy = ly*3 + lx;
> -        uvmx =
> -#endif
> -        mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 2;
> -        my = s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 2;
> -        dxy = ((my & 3) << 2) | (mx & 3);
> -        uvmx = mx & 6;
> -        uvmy = my & 6;
> +        lx = MOD3(s->current_picture_ptr->motion_val[dir][mv_pos][0]);
> +        ly = MOD3(s->current_picture_ptr->motion_val[dir][mv_pos][1]);
> +        dxy = ly*4 + lx;
> +        uvmx = MOD3(s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 1);
> +        uvmy = MOD3(s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 1);
>      }else{
>          mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 2;
>          my = s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 2;

something doesnt look correct on this
the mx/my are not rounded the same way as lx/ly, this cant be correct
what you likely want is
mx= (A + (3<<24)) / 3 - (1<<24);
my= (B + (3<<24)) / 3 - (1<<24);
lx= (A + (3<<24)) % 3;
ly= (B + (3<<24)) % 3;

also this is a duplication of svq3_mc_dirs THIRDPEL_MODE




> @@ -643,15 +639,24 @@
>                          const int width, const int height, int dir)
>  {
>      rv34_mc(r, block_type, xoff, yoff, mv_off, width, height, dir, r->rv30,
> -            r->s.dsp.put_h264_qpel_pixels_tab, r->s.dsp.put_h264_chroma_pixels_tab);
> +            r->rv30 ? r->s.dsp.put_rv30_qpel_pixels_tab
> +                    : r->s.dsp.put_h264_qpel_pixels_tab,
> +            r->rv30 ? r->s.dsp.put_rv30_chroma_pixels_tab
> +                    : r->s.dsp.put_h264_chroma_pixels_tab);
>  }
>  

>  static void rv34_mc_2mv(RV34DecContext *r, const int block_type)
>  {
>      rv34_mc(r, block_type, 0, 0, 0, 2, 2, 0, r->rv30,
> -            r->s.dsp.put_h264_qpel_pixels_tab, r->s.dsp.put_h264_chroma_pixels_tab);
> +            r->rv30 ? r->s.dsp.put_rv30_qpel_pixels_tab
> +                    : r->s.dsp.put_h264_qpel_pixels_tab,
> +            r->rv30 ? r->s.dsp.put_rv30_chroma_pixels_tab
> +                    : r->s.dsp.put_h264_chroma_pixels_tab);
>      rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->rv30,
> -            r->s.dsp.avg_h264_qpel_pixels_tab, r->s.dsp.avg_h264_chroma_pixels_tab);
> +            r->rv30 ? r->s.dsp.avg_rv30_qpel_pixels_tab
> +                    : r->s.dsp.avg_h264_qpel_pixels_tab,
> +            r->rv30 ? r->s.dsp.avg_rv30_chroma_pixels_tab
> +                    : r->s.dsp.avg_h264_chroma_pixels_tab);
>  }

qpel stands for quarter pel -> 1/4 pel third pel would be tpel :)


[...]
> +#define op_avg(a, b)  a = (((a)+cm[((b) + 32)>>6]+1)>>1)
> +#define op_put(a, b)  a = cm[((b) + 32)>>6]
> +
> +static const int coeffs[4] = {8, 5, 3, 0};
> +
> +#define RV30_CHROMA(OPNAME, OP) \
> +static void OPNAME ## rv30_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
> +    const int A=coeffs[  x]*coeffs[  y];\
> +    const int B=coeffs[3-x]*coeffs[  y];\
> +    const int C=coeffs[  x]*coeffs[3-y];\
> +    const int D=coeffs[3-x]*coeffs[3-y];\
> +    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
> +    int i;\
> +\
> +    for(i=0; i<h; i++)\
> +    {\
> +        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
> +        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
> +        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
> +        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
> +        dst+= stride;\
> +        src+= stride;\
> +    }\
> +}\
> +\
> +static void OPNAME ## rv30_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
> +    const int A=coeffs[  x]*coeffs[  y];\
> +    const int B=coeffs[3-x]*coeffs[  y];\
> +    const int C=coeffs[  x]*coeffs[3-y];\
> +    const int D=coeffs[3-x]*coeffs[3-y];\
> +    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
> +    int i;\
> +\
> +    for(i=0; i<h; i++)\
> +    {\
> +        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
> +        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
> +        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
> +        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
> +        OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
> +        OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
> +        OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
> +        OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
> +        dst+= stride;\
> +        src+= stride;\
> +    }\
> +}\
> +\

this looks like a duplication of the h264 chroma mc functions, you dont need new
functions for mapping 1->3, 2->5, 3->8

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- 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/20071223/03fc733d/attachment.pgp>



More information about the ffmpeg-devel mailing list