[FFmpeg-devel] [PATCH] lavfi: drop planar/packed negotiation support

Stefano Sabatini stefasab at gmail.com
Tue May 15 20:23:19 CEST 2012


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 the harm should not be
too much painful as we marked the audio filtering API as unstable.
---
 doc/filters.texi               |   13 +++----------
 libavfilter/af_aconvert.c      |   14 +++-----------
 libavfilter/af_aformat.c       |    7 ++-----
 libavfilter/af_amerge.c        |    6 +-----
 libavfilter/af_ashowinfo.c     |    5 ++---
 libavfilter/af_astreamsync.c   |    3 ---
 libavfilter/af_earwax.c        |    4 ----
 libavfilter/af_pan.c           |    2 --
 libavfilter/af_silencedetect.c |    6 ------
 libavfilter/af_volume.c        |    6 ------
 libavfilter/asrc_aevalsrc.c    |    2 --
 libavfilter/audio.c            |    4 ++--
 libavfilter/audio.h            |   17 +++++++++++++++++
 libavfilter/avfilter.c         |    8 ++------
 libavfilter/avfilter.h         |   12 ++++++++++++
 libavfilter/avfiltergraph.c    |   24 ++++++------------------
 libavfilter/buffersink.h       |    2 ++
 libavfilter/defaults.c         |    4 ++--
 libavfilter/formats.c          |   19 ++-----------------
 libavfilter/graphdump.c        |    5 ++---
 libavfilter/internal.h         |   10 ----------
 libavfilter/sink_buffer.c      |   12 +-----------
 libavfilter/src_buffer.c       |   17 +++--------------
 libavfilter/src_movie.c        |    2 --
 libavfilter/version.h          |    3 +++
 25 files changed, 65 insertions(+), 142 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 2af7b37..b1bf92e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -146,7 +146,7 @@ Convert the input audio to one of the specified formats. The framework will
 negotiate the most appropriate format to minimize conversions.
 
 The filter accepts three lists of formats, separated by ":", in the form:
-"@var{sample_formats}:@var{channel_layouts}:@var{packing_formats}".
+"@var{sample_formats}:@var{channel_layouts}".
 
 Elements in each list are separated by "," which has to be escaped in the
 filtergraph specification.
@@ -184,7 +184,7 @@ On the other hand, if both input are in stereo, the output channels will be
 in the default order: a1, a2, b1, b2, and the channel layout will be
 arbitrarily set to 4.0, which may or may not be the expected value.
 
-Both inputs must have the same sample rate, format and packing.
+Both inputs must have the same sample rate, and format.
 
 If inputs do not have the same duration, the output will stop with the
 shortest.
@@ -267,9 +267,6 @@ number of samples (per each channel) contained in the filtered frame
 @item rate
 sample rate for the audio frame
 
- at item planar
-if the packing format is planar, 0 if packed
-
 @item checksum
 Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
 
@@ -521,7 +518,7 @@ This source is mainly intended for a programmatic use, in particular
 through the interface defined in @file{libavfilter/asrc_abuffer.h}.
 
 It accepts the following mandatory parameters:
- at var{sample_rate}:@var{sample_fmt}:@var{channel_layout}:@var{packing}
+ at var{sample_rate}:@var{sample_fmt}:@var{channel_layout}
 
 @table @option
 
@@ -539,10 +536,6 @@ Either a channel layout name from channel_layout_map in
 @file{libavutil/audioconvert.c} or its corresponding integer representation
 from the AV_CH_LAYOUT_* macros in @file{libavutil/audioconvert.h}
 
- at item packing
-Either "packed" or "planar", or their integer representation: 0 or 1
-respectively.
-
 @end table
 
 For example:
diff --git a/libavfilter/af_aconvert.c b/libavfilter/af_aconvert.c
index 9d420f8..235c01a 100644
--- a/libavfilter/af_aconvert.c
+++ b/libavfilter/af_aconvert.c
@@ -73,7 +73,6 @@ static int query_formats(AVFilterContext *ctx)
     AConvertContext *aconvert = ctx->priv;
     AVFilterLink *inlink  = ctx->inputs[0];
     AVFilterLink *outlink = ctx->outputs[0];
