00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef FFMPEG_DSPUTIL_H
00031 #define FFMPEG_DSPUTIL_H
00032
00033 #include "avcodec.h"
00034
00035
00036
00037
00038 typedef short DCTELEM;
00039 typedef int DWTELEM;
00040 typedef short IDWTELEM;
00041
00042 void fdct_ifast (DCTELEM *data);
00043 void fdct_ifast248 (DCTELEM *data);
00044 void ff_jpeg_fdct_islow (DCTELEM *data);
00045 void ff_fdct248_islow (DCTELEM *data);
00046
00047 void j_rev_dct (DCTELEM *data);
00048 void j_rev_dct4 (DCTELEM *data);
00049 void j_rev_dct2 (DCTELEM *data);
00050 void j_rev_dct1 (DCTELEM *data);
00051 void ff_wmv2_idct_c(DCTELEM *data);
00052
00053 void ff_fdct_mmx(DCTELEM *block);
00054 void ff_fdct_mmx2(DCTELEM *block);
00055 void ff_fdct_sse2(DCTELEM *block);
00056
00057 void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride);
00058 void ff_h264_idct_add_c(uint8_t *dst, DCTELEM *block, int stride);
00059 void ff_h264_idct8_dc_add_c(uint8_t *dst, DCTELEM *block, int stride);
00060 void ff_h264_idct_dc_add_c(uint8_t *dst, DCTELEM *block, int stride);
00061 void ff_h264_lowres_idct_add_c(uint8_t *dst, int stride, DCTELEM *block);
00062 void ff_h264_lowres_idct_put_c(uint8_t *dst, int stride, DCTELEM *block);
00063
00064 void ff_vector_fmul_add_add_c(float *dst, const float *src0, const float *src1,
00065 const float *src2, int src3, int blocksize, int step);
00066 void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1,
00067 const float *win, float add_bias, int len);
00068 void ff_float_to_int16_c(int16_t *dst, const float *src, long len);
00069
00070
00071 extern const uint8_t ff_alternate_horizontal_scan[64];
00072 extern const uint8_t ff_alternate_vertical_scan[64];
00073 extern const uint8_t ff_zigzag_direct[64];
00074 extern const uint8_t ff_zigzag248_direct[64];
00075
00076
00077 #define MAX_NEG_CROP 1024
00078
00079
00080 extern uint32_t ff_squareTbl[512];
00081 extern uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
00082
00083
00084 void ff_vp3_idct_c(DCTELEM *block);
00085 void ff_vp3_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block);
00086 void ff_vp3_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block);
00087
00088
00089 void ff_img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00090 void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00091 void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00092 void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00093
00094 void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
00095 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 typedef void (*op_pixels_func)(uint8_t *block, const uint8_t *pixels, int line_size, int h);
00122 typedef void (*tpel_mc_func)(uint8_t *block, const uint8_t *pixels, int line_size, int w, int h);
00123 typedef void (*qpel_mc_func)(uint8_t *dst, uint8_t *src, int stride);
00124 typedef void (*h264_chroma_mc_func)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x, int y);
00125 typedef void (*h264_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int offset);
00126 typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset);
00127
00128 #define DEF_OLD_QPEL(name)\
00129 void ff_put_ ## name (uint8_t *dst, uint8_t *src, int stride);\
00130 void ff_put_no_rnd_ ## name (uint8_t *dst, uint8_t *src, int stride);\
00131 void ff_avg_ ## name (uint8_t *dst, uint8_t *src, int stride);
00132
00133 DEF_OLD_QPEL(qpel16_mc11_old_c)
00134 DEF_OLD_QPEL(qpel16_mc31_old_c)
00135 DEF_OLD_QPEL(qpel16_mc12_old_c)
00136 DEF_OLD_QPEL(qpel16_mc32_old_c)
00137 DEF_OLD_QPEL(qpel16_mc13_old_c)
00138 DEF_OLD_QPEL(qpel16_mc33_old_c)
00139 DEF_OLD_QPEL(qpel8_mc11_old_c)
00140 DEF_OLD_QPEL(qpel8_mc31_old_c)
00141 DEF_OLD_QPEL(qpel8_mc12_old_c)
00142 DEF_OLD_QPEL(qpel8_mc32_old_c)
00143 DEF_OLD_QPEL(qpel8_mc13_old_c)
00144 DEF_OLD_QPEL(qpel8_mc33_old_c)
00145
00146 #define CALL_2X_PIXELS(a, b, n)\
00147 static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
00148 b(block , pixels , line_size, h);\
00149 b(block+n, pixels+n, line_size, h);\
00150 }
00151
00152
00153
00154
00155 typedef int (*me_cmp_func)(void *s, uint8_t *blk1, uint8_t *blk2, int line_size, int h);
00156
00157
00158
00159 typedef struct slice_buffer_s slice_buffer;
00160
00161
00162
00163
00164 typedef struct ScanTable{
00165 const uint8_t *scantable;
00166 uint8_t permutated[64];
00167 uint8_t raster_end[64];
00168 #ifdef ARCH_POWERPC
00169
00170 DECLARE_ALIGNED(16, uint8_t, inverse[64]);
00171 #endif
00172 } ScanTable;
00173
00174 void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
00175
00176 void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize,
00177 int block_w, int block_h,
00178 int src_x, int src_y, int w, int h);
00179
00180
00181
00182
00183 typedef struct DSPContext {
00184
00185 void (*get_pixels)(DCTELEM *block, const uint8_t *pixels, int line_size);
00186 void (*diff_pixels)(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride);
00187 void (*put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00188 void (*put_signed_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00189 void (*add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
00190 void (*add_pixels8)(uint8_t *pixels, DCTELEM *block, int line_size);
00191 void (*add_pixels4)(uint8_t *pixels, DCTELEM *block, int line_size);
00192 int (*sum_abs_dctelem)(DCTELEM *block);
00193
00194
00195
00196 void (*gmc1)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x16, int y16, int rounder);
00197
00198
00199
00200 void (*gmc )(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
00201 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
00202 void (*clear_blocks)(DCTELEM *blocks);
00203 int (*pix_sum)(uint8_t * pix, int line_size);
00204 int (*pix_norm1)(uint8_t * pix, int line_size);
00205
00206
00207 me_cmp_func sad[5];
00208 me_cmp_func sse[5];
00209 me_cmp_func hadamard8_diff[5];
00210 me_cmp_func dct_sad[5];
00211 me_cmp_func quant_psnr[5];
00212 me_cmp_func bit[5];
00213 me_cmp_func rd[5];
00214 me_cmp_func vsad[5];
00215 me_cmp_func vsse[5];
00216 me_cmp_func nsse[5];
00217 me_cmp_func w53[5];
00218 me_cmp_func w97[5];
00219 me_cmp_func dct_max[5];
00220 me_cmp_func dct264_sad[5];
00221
00222 me_cmp_func me_pre_cmp[5];
00223 me_cmp_func me_cmp[5];
00224 me_cmp_func me_sub_cmp[5];
00225 me_cmp_func mb_cmp[5];
00226 me_cmp_func ildct_cmp[5];
00227 me_cmp_func frame_skip_cmp[5];
00228
00229 int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
00230 int size);
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 op_pixels_func put_pixels_tab[4][4];
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254 op_pixels_func avg_pixels_tab[4][4];
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 op_pixels_func put_no_rnd_pixels_tab[4][4];
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 op_pixels_func avg_no_rnd_pixels_tab[4][4];
00279
00280 void (*put_no_rnd_pixels_l2[2])(uint8_t *block, const uint8_t *a, const uint8_t *b, int line_size, int h);
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 tpel_mc_func put_tpel_pixels_tab[11];
00293 tpel_mc_func avg_tpel_pixels_tab[11];
00294
00295 qpel_mc_func put_qpel_pixels_tab[2][16];
00296 qpel_mc_func avg_qpel_pixels_tab[2][16];
00297 qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
00298 qpel_mc_func avg_no_rnd_qpel_pixels_tab[2][16];
00299 qpel_mc_func put_mspel_pixels_tab[8];
00300
00301
00302
00303
00304 h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
00305
00306 h264_chroma_mc_func put_no_rnd_h264_chroma_pixels_tab[3];
00307 h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
00308
00309 qpel_mc_func put_h264_qpel_pixels_tab[4][16];
00310 qpel_mc_func avg_h264_qpel_pixels_tab[4][16];
00311
00312 qpel_mc_func put_2tap_qpel_pixels_tab[4][16];
00313 qpel_mc_func avg_2tap_qpel_pixels_tab[4][16];
00314
00315 h264_weight_func weight_h264_pixels_tab[10];
00316 h264_biweight_func biweight_h264_pixels_tab[10];
00317
00318
00319 qpel_mc_func put_cavs_qpel_pixels_tab[2][16];
00320 qpel_mc_func avg_cavs_qpel_pixels_tab[2][16];
00321 void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
00322 void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
00323 void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
00324 void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
00325 void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
00326
00327 me_cmp_func pix_abs[2][4];
00328
00329
00330 void (*add_bytes)(uint8_t *dst, uint8_t *src, int w);
00331 void (*add_bytes_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w);
00332 void (*diff_bytes)(uint8_t *dst, uint8_t *src1, uint8_t *src2,int w);
00333
00334
00335
00336
00337 void (*sub_hfyu_median_prediction)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top);
00338
00339 void (*add_png_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp);
00340 void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
00341
00342 void (*h264_v_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
00343 void (*h264_h_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
00344 void (*h264_v_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
00345 void (*h264_h_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
00346 void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta);
00347 void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta);
00348
00349 void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40], int8_t ref[2][40], int16_t mv[2][40][2],
00350 int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field);
00351
00352 void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
00353 void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
00354
00355 void (*h261_loop_filter)(uint8_t *src, int stride);
00356
00357 void (*x8_v_loop_filter)(uint8_t *src, int stride, int qscale);
00358 void (*x8_h_loop_filter)(uint8_t *src, int stride, int qscale);
00359
00360
00361 void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize);
00362
00363 void (*flac_compute_autocorr)(const int32_t *data, int len, int lag, double *autoc);
00364
00365 void (*vector_fmul)(float *dst, const float *src, int len);
00366 void (*vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len);
00367
00368 void (*vector_fmul_add_add)(float *dst, const float *src0, const float *src1, const float *src2, int src3, int len, int step);
00369
00370 void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len);
00371
00372
00373
00374 void (*float_to_int16)(int16_t *dst, const float *src, long len);
00375 void (*float_to_int16_interleave)(int16_t *dst, const float **src, long len, int channels);
00376
00377
00378 void (*fdct)(DCTELEM *block);
00379 void (*fdct248)(DCTELEM *block);
00380
00381
00382 void (*idct)(DCTELEM *block);
00383
00384
00385
00386
00387
00388
00389 void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block);
00390
00391
00392
00393
00394
00395 void (*idct_add)(uint8_t *dest, int line_size, DCTELEM *block);
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 uint8_t idct_permutation[64];
00410 int idct_permutation_type;
00411 #define FF_NO_IDCT_PERM 1
00412 #define FF_LIBMPEG2_IDCT_PERM 2
00413 #define FF_SIMPLE_IDCT_PERM 3
00414 #define FF_TRANSPOSE_IDCT_PERM 4
00415 #define FF_PARTTRANS_IDCT_PERM 5
00416 #define FF_SSE2_IDCT_PERM 6
00417
00418 int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
00419 void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
00420 #define BASIS_SHIFT 16
00421 #define RECON_SHIFT 6
00422
00423 void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w);
00424 #define EDGE_WIDTH 16
00425
00426
00427 void (*h264_idct_add)(uint8_t *dst, DCTELEM *block, int stride);
00428 void (*h264_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
00429 void (*h264_idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
00430 void (*h264_idct8_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
00431 void (*h264_dct)(DCTELEM block[4][4]);
00432
00433
00434 void (*vertical_compose97i)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width);
00435 void (*horizontal_compose97i)(IDWTELEM *b, int width);
00436 void (*inner_add_yblock)(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8);
00437
00438 void (*prefetch)(void *mem, int stride, int h);
00439
00440 void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
00441
00442
00443 void (*vc1_inv_trans_8x8)(DCTELEM *b);
00444 void (*vc1_inv_trans_8x4)(uint8_t *dest, int line_size, DCTELEM *block);
00445 void (*vc1_inv_trans_4x8)(uint8_t *dest, int line_size, DCTELEM *block);
00446 void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block);
00447 void (*vc1_v_overlap)(uint8_t* src, int stride);
00448 void (*vc1_h_overlap)(uint8_t* src, int stride);
00449
00450
00451
00452 op_pixels_func put_vc1_mspel_pixels_tab[16];
00453
00454
00455 void (*x8_spatial_compensation[12])(uint8_t *src , uint8_t *dst, int linesize);
00456 void (*x8_setup_spatial_compensation)(uint8_t *src, uint8_t *dst, int linesize,
00457 int * range, int * sum, int edges);
00458
00459
00460
00461
00462
00463
00464 void (*add_int16)(int16_t *v1, int16_t *v2, int len);
00465
00466
00467
00468
00469 void (*sub_int16)(int16_t *v1, int16_t *v2, int len);
00470
00471
00472
00473
00474
00475 int32_t (*scalarproduct_int16)(int16_t *v1, int16_t *v2, int len, int shift);
00476 } DSPContext;
00477
00478 void dsputil_static_init(void);
00479 void dsputil_init(DSPContext* p, AVCodecContext *avctx);
00480
00481 int ff_check_alignment(void);
00482
00483
00484
00485
00486
00487 void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last);
00488
00489 void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
00490
00491 #define BYTE_VEC32(c) ((c)*0x01010101UL)
00492
00493 static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
00494 {
00495 return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
00496 }
00497
00498 static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
00499 {
00500 return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
00501 }
00502
00503 static inline int get_penalty_factor(int lambda, int lambda2, int type){
00504 switch(type&0xFF){
00505 default:
00506 case FF_CMP_SAD:
00507 return lambda>>FF_LAMBDA_SHIFT;
00508 case FF_CMP_DCT:
00509 return (3*lambda)>>(FF_LAMBDA_SHIFT+1);
00510 case FF_CMP_W53:
00511 return (4*lambda)>>(FF_LAMBDA_SHIFT);
00512 case FF_CMP_W97:
00513 return (2*lambda)>>(FF_LAMBDA_SHIFT);
00514 case FF_CMP_SATD:
00515 case FF_CMP_DCT264:
00516 return (2*lambda)>>FF_LAMBDA_SHIFT;
00517 case FF_CMP_RD:
00518 case FF_CMP_PSNR:
00519 case FF_CMP_SSE:
00520 case FF_CMP_NSSE:
00521 return lambda2>>FF_LAMBDA_SHIFT;
00522 case FF_CMP_BIT:
00523 return 1;
00524 }
00525 }
00526
00527
00528
00529
00530
00531
00532 #define emms_c()
00533
00534
00535
00536 int mm_support(void);
00537
00538 void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
00539 void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx);
00540 void dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
00541 void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx);
00542 void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
00543 void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
00544 void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
00545 void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
00546 void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
00547
00548 #define DECLARE_ALIGNED_16(t, v) DECLARE_ALIGNED(16, t, v)
00549
00550 #if defined(HAVE_MMX)
00551
00552 #undef emms_c
00553
00554 #define MM_MMX 0x0001
00555 #define MM_3DNOW 0x0004
00556 #define MM_MMXEXT 0x0002
00557 #define MM_SSE 0x0008
00558 #define MM_SSE2 0x0010
00559 #define MM_3DNOWEXT 0x0020
00560 #define MM_SSE3 0x0040
00561 #define MM_SSSE3 0x0080
00562
00563 extern int mm_flags;
00564
00565 void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
00566 void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
00567 void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
00568
00569 static inline void emms(void)
00570 {
00571 asm volatile ("emms;":::"memory");
00572 }
00573
00574
00575 #define emms_c() \
00576 {\
00577 if (mm_flags & MM_MMX)\
00578 emms();\
00579 }
00580
00581 void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx);
00582
00583 #elif defined(ARCH_ARMV4L)
00584
00585 #define MM_IWMMXT 0x0100
00586
00587 extern int mm_flags;
00588
00589 #elif defined(ARCH_POWERPC)
00590
00591 #define MM_ALTIVEC 0x0001
00592
00593 extern int mm_flags;
00594
00595 #define DECLARE_ALIGNED_8(t, v) DECLARE_ALIGNED(16, t, v)
00596 #define STRIDE_ALIGN 16
00597
00598 #elif defined(HAVE_MMI)
00599
00600 #define DECLARE_ALIGNED_8(t, v) DECLARE_ALIGNED(16, t, v)
00601 #define STRIDE_ALIGN 16
00602
00603 #else
00604
00605 #define mm_flags 0
00606 #define mm_support() 0
00607
00608 #endif
00609
00610 #ifndef DECLARE_ALIGNED_8
00611 # define DECLARE_ALIGNED_8(t, v) DECLARE_ALIGNED(8, t, v)
00612 #endif
00613
00614 #ifndef STRIDE_ALIGN
00615 # define STRIDE_ALIGN 8
00616 #endif
00617
00618
00619 void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3],
00620 int orig_linesize[3], int coded_linesize,
00621 AVCodecContext *avctx);
00622
00623
00624
00625
00626
00627 typedef float FFTSample;
00628
00629 struct MDCTContext;
00630
00631 typedef struct FFTComplex {
00632 FFTSample re, im;
00633 } FFTComplex;
00634
00635 typedef struct FFTContext {
00636 int nbits;
00637 int inverse;
00638 uint16_t *revtab;
00639 FFTComplex *exptab;
00640 FFTComplex *exptab1;
00641 void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
00642 void (*imdct_calc)(struct MDCTContext *s, FFTSample *output,
00643 const FFTSample *input, FFTSample *tmp);
00644 void (*imdct_half)(struct MDCTContext *s, FFTSample *output,
00645 const FFTSample *input, FFTSample *tmp);
00646 } FFTContext;
00647
00648 int ff_fft_init(FFTContext *s, int nbits, int inverse);
00649 void ff_fft_permute(FFTContext *s, FFTComplex *z);
00650 void ff_fft_calc_c(FFTContext *s, FFTComplex *z);
00651 void ff_fft_calc_sse(FFTContext *s, FFTComplex *z);
00652 void ff_fft_calc_3dn(FFTContext *s, FFTComplex *z);
00653 void ff_fft_calc_3dn2(FFTContext *s, FFTComplex *z);
00654 void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z);
00655
00656 static inline void ff_fft_calc(FFTContext *s, FFTComplex *z)
00657 {
00658 s->fft_calc(s, z);
00659 }
00660 void ff_fft_end(FFTContext *s);
00661
00662
00663
00664 typedef struct MDCTContext {
00665 int n;
00666 int nbits;
00667
00668 FFTSample *tcos;
00669 FFTSample *tsin;
00670 FFTContext fft;
00671 } MDCTContext;
00672
00673
00674
00675
00676
00677
00678
00679 void ff_kbd_window_init(float *window, float alpha, int n);
00680
00681
00682
00683
00684
00685
00686 void ff_sine_window_init(float *window, int n);
00687
00688 int ff_mdct_init(MDCTContext *s, int nbits, int inverse);
00689 void ff_imdct_calc(MDCTContext *s, FFTSample *output,
00690 const FFTSample *input, FFTSample *tmp);
00691 void ff_imdct_half(MDCTContext *s, FFTSample *output,
00692 const FFTSample *input, FFTSample *tmp);
00693 void ff_imdct_calc_3dn2(MDCTContext *s, FFTSample *output,
00694 const FFTSample *input, FFTSample *tmp);
00695 void ff_imdct_half_3dn2(MDCTContext *s, FFTSample *output,
00696 const FFTSample *input, FFTSample *tmp);
00697 void ff_imdct_calc_sse(MDCTContext *s, FFTSample *output,
00698 const FFTSample *input, FFTSample *tmp);
00699 void ff_imdct_half_sse(MDCTContext *s, FFTSample *output,
00700 const FFTSample *input, FFTSample *tmp);
00701 void ff_mdct_calc(MDCTContext *s, FFTSample *out,
00702 const FFTSample *input, FFTSample *tmp);
00703 void ff_mdct_end(MDCTContext *s);
00704
00705 #define WRAPPER8_16(name8, name16)\
00706 static int name16(void *s, uint8_t *dst, uint8_t *src, int stride, int h){\
00707 return name8(s, dst , src , stride, h)\
00708 +name8(s, dst+8 , src+8 , stride, h);\
00709 }
00710
00711 #define WRAPPER8_16_SQ(name8, name16)\
00712 static int name16(void *s, uint8_t *dst, uint8_t *src, int stride, int h){\
00713 int score=0;\
00714 score +=name8(s, dst , src , stride, 8);\
00715 score +=name8(s, dst+8 , src+8 , stride, 8);\
00716 if(h==16){\
00717 dst += 8*stride;\
00718 src += 8*stride;\
00719 score +=name8(s, dst , src , stride, 8);\
00720 score +=name8(s, dst+8 , src+8 , stride, 8);\
00721 }\
00722 return score;\
00723 }
00724
00725
00726 static inline void copy_block2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
00727 {
00728 int i;
0072