FFmpeg
noise_shaping_data.c
Go to the documentation of this file.
1 /* Effect: dither/noise-shape Copyright (c) 2008-9 robs@users.sourceforge.net
2  *
3  * This library is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation; either version 2.1 of the License, or (at
6  * your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation,
15  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  */
17 
18 typedef struct {
19  int rate;
20  enum {fir, iir} type;
21  size_t len;
22  int gain_cB; /* Chosen so clips are few if any, but not guaranteed none. */
23  double const * coefs;
25 } filter_t;
26 
27 static double const lip44[] = {2.033, -2.165, 1.959, -1.590, .6149};
28 static double const fwe44[] = {
29  2.412, -3.370, 3.937, -4.174, 3.353, -2.205, 1.281, -.569, .0847};
30 static double const mew44[] = {
31  1.662, -1.263, .4827, -.2913, .1268, -.1124, .03252, -.01265, -.03524};
32 static double const iew44[] = {
33  2.847, -4.685, 6.214, -7.184, 6.639, -5.032, 3.263, -1.632, .4191};
34 static double const ges44[] = {
35  2.2061, -.4706, -.2534, -.6214, 1.0587, .0676, -.6054, -.2738};
36 static double const ges48[] = {
37  2.2374, -.7339, -.1251, -.6033, .903, .0116, -.5853, -.2571};
38 
39 static double const shi48[] = {
40  2.8720729351043701172, -5.0413231849670410156, 6.2442994117736816406,
41  -5.8483986854553222656, 3.7067542076110839844, -1.0495119094848632812,
42  -1.1830236911773681641, 2.1126792430877685547, -1.9094531536102294922,
43  0.99913084506988525391, -0.17090806365013122559, -0.32615602016448974609,
44  0.39127644896507263184, -0.26876461505889892578, 0.097676105797290802002,
45  -0.023473845794796943665,
46 };
47 static double const shi44[] = {
48  2.6773197650909423828, -4.8308925628662109375, 6.570110321044921875,
49  -7.4572014808654785156, 6.7263274192810058594, -4.8481650352478027344,
50  2.0412089824676513672, 0.7006359100341796875, -2.9537565708160400391,
51  4.0800385475158691406, -4.1845216751098632812, 3.3311812877655029297,
52  -2.1179926395416259766, 0.879302978515625, -0.031759146600961685181,
53  -0.42382788658142089844, 0.47882103919982910156, -0.35490813851356506348,
54  0.17496839165687561035, -0.060908168554306030273,
55 };
56 static double const shi38[] = {
57  1.6335992813110351562, -2.2615492343902587891, 2.4077029228210449219,
58  -2.6341717243194580078, 2.1440362930297851562, -1.8153258562088012695,
59  1.0816224813461303711, -0.70302653312683105469, 0.15991993248462677002,
60  0.041549518704414367676, -0.29416576027870178223, 0.2518316805362701416,
61  -0.27766478061676025391, 0.15785403549671173096, -0.10165894031524658203,
62  0.016833892092108726501,
63 };
64 static double const shi32[] =
65 { /* dmaker 32000: bestmax=4.99659 (inverted) */
66 0.82118552923202515,
67 -1.0063692331314087,
68 0.62341964244842529,
69 -1.0447187423706055,
70 0.64532512426376343,
71 -0.87615132331848145,
72 0.52219754457473755,
73 -0.67434263229370117,
74 0.44954317808151245,
75 -0.52557498216629028,
76 0.34567299485206604,
77 -0.39618203043937683,
78 0.26791760325431824,
79 -0.28936097025871277,
80 0.1883765310049057,
81 -0.19097308814525604,
82 0.10431359708309174,
83 -0.10633844882249832,
84 0.046832218766212463,
85 -0.039653312414884567,
86 };
87 static double const shi22[] =
88 { /* dmaker 22050: bestmax=5.77762 (inverted) */
89 0.056581053882837296,
90 -0.56956905126571655,
91 -0.40727734565734863,
92 -0.33870288729667664,
93 -0.29810553789138794,
94 -0.19039161503314972,
95 -0.16510021686553955,
96 -0.13468159735202789,
97 -0.096633769571781158,
98 -0.081049129366874695,
99 -0.064953058958053589,
100 -0.054459091275930405,
101 -0.043378707021474838,
102 -0.03660014271736145,
103 -0.026256965473294258,
104 -0.018786206841468811,
105 -0.013387725688517094,
106 -0.0090983230620622635,
107 -0.0026585909072309732,
108 -0.00042083300650119781,
109 };
110 static double const shi16[] =
111 { /* dmaker 16000: bestmax=5.97128 (inverted) */
112 -0.37251132726669312,
113 -0.81423574686050415,
114 -0.55010956525802612,
115 -0.47405767440795898,
116 -0.32624706625938416,
117 -0.3161766529083252,
118 -0.2286367267370224,
119 -0.22916607558727264,
120 -0.19565616548061371,
121 -0.18160104751586914,
122 -0.15423151850700378,
123 -0.14104481041431427,
124 -0.11844276636838913,
125 -0.097583092749118805,
126 -0.076493598520755768,
127 -0.068106919527053833,
128 -0.041881654411554337,
129 -0.036922425031661987,
130 -0.019364040344953537,
131 -0.014994367957115173,
132 };
133 static double const shi11[] =
134 { /* dmaker 11025: bestmax=5.9406 (inverted) */
135 -0.9264228343963623,
136 -0.98695987462997437,
137 -0.631156325340271,
138 -0.51966935396194458,
139 -0.39738872647285461,
140 -0.35679301619529724,
141 -0.29720726609230042,
142 -0.26310476660728455,
143 -0.21719355881214142,
144 -0.18561814725399017,
145 -0.15404847264289856,
146 -0.12687471508979797,
147 -0.10339745879173279,
148 -0.083688631653785706,
149 -0.05875682458281517,
150 -0.046893671154975891,
151 -0.027950936928391457,
152 -0.020740609616041183,
153 -0.009366452693939209,
154 -0.0060260160826146603,
155 };
156 static double const shi08[] =
157 { /* dmaker 8000: bestmax=5.56234 (inverted) */
158 -1.202863335609436,
159 -0.94103097915649414,
160 -0.67878556251525879,
161 -0.57650017738342285,
162 -0.50004476308822632,
163 -0.44349345564842224,
164 -0.37833768129348755,
165 -0.34028723835945129,
166 -0.29413089156150818,
167 -0.24994957447052002,
168 -0.21715600788593292,
169 -0.18792112171649933,
170 -0.15268312394618988,
171 -0.12135542929172516,
172 -0.099610626697540283,
173 -0.075273610651493073,
174 -0.048787496984004974,
175 -0.042586319148540497,
176 -0.028991291299462318,
177 -0.011869125068187714,
178 };
179 static double const shl48[] = {
180  2.3925774097442626953, -3.4350297451019287109, 3.1853709220886230469,
181  -1.8117271661758422852, -0.20124770700931549072, 1.4759907722473144531,
182  -1.7210904359817504883, 0.97746700048446655273, -0.13790138065814971924,
183  -0.38185903429985046387, 0.27421241998672485352, 0.066584214568138122559,
184  -0.35223302245140075684, 0.37672343850135803223, -0.23964276909828186035,
185  0.068674825131893157959,
186 };
187 static double const shl44[] = {
188  2.0833916664123535156, -3.0418450832366943359, 3.2047898769378662109,
189  -2.7571926116943359375, 1.4978630542755126953, -0.3427594602108001709,
190  -0.71733748912811279297, 1.0737057924270629883, -1.0225815773010253906,
191  0.56649994850158691406, -0.20968692004680633545, -0.065378531813621520996,
192  0.10322438180446624756, -0.067442022264003753662, -0.00495197344571352005,
193  0,
194 };
195 static double const shh44[] = {
196  3.0259189605712890625, -6.0268716812133789062, 9.195003509521484375,
197  -11.824929237365722656, 12.767142295837402344, -11.917946815490722656,
198  9.1739168167114257812, -5.3712320327758789062, 1.1393624544143676758,
199  2.4484779834747314453, -4.9719839096069335938, 6.0392003059387207031,
200  -5.9359521865844726562, 4.903278350830078125, -3.5527443885803222656,
201  2.1909697055816650391, -1.1672389507293701172, 0.4903914332389831543,
202  -0.16519790887832641602, 0.023217858746647834778,
203 };
204 
205 static const filter_t filters[] = {
206  {44100, fir, 5, 210, lip44, SWR_DITHER_NS_LIPSHITZ},
207  {46000, fir, 9, 276, fwe44, SWR_DITHER_NS_F_WEIGHTED},
208  {46000, fir, 9, 160, mew44, SWR_DITHER_NS_MODIFIED_E_WEIGHTED},
209  {46000, fir, 9, 321, iew44, SWR_DITHER_NS_IMPROVED_E_WEIGHTED},
210 // {48000, iir, 4, 220, ges48, SWR_DITHER_NS_GESEMANN},
211 // {44100, iir, 4, 230, ges44, SWR_DITHER_NS_GESEMANN},
212  {48000, fir, 16, 301, shi48, SWR_DITHER_NS_SHIBATA},
213  {44100, fir, 20, 333, shi44, SWR_DITHER_NS_SHIBATA},
214  {37800, fir, 16, 240, shi38, SWR_DITHER_NS_SHIBATA},
215  {32000, fir, 20, 240/*TBD*/, shi32, SWR_DITHER_NS_SHIBATA},
216  {22050, fir, 20, 240/*TBD*/, shi22, SWR_DITHER_NS_SHIBATA},
217  {16000, fir, 20, 240/*TBD*/, shi16, SWR_DITHER_NS_SHIBATA},
218  {11025, fir, 20, 240/*TBD*/, shi11, SWR_DITHER_NS_SHIBATA},
219  { 8000, fir, 20, 240/*TBD*/, shi08, SWR_DITHER_NS_SHIBATA},
220  {48000, fir, 16, 250, shl48, SWR_DITHER_NS_LOW_SHIBATA},
221  {44100, fir, 15, 250, shl44, SWR_DITHER_NS_LOW_SHIBATA},
222  {44100, fir, 20, 383, shh44, SWR_DITHER_NS_HIGH_SHIBATA},
223  { 0, fir, 0, 0, NULL, SWR_DITHER_NONE},
224 };
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
SWR_DITHER_NS_LOW_SHIBATA
@ SWR_DITHER_NS_LOW_SHIBATA
Definition: swresample.h:153
SWR_DITHER_NS_IMPROVED_E_WEIGHTED
@ SWR_DITHER_NS_IMPROVED_E_WEIGHTED
Definition: swresample.h:151
SWR_DITHER_NS_MODIFIED_E_WEIGHTED
@ SWR_DITHER_NS_MODIFIED_E_WEIGHTED
Definition: swresample.h:150
SwrDitherType
SwrDitherType
Dithering algorithms.
Definition: swresample.h:141
shl48
static const double shl48[]
Definition: noise_shaping_data.c:179
shi11
static const double shi11[]
Definition: noise_shaping_data.c:133
shi32
static const double shi32[]
Definition: noise_shaping_data.c:64
filters
static const filter_t filters[]
Definition: noise_shaping_data.c:205
shi22
static const double shi22[]
Definition: noise_shaping_data.c:87
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
shi38
static const double shi38[]
Definition: noise_shaping_data.c:56
filter_t::rate
int rate
Definition: noise_shaping_data.c:19
filter_t::gain_cB
int gain_cB
Definition: noise_shaping_data.c:22
NULL
#define NULL
Definition: coverity.c:32
filter_t
Definition: noise_shaping_data.c:18
lip44
static const double lip44[]
Definition: noise_shaping_data.c:27
shi44
static const double shi44[]
Definition: noise_shaping_data.c:47
iew44
static const double iew44[]
Definition: noise_shaping_data.c:32
SWR_DITHER_NONE
@ SWR_DITHER_NONE
Definition: swresample.h:142
shi08
static const double shi08[]
Definition: noise_shaping_data.c:156
fwe44
static const double fwe44[]
Definition: noise_shaping_data.c:28
ges48
static const double ges48[]
Definition: noise_shaping_data.c:36
shi16
static const double shi16[]
Definition: noise_shaping_data.c:110
filter_t::coefs
const double * coefs
Definition: noise_shaping_data.c:23
shh44
static const double shh44[]
Definition: noise_shaping_data.c:195
filter_t::len
size_t len
Definition: noise_shaping_data.c:21
SWR_DITHER_NS_SHIBATA
@ SWR_DITHER_NS_SHIBATA
Definition: swresample.h:152
SWR_DITHER_NS_HIGH_SHIBATA
@ SWR_DITHER_NS_HIGH_SHIBATA
Definition: swresample.h:154
shi48
static const double shi48[]
Definition: noise_shaping_data.c:39
mew44
static const double mew44[]
Definition: noise_shaping_data.c:30
SWR_DITHER_NS_LIPSHITZ
@ SWR_DITHER_NS_LIPSHITZ
Definition: swresample.h:148
shl44
static const double shl44[]
Definition: noise_shaping_data.c:187
ges44
static const double ges44[]
Definition: noise_shaping_data.c:34
SWR_DITHER_NS_F_WEIGHTED
@ SWR_DITHER_NS_F_WEIGHTED
Definition: swresample.h:149