-    int out_packing = av_sample_fmt_is_planar(aconvert->out_sample_fmt);
 
     avfilter_formats_ref(avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO),
                          &inlink->out_formats);
@@ -95,12 +94,6 @@ static int query_formats(AVFilterContext *ctx)
         avfilter_formats_ref(avfilter_make_all_channel_layouts(),
                              &outlink->in_chlayouts);
 
-    avfilter_formats_ref(avfilter_make_all_packing_formats(),
-                         &inlink->out_packing);
-    formats = NULL;
-    avfilter_add_format(&formats, out_packing);
-    avfilter_formats_ref(formats, &outlink->in_packing);
-
     return 0;
 }
 
@@ -133,9 +126,9 @@ static int config_output(AVFilterLink *outlink)
     av_get_channel_layout_string(buf2, sizeof(buf2),
                                  -1, outlink->channel_layout);
     av_log(ctx, AV_LOG_INFO,
-           "fmt:%s cl:%s planar:%i -> fmt:%s cl:%s planar:%i\n",
-           av_get_sample_fmt_name(inlink ->format), buf1, inlink ->planar,
-           av_get_sample_fmt_name(outlink->format), buf2, outlink->planar);
+           "fmt:%s cl:%s -> fmt:%s cl:%s\n",
+           av_get_sample_fmt_name(inlink ->format), buf1,
+           av_get_sample_fmt_name(outlink->format), buf2);
 
     return 0;
 }
@@ -152,7 +145,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
 
     avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
     outsamplesref->audio->channel_layout = outlink->channel_layout;
-    outsamplesref->audio->planar         = outlink->planar;
 
     ff_filter_samples(outlink, outsamplesref);
     avfilter_unref_buffer(insamplesref);
diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index 0a5857e..6714197 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -30,7 +30,7 @@
 #include "internal.h"
 
 typedef struct {
-    AVFilterFormats *formats, *chlayouts, *packing;
+    AVFilterFormats *formats, *chlayouts;
 } AFormatContext;
 
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -67,13 +67,11 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
 
     ADD_FORMATS(avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO), sample_format, int, formats);
     ADD_FORMATS(avfilter_make_all_channel_layouts(), channel_layout, int64_t, chlayouts);
-    ADD_FORMATS(avfilter_make_all_packing_formats(), packing_format, int, packing);
-
     return 0;
 
 arg_fail:
     av_log(ctx, AV_LOG_ERROR, "Invalid arguments, they must be of the form "
-                              "sample_fmts:channel_layouts:packing_fmts\n");
+                              "sample_fmts:channel_layouts\n");
     av_freep(&fmts_str);
     return AVERROR(EINVAL);
 }
@@ -84,7 +82,6 @@ static int query_formats(AVFilterContext *ctx)
 
     avfilter_set_common_sample_formats (ctx, aformat->formats);
     avfilter_set_common_channel_layouts(ctx, aformat->chlayouts);
-    avfilter_set_common_packing_formats(ctx, aformat->packing);
     return 0;
 }
 
diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c
index faa64e1..2ddd7dd 100644
--- a/libavfilter/af_amerge.c
+++ b/libavfilter/af_amerge.c
@@ -54,7 +54,6 @@ static int query_formats(AVFilterContext *ctx)
 {
     AMergeContext *am = ctx->priv;
     int64_t inlayout[2], outlayout;
-    const int packing_fmts[] = { AVFILTER_PACKED, -1 };
     AVFilterFormats *formats;
     int i;
 
@@ -96,10 +95,8 @@ static int query_formats(AVFilterContext *ctx)
                 if ((inlayout[i] >> c) & 1)
                     *(route[i]++) = out_ch_number++;
     }
-    formats = avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO);
+    formats = avfilter_make_format_list(ff_packed_sample_fmts);
     avfilter_set_common_sample_formats(ctx, formats);
