FFmpeg
Loading...
Searching...
No Matches
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
34typedef int INTFLOAT;
35typedef unsigned UINTFLOAT; ///< Equivalent to INTFLOAT, Used as temporal cast to avoid undefined sign overflow operations.
36typedef int64_t INT64FLOAT;
37typedef int16_t SHORTFLOAT;
38typedef SoftFloat AAC_FLOAT;
39typedef 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 GET_GAIN(x, y) (-(y) * (1 << (x))) + 1024
46#define AAC_MUL16(x, y) (int)(((int64_t)(x) * (y) + 0x8000) >> 16)
47#define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26)
48#define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30)
49#define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31)
50#define AAC_MADD28(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
51 ((int64_t)(a) * (b)) + \
52 0x8000000) >> 28)
53#define AAC_MADD30(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
54 ((int64_t)(a) * (b)) + \
55 0x20000000) >> 30)
56#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
57 ((int64_t)(a) * (b)) + \
58 ((int64_t)(c) * (d)) + \
59 ((int64_t)(e) * (f)) + \
60 0x20000000) >> 30)
61#define AAC_MSUB30(x, y, a, b) (int)((((int64_t)(x) * (y)) - \
62 ((int64_t)(a) * (b)) + \
63 0x20000000) >> 30)
64#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
65 ((int64_t)(a) * (b)) - \
66 ((int64_t)(c) * (d)) - \
67 ((int64_t)(e) * (f)) + \
68 0x20000000) >> 30)
69#define AAC_MSUB31_V3(x, y, z) (int)((((int64_t)(x) * (z)) - \
70 ((int64_t)(y) * (z)) + \
71 0x40000000) >> 31)
72#define AAC_HALF_SUM(x, y) (((x) >> 1) + ((y) >> 1))
73
74/**
75 * Predictor State
76 */
77typedef struct PredictorStateFixed {
78 SoftFloat cor0;
79 SoftFloat cor1;
80 SoftFloat var0;
81 SoftFloat var1;
82 SoftFloat r0;
83 SoftFloat r1;
84 SoftFloat k1;
85 SoftFloat x_est;
87
88#ifdef LPC_USE_FIXED
89#error aac_defines.h must be included before lpc_functions.h for fixed point decoder
90#endif
91
92#define LPC_USE_FIXED 1
93#define LPC_MUL26(x, y) AAC_MUL26((x), (y))
94#define LPC_FIXR(x) FIXR(x)
95#define LPC_SRA_R(x, y) (int)(((x) + (1 << ((y) - 1))) >> (y))
96
97#else
98
99#define AAC_RENAME(x) x
100#define AAC_RENAME2(x) ff_ ## x
101typedef float INTFLOAT;
102typedef float UINTFLOAT;
103typedef float INT64FLOAT;
104typedef float SHORTFLOAT;
105typedef float AAC_FLOAT;
106typedef unsigned AAC_SIGNE;
107#define FIXR(x) ((float)(x))
108#define FIXR10(x) ((float)(x))
109#define Q23(x) ((float)(x))
110#define Q30(x) ((float)(x))
111#define Q31(x) ((float)(x))
112#define GET_GAIN(x, y) powf((x), -(y))
113#define AAC_MUL16(x, y) ((x) * (y))
114#define AAC_MUL26(x, y) ((x) * (y))
115#define AAC_MUL30(x, y) ((x) * (y))
116#define AAC_MUL31(x, y) ((x) * (y))
117#define AAC_MADD28(x, y, a, b) ((x) * (y) + (a) * (b))
118#define AAC_MADD30(x, y, a, b) ((x) * (y) + (a) * (b))
119#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) + \
120 (c) * (d) + (e) * (f))
121#define AAC_MSUB30(x, y, a, b) ((x) * (y) - (a) * (b))
122#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) - \
123 (c) * (d) - (e) * (f))
124#define AAC_MSUB31_V3(x, y, z) ((x) - (y)) * (z)
125#define AAC_HALF_SUM(x, y) ((x) + (y)) * 0.5f
126
127/**
128 * Predictor State
129 */
130typedef struct PredictorState {
131 float cor0;
132 float cor1;
133 float var0;
134 float var1;
135 float r0;
136 float r1;
137 float k1;
138 float x_est;
140
141#endif /* USE_FIXED */
142
143#endif /* AVCODEC_AAC_DEFINES_H */
float SHORTFLOAT
float AAC_FLOAT
float INT64FLOAT
unsigned AAC_SIGNE
float UINTFLOAT
long long int64_t
Definition coverity.c:34
#define INTFLOAT
Predictor State.