From 4d4098da009c8340997b8d1abedbf2062e4aa991 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 12 May 2012 17:38:47 +0200 Subject: [PATCH] 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. --- doc/examples/filtering_audio.c | 4 +--- doc/filter_design.txt | 3 ++- doc/filters.texi | 25 +++++++++---------------- libavdevice/lavfi.c | 2 -- libavfilter/af_aconvert.c | 16 ++++------------ libavfilter/af_amerge.c | 6 +----- libavfilter/af_ashowinfo.c | 5 ++--- libavfilter/af_astreamsync.c | 3 --- libavfilter/af_earwax.c | 3 --- 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 | 3 --- libavfilter/avfilter.h | 12 ++++++++++++ libavfilter/avfiltergraph.c | 16 ++++++---------- libavfilter/buffersink.h | 2 ++ libavfilter/defaults.c | 2 ++ libavfilter/formats.c | 19 ++----------------- libavfilter/graphdump.c | 5 ++--- libavfilter/internal.h | 10 ---------- libavfilter/sink_buffer.c | 13 +------------ libavfilter/src_buffer.c | 17 +++-------------- libavfilter/src_movie.c | 2 -- libavfilter/version.h | 3 +++ tools/lavfi-showfiltfmts.c | 8 -------- 28 files changed, 71 insertions(+), 145 deletions(-) diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c index e8e6259635..2207b458fe 100644 --- a/doc/examples/filtering_audio.c +++ b/doc/examples/filtering_audio.c @@ -88,7 +88,6 @@ static int init_filters(const char *filters_descr) AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 }; - const int packing_fmts[] = { AVFILTER_PACKED, -1 }; const int64_t *chlayouts = avfilter_all_channel_layouts; AVABufferSinkParams *abuffersink_params; const AVFilterLink *outlink; @@ -98,7 +97,7 @@ static int init_filters(const char *filters_descr) /* buffer audio source: the decoded frames from the decoder will be inserted here. */ if (!dec_ctx->channel_layout) dec_ctx->channel_layout = av_get_default_channel_layout(dec_ctx->channels); - snprintf(args, sizeof(args), "%d:%d:0x%"PRIx64":packed", + snprintf(args, sizeof(args), "%d:%d:0x%"PRIx64, dec_ctx->sample_rate, dec_ctx->sample_fmt, dec_ctx->channel_layout); ret = avfilter_graph_create_filter(&buffersrc_ctx, abuffersrc, "in", args, NULL, filter_graph); @@ -111,7 +110,6 @@ static int init_filters(const char *filters_descr) abuffersink_params = av_abuffersink_params_alloc(); abuffersink_params->sample_fmts = sample_fmts; abuffersink_params->channel_layouts = chlayouts; - abuffersink_params->packing_fmts = packing_fmts; ret = avfilter_graph_create_filter(&buffersink_ctx, abuffersink, "out", NULL, abuffersink_params, filter_graph); av_free(abuffersink_params); diff --git a/doc/filter_design.txt b/doc/filter_design.txt index 2b23054a81..4157fd1959 100644 --- a/doc/filter_design.txt +++ b/doc/filter_design.txt @@ -15,7 +15,8 @@ Format negotiation the list supported formats. For video links, that means pixel format. For audio links, that means - channel layout, sample format and sample packing. + channel layout, and sample format (the sample packing is implied by the + sample format). The lists are not just lists, they are references to shared objects. When the negotiation mechanism computes the intersection of the formats diff --git a/doc/filters.texi b/doc/filters.texi index ba8c9f46fb..bdb9fe23f9 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. @@ -156,9 +156,9 @@ supported formats. Some examples follow: @example -aformat=u8\\,s16:mono:packed +aformat=u8\\,s16:mono -aformat=s16:mono\\,stereo:all +aformat=s16:mono\\,stereo @end example @section amerge @@ -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. @@ -293,9 +293,6 @@ number of samples (per each channel) contained in the filtered frame @item rate sample rate for the audio frame -@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 @@ -566,7 +563,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: -@var{sample_rate}:@var{sample_fmt}:@var{channel_layout}:@var{packing} +@var{sample_rate}:@var{sample_fmt}:@var{channel_layout} @table @option @@ -584,23 +581,19 @@ 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} -@item packing -Either "packed" or "planar", or their integer representation: 0 or 1 -respectively. - @end table For example: @example -abuffer=44100:s16:stereo:planar +abuffer=44100:s16p:stereo @end example will instruct the source to accept planar 16bit signed stereo at 44100Hz. -Since the sample format with name "s16" corresponds to the number -1 and the "stereo" channel layout corresponds to the value 0x3, this is +Since the sample format with name "s16p" corresponds to the number +6 and the "stereo" channel layout corresponds to the value 0x3, this is equivalent to: @example -abuffer=44100:1:0x3:1 +abuffer=44100:6:0x3 @end example @section aevalsrc diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 0a6eb913dd..bdc5f58077 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -211,11 +211,9 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL, -1 }; - const int packing_fmts[] = { AVFILTER_PACKED, -1 }; const int64_t *chlayouts = avfilter_all_channel_layouts; AVABufferSinkParams *abuffersink_params = av_abuffersink_params_alloc(); abuffersink_params->sample_fmts = sample_fmts; - abuffersink_params->packing_fmts = packing_fmts; abuffersink_params->channel_layouts = chlayouts; ret = avfilter_graph_create_filter(&sink, abuffersink, diff --git a/libavfilter/af_aconvert.c b/libavfilter/af_aconvert.c index 2b3a330e3b..9e2785641d 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); AVFilterChannelLayouts *layouts; avfilter_formats_ref(avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO), @@ -96,12 +95,6 @@ static int query_formats(AVFilterContext *ctx) ff_channel_layouts_ref(ff_all_channel_layouts(), &outlink->in_channel_layouts); - 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; } @@ -134,9 +127,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; } @@ -153,7 +146,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); @@ -161,7 +153,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref AVFilter avfilter_af_aconvert = { .name = "aconvert", - .description = NULL_IF_CONFIG_SMALL("Convert the input audio to sample_fmt:channel_layout:packed_fmt."), + .description = NULL_IF_CONFIG_SMALL("Convert the input audio to sample_fmt:channel_layout."), .priv_size = sizeof(AConvertContext), .init = init, .uninit = uninit, diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index fcc1089d6f..18b3046b26 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; AVFilterChannelLayouts *layouts; int i; @@ -97,10 +96,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++) { layouts = NULL; ff_add_channel_layout(&layouts, inlayout[i]); @@ -222,7 +219,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 11d85f09c7..d4198e9a9f 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 9f040238d9..c591293a46 100644 --- a/libavfilter/af_astreamsync.c +++ b/libavfilter/af_astreamsync.c @@ -87,9 +87,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); layouts = ctx->inputs[i]->in_channel_layouts; ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts); ff_channel_layouts_ref(layouts, &ctx->outputs[i]->in_channel_layouts); diff --git a/libavfilter/af_earwax.c b/libavfilter/af_earwax.c index 2ab248f390..d4884f0624 100644 --- a/libavfilter/af_earwax.c +++ b/libavfilter/af_earwax.c @@ -86,9 +86,6 @@ static int query_formats(AVFilterContext *ctx) avfilter_set_common_sample_formats(ctx, formats); ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); ff_set_common_channel_layouts(ctx, layout); - formats = NULL; - avfilter_add_format(&formats, AVFILTER_PACKED); - avfilter_set_common_packing_formats(ctx, formats); ff_set_common_samplerates(ctx, avfilter_make_format_list(sample_rates)); return 0; diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c index 3100a14881..49f8677b90 100644 --- a/libavfilter/af_pan.c +++ b/libavfilter/af_pan.c @@ -218,7 +218,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 layouts = ff_all_channel_layouts(); @@ -348,7 +347,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 4f5d8e0dd4..76001ce1d9 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -136,7 +136,6 @@ static int query_formats(AVFilterContext *ctx) AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE }; - int packing_fmts[] = { AVFILTER_PACKED, -1 }; layouts = ff_all_channel_layouts(); if (!layouts) @@ -148,11 +147,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); - formats = ff_all_samplerates(); if (!formats) return AVERROR(ENOMEM); diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c index 50f3cbd002..7c51884195 100644 --- a/libavfilter/af_volume.c +++ b/libavfilter/af_volume.c @@ -91,7 +91,6 @@ static int query_formats(AVFilterContext *ctx) AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE }; - int packing_fmts[] = { AVFILTER_PACKED, -1 }; layouts = ff_all_channel_layouts(); if (!layouts) @@ -103,11 +102,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); - formats = ff_all_samplerates(); if (!formats) return AVERROR(ENOMEM); diff --git a/libavfilter/asrc_aevalsrc.c b/libavfilter/asrc_aevalsrc.c index 94197b2fd8..2078d7f5e2 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)); ff_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 a3ab0f672f..f8b11fc9cb 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 051efb2024..b63f85f45c 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 9704dc0a96..c6a8594514 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -148,9 +148,6 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, if (link->out_channel_layouts) ff_channel_layouts_changeref(&link->out_channel_layouts, &filt->outputs[filt_dstpad_idx]->out_channel_layouts); - if (link->out_packing) - avfilter_formats_changeref(&link->out_packing, - &filt->outputs[filt_dstpad_idx]->out_packing); if (link->out_samplerates) avfilter_formats_changeref(&link->out_samplerates, &filt->outputs[filt_dstpad_idx]->out_samplerates); diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index c76c637e8d..124f3e67a5 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; /** @@ -303,10 +305,12 @@ AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type); */ extern const int64_t avfilter_all_channel_layouts[]; +#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 @@ -519,7 +523,9 @@ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) 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); @@ -616,10 +622,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 @@ -655,7 +663,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 @@ -669,8 +679,10 @@ struct AVFilterLink { AVFilterFormats *in_formats; AVFilterFormats *out_formats; +#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 987b024b57..2286781047 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -200,14 +200,12 @@ static int insert_conv_filter(AVFilterGraph *graph, AVFilterLink *link, if (link->type == AVMEDIA_TYPE_AUDIO && (((link = filt_ctx-> inputs[0]) && - (!ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts) || - !avfilter_merge_formats(link->in_packing, link->out_packing))) || + !ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts)) || ((link = filt_ctx->outputs[0]) && - (!ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts) || - !avfilter_merge_formats(link->in_packing, link->out_packing)))) + !ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts))) ) { 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); } @@ -219,7 +217,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) { int i, j, ret; char filt_args[128]; - AVFilterFormats *formats, *packing; + AVFilterFormats *formats; AVFilterChannelLayouts *chlayouts; AVFilterFormats *samplerates; int scaler_count = 0, resampler_count = 0; @@ -254,8 +252,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) return ret; } else if (link->type == AVMEDIA_TYPE_AUDIO) { - if (!link->in_channel_layouts || !link->out_channel_layouts || - !link->in_packing || !link->out_packing) + if (!link->in_channel_layouts || !link->out_channel_layouts) return AVERROR(EINVAL); /* Merge all three list before checking: that way, in all @@ -264,9 +261,8 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) formats = avfilter_merge_formats(link->in_formats, link->out_formats); chlayouts = ff_merge_channel_layouts(link->in_channel_layouts , link->out_channel_layouts); samplerates = ff_merge_samplerates (link->in_samplerates, link->out_samplerates); - packing = avfilter_merge_formats(link->in_packing, link->out_packing); - if (!formats || !chlayouts || !packing || !samplerates) + if (!formats || !chlayouts || !samplerates) if (ret = insert_conv_filter(graph, link, "aconvert", NULL)) return ret; #else diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h index 2ee5294b26..714fa0471e 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 31dc18d9f7..c25c037c2a 100644 --- a/libavfilter/defaults.c +++ b/libavfilter/defaults.c @@ -70,9 +70,11 @@ void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats * offsetof(AVFilterLink, out_channel_layouts)); } +#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 diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 41c6da92b7..3534d64ca7 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -289,6 +289,7 @@ const int64_t avfilter_all_channel_layouts[] = { // return avfilter_make_format64_list(avfilter_all_channel_layouts); // } +#if FF_API_PACKING AVFilterFormats *avfilter_make_all_packing_formats(void) { static const int packing[] = { @@ -299,6 +300,7 @@ AVFilterFormats *avfilter_make_all_packing_formats(void) return avfilter_make_format_list(packing); } +#endif AVFilterFormats *ff_all_samplerates(void) { @@ -518,23 +520,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 bd2b2788b1..28be29d567 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 034a6c9cab..f06151f90c 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. */ diff --git a/libavfilter/sink_buffer.c b/libavfilter/sink_buffer.c index ab7aa4f5a8..3eb66ca7d5 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,11 +272,6 @@ static int asink_query_formats(AVFilterContext *ctx) if (!(layouts = avfilter_make_format64_list(buf->channel_layouts))) return AVERROR(ENOMEM); ff_set_common_channel_layouts(ctx, layouts); - - if (!(formats = avfilter_make_format_list(buf->packing_fmts))) - return AVERROR(ENOMEM); - avfilter_set_common_packing_formats(ctx, formats); - ff_set_common_samplerates (ctx, ff_all_samplerates()); return 0; diff --git a/libavfilter/src_buffer.c b/libavfilter/src_buffer.c index cadc4ee2a4..6402b44dc9 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); } @@ -517,10 +510,6 @@ static int query_formats_audio(AVFilterContext *ctx) ff_add_channel_layout(&layouts, abuffer->channel_layout); ff_set_common_channel_layouts(ctx, layouts); - 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 30624559fc..21e4e3f122 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -370,13 +370,11 @@ 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 }; int sample_rates[] = { c->sample_rate, -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)); ff_set_common_samplerates (ctx, avfilter_make_format_list(sample_rates)); ff_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts)); diff --git a/libavfilter/version.h b/libavfilter/version.h index a8e4f893d4..a47cda238f 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -53,5 +53,8 @@ #ifndef FF_API_VSRC_BUFFER_ADD_FRAME #define FF_API_VSRC_BUFFER_ADD_FRAME (LIBAVFILTER_VERSION_MAJOR < 3) #endif +#ifndef FF_API_PACKING +#define FF_API_PACKING (LIBAVFILTER_VERSION_MAJOR < 3) +#endif #endif // AVFILTER_VERSION_H diff --git a/tools/lavfi-showfiltfmts.c b/tools/lavfi-showfiltfmts.c index b33ff1c36e..6d09cc122c 100644 --- a/tools/lavfi-showfiltfmts.c +++ b/tools/lavfi-showfiltfmts.c @@ -53,14 +53,6 @@ static void print_formats(AVFilterContext *filter_ctx) fmts->formats[j]); \ printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \ i, filter_ctx->filter->inout##puts[i].name, buf); \ - } \ - \ - fmts = filter_ctx->inout##puts[i]->outin##_packing; \ - for (j = 0; j < fmts->format_count; j++) { \ - printf(#INOUT "PUT[%d] %s: packing:%s\n", \ - i, filter_ctx->filter->inout##puts[i].name, \ - fmts->formats[j] == AVFILTER_PACKED ? \ - "packed" : "planar"); \ } \ } \ } \