1 /*
2 * Copyright (C) 2012-2013 Michael Niedermayer (michaelni@gmx.at)
3 *
4 * This file is part of libswresample
5 *
6 * libswresample 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 * libswresample 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 libswresample; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
24
26
28 double scale =
s->dither.noise_scale;
29 #define TMP_EXTRA 2
32
35
37 double v;
39
40 switch(
s->dither.method){
42 default:
47 break;
48 }
50 }
51
53 double v;
54
55 switch(
s->dither.method){
56 default:
59 break;
62 break;
63 }
64
66
67 switch(noise_fmt){
73 }
74 }
75
77 return 0;
78 }
79
81 {
84
87
90
95 }
100
102
104 scale *= 1<<(32-
s->dither.output_sample_bits);
105
107 s->dither.method = 0;
108 return 0;
109 }
110
111 s->dither.ns_pos = 0;
112 s->dither.noise_scale=
scale;
113 s->dither.ns_scale =
scale;
115 memset(
s->dither.ns_errors, 0,
sizeof(
s->dither.ns_errors));
118 if (llabs(
s->out_sample_rate -
f->rate)*20 <=
f->rate &&
f->name ==
s->dither.method) {
119 int j;
120 s->dither.ns_taps =
f->len;
121 for (j=0; j<
f->len; j++)
122 s->dither.ns_coeffs[j] =
f->coefs[j];
124 break;
125 }
126 }
128 av_log(
s,
AV_LOG_WARNING,
"Requested noise shaping dither not available at this sampling rate, using triangular hp dither\n");
130 }
131
132 return 0;
133 }
134
135 #define TEMPLATE_DITHER_S16
137 #undef TEMPLATE_DITHER_S16
138
139 #define TEMPLATE_DITHER_S32
141 #undef TEMPLATE_DITHER_S32
142
143 #define TEMPLATE_DITHER_FLT
145 #undef TEMPLATE_DITHER_FLT
146
147 #define TEMPLATE_DITHER_DBL
149 #undef TEMPLATE_DITHER_DBL