-    formats = avfilter_make_format_list(packing_fmts);
-    avfilter_set_common_packing_formats(ctx, formats);
     for (i = 0; i < 2; i++) {
         formats = NULL;
         avfilter_add_format(&formats, inlayout[i]);
@@ -221,7 +218,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
     avfilter_copy_buffer_ref_props(outbuf, *inbuf[0]);
     outbuf->audio->nb_samples     = nb_samples;
     outbuf->audio->channel_layout = outlink->channel_layout;
-    outbuf->audio->planar         = outlink->planar;
 
     while (nb_samples) {
         ns = nb_samples;
diff --git a/libavfilter/af_ashowinfo.c b/libavfilter/af_ashowinfo.c
index 11d85f0..d4198e9 100644
--- a/libavfilter/af_ashowinfo.c
+++ b/libavfilter/af_ashowinfo.c
@@ -50,7 +50,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
     int linesize =
         samplesref->audio->nb_samples *
         av_get_bytes_per_sample(samplesref->format);
-    if (!samplesref->audio->planar) /* packed layout */
+    if (!av_sample_fmt_is_planar(samplesref->format))
         linesize *= av_get_channel_layout_nb_channels(samplesref->audio->channel_layout);
 
     for (plane = 0; samplesref->data[plane] && plane < 8; plane++) {
@@ -66,7 +66,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
 
     av_log(ctx, AV_LOG_INFO,
            "n:%d pts:%s pts_time:%s pos:%"PRId64" "
-           "fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d "
+           "fmt:%s chlayout:%s nb_samples:%d rate:%d "
            "checksum:%08X plane_checksum[%08X",
            showinfo->frame,
            av_ts2str(samplesref->pts), av_ts2timestr(samplesref->pts, &inlink->time_base),
@@ -75,7 +75,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
            chlayout_str,
            samplesref->audio->nb_samples,
            samplesref->audio->sample_rate,
-           samplesref->audio->planar,
            checksum,
            plane_checksum[0]);
 
diff --git a/libavfilter/af_astreamsync.c b/libavfilter/af_astreamsync.c
index faa3b7c..1bbe38b 100644
--- a/libavfilter/af_astreamsync.c
+++ b/libavfilter/af_astreamsync.c
@@ -86,9 +86,6 @@ static int query_formats(AVFilterContext *ctx)
         formats = ctx->inputs[i]->in_formats;
         avfilter_formats_ref(formats, &ctx->inputs[i]->out_formats);
         avfilter_formats_ref(formats, &ctx->outputs[i]->in_formats);
-        formats = ctx->inputs[i]->in_packing;
-        avfilter_formats_ref(formats, &ctx->inputs[i]->out_packing);
-        avfilter_formats_ref(formats, &ctx->outputs[i]->in_packing);
         formats = ctx->inputs[i]->in_chlayouts;
         avfilter_formats_ref(formats, &ctx->inputs[i]->out_chlayouts);
         avfilter_formats_ref(formats, &ctx->outputs[i]->in_chlayouts);
diff --git a/libavfilter/af_earwax.c b/libavfilter/af_earwax.c
index 6afed72..34f0157 100644
--- a/libavfilter/af_earwax.c
+++ b/libavfilter/af_earwax.c
@@ -82,10 +82,6 @@ static int query_formats(AVFilterContext *ctx)
     formats = NULL;
     avfilter_add_format(&formats, AV_CH_LAYOUT_STEREO);
     avfilter_set_common_channel_layouts(ctx, formats);
-    formats = NULL;
-    avfilter_add_format(&formats, AVFILTER_PACKED);
-    avfilter_set_common_packing_formats(ctx, formats);
-
     return 0;
 }
 
diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
index fd65aac..cfcaa57 100644
--- a/libavfilter/af_pan.c
+++ b/libavfilter/af_pan.c
@@ -217,7 +217,6 @@ static int query_formats(AVFilterContext *ctx)
     pan->pure_gains = are_gains_pure(pan);
     /* libswr supports any sample and packing formats */
     avfilter_set_common_sample_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO));
-    avfilter_set_common_packing_formats(ctx, avfilter_make_all_packing_formats());
 
     // inlink supports any channel layout
     formats = avfilter_make_all_channel_layouts();
@@ -347,7 +346,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
     swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n);
     avfilter_copy_buffer_ref_props(outsamples, insamples);
     outsamples->audio->channel_layout = outlink->channel_layout;
-    outsamples->audio->planar         = outlink->planar;
 
     ff_filter_samples(outlink, outsamples);
     avfilter_unref_buffer(insamples);
diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c
index 093ca2b..7fdfc36 100644
--- a/libavfilter/af_silencedetect.c
+++ b/libavfilter/af_silencedetect.c
@@ -134,7 +134,6 @@ static int query_formats(AVFilterContext *ctx)
         AV_SAMPLE_FMT_DBL,
         AV_SAMPLE_FMT_NONE
     };
-    int packing_fmts[] = { AVFILTER_PACKED, -1 };
 
     formats = avfilter_make_all_channel_layouts();
     if (!formats)
@@ -146,11 +145,6 @@ static int query_formats(AVFilterContext *ctx)
         return AVERROR(ENOMEM);
     avfilter_set_common_sample_formats(ctx, formats);
 
-    formats = avfilter_make_format_list(packing_fmts);
-    if (!formats)
-        return AVERROR(ENOMEM);
-    avfilter_set_common_packing_formats(ctx, formats);
-
     return 0;
 }
 
diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 8e2e37e..42ea997 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -89,7 +89,6 @@ static int query_formats(AVFilterContext *ctx)
         AV_SAMPLE_FMT_DBL,
         AV_SAMPLE_FMT_NONE
     };
-    int packing_fmts[] = { AVFILTER_PACKED, -1 };
 
     formats = avfilter_make_all_channel_layouts();
     if (!formats)
@@ -101,11 +100,6 @@ static int query_formats(AVFilterContext *ctx)
         return AVERROR(ENOMEM);
     avfilter_set_common_sample_formats(ctx, formats);
 
-    formats = avfilter_make_format_list(packing_fmts);
-    if (!formats)
-        return AVERROR(ENOMEM);
-    avfilter_set_common_packing_formats(ctx, formats);
-
     return 0;
 }
 
diff --git a/libavfilter/asrc_aevalsrc.c b/libavfilter/asrc_aevalsrc.c
index 4abcbc4..9ded587 100644
--- a/libavfilter/asrc_aevalsrc.c
+++ b/libavfilter/asrc_aevalsrc.c
@@ -187,11 +187,9 @@ static int query_formats(AVFilterContext *ctx)
     EvalContext *eval = ctx->priv;
     enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE };
     int64_t chlayouts[] = { eval->chlayout, -1 };
-    int packing_fmts[] = { AVFILTER_PLANAR, -1 };
 
     avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts));
     avfilter_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts));
-    avfilter_set_common_packing_formats(ctx, avfilter_make_format_list(packing_fmts));
 
     return 0;
 }
diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index a3ab0f6..f8b11fc 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -100,9 +100,9 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
 
     samplesref->audio->nb_samples     = nb_samples;
     samplesref->audio->channel_layout = channel_layout;
-    samplesref->audio->planar         = av_sample_fmt_is_planar(sample_fmt);
 
-    planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1;
+    planes = av_sample_fmt_is_planar(sample_fmt) ?
+        av_get_channel_layout_nb_channels(channel_layout) : 1;
 
     /* make sure the buffer gets read permission or it's useless for output */
     samplesref->perms = perms | AV_PERM_READ;
diff --git a/libavfilter/audio.h b/libavfilter/audio.h
index 051efb2..b63f85f 100644
--- a/libavfilter/audio.h
+++ b/libavfilter/audio.h
@@ -24,6 +24,23 @@
 
 #include "avfilter.h"
 
+static const enum AVSampleFormat ff_packed_sample_fmts[] = {
+    AV_SAMPLE_FMT_U8,
+    AV_SAMPLE_FMT_S16,
+    AV_SAMPLE_FMT_S32,
+    AV_SAMPLE_FMT_FLT,
+    AV_SAMPLE_FMT_DBL,
+    AV_SAMPLE_FMT_NONE
+};
+
+static const enum AVSampleFormat ff_planar_sample_fmts[] = {
+    AV_SAMPLE_FMT_U8P,
+    AV_SAMPLE_FMT_S16P,
+    AV_SAMPLE_FMT_S32P,
+    AV_SAMPLE_FMT_FLTP,
+    AV_SAMPLE_FMT_DBLP,
+    AV_SAMPLE_FMT_NONE
+};
 
 /** default handler for get_audio_buffer() for audio inputs */
 AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms,
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 4354f8c..90d8310 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -275,9 +275,6 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
     if (link->out_chlayouts)
         avfilter_formats_changeref(&link->out_chlayouts,
                                    &filt->outputs[filt_dstpad_idx]->out_chlayouts);
