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 void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride);
00057 void ff_h264_idct_add_c(uint8_t *dst, DCTELEM *block, int stride);
00058 void ff_h264_idct8_dc_add_c(uint8_t *dst, DCTELEM *block, int stride);
00059 void ff_h264_idct_dc_add_c(uint8_t *dst, DCTELEM *block, int stride);
00060 void ff_h264_lowres_idct_add_c(uint8_t *dst, int stride, DCTELEM *block);
00061 void ff_h264_lowres_idct_put_c(uint8_t *dst, int stride, DCTELEM *block);
00062 void ff_h264_idct_add16_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
00063 void ff_h264_idct_add16intra_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
00064 void ff_h264_idct8_add4_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
00065 void ff_h264_idct_add8_c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
00066
00067 void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1,
00068 const float *win, float add_bias, int len);
00069 void ff_float_to_int16_c(int16_t *dst, const float *src, long len);
00070 void ff_float_to_int16_interleave_c(int16_t *dst, const float **src, long len, int channels);
00071
00072
00073 extern const uint8_t ff_alternate_horizontal_scan[64];
00074 extern const uint8_t ff_alternate_vertical_scan[64];
00075 extern const uint8_t ff_zigzag_direct[64];
00076 extern const uint8_t ff_zigzag248_direct[64];
00077
00078
00079 #define MAX_NEG_CROP 1024
00080
00081
00082 extern uint32_t ff_squareTbl[512];
00083 extern uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
00084
00085 void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, int stride);
00086 void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, int stride);
00087 void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, int stride);
00088 void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, int stride);
00089
00090
00091 void ff_vp3_idct_c(DCTELEM *block);
00092 void ff_vp3_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block);
00093 void ff_vp3_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block);
00094 void ff_vp3_idct_dc_add_c(uint8_t *dest, int line_size, const DCTELEM *block);
00095
00096 void ff_vp3_v_loop_filter_c(uint8_t *src, int stride, int *bounding_values);
00097 void ff_vp3_h_loop_filter_c(uint8_t *src, int stride, int *bounding_values);
00098
00099
00100 void ff_bink_idct_c (DCTELEM *block);
00101 void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block);
00102 void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
00103
00104
00105 void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
00106
00107
00108 #if LIBAVCODEC_VERSION_MAJOR < 53
00109
00112 attribute_deprecated
00113 void ff_img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00114 #endif
00115
00116 void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00117 void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00118 void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00119
00120 void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
00121 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 typedef void (*op_pixels_func)(uint8_t *block, const uint8_t *pixels, int line_size, int h);
00148 typedef void (*tpel_mc_func)(uint8_t *block, const uint8_t *pixels, int line_size, int w, int h);
00149 typedef void (*qpel_mc_func)(uint8_t *dst, uint8_t *src, int stride);
00150 typedef void (*h264_chroma_mc_func)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x, int y);
00151
00152 typedef void (*op_fill_func)(uint8_t *block, uint8_t value, int line_size, int h);
00153
00154 #define DEF_OLD_QPEL(name)\
00155 void ff_put_ ## name (uint8_t *dst, uint8_t *src, int stride);\
00156 void ff_put_no_rnd_ ## name (uint8_t *dst, uint8_t *src, int stride);\
00157 void ff_avg_ ## name (uint8_t *dst, uint8_t *src, int stride);
00158
00159 DEF_OLD_QPEL(qpel16_mc11_old_c)
00160 DEF_OLD_QPEL(qpel16_mc31_old_c)
00161 DEF_OLD_QPEL(qpel16_mc12_old_c)
00162 DEF_OLD_QPEL(qpel16_mc32_old_c)
00163 DEF_OLD_QPEL(qpel16_mc13_old_c)
00164 DEF_OLD_QPEL(qpel16_mc33_old_c)
00165 DEF_OLD_QPEL(qpel8_mc11_old_c)
00166 DEF_OLD_QPEL(qpel8_mc31_old_c)
00167 DEF_OLD_QPEL(qpel8_mc12_old_c)
00168 DEF_OLD_QPEL(qpel8_mc32_old_c)
00169 DEF_OLD_QPEL(qpel8_mc13_old_c)
00170 DEF_OLD_QPEL(qpel8_mc33_old_c)
00171
00172 #define CALL_2X_PIXELS(a, b, n)\
00173 static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
00174 b(block , pixels , line_size, h);\
00175 b(block+n, pixels+n, line_size, h);\
00176 }
00177
00178
00179
00180
00181 typedef int (*me_cmp_func)(void *s, uint8_t *blk1, uint8_t *blk2, int line_size, int h);
00182
00186 typedef struct ScanTable{
00187 const uint8_t *scantable;
00188 uint8_t permutated[64];
00189 uint8_t raster_end[64];
00190 #if ARCH_PPC
00191
00192 DECLARE_ALIGNED(16, uint8_t, inverse)[64];
00193 #endif
00194 } ScanTable;
00195
00196 void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
00197
00198 void ff_emulated_edge_mc(uint8_t *buf, const uint8_t *src, int linesize,
00199 int block_w, int block_h,
00200 int src_x, int src_y, int w, int h);
00201
00205 typedef struct DSPContext {
00206
00207 void (*get_pixels)(DCTELEM *block, const uint8_t *pixels, int line_size);
00208 void (*diff_pixels)(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride);
00209 void (*put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00210 void (*put_signed_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00211 void (*put_pixels_nonclamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00212 void (*add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00213 void (*add_pixels8)(uint8_t *pixels, DCTELEM *block, int line_size);
00214 void (*add_pixels4)(uint8_t *pixels, DCTELEM *block, int line_size);
00215 int (*sum_abs_dctelem)(DCTELEM *block);
00219 void (*gmc1)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x16, int y16, int rounder);
00223 void (*gmc )(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
00224 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
00225 void (*clear_block)(DCTELEM *block);
00226 void (*clear_blocks)(DCTELEM *blocks);
00227 int (*pix_sum)(uint8_t * pix, int line_size);
00228 int (*pix_norm1)(uint8_t * pix, int line_size);
00229
00230
00231 me_cmp_func sad[6];
00232 me_cmp_func sse[6];
00233 me_cmp_func hadamard8_diff[6];
00234 me_cmp_func dct_sad[6];
00235 me_cmp_func quant_psnr[6];
00236 me_cmp_func bit[6];
00237 me_cmp_func rd[6];
00238 me_cmp_func vsad[6];
00239 me_cmp_func vsse[6];
00240 me_cmp_func nsse[6];
00241 me_cmp_func w53[6];
00242 me_cmp_func w97[6];
00243 me_cmp_func dct_max[6];
00244 me_cmp_func dct264_sad[6];
00245
00246 me_cmp_func me_pre_cmp[6];
00247 me_cmp_func me_cmp[6];
00248 me_cmp_func me_sub_cmp[6];
00249 me_cmp_func mb_cmp[6];
00250 me_cmp_func ildct_cmp[6];
00251 me_cmp_func frame_skip_cmp[6];
00252
00253 int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
00254 int size);
00255
00266 op_pixels_func put_pixels_tab[4][4];
00267
00278 op_pixels_func avg_pixels_tab[4][4];
00279
00290 op_pixels_func put_no_rnd_pixels_tab[4][4];
00291
00302 op_pixels_func avg_no_rnd_pixels_tab[4][4];
00303
00304 void (*put_no_rnd_pixels_l2[2])(uint8_t *block, const uint8_t *a, const uint8_t *b, int line_size, int h);
00305
00316 tpel_mc_func put_tpel_pixels_tab[11];
00317 tpel_mc_func avg_tpel_pixels_tab[11];
00318
00319 qpel_mc_func put_qpel_pixels_tab[2][16];
00320 qpel_mc_func avg_qpel_pixels_tab[2][16];
00321 qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
00322 qpel_mc_func avg_no_rnd_qpel_pixels_tab[2][16];
00323 qpel_mc_func put_mspel_pixels_tab[8];
00324
00328 h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
00329 h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
00330
00331 h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3];
00332 h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3];
00333
00334 qpel_mc_func put_h264_qpel_pixels_tab[4][16];
00335 qpel_mc_func avg_h264_qpel_pixels_tab[4][16];
00336
00337 qpel_mc_func put_2tap_qpel_pixels_tab[4][16];
00338 qpel_mc_func avg_2tap_qpel_pixels_tab[4][16];
00339
00340 me_cmp_func pix_abs[2][4];
00341
00342
00343 void (*add_bytes)(uint8_t *dst, uint8_t *src, int w);
00344 void (*add_bytes_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w);
00345 void (*diff_bytes)(uint8_t *dst, uint8_t *src1, uint8_t *src2,int w);
00350 void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top);
00351 void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top);
00352 int (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src, int w, int left);
00353 void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha);
00354
00355 void (*add_png_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp);
00356 void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
00357
00358 void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
00359 void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
00360
00361 void (*h261_loop_filter)(uint8_t *src, int stride);
00362
00363 void (*x8_v_loop_filter)(uint8_t *src, int stride, int qscale);
00364 void (*x8_h_loop_filter)(uint8_t *src, int stride, int qscale);
00365
00366 void (*vp3_idct_dc_add)(uint8_t *dest, int line_size, const DCTELEM *block);
00367 void (*vp3_v_loop_filter)(uint8_t *src, int stride, int *bounding_values);
00368 void (*vp3_h_loop_filter)(uint8_t *src, int stride, int *bounding_values);
00369
00370
00371 void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize);
00372 void (*ac3_downmix)(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len);
00373
00374 void (*lpc_compute_autocorr)(const int32_t *data, int len, int lag, double *autoc);
00375
00376 void (*vector_fmul)(float *dst, const float *src, int len);
00377 void (*vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len);
00378
00379 void (*vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len);
00380
00381 void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len);
00382
00383 void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len);
00384 void (*vector_clipf)(float *dst , const float *src , float min, float max, int len );
00393 void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
00394 int len);
00407 void (*vector_fmul_sv_scalar[2])(float *dst, const float *src,
00408 const float **sv, float mul, int len);
00419 void (*sv_fmul_scalar[2])(float *dst, const float **sv,
00420 float mul, int len);
00427 float (*scalarproduct_float)(const float *v1, const float *v2, int len);
00434 void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
00435
00436
00437
00438 void (*float_to_int16)(int16_t *dst, const float *src, long len);
00439 void (*float_to_int16_interleave)(int16_t *dst, const float **src, long len, int channels);
00440
00441
00442 void (*fdct)(DCTELEM *block);
00443 void (*fdct248)(DCTELEM *block);
00444
00445
00446 void (*idct)(DCTELEM *block);
00447
00453 void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block);
00454
00459 void (*idct_add)(uint8_t *dest, int line_size, DCTELEM *block);
00460
00473 uint8_t idct_permutation[64];
00474 int idct_permutation_type;
00475 #define FF_NO_IDCT_PERM 1
00476 #define FF_LIBMPEG2_IDCT_PERM 2
00477 #define FF_SIMPLE_IDCT_PERM 3
00478 #define FF_TRANSPOSE_IDCT_PERM 4
00479 #define FF_PARTTRANS_IDCT_PERM 5
00480 #define FF_SSE2_IDCT_PERM 6
00481
00482 int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
00483 void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
00484 #define BASIS_SHIFT 16
00485 #define RECON_SHIFT 6
00486
00487 void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w);
00488 #define EDGE_WIDTH 16
00489
00490 void (*prefetch)(void *mem, int stride, int h);
00491
00492 void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00493
00494
00495 void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff,
00496 int firorder, int iirorder,
00497 unsigned int filter_shift, int32_t mask, int blocksize,
00498 int32_t *sample_buffer);
00499
00500
00501 void (*vc1_inv_trans_8x8)(DCTELEM *b);
00502 void (*vc1_inv_trans_8x4)(uint8_t *dest, int line_size, DCTELEM *block);
00503 void (*vc1_inv_trans_4x8)(uint8_t *dest, int line_size, DCTELEM *block);
00504 void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block);
00505 void (*vc1_inv_trans_8x8_dc)(uint8_t *dest, int line_size, DCTELEM *block);
00506 void (*vc1_inv_trans_8x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
00507 void (*vc1_inv_trans_4x8_dc)(uint8_t *dest, int line_size, DCTELEM *block);
00508 void (*vc1_inv_trans_4x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
00509 void (*vc1_v_overlap)(uint8_t* src, int stride);
00510 void (*vc1_h_overlap)(uint8_t* src, int stride);
00511 void (*vc1_v_loop_filter4)(uint8_t *src, int stride, int pq);
00512 void (*vc1_h_loop_filter4)(uint8_t *src, int stride, int pq);
00513 void (*vc1_v_loop_filter8)(uint8_t *src, int stride, int pq);
00514 void (*vc1_h_loop_filter8)(uint8_t *src, int stride, int pq);
00515 void (*vc1_v_loop_filter16)(uint8_t *src, int stride, int pq);
00516 void (*vc1_h_loop_filter16)(uint8_t *src, int stride, int pq);
00517
00518
00519
00520 op_pixels_func put_vc1_mspel_pixels_tab[16];
00521 op_pixels_func avg_vc1_mspel_pixels_tab[16];
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
00542
00543 qpel_mc_func put_rv30_tpel_pixels_tab[4][16];
00544 qpel_mc_func avg_rv30_tpel_pixels_tab[4][16];
00545
00546
00547 qpel_mc_func put_rv40_qpel_pixels_tab[4][16];
00548 qpel_mc_func avg_rv40_qpel_pixels_tab[4][16];
00549 h264_chroma_mc_func put_rv40_chroma_pixels_tab[3];
00550 h264_chroma_mc_func avg_rv40_chroma_pixels_tab[3];
00551
00552
00553 op_fill_func fill_block_tab[2];
00554 void (*scale_block)(const uint8_t src[64], uint8_t *dst, int linesize);
00555 } DSPContext;
00556
00557 void dsputil_static_init(void);
00558 void dsputil_init(DSPContext* p, AVCodecContext *avctx);
00559
00560 int ff_check_alignment(void);
00561
00566 void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last);
00567
00568 void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
00569
00570 #define BYTE_VEC32(c) ((c)*0x01010101UL)
00571
00572 static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
00573 {
00574 return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
00575 }
00576
00577 static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
00578 {
00579 return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
00580 }
00581
00582 static inline int get_penalty_factor(int lambda, int lambda2, int type){
00583 switch(type&0xFF){
00584 default:
00585 case FF_CMP_SAD:
00586 return lambda>>FF_LAMBDA_SHIFT;
00587 case FF_CMP_DCT:
00588 return (3*lambda)>>(FF_LAMBDA_SHIFT+1);
00589 case FF_CMP_W53:
00590 return (4*lambda)>>(FF_LAMBDA_SHIFT);
00591 case FF_CMP_W97:
00592 return (2*lambda)>>(FF_LAMBDA_SHIFT);
00593 case FF_CMP_SATD:
00594 case FF_CMP_DCT264:
00595 return (2*lambda)>>FF_LAMBDA_SHIFT;
00596 case FF_CMP_RD:
00597 case FF_CMP_PSNR:
00598 case FF_CMP_SSE:
00599 case FF_CMP_NSSE:
00600 return lambda2>>FF_LAMBDA_SHIFT;
00601 case FF_CMP_BIT:
00602 return 1;
00603 }
00604 }
00605
00611 #define emms_c()
00612
00613 void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
00614 void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
00615 void dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
00616 void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx);
00617 void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
00618 void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
00619 void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
00620 void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
00621 void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
00622
00623 void ff_dsputil_init_dwt(DSPContext *c);
00624 void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx);
00625 void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx);
00626 void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx);
00627 void ff_intrax8dsp_init(DSPContext* c, AVCodecContext *avctx);
00628 void ff_mlp_init(DSPContext* c, AVCodecContext *avctx);
00629 void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx);
00630
00631 #if HAVE_MMX
00632
00633 #undef emms_c
00634
00635 static inline void emms(void)
00636 {
00637 __asm__ volatile ("emms;":::"memory");
00638 }
00639
00640 #define emms_c() emms()
00641
00642 #elif ARCH_ARM
00643
00644 #if HAVE_NEON
00645 # define STRIDE_ALIGN 16
00646 #endif
00647
00648 #elif ARCH_PPC
00649
00650 #define STRIDE_ALIGN 16
00651
00652 #elif HAVE_MMI
00653
00654 #define STRIDE_ALIGN 16
00655
00656 #endif
00657
00658 #ifndef STRIDE_ALIGN
00659 # define STRIDE_ALIGN 8
00660 #endif
00661
00662 #define LOCAL_ALIGNED(a, t, v, s, ...) \
00663 uint8_t la_##v[sizeof(t s __VA_ARGS__) + (a)]; \
00664 t (*v) __VA_ARGS__ = (void *)FFALIGN((uintptr_t)la_##v, a)
00665
00666 #if HAVE_LOCAL_ALIGNED_8
00667 # define LOCAL_ALIGNED_8(t, v, s, ...) DECLARE_ALIGNED(8, t, v) s __VA_ARGS__
00668 #else
00669 # define LOCAL_ALIGNED_8(t, v, s, ...) LOCAL_ALIGNED(8, t, v, s, __VA_ARGS__)
00670 #endif
00671
00672 #if HAVE_LOCAL_ALIGNED_16
00673 # define LOCAL_ALIGNED_16(t, v, s, ...) DECLARE_ALIGNED(16, t, v) s __VA_ARGS__
00674 #else
00675 # define LOCAL_ALIGNED_16(t, v, s, ...) LOCAL_ALIGNED(16, t, v, s, __VA_ARGS__)
00676 #endif
00677
00678
00679 void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3],
00680 int orig_linesize[3], int coded_linesize,
00681 AVCodecContext *avctx);
00682
00683 #define WRAPPER8_16(name8, name16)\
00684 static int name16(void *s, uint8_t *dst, uint8_t *src, int stride, int h){\
00685 return name8(s, dst , src , stride, h)\
00686 +name8(s, dst+8 , src+8 , stride, h);\
00687 }
00688
00689 #define WRAPPER8_16_SQ(name8, name16)\
00690 static int name16(void *s, uint8_t *dst, uint8_t *src, int stride, int h){\
00691 int score=0;\
00692 score +=name8(s, dst , src , stride, 8);\
00693 score +=name8(s, dst+8 , src+8 , stride, 8);\
00694 if(h==16){\
00695 dst += 8*stride;\
00696 src += 8*stride;\
00697 score +=name8(s, dst , src , stride, 8);\
00698 score +=name8(s, dst+8 , src+8 , stride, 8);\
00699 }\
00700 return score;\
00701 }
00702
00703
00704 static inline void copy_block2(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00705 {
00706 int i;
00707 for(i=0; i<h; i++)
00708 {
00709 AV_WN16(dst , AV_RN16(src ));
00710 dst+=dstStride;
00711 src+=srcStride;
00712 }
00713 }
00714
00715 static inline void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00716 {
00717 int i;
00718 for(i=0; i<h; i++)
00719 {
00720 AV_WN32(dst , AV_RN32(src ));
00721 dst+=dstStride;
00722 src+=srcStride;
00723 }
00724 }
00725
00726 static inline void copy_block8(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00727 {
00728 int i;
00729 for(i=0; i<h; i++)
00730 {
00731 AV_WN32(dst , AV_RN32(src ));
00732 AV_WN32(dst+4 , AV_RN32(src+4 ));
00733 dst+=dstStride;
00734 src+=srcStride;
00735 }
00736 }
00737
00738 static inline void copy_block9(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00739 {
00740 int i;
00741 for(i=0; i<h; i++)
00742 {
00743 AV_WN32(dst , AV_RN32(src ));
00744 AV_WN32(dst+4 , AV_RN32(src+4 ));
00745 dst[8]= src[8];
00746 dst+=dstStride;
00747 src+=srcStride;
00748 }
00749 }
00750
00751 static inline void copy_block16(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00752 {
00753 int i;
00754 for(i=0; i<h; i++)
00755 {
00756 AV_WN32(dst , AV_RN32(src ));
00757 AV_WN32(dst+4 , AV_RN32(src+4 ));
00758 AV_WN32(dst+8 , AV_RN32(src+8 ));
00759 AV_WN32(dst+12, AV_RN32(src+12));
00760 dst+=dstStride;
00761 src+=srcStride;
00762 }
00763 }
00764
00765 static inline void copy_block17(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
00766 {
00767 int i;
00768 for(i=0; i<h; i++)
00769 {
00770 AV_WN32(dst , AV_RN32(src ));
00771 AV_WN32(dst+4 , AV_RN32(src+4 ));
00772 AV_WN32(dst+8 , AV_RN32(src+8 ));
00773 AV_WN32(dst+12, AV_RN32(src+12));
00774 dst[16]= src[16];
00775 dst+=dstStride;
00776 src+=srcStride;
00777 }
00778 }
00779
00780 #endif