[FFmpeg-devel] [PATCH 17/41] avformat/rawdec: Deduplicate AVClasses based upon ff_raw_options

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu Jun 17 05:31:38 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>
---
 libavformat/ac3dec.c     |  6 ++----
 libavformat/acm.c        |  3 +--
 libavformat/dtsdec.c     |  4 ++--
 libavformat/flacdec.c    |  3 +--
 libavformat/g722.c       |  4 ++--
 libavformat/ipudec.c     |  9 +--------
 libavformat/loasdec.c    |  3 +--
 libavformat/mlpdec.c     |  6 ++----
 libavformat/rawdec.c     | 13 +++++++++----
 libavformat/rawdec.h     | 21 ++-------------------
 libavformat/sbcdec.c     |  3 +--
 libavformat/shortendec.c |  3 +--
 libavformat/takdec.c     |  3 +--
 libavformat/wsddec.c     |  3 +--
 14 files changed, 27 insertions(+), 57 deletions(-)

diff --git a/libavformat/ac3dec.c b/libavformat/ac3dec.c
index 246c483671..ad9b65a9be 100644
--- a/libavformat/ac3dec.c
+++ b/libavformat/ac3dec.c
@@ -102,7 +102,6 @@ static int ac3_probe(const AVProbeData *p)
     return ac3_eac3_probe(p, AV_CODEC_ID_AC3);
 }
 