-    if (link->out_packing)
-        avfilter_formats_changeref(&link->out_packing,
-                                   &filt->outputs[filt_dstpad_idx]->out_packing);
 
     return 0;
 }
@@ -401,11 +398,10 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end)
                 av_get_picture_type_char(ref->video->pict_type));
     }
     if (ref->audio) {
-        av_dlog(ctx, " cl:%"PRId64"d n:%d r:%d p:%d",
+        av_dlog(ctx, " cl:%"PRId64"d n:%d r:%d",
                 ref->audio->channel_layout,
                 ref->audio->nb_samples,
-                ref->audio->sample_rate,
-                ref->audio->planar);
+                ref->audio->sample_rate);
     }
 
     av_dlog(ctx, "]%s", end ? "\n" : "");
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 06146cf..06a555e 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -121,7 +121,9 @@ typedef struct AVFilterBufferRefAudioProps {
     uint64_t channel_layout;    ///< channel layout of audio buffer
     int nb_samples;             ///< number of audio samples per channel
     int sample_rate;            ///< audio buffer sample rate
+#if FF_API_PACKING
     int planar;                 ///< audio buffer - planar or packed
+#endif
 } AVFilterBufferRefAudioProps;
 
 /**
@@ -309,10 +311,12 @@ extern const int64_t avfilter_all_channel_layouts[];
  */
 AVFilterFormats *avfilter_make_all_channel_layouts(void);
 
+#if FF_API_PACKING
 /**
  * Return a list of all audio packing formats.
  */
 AVFilterFormats *avfilter_make_all_packing_formats(void);
+#endif
 
 /**
  * Return a format list which contains the intersection of the formats of
@@ -524,7 +528,9 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
 void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats);
 void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats);
 void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats);
+#if FF_API_PACKING
 void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats);
+#endif
 
 /** Default handler for query_formats() */
 int avfilter_default_query_formats(AVFilterContext *ctx);
@@ -621,10 +627,12 @@ struct AVFilterContext {
     struct AVFilterCommand *command_queue;
 };
 
+#if FF_API_PACKING
 enum AVFilterPacking {
     AVFILTER_PACKED = 0,
     AVFILTER_PLANAR,
 };
+#endif
 
 /**
  * A link between two filters. This contains pointers to the source and
@@ -660,7 +668,9 @@ struct AVFilterLink {
 #else
     int sample_rate;            ///< samples per second
 #endif
+#if FF_API_PACKING
     int planar;                 ///< agreed upon packing mode of audio buffers. true if planar.
+#endif
 
     int format;                 ///< agreed upon media format
 
@@ -676,8 +686,10 @@ struct AVFilterLink {
 
     AVFilterFormats *in_chlayouts;
     AVFilterFormats *out_chlayouts;
+#if FF_API_PACKING
     AVFilterFormats *in_packing;
     AVFilterFormats *out_packing;
+#endif
 
     /**
      * The buffer reference currently being sent across the link by the source
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 3bc10f9..a1e017f 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -197,15 +197,10 @@ static int insert_conv_filter(AVFilterGraph *graph, AVFilterLink *link,
     }
 
     if (link->type == AVMEDIA_TYPE_AUDIO &&
-         (((link = filt_ctx-> inputs[0]) &&
-           (!avfilter_merge_formats(link->in_chlayouts, link->out_chlayouts) ||
-            !avfilter_merge_formats(link->in_packing,   link->out_packing))) ||
-         ((link = filt_ctx->outputs[0]) &&
-           (!avfilter_merge_formats(link->in_chlayouts, link->out_chlayouts) ||
-            !avfilter_merge_formats(link->in_packing,   link->out_packing))))
-       ) {
+        (((link = filt_ctx-> inputs[0]) && !avfilter_merge_formats(link->in_chlayouts, link->out_chlayouts)) ||
+         ((link = filt_ctx->outputs[0]) && !avfilter_merge_formats(link->in_chlayouts, link->out_chlayouts)))) {
         av_log(NULL, AV_LOG_ERROR,
-               "Impossible to convert between the channel layouts/packing formats supported by the filter "
+               "Impossible to convert between the channel layouts formats supported by the filter "
                "'%s' and the filter '%s'\n", link->src->name, link->dst->name);
         return AVERROR(EINVAL);
     }
@@ -217,7 +212,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
 {
     int i, j, ret;
     char filt_args[128];
-    AVFilterFormats *formats, *chlayouts, *packing;
+    AVFilterFormats *formats, *chlayouts;
 
     /* ask all the sub-filters for their supported media formats */
     for (i = 0; i < graph->filter_count; i++) {
@@ -248,8 +243,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
                     return ret;
             }
             else if (link->type == AVMEDIA_TYPE_AUDIO) {
-                if (!link->in_chlayouts || !link->out_chlayouts ||
-                    !link->in_packing   || !link->out_packing)
+                if (!link->in_chlayouts || !link->out_chlayouts)
                     return AVERROR(EINVAL);
 
                 /* Merge all three list before checking: that way, in all
@@ -257,8 +251,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
                  * whenever possible. */
                 formats   = avfilter_merge_formats(link->in_formats,   link->out_formats);
                 chlayouts = avfilter_merge_formats(link->in_chlayouts, link->out_chlayouts);
-                packing   = avfilter_merge_formats(link->in_packing,   link->out_packing);
-                if (!formats || !chlayouts || !packing)
+                if (!formats || !chlayouts)
                     if (ret = insert_conv_filter(graph, link, "aconvert", NULL))
                        return ret;
             }
