Home | History | Annotate | Download | only in encoder
      1 /*
      2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 
     12 #ifndef VARIANCE_H
     13 #define VARIANCE_H
     14 
     15 #define prototype_sad(sym)\
     16     unsigned int (sym)\
     17     (\
     18      unsigned char *src_ptr, \
     19      int source_stride, \
     20      unsigned char *ref_ptr, \
     21      int  ref_stride, \
     22      int max_sad\
     23     )
     24 
     25 #define prototype_sad_multi_same_address(sym)\
     26     void (sym)\
     27     (\
     28      unsigned char *src_ptr, \
     29      int source_stride, \
     30      unsigned char *ref_ptr, \
     31      int  ref_stride, \
     32      unsigned int *sad_array\
     33     )
     34 
     35 #define prototype_sad_multi_dif_address(sym)\
     36     void (sym)\
     37     (\
     38      unsigned char *src_ptr, \
     39      int source_stride, \
     40      unsigned char *ref_ptr[4], \
     41      int  ref_stride, \
     42      unsigned int *sad_array\
     43     )
     44 
     45 #define prototype_variance(sym) \
     46     unsigned int (sym) \
     47     (\
     48      unsigned char *src_ptr, \
     49      int source_stride, \
     50      unsigned char *ref_ptr, \
     51      int  ref_stride, \
     52      unsigned int *sse\
     53     )
     54 
     55 #define prototype_variance2(sym) \
     56     unsigned int (sym) \
     57     (\
     58      unsigned char *src_ptr, \
     59      int source_stride, \
     60      unsigned char *ref_ptr, \
     61      int  ref_stride, \
     62      unsigned int *sse,\
     63      int *sum\
     64     )
     65 
     66 #define prototype_subpixvariance(sym) \
     67     unsigned int (sym) \
     68     ( \
     69       unsigned char  *src_ptr, \
     70       int  source_stride, \
     71       int  xoffset, \
     72       int  yoffset, \
     73       unsigned char *ref_ptr, \
     74       int Refstride, \
     75       unsigned int *sse \
     76     );
     77 
     78 
     79 #define prototype_getmbss(sym) unsigned int (sym)(short *)
     80 
     81 #if ARCH_X86 || ARCH_X86_64
     82 #include "x86/variance_x86.h"
     83 #endif
     84 
     85 #if ARCH_ARM
     86 #include "arm/variance_arm.h"
     87 #endif
     88 
     89 #ifndef vp8_variance_sad4x4
     90 #define vp8_variance_sad4x4 vp8_sad4x4_c
     91 #endif
     92 extern prototype_sad(vp8_variance_sad4x4);
     93 
     94 #ifndef vp8_variance_sad8x8
     95 #define vp8_variance_sad8x8 vp8_sad8x8_c
     96 #endif
     97 extern prototype_sad(vp8_variance_sad8x8);
     98 
     99 #ifndef vp8_variance_sad8x16
    100 #define vp8_variance_sad8x16 vp8_sad8x16_c
    101 #endif
    102 extern prototype_sad(vp8_variance_sad8x16);
    103 
    104 #ifndef vp8_variance_sad16x8
    105 #define vp8_variance_sad16x8 vp8_sad16x8_c
    106 #endif
    107 extern prototype_sad(vp8_variance_sad16x8);
    108 
    109 #ifndef vp8_variance_sad16x16
    110 #define vp8_variance_sad16x16 vp8_sad16x16_c
    111 #endif
    112 extern prototype_sad(vp8_variance_sad16x16);
    113 
    114 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    115 
    116 #ifndef vp8_variance_sad16x16x3
    117 #define vp8_variance_sad16x16x3 vp8_sad16x16x3_c
    118 #endif
    119 extern prototype_sad_multi_same_address(vp8_variance_sad16x16x3);
    120 
    121 #ifndef vp8_variance_sad16x8x3
    122 #define vp8_variance_sad16x8x3 vp8_sad16x8x3_c
    123 #endif
    124 extern prototype_sad_multi_same_address(vp8_variance_sad16x8x3);
    125 
    126 #ifndef vp8_variance_sad8x8x3
    127 #define vp8_variance_sad8x8x3 vp8_sad8x8x3_c
    128 #endif
    129 extern prototype_sad_multi_same_address(vp8_variance_sad8x8x3);
    130 
    131 #ifndef vp8_variance_sad8x16x3
    132 #define vp8_variance_sad8x16x3 vp8_sad8x16x3_c
    133 #endif
    134 extern prototype_sad_multi_same_address(vp8_variance_sad8x16x3);
    135 
    136 #ifndef vp8_variance_sad4x4x3
    137 #define vp8_variance_sad4x4x3 vp8_sad4x4x3_c
    138 #endif
    139 extern prototype_sad_multi_same_address(vp8_variance_sad4x4x3);
    140 
    141 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    142 
    143 #ifndef vp8_variance_sad16x16x4d
    144 #define vp8_variance_sad16x16x4d vp8_sad16x16x4d_c
    145 #endif
    146 extern prototype_sad_multi_dif_address(vp8_variance_sad16x16x4d);
    147 
    148 #ifndef vp8_variance_sad16x8x4d
    149 #define vp8_variance_sad16x8x4d vp8_sad16x8x4d_c
    150 #endif
    151 extern prototype_sad_multi_dif_address(vp8_variance_sad16x8x4d);
    152 
    153 #ifndef vp8_variance_sad8x8x4d
    154 #define vp8_variance_sad8x8x4d vp8_sad8x8x4d_c
    155 #endif
    156 extern prototype_sad_multi_dif_address(vp8_variance_sad8x8x4d);
    157 
    158 #ifndef vp8_variance_sad8x16x4d
    159 #define vp8_variance_sad8x16x4d vp8_sad8x16x4d_c
    160 #endif
    161 extern prototype_sad_multi_dif_address(vp8_variance_sad8x16x4d);
    162 
    163 #ifndef vp8_variance_sad4x4x4d
    164 #define vp8_variance_sad4x4x4d vp8_sad4x4x4d_c
    165 #endif
    166 extern prototype_sad_multi_dif_address(vp8_variance_sad4x4x4d);
    167 
    168 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    169 
    170 #ifndef vp8_variance_var4x4
    171 #define vp8_variance_var4x4 vp8_variance4x4_c
    172 #endif
    173 extern prototype_variance(vp8_variance_var4x4);
    174 
    175 #ifndef vp8_variance_var8x8
    176 #define vp8_variance_var8x8 vp8_variance8x8_c
    177 #endif
    178 extern prototype_variance(vp8_variance_var8x8);
    179 
    180 #ifndef vp8_variance_var8x16
    181 #define vp8_variance_var8x16 vp8_variance8x16_c
    182 #endif
    183 extern prototype_variance(vp8_variance_var8x16);
    184 
    185 #ifndef vp8_variance_var16x8
    186 #define vp8_variance_var16x8 vp8_variance16x8_c
    187 #endif
    188 extern prototype_variance(vp8_variance_var16x8);
    189 
    190 #ifndef vp8_variance_var16x16
    191 #define vp8_variance_var16x16 vp8_variance16x16_c
    192 #endif
    193 extern prototype_variance(vp8_variance_var16x16);
    194 
    195 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    196 
    197 #ifndef vp8_variance_subpixvar4x4
    198 #define vp8_variance_subpixvar4x4 vp8_sub_pixel_variance4x4_c
    199 #endif
    200 extern prototype_subpixvariance(vp8_variance_subpixvar4x4);
    201 
    202 #ifndef vp8_variance_subpixvar8x8
    203 #define vp8_variance_subpixvar8x8 vp8_sub_pixel_variance8x8_c
    204 #endif
    205 extern prototype_subpixvariance(vp8_variance_subpixvar8x8);
    206 
    207 #ifndef vp8_variance_subpixvar8x16
    208 #define vp8_variance_subpixvar8x16 vp8_sub_pixel_variance8x16_c
    209 #endif
    210 extern prototype_subpixvariance(vp8_variance_subpixvar8x16);
    211 
    212 #ifndef vp8_variance_subpixvar16x8
    213 #define vp8_variance_subpixvar16x8 vp8_sub_pixel_variance16x8_c
    214 #endif
    215 extern prototype_subpixvariance(vp8_variance_subpixvar16x8);
    216 
    217 #ifndef vp8_variance_subpixvar16x16
    218 #define vp8_variance_subpixvar16x16 vp8_sub_pixel_variance16x16_c
    219 #endif
    220 extern prototype_subpixvariance(vp8_variance_subpixvar16x16);
    221 
    222 #ifndef vp8_variance_subpixmse16x16
    223 #define vp8_variance_subpixmse16x16 vp8_sub_pixel_mse16x16_c
    224 #endif
    225 extern prototype_subpixvariance(vp8_variance_subpixmse16x16);
    226 
    227 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    228 
    229 #ifndef vp8_variance_getmbss
    230 #define vp8_variance_getmbss vp8_get_mb_ss_c
    231 #endif
    232 extern prototype_getmbss(vp8_variance_getmbss);
    233 
    234 #ifndef vp8_variance_mse16x16
    235 #define vp8_variance_mse16x16 vp8_mse16x16_c
    236 #endif
    237 extern prototype_variance(vp8_variance_mse16x16);
    238 
    239 #ifndef vp8_variance_get16x16prederror
    240 #define vp8_variance_get16x16prederror vp8_get16x16pred_error_c
    241 #endif
    242 extern prototype_sad(vp8_variance_get16x16prederror);
    243 
    244 #ifndef vp8_variance_get8x8var
    245 #define vp8_variance_get8x8var vp8_get8x8var_c
    246 #endif
    247 extern prototype_variance2(vp8_variance_get8x8var);
    248 
    249 #ifndef vp8_variance_get16x16var
    250 #define vp8_variance_get16x16var vp8_get16x16var_c
    251 #endif
    252 extern prototype_variance2(vp8_variance_get16x16var);
    253 
    254 #ifndef vp8_variance_get4x4sse_cs
    255 #define vp8_variance_get4x4sse_cs vp8_get4x4sse_cs_c
    256 #endif
    257 extern prototype_sad(vp8_variance_get4x4sse_cs);
    258 
    259 
    260 typedef prototype_sad(*vp8_sad_fn_t);
    261 typedef prototype_sad_multi_same_address(*vp8_sad_multi_fn_t);
    262 typedef prototype_sad_multi_dif_address(*vp8_sad_multi_d_fn_t);
    263 typedef prototype_variance(*vp8_variance_fn_t);
    264 typedef prototype_variance2(*vp8_variance2_fn_t);
    265 typedef prototype_subpixvariance(*vp8_subpixvariance_fn_t);
    266 typedef prototype_getmbss(*vp8_getmbss_fn_t);
    267 typedef struct
    268 {
    269     vp8_sad_fn_t             sad4x4;
    270     vp8_sad_fn_t             sad8x8;
    271     vp8_sad_fn_t             sad8x16;
    272     vp8_sad_fn_t             sad16x8;
    273     vp8_sad_fn_t             sad16x16;
    274 
    275     vp8_variance_fn_t        var4x4;
    276     vp8_variance_fn_t        var8x8;
    277     vp8_variance_fn_t        var8x16;
    278     vp8_variance_fn_t        var16x8;
    279     vp8_variance_fn_t        var16x16;
    280 
    281     vp8_subpixvariance_fn_t  subpixvar4x4;
    282     vp8_subpixvariance_fn_t  subpixvar8x8;
    283     vp8_subpixvariance_fn_t  subpixvar8x16;
    284     vp8_subpixvariance_fn_t  subpixvar16x8;
    285     vp8_subpixvariance_fn_t  subpixvar16x16;
    286     vp8_subpixvariance_fn_t  subpixmse16x16;
    287 
    288     vp8_getmbss_fn_t         getmbss;
    289     vp8_variance_fn_t        mse16x16;
    290 
    291     vp8_sad_fn_t             get16x16prederror;
    292     vp8_variance2_fn_t       get8x8var;
    293     vp8_variance2_fn_t       get16x16var;
    294     vp8_sad_fn_t             get4x4sse_cs;
    295 
    296     vp8_sad_multi_fn_t       sad16x16x3;
    297     vp8_sad_multi_fn_t       sad16x8x3;
    298     vp8_sad_multi_fn_t       sad8x16x3;
    299     vp8_sad_multi_fn_t       sad8x8x3;
    300     vp8_sad_multi_fn_t       sad4x4x3;
    301 
    302     vp8_sad_multi_d_fn_t     sad16x16x4d;
    303     vp8_sad_multi_d_fn_t     sad16x8x4d;
    304     vp8_sad_multi_d_fn_t     sad8x16x4d;
    305     vp8_sad_multi_d_fn_t     sad8x8x4d;
    306     vp8_sad_multi_d_fn_t     sad4x4x4d;
    307 
    308 } vp8_variance_rtcd_vtable_t;
    309 
    310 typedef struct
    311 {
    312     vp8_sad_fn_t  sdf;
    313     vp8_sad_multi_fn_t sdx3f;
    314     vp8_sad_multi_d_fn_t sdx4df;
    315     vp8_variance_fn_t vf;
    316     vp8_subpixvariance_fn_t svf;
    317 } vp8_variance_fn_ptr_t;
    318 
    319 #if CONFIG_RUNTIME_CPU_DETECT
    320 #define VARIANCE_INVOKE(ctx,fn) (ctx)->fn
    321 #else
    322 #define VARIANCE_INVOKE(ctx,fn) vp8_variance_##fn
    323 #endif
    324 
    325 /* TODO: Determine if this USEBILINEAR flag is necessary. */
    326 #define USEBILINEAR
    327 
    328 #endif
    329