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.
Unified · Split
| @@ -88,7 +88,6 @@ static int init_filters(const char *filters_descr) · 87 unmodified lines | |||
| 88 | AVFilterInOut *outputs = avfilter_inout_alloc(); | 88 | AVFilterInOut *outputs = avfilter_inout_alloc(); |
| 89 | AVFilterInOut *inputs = avfilter_inout_alloc(); | 89 | AVFilterInOut *inputs = avfilter_inout_alloc(); |
| 90 | const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 }; | 90 | const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 }; |
| 91 | const int packing_fmts[] = { AVFILTER_PACKED, -1 }; | ||
| 92 | const int64_t *chlayouts = avfilter_all_channel_layouts; | 91 | const int64_t *chlayouts = avfilter_all_channel_layouts; |
| 93 | AVABufferSinkParams *abuffersink_params; | 92 | AVABufferSinkParams *abuffersink_params; |
| 94 | const AVFilterLink *outlink; | 93 | const AVFilterLink *outlink; |
| @@ -98,7 +97,7 @@ static int init_filters(const char *filters_descr) · 3 unmodified lines | |||
| 98 | /* buffer audio source: the decoded frames from the decoder will be inserted here. */ | 97 | /* buffer audio source: the decoded frames from the decoder will be inserted here. */ |
| 99 | if (!dec_ctx->channel_layout) | 98 | if (!dec_ctx->channel_layout) |
| 100 | dec_ctx->channel_layout = av_get_default_channel_layout(dec_ctx->channels); | 99 | dec_ctx->channel_layout = av_get_default_channel_layout(dec_ctx->channels); |
| 101 | snprintf(args, sizeof(args), "%d:%d:0x%"PRIx64":packed", | 100 | snprintf(args, sizeof(args), "%d:%d:0x%"PRIx64, |
| 102 | dec_ctx->sample_rate, dec_ctx->sample_fmt, dec_ctx->channel_layout); | 101 | dec_ctx->sample_rate, dec_ctx->sample_fmt, dec_ctx->channel_layout); |
| 103 | ret = avfilter_graph_create_filter(&buffersrc_ctx, abuffersrc, "in", | 102 | ret = avfilter_graph_create_filter(&buffersrc_ctx, abuffersrc, "in", |
| 104 | args, NULL, filter_graph); | 103 | args, NULL, filter_graph); |
| @@ -111,7 +110,6 @@ static int init_filters(const char *filters_descr) · 6 unmodified lines | |||
| 111 | abuffersink_params = av_abuffersink_params_alloc(); | 110 | abuffersink_params = av_abuffersink_params_alloc(); |
| 112 | abuffersink_params->sample_fmts = sample_fmts; | 111 | abuffersink_params->sample_fmts = sample_fmts; |
| 113 | abuffersink_params->channel_layouts = chlayouts; | 112 | abuffersink_params->channel_layouts = chlayouts; |
| 114 | abuffersink_params->packing_fmts = packing_fmts; | ||
| 115 | ret = avfilter_graph_create_filter(&buffersink_ctx, abuffersink, "out", | 113 | ret = avfilter_graph_create_filter(&buffersink_ctx, abuffersink, "out", |
| 116 | NULL, abuffersink_params, filter_graph); | 114 | NULL, abuffersink_params, filter_graph); |
| 117 | av_free(abuffersink_params); | 115 | av_free(abuffersink_params); |
| @@ -15,7 +15,8 @@ Format negotiation · 14 unmodified lines | |||
| 15 | the list supported formats. | 15 | the list supported formats. |
| 16 | 16 | ||
| 17 | For video links, that means pixel format. For audio links, that means | 17 | For video links, that means pixel format. For audio links, that means |
| 18 | channel layout, sample format and sample packing. | 18 | channel layout, and sample format (the sample packing is implied by the |
| 19 | sample format). | ||
| 19 | 20 | ||
| 20 | The lists are not just lists, they are references to shared objects. When | 21 | The lists are not just lists, they are references to shared objects. When |
| 21 | the negotiation mechanism computes the intersection of the formats | 22 | 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 · 145 unmodified lines | |||
| 146 | negotiate the most appropriate format to minimize conversions. | 146 | negotiate the most appropriate format to minimize conversions. |
| 147 | 147 | ||
| 148 | The filter accepts three lists of formats, separated by ":", in the form: | 148 | The filter accepts three lists of formats, separated by ":", in the form: |
| 149 | "@var{sample_formats}:@var{channel_layouts}:@var{packing_formats}". | 149 | "@var{sample_formats}:@var{channel_layouts}". |
| 150 | 150 | ||
| 151 | Elements in each list are separated by "," which has to be escaped in the | 151 | Elements in each list are separated by "," which has to be escaped in the |
| 152 | filtergraph specification. | 152 | filtergraph specification. |
| @@ -156,9 +156,9 @@ supported formats. · 3 unmodified lines | |||
| 156 | 156 | ||
| 157 | Some examples follow: | 157 | Some examples follow: |
| 158 | @example | 158 | @example |
| 159 | aformat=u8\\,s16:mono:packed | 159 | aformat=u8\\,s16:mono |
| 160 | 160 | ||
| 161 | aformat=s16:mono\\,stereo:all | 161 | aformat=s16:mono\\,stereo |
| 162 | @end example | 162 | @end example |
| 163 | 163 | ||
| 164 | @section amerge | 164 | @section amerge |
| @@ -184,7 +184,7 @@ On the other hand, if both input are in stereo, the output channels will be · 19 unmodified lines | |||
| 184 | in the default order: a1, a2, b1, b2, and the channel layout will be | 184 | in the default order: a1, a2, b1, b2, and the channel layout will be |
| 185 | arbitrarily set to 4.0, which may or may not be the expected value. | 185 | arbitrarily set to 4.0, which may or may not be the expected value. |
| 186 | 186 | ||
| 187 | Both inputs must have the same sample rate, format and packing. | 187 | Both inputs must have the same sample rate, and format. |
| 188 | 188 | ||
| 189 | If inputs do not have the same duration, the output will stop with the | 189 | If inputs do not have the same duration, the output will stop with the |
| 190 | shortest. | 190 | shortest. |
| @@ -293,9 +293,6 @@ number of samples (per each channel) contained in the filtered frame · 102 unmodified lines | |||
| 293 | @item rate | 293 | @item rate |
| 294 | sample rate for the audio frame | 294 | sample rate for the audio frame |
| 295 | 295 | ||
| 296 | @item planar | ||
| 297 | if the packing format is planar, 0 if packed | ||
| 298 | |||
| 299 | @item checksum | 296 | @item checksum |
| 300 | Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame | 297 | Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame |
| 301 | 298 | ||
| @@ -566,7 +563,7 @@ This source is mainly intended for a programmatic use, in particular · 264 unmodified lines | |||
| 566 | through the interface defined in @file{libavfilter/asrc_abuffer.h}. | 563 | through the interface defined in @file{libavfilter/asrc_abuffer.h}. |
| 567 | 564 | ||
| 568 | It accepts the following mandatory parameters: | 565 | It accepts the following mandatory parameters: |
| 569 | @var{sample_rate}:@var{sample_fmt}:@var{channel_layout}:@var{packing} | 566 | @var{sample_rate}:@var{sample_fmt}:@var{channel_layout} |
| 570 | 567 | ||
| 571 | @table @option | 568 | @table @option |
| 572 | 569 | ||
| @@ -584,23 +581,19 @@ Either a channel layout name from channel_layout_map in · 11 unmodified lines | |||
| 584 | @file{libavutil/audioconvert.c} or its corresponding integer representation | 581 | @file{libavutil/audioconvert.c} or its corresponding integer representation |
| 585 | from the AV_CH_LAYOUT_* macros in @file{libavutil/audioconvert.h} | 582 | from the AV_CH_LAYOUT_* macros in @file{libavutil/audioconvert.h} |
| 586 | 583 | ||
| 587 | @item packing | ||
| 588 | Either "packed" or "planar", or their integer representation: 0 or 1 | ||
| 589 | respectively. | ||
| 590 | |||
| 591 | @end table | 584 | @end table |
| 592 | 585 | ||
| 593 | For example: | 586 | For example: |
| 594 | @example | 587 | @example |
| 595 | abuffer=44100:s16:stereo:planar | 588 | abuffer=44100:s16p:stereo |
| 596 | @end example | 589 | @end example |
| 597 | 590 | ||
| 598 | will instruct the source to accept planar 16bit signed stereo at 44100Hz. | 591 | will instruct the source to accept planar 16bit signed stereo at 44100Hz. |
| 599 | Since the sample format with name "s16" corresponds to the number | 592 | Since the sample format with name "s16p" corresponds to the number |
| 600 | 1 and the "stereo" channel layout corresponds to the value 0x3, this is | 593 | 6 and the "stereo" channel layout corresponds to the value 0x3, this is |
| 601 | equivalent to: | 594 | equivalent to: |
| 602 | @example | 595 | @example |
| 603 | abuffer=44100:1:0x3:1 | 596 | abuffer=44100:6:0x3 |
| 604 | @end example | 597 | @end example |
| 605 | 598 | ||
| 606 | @section aevalsrc | 599 | @section aevalsrc |
| @@ -211,11 +211,9 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) · 210 unmodified lines | |||
| 211 | AV_SAMPLE_FMT_S32, | 211 | AV_SAMPLE_FMT_S32, |
| 212 | AV_SAMPLE_FMT_FLT, | 212 | AV_SAMPLE_FMT_FLT, |
| 213 | AV_SAMPLE_FMT_DBL, -1 }; | 213 | AV_SAMPLE_FMT_DBL, -1 }; |
| 214 | const int packing_fmts[] = { AVFILTER_PACKED, -1 }; | ||
| 215 | const int64_t *chlayouts = avfilter_all_channel_layouts; | 214 | const int64_t *chlayouts = avfilter_all_channel_layouts; |
| 216 | AVABufferSinkParams *abuffersink_params = av_abuffersink_params_alloc(); | 215 | AVABufferSinkParams *abuffersink_params = av_abuffersink_params_alloc(); |
| 217 | abuffersink_params->sample_fmts = sample_fmts; | 216 | abuffersink_params->sample_fmts = sample_fmts; |
| 218 | abuffersink_params->packing_fmts = packing_fmts; | ||
| 219 | abuffersink_params->channel_layouts = chlayouts; | 217 | abuffersink_params->channel_layouts = chlayouts; |
| 220 | 218 | ||
| 221 | ret = avfilter_graph_create_filter(&sink, abuffersink, | 219 | ret = avfilter_graph_create_filter(&sink, abuffersink, |
| @@ -73,7 +73,6 @@ static int query_formats(AVFilterContext *ctx) · 72 unmodified lines | |||
| 73 | AConvertContext *aconvert = ctx->priv; | 73 | AConvertContext *aconvert = ctx->priv; |
| 74 | AVFilterLink *inlink = ctx->inputs[0]; | 74 | AVFilterLink *inlink = ctx->inputs[0]; |
| 75 | AVFilterLink *outlink = ctx->outputs[0]; | 75 | AVFilterLink *outlink = ctx->outputs[0]; |
| 76 | int out_packing = av_sample_fmt_is_planar(aconvert->out_sample_fmt); | ||
| 77 | AVFilterChannelLayouts *layouts; | 76 | AVFilterChannelLayouts *layouts; |
| 78 | 77 | ||
| 79 | avfilter_formats_ref(avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO), | 78 | avfilter_formats_ref(avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO), |
| @@ -96,12 +95,6 @@ static int query_formats(AVFilterContext *ctx) · 16 unmodified lines | |||
| 96 | ff_channel_layouts_ref(ff_all_channel_layouts(), | 95 | ff_channel_layouts_ref(ff_all_channel_layouts(), |
| 97 | &outlink->in_channel_layouts); | 96 | &outlink->in_channel_layouts); |
| 98 | 97 | ||
| 99 | avfilter_formats_ref(avfilter_make_all_packing_formats(), | ||
| 100 | &inlink->out_packing); | ||
| 101 | formats = NULL; | ||
| 102 | avfilter_add_format(&formats, out_packing); | ||
| 103 | avfilter_formats_ref(formats, &outlink->in_packing); | ||
| 104 | |||
| 105 | return 0; | 98 | return 0; |
| 106 | } | 99 | } |
| 107 | 100 | ||
| @@ -134,9 +127,9 @@ static int config_output(AVFilterLink *outlink) · 26 unmodified lines | |||
| 134 | av_get_channel_layout_string(buf2, sizeof(buf2), | 127 | av_get_channel_layout_string(buf2, sizeof(buf2), |
| 135 | -1, outlink->channel_layout); | 128 | -1, outlink->channel_layout); |
| 136 | av_log(ctx, AV_LOG_INFO, | 129 | av_log(ctx, AV_LOG_INFO, |
| 137 | "fmt:%s cl:%s planar:%i -> fmt:%s cl:%s planar:%i\n", | 130 | "fmt:%s cl:%s -> fmt:%s cl:%s\n", |
| 138 | av_get_sample_fmt_name(inlink ->format), buf1, inlink ->planar, | 131 | av_get_sample_fmt_name(inlink ->format), buf1, |
| 139 | av_get_sample_fmt_name(outlink->format), buf2, outlink->planar); | 132 | av_get_sample_fmt_name(outlink->format), buf2); |
| 140 | 133 | ||
| 141 | return 0; | 134 | return 0; |
| 142 | } | 135 | } |
| @@ -153,7 +146,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 10 unmodified lines | |||
| 153 | 146 | ||
| 154 | avfilter_copy_buffer_ref_props(outsamplesref, insamplesref); | 147 | avfilter_copy_buffer_ref_props(outsamplesref, insamplesref); |
| 155 | outsamplesref->audio->channel_layout = outlink->channel_layout; | 148 | outsamplesref->audio->channel_layout = outlink->channel_layout; |
| 156 | outsamplesref->audio->planar = outlink->planar; | ||
| 157 | 149 | ||
| 158 | ff_filter_samples(outlink, outsamplesref); | 150 | ff_filter_samples(outlink, outsamplesref); |
| 159 | avfilter_unref_buffer(insamplesref); | 151 | avfilter_unref_buffer(insamplesref); |
| @@ -161,7 +153,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref · 1 unmodified line | |||
| 161 | 153 | ||
| 162 | AVFilter avfilter_af_aconvert = { | 154 | AVFilter avfilter_af_aconvert = { |
| 163 | .name = "aconvert", | 155 | .name = "aconvert", |
| 164 | .description = NULL_IF_CONFIG_SMALL("Convert the input audio to sample_fmt:channel_layout:packed_fmt."), | 156 | .description = NULL_IF_CONFIG_SMALL("Convert the input audio to sample_fmt:channel_layout."), |
| 165 | .priv_size = sizeof(AConvertContext), | 157 | .priv_size = sizeof(AConvertContext), |
| 166 | .init = init, | 158 | .init = init, |
| 167 | .uninit = uninit, | 159 | .uninit = uninit, |
| @@ -54,7 +54,6 @@ static int query_formats(AVFilterContext *ctx) · 53 unmodified lines | |||
| 54 | { | 54 | { |
| 55 | AMergeContext *am = ctx->priv; | 55 | AMergeContext *am = ctx->priv; |
| 56 | int64_t inlayout[2], outlayout; | 56 | int64_t inlayout[2], outlayout; |
| 57 | const int packing_fmts[] = { AVFILTER_PACKED, -1 }; | ||
| 58 | AVFilterFormats *formats; | 57 | AVFilterFormats *formats; |
| 59 | AVFilterChannelLayouts *layouts; | 58 | AVFilterChannelLayouts *layouts; |
| 60 | int i; | 59 | int i; |
| @@ -97,10 +96,8 @@ static int query_formats(AVFilterContext *ctx) · 36 unmodified lines | |||
| 97 | if ((inlayout[i] >> c) & 1) | 96 | if ((inlayout[i] >> c) & 1) |
| 98 | *(route[i]++) = out_ch_number++; | 97 | *(route[i]++) = out_ch_number++; |
| 99 | } | 98 | } |
| 100 | formats = avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO); | 99 | formats = avfilter_make_format_list(ff_packed_sample_fmts); |
| 101 | avfilter_set_common_sample_formats(ctx, formats); | 100 | avfilter_set_common_sample_formats(ctx, formats); |
| 102 | formats = avfilter_make_format_list(packing_fmts); | ||
| 103 | avfilter_set_common_packing_formats(ctx, formats); | ||
| 104 | for (i = 0; i < 2; i++) { | 101 | for (i = 0; i < 2; i++) { |
| 105 | layouts = NULL; | 102 | layouts = NULL; |
| 106 | ff_add_channel_layout(&layouts, inlayout[i]); | 103 | ff_add_channel_layout(&layouts, inlayout[i]); |
| @@ -222,7 +219,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 115 unmodified lines | |||
| 222 | avfilter_copy_buffer_ref_props(outbuf, *inbuf[0]); | 219 | avfilter_copy_buffer_ref_props(outbuf, *inbuf[0]); |
| 223 | outbuf->audio->nb_samples = nb_samples; | 220 | outbuf->audio->nb_samples = nb_samples; |
| 224 | outbuf->audio->channel_layout = outlink->channel_layout; | 221 | outbuf->audio->channel_layout = outlink->channel_layout; |
| 225 | outbuf->audio->planar = outlink->planar; | ||
| 226 | 222 | ||
| 227 | while (nb_samples) { | 223 | while (nb_samples) { |
| 228 | ns = nb_samples; | 224 | ns = nb_samples; |
| @@ -50,7 +50,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) · 49 unmodified lines | |||
| 50 | int linesize = | 50 | int linesize = |
| 51 | samplesref->audio->nb_samples * | 51 | samplesref->audio->nb_samples * |
| 52 | av_get_bytes_per_sample(samplesref->format); | 52 | av_get_bytes_per_sample(samplesref->format); |
| 53 | if (!samplesref->audio->planar) /* packed layout */ | 53 | if (!av_sample_fmt_is_planar(samplesref->format)) |
| 54 | linesize *= av_get_channel_layout_nb_channels(samplesref->audio->channel_layout); | 54 | linesize *= av_get_channel_layout_nb_channels(samplesref->audio->channel_layout); |
| 55 | 55 | ||
| 56 | for (plane = 0; samplesref->data[plane] && plane < 8; plane++) { | 56 | for (plane = 0; samplesref->data[plane] && plane < 8; plane++) { |
| @@ -66,7 +66,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) · 9 unmodified lines | |||
| 66 | 66 | ||
| 67 | av_log(ctx, AV_LOG_INFO, | 67 | av_log(ctx, AV_LOG_INFO, |
| 68 | "n:%d pts:%s pts_time:%s pos:%"PRId64" " | 68 | "n:%d pts:%s pts_time:%s pos:%"PRId64" " |
| 69 | "fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d " | 69 | "fmt:%s chlayout:%s nb_samples:%d rate:%d " |
| 70 | "checksum:%08X plane_checksum[%08X", | 70 | "checksum:%08X plane_checksum[%08X", |
| 71 | showinfo->frame, | 71 | showinfo->frame, |
| 72 | av_ts2str(samplesref->pts), av_ts2timestr(samplesref->pts, &inlink->time_base), | 72 | av_ts2str(samplesref->pts), av_ts2timestr(samplesref->pts, &inlink->time_base), |
| @@ -75,7 +75,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) · 2 unmodified lines | |||
| 75 | chlayout_str, | 75 | chlayout_str, |
| 76 | samplesref->audio->nb_samples, | 76 | samplesref->audio->nb_samples, |
| 77 | samplesref->audio->sample_rate, | 77 | samplesref->audio->sample_rate, |
| 78 | samplesref->audio->planar, | ||
| 79 | checksum, | 78 | checksum, |
| 80 | plane_checksum[0]); | 79 | plane_checksum[0]); |
| 81 | 80 | ||
| @@ -87,9 +87,6 @@ static int query_formats(AVFilterContext *ctx) · 86 unmodified lines | |||
| 87 | formats = ctx->inputs[i]->in_formats; | 87 | formats = ctx->inputs[i]->in_formats; |
| 88 | avfilter_formats_ref(formats, &ctx->inputs[i]->out_formats); | 88 | avfilter_formats_ref(formats, &ctx->inputs[i]->out_formats); |
| 89 | avfilter_formats_ref(formats, &ctx->outputs[i]->in_formats); | 89 | avfilter_formats_ref(formats, &ctx->outputs[i]->in_formats); |
| 90 | formats = ctx->inputs[i]->in_packing; | ||
| 91 | avfilter_formats_ref(formats, &ctx->inputs[i]->out_packing); | ||
| 92 | avfilter_formats_ref(formats, &ctx->outputs[i]->in_packing); | ||
| 93 | layouts = ctx->inputs[i]->in_channel_layouts; | 90 | layouts = ctx->inputs[i]->in_channel_layouts; |
| 94 | ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts); | 91 | ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts); |
| 95 | ff_channel_layouts_ref(layouts, &ctx->outputs[i]->in_channel_layouts); | 92 | ff_channel_layouts_ref(layouts, &ctx->outputs[i]->in_channel_layouts); |
| @@ -86,9 +86,6 @@ static int query_formats(AVFilterContext *ctx) · 85 unmodified lines | |||
| 86 | avfilter_set_common_sample_formats(ctx, formats); | 86 | avfilter_set_common_sample_formats(ctx, formats); |
| 87 | ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); | 87 | ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); |
| 88 | ff_set_common_channel_layouts(ctx, layout); | 88 | ff_set_common_channel_layouts(ctx, layout); |
| 89 | formats = NULL; | ||
| 90 | avfilter_add_format(&formats, AVFILTER_PACKED); | ||
| 91 | avfilter_set_common_packing_formats(ctx, formats); | ||
| 92 | ff_set_common_samplerates(ctx, avfilter_make_format_list(sample_rates)); | 89 | ff_set_common_samplerates(ctx, avfilter_make_format_list(sample_rates)); |
| 93 | 90 | ||
| 94 | return 0; | 91 | return 0; |
| @@ -218,7 +218,6 @@ static int query_formats(AVFilterContext *ctx) · 217 unmodified lines | |||
| 218 | pan->pure_gains = are_gains_pure(pan); | 218 | pan->pure_gains = are_gains_pure(pan); |
| 219 | /* libswr supports any sample and packing formats */ | 219 | /* libswr supports any sample and packing formats */ |
| 220 | avfilter_set_common_sample_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO)); | 220 | avfilter_set_common_sample_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO)); |
| 221 | avfilter_set_common_packing_formats(ctx, avfilter_make_all_packing_formats()); | ||
| 222 | 221 | ||
| 223 | // inlink supports any channel layout | 222 | // inlink supports any channel layout |
| 224 | layouts = ff_all_channel_layouts(); | 223 | layouts = ff_all_channel_layouts(); |
| @@ -348,7 +347,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) · 123 unmodified lines | |||
| 348 | swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n); | 347 | swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n); |
| 349 | avfilter_copy_buffer_ref_props(outsamples, insamples); | 348 | avfilter_copy_buffer_ref_props(outsamples, insamples); |
| 350 | outsamples->audio->channel_layout = outlink->channel_layout; | 349 | outsamples->audio->channel_layout = outlink->channel_layout; |
| 351 | outsamples->audio->planar = outlink->planar; | ||
| 352 | 350 | ||
| 353 | ff_filter_samples(outlink, outsamples); | 351 | ff_filter_samples(outlink, outsamples); |
| 354 | avfilter_unref_buffer(insamples); | 352 | avfilter_unref_buffer(insamples); |
| @@ -136,7 +136,6 @@ static int query_formats(AVFilterContext *ctx) · 135 unmodified lines | |||
| 136 | AV_SAMPLE_FMT_DBL, | 136 | AV_SAMPLE_FMT_DBL, |
| 137 | AV_SAMPLE_FMT_NONE | 137 | AV_SAMPLE_FMT_NONE |
| 138 | }; | 138 | }; |
| 139 | int packing_fmts[] = { AVFILTER_PACKED, -1 }; | ||
| 140 | 139 | ||
| 141 | layouts = ff_all_channel_layouts(); | 140 | layouts = ff_all_channel_layouts(); |
| 142 | if (!layouts) | 141 | if (!layouts) |
| @@ -148,11 +147,6 @@ static int query_formats(AVFilterContext *ctx) · 5 unmodified lines | |||
| 148 | return AVERROR(ENOMEM); | 147 | return AVERROR(ENOMEM); |
| 149 | avfilter_set_common_sample_formats(ctx, formats); | 148 | avfilter_set_common_sample_formats(ctx, formats); |
| 150 | 149 | ||
| 151 | formats = avfilter_make_format_list(packing_fmts); | ||
| 152 | if (!formats) | ||
| 153 | return AVERROR(ENOMEM); | ||
| 154 | avfilter_set_common_packing_formats(ctx, formats); | ||
| 155 | |||
| 156 | formats = ff_all_samplerates(); | 150 | formats = ff_all_samplerates(); |
| 157 | if (!formats) | 151 | if (!formats) |
| 158 | return AVERROR(ENOMEM); | 152 | return AVERROR(ENOMEM); |
| @@ -91,7 +91,6 @@ static int query_formats(AVFilterContext *ctx) · 90 unmodified lines | |||
| 91 | AV_SAMPLE_FMT_DBL, | 91 | AV_SAMPLE_FMT_DBL, |
| 92 | AV_SAMPLE_FMT_NONE | 92 | AV_SAMPLE_FMT_NONE |
| 93 | }; | 93 | }; |
| 94 | int packing_fmts[] = { AVFILTER_PACKED, -1 }; | ||
| 95 | 94 | ||
| 96 | layouts = ff_all_channel_layouts(); | 95 | layouts = ff_all_channel_layouts(); |
| 97 | if (!layouts) | 96 | if (!layouts) |
| @@ -103,11 +102,6 @@ static int query_formats(AVFilterContext *ctx) · 5 unmodified lines | |||
| 103 | return AVERROR(ENOMEM); | 102 | return AVERROR(ENOMEM); |
| 104 | avfilter_set_common_sample_formats(ctx, formats); | 103 | avfilter_set_common_sample_formats(ctx, formats); |
| 105 | 104 | ||
| 106 | formats = avfilter_make_format_list(packing_fmts); | ||
| 107 | if (!formats) | ||
| 108 | return AVERROR(ENOMEM); | ||
| 109 | avfilter_set_common_packing_formats(ctx, formats); | ||
| 110 | |||
| 111 | formats = ff_all_samplerates(); | 105 | formats = ff_all_samplerates(); |
| 112 | if (!formats) | 106 | if (!formats) |
| 113 | return AVERROR(ENOMEM); | 107 | return AVERROR(ENOMEM); |
| @@ -187,11 +187,9 @@ static int query_formats(AVFilterContext *ctx) · 186 unmodified lines | |||
| 187 | EvalContext *eval = ctx->priv; | 187 | EvalContext *eval = ctx->priv; |
| 188 | enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE }; | 188 | enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE }; |
| 189 | int64_t chlayouts[] = { eval->chlayout, -1 }; | 189 | int64_t chlayouts[] = { eval->chlayout, -1 }; |
| 190 | int packing_fmts[] = { AVFILTER_PLANAR, -1 }; | ||
| 191 | 190 | ||
| 192 | avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts)); | 191 | avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts)); |
| 193 | ff_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts)); | 192 | ff_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts)); |
| 194 | avfilter_set_common_packing_formats(ctx, avfilter_make_format_list(packing_fmts)); | ||
| 195 | 193 | ||
| 196 | return 0; | 194 | return 0; |
| 197 | } | 195 | } |
| @@ -100,9 +100,9 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, · 99 unmodified lines | |||
| 100 | 100 | ||
| 101 | samplesref->audio->nb_samples = nb_samples; | 101 | samplesref->audio->nb_samples = nb_samples; |
| 102 | samplesref->audio->channel_layout = channel_layout; | 102 | samplesref->audio->channel_layout = channel_layout; |
| 103 | samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt); | ||
| 104 | 103 | ||
| 105 | planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1; | 104 | planes = av_sample_fmt_is_planar(sample_fmt) ? |
| 105 | av_get_channel_layout_nb_channels(channel_layout) : 1; | ||
| 106 | 106 | ||
| 107 | /* make sure the buffer gets read permission or it's useless for output */ | 107 | /* make sure the buffer gets read permission or it's useless for output */ |
| 108 | samplesref->perms = perms | AV_PERM_READ; | 108 | samplesref->perms = perms | AV_PERM_READ; |
| @@ -24,6 +24,23 @@ · 23 unmodified lines | |||
| 24 | 24 | ||
| 25 | #include "avfilter.h" | 25 | #include "avfilter.h" |
| 26 | 26 | ||
| 27 | static const enum AVSampleFormat ff_packed_sample_fmts[] = { | ||
| 28 | AV_SAMPLE_FMT_U8, | ||
| 29 | AV_SAMPLE_FMT_S16, | ||
| 30 | AV_SAMPLE_FMT_S32, | ||
| 31 | AV_SAMPLE_FMT_FLT, | ||
| 32 | AV_SAMPLE_FMT_DBL, | ||
| 33 | AV_SAMPLE_FMT_NONE | ||
| 34 | }; | ||
| 35 | |||
| 36 | static const enum AVSampleFormat ff_planar_sample_fmts[] = { | ||
| 37 | AV_SAMPLE_FMT_U8P, | ||
| 38 | AV_SAMPLE_FMT_S16P, | ||
| 39 | AV_SAMPLE_FMT_S32P, | ||
| 40 | AV_SAMPLE_FMT_FLTP, | ||
| 41 | AV_SAMPLE_FMT_DBLP, | ||
| 42 | AV_SAMPLE_FMT_NONE | ||
| 43 | }; | ||
| 27 | 44 | ||
| 28 | /** default handler for get_audio_buffer() for audio inputs */ | 45 | /** default handler for get_audio_buffer() for audio inputs */ |
| 29 | AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, | 46 | AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, |
| @@ -148,9 +148,6 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, · 147 unmodified lines | |||
| 148 | if (link->out_channel_layouts) | 148 | if (link->out_channel_layouts) |
| 149 | ff_channel_layouts_changeref(&link->out_channel_layouts, | 149 | ff_channel_layouts_changeref(&link->out_channel_layouts, |
| 150 | &filt->outputs[filt_dstpad_idx]->out_channel_layouts); | 150 | &filt->outputs[filt_dstpad_idx]->out_channel_layouts); |
| 151 | if (link->out_packing) | ||
| 152 | avfilter_formats_changeref(&link->out_packing, | ||
| 153 | &filt->outputs[filt_dstpad_idx]->out_packing); | ||
| 154 | if (link->out_samplerates) | 151 | if (link->out_samplerates) |
| 155 | avfilter_formats_changeref(&link->out_samplerates, | 152 | avfilter_formats_changeref(&link->out_samplerates, |
| 156 | &filt->outputs[filt_dstpad_idx]->out_samplerates); | 153 | &filt->outputs[filt_dstpad_idx]->out_samplerates); |
| @@ -121,7 +121,9 @@ typedef struct AVFilterBufferRefAudioProps { · 120 unmodified lines | |||
| 121 | uint64_t channel_layout; ///< channel layout of audio buffer | 121 | uint64_t channel_layout; ///< channel layout of audio buffer |
| 122 | int nb_samples; ///< number of audio samples per channel | 122 | int nb_samples; ///< number of audio samples per channel |
| 123 | int sample_rate; ///< audio buffer sample rate | 123 | int sample_rate; ///< audio buffer sample rate |
| 124 | #if FF_API_PACKING | ||
| 124 | int planar; ///< audio buffer - planar or packed | 125 | int planar; ///< audio buffer - planar or packed |
| 126 | #endif | ||
| 125 | } AVFilterBufferRefAudioProps; | 127 | } AVFilterBufferRefAudioProps; |
| 126 | 128 | ||
| 127 | /** | 129 | /** |
| @@ -303,10 +305,12 @@ AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type); · 175 unmodified lines | |||
| 303 | */ | 305 | */ |
| 304 | extern const int64_t avfilter_all_channel_layouts[]; | 306 | extern const int64_t avfilter_all_channel_layouts[]; |
| 305 | 307 | ||
| 308 | #if FF_API_PACKING | ||
| 306 | /** | 309 | /** |
| 307 | * Return a list of all audio packing formats. | 310 | * Return a list of all audio packing formats. |
| 308 | */ | 311 | */ |
| 309 | AVFilterFormats *avfilter_make_all_packing_formats(void); | 312 | AVFilterFormats *avfilter_make_all_packing_formats(void); |
| 313 | #endif | ||
| 310 | 314 | ||
| 311 | /** | 315 | /** |
| 312 | * Return a format list which contains the intersection of the formats of | 316 | * Return a format list which contains the intersection of the formats of |
| @@ -519,7 +523,9 @@ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) · 206 unmodified lines | |||
| 519 | void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats); | 523 | void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
| 520 | void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats); | 524 | void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
| 521 | void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats); | 525 | void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats); |
| 526 | #if FF_API_PACKING | ||
| 522 | void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats); | 527 | void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
| 528 | #endif | ||
| 523 | 529 | ||
| 524 | /** Default handler for query_formats() */ | 530 | /** Default handler for query_formats() */ |
| 525 | int avfilter_default_query_formats(AVFilterContext *ctx); | 531 | int avfilter_default_query_formats(AVFilterContext *ctx); |
| @@ -616,10 +622,12 @@ struct AVFilterContext { · 90 unmodified lines | |||
| 616 | struct AVFilterCommand *command_queue; | 622 | struct AVFilterCommand *command_queue; |
| 617 | }; | 623 | }; |
| 618 | 624 | ||
| 625 | #if FF_API_PACKING | ||
| 619 | enum AVFilterPacking { | 626 | enum AVFilterPacking { |
| 620 | AVFILTER_PACKED = 0, | 627 | AVFILTER_PACKED = 0, |
| 621 | AVFILTER_PLANAR, | 628 | AVFILTER_PLANAR, |
| 622 | }; | 629 | }; |
| 630 | #endif | ||
| 623 | 631 | ||
| 624 | /** | 632 | /** |
| 625 | * A link between two filters. This contains pointers to the source and | 633 | * A link between two filters. This contains pointers to the source and |
| @@ -655,7 +663,9 @@ struct AVFilterLink { · 29 unmodified lines | |||
| 655 | #else | 663 | #else |
| 656 | int sample_rate; ///< samples per second | 664 | int sample_rate; ///< samples per second |
| 657 | #endif | 665 | #endif |
| 666 | #if FF_API_PACKING | ||
| 658 | int planar; ///< agreed upon packing mode of audio buffers. true if planar. | 667 | int planar; ///< agreed upon packing mode of audio buffers. true if planar. |
| 668 | #endif | ||
| 659 | 669 | ||
| 660 | int format; ///< agreed upon media format | 670 | int format; ///< agreed upon media format |
| 661 | 671 | ||
| @@ -669,8 +679,10 @@ struct AVFilterLink { · 7 unmodified lines | |||
| 669 | AVFilterFormats *in_formats; | 679 | AVFilterFormats *in_formats; |
| 670 | AVFilterFormats *out_formats; | 680 | AVFilterFormats *out_formats; |
| 671 | 681 | ||
| 682 | #if FF_API_PACKING | ||
| 672 | AVFilterFormats *in_packing; | 683 | AVFilterFormats *in_packing; |
| 673 | AVFilterFormats *out_packing; | 684 | AVFilterFormats *out_packing; |
| 685 | #endif | ||
| 674 | 686 | ||
| 675 | /** | 687 | /** |
| 676 | * The buffer reference currently being sent across the link by the source | 688 | * 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, · 199 unmodified lines | |||
| 200 | 200 | ||
| 201 | if (link->type == AVMEDIA_TYPE_AUDIO && | 201 | if (link->type == AVMEDIA_TYPE_AUDIO && |
| 202 | (((link = filt_ctx-> inputs[0]) && | 202 | (((link = filt_ctx-> inputs[0]) && |
| 203 | (!ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts) || | 203 | !ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts)) || |
| 204 | !avfilter_merge_formats(link->in_packing, link->out_packing))) || | ||
| 205 | ((link = filt_ctx->outputs[0]) && | 204 | ((link = filt_ctx->outputs[0]) && |
| 206 | (!ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts) || | 205 | !ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts))) |
| 207 | !avfilter_merge_formats(link->in_packing, link->out_packing)))) | ||
| 208 | ) { | 206 | ) { |
| 209 | av_log(NULL, AV_LOG_ERROR, | 207 | av_log(NULL, AV_LOG_ERROR, |
| 210 | "Impossible to convert between the channel layouts/packing formats supported by the filter " | 208 | "Impossible to convert between the channel layouts formats supported by the filter " |
| 211 | "'%s' and the filter '%s'\n", link->src->name, link->dst->name); | 209 | "'%s' and the filter '%s'\n", link->src->name, link->dst->name); |
| 212 | return AVERROR(EINVAL); | 210 | return AVERROR(EINVAL); |
| 213 | } | 211 | } |
| @@ -219,7 +217,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 5 unmodified lines | |||
| 219 | { | 217 | { |
| 220 | int i, j, ret; | 218 | int i, j, ret; |
| 221 | char filt_args[128]; | 219 | char filt_args[128]; |
| 222 | AVFilterFormats *formats, *packing; | 220 | AVFilterFormats *formats; |
| 223 | AVFilterChannelLayouts *chlayouts; | 221 | AVFilterChannelLayouts *chlayouts; |
| 224 | AVFilterFormats *samplerates; | 222 | AVFilterFormats *samplerates; |
| 225 | int scaler_count = 0, resampler_count = 0; | 223 | int scaler_count = 0, resampler_count = 0; |
| @@ -254,8 +252,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 28 unmodified lines | |||
| 254 | return ret; | 252 | return ret; |
| 255 | } | 253 | } |
| 256 | else if (link->type == AVMEDIA_TYPE_AUDIO) { | 254 | else if (link->type == AVMEDIA_TYPE_AUDIO) { |
| 257 | if (!link->in_channel_layouts || !link->out_channel_layouts || | 255 | if (!link->in_channel_layouts || !link->out_channel_layouts) |
| 258 | !link->in_packing || !link->out_packing) | ||
| 259 | return AVERROR(EINVAL); | 256 | return AVERROR(EINVAL); |
| 260 | 257 | ||
| 261 | /* Merge all three list before checking: that way, in all | 258 | /* Merge all three list before checking: that way, in all |
| @@ -264,9 +261,8 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 2 unmodified lines | |||
| 264 | formats = avfilter_merge_formats(link->in_formats, link->out_formats); | 261 | formats = avfilter_merge_formats(link->in_formats, link->out_formats); |
| 265 | chlayouts = ff_merge_channel_layouts(link->in_channel_layouts , link->out_channel_layouts); | 262 | chlayouts = ff_merge_channel_layouts(link->in_channel_layouts , link->out_channel_layouts); |
| 266 | samplerates = ff_merge_samplerates (link->in_samplerates, link->out_samplerates); | 263 | samplerates = ff_merge_samplerates (link->in_samplerates, link->out_samplerates); |
| 267 | packing = avfilter_merge_formats(link->in_packing, link->out_packing); | ||
| 268 | 264 | ||
| 269 | if (!formats || !chlayouts || !packing || !samplerates) | 265 | if (!formats || !chlayouts || !samplerates) |
| 270 | if (ret = insert_conv_filter(graph, link, "aconvert", NULL)) | 266 | if (ret = insert_conv_filter(graph, link, "aconvert", NULL)) |
| 271 | return ret; | 267 | return ret; |
| 272 | #else | 268 | #else |
| @@ -46,7 +46,9 @@ AVBufferSinkParams *av_buffersink_params_alloc(void); · 45 unmodified lines | |||
| 46 | typedef struct { | 46 | typedef struct { |
| 47 | const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE | 47 | const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE |
| 48 | const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1 | 48 | const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1 |
| 49 | #if FF_API_PACKING | ||
| 49 | const int *packing_fmts; ///< list of allowed packing formats | 50 | const int *packing_fmts; ///< list of allowed packing formats |
| 51 | #endif | ||
| 50 | } AVABufferSinkParams; | 52 | } AVABufferSinkParams; |
| 51 | 53 | ||
| 52 | /** | 54 | /** |
| @@ -70,9 +70,11 @@ void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats * · 69 unmodified lines | |||
| 70 | offsetof(AVFilterLink, out_channel_layouts)); | 70 | offsetof(AVFilterLink, out_channel_layouts)); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | #if FF_API_PACKING | ||
| 73 | void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats) | 74 | void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats) |
| 74 | { | 75 | { |
| 75 | set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO, | 76 | set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO, |
| 76 | offsetof(AVFilterLink, in_packing), | 77 | offsetof(AVFilterLink, in_packing), |
| 77 | offsetof(AVFilterLink, out_packing)); | 78 | offsetof(AVFilterLink, out_packing)); |
| 78 | } | 79 | } |
| 80 | #endif | ||
| @@ -289,6 +289,7 @@ const int64_t avfilter_all_channel_layouts[] = { · 288 unmodified lines | |||
| 289 | // return avfilter_make_format64_list(avfilter_all_channel_layouts); | 289 | // return avfilter_make_format64_list(avfilter_all_channel_layouts); |
| 290 | // } | 290 | // } |
| 291 | 291 | ||
| 292 | #if FF_API_PACKING | ||
| 292 | AVFilterFormats *avfilter_make_all_packing_formats(void) | 293 | AVFilterFormats *avfilter_make_all_packing_formats(void) |
| 293 | { | 294 | { |
| 294 | static const int packing[] = { | 295 | static const int packing[] = { |
| @@ -299,6 +300,7 @@ AVFilterFormats *avfilter_make_all_packing_formats(void) · 4 unmodified lines | |||
| 299 | 300 | ||
| 300 | return avfilter_make_format_list(packing); | 301 | return avfilter_make_format_list(packing); |
| 301 | } | 302 | } |
| 303 | #endif | ||
| 302 | 304 | ||
| 303 | AVFilterFormats *ff_all_samplerates(void) | 305 | AVFilterFormats *ff_all_samplerates(void) |
| 304 | { | 306 | { |
| @@ -518,23 +520,6 @@ int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx) · 213 unmodified lines | |||
| 518 | return 0; | 520 | return 0; |
| 519 | } | 521 | } |
| 520 | 522 | ||
| 521 | int ff_parse_packing_format(int *ret, const char *arg, void *log_ctx) | ||
| 522 | { | ||
| 523 | char *tail; | ||
| 524 | int planar = strtol(arg, &tail, 10); | ||
| 525 | if (*tail) { | ||
| 526 | planar = !strcmp(arg, "packed") ? 0: | ||
| 527 | !strcmp(arg, "planar") ? 1: -1; | ||
| 528 | } | ||
| 529 | |||
| 530 | if (planar != 0 && planar != 1) { | ||
| 531 | av_log(log_ctx, AV_LOG_ERROR, "Invalid packing format '%s'\n", arg); | ||
| 532 | return AVERROR(EINVAL); | ||
| 533 | } | ||
| 534 | *ret = planar; | ||
| 535 | return 0; | ||
| 536 | } | ||
| 537 | |||
| 538 | #ifdef TEST | 523 | #ifdef TEST |
| 539 | 524 | ||
| 540 | #undef printf | 525 | #undef printf |
| @@ -46,9 +46,8 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link) · 45 unmodified lines | |||
| 46 | av_get_channel_layout_string(layout, sizeof(layout), | 46 | av_get_channel_layout_string(layout, sizeof(layout), |
| 47 | -1, link->channel_layout); | 47 | -1, link->channel_layout); |
| 48 | format = av_x_if_null(av_get_sample_fmt_name(link->format), "?"); | 48 | format = av_x_if_null(av_get_sample_fmt_name(link->format), "?"); |
| 49 | av_bprintf(buf, "[%dHz %s:%s:%s]", | 49 | av_bprintf(buf, "[%dHz %s:%s]", |
| 50 | (int)link->sample_rate, format, layout, | 50 | (int)link->sample_rate, format, layout); |
| 51 | link->planar ? "planar" : "packed"); | ||
| 52 | break; | 51 | break; |
| 53 | 52 | ||
| 54 | default: | 53 | default: |
| @@ -131,16 +131,6 @@ int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx); · 130 unmodified lines | |||
| 131 | */ | 131 | */ |
| 132 | int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx); | 132 | int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx); |
| 133 | 133 | ||
| 134 | /** | ||
| 135 | * Parse a packing format or a corresponding integer representation. | ||
| 136 | * | ||
| 137 | * @param ret integer pointer to where the value should be written | ||
| 138 | * @param arg string to parse | ||
| 139 | * @param log_ctx log context | ||
| 140 | * @return 0 in case of success, a negative AVERROR code on error | ||
| 141 | */ | ||
| 142 | int ff_parse_packing_format(int *ret, const char *arg, void *log_ctx); | ||
| 143 | |||
| 144 | /** | 134 | /** |
| 145 | * Pass video frame along and keep an internal reference for later use. | 135 | * Pass video frame along and keep an internal reference for later use. |
| 146 | */ | 136 | */ |
| @@ -42,7 +42,6 @@ AVBufferSinkParams *av_buffersink_params_alloc(void) · 41 unmodified lines | |||
| 42 | AVABufferSinkParams *av_abuffersink_params_alloc(void) | 42 | AVABufferSinkParams *av_abuffersink_params_alloc(void) |
| 43 | { | 43 | { |
| 44 | static const int sample_fmts[] = { -1 }; | 44 | static const int sample_fmts[] = { -1 }; |
| 45 | static const int packing_fmts[] = { -1 }; | ||
| 46 | static const int64_t channel_layouts[] = { -1 }; | 45 | static const int64_t channel_layouts[] = { -1 }; |
| 47 | AVABufferSinkParams *params = av_malloc(sizeof(AVABufferSinkParams)); | 46 | AVABufferSinkParams *params = av_malloc(sizeof(AVABufferSinkParams)); |
| 48 | 47 | ||
| @@ -51,7 +50,6 @@ AVABufferSinkParams *av_abuffersink_params_alloc(void) · 2 unmodified lines | |||
| 51 | 50 | ||
| 52 | params->sample_fmts = sample_fmts; | 51 | params->sample_fmts = sample_fmts; |
| 53 | params->channel_layouts = channel_layouts; | 52 | params->channel_layouts = channel_layouts; |
| 54 | params->packing_fmts = packing_fmts; | ||
| 55 | return params; | 53 | return params; |
| 56 | } | 54 | } |
| 57 | 55 | ||
| @@ -64,7 +62,6 @@ typedef struct { · 6 unmodified lines | |||
| 64 | /* only used for audio */ | 62 | /* only used for audio */ |
| 65 | enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE | 63 | enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE |
| 66 | int64_t *channel_layouts; ///< list of accepted channel layouts, terminated by -1 | 64 | int64_t *channel_layouts; ///< list of accepted channel layouts, terminated by -1 |
| 67 | int *packing_fmts; ///< list of accepted packing formats, terminated by -1 | ||
| 68 | } BufferSinkContext; | 65 | } BufferSinkContext; |
| 69 | 66 | ||
| 70 | #define FIFO_INIT_SIZE 8 | 67 | #define FIFO_INIT_SIZE 8 |
| @@ -244,11 +241,9 @@ static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaq · 173 unmodified lines | |||
| 244 | 241 | ||
| 245 | buf->sample_fmts = ff_copy_int_list (params->sample_fmts); | 242 | buf->sample_fmts = ff_copy_int_list (params->sample_fmts); |
| 246 | buf->channel_layouts = ff_copy_int64_list(params->channel_layouts); | 243 | buf->channel_layouts = ff_copy_int64_list(params->channel_layouts); |
| 247 | buf->packing_fmts = ff_copy_int_list (params->packing_fmts); | 244 | if (!buf->sample_fmts || !buf->channel_layouts) { |
| 248 | if (!buf->sample_fmts || !buf->channel_layouts || !buf->sample_fmts) { | ||
| 249 | av_freep(&buf->sample_fmts); | 245 | av_freep(&buf->sample_fmts); |
| 250 | av_freep(&buf->channel_layouts); | 246 | av_freep(&buf->channel_layouts); |
| 251 | av_freep(&buf->packing_fmts); | ||
| 252 | return AVERROR(ENOMEM); | 247 | return AVERROR(ENOMEM); |
| 253 | } | 248 | } |
| 254 | 249 | ||
| @@ -261,7 +256,6 @@ static av_cold void asink_uninit(AVFilterContext *ctx) · 6 unmodified lines | |||
| 261 | 256 | ||
| 262 | av_freep(&buf->sample_fmts); | 257 | av_freep(&buf->sample_fmts); |
| 263 | av_freep(&buf->channel_layouts); | 258 | av_freep(&buf->channel_layouts); |
| 264 | av_freep(&buf->packing_fmts); | ||
| 265 | return common_uninit(ctx); | 259 | return common_uninit(ctx); |
| 266 | } | 260 | } |
| 267 | 261 | ||
| @@ -278,11 +272,6 @@ static int asink_query_formats(AVFilterContext *ctx) · 10 unmodified lines | |||
| 278 | if (!(layouts = avfilter_make_format64_list(buf->channel_layouts))) | 272 | if (!(layouts = avfilter_make_format64_list(buf->channel_layouts))) |
| 279 | return AVERROR(ENOMEM); | 273 | return AVERROR(ENOMEM); |
| 280 | ff_set_common_channel_layouts(ctx, layouts); | 274 | ff_set_common_channel_layouts(ctx, layouts); |
| 281 | |||
| 282 | if (!(formats = avfilter_make_format_list(buf->packing_fmts))) | ||
| 283 | return AVERROR(ENOMEM); | ||
| 284 | avfilter_set_common_packing_formats(ctx, formats); | ||
| 285 | |||
| 286 | ff_set_common_samplerates (ctx, ff_all_samplerates()); | 275 | ff_set_common_samplerates (ctx, ff_all_samplerates()); |
| 287 | 276 | ||
| 288 | return 0; | 277 | return 0; |
| @@ -55,7 +55,6 @@ typedef struct { · 54 unmodified lines | |||
| 55 | int sample_rate; | 55 | int sample_rate; |
| 56 | unsigned int sample_format; | 56 | unsigned int sample_format; |
| 57 | int64_t channel_layout; | 57 | int64_t channel_layout; |
| 58 | int packing_format; | ||
| 59 | 58 | ||
| 60 | // Normalization filters | 59 | // Normalization filters |
| 61 | AVFilterContext *aconvert; | 60 | AVFilterContext *aconvert; |
| @@ -91,7 +90,6 @@ static int reconfigure_filter(BufferSourceContext *abuffer, AVFilterContext *fil · 29 unmodified lines | |||
| 91 | 90 | ||
| 92 | inlink->format = abuffer->sample_format; | 91 | inlink->format = abuffer->sample_format; |
| 93 | inlink->channel_layout = abuffer->channel_layout; | 92 | inlink->channel_layout = abuffer->channel_layout; |
| 94 | inlink->planar = abuffer->packing_format; | ||
| 95 | inlink->sample_rate = abuffer->sample_rate; | 93 | inlink->sample_rate = abuffer->sample_rate; |
| 96 | 94 | ||
| 97 | filt_ctx->filter->uninit(filt_ctx); | 95 | filt_ctx->filter->uninit(filt_ctx); |
| @@ -239,14 +237,12 @@ static int check_format_change_audio(AVFilterContext *ctx, · 141 unmodified lines | |||
| 239 | 237 | ||
| 240 | link = ctx->outputs[0]; | 238 | link = ctx->outputs[0]; |
| 241 | if (samplesref->format != link->format || | 239 | if (samplesref->format != link->format || |
| 242 | samplesref->audio->channel_layout != link->channel_layout || | 240 | samplesref->audio->channel_layout != link->channel_layout) { |
| 243 | samplesref->audio->planar != link->planar) { | ||
| 244 | 241 | ||
| 245 | if (!logged) log_input_change(ctx, link, samplesref); | 242 | if (!logged) log_input_change(ctx, link, samplesref); |
| 246 | 243 | ||
| 247 | abuffer->sample_format = samplesref->format; | 244 | abuffer->sample_format = samplesref->format; |
| 248 | abuffer->channel_layout = samplesref->audio->channel_layout; | 245 | abuffer->channel_layout = samplesref->audio->channel_layout; |
| 249 | abuffer->packing_format = samplesref->audio->planar; | ||
| 250 | 246 | ||
| 251 | if (!abuffer->aconvert) { | 247 | if (!abuffer->aconvert) { |
| 252 | ret = insert_filter(abuffer, link, &abuffer->aconvert, "aconvert"); | 248 | ret = insert_filter(abuffer, link, &abuffer->aconvert, "aconvert"); |
| @@ -254,9 +250,7 @@ static int check_format_change_audio(AVFilterContext *ctx, · 1 unmodified line | |||
| 254 | } else { | 250 | } else { |
| 255 | link = abuffer->aconvert->outputs[0]; | 251 | link = abuffer->aconvert->outputs[0]; |
| 256 | if (samplesref->format == link->format && | 252 | if (samplesref->format == link->format && |
| 257 | samplesref->audio->channel_layout == link->channel_layout && | 253 | samplesref->audio->channel_layout == link->channel_layout) |
| 258 | samplesref->audio->planar == link->planar | ||
| 259 | ) | ||
| 260 | remove_filter(&abuffer->aconvert); | 254 | remove_filter(&abuffer->aconvert); |
| 261 | else | 255 | else |
| 262 | if ((ret = reconfigure_filter(abuffer, abuffer->aconvert)) < 0) | 256 | if ((ret = reconfigure_filter(abuffer, abuffer->aconvert)) < 0) |
| @@ -456,7 +450,6 @@ static av_cold int init_audio(AVFilterContext *ctx, const char *args0, void *opa · 193 unmodified lines | |||
| 456 | ADD_FORMAT(sample_rate); | 450 | ADD_FORMAT(sample_rate); |
| 457 | ADD_FORMAT(sample_format); | 451 | ADD_FORMAT(sample_format); |
| 458 | ADD_FORMAT(channel_layout); | 452 | ADD_FORMAT(channel_layout); |
| 459 | ADD_FORMAT(packing_format); | ||
| 460 | 453 | ||
| 461 | abuffer->fifo = av_fifo_alloc(FIFO_SIZE*sizeof(AVFilterBufferRef*)); | 454 | abuffer->fifo = av_fifo_alloc(FIFO_SIZE*sizeof(AVFilterBufferRef*)); |
| 462 | if (!abuffer->fifo) { | 455 | if (!abuffer->fifo) { |
| @@ -475,7 +468,7 @@ static av_cold int init_audio(AVFilterContext *ctx, const char *args0, void *opa · 12 unmodified lines | |||
| 475 | 468 | ||
| 476 | arg_fail: | 469 | arg_fail: |
| 477 | av_log(ctx, AV_LOG_ERROR, "Invalid arguments, must be of the form " | 470 | av_log(ctx, AV_LOG_ERROR, "Invalid arguments, must be of the form " |
| 478 | "sample_rate:sample_fmt:channel_layout:packing\n"); | 471 | "sample_rate:sample_fmt:channel_layout\n"); |
| 479 | av_freep(&args); | 472 | av_freep(&args); |
| 480 | return AVERROR(EINVAL); | 473 | return AVERROR(EINVAL); |
| 481 | } | 474 | } |
| @@ -517,10 +510,6 @@ static int query_formats_audio(AVFilterContext *ctx) · 35 unmodified lines | |||
| 517 | ff_add_channel_layout(&layouts, abuffer->channel_layout); | 510 | ff_add_channel_layout(&layouts, abuffer->channel_layout); |
| 518 | ff_set_common_channel_layouts(ctx, layouts); | 511 | ff_set_common_channel_layouts(ctx, layouts); |
| 519 | 512 | ||
| 520 | formats = NULL; | ||
| 521 | avfilter_add_format(&formats, abuffer->packing_format); | ||
| 522 | avfilter_set_common_packing_formats(ctx, formats); | ||
| 523 | |||
| 524 | return 0; | 513 | return 0; |
| 525 | } | 514 | } |
| 526 | 515 | ||
| @@ -370,13 +370,11 @@ static int amovie_query_formats(AVFilterContext *ctx) · 369 unmodified lines | |||
| 370 | AVCodecContext *c = movie->codec_ctx; | 370 | AVCodecContext *c = movie->codec_ctx; |
| 371 | 371 | ||
| 372 | enum AVSampleFormat sample_fmts[] = { c->sample_fmt, -1 }; | 372 | enum AVSampleFormat sample_fmts[] = { c->sample_fmt, -1 }; |
| 373 | int packing_fmts[] = { AVFILTER_PACKED, -1 }; | ||
| 374 | int sample_rates[] = { c->sample_rate, -1 }; | 373 | int sample_rates[] = { c->sample_rate, -1 }; |
| 375 | int64_t chlayouts[] = { c->channel_layout ? c->channel_layout : | 374 | int64_t chlayouts[] = { c->channel_layout ? c->channel_layout : |
| 376 | av_get_default_channel_layout(c->channels), -1 }; | 375 | av_get_default_channel_layout(c->channels), -1 }; |
| 377 | 376 | ||
| 378 | avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts)); | 377 | avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts)); |
| 379 | avfilter_set_common_packing_formats(ctx, avfilter_make_format_list(packing_fmts)); | ||
| 380 | ff_set_common_samplerates (ctx, avfilter_make_format_list(sample_rates)); | 378 | ff_set_common_samplerates (ctx, avfilter_make_format_list(sample_rates)); |
| 381 | ff_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts)); | 379 | ff_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts)); |
| 382 | 380 | ||
| @@ -53,5 +53,8 @@ · 52 unmodified lines | |||
| 53 | #ifndef FF_API_VSRC_BUFFER_ADD_FRAME | 53 | #ifndef FF_API_VSRC_BUFFER_ADD_FRAME |
| 54 | #define FF_API_VSRC_BUFFER_ADD_FRAME (LIBAVFILTER_VERSION_MAJOR < 3) | 54 | #define FF_API_VSRC_BUFFER_ADD_FRAME (LIBAVFILTER_VERSION_MAJOR < 3) |
| 55 | #endif | 55 | #endif |
| 56 | #ifndef FF_API_PACKING | ||
| 57 | #define FF_API_PACKING (LIBAVFILTER_VERSION_MAJOR < 3) | ||
| 58 | #endif | ||
| 56 | 59 | ||
| 57 | #endif // AVFILTER_VERSION_H | 60 | #endif // AVFILTER_VERSION_H |
| @@ -53,14 +53,6 @@ static void print_formats(AVFilterContext *filter_ctx) · 52 unmodified lines | |||
| 53 | fmts->formats[j]); \ | 53 | fmts->formats[j]); \ |
| 54 | printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \ | 54 | printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \ |
| 55 | i, filter_ctx->filter->inout##puts[i].name, buf); \ | 55 | i, filter_ctx->filter->inout##puts[i].name, buf); \ |
| 56 | } \ | ||
| 57 | \ | ||
| 58 | fmts = filter_ctx->inout##puts[i]->outin##_packing; \ | ||
| 59 | for (j = 0; j < fmts->format_count; j++) { \ | ||
| 60 | printf(#INOUT "PUT[%d] %s: packing:%s\n", \ | ||
| 61 | i, filter_ctx->filter->inout##puts[i].name, \ | ||
| 62 | fmts->formats[j] == AVFILTER_PACKED ? \ | ||
| 63 | "packed" : "planar"); \ | ||
| 64 | } \ | 56 | } \ |
| 65 | } \ | 57 | } \ |
| 66 | } \ | 58 | } \ |