Lines Matching +full:high +full:- +full:precision

1 /* Effect: dither/noise-shape   Copyright (c) 2008-9 robs@users.sourceforge.net
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #define RANQD1 ranqd1(p->ranqd1)
35 {"f-weighted", Shape_f_weighted},
36 {"modified-e-weighted", Shape_modified_e_weighted},
37 {"improved-e-weighted", Shape_improved_e_weighted},
40 {"low-shibata", Shape_low_shibata},
41 {"high-shibata", Shape_high_shibata},
53 static double const lip44[] = {2.033, -2.165, 1.959, -1.590, .6149};
55 2.412, -3.370, 3.937, -4.174, 3.353, -2.205, 1.281, -.569, .0847};
57 1.662, -1.263, .4827, -.2913, .1268, -.1124, .03252, -.01265, -.03524};
59 2.847, -4.685, 6.214, -7.184, 6.639, -5.032, 3.263, -1.632, .4191};
61 2.2061, -.4706, -.2534, -.6214, 1.0587, .0676, -.6054, -.2738};
63 2.2374, -.7339, -.1251, -.6033, .903, .0116, -.5853, -.2571};
66 2.8720729351043701172, -5.0413231849670410156, 6.2442994117736816406,
67 -5.8483986854553222656, 3.7067542076110839844, -1.0495119094848632812,
68 -1.1830236911773681641, 2.1126792430877685547, -1.9094531536102294922,
69 0.99913084506988525391, -0.17090806365013122559, -0.32615602016448974609,
70 0.39127644896507263184, -0.26876461505889892578, 0.097676105797290802002,
71 -0.023473845794796943665,
74 2.6773197650909423828, -4.8308925628662109375, 6.570110321044921875,
75 -7.4572014808654785156, 6.7263274192810058594, -4.8481650352478027344,
76 2.0412089824676513672, 0.7006359100341796875, -2.9537565708160400391,
77 4.0800385475158691406, -4.1845216751098632812, 3.3311812877655029297,
78 -2.1179926395416259766, 0.879302978515625, -0.031759146600961685181,
79 -0.42382788658142089844, 0.47882103919982910156, -0.35490813851356506348,
80 0.17496839165687561035, -0.060908168554306030273,
83 1.6335992813110351562, -2.2615492343902587891, 2.4077029228210449219,
84 -2.6341717243194580078, 2.1440362930297851562, -1.8153258562088012695,
85 1.0816224813461303711, -0.70302653312683105469, 0.15991993248462677002,
86 0.041549518704414367676, -0.29416576027870178223, 0.2518316805362701416,
87 -0.27766478061676025391, 0.15785403549671173096, -0.10165894031524658203,
93 -1.0063692331314087,
95 -1.0447187423706055,
97 -0.87615132331848145,
99 -0.67434263229370117,
101 -0.52557498216629028,
103 -0.39618203043937683,
105 -0.28936097025871277,
107 -0.19097308814525604,
109 -0.10633844882249832,
111 -0.039653312414884567,
116 -0.56956905126571655,
117 -0.40727734565734863,
118 -0.33870288729667664,
119 -0.29810553789138794,
120 -0.19039161503314972,
121 -0.16510021686553955,
122 -0.13468159735202789,
123 -0.096633769571781158,
124 -0.081049129366874695,
125 -0.064953058958053589,
126 -0.054459091275930405,
127 -0.043378707021474838,
128 -0.03660014271736145,
129 -0.026256965473294258,
130 -0.018786206841468811,
131 -0.013387725688517094,
132 -0.0090983230620622635,
133 -0.0026585909072309732,
134 -0.00042083300650119781,
138 -0.37251132726669312,
139 -0.81423574686050415,
140 -0.55010956525802612,
141 -0.47405767440795898,
142 -0.32624706625938416,
143 -0.3161766529083252,
144 -0.2286367267370224,
145 -0.22916607558727264,
146 -0.19565616548061371,
147 -0.18160104751586914,
148 -0.15423151850700378,
149 -0.14104481041431427,
150 -0.11844276636838913,
151 -0.097583092749118805,
152 -0.076493598520755768,
153 -0.068106919527053833,
154 -0.041881654411554337,
155 -0.036922425031661987,
156 -0.019364040344953537,
157 -0.014994367957115173,
161 -0.9264228343963623,
162 -0.98695987462997437,
163 -0.631156325340271,
164 -0.51966935396194458,
165 -0.39738872647285461,
166 -0.35679301619529724,
167 -0.29720726609230042,
168 -0.26310476660728455,
169 -0.21719355881214142,
170 -0.18561814725399017,
171 -0.15404847264289856,
172 -0.12687471508979797,
173 -0.10339745879173279,
174 -0.083688631653785706,
175 -0.05875682458281517,
176 -0.046893671154975891,
177 -0.027950936928391457,
178 -0.020740609616041183,
179 -0.009366452693939209,
180 -0.0060260160826146603,
184 -1.202863335609436,
185 -0.94103097915649414,
186 -0.67878556251525879,
187 -0.57650017738342285,
188 -0.50004476308822632,
189 -0.44349345564842224,
190 -0.37833768129348755,
191 -0.34028723835945129,
192 -0.29413089156150818,
193 -0.24994957447052002,
194 -0.21715600788593292,
195 -0.18792112171649933,
196 -0.15268312394618988,
197 -0.12135542929172516,
198 -0.099610626697540283,
199 -0.075273610651493073,
200 -0.048787496984004974,
201 -0.042586319148540497,
202 -0.028991291299462318,
203 -0.011869125068187714,
206 2.3925774097442626953, -3.4350297451019287109, 3.1853709220886230469,
207 -1.8117271661758422852, -0.20124770700931549072, 1.4759907722473144531,
208 -1.7210904359817504883, 0.97746700048446655273, -0.13790138065814971924,
209 -0.38185903429985046387, 0.27421241998672485352, 0.066584214568138122559,
210 -0.35223302245140075684, 0.37672343850135803223, -0.23964276909828186035,
214 2.0833916664123535156, -3.0418450832366943359, 3.2047898769378662109,
215 -2.7571926116943359375, 1.4978630542755126953, -0.3427594602108001709,
216 -0.71733748912811279297, 1.0737057924270629883, -1.0225815773010253906,
217 0.56649994850158691406, -0.20968692004680633545, -0.065378531813621520996,
218 0.10322438180446624756, -0.067442022264003753662, -0.00495197344571352005,
221 3.0259189605712890625, -6.0268716812133789062, 9.195003509521484375,
222 -11.824929237365722656, 12.767142295837402344, -11.917946815490722656,
223 9.1739168167114257812, -5.3712320327758789062, 1.1393624544143676758,
224 2.4484779834747314453, -4.9719839096069335938, 6.0392003059387207031,
225 -5.9359521865844726562, 4.903278350830078125, -3.5527443885803222656,
226 2.1909697055816650391, -1.1672389507293701172, 0.4903914332389831543,
227 -0.16519790887832641602, 0.023217858746647834778,
298 priv_t * p = (priv_t *)effp->priv; in flow_no_shape()
301 while (len--) { in flow_no_shape()
302 if (p->auto_detect) { in flow_no_shape()
303 p->history = (p->history << 1) + in flow_no_shape()
304 !!(*ibuf & (((unsigned)-1) >> p->prec)); in flow_no_shape()
305 if (p->history && p->dither_off) { in flow_no_shape()
306 p->dither_off = sox_false; in flow_no_shape()
307 lsx_debug("flow %" PRIuPTR ": on @ %" PRIu64, effp->flow, p->num_output); in flow_no_shape()
308 } else if (!p->history && !p->dither_off) { in flow_no_shape()
309 p->dither_off = sox_true; in flow_no_shape()
310 lsx_debug("flow %" PRIuPTR ": off @ %" PRIu64, effp->flow, p->num_output); in flow_no_shape()
314 if (!p->dither_off) { in flow_no_shape()
315 int32_t r = RANQD1 >> p->prec; in flow_no_shape()
316 …double d = ((double)*ibuf++ + r + (p->alt_tpdf? -p->r : (RANQD1 >> p->prec))) / (1 << (32 - p->pre… in flow_no_shape()
317 int i = d < 0? d - .5 : d + .5; in flow_no_shape()
318 p->r = r; in flow_no_shape()
319 if (i <= (-1 << (p->prec-1))) in flow_no_shape()
320 ++effp->clips, *obuf = SOX_SAMPLE_MIN; in flow_no_shape()
321 else if (i > (int)SOX_INT_MAX(p->prec)) in flow_no_shape()
322 ++effp->clips, *obuf = SOX_INT_MAX(p->prec) << (32 - p->prec); in flow_no_shape()
323 else *obuf = i << (32 - p->prec); in flow_no_shape()
328 ++p->num_output; in flow_no_shape()
335 priv_t * p = (priv_t *)effp->priv; in getopts()
340 while ((c = lsx_getopt(&optstate)) != -1) switch (c) { in getopts()
341 case 'a': p->auto_detect = sox_true; break; in getopts()
342 case 'S': p->alt_tpdf = sox_true; break; in getopts()
343 case 's': p->filter_name = Shape_shibata; break; in getopts()
345 p->filter_name = lsx_enum_option(c, optstate.arg, filter_names); in getopts()
346 if (p->filter_name == INT_MAX) in getopts()
350 default: lsx_fail("invalid option `-%c'", optstate.opt); return lsx_usage(effp); in getopts()
352 argc -= optstate.ind, argv += optstate.ind; in getopts()
358 priv_t * p = (priv_t *)effp->priv; in start()
359 double mult = 1; /* Amount the noise shaping multiplies up the TPDF (+/-1) */ in start()
361 if (p->prec == 0) in start()
362 p->prec = effp->out_signal.precision; in start()
364 if (effp->in_signal.precision <= p->prec || p->prec > 24) in start()
367 if (p->prec == 1) { in start()
370 TODO: Some special-case treatment of 1-bit noise shaping will be in start()
372 lsx_warn("Dithering/noise-shaping to 1 bit is currently not supported."); in start()
376 effp->out_signal.precision = p->prec; in start()
378 p->flow = flow_no_shape; in start()
379 if (p->filter_name) { in start()
382 …for (f = filters; f->len && (f->name != p->filter_name || fabs(effp->in_signal.rate - f->rate) / f in start()
383 if (!f->len) { in start()
384 p->alt_tpdf |= effp->in_signal.rate >= 22050; in start()
385 if (!effp->flow) in start()
387 lsx_find_enum_value(p->filter_name, filter_names)->text, in start()
388 effp->in_signal.rate, p->alt_tpdf? "sloped" : "plain"); in start()
391 assert(f->len <= MAX_N); in start()
392 if (f->type == fir) switch(f->len) { in start()
393 case 5: p->flow = flow_fir_5 ; break; in start()
394 case 9: p->flow = flow_fir_9 ; break; in start()
395 case 15: p->flow = flow_fir_15; break; in start()
396 case 16: p->flow = flow_fir_16; break; in start()
397 case 20: p->flow = flow_fir_20; break; in start()
399 } else switch(f->len) { in start()
400 case 4: p->flow = flow_iir_4 ; break; in start()
403 p->coefs = f->coefs; in start()
404 mult = dB_to_linear(f->gain_cB * 0.1); in start()
407 p->ranqd1 = ranqd1(sox_globals.ranqd1) + effp->flow; in start()
408 if (effp->in_signal.mult) /* (Takes account of ostart mult (sox.c). */ in start()
409 *effp->in_signal.mult *= (SOX_SAMPLE_MAX - (1 << (31 - p->prec)) * in start()
410 (2 * mult + 1)) / (SOX_SAMPLE_MAX - (1 << (31 - p->prec))); in start()
417 priv_t * p = (priv_t *)effp->priv; in flow()
418 return p->flow(effp, ibuf, obuf, isamp, osamp); in flow()
424 "dither", "[-S|-s|-f filter] [-a] [-p precision]" in lsx_dither_effect_fn()
426 "\n -S Use sloped TPDF (without noise shaping)" in lsx_dither_effect_fn()
427 "\n -s Shape noise (with shibata filter)" in lsx_dither_effect_fn()
428 "\n -f name Set shaping filter to one of: lipshitz, f-weighted," in lsx_dither_effect_fn()
429 "\n modified-e-weighted, improved-e-weighted, gesemann," in lsx_dither_effect_fn()
430 "\n shibata, low-shibata, high-shibata." in lsx_dither_effect_fn()
431 "\n -a Automatically turn on & off dithering as needed (use with caution!)" in lsx_dither_effect_fn()
432 "\n -p bits Override the target sample precision", in lsx_dither_effect_fn()