]> git.sesse.net Git - ffmpeg/blob - libavcodec/dsputil.h
dsputil: Split off pixel block routines into their own context
[ffmpeg] / libavcodec / dsputil.h
1 /*
2  * DSP utils
3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5  *
6  * This file is part of Libav.
7  *
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.
12  *
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.
17  *
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
21  */
22
23 /**
24  * @file
25  * DSP utils.
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.
28  */
29
30 #ifndef AVCODEC_DSPUTIL_H
31 #define AVCODEC_DSPUTIL_H
32
33 #include "avcodec.h"
34
35 extern uint32_t ff_square_tab[512];
36
37 struct MpegEncContext;
38 /* Motion estimation:
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);
46
47 /**
48  * DSPContext.
49  */
50 typedef struct DSPContext {
51     int (*sum_abs_dctelem)(int16_t *block /* align 16 */);
52
53     me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
54     me_cmp_func sse[6];
55     me_cmp_func hadamard8_diff[6];
56     me_cmp_func dct_sad[6];
57     me_cmp_func quant_psnr[6];
58     me_cmp_func bit[6];
59     me_cmp_func rd[6];
60     me_cmp_func vsad[6];
61     me_cmp_func vsse[6];
62     me_cmp_func nsse[6];
63     me_cmp_func dct_max[6];
64     me_cmp_func dct264_sad[6];
65
66     me_cmp_func me_pre_cmp[6];
67     me_cmp_func me_cmp[6];
68     me_cmp_func me_sub_cmp[6];
69     me_cmp_func mb_cmp[6];
70     me_cmp_func ildct_cmp[6]; // only width 16 used
71     me_cmp_func frame_skip_cmp[6]; // only width 8 used
72
73     me_cmp_func pix_abs[2][4];
74 } DSPContext;
75
76 void ff_dsputil_static_init(void);
77 void ff_dsputil_init(DSPContext *p, AVCodecContext *avctx);
78
79 void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type);
80
81 void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx,
82                          unsigned high_bit_depth);
83 void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx,
84                          unsigned high_bit_depth);
85 void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
86                          unsigned high_bit_depth);
87
88 #endif /* AVCODEC_DSPUTIL_H */