|
...
|
...
|
@@ -191,9 +191,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args0, void *opaque)
|
|
191
|
191
|
return 0;
|
|
192
|
192
|
}
|
|
193
|
193
|
|
|
194
|
|
-static void filter_samples_channel_mapping(PanContext *pan, AVFilterBufferRef *outsamples, AVFilterBufferRef *insamples, int n);
|
|
195
|
|
-static void filter_samples_panning (PanContext *pan, AVFilterBufferRef *outsamples, AVFilterBufferRef *insamples, int n);
|
|
196
|
|
-
|
|
197
|
194
|
static int are_gains_pure(const PanContext *pan)
|
|
198
|
195
|
{
|
|
199
|
196
|
int i, j;
|
|
...
|
...
|
@@ -216,40 +213,6 @@ static int are_gains_pure(const PanContext *pan)
|
|
216
|
216
|
return 1;
|
|
217
|
217
|
}
|
|
218
|
218
|
|
|
219
|
|
-static int query_formats(AVFilterContext *ctx)
|
|
220
|
|
-{
|
|
221
|
|
- PanContext *pan = ctx->priv;
|
|
222
|
|
- AVFilterLink *inlink = ctx->inputs[0];
|
|
223
|
|
- AVFilterLink *outlink = ctx->outputs[0];
|
|
224
|
|
- AVFilterFormats *formats;
|
|
225
|
|
-
|
|
226
|
|
- if (pan->nb_output_channels <= SWR_CH_MAX)
|
|
227
|
|
- pan->pure_gains = are_gains_pure(pan);
|
|
228
|
|
- if (pan->pure_gains) {
|
|
229
|
|
- /* libswr supports any sample and packing formats */
|
|
230
|
|
- avfilter_set_common_sample_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO));
|
|
231
|
|
- avfilter_set_common_packing_formats(ctx, avfilter_make_all_packing_formats());
|
|
232
|
|
- pan->filter_samples = filter_samples_channel_mapping;
|
|
233
|
|
- } else {
|
|
234
|
|
- const enum AVSampleFormat sample_fmts[] = {AV_SAMPLE_FMT_S16, -1};
|
|
235
|
|
- const int packing_fmts[] = {AVFILTER_PACKED, -1};
|
|
236
|
|
-
|
|
237
|
|
- avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts));
|
|
238
|
|
- avfilter_set_common_packing_formats(ctx, avfilter_make_format_list(packing_fmts));
|
|
239
|
|
- pan->filter_samples = filter_samples_panning;
|
|
240
|
|
- }
|
|
241
|
|
-
|
|
242
|
|
- // inlink supports any channel layout
|
|
243
|
|
- formats = avfilter_make_all_channel_layouts();
|
|
244
|
|
- avfilter_formats_ref(formats, &inlink->out_chlayouts);
|
|
245
|
|
-
|
|
246
|
|
- // outlink supports only requested output channel layout
|
|
247
|
|
- formats = NULL;
|
|
248
|
|
- avfilter_add_format(&formats, pan->out_channel_layout);
|
|
249
|
|
- avfilter_formats_ref(formats, &outlink->in_chlayouts);
|
|
250
|
|
- return 0;
|
|
251
|
|
-}
|
|
252
|
|
-
|
|
253
|
219
|
static int config_props(AVFilterLink *link)
|
|
254
|
220
|
{
|
|
255
|
221
|
AVFilterContext *ctx = link->dst;
|
|
...
|
...
|
@@ -403,6 +366,40 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
|
|
403
|
403
|
avfilter_unref_buffer(insamples);
|
|
404
|
404
|
}
|
|
405
|
405
|
|
|
|
406
|
+static int query_formats(AVFilterContext *ctx)
|
|
|
407
|
+{
|
|
|
408
|
+ PanContext *pan = ctx->priv;
|
|
|
409
|
+ AVFilterLink *inlink = ctx->inputs[0];
|
|
|
410
|
+ AVFilterLink *outlink = ctx->outputs[0];
|
|
|
411
|
+ AVFilterFormats *formats;
|
|
|
412
|
+
|
|
|
413
|
+ if (pan->nb_output_channels <= SWR_CH_MAX)
|
|
|
414
|
+ pan->pure_gains = are_gains_pure(pan);
|
|
|
415
|
+ if (pan->pure_gains) {
|
|
|
416
|
+ /* libswr supports any sample and packing formats */
|
|
|
417
|
+ avfilter_set_common_sample_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO));
|
|
|
418
|
+ avfilter_set_common_packing_formats(ctx, avfilter_make_all_packing_formats());
|
|
|
419
|
+ pan->filter_samples = filter_samples_channel_mapping;
|
|
|
420
|
+ } else {
|
|
|
421
|
+ const enum AVSampleFormat sample_fmts[] = {AV_SAMPLE_FMT_S16, -1};
|
|
|
422
|
+ const int packing_fmts[] = {AVFILTER_PACKED, -1};
|
|
|
423
|
+
|
|
|
424
|
+ avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts));
|
|
|
425
|
+ avfilter_set_common_packing_formats(ctx, avfilter_make_format_list(packing_fmts));
|
|
|
426
|
+ pan->filter_samples = filter_samples_panning;
|
|
|
427
|
+ }
|
|
|
428
|
+
|
|
|
429
|
+ // inlink supports any channel layout
|
|
|
430
|
+ formats = avfilter_make_all_channel_layouts();
|
|
|
431
|
+ avfilter_formats_ref(formats, &inlink->out_chlayouts);
|
|
|
432
|
+
|
|
|
433
|
+ // outlink supports only requested output channel layout
|
|
|
434
|
+ formats = NULL;
|
|
|
435
|
+ avfilter_add_format(&formats, pan->out_channel_layout);
|
|
|
436
|
+ avfilter_formats_ref(formats, &outlink->in_chlayouts);
|
|
|
437
|
+ return 0;
|
|
|
438
|
+}
|
|
|
439
|
+
|
|
406
|
440
|
static av_cold void uninit(AVFilterContext *ctx)
|
|
407
|
441
|
{
|
|
408
|
442
|
PanContext *pan = ctx->priv;
|