[FFmpeg-devel] [PATCH 23/41] avcodec/ac3enc: Deduplicate AVClasses

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu Jun 17 05:31:44 EEST 2021


The child_class_next API relied on different (de)muxers to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/ac3enc.c       |  7 +++++++
 libavcodec/ac3enc.h       |  1 +
 libavcodec/ac3enc_fixed.c |  9 +--------
 libavcodec/ac3enc_float.c | 10 +---------
 4 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 0036f7d8bc..034aa0beb9 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -125,6 +125,13 @@ const AVOption ff_ac3_enc_options[] = {
 {NULL}
 };
 
+const AVClass ff_ac3enc_class = {
+    .class_name = "AC-3 Encoder",
+    .item_name  = av_default_item_name,
+    .option     = ff_ac3_enc_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 const AVCodecDefault ff_ac3_enc_defaults[] = {
     { "b",  "0" },
     { NULL }
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index c064ba4d63..6d424fdbf6 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -267,6 +267,7 @@ typedef struct AC3EncodeContext {
 
 extern const uint64_t ff_ac3_channel_layouts[19];
 extern const AVOption ff_ac3_enc_options[];
+extern const AVClass ff_ac3enc_class;
 extern const AVCodecDefault ff_ac3_enc_defaults[];
 
 int ff_ac3_encode_init(AVCodecContext *avctx);
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index 58decc594e..c7632d78e1 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -35,13 +35,6 @@
 #include "eac3enc.h"
 #include "kbdwin.h"
 
-static const AVClass ac3enc_class = {
-    .class_name = "Fixed-Point AC-3 Encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_ac3_enc_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 static void sum_square_butterfly(AC3EncodeContext *s, int64_t sum[4],
                                  const int32_t *coef0, const int32_t *coef1,
                                  int len)
@@ -139,7 +132,7 @@ const AVCodec ff_ac3_fixed_encoder = {
     .close           = ff_ac3_encode_close,
     .sample_fmts     = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32P,
                                                       AV_SAMPLE_FMT_NONE },
-    .priv_class      = &ac3enc_class,
+    .priv_class      = &ff_ac3enc_class,
     .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .supported_samplerates = ff_ac3_sample_rate_tab,
     .channel_layouts = ff_ac3_channel_layouts,
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index f9759bd2cf..e4a3794dd8 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -34,14 +34,6 @@
 #include "kbdwin.h"
 
 
-static const AVClass ac3enc_class = {
-    .class_name = "AC-3 Encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_ac3_enc_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
-
 /*
  * Scale MDCT coefficients from float to 24-bit fixed-point.
  */
@@ -143,7 +135,7 @@ const AVCodec ff_ac3_encoder = {
     .close           = ff_ac3_encode_close,
     .sample_fmts     = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
-    .priv_class      = &ac3enc_class,
+    .priv_class      = &ff_ac3enc_class,
     .supported_samplerates = ff_ac3_sample_rate_tab,
     .channel_layouts = ff_ac3_channel_layouts,
     .defaults        = ff_ac3_enc_defaults,
-- 
2.27.0



More information about the ffmpeg-devel mailing list