annotate ps_tablegen.h @ 11893:5ee87f2c9bc8 libavcodec

Allow PS envelope fixup when ps->num_env_old <= 1. It is already rejected by the "source >= 0 && source != ps->num_env" 0 envelope case and is perfectly legally for the suppressed final envelope case.
author alexc
date Sun, 20 Jun 2010 19:38:08 +0000
parents 2d81202be6e2
children a1b4029b2465
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11886
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1 /*
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
2 * Header file for hardcoded Parametric Stereo tables
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
3 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
4 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
5 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
6 * This file is part of FFmpeg.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
7 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
12 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
16 * Lesser General Public License for more details.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
17 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
21 */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
22
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
23 #ifndef PS_TABLEGEN_H
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
24 #define PS_TABLEGEN_H
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
25
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
26 #include <stdint.h>
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
27 #include <math.h>
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
28
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
29 #if CONFIG_HARDCODED_TABLES
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
30 #define ps_tableinit()
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
31 #include "libavcodec/ps_tables.h"
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
32 #else
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
33 #include "../libavutil/common.h"
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
34 #ifndef M_SQRT1_2
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
35 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
36 #endif
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
37 #ifndef M_PI
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
38 #define M_PI 3.14159265358979323846 /* pi */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
39 #endif
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
40 #ifndef M_SQRT2
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
41 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
42 #endif
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
43 #define NR_ALLPASS_BANDS20 30
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
44 #define NR_ALLPASS_BANDS34 50
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
45 #define PS_AP_LINKS 3
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
46 static float pd_re_smooth[8*8*8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
47 static float pd_im_smooth[8*8*8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
48 static float HA[46][8][4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
49 static float HB[46][8][4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
50 static float f20_0_8 [ 8][7][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
51 static float f34_0_12[12][7][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
52 static float f34_1_8 [ 8][7][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
53 static float f34_2_4 [ 4][7][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
54 static float Q_fract_allpass[2][50][3][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
55 static float phi_fract[2][50][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
56
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
57 static const float g0_Q8[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
58 0.00746082949812f, 0.02270420949825f, 0.04546865930473f, 0.07266113929591f,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
59 0.09885108575264f, 0.11793710567217f, 0.125f
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
60 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
61
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
62 static const float g0_Q12[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
63 0.04081179924692f, 0.03812810994926f, 0.05144908135699f, 0.06399831151592f,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
64 0.07428313801106f, 0.08100347892914f, 0.08333333333333f
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
65 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
66
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
67 static const float g1_Q8[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
68 0.01565675600122f, 0.03752716391991f, 0.05417891378782f, 0.08417044116767f,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
69 0.10307344158036f, 0.12222452249753f, 0.125f
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
70 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
71
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
72 static const float g2_Q4[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
73 -0.05908211155639f, -0.04871498374946f, 0.0f, 0.07778723915851f,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
74 0.16486303567403f, 0.23279856662996f, 0.25f
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
75 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
76
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
77 static void make_filters_from_proto(float (*filter)[7][2], const float *proto, int bands)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
78 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
79 int q, n;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
80 for (q = 0; q < bands; q++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
81 for (n = 0; n < 7; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
82 double theta = 2 * M_PI * (q + 0.5) * (n - 6) / bands;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
83 filter[q][n][0] = proto[n] * cos(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
84 filter[q][n][1] = proto[n] * -sin(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
85 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
86 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
87 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
88
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
89 static void ps_tableinit(void)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
90 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
91 static const float ipdopd_sin[] = { 0, M_SQRT1_2, 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
92 static const float ipdopd_cos[] = { 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2, 0, M_SQRT1_2 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
93 int pd0, pd1, pd2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
94
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
95 static const float iid_par_dequant[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
96 //iid_par_dequant_default
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
97 0.05623413251903, 0.12589254117942, 0.19952623149689, 0.31622776601684,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
98 0.44668359215096, 0.63095734448019, 0.79432823472428, 1,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
99 1.25892541179417, 1.58489319246111, 2.23872113856834, 3.16227766016838,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
100 5.01187233627272, 7.94328234724282, 17.7827941003892,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
101 //iid_par_dequant_fine
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
102 0.00316227766017, 0.00562341325190, 0.01, 0.01778279410039,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
103 0.03162277660168, 0.05623413251903, 0.07943282347243, 0.11220184543020,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
104 0.15848931924611, 0.22387211385683, 0.31622776601684, 0.39810717055350,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
105 0.50118723362727, 0.63095734448019, 0.79432823472428, 1,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
106 1.25892541179417, 1.58489319246111, 1.99526231496888, 2.51188643150958,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
107 3.16227766016838, 4.46683592150963, 6.30957344480193, 8.91250938133745,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
108 12.5892541179417, 17.7827941003892, 31.6227766016838, 56.2341325190349,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
109 100, 177.827941003892, 316.227766016837,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
110 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
111 static const float icc_invq[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
112 1, 0.937, 0.84118, 0.60092, 0.36764, 0, -0.589, -1
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
113 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
114 static const float acos_icc_invq[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
115 0, 0.35685527, 0.57133466, 0.92614472, 1.1943263, M_PI/2, 2.2006171, M_PI
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
116 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
117 int iid, icc;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
118
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
119 int k, m;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
120 static const int8_t f_center_20[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
121 -3, -1, 1, 3, 5, 7, 10, 14, 18, 22,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
122 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
123 static const int8_t f_center_34[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
124 2, 6, 10, 14, 18, 22, 26, 30,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
125 34,-10, -6, -2, 51, 57, 15, 21,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
126 27, 33, 39, 45, 54, 66, 78, 42,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
127 102, 66, 78, 90,102,114,126, 90,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
128 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
129 static const float fractional_delay_links[] = { 0.43f, 0.75f, 0.347f };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
130 const float fractional_delay_gain = 0.39f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
131
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
132 for (pd0 = 0; pd0 < 8; pd0++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
133 float pd0_re = ipdopd_cos[pd0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
134 float pd0_im = ipdopd_sin[pd0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
135 for (pd1 = 0; pd1 < 8; pd1++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
136 float pd1_re = ipdopd_cos[pd1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
137 float pd1_im = ipdopd_sin[pd1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
138 for (pd2 = 0; pd2 < 8; pd2++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
139 float pd2_re = ipdopd_cos[pd2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
140 float pd2_im = ipdopd_sin[pd2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
141 float re_smooth = 0.25f * pd0_re + 0.5f * pd1_re + pd2_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
142 float im_smooth = 0.25f * pd0_im + 0.5f * pd1_im + pd2_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
143 float pd_mag = 1 / sqrt(im_smooth * im_smooth + re_smooth * re_smooth);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
144 pd_re_smooth[pd0*64+pd1*8+pd2] = re_smooth * pd_mag;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
145 pd_im_smooth[pd0*64+pd1*8+pd2] = im_smooth * pd_mag;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
146 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
147 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
148 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
149
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
150 for (iid = 0; iid < 46; iid++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
151 float c = iid_par_dequant[iid]; //<Linear Inter-channel Intensity Difference
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
152 float c1 = (float)M_SQRT2 / sqrtf(1.0f + c*c);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
153 float c2 = c * c1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
154 for (icc = 0; icc < 8; icc++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
155 /*if (PS_BASELINE || ps->icc_mode < 3)*/ {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
156 float alpha = 0.5f * acos_icc_invq[icc];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
157 float beta = alpha * (c1 - c2) * (float)M_SQRT1_2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
158 HA[iid][icc][0] = c2 * cosf(beta + alpha);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
159 HA[iid][icc][1] = c1 * cosf(beta - alpha);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
160 HA[iid][icc][2] = c2 * sinf(beta + alpha);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
161 HA[iid][icc][3] = c1 * sinf(beta - alpha);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
162 } /* else */ {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
163 float alpha, gamma, mu, rho;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
164 float alpha_c, alpha_s, gamma_c, gamma_s;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
165 rho = FFMAX(icc_invq[icc], 0.05f);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
166 alpha = 0.5f * atan2f(2.0f * c * rho, c*c - 1.0f);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
167 mu = c + 1.0f / c;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
168 mu = sqrtf(1 + (4 * rho * rho - 4)/(mu * mu));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
169 gamma = atanf(sqrtf((1.0f - mu)/(1.0f + mu)));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
170 if (alpha < 0) alpha += M_PI/2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
171 alpha_c = cosf(alpha);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
172 alpha_s = sinf(alpha);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
173 gamma_c = cosf(gamma);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
174 gamma_s = sinf(gamma);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
175 HB[iid][icc][0] = M_SQRT2 * alpha_c * gamma_c;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
176 HB[iid][icc][1] = M_SQRT2 * alpha_s * gamma_c;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
177 HB[iid][icc][2] = -M_SQRT2 * alpha_s * gamma_s;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
178 HB[iid][icc][3] = M_SQRT2 * alpha_c * gamma_s;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
179 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
180 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
181 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
182
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
183 for (k = 0; k < NR_ALLPASS_BANDS20; k++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
184 double f_center, theta;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
185 if (k < FF_ARRAY_ELEMS(f_center_20))
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
186 f_center = f_center_20[k] * 0.125;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
187 else
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
188 f_center = k - 6.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
189 for (m = 0; m < PS_AP_LINKS; m++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
190 theta = -M_PI * fractional_delay_links[m] * f_center;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
191 Q_fract_allpass[0][k][m][0] = cos(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
192 Q_fract_allpass[0][k][m][1] = sin(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
193 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
194 theta = -M_PI*fractional_delay_gain*f_center;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
195 phi_fract[0][k][0] = cos(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
196 phi_fract[0][k][1] = sin(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
197 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
198 for (k = 0; k < NR_ALLPASS_BANDS34; k++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
199 double f_center, theta;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
200 if (k < FF_ARRAY_ELEMS(f_center_34))
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
201 f_center = f_center_34[k] / 24.;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
202 else
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
203 f_center = k - 26.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
204 for (m = 0; m < PS_AP_LINKS; m++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
205 theta = -M_PI * fractional_delay_links[m] * f_center;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
206 Q_fract_allpass[1][k][m][0] = cos(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
207 Q_fract_allpass[1][k][m][1] = sin(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
208 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
209 theta = -M_PI*fractional_delay_gain*f_center;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
210 phi_fract[1][k][0] = cos(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
211 phi_fract[1][k][1] = sin(theta);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
212 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
213
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
214 make_filters_from_proto(f20_0_8, g0_Q8, 8);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
215 make_filters_from_proto(f34_0_12, g0_Q12, 12);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
216 make_filters_from_proto(f34_1_8, g1_Q8, 8);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
217 make_filters_from_proto(f34_2_4, g2_Q4, 4);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
218 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
219 #endif /* CONFIG_HARDCODED_TABLES */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
220
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
221 #endif /* PS_TABLEGEN_H */