-FF_RAW_DEMUXER_CLASS(ac3)
 const AVInputFormat ff_ac3_demuxer = {
     .name           = "ac3",
     .long_name      = NULL_IF_CONFIG_SMALL("raw AC-3"),
@@ -113,7 +112,7 @@ const AVInputFormat ff_ac3_demuxer = {
     .extensions = "ac3",
     .raw_codec_id   = AV_CODEC_ID_AC3,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &ac3_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
 #endif
 
@@ -123,7 +122,6 @@ static int eac3_probe(const AVProbeData *p)
     return ac3_eac3_probe(p, AV_CODEC_ID_EAC3);
 }
 
-FF_RAW_DEMUXER_CLASS(eac3)
 const AVInputFormat ff_eac3_demuxer = {
     .name           = "eac3",
     .long_name      = NULL_IF_CONFIG_SMALL("raw E-AC-3"),
@@ -134,6 +132,6 @@ const AVInputFormat ff_eac3_demuxer = {
     .extensions     = "eac3",
     .raw_codec_id   = AV_CODEC_ID_EAC3,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &eac3_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
 #endif
diff --git a/libavformat/acm.c b/libavformat/acm.c
index bc87b3fab9..ccd043ee32 100644
--- a/libavformat/acm.c
+++ b/libavformat/acm.c
@@ -60,7 +60,6 @@ static int acm_read_header(AVFormatContext *s)
     return 0;
 }
 
-FF_RAW_DEMUXER_CLASS(acm)
 const AVInputFormat ff_acm_demuxer = {
     .name           = "acm",
     .long_name      = NULL_IF_CONFIG_SMALL("Interplay ACM"),
@@ -71,5 +70,5 @@ const AVInputFormat ff_acm_demuxer = {
     .extensions     = "acm",
     .raw_codec_id   = AV_CODEC_ID_INTERPLAY_ACM,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &acm_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c
index 7f8f73fe05..ceedb2eb49 100644
--- a/libavformat/dtsdec.c
+++ b/libavformat/dtsdec.c
@@ -132,7 +132,6 @@ static int dts_probe(const AVProbeData *p)
     return 0;
 }
 
-FF_RAW_DEMUXER_CLASS(dts)
 const AVInputFormat ff_dts_demuxer = {
     .name           = "dts",
     .long_name      = NULL_IF_CONFIG_SMALL("raw DTS"),
@@ -143,4 +142,5 @@ const AVInputFormat ff_dts_demuxer = {
     .extensions     = "dts",
     .raw_codec_id   = AV_CODEC_ID_DTS,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &dts_demuxer_class,};
+    .priv_class     = &ff_raw_demuxer_class,
+};
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index c841fdba01..bfa464c508 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -328,7 +328,6 @@ static int flac_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in
     return -1;
 }
 
-FF_RAW_DEMUXER_CLASS(flac)
 const AVInputFormat ff_flac_demuxer = {
     .name           = "flac",
     .long_name      = NULL_IF_CONFIG_SMALL("raw FLAC"),
@@ -341,5 +340,5 @@ const AVInputFormat ff_flac_demuxer = {
     .extensions     = "flac",
     .raw_codec_id   = AV_CODEC_ID_FLAC,
     .priv_data_size = sizeof(FLACDecContext),
-    .priv_class     = &flac_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
diff --git a/libavformat/g722.c b/libavformat/g722.c
index 360ced7172..3bfe05ea6f 100644
--- a/libavformat/g722.c
+++ b/libavformat/g722.c
@@ -46,7 +46,6 @@ static int g722_read_header(AVFormatContext *s)
     return 0;
 }
 
-FF_RAW_DEMUXER_CLASS(g722)
 const AVInputFormat ff_g722_demuxer = {
     .name           = "g722",
     .long_name      = NULL_IF_CONFIG_SMALL("raw G.722"),
@@ -56,4 +55,5 @@ const AVInputFormat ff_g722_demuxer = {
     .extensions     = "g722,722",
     .raw_codec_id   = AV_CODEC_ID_ADPCM_G722,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &g722_demuxer_class,};
+    .priv_class     = &ff_raw_demuxer_class,
+};
diff --git a/libavformat/ipudec.c b/libavformat/ipudec.c
index b76371b58c..27b6b59356 100644
--- a/libavformat/ipudec.c
+++ b/libavformat/ipudec.c
@@ -68,13 +68,6 @@ static int ipu_read_header(AVFormatContext *s)
     return 0;
 }
 
-static const AVClass ipu_demuxer_class = {
-    .class_name = "ipu demuxer",
-    .item_name  = av_default_item_name,
-    .option     = ff_raw_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 const AVInputFormat ff_ipu_demuxer = {
     .name           = "ipu",
     .long_name      = NULL_IF_CONFIG_SMALL("raw IPU Video"),
@@ -85,5 +78,5 @@ const AVInputFormat ff_ipu_demuxer = {
     .flags          = AVFMT_GENERIC_INDEX,
     .raw_codec_id   = AV_CODEC_ID_IPU,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &ipu_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c
index 97fabefcd7..3c84d9f37e 100644
--- a/libavformat/loasdec.c
+++ b/libavformat/loasdec.c
@@ -83,7 +83,6 @@ static int loas_read_header(AVFormatContext *s)
     return 0;
 }
 
-FF_RAW_DEMUXER_CLASS(loas)
 const AVInputFormat ff_loas_demuxer = {
     .name           = "loas",
     .long_name      = NULL_IF_CONFIG_SMALL("LOAS AudioSyncStream"),
@@ -93,5 +92,5 @@ const AVInputFormat ff_loas_demuxer = {
     .flags= AVFMT_GENERIC_INDEX,
     .raw_codec_id = AV_CODEC_ID_AAC_LATM,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &loas_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
diff --git a/libavformat/mlpdec.c b/libavformat/mlpdec.c
index 6f2ba5d874..8f0aabb510 100644
--- a/libavformat/mlpdec.c
+++ b/libavformat/mlpdec.c
@@ -56,7 +56,6 @@ static int mlp_probe(const AVProbeData *p)
     return mlp_thd_probe(p, 0xf8726fbb);
 }
 
-FF_RAW_DEMUXER_CLASS(mlp)
 const AVInputFormat ff_mlp_demuxer = {
     .name           = "mlp",
     .long_name      = NULL_IF_CONFIG_SMALL("raw MLP"),
@@ -67,7 +66,7 @@ const AVInputFormat ff_mlp_demuxer = {
     .extensions     = "mlp",
     .raw_codec_id   = AV_CODEC_ID_MLP,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &mlp_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
 #endif
 
@@ -77,7 +76,6 @@ static int thd_probe(const AVProbeData *p)
     return mlp_thd_probe(p, 0xf8726fba);
 }
 
-FF_RAW_DEMUXER_CLASS(truehd)
 const AVInputFormat ff_truehd_demuxer = {
     .name           = "truehd",
     .long_name      = NULL_IF_CONFIG_SMALL("raw TrueHD"),
@@ -88,7 +86,7 @@ const AVInputFormat ff_truehd_demuxer = {
     .extensions     = "thd",
     .raw_codec_id   = AV_CODEC_ID_TRUEHD,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &truehd_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
 #endif
 
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index a1f593c66a..aa6eba4f39 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -125,14 +125,19 @@ const AVOption ff_rawvideo_options[] = {
 };
 #undef OFFSET
 #define OFFSET(x) offsetof(FFRawDemuxerContext, x)
-const AVOption ff_raw_options[] = {
+static const AVOption raw_options[] = {
     { "raw_packet_size", "", OFFSET(raw_packet_size), AV_OPT_TYPE_INT, {.i64 = RAW_PACKET_SIZE }, 1, INT_MAX, DEC},
     { NULL },
 };
 
-#if CONFIG_DATA_DEMUXER
-FF_RAW_DEMUXER_CLASS(raw_data)
+const AVClass ff_raw_demuxer_class = {
+    .class_name = "generic raw demuxer",
+    .item_name  = av_default_item_name,
+    .option     = raw_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
 
+#if CONFIG_DATA_DEMUXER
 const AVInputFormat ff_data_demuxer = {
     .name           = "data",
     .long_name      = NULL_IF_CONFIG_SMALL("raw data"),
@@ -141,7 +146,7 @@ const AVInputFormat ff_data_demuxer = {
     .raw_codec_id   = AV_CODEC_ID_NONE,
     .flags          = AVFMT_NOTIMESTAMPS,
     .priv_data_size = sizeof(FFRawDemuxerContext),\
-    .priv_class     = &raw_data_demuxer_class,\
+    .priv_class     = &ff_raw_demuxer_class,
 };
 #endif
 
diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h
index e64ad8010c..3c05795762 100644
--- a/libavformat/rawdec.h
+++ b/libavformat/rawdec.h
@@ -40,7 +40,7 @@ typedef struct FFRawDemuxerContext {
 } FFRawDemuxerContext;
 
 extern const AVOption ff_rawvideo_options[];
-extern const AVOption ff_raw_options[];
+extern const AVClass ff_raw_demuxer_class;
 
 int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt);
 
@@ -52,14 +52,6 @@ int ff_raw_subtitle_read_header(AVFormatContext *s);
 
 int ff_raw_data_read_header(AVFormatContext *s);
 
-#define FF_RAW_DEMUXER_CLASS(name)\
-static const AVClass name ## _demuxer_class = {\
-    .class_name = #name " demuxer",\
-    .item_name  = av_default_item_name,\
-    .option     = ff_raw_options,\
-    .version    = LIBAVUTIL_VERSION_INT,\
-};
-
 #define FF_RAWVIDEO_DEMUXER_CLASS(name)\
 static const AVClass name ## _demuxer_class = {\
     .class_name = #name " demuxer",\
@@ -86,16 +78,7 @@ const AVInputFormat ff_ ## shortname ## _demuxer = {\
 #define FF_DEF_RAWVIDEO_DEMUXER(shortname, longname, probe, ext, id)\
 FF_DEF_RAWVIDEO_DEMUXER2(shortname, longname, probe, ext, id, AVFMT_GENERIC_INDEX)
 
-#define FF_RAWSUB_DEMUXER_CLASS(name)\
-static const AVClass name ## _demuxer_class = {\
-    .class_name = #name " demuxer",\
-    .item_name  = av_default_item_name,\
-    .option     = ff_raw_options,\
-    .version    = LIBAVUTIL_VERSION_INT,\
-};
-
 #define FF_DEF_RAWSUB_DEMUXER(shortname, longname, probe, ext, id, flag)\
-FF_RAWSUB_DEMUXER_CLASS(shortname)\
 const AVInputFormat ff_ ## shortname ## _demuxer = {\
     .name           = #shortname,\
     .long_name      = NULL_IF_CONFIG_SMALL(longname),\
@@ -106,7 +89,7 @@ const AVInputFormat ff_ ## shortname ## _demuxer = {\
     .flags          = flag,\
     .raw_codec_id   = id,\
     .priv_data_size = sizeof(FFRawDemuxerContext),\
-    .priv_class     = &shortname ## _demuxer_class,\
+    .priv_class     = &ff_raw_demuxer_class,\
 };
 
 #endif /* AVFORMAT_RAWDEC_H */
diff --git a/libavformat/sbcdec.c b/libavformat/sbcdec.c
index 4de29b37c5..c917743fa1 100644
--- a/libavformat/sbcdec.c
+++ b/libavformat/sbcdec.c
@@ -22,7 +22,6 @@
 #include "avformat.h"
 #include "rawdec.h"
 
-FF_RAW_DEMUXER_CLASS(sbc)
 const AVInputFormat ff_sbc_demuxer = {
     .name           = "sbc",
     .long_name      = NULL_IF_CONFIG_SMALL("raw SBC (low-complexity subband codec)"),
@@ -32,5 +31,5 @@ const AVInputFormat ff_sbc_demuxer = {
     .read_packet    = ff_raw_read_partial_packet,
     .flags          = AVFMT_GENERIC_INDEX,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &sbc_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
diff --git a/libavformat/shortendec.c b/libavformat/shortendec.c
index 9209de4388..cd14b55d70 100644
--- a/libavformat/shortendec.c
+++ b/libavformat/shortendec.c
@@ -65,7 +65,6 @@ static int shn_probe(const AVProbeData *p)
     return AVPROBE_SCORE_EXTENSION + 1;
 }
 
-FF_RAW_DEMUXER_CLASS(shorten)
 const AVInputFormat ff_shorten_demuxer = {
     .name           = "shn",
     .long_name      = NULL_IF_CONFIG_SMALL("raw Shorten"),
@@ -76,5 +75,5 @@ const AVInputFormat ff_shorten_demuxer = {
     .extensions     = "shn",
     .raw_codec_id   = AV_CODEC_ID_SHORTEN,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &shorten_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
diff --git a/libavformat/takdec.c b/libavformat/takdec.c
index cf400ec04b..e3f611883b 100644
--- a/libavformat/takdec.c
+++ b/libavformat/takdec.c
@@ -212,7 +212,6 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
     return ret;
 }
 
-FF_RAW_DEMUXER_CLASS(tak)
 const AVInputFormat ff_tak_demuxer = {
     .name           = "tak",
     .long_name      = NULL_IF_CONFIG_SMALL("raw TAK"),
@@ -223,5 +222,5 @@ const AVInputFormat ff_tak_demuxer = {
     .flags          = AVFMT_GENERIC_INDEX,
     .extensions     = "tak",
     .raw_codec_id   = AV_CODEC_ID_TAK,
-    .priv_class     = &tak_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
diff --git a/libavformat/wsddec.c b/libavformat/wsddec.c
index 169a96c71f..a2fcdae2be 100644
--- a/libavformat/wsddec.c
+++ b/libavformat/wsddec.c
@@ -161,7 +161,6 @@ static int wsd_read_header(AVFormatContext *s)
     return avio_seek(pb, data_offset, SEEK_SET);
 }
 
-FF_RAW_DEMUXER_CLASS(wsd)
 const AVInputFormat ff_wsd_demuxer = {
     .name         = "wsd",
     .long_name    = NULL_IF_CONFIG_SMALL("Wideband Single-bit Data (WSD)"),
@@ -172,5 +171,5 @@ const AVInputFormat ff_wsd_demuxer = {
     .flags        = AVFMT_GENERIC_INDEX | AVFMT_NO_BYTE_SEEK,
     .raw_codec_id = AV_CODEC_ID_DSD_MSBF,
     .priv_data_size = sizeof(FFRawDemuxerContext),
-    .priv_class     = &wsd_demuxer_class,
+    .priv_class     = &ff_raw_demuxer_class,
 };
-- 
2.27.0



More information about the ffmpeg-devel mailing list