[FFmpeg-devel] [PATCH] avfilter/trim: support all channel numbers in atrim filter

Paul B Mahol onemda at gmail.com
Wed Dec 30 10:14:23 CET 2015


On 12/30/15, Clement Boesch <u at pkh.me> wrote:
> On Wed, Dec 30, 2015 at 09:17:56AM +0100, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>>  libavfilter/trim.c | 27 +++++++++++++++++++++++++++
>>  1 file changed, 27 insertions(+)
>>
>> diff --git a/libavfilter/trim.c b/libavfilter/trim.c
>> index b2d9c6f..9d040dd 100644
>> --- a/libavfilter/trim.c
>> +++ b/libavfilter/trim.c
>> @@ -345,6 +345,32 @@ drop:
>>      return 0;
>>  }
>>
>> +static int atrim_query_formats(AVFilterContext *ctx)
>> +{
>> +    AVFilterFormats *formats;
>> +    AVFilterChannelLayouts *layouts;
>> +    int ret;
>> +
>> +    layouts = ff_all_channel_counts();
>> +    if (!layouts)
>> +        return AVERROR(ENOMEM);
>> +    ret = ff_set_common_channel_layouts(ctx, layouts);
>> +    if (ret < 0)
>> +        return ret;
>> +
>> +    formats = ff_all_formats(AVMEDIA_TYPE_AUDIO);
>> +    if (!formats)
>> +        return AVERROR(ENOMEM);
>> +    ret = ff_set_common_formats(ctx, formats);
>> +    if (ret < 0)
>> +        return ret;
>> +
>> +    formats = ff_all_samplerates();
>> +    if (!formats)
>> +        return AVERROR(ENOMEM);
>> +    return ff_set_common_samplerates(ctx, formats);
>> +}
>> +
>>  #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
>>  static const AVOption atrim_options[] = {
>>      COMMON_OPTS
>> @@ -381,6 +407,7 @@ AVFilter ff_af_atrim = {
>>      .name        = "atrim",
>>      .description = NULL_IF_CONFIG_SMALL("Pick one continuous section from
>> the input, drop the rest."),
>>      .init        = init,
>> +    .query_formats = atrim_query_formats,
>>      .priv_size   = sizeof(TrimContext),
>>      .priv_class  = &atrim_class,
>>      .inputs      = atrim_inputs,
>
> Mmmh... It seems we have ff_query_formats_all(); can you use that?
>
> Q: why is it not the default?
>

The all channel counts layout?

> --
> Clement B.
>


More information about the ffmpeg-devel mailing list