[FFmpeg-devel] [PATCH] [RFC] Bitstream filtering API in libavformat

Michael Niedermayer michaelni
Tue May 5 13:29:56 CEST 2009


On Fri, Mar 20, 2009 at 01:57:26AM -0700, Baptiste Coudurier wrote:
> Hi,
> 
> Here is an attempt at creating an API to enable bitstream filtering when
> demuxing and muxing.
> 
> Demuxing example for mov.
> 
> I believe the API should be suitable for muxing too.
> 
> Please tell me what you think about it. Any suggestion welcome, for
> field and function names as well.
> 
> -- 
> Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
> Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
> checking for life_signs in -lkenny... no
> FFmpeg maintainer                                  http://www.ffmpeg.org

>  avformat.h |   11 ++++++++
>  mov.c      |    7 +++++
>  utils.c    |   81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 99 insertions(+)
> 087a871e7351ced0ef2bf3cd546545120233d042  bsf_api.patch
> Index: libavformat/avformat.h
> ===================================================================
> --- libavformat/avformat.h	(revision 18065)
> +++ libavformat/avformat.h	(working copy)
> @@ -529,6 +529,17 @@
>       * AV_NOPTS_VALUE by default.
>       */
>      int64_t reference_dts;

> +    /**
> +     * Bitstream needs bitfiltering, this can be set when muxing or demuxing
> +     * by demuxer or muxer or user
> +     *
> +     * Represents a list of successive bitstream filters.
> +     */
> +    int disable_bsfiltering;              ///< set to explicitly disable bistream filtering

ive not tried but i think doxygen would associate both these coments
to disable_bsfiltering

also disable_bsfiltering is never written to, thus useless


> +    int bsfilters_num;                    ///< number of bitstream filters
> +    const char **bsfilters_names;
> +    AVBitStreamFilterContext **bsfilters;
> +    int bsfilters_inited;                 ///< bitstream filters are initialized
>  } AVStream;
>  
>  #define AV_PROGRAM_RUNNING 1

> Index: libavformat/utils.c
> ===================================================================
> --- libavformat/utils.c	(revision 18065)
> +++ libavformat/utils.c	(working copy)
> @@ -937,6 +937,78 @@
>      pkt->data = NULL; pkt->size = 0;
>  }
>  
> +int ff_stream_add_bitstream_filter(AVFormatContext *s, AVStream *st,
> +                                   const char *name)
> +{
> +    AVBitStreamFilterContext **bsfilters;
> +    const char **bsfilters_names;
> +
> +    if (st->bsfilters_num >= UINT_MAX / sizeof(*st->bsfilters))
> +        return AVERROR(ENOMEM);

> +    bsfilters = av_realloc(st->bsfilters, (st->bsfilters_num+1)*
> +                           sizeof(*bsfilters));
> +    if (!bsfilters)
> +        return AVERROR(ENOMEM);
> +    bsfilters_names = av_realloc(st->bsfilters_names, (st->bsfilters_num+1)*
> +                                 sizeof(*bsfilters_names));
> +    if (!bsfilters_names)
> +        return AVERROR(ENOMEM);

memleak


> +    st->bsfilters = bsfilters;
> +    st->bsfilters_names = bsfilters_names;
> +    st->bsfilters_names[st->bsfilters_num] = name;
> +    st->bsfilters_num++;
> +
> +    return 0;
> +}
> +
> +static int ff_stream_bitstream_filters_init(AVFormatContext *s, AVStream *st)
> +{

why the split between add & init ?

also i think we need a way for the user to change these filters from the
ffmpeg/ffplay command line


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090505/48ea4ad8/attachment.pgp>



More information about the ffmpeg-devel mailing list