00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00030 #ifndef AVCODEC_DSPUTIL_H
00031 #define AVCODEC_DSPUTIL_H
00032 
00033 #include "libavutil/intreadwrite.h"
00034 #include "avcodec.h"
00035 
00036 
00037 
00038 
00039 typedef short DCTELEM;
00040 
00041 void fdct_ifast (DCTELEM *data);
00042 void fdct_ifast248 (DCTELEM *data);
00043 void ff_jpeg_fdct_islow (DCTELEM *data);
00044 void ff_fdct248_islow (DCTELEM *data);
00045 
00046 void j_rev_dct (DCTELEM *data);
00047 void j_rev_dct4 (DCTELEM *data);
00048 void j_rev_dct2 (DCTELEM *data);
00049 void j_rev_dct1 (DCTELEM *data);
00050 void ff_wmv2_idct_c(DCTELEM *data);
00051 
00052 void ff_fdct_mmx(DCTELEM *block);
00053 void ff_fdct_mmx2(DCTELEM *block);
00054 void ff_fdct_sse2(DCTELEM *block);
00055 
00056 #define H264_IDCT(depth) \
00057 void ff_h264_idct8_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\
00058 void ff_h264_idct_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\
00059 void ff_h264_idct8_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\
00060 void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\
00061 void ff_h264_lowres_idct_add_ ## depth ## _c(uint8_t *dst, int stride, DCTELEM *block);\
00062 void ff_h264_lowres_idct_put_ ## depth ## _c(uint8_t *dst, int stride, DCTELEM *block);\
00063 void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\
00064 void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\
00065 void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\
00066 void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\
00067 void ff_h264_luma_dc_dequant_idct_ ## depth ## _c(DCTELEM *output, DCTELEM *input, int qmul);\
00068 void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(DCTELEM *block, int qmul);
00069 
00070 H264_IDCT( 8)
00071 H264_IDCT( 9)
00072 H264_IDCT(10)
00073 
00074 void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qp);
00075 void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
00076 
00077 
00078 extern const uint8_t ff_alternate_horizontal_scan[64];
00079 extern const uint8_t ff_alternate_vertical_scan[64];
00080 extern const uint8_t ff_zigzag_direct[64];
00081 extern const uint8_t ff_zigzag248_direct[64];
00082 
00083 
00084 #define MAX_NEG_CROP 1024
00085 
00086 
00087 extern uint32_t ff_squareTbl[512];
00088 extern uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
00089 
00090 #define PUTAVG_PIXELS(depth)\
00091 void ff_put_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
00092 void ff_avg_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
00093 void ff_put_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
00094 void ff_avg_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);
00095 
00096 PUTAVG_PIXELS( 8)
00097 PUTAVG_PIXELS( 9)
00098 PUTAVG_PIXELS(10)
00099 
00100 #define ff_put_pixels8x8_c ff_put_pixels8x8_8_c
00101 #define ff_avg_pixels8x8_c ff_avg_pixels8x8_8_c
00102 #define ff_put_pixels16x16_c ff_put_pixels16x16_8_c
00103 #define ff_avg_pixels16x16_c ff_avg_pixels16x16_8_c
00104 
00105 
00106 void ff_vp3_idct_c(DCTELEM *block);
00107 void ff_vp3_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block);
00108 void ff_vp3_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block);
00109 void ff_vp3_idct_dc_add_c(uint8_t *dest, int line_size, const DCTELEM *block);
00110 
00111 void ff_vp3_v_loop_filter_c(uint8_t *src, int stride, int *bounding_values);
00112 void ff_vp3_h_loop_filter_c(uint8_t *src, int stride, int *bounding_values);
00113 
00114 
00115 void ff_bink_idct_c    (DCTELEM *block);
00116 void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block);
00117 void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
00118 
00119 
00120 void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
00121 
00122 
00123 void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00124 void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00125 void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00126 
00127 void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
00128               int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 typedef void (*op_pixels_func)(uint8_t *block, const uint8_t *pixels, int line_size, int h);
00155 typedef void (*tpel_mc_func)(uint8_t *block, const uint8_t *pixels, int line_size, int w, int h);
00156 typedef void (*qpel_mc_func)(uint8_t *dst, uint8_t *src, int stride);
00157 typedef void (*h264_chroma_mc_func)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x, int y);
00158 
00159 typedef void (*op_fill_func)(uint8_t *block, uint8_t value, int line_size, int h);
00160 
00161 #define DEF_OLD_QPEL(name)\
00162 void ff_put_        ## name (uint8_t *dst, uint8_t *src, int stride);\
00163 void ff_put_no_rnd_ ## name (uint8_t *dst, uint8_t *src, int stride);\
00164 void ff_avg_        ## name (uint8_t *dst, uint8_t *src, int stride);
00165 
00166 DEF_OLD_QPEL(qpel16_mc11_old_c)
00167 DEF_OLD_QPEL(qpel16_mc31_old_c)
00168 DEF_OLD_QPEL(qpel16_mc12_old_c)
00169 DEF_OLD_QPEL(qpel16_mc32_old_c)
00170 DEF_OLD_QPEL(qpel16_mc13_old_c)
00171 DEF_OLD_QPEL(qpel16_mc33_old_c)
00172 DEF_OLD_QPEL(qpel8_mc11_old_c)
00173 DEF_OLD_QPEL(qpel8_mc31_old_c)
00174 DEF_OLD_QPEL(qpel8_mc12_old_c)
00175 DEF_OLD_QPEL(qpel8_mc32_old_c)
00176 DEF_OLD_QPEL(qpel8_mc13_old_c)
00177 DEF_OLD_QPEL(qpel8_mc33_old_c)
00178 
00179 #define CALL_2X_PIXELS(a, b, n)\
00180 static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
00181     b(block  , pixels  , line_size, h);\
00182     b(block+n, pixels+n, line_size, h);\
00183 }
00184 
00185 
00186 
00187 
00188 typedef int (*me_cmp_func)(void  *s, uint8_t *blk1, uint8_t *blk2, int line_size, int h);
00189 
00193 typedef struct ScanTable{
00194     const uint8_t *scantable;
00195     uint8_t permutated[64];
00196     uint8_t raster_end[64];
00197 #if ARCH_PPC
00198 
00199     DECLARE_ALIGNED(16, uint8_t, inverse)[64];
00200 #endif
00201 } ScanTable;
00202 
00203 void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
00204 
00205 #define EMULATED_EDGE(depth) \
00206 void ff_emulated_edge_mc_ ## depth (uint8_t *buf, const uint8_t *src, int linesize,\
00207                          int block_w, int block_h,\
00208                          int src_x, int src_y, int w, int h);
00209 
00210 EMULATED_EDGE(8)
00211 EMULATED_EDGE(9)
00212 EMULATED_EDGE(10)
00213 
00214 #define ff_emulated_edge_mc ff_emulated_edge_mc_8
00215 
00216 void ff_add_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize);
00217 void ff_put_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize);
00218 void ff_put_signed_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize);
00219 
00223 typedef struct DSPContext {
00224     
00225     void (*get_pixels)(DCTELEM *block, const uint8_t *pixels, int line_size);
00226     void (*diff_pixels)(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride);
00227     void (*put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00228     void (*put_signed_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00229     void (*put_pixels_nonclamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00230     void (*add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00231     void (*add_pixels8)(uint8_t *pixels, DCTELEM *block, int line_size);
00232     void (*add_pixels4)(uint8_t *pixels, DCTELEM *block, int line_size);
00233     int (*sum_abs_dctelem)(DCTELEM *block);
00246     void (*emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize,
00247                              int block_w, int block_h,
00248                              int src_x, int src_y, int w, int h);
00252     void (*gmc1)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x16, int y16, int rounder);
00256     void (*gmc )(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
00257                     int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
00258     void (*clear_block)(DCTELEM *block);
00259     void (*clear_blocks)(DCTELEM *blocks);
00260     int (*pix_sum)(uint8_t * pix, int line_size);
00261     int (*pix_norm1)(uint8_t * pix, int line_size);
00262 
00263 
00264     me_cmp_func sad[6]; 
00265     me_cmp_func sse[6];
00266     me_cmp_func hadamard8_diff[6];
00267     me_cmp_func dct_sad[6];
00268     me_cmp_func quant_psnr[6];
00269     me_cmp_func bit[6];
00270     me_cmp_func rd[6];
00271     me_cmp_func vsad[6];
00272     me_cmp_func vsse[6];
00273     me_cmp_func nsse[6];
00274     me_cmp_func w53[6];
00275     me_cmp_func w97[6];
00276     me_cmp_func dct_max[6];
00277     me_cmp_func dct264_sad[6];
00278 
00279     me_cmp_func me_pre_cmp[6];
00280     me_cmp_func me_cmp[6];
00281     me_cmp_func me_sub_cmp[6];
00282     me_cmp_func mb_cmp[6];
00283     me_cmp_func ildct_cmp[6]; 
00284     me_cmp_func frame_skip_cmp[6]; 
00285 
00286     int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
00287                              int size);
00288 
00299     op_pixels_func put_pixels_tab[4][4];
00300 
00311     op_pixels_func avg_pixels_tab[4][4];
00312 
00323     op_pixels_func put_no_rnd_pixels_tab[4][4];
00324 
00335     op_pixels_func avg_no_rnd_pixels_tab[4][4];
00336 
00337     void (*put_no_rnd_pixels_l2[2])(uint8_t *block, const uint8_t *a, const uint8_t *b, int line_size, int h);
00338 
00349     tpel_mc_func put_tpel_pixels_tab[11]; 
00350     tpel_mc_func avg_tpel_pixels_tab[11]; 
00351 
00352     qpel_mc_func put_qpel_pixels_tab[2][16];
00353     qpel_mc_func avg_qpel_pixels_tab[2][16];
00354     qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
00355     qpel_mc_func avg_no_rnd_qpel_pixels_tab[2][16];
00356     qpel_mc_func put_mspel_pixels_tab[8];
00357 
00361     h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
00362     h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
00363 
00364     qpel_mc_func put_h264_qpel_pixels_tab[4][16];
00365     qpel_mc_func avg_h264_qpel_pixels_tab[4][16];
00366 
00367     qpel_mc_func put_2tap_qpel_pixels_tab[4][16];
00368     qpel_mc_func avg_2tap_qpel_pixels_tab[4][16];
00369 
00370     me_cmp_func pix_abs[2][4];
00371 
00372     
00373     void (*add_bytes)(uint8_t *dst, uint8_t *src, int w);
00374     void (*diff_bytes)(uint8_t *dst, uint8_t *src1, uint8_t *src2,int w);
00379     void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top);
00380     void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top);
00381     int  (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src, int w, int left);
00382     void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha);
00383     
00384     void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
00385     void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len);
00386 
00387     void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
00388     void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
00389 
00390     void (*h261_loop_filter)(uint8_t *src, int stride);
00391 
00392     void (*x8_v_loop_filter)(uint8_t *src, int stride, int qscale);
00393     void (*x8_h_loop_filter)(uint8_t *src, int stride, int qscale);
00394 
00395     void (*vp3_idct_dc_add)(uint8_t *dest, int line_size, const DCTELEM *block);
00396     void (*vp3_v_loop_filter)(uint8_t *src, int stride, int *bounding_values);
00397     void (*vp3_h_loop_filter)(uint8_t *src, int stride, int *bounding_values);
00398 
00399     
00400     void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize);
00401     void (*ac3_downmix)(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len);
00402     
00403     void (*vector_fmul)(float *dst, const float *src0, const float *src1, int len);
00404     void (*vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len);
00405     
00406     void (*vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len);
00407     
00408     void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len);
00409     
00410     void (*vector_clipf)(float *dst , const float *src , float min, float max, int len );
00419     void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
00420                                int len);
00433     void (*vector_fmul_sv_scalar[2])(float *dst, const float *src,
00434                                      const float **sv, float mul, int len);
00445     void (*sv_fmul_scalar[2])(float *dst, const float **sv,
00446                               float mul, int len);
00453     float (*scalarproduct_float)(const float *v1, const float *v2, int len);
00460     void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
00461 
00462     
00463     void (*fdct)(DCTELEM *block);
00464     void (*fdct248)(DCTELEM *block);
00465 
00466     
00467     void (*idct)(DCTELEM *block);
00468 
00474     void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block);
00475 
00480     void (*idct_add)(uint8_t *dest, int line_size, DCTELEM *block);
00481 
00494     uint8_t idct_permutation[64];
00495     int idct_permutation_type;
00496 #define FF_NO_IDCT_PERM 1
00497 #define FF_LIBMPEG2_IDCT_PERM 2
00498 #define FF_SIMPLE_IDCT_PERM 3
00499 #define FF_TRANSPOSE_IDCT_PERM 4
00500 #define FF_PARTTRANS_IDCT_PERM 5
00501 #define FF_SSE2_IDCT_PERM 6
00502 
00503     int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
00504     void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
00505 #define BASIS_SHIFT 16
00506 #define RECON_SHIFT 6
00507 
00508     void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides);
00509 #define EDGE_WIDTH 16
00510 #define EDGE_TOP    1
00511 #define EDGE_BOTTOM 2
00512 
00513     void (*prefetch)(void *mem, int stride, int h);
00514 
00515     void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00516 
00517     
00518     void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff,
00519                                int firorder, int iirorder,
00520                                unsigned int filter_shift, int32_t mask, int blocksize,
00521                                int32_t *sample_buffer);
00522 
00523     
00524     void (*x8_spatial_compensation[12])(uint8_t *src , uint8_t *dst, int linesize);
00525     void (*x8_setup_spatial_compensation)(uint8_t *src, uint8_t *dst, int linesize,
00526            int * range, int * sum,  int edges);
00527 
00533     int32_t (*scalarproduct_int16)(const int16_t *v1, const int16_t *v2, int len, int shift);
00534     
00540     int32_t (*scalarproduct_and_madd_int16)(int16_t *v1, const int16_t *v2, const int16_t *v3, int len, int mul);
00541 
00553     void (*apply_window_int16)(int16_t *output, const int16_t *input,
00554                                const int16_t *window, unsigned int len);
00555 
00556     
00557     qpel_mc_func put_rv30_tpel_pixels_tab[4][16];
00558     qpel_mc_func avg_rv30_tpel_pixels_tab[4][16];
00559 
00560     
00561     qpel_mc_func put_rv40_qpel_pixels_tab[4][16];
00562     qpel_mc_func avg_rv40_qpel_pixels_tab[4][16];
00563     h264_chroma_mc_func put_rv40_chroma_pixels_tab[3];
00564     h264_chroma_mc_func avg_rv40_chroma_pixels_tab[3];
00565 
00566     
00567     op_fill_func fill_block_tab[2];
00568     void (*scale_block)(const uint8_t src[64], uint8_t *dst, int linesize);
00569 } DSPContext;
00570 
00571 void dsputil_static_init(void);
00572 void dsputil_init(DSPContext* p, AVCodecContext *avctx);
00573 
00574 int ff_check_alignment(void);
00575 
00580 void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last);
00581 
00582 void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
00583 
00584 #define         BYTE_VEC32(c)   ((c)*0x01010101UL)
00585 #define         BYTE_VEC64(c)   ((c)*0x0001000100010001UL)
00586 
00587 static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
00588 {
00589     return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
00590 }
00591 
00592 static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
00593 {
00594     return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
00595 }
00596 
00597 static inline uint64_t rnd_avg64(uint64_t a, uint64_t b)
00598 {
00599     return (a | b) - (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1);
00600 }
00601 
00602 static inline uint64_t no_rnd_avg64(uint64_t a, uint64_t b)
00603 {
00604     return (a & b) + (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1);
00605 }
00606 
00607 static inline int get_penalty_factor(int lambda, int lambda2, int type){
00608     switch(type&0xFF){
00609     default:
00610     case FF_CMP_SAD:
00611         return lambda>>FF_LAMBDA_SHIFT;
00612     case FF_CMP_DCT:
00613         return (3*lambda)>>(FF_LAMBDA_SHIFT+1);
00614     case FF_CMP_W53:
00615         return (4*lambda)>>(FF_LAMBDA_SHIFT);
00616     case FF_CMP_W97:
00617         return (2*lambda)>>(FF_LAMBDA_SHIFT);
00618     case FF_CMP_SATD:
00619     case FF_CMP_DCT264:
00620         return (2*lambda)>>FF_LAMBDA_SHIFT;
00621     case FF_CMP_RD:
00622     case FF_CMP_PSNR:
00623     case FF_CMP_SSE:
00624     case FF_CMP_NSSE:
00625         return lambda2>>FF_LAMBDA_SHIFT;
00626     case FF_CMP_BIT:
00627         return 1;
00628     }
00629 }
00630 
00631 void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
00632 void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
00633 void dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
00634 void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx);
00635 void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
00636 void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
00637 void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
00638 void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
00639 void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
00640 
00641 void ff_dsputil_init_dwt(DSPContext *c);
00642 void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx);
00643 void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx);
00644 void ff_intrax8dsp_init(DSPContext* c, AVCodecContext *avctx);
00645 void ff_mlp_init(DSPContext* c, AVCodecContext *avctx);
00646 void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx);
00647 
00648 
00649 #if ARCH_ARM
00650 
00651 
00652 #if HAVE_NEON
00653 #   define STRIDE_ALIGN 16
00654 #endif
00655 
00656 #elif ARCH_PPC
00657 
00658 #define STRIDE_ALIGN 16
00659 
00660 #elif HAVE_MMI
00661 
00662 #define STRIDE_ALIGN 16
00663 
00664 #endif
00665 
00666 #ifndef STRIDE_ALIGN
00667 #   define STRIDE_ALIGN 8
00668 #endif
00669 
00670 #define LOCAL_ALIGNED_A(a, t, v, s, o, ...)             \
00671     uint8_t la_##v[sizeof(t s o) + (a)];                \
00672     t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
00673 
00674 #define LOCAL_ALIGNED_D(a, t, v, s, o, ...) DECLARE_ALIGNED(a, t, v) s o
00675 
00676 #define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_A(a, t, v, __VA_ARGS__,,)
00677 
00678 #if HAVE_LOCAL_ALIGNED_8
00679 #   define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,)
00680 #else
00681 #   define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED(8, t, v, __VA_ARGS__)
00682 #endif
00683 
00684 #if HAVE_LOCAL_ALIGNED_16
00685 #   define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,)
00686 #else
00687 #   define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED(16, t, v, __VA_ARGS__)
00688 #endif
00689 
00690 #define WRAPPER8_16(name8, name16)\
00691 static int name16(void  *s, uint8_t *dst, uint8_t *src, int stride, int h){\
00692     return name8(s, dst           , src           , stride, h)\
00693           +name8(s, dst+8         , src+8         , stride, h);\
00694 }
00695 
00696 #define WRAPPER8_16_SQ(name8, name16)\
00697 static int name16(void  *s, uint8_t *dst, uint8_t *src, int stride, int h){\
00698     int score=0;\
00699     score +=name8(s, dst           , src           , stride, 8);\
00700     score +=name8(s, dst+8         , src+8         , stride, 8);\
00701     if(h==16){\
00702         dst += 8*stride;\
00703         src += 8*stride;\
00704         score +=name8(s, dst           , src           , stride, 8);\
00705         score +=name8(s, dst+8         , src+8         , stride, 8);\
00706     }\
00707     return score;\
00708 }
00709 
00710 
00711 static inline void copy_block2(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00712 {
00713     int i;
00714     for(i=0; i<h; i++)
00715     {
00716         AV_WN16(dst   , AV_RN16(src   ));
00717         dst+=dstStride;
00718         src+=srcStride;
00719     }
00720 }
00721 
00722 static inline void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00723 {
00724     int i;
00725     for(i=0; i<h; i++)
00726     {
00727         AV_WN32(dst   , AV_RN32(src   ));
00728         dst+=dstStride;
00729         src+=srcStride;
00730     }
00731 }
00732 
00733 static inline void copy_block8(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00734 {
00735     int i;
00736     for(i=0; i<h; i++)
00737     {
00738         AV_WN32(dst   , AV_RN32(src   ));
00739         AV_WN32(dst+4 , AV_RN32(src+4 ));
00740         dst+=dstStride;
00741         src+=srcStride;
00742     }
00743 }
00744 
00745 static inline void copy_block9(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00746 {
00747     int i;
00748     for(i=0; i<h; i++)
00749     {
00750         AV_WN32(dst   , AV_RN32(src   ));
00751         AV_WN32(dst+4 , AV_RN32(src+4 ));
00752         dst[8]= src[8];
00753         dst+=dstStride;
00754         src+=srcStride;
00755     }
00756 }
00757 
00758 static inline void copy_block16(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00759 {
00760     int i;
00761     for(i=0; i<h; i++)
00762     {
00763         AV_WN32(dst   , AV_RN32(src   ));
00764         AV_WN32(dst+4 , AV_RN32(src+4 ));
00765         AV_WN32(dst+8 , AV_RN32(src+8 ));
00766         AV_WN32(dst+12, AV_RN32(src+12));
00767         dst+=dstStride;
00768         src+=srcStride;
00769     }
00770 }
00771 
00772 static inline void copy_block17(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00773 {
00774     int i;
00775     for(i=0; i<h; i++)
00776     {
00777         AV_WN32(dst   , AV_RN32(src   ));
00778         AV_WN32(dst+4 , AV_RN32(src+4 ));
00779         AV_WN32(dst+8 , AV_RN32(src+8 ));
00780         AV_WN32(dst+12, AV_RN32(src+12));
00781         dst[16]= src[16];
00782         dst+=dstStride;
00783         src+=srcStride;
00784     }
00785 }
00786 
00787 #endif