@@ -296,11 +289,6 @@ static void pick_format(AVFilterLink *link, AVFilterLink *ref)
         link->channel_layout = link->in_chlayouts->formats[0];
         avfilter_formats_unref(&link->in_chlayouts);
         avfilter_formats_unref(&link->out_chlayouts);
-
-        link->in_packing->format_count = 1;
-        link->planar = link->in_packing->formats[0] == AVFILTER_PLANAR;
-        avfilter_formats_unref(&link->in_packing);
-        avfilter_formats_unref(&link->out_packing);
     }
 }
 
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 86a4b24..b096f2c 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -46,7 +46,9 @@ AVBufferSinkParams *av_buffersink_params_alloc(void);
 typedef struct {
     const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
     const int64_t *channel_layouts;         ///< list of allowed channel layouts, terminated by -1
+#if FF_API_PACKING
     const int *packing_fmts;                ///< list of allowed packing formats
+#endif
 } AVABufferSinkParams;
 
 /**
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index d2e0149..a88c004 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -174,20 +174,20 @@ void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *
                        offsetof(AVFilterLink, out_chlayouts));
 }
 
+#if FF_API_PACKING
 void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats)
 {
     set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO,
                        offsetof(AVFilterLink, in_packing),
                        offsetof(AVFilterLink, out_packing));
 }
+#endif
 
 int avfilter_default_query_formats(AVFilterContext *ctx)
 {
     avfilter_set_common_pixel_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_VIDEO));
     avfilter_set_common_sample_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO));
     avfilter_set_common_channel_layouts(ctx, avfilter_make_all_channel_layouts());
-    avfilter_set_common_packing_formats(ctx, avfilter_make_all_packing_formats());
-
     return 0;
 }
 
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 569178f..9303a78 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -204,6 +204,7 @@ AVFilterFormats *avfilter_make_all_channel_layouts(void)
     return avfilter_make_format64_list(avfilter_all_channel_layouts);
 }
 
+#if FF_API_PACKING
 AVFilterFormats *avfilter_make_all_packing_formats(void)
 {
     static const int packing[] = {
@@ -214,6 +215,7 @@ AVFilterFormats *avfilter_make_all_packing_formats(void)
 
     return avfilter_make_format_list(packing);
 }
+#endif
 
 void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
 {
@@ -323,23 +325,6 @@ int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx)
     return 0;
 }
 
-int ff_parse_packing_format(int *ret, const char *arg, void *log_ctx)
-{
-    char *tail;
-    int planar = strtol(arg, &tail, 10);
-    if (*tail) {
-        planar = !strcmp(arg, "packed") ? 0:
-                 !strcmp(arg, "planar") ? 1: -1;
-    }
-
-    if (planar != 0 && planar != 1) {
-        av_log(log_ctx, AV_LOG_ERROR, "Invalid packing format '%s'\n", arg);
-        return AVERROR(EINVAL);
-    }
-    *ret = planar;
-    return 0;
-}
-
 #ifdef TEST
 
 #undef printf
diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c
index bd2b278..28be29d 100644
--- a/libavfilter/graphdump.c
+++ b/libavfilter/graphdump.c
@@ -46,9 +46,8 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
             av_get_channel_layout_string(layout, sizeof(layout),
                                          -1, link->channel_layout);
             format = av_x_if_null(av_get_sample_fmt_name(link->format), "?");
-            av_bprintf(buf, "[%dHz %s:%s:%s]",
-                    (int)link->sample_rate, format, layout,
-                    link->planar ? "planar" : "packed");
+            av_bprintf(buf, "[%dHz %s:%s]",
+                       (int)link->sample_rate, format, layout);
             break;
 
         default:
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 09d6055..7c17597 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -131,16 +131,6 @@ int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx);
 int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx);
 
 /**
- * Parse a packing format or a corresponding integer representation.
- *
- * @param ret integer pointer to where the value should be written
- * @param arg string to parse
- * @param log_ctx log context
- * @return 0 in case of success, a negative AVERROR code on error
- */
-int ff_parse_packing_format(int *ret, const char *arg, void *log_ctx);
-
-/**
  * Pass video frame along and keep an internal reference for later use.
  */
 static inline void ff_null_start_frame_keep_ref(AVFilterLink *inlink,
diff --git a/libavfilter/sink_buffer.c b/libavfilter/sink_buffer.c
index b0cc519..64d1699 100644
--- a/libavfilter/sink_buffer.c
+++ b/libavfilter/sink_buffer.c
@@ -42,7 +42,6 @@ AVBufferSinkParams *av_buffersink_params_alloc(void)
 AVABufferSinkParams *av_abuffersink_params_alloc(void)
 {
     static const int sample_fmts[] = { -1 };
-    static const int packing_fmts[] = { -1 };
     static const int64_t channel_layouts[] = { -1 };
     AVABufferSinkParams *params = av_malloc(sizeof(AVABufferSinkParams));
 
@@ -51,7 +50,6 @@ AVABufferSinkParams *av_abuffersink_params_alloc(void)
 
     params->sample_fmts = sample_fmts;
     params->channel_layouts = channel_layouts;
-    params->packing_fmts = packing_fmts;
     return params;
 }
 
@@ -64,7 +62,6 @@ typedef struct {
     /* only used for audio */
     enum AVSampleFormat *sample_fmts;       ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
     int64_t *channel_layouts;               ///< list of accepted channel layouts, terminated by -1
-    int *packing_fmts;                      ///< list of accepted packing formats, terminated by -1
 } BufferSinkContext;
 
 #define FIFO_INIT_SIZE 8
@@ -244,11 +241,9 @@ static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaq
 
     buf->sample_fmts     = ff_copy_int_list  (params->sample_fmts);
     buf->channel_layouts = ff_copy_int64_list(params->channel_layouts);
-    buf->packing_fmts    = ff_copy_int_list  (params->packing_fmts);
-    if (!buf->sample_fmts || !buf->channel_layouts || !buf->sample_fmts) {
+    if (!buf->sample_fmts || !buf->channel_layouts) {
         av_freep(&buf->sample_fmts);
         av_freep(&buf->channel_layouts);
-        av_freep(&buf->packing_fmts);
         return AVERROR(ENOMEM);
     }
 
@@ -261,7 +256,6 @@ static av_cold void asink_uninit(AVFilterContext *ctx)
 
     av_freep(&buf->sample_fmts);
     av_freep(&buf->channel_layouts);
-    av_freep(&buf->packing_fmts);
     return common_uninit(ctx);
 }
 
@@ -278,10 +272,6 @@ static int asink_query_formats(AVFilterContext *ctx)
         return AVERROR(ENOMEM);
     avfilter_set_common_channel_layouts(ctx, formats);
 
-    if (!(formats = avfilter_make_format_list(buf->packing_fmts)))
-        return AVERROR(ENOMEM);
-    avfilter_set_common_packing_formats(ctx, formats);
-
     return 0;
 }
 
