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