FFmpeg
aac_defines.h
Go to the documentation of this file.
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 AAC_RENAME(x) x ## _fixed
33 #define AAC_RENAME2(x) x ## _fixed
34 typedef int INTFLOAT;
35 typedef unsigned UINTFLOAT; ///< Equivalent to INTFLOAT, Used as temporal cast to avoid undefined sign overflow operations.
36 typedef int64_t INT64FLOAT;
37 typedef int16_t SHORTFLOAT;
38 typedef SoftFloat AAC_FLOAT;
39 typedef int AAC_SIGNE;
40 #define FIXR(a) ((int)((a) * 1 + 0.5))
41 #define FIXR10(a) ((int)((a) * 1024.0 + 0.5))
42 #define Q23(a) (int)((a) * 8388608.0 + 0.5)
43 #define Q30(x) (int)((x)*1073741824.0 + 0.5)
44 #define Q31(x) (int)((x)*2147483648.0 + 0.5)
45 #define TX_SCALE(x) ((x) * 128.0f)
46 #define GET_GAIN(x, y) (-(y) * (1 << (x))) + 1024
47 #define AAC_MUL16(x, y) (int)(((int64_t)(x) * (y) + 0x8000) >> 16)
48 #define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26)
49 #define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30)
50 #define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31)
51 #define AAC_MADD28(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
52  ((int64_t)(a) * (b)) + \
53  0x8000000) >> 28)
54 #define AAC_MADD30(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
55  ((int64_t)(a) * (b)) + \
56  0x20000000) >> 30)
57 #define AAC_MADD30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
58  ((int64_t)(a) * (b)) + \
59  ((int64_t)(c) * (d)) + \
60  ((int64_t)(e) * (f)) + \
61  0x20000000) >> 30)
62 #define AAC_MSUB30(x, y, a, b) (int)((((int64_t)(x) * (y)) - \
63  ((int64_t)(a) * (b)) + \
64  0x20000000) >> 30)
65 #define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
66  ((int64_t)(a) * (b)) - \
67  ((int64_t)(c) * (d)) - \
68  ((int64_t)(e) * (f)) + \
69  0x20000000) >> 30)
70 #define AAC_MSUB31_V3(x, y, z) (int)((((int64_t)(x) * (z)) - \
71  ((int64_t)(y) * (z)) + \
72  0x40000000) >> 31)
73 #define AAC_HALF_SUM(x, y) (((x) >> 1) + ((y) >> 1))
74 #define AAC_SRA_R(x, y) (int)(((x) + (1 << ((y) - 1))) >> (y))
75 
76 #else
77 
78 #define AAC_RENAME(x) x
79 #define AAC_RENAME2(x) ff_ ## x
80 typedef float INTFLOAT;
81 typedef float UINTFLOAT;
82 typedef float INT64FLOAT;
83 typedef float SHORTFLOAT;
84 typedef float AAC_FLOAT;
85 typedef unsigned AAC_SIGNE;
86 #define FIXR(x) ((float)(x))
87 #define FIXR10(x) ((float)(x))
88 #define Q23(x) ((float)(x))
89 #define Q30(x) ((float)(x))
90 #define Q31(x) ((float)(x))
91 #define TX_SCALE(x) ((x) / 32768.0f)
92 #define GET_GAIN(x, y) powf((x), -(y))
93 #define AAC_MUL16(x, y) ((x) * (y))
94 #define AAC_MUL26(x, y) ((x) * (y))
95 #define AAC_MUL30(x, y) ((x) * (y))
96 #define AAC_MUL31(x, y) ((x) * (y))
97 #define AAC_MADD28(x, y, a, b) ((x) * (y) + (a) * (b))
98 #define AAC_MADD30(x, y, a, b) ((x) * (y) + (a) * (b))
99 #define AAC_MADD30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) + \
100  (c) * (d) + (e) * (f))
101 #define AAC_MSUB30(x, y, a, b) ((x) * (y) - (a) * (b))
102 #define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) - \
103  (c) * (d) - (e) * (f))
104 #define AAC_MSUB31_V3(x, y, z) ((x) - (y)) * (z)
105 #define AAC_HALF_SUM(x, y) ((x) + (y)) * 0.5f
106 #define AAC_SRA_R(x, y) (x)
107 
108 #endif /* USE_FIXED */
109 
110 #endif /* AVCODEC_AAC_DEFINES_H */
AAC_SIGNE
unsigned AAC_SIGNE
Definition: aac_defines.h:85
SHORTFLOAT
float SHORTFLOAT
Definition: aac_defines.h:83
INT64FLOAT
float INT64FLOAT
Definition: aac_defines.h:82
SoftFloat
Definition: softfloat.h:34
UINTFLOAT
float UINTFLOAT
Definition: aac_defines.h:81
AAC_FLOAT
float AAC_FLOAT
Definition: aac_defines.h:84
softfloat.h
INTFLOAT
float INTFLOAT
Definition: aac_defines.h:80