3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
6 * This file is part of Libav.
8 * Libav is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * Libav is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Libav; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 * Note, many functions in here may use MMX which trashes the FPU state, it is
27 * absolutely necessary to call emms_c() between DSP & float/double code.
30 #ifndef AVCODEC_DSPUTIL_H
31 #define AVCODEC_DSPUTIL_H
35 extern uint32_t ff_square_tab[512];
37 struct MpegEncContext;
39 * h is limited to { width / 2, width, 2 * width },
40 * but never larger than 16 and never smaller than 2.
41 * Although currently h < 4 is not used as functions with
42 * width < 8 are neither used nor implemented. */
43 typedef int (*me_cmp_func)(struct MpegEncContext *c,
44 uint8_t *blk1 /* align width (8 or 16) */,
45 uint8_t *blk2 /* align 1 */, int line_size, int h);
50 typedef struct DSPContext {
51 /* pixel ops : interface with DCT */
52 void (*get_pixels)(int16_t *block /* align 16 */,
53 const uint8_t *pixels /* align 8 */,
55 void (*diff_pixels)(int16_t *block /* align 16 */,
56 const uint8_t *s1 /* align 8 */,
57 const uint8_t *s2 /* align 8 */,
59 int (*sum_abs_dctelem)(int16_t *block /* align 16 */);
61 int (*pix_sum)(uint8_t *pix, int line_size);
62 int (*pix_norm1)(uint8_t *pix, int line_size);
64 me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
66 me_cmp_func hadamard8_diff[6];
67 me_cmp_func dct_sad[6];
68 me_cmp_func quant_psnr[6];
74 me_cmp_func dct_max[6];
75 me_cmp_func dct264_sad[6];
77 me_cmp_func me_pre_cmp[6];
78 me_cmp_func me_cmp[6];
79 me_cmp_func me_sub_cmp[6];
80 me_cmp_func mb_cmp[6];
81 me_cmp_func ildct_cmp[6]; // only width 16 used
82 me_cmp_func frame_skip_cmp[6]; // only width 8 used
84 me_cmp_func pix_abs[2][4];
87 void (*fdct)(int16_t *block /* align 16 */);
88 void (*fdct248)(int16_t *block /* align 16 */);
90 int (*try_8x8basis)(int16_t rem[64], int16_t weight[64],
91 int16_t basis[64], int scale);
92 void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
93 #define BASIS_SHIFT 16
96 void (*draw_edges)(uint8_t *buf, int wrap, int width, int height,
97 int w, int h, int sides);
100 #define EDGE_BOTTOM 2
102 void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src,
103 int src_wrap, int width, int height);
106 void ff_dsputil_static_init(void);
107 void ff_dsputil_init(DSPContext *p, AVCodecContext *avctx);
109 void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type);
111 void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx,
112 unsigned high_bit_depth);
113 void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx,
114 unsigned high_bit_depth);
115 void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
116 unsigned high_bit_depth);
118 #endif /* AVCODEC_DSPUTIL_H */