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.tags/n0.11
| @@ -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); | |||
| @@ -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 | |||
| @@ -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 | |||
| @@ -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, | |||
| @@ -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, | |||
| @@ -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; | |||
| @@ -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]); | |||
| @@ -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); | |||
| @@ -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; | |||
| @@ -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); | |||
| @@ -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); | |||
| @@ -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); | |||
| @@ -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; | |||
| } | |||
| @@ -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; | |||
| @@ -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, | |||
| @@ -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); | |||
| @@ -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 | |||
| @@ -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 | |||
| @@ -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; | |||
| /** | |||
| @@ -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 | |||
| @@ -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 | |||
| @@ -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: | |||
| @@ -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. | |||
| */ | |||
| @@ -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; | |||
| @@ -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; | |||
| } | |||
| @@ -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)); | |||
| @@ -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 | |||
| @@ -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"); \ | |||
| } \ | |||
| } \ | |||
| } \ | |||