diff mbox

[FFmpeg-devel,7/8] cbs: Add a table of all supported codec IDs

Message ID 20180311183021.25556-7-sw@jkqxz.net
State New
Headers show

Commit Message

Mark Thompson March 11, 2018, 6:30 p.m. UTC
Use it as the set of codec IDs supported by the trace_headers BSF.
---
 configure                      |  1 -
 libavcodec/cbs.c               | 13 +++++++++++++
 libavcodec/cbs.h               |  8 ++++++++
 libavcodec/trace_headers_bsf.c |  9 +--------
 4 files changed, 22 insertions(+), 9 deletions(-)

Comments

James Almer March 11, 2018, 7:04 p.m. UTC | #1
On 3/11/2018 3:30 PM, Mark Thompson wrote:
> Use it as the set of codec IDs supported by the trace_headers BSF.
> ---
>  configure                      |  1 -
>  libavcodec/cbs.c               | 13 +++++++++++++
>  libavcodec/cbs.h               |  8 ++++++++
>  libavcodec/trace_headers_bsf.c |  9 +--------
>  4 files changed, 22 insertions(+), 9 deletions(-)
> 
> diff --git a/configure b/configure
> index 5e38bdab17..95354611ff 100755
> --- a/configure
> +++ b/configure
> @@ -2905,7 +2905,6 @@ 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"

It should at least select cbs, otherwise linking will fail if no other
module using cbs is enabled.

>  
>  # external libraries
>  aac_at_decoder_deps="audiotoolbox"
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 62f60be437..897e0bb28e 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_H265,
> +#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 396ff0faec..402eb39e00 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -201,6 +201,14 @@ typedef struct CodedBitstreamContext {
>  } 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.
>   */
> diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
> index 93d04cb509..f742e36d77 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,
>  };
> 

Should be ok assuming the bsf API is ok with a filter reporting only
ID_NONE as supported codec (I don't think any filter currently does
that, but i didn't check).
Mark Thompson March 11, 2018, 7:31 p.m. UTC | #2
On 11/03/18 19:04, James Almer wrote:
> On 3/11/2018 3:30 PM, Mark Thompson wrote:
>> Use it as the set of codec IDs supported by the trace_headers BSF.
>> ---
>>  configure                      |  1 -
>>  libavcodec/cbs.c               | 13 +++++++++++++
>>  libavcodec/cbs.h               |  8 ++++++++
>>  libavcodec/trace_headers_bsf.c |  9 +--------
>>  4 files changed, 22 insertions(+), 9 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 5e38bdab17..95354611ff 100755
>> --- a/configure
>> +++ b/configure
>> @@ -2905,7 +2905,6 @@ 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"
> 
> It should at least select cbs, otherwise linking will fail if no other
> module using cbs is enabled.

Yes, it should.  Fixed locally.

>>  
>>  # external libraries
>>  aac_at_decoder_deps="audiotoolbox"
>> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
>> index 62f60be437..897e0bb28e 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_H265,
>> +#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 396ff0faec..402eb39e00 100644
>> --- a/libavcodec/cbs.h
>> +++ b/libavcodec/cbs.h
>> @@ -201,6 +201,14 @@ typedef struct CodedBitstreamContext {
>>  } 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.
>>   */
>> diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
>> index 93d04cb509..f742e36d77 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,
>>  };
>>
> 
> Should be ok assuming the bsf API is ok with a filter reporting only
> ID_NONE as supported codec (I don't think any filter currently does
> that, but i didn't check).

It is.  (And you correctly always get the "Codec 'h264' (27) is not supported by the bitstream filter ..." message when trying to use it in that case.)

Thanks,

- Mark
diff mbox

Patch

diff --git a/configure b/configure
index 5e38bdab17..95354611ff 100755
--- a/configure
+++ b/configure
@@ -2905,7 +2905,6 @@  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"
 
 # external libraries
 aac_at_decoder_deps="audiotoolbox"
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 62f60be437..897e0bb28e 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_H265,
+#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 396ff0faec..402eb39e00 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -201,6 +201,14 @@  typedef struct CodedBitstreamContext {
 } 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.
  */
diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
index 93d04cb509..f742e36d77 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,
 };