fix different UMV handling for mpeg4 vs. h263 - patch by Michael Niedermayer <michael...
[libav.git] / libavcodec / dsputil.h
CommitLineData
de6d9b64
FB
1#ifndef DSPUTIL_H
2#define DSPUTIL_H
3
4#include "common.h"
de6d9b64
FB
5
6/* dct code */
7typedef short DCTELEM;
8
9void jpeg_fdct_ifast (DCTELEM *data);
10
11void j_rev_dct (DCTELEM *data);
12
13void fdct_mmx(DCTELEM *block);
14
15void (*av_fdct)(DCTELEM *block);
16
e0eac44e
FB
17/* encoding scans */
18extern UINT8 ff_alternate_horizontal_scan[64];
19extern UINT8 ff_alternate_vertical_scan[64];
20extern UINT8 zigzag_direct[64];
21
de6d9b64
FB
22/* pixel operations */
23#define MAX_NEG_CROP 384
24
25/* temporary */
26extern UINT32 squareTbl[512];
0cfa9713 27extern UINT8 cropTbl[256 + 2 * MAX_NEG_CROP];
de6d9b64
FB
28
29void dsputil_init(void);
30
31/* pixel ops : interface with DCT */
32
4af7bcc1 33extern void (*ff_idct)(DCTELEM *block);
de6d9b64
FB
34extern void (*get_pixels)(DCTELEM *block, const UINT8 *pixels, int line_size);
35extern void (*put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
36extern void (*add_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
37
38void get_pixels_c(DCTELEM *block, const UINT8 *pixels, int line_size);
39void put_pixels_clamped_c(const DCTELEM *block, UINT8 *pixels, int line_size);
40void add_pixels_clamped_c(const DCTELEM *block, UINT8 *pixels, int line_size);
41
42/* add and put pixel (decoding) */
43typedef void (*op_pixels_func)(UINT8 *block, const UINT8 *pixels, int line_size, int h);
44
45extern op_pixels_func put_pixels_tab[4];
46extern op_pixels_func avg_pixels_tab[4];
47extern op_pixels_func put_no_rnd_pixels_tab[4];
48extern op_pixels_func avg_no_rnd_pixels_tab[4];
49
50/* sub pixel (encoding) */
51extern void (*sub_pixels_tab[4])(DCTELEM *block, const UINT8 *pixels, int line_size, int h);
52
53#define sub_pixels_2(block, pixels, line_size, dxy) \
54 sub_pixels_tab[dxy](block, pixels, line_size, 8)
55
56/* motion estimation */
57
58typedef int (*op_pixels_abs_func)(UINT8 *blk1, UINT8 *blk2, int line_size, int h);
59
60extern op_pixels_abs_func pix_abs16x16;
61extern op_pixels_abs_func pix_abs16x16_x2;
62extern op_pixels_abs_func pix_abs16x16_y2;
63extern op_pixels_abs_func pix_abs16x16_xy2;
64
65int pix_abs16x16_c(UINT8 *blk1, UINT8 *blk2, int lx, int h);
66int pix_abs16x16_x2_c(UINT8 *blk1, UINT8 *blk2, int lx, int h);
67int pix_abs16x16_y2_c(UINT8 *blk1, UINT8 *blk2, int lx, int h);
68int pix_abs16x16_xy2_c(UINT8 *blk1, UINT8 *blk2, int lx, int h);
69
d962f6fd
A
70#if defined (SIMPLE_IDCT) && defined (HAVE_MMX)
71static inline int block_permute_op(int j)
72{
73static const int table[64]={
74 0x00, 0x08, 0x01, 0x09, 0x04, 0x0C, 0x05, 0x0D,
75 0x10, 0x18, 0x11, 0x19, 0x14, 0x1C, 0x15, 0x1D,
76 0x02, 0x0A, 0x03, 0x0B, 0x06, 0x0E, 0x07, 0x0F,
77 0x12, 0x1A, 0x13, 0x1B, 0x16, 0x1E, 0x17, 0x1F,
78 0x20, 0x28, 0x21, 0x29, 0x24, 0x2C, 0x25, 0x2D,
79 0x30, 0x38, 0x31, 0x39, 0x34, 0x3C, 0x35, 0x3D,
80 0x22, 0x2A, 0x23, 0x2B, 0x26, 0x2E, 0x27, 0x2F,
81 0x32, 0x3A, 0x33, 0x3B, 0x36, 0x3E, 0x37, 0x3F,
82};
83
84 return table[j];
85}
86#elif defined (SIMPLE_IDCT)
87static inline int block_permute_op(int j)
88{
89 return j;
90}
91#else
e0eac44e
FB
92static inline int block_permute_op(int j)
93{
94 return (j & 0x38) | ((j & 6) >> 1) | ((j & 1) << 2);
95}
d962f6fd 96#endif
e0eac44e
FB
97
98void block_permute(INT16 *block);
99
3d03c0a2 100#if defined(HAVE_MMX)
de6d9b64
FB
101
102#define MM_MMX 0x0001 /* standard MMX */
103#define MM_3DNOW 0x0004 /* AMD 3DNOW */
104#define MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
105#define MM_SSE 0x0008 /* SSE functions */
106#define MM_SSE2 0x0010 /* PIV SSE2 functions */
107
108extern int mm_flags;
109
110int mm_support(void);
111
112static inline void emms(void)
113{
fb16b7e7
FB
114 __asm __volatile ("emms;":::"memory");
115}
116
117#define emms_c() \
118{\
119 if (mm_flags & MM_MMX)\
120 emms();\
de6d9b64
FB
121}
122
123#define __align8 __attribute__ ((aligned (8)))
124
125void dsputil_init_mmx(void);
126
3d03c0a2
FB
127#elif defined(ARCH_ARMV4L)
128
129#define emms_c()
130
131/* This is to use 4 bytes read to the IDCT pointers for some 'zero'
132 line ptimizations */
133#define __align8 __attribute__ ((aligned (4)))
134
135void dsputil_init_armv4l(void);
136
c34270f5
FB
137#elif defined(HAVE_MLIB)
138
139#define emms_c()
140
141/* SPARC/VIS IDCT needs 8-byte aligned DCT blocks */
142#define __align8 __attribute__ ((aligned (8)))
143
144void dsputil_init_mlib(void);
145
de6d9b64
FB
146#else
147
fb16b7e7
FB
148#define emms_c()
149
de6d9b64
FB
150#define __align8
151
152#endif
153
154#endif