History

lavfi: drop planar/packed negotiation support

The planar/packed switch and the packing_formats list is no longer required, since the planar/packed information is now stored in the sample format enum. This is technically a major API break, possibly it should be not too painful as we marked the audio filtering API as unstable.

Stefano Sabatini committed 14 years ago

Commit 4d4098d1 parent 183596f28 files · +71 −145Browse files

Unified · Split

28 files
  1. doc/examples/filtering_audio.c +1 −3
  2. doc/filter_design.txt +2 −1
  3. doc/filters.texi +9 −16
  4. libavdevice/lavfi.c +0 −2
  5. libavfilter/af_aconvert.c +4 −12
  6. libavfilter/af_amerge.c +1 −5
  7. libavfilter/af_ashowinfo.c +2 −3
  8. libavfilter/af_astreamsync.c +0 −3
  9. libavfilter/af_earwax.c +0 −3
  10. libavfilter/af_pan.c +0 −2
  11. libavfilter/af_silencedetect.c +0 −6
  12. libavfilter/af_volume.c +0 −6
  13. libavfilter/asrc_aevalsrc.c +0 −2
  14. libavfilter/audio.c +2 −2
  15. libavfilter/audio.h +17 −0
  16. libavfilter/avfilter.c +0 −3
  17. libavfilter/avfilter.h +12 −0
  18. libavfilter/avfiltergraph.c +6 −10
  19. libavfilter/buffersink.h +2 −0
  20. libavfilter/defaults.c +2 −0
  21. libavfilter/formats.c +2 −17
  22. libavfilter/graphdump.c +2 −3
  23. libavfilter/internal.h +0 −10
  24. libavfilter/sink_buffer.c +1 −12
  25. libavfilter/src_buffer.c +3 −14
  26. libavfilter/src_movie.c +0 −2
  27. libavfilter/version.h +3 −0
  28. tools/lavfi-showfiltfmts.c +0 −8
