History

af_pan: remove dual double/int storage of gain.

libswresample takes care of that now.

Nicolas George committed 14 years ago

Commit 4217dfe1 parent d00bc6a1 file · +9 −23Browse files

Unified · Split

libavfilter/af_pan.c+9−23
@@ -37,11 +37,7 @@ · 36 unmodified lines
3737
3838 typedef struct PanContext {
3939 int64_t out_channel_layout;
40− union {
41− double d[MAX_CHANNELS][MAX_CHANNELS];
42− // i is 1:7:8 fixed-point, i.e. in [-128*256; +128*256[
43− int i[MAX_CHANNELS][MAX_CHANNELS];
44− } gain;
40+ double gain[MAX_CHANNELS][MAX_CHANNELS];
4541 int64_t need_renorm;
4642 int need_renumber;
4743 int nb_input_channels;
@@ -171,7 +167,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args0, void *opaque) · 123 unmodified lines
171167 "Can not mix named and numbered channels\n");
172168 return AVERROR(EINVAL);
173169 }
174− pan->gain.d[out_ch_id][in_ch_id] = gain;
170+ pan->gain[out_ch_id][in_ch_id] = gain;
175171 if (!*arg)
176172 break;
177173 if (*arg != '+') {
@@ -196,7 +192,7 @@ static int are_gains_pure(const PanContext *pan) · 18 unmodified lines
196192 int nb_gain = 0;
197193
198194 for (j = 0; j < MAX_CHANNELS; j++) {
199− double gain = pan->gain.d[i][j];
195+ double gain = pan->gain[i][j];
200196
201197 /* channel mapping is effective only if 0% or 100% of a channel is
202198 * selected... */
@@ -247,7 +243,7 @@ static int config_props(AVFilterLink *link) · 44 unmodified lines
247243 for (i = j = 0; i < MAX_CHANNELS; i++) {
248244 if ((link->channel_layout >> i) & 1) {
249245 for (k = 0; k < pan->nb_output_channels; k++)
250− pan->gain.d[k][j] = pan->gain.d[k][i];
246+ pan->gain[k][j] = pan->gain[k][i];
251247 j++;
252248 }
253249 }
@@ -278,7 +274,7 @@ static int config_props(AVFilterLink *link) · 24 unmodified lines
278274 for (i = 0; i < pan->nb_output_channels; i++) {
279275 int ch_id = -1;
280276 for (j = 0; j < pan->nb_input_channels; j++) {
281− if (pan->gain.d[i][j]) {
277+ if (pan->gain[i][j]) {
282278 ch_id = j;
283279 break;
284280 }
@@ -296,7 +292,7 @@ static int config_props(AVFilterLink *link) · 11 unmodified lines
296292 continue;
297293 t = 0;
298294 for (j = 0; j < pan->nb_input_channels; j++)
299− t += pan->gain.d[i][j];
295+ t += pan->gain[i][j];
300296 if (t > -1E-5 && t < 1E-5) {
301297 // t is almost 0 but not exactly, this is probably a mistake
302298 if (t)
@@ -305,12 +301,11 @@ static int config_props(AVFilterLink *link) · 2 unmodified lines
305301 continue;
306302 }
307303 for (j = 0; j < pan->nb_input_channels; j++)
308− pan->gain.d[i][j] /= t;
304+ pan->gain[i][j] /= t;
309305 }
310306 av_opt_set_int(pan->swr, "icl", link->channel_layout, 0);
311307 av_opt_set_int(pan->swr, "ocl", pan->out_channel_layout, 0);
312− swr_set_matrix(pan->swr, pan->gain.d[0],
313− pan->gain.d[1] - pan->gain.d[0]);
308+ swr_set_matrix(pan->swr, pan->gain[0], pan->gain[1] - pan->gain[0]);
314309 }
315310
316311 r = swr_init(pan->swr);
@@ -322,7 +317,7 @@ static int config_props(AVFilterLink *link) · 5 unmodified lines
322317 cur = buf;
323318 for (j = 0; j < pan->nb_input_channels; j++) {
324319 r = snprintf(cur, buf + sizeof(buf) - cur, "%s%.3g i%d",
325− j ? " + " : "", pan->gain.d[i][j], j);
320+ j ? " + " : "", pan->gain[i][j], j);
326321 cur += FFMIN(buf + sizeof(buf) - cur, r);
327322 }
328323 av_log(ctx, AV_LOG_INFO, "o%d = %s\n", i, buf);
@@ -338,15 +333,6 @@ static int config_props(AVFilterLink *link) · 9 unmodified lines
338333 av_log(ctx, AV_LOG_INFO, "\n");
339334 return 0;
340335 }
341− // convert to integer
342− for (i = 0; i < pan->nb_output_channels; i++) {
343− for (j = 0; j < pan->nb_input_channels; j++) {
344− if (pan->gain.d[i][j] < -128 || pan->gain.d[i][j] > 128)
345− av_log(ctx, AV_LOG_WARNING,
346− "Gain #%d->#%d too large, clamped\n", j, i);
347− pan->gain.i[i][j] = av_clipf(pan->gain.d[i][j], -128, 128) * 256.0;
348− }
349− }
350336 return 0;
351337 }
352338

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t