]> git.sesse.net Git - ffmpeg/blob - libavcodec/dsputil.h
dsputil: Split off IDCT bits 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     /* pixel ops : interface with DCT */
52     void (*get_pixels)(int16_t *block /* align 16 */,
53                        const uint8_t *pixels /* align 8 */,
54                        int line_size);
55     void (*diff_pixels)(int16_t *block /* align 16 */,
56                         const uint8_t *s1 /* align 8 */,
57                         const uint8_t *s2 /* align 8 */,
58                         int stride);
59     int (*sum_abs_dctelem)(int16_t *block /* align 16 */);
60
61     int (*pix_sum)(uint8_t *pix, int line_size);
62     int (*pix_norm1)(uint8_t *pix, int line_size);
63
64     me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
65     me_cmp_func sse[6];
66     me_cmp_func hadamard8_diff[6];
67     me_cmp_func dct_sad[6];
68     me_cmp_func quant_psnr[6];
69     me_cmp_func bit[6];
70     me_cmp_func rd[6];
71     me_cmp_func vsad[6];
72     me_cmp_func vsse[6];
73     me_cmp_func nsse[6];
74     me_cmp_func dct_max[6];
75     me_cmp_func dct264_sad[6];
76
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
83
84     me_cmp_func pix_abs[2][4];
85
86     /* (I)DCT */
87     void (*fdct)(int16_t *block /* align 16 */);
88     void (*fdct248)(int16_t *block /* align 16 */);
89
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
94 #define RECON_SHIFT 6
95
96     void (*draw_edges)(uint8_t *buf, int wrap, int width, int height,
97                        int w, int h, int sides);
98 #define EDGE_WIDTH 16
99 #define EDGE_TOP    1
100 #define EDGE_BOTTOM 2
101
102     void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src,
103                       int src_wrap, int width, int height);
104 } DSPContext;
105
106 void ff_dsputil_static_init(void);
107 void ff_dsputil_init(DSPContext *p, AVCodecContext *avctx);
108
109 void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type);
110
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);
117
118 #endif /* AVCODEC_DSPUTIL_H */