doc/examples/filtering_audio.c+1−3
@@ -88,7 +88,6 @@ static int init_filters(const char *filters_descr) · 87 unmodified lines
8888 AVFilterInOut *outputs = avfilter_inout_alloc();
8989 AVFilterInOut *inputs = avfilter_inout_alloc();
9090 const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 };
91− const int packing_fmts[] = { AVFILTER_PACKED, -1 };
9291 const int64_t *chlayouts = avfilter_all_channel_layouts;
9392 AVABufferSinkParams *abuffersink_params;
9493 const AVFilterLink *outlink;
@@ -98,7 +97,7 @@ static int init_filters(const char *filters_descr) · 3 unmodified lines
9897 /* buffer audio source: the decoded frames from the decoder will be inserted here. */
9998 if (!dec_ctx->channel_layout)
10099 dec_ctx->channel_layout = av_get_default_channel_layout(dec_ctx->channels);
101− snprintf(args, sizeof(args), "%d:%d:0x%"PRIx64":packed",
100+ snprintf(args, sizeof(args), "%d:%d:0x%"PRIx64,
102101 dec_ctx->sample_rate, dec_ctx->sample_fmt, dec_ctx->channel_layout);
103102 ret = avfilter_graph_create_filter(&buffersrc_ctx, abuffersrc, "in",
104103 args, NULL, filter_graph);
@@ -111,7 +110,6 @@ static int init_filters(const char *filters_descr) · 6 unmodified lines
111110 abuffersink_params = av_abuffersink_params_alloc();
112111 abuffersink_params->sample_fmts = sample_fmts;
113112 abuffersink_params->channel_layouts = chlayouts;
114− abuffersink_params->packing_fmts = packing_fmts;
115113 ret = avfilter_graph_create_filter(&buffersink_ctx, abuffersink, "out",
116114 NULL, abuffersink_params, filter_graph);
117115 av_free(abuffersink_params);
doc/filter_design.txt+2−1
@@ -15,7 +15,8 @@ Format negotiation · 14 unmodified lines
1515 the list supported formats.
1616
1717 For video links, that means pixel format. For audio links, that means
18− channel layout, sample format and sample packing.
18+ channel layout, and sample format (the sample packing is implied by the
19+ sample format).
1920
2021 The lists are not just lists, they are references to shared objects. When
2122 the negotiation mechanism computes the intersection of the formats
doc/filters.texi+9−16
@@ -146,7 +146,7 @@ Convert the input audio to one of the specified formats. The framework will · 145 unmodified lines
146146 negotiate the most appropriate format to minimize conversions.
147147
148148 The filter accepts three lists of formats, separated by ":", in the form:
149−"@var{sample_formats}:@var{channel_layouts}:@var{packing_formats}".
149+"@var{sample_formats}:@var{channel_layouts}".
150150
151151 Elements in each list are separated by "," which has to be escaped in the
152152 filtergraph specification.
@@ -156,9 +156,9 @@ supported formats. · 3 unmodified lines
156156
157157 Some examples follow:
158158 @example
159−aformat=u8\\,s16:mono:packed
159+aformat=u8\\,s16:mono
160160
161−aformat=s16:mono\\,stereo:all
161+aformat=s16:mono\\,stereo
162162 @end example
163163
164164 @section amerge
@@ -184,7 +184,7 @@ On the other hand, if both input are in stereo, the output channels will be · 19 unmodified lines
184184 in the default order: a1, a2, b1, b2, and the channel layout will be
185185 arbitrarily set to 4.0, which may or may not be the expected value.
186186
187−Both inputs must have the same sample rate, format and packing.
187+Both inputs must have the same sample rate, and format.
188188
189189 If inputs do not have the same duration, the output will stop with the
190190 shortest.
@@ -293,9 +293,6 @@ number of samples (per each channel) contained in the filtered frame · 102 unmodified lines
293293 @item rate
294294 sample rate for the audio frame
295295
296−@item planar
297−if the packing format is planar, 0 if packed
298−
299296 @item checksum
300297 Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
301298
@@ -566,7 +563,7 @@ This source is mainly intended for a programmatic use, in particular · 264 unmodified lines
566563 through the interface defined in @file{libavfilter/asrc_abuffer.h}.
567564
568565 It accepts the following mandatory parameters:
569−@var{sample_rate}:@var{sample_fmt}:@var{channel_layout}:@var{packing}
566+@var{sample_rate}:@var{sample_fmt}:@var{channel_layout}
570567
571568 @table @option
572569
@@ -584,23 +581,19 @@ Either a channel layout name from channel_layout_map in · 11 unmodified lines
584581 @file{libavutil/audioconvert.c} or its corresponding integer representation
585582 from the AV_CH_LAYOUT_* macros in @file{libavutil/audioconvert.h}
586583
587−@item packing
588−Either "packed" or "planar", or their integer representation: 0 or 1
589−respectively.
590−
591584 @end table
592585
593586 For example:
594587 @example
595−abuffer=44100:s16:stereo:planar
588+abuffer=44100:s16p:stereo
596589 @end example
597590
598591 will instruct the source to accept planar 16bit signed stereo at 44100Hz.
599−Since the sample format with name "s16" corresponds to the number
600−1 and the "stereo" channel layout corresponds to the value 0x3, this is
592+Since the sample format with name "s16p" corresponds to the number
593+6 and the "stereo" channel layout corresponds to the value 0x3, this is
601594 equivalent to:
602595 @example
603−abuffer=44100:1:0x3:1
596+abuffer=44100:6:0x3
604597 @end example
605598
606599 @section aevalsrc
libavdevice/lavfi.c+0−2
@@ -211,11 +211,9 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) · 210 unmodified lines
211211 AV_SAMPLE_FMT_S32,
212212 AV_SAMPLE_FMT_FLT,
213213 AV_SAMPLE_FMT_DBL, -1 };
214− const int packing_fmts[] = { AVFILTER_PACKED, -1 };
215214 const int64_t *chlayouts = avfilter_all_channel_layouts;
216215 AVABufferSinkParams *abuffersink_params = av_abuffersink_params_alloc();
217216 abuffersink_params->sample_fmts = sample_fmts;
218− abuffersink_params->packing_fmts = packing_fmts;
219217 abuffersink_params->channel_layouts = chlayouts;
220218
221219 ret = avfilter_graph_create_filter(&sink, abuffersink,
libavfilter/af_aconvert.c+4−12
@@ -73,7 +73,6 @@ static int query_formats(AVFilterContext *ctx) · 72 unmodified lines
7373 AConvertContext *aconvert = ctx->priv;
7474 AVFilterLink *inlink = ctx->inputs[0];
7575 AVFilterLink *outlink = ctx->outputs[0];
76− int out_packing = av_sample_fmt_is_planar(aconvert->out_sample_fmt);
7776 AVFilterChannelLayouts *layouts;
7877
7978 avfilter_formats_ref(avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO),
@@ -96,12 +95,6 @@ static int query_formats(AVFilterContext *ctx) · 16 unmodified lines
9695 ff_channel_layouts_ref(ff_all_channel_layouts(),
9796 &outlink->in_channel_layouts);
9897
99− avfilter_formats_ref(avfilter_make_all_packing_formats(),
100− &inlink->out_packing);
101− formats = NULL;
102− avfilter_add_format(&formats, out_packing);
103− avfilter_formats_ref(formats, &outlink->in_packing);
104−
10598 return 0;
10699 }
107100
@@ -134,9 +127,9 @@ static int config_output(AVFilterLink *outlink) · 26 unmodified lines
134127 av_get_channel_layout_string(buf2, sizeof(buf2),
135128 -1, outlink->channel_layout);
136129 av_log(ctx, AV_LOG_INFO,
137− "fmt:%s cl:%s planar:%i -> fmt:%s cl:%s planar:%i\n",
138− av_get_sample_fmt_name(inlink ->format), buf1, inlink ->planar,
139− av_get_sample_fmt_name(outlink->format), buf2, outlink->planar);
130+ "fmt:%s cl:%s -> fmt:%s cl:%s\n",
131+ av_get_sample_fmt_name(inlink ->format), buf1,
132+ av_get_sample_fmt_name(outlink->format), buf2);
140133
141134 return 0;
142135 }
@@ -153,7 +146,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 10 unmodified lines
153146
154147 avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
155148 outsamplesref->audio->channel_layout = outlink->channel_layout;
156− outsamplesref->audio->planar = outlink->planar;
157149
158150 ff_filter_samples(outlink, outsamplesref);
159151 avfilter_unref_buffer(insamplesref);
@@ -161,7 +153,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 1 unmodified line
161153
162154 AVFilter avfilter_af_aconvert = {
163155 .name = "aconvert",
164− .description = NULL_IF_CONFIG_SMALL("Convert the input audio to sample_fmt:channel_layout:packed_fmt."),
156+ .description = NULL_IF_CONFIG_SMALL("Convert the input audio to sample_fmt:channel_layout."),
165157 .priv_size = sizeof(AConvertContext),
166158 .init = init,
167159 .uninit = uninit,
libavfilter/af_amerge.c+1−5
@@ -54,7 +54,6 @@ static int query_formats(AVFilterContext *ctx) · 53 unmodified lines
5454 {
5555 AMergeContext *am = ctx->priv;
5656 int64_t inlayout[2], outlayout;
57− const int packing_fmts[] = { AVFILTER_PACKED, -1 };
5857 AVFilterFormats *formats;
5958 AVFilterChannelLayouts *layouts;
6059 int i;
@@ -97,10 +96,8 @@ static int query_formats(AVFilterContext *ctx) · 36 unmodified lines
9796 if ((inlayout[i] >> c) & 1)
9897 *(route[i]++) = out_ch_number++;
9998 }
100− formats = avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO);
99+ formats = avfilter_make_format_list(ff_packed_sample_fmts);
101100 avfilter_set_common_sample_formats(ctx, formats);
102− formats = avfilter_make_format_list(packing_fmts);
103− avfilter_set_common_packing_formats(ctx, formats);
104101 for (i = 0; i < 2; i++) {
105102 layouts = NULL;
106103 ff_add_channel_layout(&layouts, inlayout[i]);
@@ -222,7 +219,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 115 unmodified lines
222219 avfilter_copy_buffer_ref_props(outbuf, *inbuf[0]);
223220 outbuf->audio->nb_samples = nb_samples;
224221 outbuf->audio->channel_layout = outlink->channel_layout;
225− outbuf->audio->planar = outlink->planar;
226222
227223 while (nb_samples) {
228224 ns = nb_samples;
libavfilter/af_ashowinfo.c+2−3
@@ -50,7 +50,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) · 49 unmodified lines
5050 int linesize =
5151 samplesref->audio->nb_samples *
5252 av_get_bytes_per_sample(samplesref->format);
53− if (!samplesref->audio->planar) /* packed layout */
53+ if (!av_sample_fmt_is_planar(samplesref->format))
5454 linesize *= av_get_channel_layout_nb_channels(samplesref->audio->channel_layout);
5555
5656 for (plane = 0; samplesref->data[plane] && plane < 8; plane++) {
@@ -66,7 +66,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) · 9 unmodified lines
6666
6767 av_log(ctx, AV_LOG_INFO,
6868 "n:%d pts:%s pts_time:%s pos:%"PRId64" "
69− "fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d "
69+ "fmt:%s chlayout:%s nb_samples:%d rate:%d "
7070 "checksum:%08X plane_checksum[%08X",
7171 showinfo->frame,
7272 av_ts2str(samplesref->pts), av_ts2timestr(samplesref->pts, &inlink->time_base),
@@ -75,7 +75,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) · 2 unmodified lines
7575 chlayout_str,
7676 samplesref->audio->nb_samples,
7777 samplesref->audio->sample_rate,
78− samplesref->audio->planar,
7978 checksum,
8079 plane_checksum[0]);
8180
libavfilter/af_astreamsync.c+0−3
@@ -87,9 +87,6 @@ static int query_formats(AVFilterContext *ctx) · 86 unmodified lines
8787 formats = ctx->inputs[i]->in_formats;
8888 avfilter_formats_ref(formats, &ctx->inputs[i]->out_formats);
8989 avfilter_formats_ref(formats, &ctx->outputs[i]->in_formats);
90− formats = ctx->inputs[i]->in_packing;
91− avfilter_formats_ref(formats, &ctx->inputs[i]->out_packing);
92− avfilter_formats_ref(formats, &ctx->outputs[i]->in_packing);
9390 layouts = ctx->inputs[i]->in_channel_layouts;
9491 ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts);
9592 ff_channel_layouts_ref(layouts, &ctx->outputs[i]->in_channel_layouts);
libavfilter/af_earwax.c+0−3
@@ -86,9 +86,6 @@ static int query_formats(AVFilterContext *ctx) · 85 unmodified lines
8686 avfilter_set_common_sample_formats(ctx, formats);
8787 ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO);
8888 ff_set_common_channel_layouts(ctx, layout);
89− formats = NULL;
90− avfilter_add_format(&formats, AVFILTER_PACKED);
91− avfilter_set_common_packing_formats(ctx, formats);
9289 ff_set_common_samplerates(ctx, avfilter_make_format_list(sample_rates));
9390
9491 return 0;
libavfilter/af_pan.c+0−2
@@ -218,7 +218,6 @@ static int query_formats(AVFilterContext *ctx) · 217 unmodified lines
218218 pan->pure_gains = are_gains_pure(pan);
219219 /* libswr supports any sample and packing formats */
220220 avfilter_set_common_sample_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO));
221− avfilter_set_common_packing_formats(ctx, avfilter_make_all_packing_formats());
222221
223222 // inlink supports any channel layout
224223 layouts = ff_all_channel_layouts();
@@ -348,7 +347,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 123 unmodified lines
348347 swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n);
349348 avfilter_copy_buffer_ref_props(outsamples, insamples);
350349 outsamples->audio->channel_layout = outlink->channel_layout;
351− outsamples->audio->planar = outlink->planar;
352350
353351 ff_filter_samples(outlink, outsamples);
354352 avfilter_unref_buffer(insamples);
libavfilter/af_silencedetect.c+0−6
@@ -136,7 +136,6 @@ static int query_formats(AVFilterContext *ctx) · 135 unmodified lines
136136 AV_SAMPLE_FMT_DBL,
137137 AV_SAMPLE_FMT_NONE
138138 };
139− int packing_fmts[] = { AVFILTER_PACKED, -1 };
140139
141140 layouts = ff_all_channel_layouts();
142141 if (!layouts)
@@ -148,11 +147,6 @@ static int query_formats(AVFilterContext *ctx) · 5 unmodified lines
148147 return AVERROR(ENOMEM);
149148 avfilter_set_common_sample_formats(ctx, formats);
150149
151− formats = avfilter_make_format_list(packing_fmts);
152− if (!formats)
153− return AVERROR(ENOMEM);
154− avfilter_set_common_packing_formats(ctx, formats);
155−
156150 formats = ff_all_samplerates();
157151 if (!formats)
158152 return AVERROR(ENOMEM);
libavfilter/af_volume.c+0−6
@@ -91,7 +91,6 @@ static int query_formats(AVFilterContext *ctx) · 90 unmodified lines
9191 AV_SAMPLE_FMT_DBL,
9292 AV_SAMPLE_FMT_NONE
9393 };
94− int packing_fmts[] = { AVFILTER_PACKED, -1 };
9594
9695 layouts = ff_all_channel_layouts();
9796 if (!layouts)
@@ -103,11 +102,6 @@ static int query_formats(AVFilterContext *ctx) · 5 unmodified lines
103102 return AVERROR(ENOMEM);
104103 avfilter_set_common_sample_formats(ctx, formats);
105104
106− formats = avfilter_make_format_list(packing_fmts);
107− if (!formats)
108− return AVERROR(ENOMEM);
109− avfilter_set_common_packing_formats(ctx, formats);
110−
111105 formats = ff_all_samplerates();
112106 if (!formats)
113107 return AVERROR(ENOMEM);
libavfilter/asrc_aevalsrc.c+0−2
@@ -187,11 +187,9 @@ static int query_formats(AVFilterContext *ctx) · 186 unmodified lines
187187 EvalContext *eval = ctx->priv;
188188 enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE };
189189 int64_t chlayouts[] = { eval->chlayout, -1 };
190− int packing_fmts[] = { AVFILTER_PLANAR, -1 };
191190
192191 avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts));
193192 ff_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts));
194− avfilter_set_common_packing_formats(ctx, avfilter_make_format_list(packing_fmts));
195193
196194 return 0;
197195 }
libavfilter/audio.c+2−2
@@ -100,9 +100,9 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, · 99 unmodified lines
100100
101101 samplesref->audio->nb_samples = nb_samples;
102102 samplesref->audio->channel_layout = channel_layout;
103− samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt);
104103
105− planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1;
104+ planes = av_sample_fmt_is_planar(sample_fmt) ?
105+ av_get_channel_layout_nb_channels(channel_layout) : 1;
106106
107107 /* make sure the buffer gets read permission or it's useless for output */
108108 samplesref->perms = perms | AV_PERM_READ;
libavfilter/audio.h+17−0
@@ -24,6 +24,23 @@ · 23 unmodified lines
2424
2525 #include "avfilter.h"
2626
27+static const enum AVSampleFormat ff_packed_sample_fmts[] = {
28+ AV_SAMPLE_FMT_U8,
29+ AV_SAMPLE_FMT_S16,
30+ AV_SAMPLE_FMT_S32,
31+ AV_SAMPLE_FMT_FLT,
32+ AV_SAMPLE_FMT_DBL,
33+ AV_SAMPLE_FMT_NONE
34+};
35+
36+static const enum AVSampleFormat ff_planar_sample_fmts[] = {
37+ AV_SAMPLE_FMT_U8P,
38+ AV_SAMPLE_FMT_S16P,
39+ AV_SAMPLE_FMT_S32P,
40+ AV_SAMPLE_FMT_FLTP,
41+ AV_SAMPLE_FMT_DBLP,
42+ AV_SAMPLE_FMT_NONE
43+};
2744
2845 /** default handler for get_audio_buffer() for audio inputs */
2946 AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms,
libavfilter/avfilter.c+0−3
@@ -148,9 +148,6 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, · 147 unmodified lines
148148 if (link->out_channel_layouts)
149149 ff_channel_layouts_changeref(&link->out_channel_layouts,
150150 &filt->outputs[filt_dstpad_idx]->out_channel_layouts);
151− if (link->out_packing)
152− avfilter_formats_changeref(&link->out_packing,
153− &filt->outputs[filt_dstpad_idx]->out_packing);
154151 if (link->out_samplerates)
155152 avfilter_formats_changeref(&link->out_samplerates,
156153 &filt->outputs[filt_dstpad_idx]->out_samplerates);
libavfilter/avfilter.h+12−0
@@ -121,7 +121,9 @@ typedef struct AVFilterBufferRefAudioProps { · 120 unmodified lines
121121 uint64_t channel_layout; ///< channel layout of audio buffer
122122 int nb_samples; ///< number of audio samples per channel
123123 int sample_rate; ///< audio buffer sample rate
124+#if FF_API_PACKING
124125 int planar; ///< audio buffer - planar or packed
126+#endif
125127 } AVFilterBufferRefAudioProps;
126128
127129 /**
@@ -303,10 +305,12 @@ AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type); · 175 unmodified lines
303305 */
304306 extern const int64_t avfilter_all_channel_layouts[];
305307
308+#if FF_API_PACKING
306309 /**
307310 * Return a list of all audio packing formats.
308311 */
309312 AVFilterFormats *avfilter_make_all_packing_formats(void);
313+#endif
310314
311315 /**
312316 * Return a format list which contains the intersection of the formats of
@@ -519,7 +523,9 @@ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) · 206 unmodified lines
519523 void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats);
520524 void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats);
521525 void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats);
526+#if FF_API_PACKING
522527 void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats);
528+#endif
523529
524530 /** Default handler for query_formats() */
525531 int avfilter_default_query_formats(AVFilterContext *ctx);
@@ -616,10 +622,12 @@ struct AVFilterContext { · 90 unmodified lines
616622 struct AVFilterCommand *command_queue;
617623 };
618624
625+#if FF_API_PACKING
619626 enum AVFilterPacking {
620627 AVFILTER_PACKED = 0,
621628 AVFILTER_PLANAR,
622629 };
630+#endif
623631
624632 /**
625633 * A link between two filters. This contains pointers to the source and
@@ -655,7 +663,9 @@ struct AVFilterLink { · 29 unmodified lines
655663 #else
656664 int sample_rate; ///< samples per second
657665 #endif
666+#if FF_API_PACKING
658667 int planar; ///< agreed upon packing mode of audio buffers. true if planar.
668+#endif
659669
660670 int format; ///< agreed upon media format
661671
@@ -669,8 +679,10 @@ struct AVFilterLink { · 7 unmodified lines
669679 AVFilterFormats *in_formats;
670680 AVFilterFormats *out_formats;
671681
682+#if FF_API_PACKING
672683 AVFilterFormats *in_packing;
673684 AVFilterFormats *out_packing;
685+#endif
674686
675687 /**
676688 * The buffer reference currently being sent across the link by the source
libavfilter/avfiltergraph.c+6−10
@@ -200,14 +200,12 @@ static int insert_conv_filter(AVFilterGraph *graph, AVFilterLink *link, · 199 unmodified lines
200200
201201 if (link->type == AVMEDIA_TYPE_AUDIO &&
202202 (((link = filt_ctx-> inputs[0]) &&
203− (!ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts) ||
204− !avfilter_merge_formats(link->in_packing, link->out_packing))) ||
203+ !ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts)) ||
205204 ((link = filt_ctx->outputs[0]) &&
206− (!ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts) ||
207− !avfilter_merge_formats(link->in_packing, link->out_packing))))
205+ !ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts)))
208206 ) {
209207 av_log(NULL, AV_LOG_ERROR,
210− "Impossible to convert between the channel layouts/packing formats supported by the filter "
208+ "Impossible to convert between the channel layouts formats supported by the filter "
211209 "'%s' and the filter '%s'\n", link->src->name, link->dst->name);
212210 return AVERROR(EINVAL);
213211 }
@@ -219,7 +217,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 5 unmodified lines
219217 {
220218 int i, j, ret;
221219 char filt_args[128];
222− AVFilterFormats *formats, *packing;
220+ AVFilterFormats *formats;
223221 AVFilterChannelLayouts *chlayouts;
224222 AVFilterFormats *samplerates;
225223 int scaler_count = 0, resampler_count = 0;
@@ -254,8 +252,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 28 unmodified lines
254252 return ret;
255253 }
256254 else if (link->type == AVMEDIA_TYPE_AUDIO) {
257− if (!link->in_channel_layouts || !link->out_channel_layouts ||
258− !link->in_packing || !link->out_packing)
255+ if (!link->in_channel_layouts || !link->out_channel_layouts)
259256 return AVERROR(EINVAL);
260257
261258 /* Merge all three list before checking: that way, in all
@@ -264,9 +261,8 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 2 unmodified lines
264261 formats = avfilter_merge_formats(link->in_formats, link->out_formats);
265262 chlayouts = ff_merge_channel_layouts(link->in_channel_layouts , link->out_channel_layouts);
266263 samplerates = ff_merge_samplerates (link->in_samplerates, link->out_samplerates);
267− packing = avfilter_merge_formats(link->in_packing, link->out_packing);
268264
269− if (!formats || !chlayouts || !packing || !samplerates)
265+ if (!formats || !chlayouts || !samplerates)
270266 if (ret = insert_conv_filter(graph, link, "aconvert", NULL))
271267 return ret;
272268 #else
libavfilter/buffersink.h+2−0
@@ -46,7 +46,9 @@ AVBufferSinkParams *av_buffersink_params_alloc(void); · 45 unmodified lines
4646 typedef struct {
4747 const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
4848 const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1
49+#if FF_API_PACKING
4950 const int *packing_fmts; ///< list of allowed packing formats
51+#endif
5052 } AVABufferSinkParams;
5153
5254 /**
libavfilter/defaults.c+2−0
@@ -70,9 +70,11 @@ void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats * · 69 unmodified lines
7070 offsetof(AVFilterLink, out_channel_layouts));
7171 }
7272
73+#if FF_API_PACKING
7374 void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats)
7475 {
7576 set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO,
7677 offsetof(AVFilterLink, in_packing),
7778 offsetof(AVFilterLink, out_packing));
7879 }
80+#endif
libavfilter/formats.c+2−17
@@ -289,6 +289,7 @@ const int64_t avfilter_all_channel_layouts[] = { · 288 unmodified lines
289289 // return avfilter_make_format64_list(avfilter_all_channel_layouts);
290290 // }
291291
292+#if FF_API_PACKING
292293 AVFilterFormats *avfilter_make_all_packing_formats(void)
293294 {
294295 static const int packing[] = {
@@ -299,6 +300,7 @@ AVFilterFormats *avfilter_make_all_packing_formats(void) · 4 unmodified lines
299300
300301 return avfilter_make_format_list(packing);
301302 }
303+#endif
302304
303305 AVFilterFormats *ff_all_samplerates(void)
304306 {
@@ -518,23 +520,6 @@ int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx) · 213 unmodified lines
518520 return 0;
519521 }
520522
521−int ff_parse_packing_format(int *ret, const char *arg, void *log_ctx)
522−{
523− char *tail;
524− int planar = strtol(arg, &tail, 10);
525− if (*tail) {
526− planar = !strcmp(arg, "packed") ? 0:
527− !strcmp(arg, "planar") ? 1: -1;
528− }
529−
530− if (planar != 0 && planar != 1) {
531− av_log(log_ctx, AV_LOG_ERROR, "Invalid packing format '%s'\n", arg);
532− return AVERROR(EINVAL);
533− }
534− *ret = planar;
535− return 0;
536−}
537−
538523 #ifdef TEST
539524
540525 #undef printf
libavfilter/graphdump.c+2−3
@@ -46,9 +46,8 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link) · 45 unmodified lines
4646 av_get_channel_layout_string(layout, sizeof(layout),
4747 -1, link->channel_layout);
4848 format = av_x_if_null(av_get_sample_fmt_name(link->format), "?");
49− av_bprintf(buf, "[%dHz %s:%s:%s]",
50− (int)link->sample_rate, format, layout,
51− link->planar ? "planar" : "packed");
49+ av_bprintf(buf, "[%dHz %s:%s]",
50+ (int)link->sample_rate, format, layout);
5251 break;
5352
5453 default:
libavfilter/internal.h+0−10
@@ -131,16 +131,6 @@ int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx); · 130 unmodified lines
131131 */
132132 int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx);
133133
134−/**
135− * Parse a packing format or a corresponding integer representation.
136− *
137− * @param ret integer pointer to where the value should be written
138− * @param arg string to parse
139− * @param log_ctx log context
140− * @return 0 in case of success, a negative AVERROR code on error
141− */
142−int ff_parse_packing_format(int *ret, const char *arg, void *log_ctx);
143−
144134 /**
145135 * Pass video frame along and keep an internal reference for later use.
146136 */
libavfilter/sink_buffer.c+1−12
@@ -42,7 +42,6 @@ AVBufferSinkParams *av_buffersink_params_alloc(void) · 41 unmodified lines
4242 AVABufferSinkParams *av_abuffersink_params_alloc(void)
4343 {
4444 static const int sample_fmts[] = { -1 };
45− static const int packing_fmts[] = { -1 };
4645 static const int64_t channel_layouts[] = { -1 };
4746 AVABufferSinkParams *params = av_malloc(sizeof(AVABufferSinkParams));
4847
@@ -51,7 +50,6 @@ AVABufferSinkParams *av_abuffersink_params_alloc(void) · 2 unmodified lines
5150
5251 params->sample_fmts = sample_fmts;
5352 params->channel_layouts = channel_layouts;
54− params->packing_fmts = packing_fmts;
5553 return params;
5654 }
5755
@@ -64,7 +62,6 @@ typedef struct { · 6 unmodified lines
6462 /* only used for audio */
6563 enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
6664 int64_t *channel_layouts; ///< list of accepted channel layouts, terminated by -1
67− int *packing_fmts; ///< list of accepted packing formats, terminated by -1
6865 } BufferSinkContext;
6966
7067 #define FIFO_INIT_SIZE 8
@@ -244,11 +241,9 @@ static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaq · 173 unmodified lines
244241
245242 buf->sample_fmts = ff_copy_int_list (params->sample_fmts);
246243 buf->channel_layouts = ff_copy_int64_list(params->channel_layouts);
247− buf->packing_fmts = ff_copy_int_list (params->packing_fmts);
248− if (!buf->sample_fmts || !buf->channel_layouts || !buf->sample_fmts) {
244+ if (!buf->sample_fmts || !buf->channel_layouts) {
249245 av_freep(&buf->sample_fmts);
250246 av_freep(&buf->channel_layouts);
251− av_freep(&buf->packing_fmts);
252247 return AVERROR(ENOMEM);
253248 }
254249
@@ -261,7 +256,6 @@ static av_cold void asink_uninit(AVFilterContext *ctx) · 6 unmodified lines
261256
262257 av_freep(&buf->sample_fmts);
263258 av_freep(&buf->channel_layouts);
264− av_freep(&buf->packing_fmts);
265259 return common_uninit(ctx);
266260 }
267261
@@ -278,11 +272,6 @@ static int asink_query_formats(AVFilterContext *ctx) · 10 unmodified lines
278272 if (!(layouts = avfilter_make_format64_list(buf->channel_layouts)))
279273 return AVERROR(ENOMEM);
280274 ff_set_common_channel_layouts(ctx, layouts);
281−
282− if (!(formats = avfilter_make_format_list(buf->packing_fmts)))
283− return AVERROR(ENOMEM);
284− avfilter_set_common_packing_formats(ctx, formats);
285−
286275 ff_set_common_samplerates (ctx, ff_all_samplerates());
287276
288277 return 0;
libavfilter/src_buffer.c+3−14
@@ -55,7 +55,6 @@ typedef struct { · 54 unmodified lines
5555 int sample_rate;
5656 unsigned int sample_format;
5757 int64_t channel_layout;
58− int packing_format;
5958
6059 // Normalization filters
6160 AVFilterContext *aconvert;
@@ -91,7 +90,6 @@ static int reconfigure_filter(BufferSourceContext *abuffer, AVFilterContext *fil · 29 unmodified lines
9190
9291 inlink->format = abuffer->sample_format;
9392 inlink->channel_layout = abuffer->channel_layout;
94− inlink->planar = abuffer->packing_format;
9593 inlink->sample_rate = abuffer->sample_rate;
9694
9795 filt_ctx->filter->uninit(filt_ctx);
@@ -239,14 +237,12 @@ static int check_format_change_audio(AVFilterContext *ctx, · 141 unmodified lines
239237
240238 link = ctx->outputs[0];
241239 if (samplesref->format != link->format ||
242− samplesref->audio->channel_layout != link->channel_layout ||
243− samplesref->audio->planar != link->planar) {
240+ samplesref->audio->channel_layout != link->channel_layout) {
244241
245242 if (!logged) log_input_change(ctx, link, samplesref);
246243
247244 abuffer->sample_format = samplesref->format;
248245 abuffer->channel_layout = samplesref->audio->channel_layout;
249− abuffer->packing_format = samplesref->audio->planar;
250246
251247 if (!abuffer->aconvert) {
252248 ret = insert_filter(abuffer, link, &abuffer->aconvert, "aconvert");
@@ -254,9 +250,7 @@ static int check_format_change_audio(AVFilterContext *ctx, · 1 unmodified line
254250 } else {
255251 link = abuffer->aconvert->outputs[0];
256252 if (samplesref->format == link->format &&
257− samplesref->audio->channel_layout == link->channel_layout &&
258− samplesref->audio->planar == link->planar
259− )
253+ samplesref->audio->channel_layout == link->channel_layout)
260254 remove_filter(&abuffer->aconvert);
261255 else
262256 if ((ret = reconfigure_filter(abuffer, abuffer->aconvert)) < 0)
@@ -456,7 +450,6 @@ static av_cold int init_audio(AVFilterContext *ctx, const char *args0, void *opa · 193 unmodified lines
456450 ADD_FORMAT(sample_rate);
457451 ADD_FORMAT(sample_format);
458452 ADD_FORMAT(channel_layout);
459− ADD_FORMAT(packing_format);
460453
461454 abuffer->fifo = av_fifo_alloc(FIFO_SIZE*sizeof(AVFilterBufferRef*));
462455 if (!abuffer->fifo) {
@@ -475,7 +468,7 @@ static av_cold int init_audio(AVFilterContext *ctx, const char *args0, void *opa · 12 unmodified lines
475468
476469 arg_fail:
477470 av_log(ctx, AV_LOG_ERROR, "Invalid arguments, must be of the form "
478− "sample_rate:sample_fmt:channel_layout:packing\n");
471+ "sample_rate:sample_fmt:channel_layout\n");
479472 av_freep(&args);
480473 return AVERROR(EINVAL);
481474 }
@@ -517,10 +510,6 @@ static int query_formats_audio(AVFilterContext *ctx) · 35 unmodified lines
517510 ff_add_channel_layout(&layouts, abuffer->channel_layout);
518511 ff_set_common_channel_layouts(ctx, layouts);
519512
520− formats = NULL;
521− avfilter_add_format(&formats, abuffer->packing_format);
522− avfilter_set_common_packing_formats(ctx, formats);
523−
524513 return 0;
525514 }
526515
libavfilter/src_movie.c+0−2
@@ -370,13 +370,11 @@ static int amovie_query_formats(AVFilterContext *ctx) · 369 unmodified lines
370370 AVCodecContext *c = movie->codec_ctx;
371371
372372 enum AVSampleFormat sample_fmts[] = { c->sample_fmt, -1 };
373− int packing_fmts[] = { AVFILTER_PACKED, -1 };
374373 int sample_rates[] = { c->sample_rate, -1 };
375374 int64_t chlayouts[] = { c->channel_layout ? c->channel_layout :
376375 av_get_default_channel_layout(c->channels), -1 };
377376
378377 avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts));
379− avfilter_set_common_packing_formats(ctx, avfilter_make_format_list(packing_fmts));
380378 ff_set_common_samplerates (ctx, avfilter_make_format_list(sample_rates));
381379 ff_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts));
382380
libavfilter/version.h+3−0
@@ -53,5 +53,8 @@ · 52 unmodified lines
5353 #ifndef FF_API_VSRC_BUFFER_ADD_FRAME
5454 #define FF_API_VSRC_BUFFER_ADD_FRAME (LIBAVFILTER_VERSION_MAJOR < 3)
5555 #endif
56+#ifndef FF_API_PACKING
57+#define FF_API_PACKING (LIBAVFILTER_VERSION_MAJOR < 3)
58+#endif
5659
5760 #endif // AVFILTER_VERSION_H
tools/lavfi-showfiltfmts.c+0−8
@@ -53,14 +53,6 @@ static void print_formats(AVFilterContext *filter_ctx) · 52 unmodified lines
5353 fmts->formats[j]); \
5454 printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \
5555 i, filter_ctx->filter->inout##puts[i].name, buf); \
56− } \
57− \
58− fmts = filter_ctx->inout##puts[i]->outin##_packing; \
59− for (j = 0; j < fmts->format_count; j++) { \
60− printf(#INOUT "PUT[%d] %s: packing:%s\n", \
61− i, filter_ctx->filter->inout##puts[i].name, \
62− fmts->formats[j] == AVFILTER_PACKED ? \
63− "packed" : "planar"); \
6456 } \
6557 } \
6658 } \

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