]> git.sesse.net Git - ffmpeg/blob - libavcodec/aac_defines.h
avformat/avio: Add Metacube support
[ffmpeg] / libavcodec / aac_defines.h
1 /*
2  * AAC defines
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVCODEC_AAC_DEFINES_H
22 #define AVCODEC_AAC_DEFINES_H
23
24 #ifndef USE_FIXED
25 #define USE_FIXED 0
26 #endif
27
28 #if USE_FIXED
29
30 #include "libavutil/softfloat.h"
31
32 #define FFT_FLOAT    0
33 #define FFT_FIXED_32 1
34
35 #define AAC_RENAME(x)       x ## _fixed
36 #define AAC_RENAME_32(x)    x ## _fixed_32
37 #define AAC_RENAME2(x)      x ## _fixed
38 typedef int                 INTFLOAT;
39 typedef unsigned            UINTFLOAT;  ///< Equivalent to INTFLOAT, Used as temporal cast to avoid undefined sign overflow operations.
40 typedef int64_t             INT64FLOAT;
41 typedef int16_t             SHORTFLOAT;
42 typedef SoftFloat           AAC_FLOAT;
43 typedef int                 AAC_SIGNE;
44 #define FIXR(a)             ((int)((a) * 1 + 0.5))
45 #define FIXR10(a)           ((int)((a) * 1024.0 + 0.5))
46 #define Q23(a)              (int)((a) * 8388608.0 + 0.5)
47 #define Q30(x)              (int)((x)*1073741824.0 + 0.5)
48 #define Q31(x)              (int)((x)*2147483648.0 + 0.5)
49 #define RANGE15(x)          x
50 #define GET_GAIN(x, y)      (-(y) * (1 << (x))) + 1024
51 #define AAC_MUL16(x, y)     (int)(((int64_t)(x) * (y) + 0x8000) >> 16)
52 #define AAC_MUL26(x, y)     (int)(((int64_t)(x) * (y) + 0x2000000) >> 26)
53 #define AAC_MUL30(x, y)     (int)(((int64_t)(x) * (y) + 0x20000000) >> 30)
54 #define AAC_MUL31(x, y)     (int)(((int64_t)(x) * (y) + 0x40000000) >> 31)
55 #define AAC_MADD28(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
56                                       ((int64_t)(a) * (b)) + \
57                                         0x8000000) >> 28)
58 #define AAC_MADD30(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
59                                       ((int64_t)(a) * (b)) + \
60                                         0x20000000) >> 30)
61 #define AAC_MADD30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
62                                                      ((int64_t)(a) * (b)) + \
63                                                      ((int64_t)(c) * (d)) + \
64                                                      ((int64_t)(e) * (f)) + \
65                                                        0x20000000) >> 30)
66 #define AAC_MSUB30(x, y, a, b) (int)((((int64_t)(x) * (y)) - \
67                                       ((int64_t)(a) * (b)) + \
68                                         0x20000000) >> 30)
69 #define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
70                                                      ((int64_t)(a) * (b)) - \
71                                                      ((int64_t)(c) * (d)) - \
72                                                      ((int64_t)(e) * (f)) + \
73                                                        0x20000000) >> 30)
74 #define AAC_MSUB31_V3(x, y, z)    (int)((((int64_t)(x) * (z)) - \
75                                       ((int64_t)(y) * (z)) + \
76                                         0x40000000) >> 31)
77 #define AAC_HALF_SUM(x, y)  (((x) >> 1) + ((y) >> 1))
78 #define AAC_SRA_R(x, y)     (int)(((x) + (1 << ((y) - 1))) >> (y))
79
80 #else
81
82 #define FFT_FLOAT    1
83 #define FFT_FIXED_32 0
84
85 #define AAC_RENAME(x)       x
86 #define AAC_RENAME_32(x)    x
87 #define AAC_RENAME2(x)      ff_ ## x
88 typedef float               INTFLOAT;
89 typedef float               UINTFLOAT;
90 typedef float               INT64FLOAT;
91 typedef float               SHORTFLOAT;
92 typedef float               AAC_FLOAT;
93 typedef unsigned            AAC_SIGNE;
94 #define FIXR(x)             ((float)(x))
95 #define FIXR10(x)           ((float)(x))
96 #define Q23(x)              ((float)(x))
97 #define Q30(x)              ((float)(x))
98 #define Q31(x)              ((float)(x))
99 #define RANGE15(x)          (32768.0 * (x))
100 #define GET_GAIN(x, y)      powf((x), -(y))
101 #define AAC_MUL16(x, y)     ((x) * (y))
102 #define AAC_MUL26(x, y)     ((x) * (y))
103 #define AAC_MUL30(x, y)     ((x) * (y))
104 #define AAC_MUL31(x, y)     ((x) * (y))
105 #define AAC_MADD28(x, y, a, b) ((x) * (y) + (a) * (b))
106 #define AAC_MADD30(x, y, a, b) ((x) * (y) + (a) * (b))
107 #define AAC_MADD30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) + \
108                                                (c) * (d) + (e) * (f))
109 #define AAC_MSUB30(x, y, a, b) ((x) * (y) - (a) * (b))
110 #define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) - \
111                                                (c) * (d) - (e) * (f))
112 #define AAC_MSUB31_V3(x, y, z)    ((x) - (y)) * (z)
113 #define AAC_HALF_SUM(x, y)  ((x) + (y)) * 0.5f
114 #define AAC_SRA_R(x, y)     (x)
115
116 #endif /* USE_FIXED */
117
118 #endif /* AVCODEC_AAC_DEFINES_H */