[03/14] cbs: Add a table of all supported codec IDs

Message ID 20190504121427.9638-4-lu_zero@gentoo.org
State New
Headers show
Series
  • [01/14] maint: Ignore dot dirs
Related show

Commit Message

Luca Barbato May 4, 2019, 12:14 p.m.
From: Mark Thompson <sw@jkqxz.net>

Use it as the set of codec IDs supported by the trace_headers BSF.
---
 configure                      |  2 +-
 libavcodec/cbs.c               | 13 +++++++++++++
 libavcodec/cbs.h               |  8 ++++++++
 libavcodec/trace_headers_bsf.c |  9 +--------
 4 files changed, 23 insertions(+), 9 deletions(-)

Comments

Alexandra Hájková May 13, 2019, 8:39 a.m. | #1
On Sat, May 4, 2019 at 2:14 PM Luca Barbato <lu_zero@gentoo.org> wrote:
>
> From: Mark Thompson <sw@jkqxz.net>
>
> Use it as the set of codec IDs supported by the trace_headers BSF.
> ---
>  configure                      |  2 +-
>  libavcodec/cbs.c               | 13 +++++++++++++
>  libavcodec/cbs.h               |  8 ++++++++
>  libavcodec/trace_headers_bsf.c |  9 +--------
>  4 files changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/configure b/configure
> index 8c46a870c4..7b5df4df29 100755
> --- a/configure
> +++ b/configure
> @@ -2365,7 +2365,7 @@ h264_redundant_pps_bsf_select="cbs_h264"
>  hevc_metadata_bsf_select="cbs_h265"
>  mjpeg2jpeg_bsf_select="jpegtables"
>  mpeg2_metadata_bsf_select="cbs_mpeg2"
> -trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
> +trace_headers_bsf_select="cbs"
>
>  # external libraries
>  avisynth_deps="LoadLibrary"
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 04ad2dfc41..c5c5b98d24 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -40,6 +40,19 @@ static const CodedBitstreamType *cbs_type_table[] = {
>  #endif
>  };
>
> +const enum AVCodecID ff_cbs_all_codec_ids[] = {
> +#if CONFIG_CBS_H264
> +    AV_CODEC_ID_H264,
> +#endif
> +#if CONFIG_CBS_H265
> +    AV_CODEC_ID_HEVC,
> +#endif
> +#if CONFIG_CBS_MPEG2
> +    AV_CODEC_ID_MPEG2VIDEO,
> +#endif
> +    AV_CODEC_ID_NONE
> +};
> +
>  int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
>                  enum AVCodecID codec_id, void *log_ctx)
>  {
> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
> index 6505386708..1f26be7b36 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -202,6 +202,14 @@ typedef struct CodedBitstreamContext {
>
>
>  /**
> + * Table of all supported codec IDs.
> + *
> + * Terminated by AV_CODEC_ID_NONE.
> + */
> +extern const enum AVCodecID ff_cbs_all_codec_ids[];
> +
> +
> +/**
>   * Create and initialise a new context for the given codec.
>   */
>  int ff_cbs_init(CodedBitstreamContext **ctx,
> diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
> index 9c97dd4cea..4494bd4553 100644
> --- a/libavcodec/trace_headers_bsf.c
> +++ b/libavcodec/trace_headers_bsf.c
> @@ -109,18 +109,11 @@ static int trace_headers(AVBSFContext *bsf, AVPacket *out)
>      return 0;
>  }
>
> -static const enum AVCodecID trace_headers_codec_ids[] = {
> -    AV_CODEC_ID_H264,
> -    AV_CODEC_ID_HEVC,
> -    AV_CODEC_ID_MPEG2VIDEO,
> -    AV_CODEC_ID_NONE,
> -};
> -
>  const AVBitStreamFilter ff_trace_headers_bsf = {
>      .name           = "trace_headers",
>      .priv_data_size = sizeof(TraceHeadersContext),
>      .init           = &trace_headers_init,
>      .close          = &trace_headers_close,
>      .filter         = &trace_headers,
> -    .codec_ids      = trace_headers_codec_ids,
> +    .codec_ids      = ff_cbs_all_codec_ids,
>  };
> --
> 2.12.2
>

OK

Patch

diff --git a/configure b/configure
index 8c46a870c4..7b5df4df29 100755
--- a/configure
+++ b/configure
@@ -2365,7 +2365,7 @@  h264_redundant_pps_bsf_select="cbs_h264"
 hevc_metadata_bsf_select="cbs_h265"
 mjpeg2jpeg_bsf_select="jpegtables"
 mpeg2_metadata_bsf_select="cbs_mpeg2"
-trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
+trace_headers_bsf_select="cbs"
 
 # external libraries
 avisynth_deps="LoadLibrary"
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 04ad2dfc41..c5c5b98d24 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -40,6 +40,19 @@  static const CodedBitstreamType *cbs_type_table[] = {
 #endif
 };
 
+const enum AVCodecID ff_cbs_all_codec_ids[] = {
+#if CONFIG_CBS_H264
+    AV_CODEC_ID_H264,
+#endif
+#if CONFIG_CBS_H265
+    AV_CODEC_ID_HEVC,
+#endif
+#if CONFIG_CBS_MPEG2
+    AV_CODEC_ID_MPEG2VIDEO,
+#endif
+    AV_CODEC_ID_NONE
+};
+
 int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
                 enum AVCodecID codec_id, void *log_ctx)
 {
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 6505386708..1f26be7b36 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -202,6 +202,14 @@  typedef struct CodedBitstreamContext {
 
 
 /**
+ * Table of all supported codec IDs.
+ *
+ * Terminated by AV_CODEC_ID_NONE.
+ */
+extern const enum AVCodecID ff_cbs_all_codec_ids[];
+
+
+/**
  * Create and initialise a new context for the given codec.
  */
 int ff_cbs_init(CodedBitstreamContext **ctx,
diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
index 9c97dd4cea..4494bd4553 100644
--- a/libavcodec/trace_headers_bsf.c
+++ b/libavcodec/trace_headers_bsf.c
@@ -109,18 +109,11 @@  static int trace_headers(AVBSFContext *bsf, AVPacket *out)
     return 0;
 }
 
-static const enum AVCodecID trace_headers_codec_ids[] = {
-    AV_CODEC_ID_H264,
-    AV_CODEC_ID_HEVC,
-    AV_CODEC_ID_MPEG2VIDEO,
-    AV_CODEC_ID_NONE,
-};
-
 const AVBitStreamFilter ff_trace_headers_bsf = {
     .name           = "trace_headers",
     .priv_data_size = sizeof(TraceHeadersContext),
     .init           = &trace_headers_init,
     .close          = &trace_headers_close,
     .filter         = &trace_headers,
-    .codec_ids      = trace_headers_codec_ids,
+    .codec_ids      = ff_cbs_all_codec_ids,
 };