diff mbox series

[FFmpeg-devel,37/41] avcodec/mpegvideo_enc: Deduplicate ff_mpv_generic_options-based AVClasses

Message ID VI1PR0301MB2159F4CB5A4604E0D9DACFDC8F0E9@VI1PR0301MB2159.eurprd03.prod.outlook.com
State Accepted
Commit 34ff543672e19d5b6d3879981080ea5639fa6e04
Headers show
Series [FFmpeg-devel,01/41] avformat/Makefile: Add missing rawdec dependency for IPU demuxer
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt June 17, 2021, 2:31 a.m. UTC
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@outlook.com>
---
 libavcodec/flvenc.c        |  9 +--------
 libavcodec/h261enc.c       |  9 +--------
 libavcodec/mpegvideo.h     |  2 +-
 libavcodec/mpegvideo_enc.c | 36 +++++++++++-------------------------
 libavcodec/rv10enc.c       |  9 +--------
 libavcodec/rv20enc.c       |  9 +--------
 libavcodec/speedhqenc.c    |  9 +--------
 libavcodec/wmv2enc.c       |  9 +--------
 8 files changed, 18 insertions(+), 74 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c
index b40178cd43..614ef20243 100644
--- a/libavcodec/flvenc.c
+++ b/libavcodec/flvenc.c
@@ -91,18 +91,12 @@  void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level,
     }
 }
 
-static const AVClass flv_class = {
-    .class_name = "flv encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_mpv_generic_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 const AVCodec ff_flv_encoder = {
     .name           = "flv",
     .long_name      = NULL_IF_CONFIG_SMALL("FLV / Sorenson Spark / Sorenson H.263 (Flash Video)"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_FLV1,
+    .priv_class     = &ff_mpv_enc_class,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
@@ -110,5 +104,4 @@  const AVCodec ff_flv_encoder = {
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                      AV_PIX_FMT_NONE},
-    .priv_class     = &flv_class,
 };
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index da681f140a..79f680f81d 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -385,18 +385,12 @@  av_cold void ff_h261_encode_init(MpegEncContext *s)
     ff_thread_once(&init_static_once, h261_encode_init_static);
 }
 
