FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
aacps_fixed_tablegen.h
Go to the documentation of this file.
1 /*
2  * Header file for hardcoded Parametric Stereo tables
3  *
4  * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * Note: Rounding-to-nearest used unless otherwise stated
23  *
24  */
25 
26 #ifndef AVCODEC_AACPS_FIXED_TABLEGEN_H
27 #define AVCODEC_AACPS_FIXED_TABLEGEN_H
28 
29 #include <math.h>
30 #include <stdint.h>
31 
32 #if CONFIG_HARDCODED_TABLES
33 #define ps_tableinit()
34 #define TABLE_CONST const
35 #include "libavcodec/aacps_fixed_tables.h"
36 #else
37 #include "libavutil/common.h"
38 #include "libavutil/mathematics.h"
39 #include "libavutil/mem.h"
40 
41 #include "aac_defines.h"
42 #include "libavutil/softfloat.h"
43 #define NR_ALLPASS_BANDS20 30
44 #define NR_ALLPASS_BANDS34 50
45 #define PS_AP_LINKS 3
46 #define TABLE_CONST
47 static int pd_re_smooth[8*8*8];
48 static int pd_im_smooth[8*8*8];
49 static int HA[46][8][4];
50 static int HB[46][8][4];
51 static DECLARE_ALIGNED(16, int, f20_0_8) [ 8][8][2];
52 static DECLARE_ALIGNED(16, int, f34_0_12)[12][8][2];
53 static DECLARE_ALIGNED(16, int, f34_1_8) [ 8][8][2];
54 static DECLARE_ALIGNED(16, int, f34_2_4) [ 4][8][2];
55 static TABLE_CONST DECLARE_ALIGNED(16, int, Q_fract_allpass)[2][50][3][2];
56 static DECLARE_ALIGNED(16, int, phi_fract)[2][50][2];
57 
58 static const int g0_Q8[] = {
59  Q31(0.00746082949812f), Q31(0.02270420949825f), Q31(0.04546865930473f), Q31(0.07266113929591f),
60  Q31(0.09885108575264f), Q31(0.11793710567217f), Q31(0.125f)
61 };
62 
63 static const int g0_Q12[] = {
64  Q31(0.04081179924692f), Q31(0.03812810994926f), Q31(0.05144908135699f), Q31(0.06399831151592f),
65  Q31(0.07428313801106f), Q31(0.08100347892914f), Q31(0.08333333333333f)
66 };
67 
68 static const int g1_Q8[] = {
69  Q31(0.01565675600122f), Q31(0.03752716391991f), Q31(0.05417891378782f), Q31(0.08417044116767f),
70  Q31(0.10307344158036f), Q31(0.12222452249753f), Q31(0.125f)
71 };
72 
73 static const int g2_Q4[] = {
74  Q31(-0.05908211155639f), Q31(-0.04871498374946f), Q31(0.0f), Q31(0.07778723915851f),
75  Q31( 0.16486303567403f), Q31( 0.23279856662996f), Q31(0.25f)
76 };
77 
78 static const int sintbl_4[4] = { 0, 1073741824, 0, -1073741824 };
79 static const int costbl_4[4] = { 1073741824, 0, -1073741824, 0 };
80 static const int sintbl_8[8] = { 0, 759250125, 1073741824, 759250125,
81  0, -759250125, -1073741824, -759250125 };
82 static const int costbl_8[8] = { 1073741824, 759250125, 0, -759250125,
83  -1073741824, -759250125, 0, 759250125 };
84 static const int sintbl_12[12] = { 0, 536870912, 929887697, 1073741824,
85  929887697, 536870912, 0, -536870912,
86  -929887697, -1073741824, -929887697, -536870912 };
87 static const int costbl_12[12] = { 1073741824, 929887697, 536870912, 0,
88  -536870912, -929887697, -1073741824, -929887697,
89  -536870912, 0, 536870912, 929887697 };
90 
91 static void make_filters_from_proto(int (*filter)[8][2], const int *proto, int bands)
92 {
93 
94  const int *sinptr, *cosptr;
95  int s, c, sinhalf, coshalf;
96  int q, n;
97 
98  if (bands == 4) {
99  sinptr = sintbl_4;
100  cosptr = costbl_4;
101  sinhalf = 759250125;
102  coshalf = 759250125;
103  } else if (bands == 8) {
104  sinptr = sintbl_8;
105  cosptr = costbl_8;
106  sinhalf = 410903207;
107  coshalf = 992008094;
108  } else {
109  sinptr = sintbl_12;
110  cosptr = costbl_12;
111  sinhalf = 277904834;
112  coshalf = 1037154959;
113  }
114 
115  for (q = 0; q < bands; q++) {
116  for (n = 0; n < 7; n++) {
117  int theta = (q*(n-6) + (n>>1) - 3) % bands;
118 
119  if (theta < 0)
120  theta += bands;
121  s = sinptr[theta];
122  c = cosptr[theta];
123 
124  if (n & 1) {
125  theta = (int)(((int64_t)c * coshalf - (int64_t)s * sinhalf + 0x20000000) >> 30);
126  s = (int)(((int64_t)s * coshalf + (int64_t)c * sinhalf + 0x20000000) >> 30);
127  c = theta;
128  }
129  filter[q][n][0] = (int)(((int64_t)proto[n] * c + 0x20000000) >> 30);
130  filter[q][n][1] = -(int)(((int64_t)proto[n] * s + 0x20000000) >> 30);
131  }
132  }
133 }
134 
135 static void ps_tableinit(void)
136 {
137  static const int ipdopd_sin[] = { Q30(0), Q30(M_SQRT1_2), Q30(1), Q30( M_SQRT1_2), Q30( 0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2) };
138  static const int ipdopd_cos[] = { Q30(1), Q30(M_SQRT1_2), Q30(0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2), Q30( 0), Q30( M_SQRT1_2) };
139  int pd0, pd1, pd2;
140  int idx;
141 
142  static const int alpha_tab[] =
143  {
144  Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI),
145  Q30(1.4455626011f/M_PI), Q30(1.4531552792f/M_PI), Q30(1.4648091793f/M_PI), Q30(1.4945238829f/M_PI), Q30(1.5239057541f/M_PI), Q30(1.5644006729f/M_PI),
146  Q30(1.3738563061f/M_PI), Q30(1.3851221800f/M_PI), Q30(1.4026404619f/M_PI), Q30(1.4484288692f/M_PI), Q30(1.4949874878f/M_PI), Q30(1.5604078770f/M_PI),
147  Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI),
148  Q30(1.1507037878f/M_PI), Q30(1.1669205427f/M_PI), Q30(1.1938756704f/M_PI), Q30(1.2754167318f/M_PI), Q30(1.3761177063f/M_PI), Q30(1.5429240465f/M_PI),
149  Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI),
150  Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI),
151  Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI),
152  Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI),
153  Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI),
154  Q30(0.4200925827f/M_PI), Q30(0.4038758278f/M_PI), Q30(0.3769206405f/M_PI), Q30(0.2953795493f/M_PI), Q30(0.1946786791f/M_PI), Q30(0.0278722942f/M_PI),
155  Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI),
156  Q30(0.1969399750f/M_PI), Q30(0.1856741160f/M_PI), Q30(0.1681558639f/M_PI), Q30(0.1223674342f/M_PI), Q30(0.0758088827f/M_PI), Q30(0.0103884479f/M_PI),
157  Q30(0.1252337098f/M_PI), Q30(0.1176410317f/M_PI), Q30(0.1059871912f/M_PI), Q30(0.0762724727f/M_PI), Q30(0.0468905345f/M_PI), Q30(0.0063956482f/M_PI),
158  Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI),
159  Q30(1.5676341057f/M_PI), Q30(1.5678333044f/M_PI), Q30(1.5681363344f/M_PI), Q30(1.5688960552f/M_PI), Q30(1.5696337223f/M_PI), Q30(1.5706381798f/M_PI),
160  Q30(1.5651730299f/M_PI), Q30(1.5655272007f/M_PI), Q30(1.5660660267f/M_PI), Q30(1.5674170256f/M_PI), Q30(1.5687289238f/M_PI), Q30(1.5705151558f/M_PI),
161  Q30(1.5607966185f/M_PI), Q30(1.5614265203f/M_PI), Q30(1.5623844862f/M_PI), Q30(1.5647867918f/M_PI), Q30(1.5671195984f/M_PI), Q30(1.5702962875f/M_PI),
162  Q30(1.5530153513f/M_PI), Q30(1.5541347265f/M_PI), Q30(1.5558375120f/M_PI), Q30(1.5601085424f/M_PI), Q30(1.5642569065f/M_PI), Q30(1.5699069500f/M_PI),
163  Q30(1.5391840935f/M_PI), Q30(1.5411708355f/M_PI), Q30(1.5441943407f/M_PI), Q30(1.5517836809f/M_PI), Q30(1.5591609478f/M_PI), Q30(1.5692136288f/M_PI),
164  Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI),
165  Q30(1.4915299416f/M_PI), Q30(1.4964480400f/M_PI), Q30(1.5039558411f/M_PI), Q30(1.5229074955f/M_PI), Q30(1.5414420366f/M_PI), Q30(1.5667995214f/M_PI),
166  Q30(1.4590617418f/M_PI), Q30(1.4658898115f/M_PI), Q30(1.4763505459f/M_PI), Q30(1.5029321909f/M_PI), Q30(1.5291173458f/M_PI), Q30(1.5651149750f/M_PI),
167  Q30(1.4136143923f/M_PI), Q30(1.4229322672f/M_PI), Q30(1.4373078346f/M_PI), Q30(1.4743183851f/M_PI), Q30(1.5113102198f/M_PI), Q30(1.5626684427f/M_PI),
168  Q30(1.3505556583f/M_PI), Q30(1.3628427982f/M_PI), Q30(1.3820509911f/M_PI), Q30(1.4327841997f/M_PI), Q30(1.4850014448f/M_PI), Q30(1.5590143204f/M_PI),
169  Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI),
170  Q30(1.1919227839f/M_PI), Q30(1.2081253529f/M_PI), Q30(1.2346779108f/M_PI), Q30(1.3123005629f/M_PI), Q30(1.4034168720f/M_PI), Q30(1.5471596718f/M_PI),
171  Q30(1.1061993837f/M_PI), Q30(1.1219338179f/M_PI), Q30(1.1484941244f/M_PI), Q30(1.2320860624f/M_PI), Q30(1.3421301842f/M_PI), Q30(1.5373806953f/M_PI),
172  Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI),
173  Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI),
174  Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI),
175  Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI),
176  Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI),
177  Q30(0.4645969570f/M_PI), Q30(0.4488625824f/M_PI), Q30(0.4223022461f/M_PI), Q30(0.3387103081f/M_PI), Q30(0.2286661267f/M_PI), Q30(0.0334156826f/M_PI),
178  Q30(0.3788735867f/M_PI), Q30(0.3626709878f/M_PI), Q30(0.3361184299f/M_PI), Q30(0.2584958076f/M_PI), Q30(0.1673794836f/M_PI), Q30(0.0236366931f/M_PI),
179  Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI),
180  Q30(0.2202406377f/M_PI), Q30(0.2079535723f/M_PI), Q30(0.1887452900f/M_PI), Q30(0.1380121708f/M_PI), Q30(0.0857949182f/M_PI), Q30(0.0117820343f/M_PI),
181  Q30(0.1571819335f/M_PI), Q30(0.1478640437f/M_PI), Q30(0.1334884763f/M_PI), Q30(0.0964778885f/M_PI), Q30(0.0594860613f/M_PI), Q30(0.0081279324f/M_PI),
182  Q30(0.1117345318f/M_PI), Q30(0.1049065739f/M_PI), Q30(0.0944457650f/M_PI), Q30(0.0678641573f/M_PI), Q30(0.0416790098f/M_PI), Q30(0.0056813755f/M_PI),
183  Q30(0.0792663917f/M_PI), Q30(0.0743482932f/M_PI), Q30(0.0668405443f/M_PI), Q30(0.0478888862f/M_PI), Q30(0.0293543357f/M_PI), Q30(0.0039967746f/M_PI),
184  Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI),
185  Q30(0.0316122435f/M_PI), Q30(0.0296254847f/M_PI), Q30(0.0266019460f/M_PI), Q30(0.0190126132f/M_PI), Q30(0.0116353342f/M_PI), Q30(0.0015827164f/M_PI),
186  Q30(0.0177809205f/M_PI), Q30(0.0166615788f/M_PI), Q30(0.0149587989f/M_PI), Q30(0.0106877899f/M_PI), Q30(0.0065393616f/M_PI), Q30(0.0008894200f/M_PI),
187  Q30(0.0099996664f/M_PI), Q30(0.0093698399f/M_PI), Q30(0.0084118480f/M_PI), Q30(0.0060095116f/M_PI), Q30(0.0036767013f/M_PI), Q30(0.0005000498f/M_PI),
188  Q30(0.0056233541f/M_PI), Q30(0.0052691097f/M_PI), Q30(0.0047303112f/M_PI), Q30(0.0033792770f/M_PI), Q30(0.0020674451f/M_PI), Q30(0.0002811795f/M_PI),
189  Q30(0.0031622672f/M_PI), Q30(0.0029630491f/M_PI), Q30(0.0026600463f/M_PI), Q30(0.0019002859f/M_PI), Q30(0.0011625893f/M_PI), Q30(0.0001581155f/M_PI)
190  };
191 
192  static const int gamma_tab[] =
193  {
194  Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
195  Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI),
196  Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI),
197  Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
198  Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI),
199  Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
200  Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
201  Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI),
202  Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
203  Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
204  Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI),
205  Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
206  Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI),
207  Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI),
208  Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
209  Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI),
210  Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI),
211  Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI),
212  Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI),
213  Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI),
214  Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
215  Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI),
216  Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI),
217  Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI),
218  Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI),
219  Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
220  Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI),
221  Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI),
222  Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
223  Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
224  Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI),
225  Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
226  Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
227  Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI),
228  Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI),
229  Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
230  Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI),
231  Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI),
232  Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI),
233  Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI),
234  Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
235  Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI),
236  Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI),
237  Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI),
238  Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI),
239  Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI)
240  };
241 
242  static const int iid_par_dequant_c1[] = {
243  //iid_par_dequant_default
244  Q30(1.41198278375959f), Q30(1.40313815268360f), Q30(1.38687670404960f), Q30(1.34839972492648f),
245  Q30(1.29124937110028f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1),
246  Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.57677990744575f), Q30(0.42640143271122f),
247  Q30(0.27671828230984f), Q30(0.17664462766713f), Q30(0.07940162697653f),
248  //iid_par_dequant_fine
249  Q30(1.41420649135832f), Q30(1.41419120222364f), Q30(1.41414285699784f), Q30(1.41399000859438f),
250  Q30(1.41350698548044f), Q30(1.41198278375959f), Q30(1.40977302262355f), Q30(1.40539479488545f),
251  Q30(1.39677960498402f), Q30(1.38005309967827f), Q30(1.34839972492648f), Q30(1.31392017367631f),
252  Q30(1.26431008149654f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1),
253  Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.63365607219232f), Q30(0.52308104267543f),
254  Q30(0.42640143271122f), Q30(0.30895540465965f), Q30(0.22137464873077f), Q30(0.15768788954414f),
255  Q30(0.11198225164225f), Q30(0.07940162697653f), Q30(0.04469901562677f), Q30(0.02514469318284f),
256  Q30(0.01414142856998f), Q30(0.00795258154731f), Q30(0.00447211359449f),
257  };
258 
259  static const int acos_icc_invq[] = {
260  Q31(0), Q31(0.178427635f/M_PI), Q31(0.28566733f/M_PI), Q31(0.46307236f/M_PI), Q31(0.59716315f/M_PI), Q31(0.78539816f/M_PI), Q31(1.10030855f/M_PI), Q31(1.57079633f/M_PI)
261  };
262  int iid, icc;
263 
264  int k, m;
265  static const int8_t f_center_20[] = {
266  -3, -1, 1, 3, 5, 7, 10, 14, 18, 22,
267  };
268  static const int32_t f_center_34[] = {
269  Q31( 2/768.0),Q31( 6/768.0),Q31(10/768.0),Q31(14/768.0),Q31( 18/768.0),Q31( 22/768.0),Q31( 26/768.0),Q31(30/768.0),
270  Q31( 34/768.0),Q31(-10/768.0),Q31(-6/768.0),Q31(-2/768.0),Q31( 51/768.0),Q31( 57/768.0),Q31( 15/768.0),Q31(21/768.0),
271  Q31( 27/768.0),Q31( 33/768.0),Q31(39/768.0),Q31(45/768.0),Q31( 54/768.0),Q31( 66/768.0),Q31( 78/768.0),Q31(42/768.0),
272  Q31(102/768.0),Q31( 66/768.0),Q31(78/768.0),Q31(90/768.0),Q31(102/768.0),Q31(114/768.0),Q31(126/768.0),Q31(90/768.0)
273  };
274  static const int fractional_delay_links[] = { Q31(0.43f), Q31(0.75f), Q31(0.347f) };
275  const int fractional_delay_gain = Q31(0.39f);
276 
277  for (pd0 = 0; pd0 < 8; pd0++) {
278  int pd0_re = (ipdopd_cos[pd0]+2)>>2;
279  int pd0_im = (ipdopd_sin[pd0]+2)>>2;
280  for (pd1 = 0; pd1 < 8; pd1++) {
281  int pd1_re = ipdopd_cos[pd1] >> 1;
282  int pd1_im = ipdopd_sin[pd1] >> 1;
283  for (pd2 = 0; pd2 < 8; pd2++) {
284  int shift, round;
285  int pd2_re = ipdopd_cos[pd2];
286  int pd2_im = ipdopd_sin[pd2];
287  int re_smooth = pd0_re + pd1_re + pd2_re;
288  int im_smooth = pd0_im + pd1_im + pd2_im;
289 
290  SoftFloat pd_mag = av_int2sf(((ipdopd_cos[(pd0-pd1)&7]+8)>>4) + ((ipdopd_cos[(pd0-pd2)&7]+4)>>3) +
291  ((ipdopd_cos[(pd1-pd2)&7]+2)>>2) + 0x15000000, 28);
292  pd_mag = av_div_sf(FLOAT_1, av_sqrt_sf(pd_mag));
293  shift = 30 - pd_mag.exp;
294  round = 1 << (shift-1);
295  pd_re_smooth[pd0*64+pd1*8+pd2] = (int)(((int64_t)re_smooth * pd_mag.mant + round) >> shift);
296  pd_im_smooth[pd0*64+pd1*8+pd2] = (int)(((int64_t)im_smooth * pd_mag.mant + round) >> shift);
297  }
298  }
299  }
300 
301  idx = 0;
302  for (iid = 0; iid < 46; iid++) {
303  int c1, c2;
304 
305  c1 = iid_par_dequant_c1[iid];
306  if (iid < 15)
307  c2 = iid_par_dequant_c1[14-iid];
308  else
309  c2 = iid_par_dequant_c1[60-iid];
310 
311  for (icc = 0; icc < 8; icc++) {
312  /*if (PS_BASELINE || ps->icc_mode < 3)*/{
313  int alpha, beta;
314  int ca, sa, cb, sb;
315 
316  alpha = acos_icc_invq[icc];
317  beta = (int)(((int64_t)alpha * 1518500250 + 0x40000000) >> 31);
318  alpha >>= 1;
319  beta = (int)(((int64_t)beta * (c1 - c2) + 0x40000000) >> 31);
320  av_sincos_sf(beta + alpha, &sa, &ca);
321  av_sincos_sf(beta - alpha, &sb, &cb);
322 
323  HA[iid][icc][0] = (int)(((int64_t)c2 * ca + 0x20000000) >> 30);
324  HA[iid][icc][1] = (int)(((int64_t)c1 * cb + 0x20000000) >> 30);
325  HA[iid][icc][2] = (int)(((int64_t)c2 * sa + 0x20000000) >> 30);
326  HA[iid][icc][3] = (int)(((int64_t)c1 * sb + 0x20000000) >> 30);
327  } /* else */ {
328  int alpha_int, gamma_int;
329  int alpha_c_int, alpha_s_int, gamma_c_int, gamma_s_int;
330 
331  alpha_int = alpha_tab[idx];
332  gamma_int = gamma_tab[idx];
333 
334  av_sincos_sf(alpha_int, &alpha_s_int, &alpha_c_int);
335  av_sincos_sf(gamma_int, &gamma_s_int, &gamma_c_int);
336 
337  alpha_c_int = (int)(((int64_t)alpha_c_int * 1518500250 + 0x20000000) >> 30);
338  alpha_s_int = (int)(((int64_t)alpha_s_int * 1518500250 + 0x20000000) >> 30);
339 
340  HB[iid][icc][0] = (int)(((int64_t)alpha_c_int * gamma_c_int + 0x20000000) >> 30);
341  HB[iid][icc][1] = (int)(((int64_t)alpha_s_int * gamma_c_int + 0x20000000) >> 30);
342  HB[iid][icc][2] = -(int)(((int64_t)alpha_s_int * gamma_s_int + 0x20000000) >> 30);
343  HB[iid][icc][3] = (int)(((int64_t)alpha_c_int * gamma_s_int + 0x20000000) >> 30);
344  }
345 
346  if (icc < 5 || icc > 6)
347  idx++;
348  }
349  }
350 
351  for (k = 0; k < NR_ALLPASS_BANDS20; k++) {
352  int theta;
353  int64_t f_center;
354  int c, s;
355 
356  if (k < FF_ARRAY_ELEMS(f_center_20))
357  f_center = f_center_20[k];
358  else
359  f_center = (k << 3) - 52;
360 
361  for (m = 0; m < PS_AP_LINKS; m++) {
362  theta = (int)(((int64_t)fractional_delay_links[m] * f_center + 8) >> 4);
363  av_sincos_sf(-theta, &s, &c);
364  Q_fract_allpass[0][k][m][0] = c;
365  Q_fract_allpass[0][k][m][1] = s;
366  }
367 
368  theta = (int)(((int64_t)fractional_delay_gain * f_center + 8) >> 4);
369  av_sincos_sf(-theta, &s, &c);
370  phi_fract[0][k][0] = c;
371  phi_fract[0][k][1] = s;
372  }
373 
374  for (k = 0; k < NR_ALLPASS_BANDS34; k++) {
375  int theta, f_center;
376  int c, s;
377 
378  if (k < FF_ARRAY_ELEMS(f_center_34))
379  f_center = f_center_34[k];
380  else
381  f_center = ((int64_t)k << 26) - (53 << 25);
382 
383  for (m = 0; m < PS_AP_LINKS; m++) {
384  theta = (int)(((int64_t)fractional_delay_links[m] * f_center + 0x10000000) >> 27);
385  av_sincos_sf(-theta, &s, &c);
386  Q_fract_allpass[1][k][m][0] = c;
387  Q_fract_allpass[1][k][m][1] = s;
388  }
389 
390  theta = (int)(((int64_t)fractional_delay_gain * f_center + 0x10000000) >> 27);
391  av_sincos_sf(-theta, &s, &c);
392  phi_fract[1][k][0] = c;
393  phi_fract[1][k][1] = s;
394  }
395 
400 }
401 #endif /* CONFIG_HARDCODED_TABLES */
402 
403 #endif /* AVCODEC_AACPS_FIXED_TABLEGEN_H */
static av_always_inline SoftFloat av_sqrt_sf(SoftFloat val)
Rounding-to-nearest used.
Definition: softfloat.h:198
static const int g0_Q8[]
const char * s
Definition: avisynth_c.h:631
static int shift(int a, int b)
Definition: sonic.c:82
memory handling functions
static int HA[46][8][4]
static TABLE_CONST int Q_fract_allpass[2][50][3][2]
static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b)
b has to be normalized and not zero.
Definition: softfloat.h:116
#define M_SQRT1_2
Definition: mathematics.h:52
#define NR_ALLPASS_BANDS34
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:53
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:97
static int pd_im_smooth[8 *8 *8]
#define Q30(x)
Definition: aac_defines.h:93
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, uint8_t clip)
Definition: cfhd.c:80
static const int costbl_4[4]
static const uint64_t c1
Definition: murmur3.c:49
int32_t mant
Definition: softfloat.h:35
static int f34_0_12[12][8][2]
static const int g0_Q12[]
unsigned m
Definition: audioconvert.c:187
#define TABLE_CONST
static void make_filters_from_proto(int(*filter)[8][2], const int *proto, int bands)
static double alpha(void *priv, double x, double y)
Definition: vf_geq.c:99
static const SoftFloat FLOAT_1
1.0
Definition: softfloat.h:41
static const int sintbl_12[12]
static av_always_inline av_const double round(double x)
Definition: libm.h:444
static int phi_fract[2][50][2]
static av_unused void av_sincos_sf(int a, int *s, int *c)
Rounding-to-nearest used.
Definition: softfloat.h:231
#define NR_ALLPASS_BANDS20
static int f34_1_8[8][8][2]
#define Q31(x)
Definition: aac_defines.h:94
static const int sintbl_8[8]
static const int sintbl_4[4]
int32_t
int n
Definition: avisynth_c.h:547
#define FF_ARRAY_ELEMS(a)
static int HB[46][8][4]
static const int costbl_8[8]
static void ps_tableinit(void)
static const int costbl_12[12]
static const int g1_Q8[]
common internal and external API header
static double c[64]
static const uint64_t c2
Definition: murmur3.c:50
int32_t exp
Definition: softfloat.h:36
static int pd_re_smooth[8 *8 *8]
static int f34_2_4[4][8][2]
static av_const SoftFloat av_int2sf(int v, int frac_bits)
Converts a mantisse and exponent to a SoftFloat.
Definition: softfloat.h:176
static int f20_0_8[8][8][2]
#define M_PI
Definition: mathematics.h:46
static const int g2_Q4[]
static const uint8_t alpha_tab[64]
Definition: cavs.c:38
#define PS_AP_LINKS