diff --git a/libavfilter/src_buffer.c b/libavfilter/src_buffer.c
index f8d572d..fd0e8fd 100644
--- a/libavfilter/src_buffer.c
+++ b/libavfilter/src_buffer.c
@@ -55,7 +55,6 @@ typedef struct {
     int sample_rate;
     unsigned int sample_format;
     int64_t channel_layout;
-    int packing_format;
 
     // Normalization filters
     AVFilterContext *aconvert;
@@ -91,7 +90,6 @@ static int reconfigure_filter(BufferSourceContext *abuffer, AVFilterContext *fil
 
     inlink->format         = abuffer->sample_format;
     inlink->channel_layout = abuffer->channel_layout;
-    inlink->planar         = abuffer->packing_format;
     inlink->sample_rate    = abuffer->sample_rate;
 
     filt_ctx->filter->uninit(filt_ctx);
@@ -239,14 +237,12 @@ static int check_format_change_audio(AVFilterContext *ctx,
 
     link = ctx->outputs[0];
     if (samplesref->format                != link->format         ||
-        samplesref->audio->channel_layout != link->channel_layout ||
-        samplesref->audio->planar         != link->planar) {
+        samplesref->audio->channel_layout != link->channel_layout) {
 
         if (!logged) log_input_change(ctx, link, samplesref);
 
         abuffer->sample_format  = samplesref->format;
         abuffer->channel_layout = samplesref->audio->channel_layout;
-        abuffer->packing_format = samplesref->audio->planar;
 
         if (!abuffer->aconvert) {
             ret = insert_filter(abuffer, link, &abuffer->aconvert, "aconvert");
@@ -254,9 +250,7 @@ static int check_format_change_audio(AVFilterContext *ctx,
         } else {
             link = abuffer->aconvert->outputs[0];
             if (samplesref->format                == link->format         &&
-                samplesref->audio->channel_layout == link->channel_layout &&
-                samplesref->audio->planar         == link->planar
-               )
+                samplesref->audio->channel_layout == link->channel_layout)
                 remove_filter(&abuffer->aconvert);
             else
                 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
     ADD_FORMAT(sample_rate);
     ADD_FORMAT(sample_format);
     ADD_FORMAT(channel_layout);
-    ADD_FORMAT(packing_format);
 
     abuffer->fifo = av_fifo_alloc(FIFO_SIZE*sizeof(AVFilterBufferRef*));
     if (!abuffer->fifo) {
@@ -475,7 +468,7 @@ static av_cold int init_audio(AVFilterContext *ctx, const char *args0, void *opa
 
 arg_fail:
     av_log(ctx, AV_LOG_ERROR, "Invalid arguments, must be of the form "
-                              "sample_rate:sample_fmt:channel_layout:packing\n");
+                              "sample_rate:sample_fmt:channel_layout\n");
     av_freep(&args);
     return AVERROR(EINVAL);
 }
@@ -516,10 +509,6 @@ static int query_formats_audio(AVFilterContext *ctx)
     avfilter_add_format(&formats, abuffer->channel_layout);
     avfilter_set_common_channel_layouts(ctx, formats);
 
-    formats = NULL;
-    avfilter_add_format(&formats, abuffer->packing_format);
-    avfilter_set_common_packing_formats(ctx, formats);
-
     return 0;
 }
 
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index a00d30d..20416a6 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -369,12 +369,10 @@ static int amovie_query_formats(AVFilterContext *ctx)
     AVCodecContext *c = movie->codec_ctx;
 
     enum AVSampleFormat sample_fmts[] = { c->sample_fmt, -1 };
-    int packing_fmts[] = { AVFILTER_PACKED, -1 };
     int64_t chlayouts[] = { c->channel_layout ? c->channel_layout :
                             av_get_default_channel_layout(c->channels), -1 };
 
     avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts));
-    avfilter_set_common_packing_formats(ctx, avfilter_make_format_list(packing_fmts));
     avfilter_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts));
 
     return 0;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 0531804..0cf6929 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -50,5 +50,8 @@
 #ifndef FF_API_SAMPLERATE64
 #define FF_API_SAMPLERATE64             (LIBAVFILTER_VERSION_MAJOR < 3)
 #endif
+#ifndef FF_API_PACKING
+#define FF_API_PACKING                  (LIBAVFILTER_VERSION_MAJOR < 3)
+#endif
 
 #endif // AVFILTER_VERSION_H
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list