[FFmpeg-soc] [soc]: r4737 - in afilters: af_null.c af_src.c avfilter.c dummy.c

Vitor Sessak vitor1001 at gmail.com
Wed Jul 22 06:05:21 CEST 2009


kdub wrote:
> Author: kdub
> Date: Tue Jul 21 10:38:11 2009
> New Revision: 4737
> 
> Log:
> Add accepted pcm formats to my 3 filters
> 
> Modified:
>    afilters/af_null.c
>    afilters/af_src.c
>    afilters/avfilter.c
>    afilters/dummy.c
> 
> Modified: afilters/af_null.c
> ==============================================================================
> --- afilters/af_null.c	Tue Jul 21 01:42:11 2009	(r4736)
> +++ afilters/af_null.c	Tue Jul 21 10:38:11 2009	(r4737)
> @@ -24,7 +24,10 @@
>  
>  #include <stdio.h>
>  #include "avfilter.h"
> +
>  static int null_filter(AVFilterLink *link, AVFilterBufferRef *sample_ref);
> +static int query_af_null_formats(AVFilterContext *ctx);
> +static int init_af_null(AVFilterContext *ctx, const char *args, void *opaque);
>  
>  typedef struct
>  {
> @@ -32,6 +35,7 @@ typedef struct
>  
>  } af_null_priv_t;
>  
> +
>  AVFilter avfilter_af_null =
>  {
>      .name      = "audio_null",
> @@ -46,8 +50,38 @@ AVFilter avfilter_af_null =
>      .outputs   = (AVFilterPad[]) {{ .name            = "default",
>                                      .type            = CODEC_TYPE_AUDIO, },
>                                    { .name = NULL}},
> +
> +    .init = init_af_null,
> +    .query_formats = query_af_null_formats,
>  };


Adding a init_af_null() method and adding a query_formats() method 
should belong to two separated commits

> +
> +static int init_af_null(AVFilterContext *ctx, const char *args, void *opaque)
> +{
> +    printf("init afnull\n");
> +    int i;
> +    af_null_priv_t * p;
> +    ctx->priv = av_mallocz(sizeof(af_null_priv_t));

It is better to design the filter framework in a way that this is 
automatically done by the framework, to avoid duplicating this field in 
every filter (note that this is also done in all video filters).

> +    p = (af_null_priv_t*) ctx->priv;
> +    for (i=0; i<100; i++)
> +       p->history[i] = i;
> +
> +    return 0;
> +}

> +
> +static int query_af_null_formats(AVFilterContext *ctx)
> +{
> +    av_log(0,0, "query formats\n");
> +
> +    AVFilterFormats *formats;
> +    formats = avfilter_make_format_list(3, CODEC_ID_PCM_S16LE,
> +                                            CODEC_ID_PCM_S16BE,
> +                                            CODEC_ID_PCM_F32LE);
> +    avfilter_set_common_formats(ctx,formats);
> +
> +    return 0;
> +}

Looks good, but isn't the number of channels part of the format?

-Vitor


More information about the FFmpeg-soc mailing list