-static const AVClass h261_class = {
-    .class_name = "h261 encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_mpv_generic_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 const AVCodec ff_h261_encoder = {
     .name           = "h261",
     .long_name      = NULL_IF_CONFIG_SMALL("H.261"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_H261,
+    .priv_class     = &ff_mpv_enc_class,
     .priv_data_size = sizeof(H261Context),
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
@@ -404,5 +398,4 @@  const AVCodec ff_h261_encoder = {
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                      AV_PIX_FMT_NONE },
-    .priv_class     = &h261_class,
 };
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 546d9c7929..76b32ea547 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -680,7 +680,7 @@  FF_MPV_OPT_CMP_FUNC, \
    { "brd_scale",     "Deprecated, does nothing", FF_MPV_OFFSET(brd_scale),        AV_OPT_TYPE_INT, { .i64 =  0 }, 0, 3, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED },
 #endif
 
-extern const AVOption ff_mpv_generic_options[];
+extern const AVClass ff_mpv_enc_class;
 
 /**
  * Set the given MpegEncContext to common defaults (same for encoding
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 794ca017a4..3d4ffdf021 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -85,7 +85,7 @@  static int dct_quantize_trellis_c(MpegEncContext *s, int16_t *block, int n, int
 static uint8_t default_mv_penalty[MAX_FCODE + 1][MAX_DMV * 2 + 1];
 static uint8_t default_fcode_tab[MAX_MV * 2 + 1];
 
-const AVOption ff_mpv_generic_options[] = {
+static const AVOption mpv_generic_options[] = {
     FF_MPV_COMMON_OPTS
 #if FF_API_MPEGVIDEO_OPTS
     FF_MPV_DEPRECATED_MPEG_QUANT_OPT
@@ -96,6 +96,13 @@  const AVOption ff_mpv_generic_options[] = {
     { NULL },
 };
 
+const AVClass ff_mpv_enc_class = {
+    .class_name = "generic mpegvideo encoder",
+    .item_name  = av_default_item_name,
+    .option     = mpv_generic_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
                        uint16_t (*qmat16)[2][64],
                        const uint16_t *quant_matrix,
@@ -4648,32 +4655,18 @@  const AVCodec ff_h263p_encoder = {
     .priv_class     = &h263p_class,
 };
 
-static const AVClass msmpeg4v2_class = {
-    .class_name = "msmpeg4v2 encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_mpv_generic_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 const AVCodec ff_msmpeg4v2_encoder = {
     .name           = "msmpeg4v2",
     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_MSMPEG4V2,
+    .priv_class     = &ff_mpv_enc_class,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
     .close          = ff_mpv_encode_end,
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
-    .priv_class     = &msmpeg4v2_class,
-};
-
-static const AVClass msmpeg4v3_class = {
-    .class_name = "msmpeg4v3 encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_mpv_generic_options,
-    .version    = LIBAVUTIL_VERSION_INT,
 };
 
 const AVCodec ff_msmpeg4v3_encoder = {
@@ -4681,20 +4674,13 @@  const AVCodec ff_msmpeg4v3_encoder = {
     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_MSMPEG4V3,
+    .priv_class     = &ff_mpv_enc_class,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
     .close          = ff_mpv_encode_end,
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
-    .priv_class     = &msmpeg4v3_class,
-};
-
-static const AVClass wmv1_class = {
-    .class_name = "wmv1 encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_mpv_generic_options,
-    .version    = LIBAVUTIL_VERSION_INT,
 };
 
 const AVCodec ff_wmv1_encoder = {
@@ -4702,11 +4688,11 @@  const AVCodec ff_wmv1_encoder = {
     .long_name      = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_WMV1,
+    .priv_class     = &ff_mpv_enc_class,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
     .close          = ff_mpv_encode_end,
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
-    .priv_class     = &wmv1_class,
 };
diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c
index c7bd76bf1a..72b25e0c55 100644
--- a/libavcodec/rv10enc.c
+++ b/libavcodec/rv10enc.c
@@ -63,23 +63,16 @@  int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number)
     return 0;
 }
 
-static const AVClass rv10_class = {
-    .class_name = "rv10 encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_mpv_generic_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 const AVCodec ff_rv10_encoder = {
     .name           = "rv10",
     .long_name      = NULL_IF_CONFIG_SMALL("RealVideo 1.0"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_RV10,
+    .priv_class     = &ff_mpv_enc_class,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
     .close          = ff_mpv_encode_end,
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
-    .priv_class     = &rv10_class,
 };
diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c
index 9da4d144ad..19b6aab278 100644
--- a/libavcodec/rv20enc.c
+++ b/libavcodec/rv20enc.c
@@ -60,23 +60,16 @@  void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number){
     }
 }
 
-static const AVClass rv20_class = {
-    .class_name = "rv20 encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_mpv_generic_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 const AVCodec ff_rv20_encoder = {
     .name           = "rv20",
     .long_name      = NULL_IF_CONFIG_SMALL("RealVideo 2.0"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_RV20,
+    .priv_class     = &ff_mpv_enc_class,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
     .close          = ff_mpv_encode_end,
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
-    .priv_class     = &rv20_class,
 };
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 43437223db..4a2b422f13 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -265,18 +265,12 @@  int ff_speedhq_mb_y_order_to_mb(int mb_y_order, int mb_height, int *first_in_sli
 }
 
 #if CONFIG_SPEEDHQ_ENCODER
-static const AVClass speedhq_class = {
-    .class_name = "speedhq encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_mpv_generic_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 const AVCodec ff_speedhq_encoder = {
     .name           = "speedhq",
     .long_name      = NULL_IF_CONFIG_SMALL("NewTek SpeedHQ"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_SPEEDHQ,
+    .priv_class     = &ff_mpv_enc_class,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
@@ -286,6 +280,5 @@  const AVCodec ff_speedhq_encoder = {
         AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,
         AV_PIX_FMT_NONE
     },
-    .priv_class     = &speedhq_class,
 };
 #endif
diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c
index b3d2a05c4e..ab5365d1f6 100644
--- a/libavcodec/wmv2enc.c
+++ b/libavcodec/wmv2enc.c
@@ -214,20 +214,13 @@  void ff_wmv2_encode_mb(MpegEncContext *s, int16_t block[6][64],
         s->p_tex_bits += get_bits_diff(s);
 }
 
-static const AVClass wmv2_class = {
-    .class_name = "wmv2 encoder",
-    .item_name  = av_default_item_name,
-    .option     = ff_mpv_generic_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 const AVCodec ff_wmv2_encoder = {
     .name           = "wmv2",
     .long_name      = NULL_IF_CONFIG_SMALL("Windows Media Video 8"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_WMV2,
+    .priv_class     = &ff_mpv_enc_class,
     .priv_data_size = sizeof(Wmv2Context),
-    .priv_class     = &wmv2_class,
     .init           = wmv2_encode_init,
     .encode2        = ff_mpv_encode_picture,
     .close          = ff_mpv_encode_end,