[FFmpeg-soc] [soc]: r4390 - in afilters: Makefile.dummy af_null.c avfilter.c avfilter.h dummy.c

Vitor Sessak vitor1001 at gmail.com
Mon Jun 8 22:17:51 CEST 2009


kdub wrote:
> Author: kdub
> Date: Mon Jun  8 06:02:12 2009
> New Revision: 4390
> 
> Log:
> Constructs for afilters, null filter example, standalone testing program w/ makefile
> 
> Added:
>    afilters/Makefile.dummy
>    afilters/af_null.c
>    afilters/dummy.c
> Modified:
>    afilters/avfilter.c
>    afilters/avfilter.h
> 
> Added: afilters/Makefile.dummy
> ==============================================================================
> --- /dev/null	00:00:00 1970	(empty, because file is newly added)
> +++ afilters/Makefile.dummy	Mon Jun  8 06:02:12 2009	(r4390)
> @@ -0,0 +1,4 @@
> +
> +
> +all:
> +	gcc dummy.c -o dummy -I./ffmpeg -lm ./ffmpeg/libav*/libav*.a
> 
> Added: afilters/af_null.c
> ==============================================================================
> --- /dev/null	00:00:00 1970	(empty, because file is newly added)
> +++ afilters/af_null.c	Mon Jun  8 06:02:12 2009	(r4390)
> @@ -0,0 +1,61 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +/**
> + * @file libavfilter/vf_null.c
> + * null filter
> + */
> +
> +#include <stdio.h>
> +#include "avfilter.h"
> +
> +
> +typedef struct
> +{
> +    int history[100]; /*just an example */
> +
> +
> +} af_null_priv_t;
> +
> +
> +static int start_buf(AVFilterLink *link)
> +{
> +    return;
> +}
> +
> +static int end_buf(AVFilterLink *link)
> +{
> +    return;
> +}
> +
> +AVFilter avfilter_af_null =
> +{
> +    .name      = "audio_null",
> +
> +    .priv_size = sizeof(af_null_priv_t),
> +
> +    .inputs    = (AVFilterPad[]) {{ .name            = "default",
> +                                    .type            = CODEC_TYPE_AUDIO,
> +                                    .start_buffer    = start_buf,
> +                                    .end_buffer      = end_buf },
> +                                  { .name = NULL}},
> +
> +    .outputs   = (AVFilterPad[]) {{ .name            = "default",
> +                                    .type            = CODEC_TYPE_AUDIO, },
> +                                  { .name = NULL}},
> +};
> 
> Modified: afilters/avfilter.c
> ==============================================================================
> --- afilters/avfilter.c	Sun Jun  7 20:19:38 2009	(r4389)
> +++ afilters/avfilter.c	Mon Jun  8 06:02:12 2009	(r4390)
> @@ -69,6 +69,8 @@ void avfilter_insert_pad(unsigned idx, u
>      (*links)[idx] = NULL;
>  
>      (*count) ++;
> +
> +    av_log(0,0,"%x %x\n", idx, *count);
>      for(i = idx+1; i < *count; i ++)
>          if(*links[i])
>              (*(unsigned *)((uint8_t *) *links[i] + padidx_off)) ++;
> @@ -297,6 +299,7 @@ AVFilter *avfilter_get_by_name(const cha
>      return NULL;
>  }
>  
> +/* does not work, nonrobust logic? */
>  void avfilter_register(AVFilter *filter)
>  {
>      struct FilterList *newfilt = av_malloc(sizeof(struct FilterList));
> @@ -318,9 +321,12 @@ void avfilter_uninit(void)
>  
>  static int pad_count(const AVFilterPad *pads)
>  {
> -    int count;
> +    if (!pads)
> +        return 0;
>  
> +    int count;
>      for(count = 0; pads->name; count ++) pads ++;
> +    av_log(0,0,"count is: %i\n", count);
>      return count;
>  }

I think you cannot declare a var after an if() without at least GCC 2.95 
complaining.

> Modified: afilters/avfilter.h
> ==============================================================================
> --- afilters/avfilter.h	Sun Jun  7 20:19:38 2009	(r4389)
> +++ afilters/avfilter.h	Mon Jun  8 06:02:12 2009	(r4390)
> @@ -101,6 +101,20 @@ typedef struct AVFilterPicRef
>  #define AV_PERM_REUSE2   0x10   ///< can output the buffer multiple times, modified each time
>  } AVFilterPicRef;
>  
> +
> +typedef struct AVFilterSamples
> +{
> +    /* data */
> +    void *data;

I think it is better to declare it uint8_t, so you can write code like:

/* advance data N samples */
data += N << bits_per_sample;

> +    int *n_samples;
> +
> +    void *priv;
> +    void (*free)(struct AVFilterSamples *samples)
> +
> +}AVFilterSamples;
> +
> +
> +
>  /**
>   * Adds a new reference to a picture.
>   * @param ref   an existing reference to the picture
> @@ -345,6 +359,17 @@ struct AVFilterPad
>       * and another value on error.
>       */
>      int (*config_props)(AVFilterLink *link);
> +
> +
> +    /**
> +     * Process an audio buffer. This function is where the audio filter should
> +     * recieve and process data

recEIve

> +     */
> +    int (*start_buffer)(AVFilterLink *link);
> +
> +    int (*end_buffer)(AVFilterLink *link);
> +
> +
>  };

@Michael: If you are going to complain of having start_buffer() for 
audio and start_frame() for video, this it the best time for it.

-Vitor


More information about the FFmpeg-soc mailing list