FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/af_compand.c
Date: 2022-11-26 13:19:19
Exec Total Coverage
Lines: 162 284 57.0%
Branches: 64 130 49.2%

Line Branch Exec Source
1 /*
2 * Copyright (c) 1999 Chris Bagwell
3 * Copyright (c) 1999 Nick Bailey
4 * Copyright (c) 2007 Rob Sykes <robs@users.sourceforge.net>
5 * Copyright (c) 2013 Paul B Mahol
6 * Copyright (c) 2014 Andrew Kelley
7 *
8 * This file is part of FFmpeg.
9 *
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 /**
26 * @file
27 * audio compand filter
28 */
29
30 #include "libavutil/avassert.h"
31 #include "libavutil/avstring.h"
32 #include "libavutil/ffmath.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/samplefmt.h"
35 #include "audio.h"
36 #include "avfilter.h"
37 #include "internal.h"
38
39 typedef struct ChanParam {
40 double attack;
41 double decay;
42 double volume;
43 } ChanParam;
44
45 typedef struct CompandSegment {
46 double x, y;
47 double a, b;
48 } CompandSegment;
49
50 typedef struct CompandContext {
51 const AVClass *class;
52 int nb_segments;
53 char *attacks, *decays, *points;
54 CompandSegment *segments;
55 ChanParam *channels;
56 double in_min_lin;
57 double out_min_lin;
58 double curve_dB;
59 double gain_dB;
60 double initial_volume;
61 double delay;
62 AVFrame *delay_frame;
63 int delay_samples;
64 int delay_count;
65 int delay_index;
66 int64_t pts;
67
68 int (*compand)(AVFilterContext *ctx, AVFrame *frame);
69 } CompandContext;
70
71 #define OFFSET(x) offsetof(CompandContext, x)
72 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
73
74 static const AVOption compand_options[] = {
75 { "attacks", "set time over which increase of volume is determined", OFFSET(attacks), AV_OPT_TYPE_STRING, { .str = "0" }, 0, 0, A },
76 { "decays", "set time over which decrease of volume is determined", OFFSET(decays), AV_OPT_TYPE_STRING, { .str = "0.8" }, 0, 0, A },
77 { "points", "set points of transfer function", OFFSET(points), AV_OPT_TYPE_STRING, { .str = "-70/-70|-60/-20|1/0" }, 0, 0, A },
78 { "soft-knee", "set soft-knee", OFFSET(curve_dB), AV_OPT_TYPE_DOUBLE, { .dbl = 0.01 }, 0.01, 900, A },
79 { "gain", "set output gain", OFFSET(gain_dB), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -900, 900, A },
80 { "volume", "set initial volume", OFFSET(initial_volume), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -900, 0, A },
81 { "delay", "set delay for samples before sending them to volume adjuster", OFFSET(delay), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, 0, 20, A },
82 { NULL }
83 };
84
85 AVFILTER_DEFINE_CLASS(compand);
86
87 2 static av_cold int init(AVFilterContext *ctx)
88 {
89 2 CompandContext *s = ctx->priv;
90 2 s->pts = AV_NOPTS_VALUE;
91 2 return 0;
92 }
93
94 3 static av_cold void uninit(AVFilterContext *ctx)
95 {
96 3 CompandContext *s = ctx->priv;
97
98 3 av_freep(&s->channels);
99 3 av_freep(&s->segments);
100 3 av_frame_free(&s->delay_frame);
101 3 }
102
103 3 static void count_items(char *item_str, int *nb_items)
104 {
105 char *p;
106
107 3 *nb_items = 1;
108
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 3 times.
34 for (p = item_str; *p; p++) {
109
3/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 28 times.
31 if (*p == ' ' || *p == '|')
110 3 (*nb_items)++;
111 }
112 3 }
113
114 40960 static void update_volume(ChanParam *cp, double in)
115 {
116 40960 double delta = in - cp->volume;
117
118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40960 times.
40960 if (delta > 0.0)
119 cp->volume += delta * cp->attack;
120 else
121 40960 cp->volume += delta * cp->decay;
122 40960 }
123
124 40960 static double get_volume(CompandContext *s, double in_lin)
125 {
126 CompandSegment *cs;
127 double in_log, out_log;
128 int i;
129
130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40960 times.
40960 if (in_lin < s->in_min_lin)
131 return s->out_min_lin;
132
133 40960 in_log = log(in_lin);
134
135
1/2
✓ Branch 0 taken 122966 times.
✗ Branch 1 not taken.
122966 for (i = 1; i < s->nb_segments; i++)
136
2/2
✓ Branch 0 taken 40960 times.
✓ Branch 1 taken 82006 times.
122966 if (in_log <= s->segments[i].x)
137 40960 break;
138 40960 cs = &s->segments[i - 1];
139 40960 in_log -= cs->x;
140 40960 out_log = cs->y + in_log * (cs->a * in_log + cs->b);
141
142 40960 return exp(out_log);
143 }
144
145 20 static int compand_nodelay(AVFilterContext *ctx, AVFrame *frame)
146 {
147 20 CompandContext *s = ctx->priv;
148 20 AVFilterLink *inlink = ctx->inputs[0];
149 20 const int channels = inlink->ch_layout.nb_channels;
150 20 const int nb_samples = frame->nb_samples;
151 AVFrame *out_frame;
152 int chan, i;
153 int err;
154
155
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 if (av_frame_is_writable(frame)) {
156 20 out_frame = frame;
157 } else {
158 out_frame = ff_get_audio_buffer(ctx->outputs[0], nb_samples);
159 if (!out_frame) {
160 av_frame_free(&frame);
161 return AVERROR(ENOMEM);
162 }
163 err = av_frame_copy_props(out_frame, frame);
164 if (err < 0) {
165 av_frame_free(&out_frame);
166 av_frame_free(&frame);
167 return err;
168 }
169 }
170
171
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 20 times.
60 for (chan = 0; chan < channels; chan++) {
172 40 const double *src = (double *)frame->extended_data[chan];
173 40 double *dst = (double *)out_frame->extended_data[chan];
174 40 ChanParam *cp = &s->channels[chan];
175
176
2/2
✓ Branch 0 taken 40960 times.
✓ Branch 1 taken 40 times.
41000 for (i = 0; i < nb_samples; i++) {
177 40960 update_volume(cp, fabs(src[i]));
178
179 40960 dst[i] = src[i] * get_volume(s, cp->volume);
180 }
181 }
182
183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (frame != out_frame)
184 av_frame_free(&frame);
185
186 20 return ff_filter_frame(ctx->outputs[0], out_frame);
187 }
188
189 #define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
190
191 static int compand_delay(AVFilterContext *ctx, AVFrame *frame)
192 {
193 CompandContext *s = ctx->priv;
194 AVFilterLink *inlink = ctx->inputs[0];
195 const int channels = inlink->ch_layout.nb_channels;
196 const int nb_samples = frame->nb_samples;
197 int chan, i, av_uninit(dindex), oindex, av_uninit(count);
198 AVFrame *out_frame = NULL;
199 int err;
200
201 if (s->pts == AV_NOPTS_VALUE) {
202 s->pts = (frame->pts == AV_NOPTS_VALUE) ? 0 : frame->pts;
203 }
204
205 av_assert1(channels > 0); /* would corrupt delay_count and delay_index */
206
207 for (chan = 0; chan < channels; chan++) {
208 AVFrame *delay_frame = s->delay_frame;
209 const double *src = (double *)frame->extended_data[chan];
210 double *dbuf = (double *)delay_frame->extended_data[chan];
211 ChanParam *cp = &s->channels[chan];
212 double *dst;
213
214 count = s->delay_count;
215 dindex = s->delay_index;
216 for (i = 0, oindex = 0; i < nb_samples; i++) {
217 const double in = src[i];
218 update_volume(cp, fabs(in));
219
220 if (count >= s->delay_samples) {
221 if (!out_frame) {
222 out_frame = ff_get_audio_buffer(ctx->outputs[0], nb_samples - i);
223 if (!out_frame) {
224 av_frame_free(&frame);
225 return AVERROR(ENOMEM);
226 }
227 err = av_frame_copy_props(out_frame, frame);
228 if (err < 0) {
229 av_frame_free(&out_frame);
230 av_frame_free(&frame);
231 return err;
232 }
233 out_frame->pts = s->pts;
234 s->pts += av_rescale_q(nb_samples - i,
235 (AVRational){ 1, inlink->sample_rate },
236 inlink->time_base);
237 }
238
239 dst = (double *)out_frame->extended_data[chan];
240 dst[oindex++] = dbuf[dindex] * get_volume(s, cp->volume);
241 } else {
242 count++;
243 }
244
245 dbuf[dindex] = in;
246 dindex = MOD(dindex + 1, s->delay_samples);
247 }
248 }
249
250 s->delay_count = count;
251 s->delay_index = dindex;
252
253 av_frame_free(&frame);
254
255 if (out_frame) {
256 err = ff_filter_frame(ctx->outputs[0], out_frame);
257 return err;
258 }
259
260 return 0;
261 }
262
263 static int compand_drain(AVFilterLink *outlink)
264 {
265 AVFilterContext *ctx = outlink->src;
266 CompandContext *s = ctx->priv;
267 const int channels = outlink->ch_layout.nb_channels;
268 AVFrame *frame = NULL;
269 int chan, i, dindex;
270
271 /* 2048 is to limit output frame size during drain */
272 frame = ff_get_audio_buffer(outlink, FFMIN(2048, s->delay_count));
273 if (!frame)
274 return AVERROR(ENOMEM);
275 frame->pts = s->pts;
276 s->pts += av_rescale_q(frame->nb_samples,
277 (AVRational){ 1, outlink->sample_rate }, outlink->time_base);
278
279 av_assert0(channels > 0);
280 for (chan = 0; chan < channels; chan++) {
281 AVFrame *delay_frame = s->delay_frame;
282 double *dbuf = (double *)delay_frame->extended_data[chan];
283 double *dst = (double *)frame->extended_data[chan];
284 ChanParam *cp = &s->channels[chan];
285
286 dindex = s->delay_index;
287 for (i = 0; i < frame->nb_samples; i++) {
288 dst[i] = dbuf[dindex] * get_volume(s, cp->volume);
289 dindex = MOD(dindex + 1, s->delay_samples);
290 }
291 }
292 s->delay_count -= frame->nb_samples;
293 s->delay_index = dindex;
294
295 return ff_filter_frame(outlink, frame);
296 }
297
298 1 static int config_output(AVFilterLink *outlink)
299 {
300 1 AVFilterContext *ctx = outlink->src;
301 1 CompandContext *s = ctx->priv;
302 1 const int sample_rate = outlink->sample_rate;
303 1 double radius = s->curve_dB * M_LN10 / 20.0;
304 1 char *p, *saveptr = NULL;
305 1 const int channels = outlink->ch_layout.nb_channels;
306 int nb_attacks, nb_decays, nb_points;
307 int new_nb_items, num;
308 int i;
309 int err;
310
311
312 1 count_items(s->attacks, &nb_attacks);
313 1 count_items(s->decays, &nb_decays);
314 1 count_items(s->points, &nb_points);
315
316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (channels <= 0) {
317 av_log(ctx, AV_LOG_ERROR, "Invalid number of channels: %d\n", channels);
318 return AVERROR(EINVAL);
319 }
320
321
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (nb_attacks > channels || nb_decays > channels) {
322 av_log(ctx, AV_LOG_WARNING,
323 "Number of attacks/decays bigger than number of channels. Ignoring rest of entries.\n");
324 nb_attacks = FFMIN(nb_attacks, channels);
325 nb_decays = FFMIN(nb_decays, channels);
326 }
327
328 1 uninit(ctx);
329
330 1 s->channels = av_calloc(channels, sizeof(*s->channels));
331 1 s->nb_segments = (nb_points + 4) * 2;
332 1 s->segments = av_calloc(s->nb_segments, sizeof(*s->segments));
333
334
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (!s->channels || !s->segments) {
335 uninit(ctx);
336 return AVERROR(ENOMEM);
337 }
338
339 1 p = s->attacks;
340
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for (i = 0, new_nb_items = 0; i < nb_attacks; i++) {
341 1 char *tstr = av_strtok(p, " |", &saveptr);
342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!tstr) {
343 uninit(ctx);
344 return AVERROR(EINVAL);
345 }
346 1 p = NULL;
347 1 new_nb_items += sscanf(tstr, "%lf", &s->channels[i].attack) == 1;
348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (s->channels[i].attack < 0) {
349 uninit(ctx);
350 return AVERROR(EINVAL);
351 }
352 }
353 1 nb_attacks = new_nb_items;
354
355 1 p = s->decays;
356
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for (i = 0, new_nb_items = 0; i < nb_decays; i++) {
357 1 char *tstr = av_strtok(p, " |", &saveptr);
358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!tstr) {
359 uninit(ctx);
360 return AVERROR(EINVAL);
361 }
362 1 p = NULL;
363 1 new_nb_items += sscanf(tstr, "%lf", &s->channels[i].decay) == 1;
364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (s->channels[i].decay < 0) {
365 uninit(ctx);
366 return AVERROR(EINVAL);
367 }
368 }
369 1 nb_decays = new_nb_items;
370
371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (nb_attacks != nb_decays) {
372 av_log(ctx, AV_LOG_ERROR,
373 "Number of attacks %d differs from number of decays %d.\n",
374 nb_attacks, nb_decays);
375 uninit(ctx);
376 return AVERROR(EINVAL);
377 }
378
379
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for (i = nb_decays; i < channels; i++) {
380 1 s->channels[i].attack = s->channels[nb_decays - 1].attack;
381 1 s->channels[i].decay = s->channels[nb_decays - 1].decay;
382 }
383
384 #define S(x) s->segments[2 * ((x) + 1)]
385 1 p = s->points;
386
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (i = 0, new_nb_items = 0; i < nb_points; i++) {
387 4 char *tstr = av_strtok(p, " |", &saveptr);
388 4 p = NULL;
389
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if (!tstr || sscanf(tstr, "%lf/%lf", &S(i).x, &S(i).y) != 2) {
390 av_log(ctx, AV_LOG_ERROR,
391 "Invalid and/or missing input/output value.\n");
392 uninit(ctx);
393 return AVERROR(EINVAL);
394 }
395
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
4 if (i && S(i - 1).x > S(i).x) {
396 av_log(ctx, AV_LOG_ERROR,
397 "Transfer function input values must be increasing.\n");
398 uninit(ctx);
399 return AVERROR(EINVAL);
400 }
401 4 S(i).y -= S(i).x;
402 4 av_log(ctx, AV_LOG_DEBUG, "%d: x=%f y=%f\n", i, S(i).x, S(i).y);
403 4 new_nb_items++;
404 }
405 1 num = new_nb_items;
406
407 /* Add 0,0 if necessary */
408
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if (num == 0 || S(num - 1).x)
409 1 num++;
410
411 #undef S
412 #define S(x) s->segments[2 * (x)]
413 /* Add a tail off segment at the start */
414 1 S(0).x = S(1).x - 2 * s->curve_dB;
415 1 S(0).y = S(1).y;
416 1 num++;
417
418 /* Join adjacent colinear segments */
419
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (i = 2; i < num; i++) {
420 4 double g1 = (S(i - 1).y - S(i - 2).y) * (S(i - 0).x - S(i - 1).x);
421 4 double g2 = (S(i - 0).y - S(i - 1).y) * (S(i - 1).x - S(i - 2).x);
422 int j;
423
424
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 if (fabs(g1 - g2))
425 3 continue;
426 1 num--;
427
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (j = --i; j < num; j++)
428 4 S(j) = S(j + 1);
429 }
430
431
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 for (i = 0; i < s->nb_segments; i += 2) {
432 8 s->segments[i].y += s->gain_dB;
433 8 s->segments[i].x *= M_LN10 / 20;
434 8 s->segments[i].y *= M_LN10 / 20;
435 }
436
437 #define L(x) s->segments[i - (x)]
438
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 for (i = 4; i < s->nb_segments; i += 2) {
439 double x, y, cx, cy, in1, in2, out1, out2, theta, len, r;
440
441 6 L(4).a = 0;
442 6 L(4).b = (L(2).y - L(4).y) / (L(2).x - L(4).x);
443
444 6 L(2).a = 0;
445 6 L(2).b = (L(0).y - L(2).y) / (L(0).x - L(2).x);
446
447 6 theta = atan2(L(2).y - L(4).y, L(2).x - L(4).x);
448 6 len = hypot(L(2).x - L(4).x, L(2).y - L(4).y);
449
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 r = FFMIN(radius, len);
450 6 L(3).x = L(2).x - r * cos(theta);
451 6 L(3).y = L(2).y - r * sin(theta);
452
453 6 theta = atan2(L(0).y - L(2).y, L(0).x - L(2).x);
454 6 len = hypot(L(0).x - L(2).x, L(0).y - L(2).y);
455
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 r = FFMIN(radius, len / 2);
456 6 x = L(2).x + r * cos(theta);
457 6 y = L(2).y + r * sin(theta);
458
459 6 cx = (L(3).x + L(2).x + x) / 3;
460 6 cy = (L(3).y + L(2).y + y) / 3;
461
462 6 L(2).x = x;
463 6 L(2).y = y;
464
465 6 in1 = cx - L(3).x;
466 6 out1 = cy - L(3).y;
467 6 in2 = L(2).x - L(3).x;
468 6 out2 = L(2).y - L(3).y;
469 6 L(3).a = (out2 / in2 - out1 / in1) / (in2 - in1);
470 6 L(3).b = out1 / in1 - L(3).a * in1;
471 }
472 1 L(3).x = 0;
473 1 L(3).y = L(2).y;
474
475 1 s->in_min_lin = exp(s->segments[1].x);
476 1 s->out_min_lin = exp(s->segments[1].y);
477
478
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (i = 0; i < channels; i++) {
479 2 ChanParam *cp = &s->channels[i];
480
481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (cp->attack > 1.0 / sample_rate)
482 cp->attack = 1.0 - exp(-1.0 / (sample_rate * cp->attack));
483 else
484 2 cp->attack = 1.0;
485
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (cp->decay > 1.0 / sample_rate)
486 2 cp->decay = 1.0 - exp(-1.0 / (sample_rate * cp->decay));
487 else
488 cp->decay = 1.0;
489 2 cp->volume = ff_exp10(s->initial_volume / 20);
490 }
491
492 1 s->delay_samples = s->delay * sample_rate;
493
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (s->delay_samples <= 0) {
494 1 s->compand = compand_nodelay;
495 1 return 0;
496 }
497
498 s->delay_frame = av_frame_alloc();
499 if (!s->delay_frame) {
500 uninit(ctx);
501 return AVERROR(ENOMEM);
502 }
503
504 s->delay_frame->format = outlink->format;
505 s->delay_frame->nb_samples = s->delay_samples;
506 #if FF_API_OLD_CHANNEL_LAYOUT
507 FF_DISABLE_DEPRECATION_WARNINGS
508 s->delay_frame->channel_layout = outlink->channel_layout;
509 FF_ENABLE_DEPRECATION_WARNINGS
510 #endif
511 if ((err = av_channel_layout_copy(&s->delay_frame->ch_layout, &outlink->ch_layout)) < 0)
512 return err;
513
514 err = av_frame_get_buffer(s->delay_frame, 0);
515 if (err)
516 return err;
517
518 s->compand = compand_delay;
519 return 0;
520 }
521
522 20 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
523 {
524 20 AVFilterContext *ctx = inlink->dst;
525 20 CompandContext *s = ctx->priv;
526
527 20 return s->compand(ctx, frame);
528 }
529
530 20 static int request_frame(AVFilterLink *outlink)
531 {
532 20 AVFilterContext *ctx = outlink->src;
533 20 CompandContext *s = ctx->priv;
534 20 int ret = 0;
535
536 20 ret = ff_request_frame(ctx->inputs[0]);
537
538
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
20 if (ret == AVERROR_EOF && !ctx->is_disabled && s->delay_count)
539 ret = compand_drain(outlink);
540
541 20 return ret;
542 }
543
544 static const AVFilterPad compand_inputs[] = {
545 {
546 .name = "default",
547 .type = AVMEDIA_TYPE_AUDIO,
548 .filter_frame = filter_frame,
549 },
550 };
551
552 static const AVFilterPad compand_outputs[] = {
553 {
554 .name = "default",
555 .request_frame = request_frame,
556 .config_props = config_output,
557 .type = AVMEDIA_TYPE_AUDIO,
558 },
559 };
560
561
562 const AVFilter ff_af_compand = {
563 .name = "compand",
564 .description = NULL_IF_CONFIG_SMALL(
565 "Compress or expand audio dynamic range."),
566 .priv_size = sizeof(CompandContext),
567 .priv_class = &compand_class,
568 .init = init,
569 .uninit = uninit,
570 FILTER_INPUTS(compand_inputs),
571 FILTER_OUTPUTS(compand_outputs),
572 FILTER_SINGLE_SAMPLEFMT(AV_SAMPLE_FMT_DBLP),
573 };
574