[FFmpeg-devel] [PATCH] avcodec/bsf: Add FFBitStreamFilter, hide internals of BSFs

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Mar 23 14:05:49 EET 2022


Andreas Rheinhardt:
> This patch is analogous to 20f972701806be20a77f808db332d9489343bb78:
> It hides the internal part of AVBitStreamFilter by adding a new
> internal structure FFBitStreamFilter (declared in bsf_internal.h)
> that has an AVBitStreamFilter as its first member; the internal
> part of AVBitStreamFilter is moved to this new structure.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  configure                              |  4 +-
>  libavcodec/aac_adtstoasc_bsf.c         |  6 +-
>  libavcodec/av1_frame_merge_bsf.c       |  6 +-
>  libavcodec/av1_frame_split_bsf.c       |  6 +-
>  libavcodec/av1_metadata_bsf.c          |  9 +--
>  libavcodec/bitstream_filters.c         | 85 +++++++++++++-------------
>  libavcodec/bsf.c                       | 38 ++++++------
>  libavcodec/bsf.h                       | 14 -----
>  libavcodec/bsf_internal.h              | 13 ++++
>  libavcodec/cbs_bsf.h                   |  6 +-
>  libavcodec/chomp_bsf.c                 |  4 +-
>  libavcodec/dca_core_bsf.c              |  8 +--
>  libavcodec/dump_extradata_bsf.c        |  6 +-
>  libavcodec/dv_error_marker_bsf.c       |  8 +--
>  libavcodec/eac3_core_bsf.c             |  8 +--
>  libavcodec/extract_extradata_bsf.c     |  8 +--
>  libavcodec/filter_units_bsf.c          |  8 +--
>  libavcodec/h264_metadata_bsf.c         |  9 +--
>  libavcodec/h264_mp4toannexb_bsf.c      |  6 +-
>  libavcodec/h264_redundant_pps_bsf.c    |  7 ++-
>  libavcodec/h265_metadata_bsf.c         |  9 +--
>  libavcodec/hapqa_extract_bsf.c         | 10 +--
>  libavcodec/hevc_mp4toannexb_bsf.c      |  6 +-
>  libavcodec/imx_dump_header_bsf.c       |  8 +--
>  libavcodec/mjpeg2jpeg_bsf.c            |  6 +-
>  libavcodec/mjpega_dump_header_bsf.c    |  8 +--
>  libavcodec/movsub_bsf.c                |  8 +--
>  libavcodec/mp3_header_decompress_bsf.c |  8 +--
>  libavcodec/mpeg2_metadata_bsf.c        | 10 +--
>  libavcodec/mpeg4_unpack_bframes_bsf.c  |  6 +-
>  libavcodec/noise_bsf.c                 |  7 +--
>  libavcodec/null_bsf.c                  |  5 +-
>  libavcodec/opus_metadata_bsf.c         |  8 +--
>  libavcodec/pcm_rechunk_bsf.c           |  8 +--
>  libavcodec/prores_metadata_bsf.c       | 12 ++--
>  libavcodec/remove_extradata_bsf.c      |  6 +-
>  libavcodec/setts_bsf.c                 |  6 +-
>  libavcodec/trace_headers_bsf.c         |  6 +-
>  libavcodec/truehd_core_bsf.c           |  6 +-
>  libavcodec/vp9_metadata_bsf.c          | 12 ++--
>  libavcodec/vp9_raw_reorder_bsf.c       |  6 +-
>  libavcodec/vp9_superframe_bsf.c        |  6 +-
>  libavcodec/vp9_superframe_split_bsf.c  |  6 +-
>  43 files changed, 219 insertions(+), 213 deletions(-)
> 
> diff --git a/configure b/configure
> index a7953ffc16..e4d36aa639 100755
> --- a/configure
> +++ b/configure
> @@ -3992,7 +3992,7 @@ CODEC_LIST="
>      $DECODER_LIST
>  "
>  PARSER_LIST=$(find_things_extern parser AVCodecParser libavcodec/parsers.c)
> -BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c)
> +BSF_LIST=$(find_things_extern bsf FFBitStreamFilter libavcodec/bitstream_filters.c)
>  HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h)
>  PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c)
>  
> @@ -7869,7 +7869,7 @@ print_enabled_components(){
>  print_enabled_components libavfilter/filter_list.c AVFilter filter_list $FILTER_LIST
>  print_enabled_components libavcodec/codec_list.c FFCodec codec_list $CODEC_LIST
>  print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $PARSER_LIST
> -print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST
> +print_enabled_components libavcodec/bsf_list.c FFBitStreamFilter bitstream_filters $BSF_LIST
>  print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list $DEMUXER_LIST
>  print_enabled_components libavformat/muxer_list.c AVOutputFormat muxer_list $MUXER_LIST
>  print_enabled_components libavdevice/indev_list.c AVInputFormat indev_list $INDEV_LIST
> diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c
> index 267ef97572..d32fcc5f9d 100644
> --- a/libavcodec/aac_adtstoasc_bsf.c
> +++ b/libavcodec/aac_adtstoasc_bsf.c
> @@ -148,10 +148,10 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_AAC, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_aac_adtstoasc_bsf = {
> -    .name           = "aac_adtstoasc",
> +const FFBitStreamFilter ff_aac_adtstoasc_bsf = {
> +    .p.name         = "aac_adtstoasc",
> +    .p.codec_ids    = codec_ids,
>      .priv_data_size = sizeof(AACBSFContext),
>      .init           = aac_adtstoasc_init,
>      .filter         = aac_adtstoasc_filter,
> -    .codec_ids      = codec_ids,
>  };
> diff --git a/libavcodec/av1_frame_merge_bsf.c b/libavcodec/av1_frame_merge_bsf.c
> index 19b9cd01a8..4c54f2167e 100644
> --- a/libavcodec/av1_frame_merge_bsf.c
> +++ b/libavcodec/av1_frame_merge_bsf.c
> @@ -156,12 +156,12 @@ static const enum AVCodecID av1_frame_merge_codec_ids[] = {
>      AV_CODEC_ID_AV1, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_av1_frame_merge_bsf = {
> -    .name           = "av1_frame_merge",
> +const FFBitStreamFilter ff_av1_frame_merge_bsf = {
> +    .p.name         = "av1_frame_merge",
> +    .p.codec_ids    = av1_frame_merge_codec_ids,
>      .priv_data_size = sizeof(AV1FMergeContext),
>      .init           = av1_frame_merge_init,
>      .flush          = av1_frame_merge_flush,
>      .close          = av1_frame_merge_close,
>      .filter         = av1_frame_merge_filter,
> -    .codec_ids      = av1_frame_merge_codec_ids,
>  };
> diff --git a/libavcodec/av1_frame_split_bsf.c b/libavcodec/av1_frame_split_bsf.c
> index fa8b887b6c..5f6a40316c 100644
> --- a/libavcodec/av1_frame_split_bsf.c
> +++ b/libavcodec/av1_frame_split_bsf.c
> @@ -250,12 +250,12 @@ static const enum AVCodecID av1_frame_split_codec_ids[] = {
>      AV_CODEC_ID_AV1, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_av1_frame_split_bsf = {
> -    .name           = "av1_frame_split",
> +const FFBitStreamFilter ff_av1_frame_split_bsf = {
> +    .p.name         = "av1_frame_split",
> +    .p.codec_ids    = av1_frame_split_codec_ids,
>      .priv_data_size = sizeof(AV1FSplitContext),
>      .init           = av1_frame_split_init,
>      .flush          = av1_frame_split_flush,
>      .close          = av1_frame_split_close,
>      .filter         = av1_frame_split_filter,
> -    .codec_ids      = av1_frame_split_codec_ids,
>  };
> diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
> index c52673bf6a..41b02cc836 100644
> --- a/libavcodec/av1_metadata_bsf.c
> +++ b/libavcodec/av1_metadata_bsf.c
> @@ -20,6 +20,7 @@
>  #include "libavutil/opt.h"
>  
>  #include "bsf.h"
> +#include "bsf_internal.h"
>  #include "cbs.h"
>  #include "cbs_bsf.h"
>  #include "cbs_av1.h"
> @@ -219,12 +220,12 @@ static const enum AVCodecID av1_metadata_codec_ids[] = {
>      AV_CODEC_ID_AV1, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_av1_metadata_bsf = {
> -    .name           = "av1_metadata",
> +const FFBitStreamFilter ff_av1_metadata_bsf = {
> +    .p.name         = "av1_metadata",
> +    .p.codec_ids    = av1_metadata_codec_ids,
> +    .p.priv_class   = &av1_metadata_class,
>      .priv_data_size = sizeof(AV1MetadataContext),
> -    .priv_class     = &av1_metadata_class,
>      .init           = &av1_metadata_init,
>      .close          = &ff_cbs_bsf_generic_close,
>      .filter         = &ff_cbs_bsf_generic_filter,
> -    .codec_ids      = av1_metadata_codec_ids,
>  };
> diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
> index ab27972a88..f117bc0e17 100644
> --- a/libavcodec/bitstream_filters.c
> +++ b/libavcodec/bitstream_filters.c
> @@ -24,56 +24,57 @@
>  #include "bsf.h"
>  #include "bsf_internal.h"
>  
> -extern const AVBitStreamFilter ff_aac_adtstoasc_bsf;
> -extern const AVBitStreamFilter ff_av1_frame_merge_bsf;
> -extern const AVBitStreamFilter ff_av1_frame_split_bsf;
> -extern const AVBitStreamFilter ff_av1_metadata_bsf;
> -extern const AVBitStreamFilter ff_chomp_bsf;
> -extern const AVBitStreamFilter ff_dump_extradata_bsf;
> -extern const AVBitStreamFilter ff_dca_core_bsf;
> -extern const AVBitStreamFilter ff_dv_error_marker_bsf;
> -extern const AVBitStreamFilter ff_eac3_core_bsf;
> -extern const AVBitStreamFilter ff_extract_extradata_bsf;
> -extern const AVBitStreamFilter ff_filter_units_bsf;
> -extern const AVBitStreamFilter ff_h264_metadata_bsf;
> -extern const AVBitStreamFilter ff_h264_mp4toannexb_bsf;
> -extern const AVBitStreamFilter ff_h264_redundant_pps_bsf;
> -extern const AVBitStreamFilter ff_hapqa_extract_bsf;
> -extern const AVBitStreamFilter ff_hevc_metadata_bsf;
> -extern const AVBitStreamFilter ff_hevc_mp4toannexb_bsf;
> -extern const AVBitStreamFilter ff_imx_dump_header_bsf;
> -extern const AVBitStreamFilter ff_mjpeg2jpeg_bsf;
> -extern const AVBitStreamFilter ff_mjpega_dump_header_bsf;
> -extern const AVBitStreamFilter ff_mp3_header_decompress_bsf;
> -extern const AVBitStreamFilter ff_mpeg2_metadata_bsf;
> -extern const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf;
> -extern const AVBitStreamFilter ff_mov2textsub_bsf;
> -extern const AVBitStreamFilter ff_noise_bsf;
> -extern const AVBitStreamFilter ff_null_bsf;
> -extern const AVBitStreamFilter ff_opus_metadata_bsf;
> -extern const AVBitStreamFilter ff_pcm_rechunk_bsf;
> -extern const AVBitStreamFilter ff_prores_metadata_bsf;
> -extern const AVBitStreamFilter ff_remove_extradata_bsf;
> -extern const AVBitStreamFilter ff_setts_bsf;
> -extern const AVBitStreamFilter ff_text2movsub_bsf;
> -extern const AVBitStreamFilter ff_trace_headers_bsf;
> -extern const AVBitStreamFilter ff_truehd_core_bsf;
> -extern const AVBitStreamFilter ff_vp9_metadata_bsf;
> -extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf;
> -extern const AVBitStreamFilter ff_vp9_superframe_bsf;
> -extern const AVBitStreamFilter ff_vp9_superframe_split_bsf;
> +extern const FFBitStreamFilter ff_aac_adtstoasc_bsf;
> +extern const FFBitStreamFilter ff_av1_frame_merge_bsf;
> +extern const FFBitStreamFilter ff_av1_frame_split_bsf;
> +extern const FFBitStreamFilter ff_av1_metadata_bsf;
> +extern const FFBitStreamFilter ff_chomp_bsf;
> +extern const FFBitStreamFilter ff_dump_extradata_bsf;
> +extern const FFBitStreamFilter ff_dca_core_bsf;
> +extern const FFBitStreamFilter ff_dv_error_marker_bsf;
> +extern const FFBitStreamFilter ff_eac3_core_bsf;
> +extern const FFBitStreamFilter ff_extract_extradata_bsf;
> +extern const FFBitStreamFilter ff_filter_units_bsf;
> +extern const FFBitStreamFilter ff_h264_metadata_bsf;
> +extern const FFBitStreamFilter ff_h264_mp4toannexb_bsf;
> +extern const FFBitStreamFilter ff_h264_redundant_pps_bsf;
> +extern const FFBitStreamFilter ff_hapqa_extract_bsf;
> +extern const FFBitStreamFilter ff_hevc_metadata_bsf;
> +extern const FFBitStreamFilter ff_hevc_mp4toannexb_bsf;
> +extern const FFBitStreamFilter ff_imx_dump_header_bsf;
> +extern const FFBitStreamFilter ff_mjpeg2jpeg_bsf;
> +extern const FFBitStreamFilter ff_mjpega_dump_header_bsf;
> +extern const FFBitStreamFilter ff_mp3_header_decompress_bsf;
> +extern const FFBitStreamFilter ff_mpeg2_metadata_bsf;
> +extern const FFBitStreamFilter ff_mpeg4_unpack_bframes_bsf;
> +extern const FFBitStreamFilter ff_mov2textsub_bsf;
> +extern const FFBitStreamFilter ff_noise_bsf;
> +extern const FFBitStreamFilter ff_null_bsf;
> +extern const FFBitStreamFilter ff_opus_metadata_bsf;
> +extern const FFBitStreamFilter ff_pcm_rechunk_bsf;
> +extern const FFBitStreamFilter ff_prores_metadata_bsf;
> +extern const FFBitStreamFilter ff_remove_extradata_bsf;
> +extern const FFBitStreamFilter ff_setts_bsf;
> +extern const FFBitStreamFilter ff_text2movsub_bsf;
> +extern const FFBitStreamFilter ff_trace_headers_bsf;
> +extern const FFBitStreamFilter ff_truehd_core_bsf;
> +extern const FFBitStreamFilter ff_vp9_metadata_bsf;
> +extern const FFBitStreamFilter ff_vp9_raw_reorder_bsf;
> +extern const FFBitStreamFilter ff_vp9_superframe_bsf;
> +extern const FFBitStreamFilter ff_vp9_superframe_split_bsf;
>  
>  #include "libavcodec/bsf_list.c"
>  
>  const AVBitStreamFilter *av_bsf_iterate(void **opaque)
>  {
>      uintptr_t i = (uintptr_t)*opaque;
> -    const AVBitStreamFilter *f = bitstream_filters[i];
> +    const FFBitStreamFilter *f = bitstream_filters[i];
>  
> -    if (f)
> +    if (f) {
>          *opaque = (void*)(i + 1);
> -
> -    return f;
> +        return &f->p;
> +    }
> +    return NULL;
>  }
>  
>  const AVBitStreamFilter *av_bsf_get_by_name(const char *name)
> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> index 60761e6f7d..42cc1b5ab0 100644
> --- a/libavcodec/bsf.c
> +++ b/libavcodec/bsf.c
> @@ -18,7 +18,6 @@
>  
>  #include <string.h>
>  
> -#include "config.h"
>  #include "config_components.h"
>  
>  #include "libavutil/avassert.h"
> @@ -35,6 +34,11 @@
>  
>  #define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems)
>  
> +static av_always_inline const FFBitStreamFilter *ff_bsf(const AVBitStreamFilter *bsf)
> +{
> +    return (const FFBitStreamFilter*)bsf;
> +}
> +
>  typedef struct FFBSFContext {
>      AVBSFContext pub;
>      AVPacket *buffer_pkt;
> @@ -57,8 +61,8 @@ void av_bsf_free(AVBSFContext **pctx)
>      bsfi = ffbsfcontext(ctx);
>  
>      if (ctx->priv_data) {
> -        if (ctx->filter->close)
> -            ctx->filter->close(ctx);
> +        if (ff_bsf(ctx->filter)->close)
> +            ff_bsf(ctx->filter)->close(ctx);
>          if (ctx->filter->priv_class)
>              av_opt_free(ctx->priv_data);
>          av_freep(&ctx->priv_data);
> @@ -119,8 +123,8 @@ int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
>          goto fail;
>      }
>      /* allocate priv data and init private options */
> -    if (filter->priv_data_size) {
> -        ctx->priv_data = av_mallocz(filter->priv_data_size);
> +    if (ff_bsf(filter)->priv_data_size) {
> +        ctx->priv_data = av_mallocz(ff_bsf(filter)->priv_data_size);
>          if (!ctx->priv_data) {
>              ret = AVERROR(ENOMEM);
>              goto fail;
> @@ -175,8 +179,8 @@ int av_bsf_init(AVBSFContext *ctx)
>  
>      ctx->time_base_out = ctx->time_base_in;
>  
> -    if (ctx->filter->init) {
> -        ret = ctx->filter->init(ctx);
> +    if (ff_bsf(ctx->filter)->init) {
> +        ret = ff_bsf(ctx->filter)->init(ctx);
>          if (ret < 0)
>              return ret;
>      }
> @@ -192,8 +196,8 @@ void av_bsf_flush(AVBSFContext *ctx)
>  
>      av_packet_unref(bsfi->buffer_pkt);
>  
> -    if (ctx->filter->flush)
> -        ctx->filter->flush(ctx);
> +    if (ff_bsf(ctx->filter)->flush)
> +        ff_bsf(ctx->filter)->flush(ctx);
>  }
>  
>  int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
> @@ -226,7 +230,7 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
>  
>  int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
>  {
> -    return ctx->filter->filter(ctx, pkt);
> +    return ff_bsf(ctx->filter)->filter(ctx, pkt);
>  }
>  
>  int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
> @@ -399,10 +403,10 @@ static const AVClass bsf_list_class = {
>          .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -static const AVBitStreamFilter list_bsf = {
> -        .name           = "bsf_list",
> +static const FFBitStreamFilter list_bsf = {
> +        .p.name         = "bsf_list",
> +        .p.priv_class   = &bsf_list_class,
>          .priv_data_size = sizeof(BSFListContext),
> -        .priv_class     = &bsf_list_class,
>          .init           = bsf_list_init,
>          .filter         = bsf_list_filter,
>          .flush          = bsf_list_flush,
> @@ -495,7 +499,7 @@ int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf)
>          goto end;
>      }
>  
> -    ret = av_bsf_alloc(&list_bsf, bsf);
> +    ret = av_bsf_alloc(&list_bsf.p, bsf);
>      if (ret < 0)
>          return ret;
>  
> @@ -550,9 +554,9 @@ end:
>  int av_bsf_get_null_filter(AVBSFContext **bsf)
>  {
>  #if CONFIG_NULL_BSF
> -    extern const AVBitStreamFilter ff_null_bsf;
> -    return av_bsf_alloc(&ff_null_bsf, bsf);
> +    extern const FFBitStreamFilter ff_null_bsf;
> +    return av_bsf_alloc(&ff_null_bsf.p, bsf);
>  #else
> -    return av_bsf_alloc(&list_bsf, bsf);
> +    return av_bsf_alloc(&list_bsf.p, bsf);
>  #endif
>  }
> diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h
> index 611beab885..69d91a16ab 100644
> --- a/libavcodec/bsf.h
> +++ b/libavcodec/bsf.h
> @@ -128,20 +128,6 @@ typedef struct AVBitStreamFilter {
>       * code to this class.
>       */
>      const AVClass *priv_class;
> -
> -    /*****************************************************************
> -     * No fields below this line are part of the public API. They
> -     * may not be used outside of libavcodec and can be changed and
> -     * removed at will.
> -     * New public fields should be added right above.
> -     *****************************************************************
> -     */
> -
> -    int priv_data_size;
> -    int (*init)(AVBSFContext *ctx);
> -    int (*filter)(AVBSFContext *ctx, AVPacket *pkt);
> -    void (*close)(AVBSFContext *ctx);
> -    void (*flush)(AVBSFContext *ctx);
>  } AVBitStreamFilter;
>  
>  /**
> diff --git a/libavcodec/bsf_internal.h b/libavcodec/bsf_internal.h
> index 06979fdaa3..922b03c01b 100644
> --- a/libavcodec/bsf_internal.h
> +++ b/libavcodec/bsf_internal.h
> @@ -24,6 +24,19 @@
>  #include "bsf.h"
>  #include "packet.h"
>  
> +typedef struct FFBitStreamFilter {
> +    /**
> +     * The public AVBitStreamFilter. See bsf.h for it.
> +     */
> +    AVBitStreamFilter p;
> +
> +    int priv_data_size;
> +    int (*init)(AVBSFContext *ctx);
> +    int (*filter)(AVBSFContext *ctx, AVPacket *pkt);
> +    void (*close)(AVBSFContext *ctx);
> +    void (*flush)(AVBSFContext *ctx);
> +} FFBitStreamFilter;
> +
>  /**
>   * Called by the bitstream filters to get the next packet for filtering.
>   * The filter is responsible for either freeing the packet or passing it to the
> diff --git a/libavcodec/cbs_bsf.h b/libavcodec/cbs_bsf.h
> index a370be1b5f..aa7385c8f2 100644
> --- a/libavcodec/cbs_bsf.h
> +++ b/libavcodec/cbs_bsf.h
> @@ -67,7 +67,7 @@ typedef struct CBSBSFContext {
>   *
>   * Since it calls the update_fragment() function immediately to deal with
>   * extradata, this should be called after any codec-specific setup is done
> - * (probably at the end of the AVBitStreamFilter.init function).
> + * (probably at the end of the FFBitStreamFilter.init function).
>   */
>  int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type);
>  
> @@ -75,7 +75,7 @@ int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type);
>   * Close a generic CBS BSF instance.
>   *
>   * If no other deinitialisation is required then this function can be used
> - * directly as AVBitStreamFilter.close.
> + * directly as FFBitStreamFilter.close.
>   */
>  void ff_cbs_bsf_generic_close(AVBSFContext *bsf);
>  
> @@ -88,7 +88,7 @@ void ff_cbs_bsf_generic_close(AVBSFContext *bsf);
>   * the same thing to that new extradata to form the output side-data first.
>   *
>   * If the BSF does not do anything else then this function can be used
> - * directly as AVBitStreamFilter.filter.
> + * directly as FFBitStreamFilter.filter.
>   */
>  int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt);
>  
> diff --git a/libavcodec/chomp_bsf.c b/libavcodec/chomp_bsf.c
> index 48b9336466..532b4e6a94 100644
> --- a/libavcodec/chomp_bsf.c
> +++ b/libavcodec/chomp_bsf.c
> @@ -39,7 +39,7 @@ static int chomp_filter(AVBSFContext *ctx, AVPacket *pkt)
>  /**
>   * This filter removes a string of NULL bytes from the end of a packet.
>   */
> -const AVBitStreamFilter ff_chomp_bsf = {
> -    .name   = "chomp",
> +const FFBitStreamFilter ff_chomp_bsf = {
> +    .p.name = "chomp",
>      .filter = chomp_filter,
>  };
> diff --git a/libavcodec/dca_core_bsf.c b/libavcodec/dca_core_bsf.c
> index b92e6a1ba6..1a2db39cba 100644
> --- a/libavcodec/dca_core_bsf.c
> +++ b/libavcodec/dca_core_bsf.c
> @@ -54,8 +54,8 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_DTS, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_dca_core_bsf = {
> -    .name      = "dca_core",
> -    .filter    = dca_core_filter,
> -    .codec_ids = codec_ids,
> +const FFBitStreamFilter ff_dca_core_bsf = {
> +    .p.name      = "dca_core",
> +    .p.codec_ids = codec_ids,
> +    .filter      = dca_core_filter,
>  };
> diff --git a/libavcodec/dump_extradata_bsf.c b/libavcodec/dump_extradata_bsf.c
> index b6ef8b3e6b..5506d5ed65 100644
> --- a/libavcodec/dump_extradata_bsf.c
> +++ b/libavcodec/dump_extradata_bsf.c
> @@ -98,9 +98,9 @@ static const AVClass dump_extradata_class = {
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -const AVBitStreamFilter ff_dump_extradata_bsf = {
> -    .name           = "dump_extra",
> +const FFBitStreamFilter ff_dump_extradata_bsf = {
> +    .p.name         = "dump_extra",
> +    .p.priv_class   = &dump_extradata_class,
>      .priv_data_size = sizeof(DumpExtradataContext),
> -    .priv_class     = &dump_extradata_class,
>      .filter         = dump_extradata,
>  };
> diff --git a/libavcodec/dv_error_marker_bsf.c b/libavcodec/dv_error_marker_bsf.c
> index a2b9e09ce5..131c6fcbe6 100644
> --- a/libavcodec/dv_error_marker_bsf.c
> +++ b/libavcodec/dv_error_marker_bsf.c
> @@ -128,11 +128,11 @@ static const AVClass dv_error_marker_class = {
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -const AVBitStreamFilter ff_dv_error_marker_bsf = {
> -    .name           = "dv_error_marker",
> +const FFBitStreamFilter ff_dv_error_marker_bsf = {
> +    .p.name         = "dv_error_marker",
> +    .p.codec_ids    = (const enum AVCodecID []){ AV_CODEC_ID_DVVIDEO, AV_CODEC_ID_NONE },
> +    .p.priv_class   = &dv_error_marker_class,
>      .priv_data_size = sizeof(DVErrorMarkerContext),
> -    .priv_class     = &dv_error_marker_class,
>      .init           = dv_error_marker_init,
>      .filter         = dv_error_marker_filter,
> -    .codec_ids      =  (const enum AVCodecID []){ AV_CODEC_ID_DVVIDEO, AV_CODEC_ID_NONE },
>  };
> diff --git a/libavcodec/eac3_core_bsf.c b/libavcodec/eac3_core_bsf.c
> index 49c3389ee1..1c714b18f9 100644
> --- a/libavcodec/eac3_core_bsf.c
> +++ b/libavcodec/eac3_core_bsf.c
> @@ -79,8 +79,8 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_EAC3, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_eac3_core_bsf = {
> -    .name      = "eac3_core",
> -    .filter    = eac3_core_filter,
> -    .codec_ids = codec_ids,
> +const FFBitStreamFilter ff_eac3_core_bsf = {
> +    .p.name      = "eac3_core",
> +    .p.codec_ids = codec_ids,
> +    .filter      = eac3_core_filter,
>  };
> diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
> index 027a578af1..329b1a6174 100644
> --- a/libavcodec/extract_extradata_bsf.c
> +++ b/libavcodec/extract_extradata_bsf.c
> @@ -422,11 +422,11 @@ static const AVClass extract_extradata_class = {
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -const AVBitStreamFilter ff_extract_extradata_bsf = {
> -    .name           = "extract_extradata",
> -    .codec_ids      = codec_ids,
> +const FFBitStreamFilter ff_extract_extradata_bsf = {
> +    .p.name         = "extract_extradata",
> +    .p.codec_ids    = codec_ids,
> +    .p.priv_class   = &extract_extradata_class,
>      .priv_data_size = sizeof(ExtractExtradataContext),
> -    .priv_class     = &extract_extradata_class,
>      .init           = extract_extradata_init,
>      .filter         = extract_extradata_filter,
>      .close          = extract_extradata_close,
> diff --git a/libavcodec/filter_units_bsf.c b/libavcodec/filter_units_bsf.c
> index 354594ac50..38756baf42 100644
> --- a/libavcodec/filter_units_bsf.c
> +++ b/libavcodec/filter_units_bsf.c
> @@ -235,12 +235,12 @@ static const AVClass filter_units_class = {
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -const AVBitStreamFilter ff_filter_units_bsf = {
> -    .name           = "filter_units",
> +const FFBitStreamFilter ff_filter_units_bsf = {
> +    .p.name         = "filter_units",
> +    .p.codec_ids    = ff_cbs_all_codec_ids,
> +    .p.priv_class   = &filter_units_class,
>      .priv_data_size = sizeof(FilterUnitsContext),
> -    .priv_class     = &filter_units_class,
>      .init           = &filter_units_init,
>      .close          = &filter_units_close,
>      .filter         = &filter_units_filter,
> -    .codec_ids      = ff_cbs_all_codec_ids,
>  };
> diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
> index 9df99cbae3..e905982d26 100644
> --- a/libavcodec/h264_metadata_bsf.c
> +++ b/libavcodec/h264_metadata_bsf.c
> @@ -22,6 +22,7 @@
>  #include "libavutil/opt.h"
>  
>  #include "bsf.h"
> +#include "bsf_internal.h"
>  #include "cbs.h"
>  #include "cbs_bsf.h"
>  #include "cbs_h264.h"
> @@ -716,12 +717,12 @@ static const enum AVCodecID h264_metadata_codec_ids[] = {
>      AV_CODEC_ID_H264, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_h264_metadata_bsf = {
> -    .name           = "h264_metadata",
> +const FFBitStreamFilter ff_h264_metadata_bsf = {
> +    .p.name         = "h264_metadata",
> +    .p.codec_ids    = h264_metadata_codec_ids,
> +    .p.priv_class   = &h264_metadata_class,
>      .priv_data_size = sizeof(H264MetadataContext),
> -    .priv_class     = &h264_metadata_class,
>      .init           = &h264_metadata_init,
>      .close          = &ff_cbs_bsf_generic_close,
>      .filter         = &ff_cbs_bsf_generic_filter,
> -    .codec_ids      = h264_metadata_codec_ids,
>  };
> diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c
> index 5a2656197e..d11be455c2 100644
> --- a/libavcodec/h264_mp4toannexb_bsf.c
> +++ b/libavcodec/h264_mp4toannexb_bsf.c
> @@ -312,11 +312,11 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_H264, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_h264_mp4toannexb_bsf = {
> -    .name           = "h264_mp4toannexb",
> +const FFBitStreamFilter ff_h264_mp4toannexb_bsf = {
> +    .p.name         = "h264_mp4toannexb",
> +    .p.codec_ids    = codec_ids,
>      .priv_data_size = sizeof(H264BSFContext),
>      .init           = h264_mp4toannexb_init,
>      .filter         = h264_mp4toannexb_filter,
>      .flush          = h264_mp4toannexb_flush,
> -    .codec_ids      = codec_ids,
>  };
> diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c
> index d64b064590..f8bab1f109 100644
> --- a/libavcodec/h264_redundant_pps_bsf.c
> +++ b/libavcodec/h264_redundant_pps_bsf.c
> @@ -21,6 +21,7 @@
>  #include "libavutil/log.h"
>  
>  #include "bsf.h"
> +#include "bsf_internal.h"
>  #include "cbs.h"
>  #include "cbs_bsf.h"
>  #include "cbs_h264.h"
> @@ -126,11 +127,11 @@ static const enum AVCodecID h264_redundant_pps_codec_ids[] = {
>      AV_CODEC_ID_H264, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_h264_redundant_pps_bsf = {
> -    .name           = "h264_redundant_pps",
> +const FFBitStreamFilter ff_h264_redundant_pps_bsf = {
> +    .p.name         = "h264_redundant_pps",
> +    .p.codec_ids    = h264_redundant_pps_codec_ids,
>      .priv_data_size = sizeof(H264RedundantPPSContext),
>      .init           = &h264_redundant_pps_init,
>      .close          = &ff_cbs_bsf_generic_close,
>      .filter         = &ff_cbs_bsf_generic_filter,
> -    .codec_ids      = h264_redundant_pps_codec_ids,
>  };
> diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
> index e5f70cfbc1..f01c8e4cd7 100644
> --- a/libavcodec/h265_metadata_bsf.c
> +++ b/libavcodec/h265_metadata_bsf.c
> @@ -20,6 +20,7 @@
>  #include "libavutil/opt.h"
>  
>  #include "bsf.h"
> +#include "bsf_internal.h"
>  #include "cbs.h"
>  #include "cbs_bsf.h"
>  #include "cbs_h265.h"
> @@ -498,12 +499,12 @@ static const enum AVCodecID h265_metadata_codec_ids[] = {
>      AV_CODEC_ID_HEVC, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_hevc_metadata_bsf = {
> -    .name           = "hevc_metadata",
> +const FFBitStreamFilter ff_hevc_metadata_bsf = {
> +    .p.name         = "hevc_metadata",
> +    .p.codec_ids    = h265_metadata_codec_ids,
> +    .p.priv_class   = &h265_metadata_class,
>      .priv_data_size = sizeof(H265MetadataContext),
> -    .priv_class     = &h265_metadata_class,
>      .init           = &h265_metadata_init,
>      .close          = &ff_cbs_bsf_generic_close,
>      .filter         = &ff_cbs_bsf_generic_filter,
> -    .codec_ids      = h265_metadata_codec_ids,
>  };
> diff --git a/libavcodec/hapqa_extract_bsf.c b/libavcodec/hapqa_extract_bsf.c
> index 1c8b0669b7..0d9b40aaa6 100644
> --- a/libavcodec/hapqa_extract_bsf.c
> +++ b/libavcodec/hapqa_extract_bsf.c
> @@ -125,10 +125,10 @@ static const AVClass hapqa_extract_class = {
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -const AVBitStreamFilter ff_hapqa_extract_bsf = {
> -    .name       = "hapqa_extract",
> -    .filter     = hapqa_extract,
> +const FFBitStreamFilter ff_hapqa_extract_bsf = {
> +    .p.name         = "hapqa_extract",
> +    .p.codec_ids    = codec_ids,
> +    .p.priv_class   = &hapqa_extract_class,
>      .priv_data_size = sizeof(HapqaExtractContext),
> -    .priv_class = &hapqa_extract_class,
> -    .codec_ids  = codec_ids,
> +    .filter         = hapqa_extract,
>  };
> diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c
> index 790dfb0394..f9a025a36b 100644
> --- a/libavcodec/hevc_mp4toannexb_bsf.c
> +++ b/libavcodec/hevc_mp4toannexb_bsf.c
> @@ -195,10 +195,10 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_HEVC, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_hevc_mp4toannexb_bsf = {
> -    .name           = "hevc_mp4toannexb",
> +const FFBitStreamFilter ff_hevc_mp4toannexb_bsf = {
> +    .p.name         = "hevc_mp4toannexb",
> +    .p.codec_ids    = codec_ids,
>      .priv_data_size = sizeof(HEVCBSFContext),
>      .init           = hevc_mp4toannexb_init,
>      .filter         = hevc_mp4toannexb_filter,
> -    .codec_ids      = codec_ids,
>  };
> diff --git a/libavcodec/imx_dump_header_bsf.c b/libavcodec/imx_dump_header_bsf.c
> index e2b6a15591..241415a0ef 100644
> --- a/libavcodec/imx_dump_header_bsf.c
> +++ b/libavcodec/imx_dump_header_bsf.c
> @@ -69,8 +69,8 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_imx_dump_header_bsf = {
> -    .name      = "imxdump",
> -    .filter    = imx_dump_header,
> -    .codec_ids = codec_ids,
> +const FFBitStreamFilter ff_imx_dump_header_bsf = {
> +    .p.name      = "imxdump",
> +    .p.codec_ids = codec_ids,
> +    .filter      = imx_dump_header,
>  };
> diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
> index 2a972a7c37..f545e9438d 100644
> --- a/libavcodec/mjpeg2jpeg_bsf.c
> +++ b/libavcodec/mjpeg2jpeg_bsf.c
> @@ -135,8 +135,8 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_MJPEG, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_mjpeg2jpeg_bsf = {
> -    .name           = "mjpeg2jpeg",
> +const FFBitStreamFilter ff_mjpeg2jpeg_bsf = {
> +    .p.name         = "mjpeg2jpeg",
> +    .p.codec_ids    = codec_ids,
>      .filter         = mjpeg2jpeg_filter,
> -    .codec_ids      = codec_ids,
>  };
> diff --git a/libavcodec/mjpega_dump_header_bsf.c b/libavcodec/mjpega_dump_header_bsf.c
> index ab68f9c3e9..d541084e74 100644
> --- a/libavcodec/mjpega_dump_header_bsf.c
> +++ b/libavcodec/mjpega_dump_header_bsf.c
> @@ -101,8 +101,8 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_MJPEG, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_mjpega_dump_header_bsf = {
> -    .name      = "mjpegadump",
> -    .filter    = mjpega_dump_header,
> -    .codec_ids = codec_ids,
> +const FFBitStreamFilter ff_mjpega_dump_header_bsf = {
> +    .p.name      = "mjpegadump",
> +    .p.codec_ids = codec_ids,
> +    .filter      = mjpega_dump_header,
>  };
> diff --git a/libavcodec/movsub_bsf.c b/libavcodec/movsub_bsf.c
> index 6e29fa8e50..a5125c7aff 100644
> --- a/libavcodec/movsub_bsf.c
> +++ b/libavcodec/movsub_bsf.c
> @@ -57,8 +57,8 @@ fail:
>      return ret;
>  }
>  
> -const AVBitStreamFilter ff_text2movsub_bsf = {
> -    .name   = "text2movsub",
> +const FFBitStreamFilter ff_text2movsub_bsf = {
> +    .p.name = "text2movsub",
>      .filter = text2movsub,
>  };
>  
> @@ -81,7 +81,7 @@ static int mov2textsub(AVBSFContext *ctx, AVPacket *pkt)
>      return 0;
>  }
>  
> -const AVBitStreamFilter ff_mov2textsub_bsf = {
> -    .name   = "mov2textsub",
> +const FFBitStreamFilter ff_mov2textsub_bsf = {
> +    .p.name = "mov2textsub",
>      .filter = mov2textsub,
>  };
> diff --git a/libavcodec/mp3_header_decompress_bsf.c b/libavcodec/mp3_header_decompress_bsf.c
> index 0fd8b3a454..a177029fe0 100644
> --- a/libavcodec/mp3_header_decompress_bsf.c
> +++ b/libavcodec/mp3_header_decompress_bsf.c
> @@ -123,8 +123,8 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_MP3, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_mp3_header_decompress_bsf = {
> -    .name      = "mp3decomp",
> -    .filter    = mp3_header_decompress,
> -    .codec_ids = codec_ids,
> +const FFBitStreamFilter ff_mp3_header_decompress_bsf = {
> +    .p.name      = "mp3decomp",
> +    .p.codec_ids = codec_ids,
> +    .filter      = mp3_header_decompress,
>  };
> diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c
> index 11b46c0ae3..1aa6e02791 100644
> --- a/libavcodec/mpeg2_metadata_bsf.c
> +++ b/libavcodec/mpeg2_metadata_bsf.c
> @@ -16,11 +16,11 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
>  
> -#include "libavutil/avstring.h"
>  #include "libavutil/common.h"
>  #include "libavutil/opt.h"
>  
>  #include "bsf.h"
> +#include "bsf_internal.h"
>  #include "cbs.h"
>  #include "cbs_bsf.h"
>  #include "cbs_mpeg2.h"
> @@ -232,12 +232,12 @@ static const enum AVCodecID mpeg2_metadata_codec_ids[] = {
>      AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_mpeg2_metadata_bsf = {
> -    .name           = "mpeg2_metadata",
> +const FFBitStreamFilter ff_mpeg2_metadata_bsf = {
> +    .p.name         = "mpeg2_metadata",
> +    .p.codec_ids    = mpeg2_metadata_codec_ids,
> +    .p.priv_class   = &mpeg2_metadata_class,
>      .priv_data_size = sizeof(MPEG2MetadataContext),
> -    .priv_class     = &mpeg2_metadata_class,
>      .init           = &mpeg2_metadata_init,
>      .close          = &ff_cbs_bsf_generic_close,
>      .filter         = &ff_cbs_bsf_generic_filter,
> -    .codec_ids      = mpeg2_metadata_codec_ids,
>  };
> diff --git a/libavcodec/mpeg4_unpack_bframes_bsf.c b/libavcodec/mpeg4_unpack_bframes_bsf.c
> index ae2c129d88..5493dafa97 100644
> --- a/libavcodec/mpeg4_unpack_bframes_bsf.c
> +++ b/libavcodec/mpeg4_unpack_bframes_bsf.c
> @@ -155,12 +155,12 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_MPEG4, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf = {
> -    .name           = "mpeg4_unpack_bframes",
> +const FFBitStreamFilter ff_mpeg4_unpack_bframes_bsf = {
> +    .p.name         = "mpeg4_unpack_bframes",
> +    .p.codec_ids    = codec_ids,
>      .priv_data_size = sizeof(UnpackBFramesBSFContext),
>      .init           = mpeg4_unpack_bframes_init,
>      .filter         = mpeg4_unpack_bframes_filter,
>      .flush          = mpeg4_unpack_bframes_close_flush,
>      .close          = mpeg4_unpack_bframes_close_flush,
> -    .codec_ids      = codec_ids,
>  };
> diff --git a/libavcodec/noise_bsf.c b/libavcodec/noise_bsf.c
> index 05b5d5f32b..168f3aa373 100644
> --- a/libavcodec/noise_bsf.c
> +++ b/libavcodec/noise_bsf.c
> @@ -23,7 +23,6 @@
>  #include "bsf.h"
>  #include "bsf_internal.h"
>  
> -#include "libavutil/avstring.h"
>  #include "libavutil/log.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/eval.h"
> @@ -220,10 +219,10 @@ static const AVClass noise_class = {
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -const AVBitStreamFilter ff_noise_bsf = {
> -    .name           = "noise",
> +const FFBitStreamFilter ff_noise_bsf = {
> +    .p.name         = "noise",
> +    .p.priv_class   = &noise_class,
>      .priv_data_size = sizeof(NoiseContext),
> -    .priv_class     = &noise_class,
>      .init           = noise_init,
>      .close          = noise_close,
>      .filter         = noise,
> diff --git a/libavcodec/null_bsf.c b/libavcodec/null_bsf.c
> index 595945027d..28237076fb 100644
> --- a/libavcodec/null_bsf.c
> +++ b/libavcodec/null_bsf.c
> @@ -21,10 +21,9 @@
>   * Null bitstream filter -- pass the input through unchanged.
>   */
>  
> -#include "bsf.h"
>  #include "bsf_internal.h"
>  
> -const AVBitStreamFilter ff_null_bsf = {
> -    .name           = "null",
> +const FFBitStreamFilter ff_null_bsf = {
> +    .p.name         = "null",
>      .filter         = ff_bsf_get_packet_ref,
>  };
> diff --git a/libavcodec/opus_metadata_bsf.c b/libavcodec/opus_metadata_bsf.c
> index e73852d618..2a0f86cec3 100644
> --- a/libavcodec/opus_metadata_bsf.c
> +++ b/libavcodec/opus_metadata_bsf.c
> @@ -58,11 +58,11 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_OPUS, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_opus_metadata_bsf = {
> -    .name           = "opus_metadata",
> +const FFBitStreamFilter ff_opus_metadata_bsf = {
> +    .p.name         = "opus_metadata",
> +    .p.codec_ids    = codec_ids,
> +    .p.priv_class   = &opus_metadata_class,
>      .priv_data_size = sizeof(OpusBSFContext),
> -    .priv_class     = &opus_metadata_class,
>      .init           = &opus_metadata_init,
>      .filter         = &ff_bsf_get_packet_ref,
> -    .codec_ids      = codec_ids,
>  };
> diff --git a/libavcodec/pcm_rechunk_bsf.c b/libavcodec/pcm_rechunk_bsf.c
> index 80727a1a91..108d9e90b9 100644
> --- a/libavcodec/pcm_rechunk_bsf.c
> +++ b/libavcodec/pcm_rechunk_bsf.c
> @@ -209,13 +209,13 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_pcm_rechunk_bsf = {
> -    .name           = "pcm_rechunk",
> +const FFBitStreamFilter ff_pcm_rechunk_bsf = {
> +    .p.name         = "pcm_rechunk",
> +    .p.codec_ids    = codec_ids,
> +    .p.priv_class   = &pcm_rechunk_class,
>      .priv_data_size = sizeof(PCMContext),
> -    .priv_class     = &pcm_rechunk_class,
>      .filter         = rechunk_filter,
>      .init           = init,
>      .flush          = flush,
>      .close          = uninit,
> -    .codec_ids      = codec_ids,
>  };
> diff --git a/libavcodec/prores_metadata_bsf.c b/libavcodec/prores_metadata_bsf.c
> index d971243a8b..fb001b38d7 100644
> --- a/libavcodec/prores_metadata_bsf.c
> +++ b/libavcodec/prores_metadata_bsf.c
> @@ -166,11 +166,11 @@ static const AVClass prores_metadata_class = {
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -const AVBitStreamFilter ff_prores_metadata_bsf = {
> -    .name       = "prores_metadata",
> -    .init       = prores_metadata_init,
> -    .filter     = prores_metadata,
> +const FFBitStreamFilter ff_prores_metadata_bsf = {
> +    .p.name         = "prores_metadata",
> +    .p.codec_ids    = codec_ids,
> +    .p.priv_class   = &prores_metadata_class,
>      .priv_data_size = sizeof(ProresMetadataContext),
> -    .priv_class = &prores_metadata_class,
> -    .codec_ids  = codec_ids,
> +    .init           = prores_metadata_init,
> +    .filter         = prores_metadata,
>  };
> diff --git a/libavcodec/remove_extradata_bsf.c b/libavcodec/remove_extradata_bsf.c
> index c698d1d7f9..66b7d00bd8 100644
> --- a/libavcodec/remove_extradata_bsf.c
> +++ b/libavcodec/remove_extradata_bsf.c
> @@ -245,9 +245,9 @@ static const AVClass remove_extradata_class = {
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -const AVBitStreamFilter ff_remove_extradata_bsf = {
> -    .name           = "remove_extra",
> +const FFBitStreamFilter ff_remove_extradata_bsf = {
> +    .p.name         = "remove_extra",
> +    .p.priv_class   = &remove_extradata_class,
>      .priv_data_size = sizeof(RemoveExtradataContext),
> -    .priv_class     = &remove_extradata_class,
>      .filter         = remove_extradata,
>  };
> diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c
> index fadf63bc54..9c27b24a39 100644
> --- a/libavcodec/setts_bsf.c
> +++ b/libavcodec/setts_bsf.c
> @@ -267,10 +267,10 @@ static const AVClass setts_class = {
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>  
> -const AVBitStreamFilter ff_setts_bsf = {
> -    .name           = "setts",
> +const FFBitStreamFilter ff_setts_bsf = {
> +    .p.name         = "setts",
> +    .p.priv_class   = &setts_class,
>      .priv_data_size = sizeof(SetTSContext),
> -    .priv_class     = &setts_class,
>      .init           = setts_init,
>      .close          = setts_close,
>      .filter         = setts_filter,
> diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
> index 96a52fac53..028b0a1e59 100644
> --- a/libavcodec/trace_headers_bsf.c
> +++ b/libavcodec/trace_headers_bsf.c
> @@ -117,11 +117,11 @@ static int trace_headers(AVBSFContext *bsf, AVPacket *pkt)
>      return err;
>  }
>  
> -const AVBitStreamFilter ff_trace_headers_bsf = {
> -    .name           = "trace_headers",
> +const FFBitStreamFilter ff_trace_headers_bsf = {
> +    .p.name         = "trace_headers",
> +    .p.codec_ids    = ff_cbs_all_codec_ids,
>      .priv_data_size = sizeof(TraceHeadersContext),
>      .init           = &trace_headers_init,
>      .close          = &trace_headers_close,
>      .filter         = &trace_headers,
> -    .codec_ids      = ff_cbs_all_codec_ids,
>  };
> diff --git a/libavcodec/truehd_core_bsf.c b/libavcodec/truehd_core_bsf.c
> index cc2779cc2e..ee1060b021 100644
> --- a/libavcodec/truehd_core_bsf.c
> +++ b/libavcodec/truehd_core_bsf.c
> @@ -173,10 +173,10 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_TRUEHD, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_truehd_core_bsf = {
> -    .name           = "truehd_core",
> +const FFBitStreamFilter ff_truehd_core_bsf = {
> +    .p.name         = "truehd_core",
> +    .p.codec_ids    = codec_ids,
>      .priv_data_size = sizeof(TrueHDCoreContext),
>      .filter         = truehd_core_filter,
>      .flush          = truehd_core_flush,
> -    .codec_ids      = codec_ids,
>  };
> diff --git a/libavcodec/vp9_metadata_bsf.c b/libavcodec/vp9_metadata_bsf.c
> index d904a0088d..40d1b21c67 100644
> --- a/libavcodec/vp9_metadata_bsf.c
> +++ b/libavcodec/vp9_metadata_bsf.c
> @@ -16,11 +16,11 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
>  
> -#include "libavutil/avstring.h"
> -#include "libavutil/common.h"
> +#include "libavutil/log.h"
>  #include "libavutil/opt.h"
>  
>  #include "bsf.h"
> +#include "bsf_internal.h"
>  #include "cbs.h"
>  #include "cbs_bsf.h"
>  #include "cbs_vp9.h"
> @@ -135,12 +135,12 @@ static const enum AVCodecID vp9_metadata_codec_ids[] = {
>      AV_CODEC_ID_VP9, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_vp9_metadata_bsf = {
> -    .name           = "vp9_metadata",
> +const FFBitStreamFilter ff_vp9_metadata_bsf = {
> +    .p.name         = "vp9_metadata",
> +    .p.codec_ids    = vp9_metadata_codec_ids,
> +    .p.priv_class   = &vp9_metadata_class,
>      .priv_data_size = sizeof(VP9MetadataContext),
> -    .priv_class     = &vp9_metadata_class,
>      .init           = &vp9_metadata_init,
>      .close          = &ff_cbs_bsf_generic_close,
>      .filter         = &ff_cbs_bsf_generic_filter,
> -    .codec_ids      = vp9_metadata_codec_ids,
>  };
> diff --git a/libavcodec/vp9_raw_reorder_bsf.c b/libavcodec/vp9_raw_reorder_bsf.c
> index 6562399159..f98752c775 100644
> --- a/libavcodec/vp9_raw_reorder_bsf.c
> +++ b/libavcodec/vp9_raw_reorder_bsf.c
> @@ -408,11 +408,11 @@ static const enum AVCodecID vp9_raw_reorder_codec_ids[] = {
>      AV_CODEC_ID_VP9, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_vp9_raw_reorder_bsf = {
> -    .name           = "vp9_raw_reorder",
> +const FFBitStreamFilter ff_vp9_raw_reorder_bsf = {
> +    .p.name         = "vp9_raw_reorder",
> +    .p.codec_ids    = vp9_raw_reorder_codec_ids,
>      .priv_data_size = sizeof(VP9RawReorderContext),
>      .close          = &vp9_raw_reorder_close,
>      .flush          = &vp9_raw_reorder_flush,
>      .filter         = &vp9_raw_reorder_filter,
> -    .codec_ids      = vp9_raw_reorder_codec_ids,
>  };
> diff --git a/libavcodec/vp9_superframe_bsf.c b/libavcodec/vp9_superframe_bsf.c
> index 57681e29e4..349d43d62e 100644
> --- a/libavcodec/vp9_superframe_bsf.c
> +++ b/libavcodec/vp9_superframe_bsf.c
> @@ -211,12 +211,12 @@ static const enum AVCodecID codec_ids[] = {
>      AV_CODEC_ID_VP9, AV_CODEC_ID_NONE,
>  };
>  
> -const AVBitStreamFilter ff_vp9_superframe_bsf = {
> -    .name           = "vp9_superframe",
> +const FFBitStreamFilter ff_vp9_superframe_bsf = {
> +    .p.name         = "vp9_superframe",
> +    .p.codec_ids    = codec_ids,
>      .priv_data_size = sizeof(VP9BSFContext),
>      .filter         = vp9_superframe_filter,
>      .init           = vp9_superframe_init,
>      .flush          = vp9_superframe_flush,
>      .close          = vp9_superframe_close,
> -    .codec_ids      = codec_ids,
>  };
> diff --git a/libavcodec/vp9_superframe_split_bsf.c b/libavcodec/vp9_superframe_split_bsf.c
> index ed0444561a..2a068a6898 100644
> --- a/libavcodec/vp9_superframe_split_bsf.c
> +++ b/libavcodec/vp9_superframe_split_bsf.c
> @@ -155,12 +155,12 @@ static void vp9_superframe_split_uninit(AVBSFContext *ctx)
>      av_packet_free(&s->buffer_pkt);
>  }
>  
> -const AVBitStreamFilter ff_vp9_superframe_split_bsf = {
> -    .name = "vp9_superframe_split",
> +const FFBitStreamFilter ff_vp9_superframe_split_bsf = {
> +    .p.name         = "vp9_superframe_split",
> +    .p.codec_ids    = (const enum AVCodecID []){ AV_CODEC_ID_VP9, AV_CODEC_ID_NONE },
>      .priv_data_size = sizeof(VP9SFSplitContext),
>      .init           = vp9_superframe_split_init,
>      .flush          = vp9_superframe_split_flush,
>      .close          = vp9_superframe_split_uninit,
>      .filter         = vp9_superframe_split_filter,
> -    .codec_ids      = (const enum AVCodecID []){ AV_CODEC_ID_VP9, AV_CODEC_ID_NONE },
>  };

Will apply this tomorrow unless there are objections.

- Andreas


More information about the ffmpeg-devel mailing list