]> git.sesse.net Git - ffmpeg/blob - libavcodec/dsputil.h
Merge commit 'c166148409fe8f0dbccef2fe684286a40ba1e37d'
[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 FFmpeg.
7  *
8  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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
38 /* minimum alignment rules ;)
39  * If you notice errors in the align stuff, need more alignment for some ASM code
40  * for some CPU or need to use a function with less aligned data then send a mail
41  * to the ffmpeg-devel mailing list, ...
42  *
43  * !warning These alignments might not match reality, (missing attribute((align))
44  * stuff somewhere possible).
45  * I (Michael) did not check them, these are just the alignments which I think
46  * could be reached easily ...
47  *
48  * !future video codecs might need functions with less strict alignment
49  */
50
51 struct MpegEncContext;
52 /* Motion estimation:
53  * h is limited to { width / 2, width, 2 * width },
54  * but never larger than 16 and never smaller than 2.
55  * Although currently h < 4 is not used as functions with
56  * width < 8 are neither used nor implemented. */
57 typedef int (*me_cmp_func)(struct MpegEncContext *c,
58                            uint8_t *blk1 /* align width (8 or 16) */,
59                            uint8_t *blk2 /* align 1 */, int line_size, int h);
60
61 /**
62  * DSPContext.
63  */
64 typedef struct DSPContext {
65     /* pixel ops : interface with DCT */
66     void (*get_pixels)(int16_t *block /* align 16 */,
67                        const uint8_t *pixels /* align 8 */,
68                        int line_size);
69     void (*diff_pixels)(int16_t *block /* align 16 */,
70                         const uint8_t *s1 /* align 8 */,
71                         const uint8_t *s2 /* align 8 */,
72                         int stride);
73     int (*sum_abs_dctelem)(int16_t *block /* align 16 */);
74
75     me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
76     me_cmp_func sse[6];
77     me_cmp_func hadamard8_diff[6];
78     me_cmp_func dct_sad[6];
79     me_cmp_func quant_psnr[6];
80     me_cmp_func bit[6];
81     me_cmp_func rd[6];
82     me_cmp_func vsad[6];
83     me_cmp_func vsse[6];
84     me_cmp_func nsse[6];
85     me_cmp_func w53[6];
86     me_cmp_func w97[6];
87     me_cmp_func dct_max[6];
88     me_cmp_func dct264_sad[6];
89
90     me_cmp_func me_pre_cmp[6];
91     me_cmp_func me_cmp[6];
92     me_cmp_func me_sub_cmp[6];
93     me_cmp_func mb_cmp[6];
94     me_cmp_func ildct_cmp[6]; // only width 16 used
95     me_cmp_func frame_skip_cmp[6]; // only width 8 used
96
97     me_cmp_func pix_abs[2][4];
98
99     /* (I)DCT */
100     void (*fdct)(int16_t *block /* align 16 */);
101     void (*fdct248)(int16_t *block /* align 16 */);
102
103     void (*draw_edges)(uint8_t *buf, int wrap, int width, int height,
104                        int w, int h, int sides);
105 #define EDGE_WIDTH 16
106 #define EDGE_TOP    1
107 #define EDGE_BOTTOM 2
108 } DSPContext;
109
110 void ff_dsputil_static_init(void);
111 void ff_dsputil_init(DSPContext *p, AVCodecContext *avctx);
112 void avpriv_dsputil_init(DSPContext* p, AVCodecContext *avctx);
113 attribute_deprecated void dsputil_init(DSPContext* c, AVCodecContext *avctx);
114
115 int ff_check_alignment(void);
116
117 void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type);
118
119 void ff_dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
120 void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx,
121                          unsigned high_bit_depth);
122 void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx,
123                          unsigned high_bit_depth);
124 void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
125                          unsigned high_bit_depth);
126
127 void ff_dsputil_init_dwt(DSPContext *c);
128
129 #endif /* AVCODEC_DSPUTIL_H */