diff mbox series

[FFmpeg-devel,18/41] avformat/rawdec: Deduplicate AVClasses based upon ff_rawvideo_options

Message ID VI1PR0301MB2159193972AF7ABD73A556298F0E9@VI1PR0301MB2159.eurprd03.prod.outlook.com
State Accepted
Commit 7ca0931fe1782fed54e508850c12bee7ee0a432a
Headers show
Series [FFmpeg-devel,01/41] avformat/Makefile: Add missing rawdec dependency for IPU demuxer | expand

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>
---
 libavformat/ingenientdec.c |  4 +---
 libavformat/rawdec.c       | 10 +++++++++-
 libavformat/rawdec.h       | 14 ++------------
 3 files changed, 12 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/ingenientdec.c b/libavformat/ingenientdec.c
index 9848e12e9e..7a9cce155f 100644
--- a/libavformat/ingenientdec.c
+++ b/libavformat/ingenientdec.c
@@ -61,8 +61,6 @@  static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
     return ret;
 }
 
-FF_RAWVIDEO_DEMUXER_CLASS(ingenient)
-
 const AVInputFormat ff_ingenient_demuxer = {
     .name           = "ingenient",
     .long_name      = NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"),
@@ -73,5 +71,5 @@  const AVInputFormat ff_ingenient_demuxer = {
     .flags          = AVFMT_GENERIC_INDEX,
     .extensions     = "cgi", // FIXME
     .raw_codec_id   = AV_CODEC_ID_MJPEG,
-    .priv_class     = &ingenient_demuxer_class,
+    .priv_class     = &ff_rawvideo_demuxer_class,
 };
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index aa6eba4f39..cf5da8c21e 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -118,12 +118,20 @@  int ff_raw_data_read_header(AVFormatContext *s)
 
 #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
 #define DEC AV_OPT_FLAG_DECODING_PARAM
-const AVOption ff_rawvideo_options[] = {
+static const AVOption rawvideo_options[] = {
     { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC},
     { "raw_packet_size", "", OFFSET(raw_packet_size), AV_OPT_TYPE_INT, {.i64 = RAW_PACKET_SIZE }, 1, INT_MAX, DEC},
     { NULL },
 };
 #undef OFFSET
+
+const AVClass ff_rawvideo_demuxer_class = {
+    .class_name = "generic raw video demuxer",
+    .item_name  = av_default_item_name,
+    .option     = rawvideo_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 #define OFFSET(x) offsetof(FFRawDemuxerContext, x)
 static const AVOption raw_options[] = {
     { "raw_packet_size", "", OFFSET(raw_packet_size), AV_OPT_TYPE_INT, {.i64 = RAW_PACKET_SIZE }, 1, INT_MAX, DEC},
diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h
index 3c05795762..18777db290 100644
--- a/libavformat/rawdec.h
+++ b/libavformat/rawdec.h
@@ -24,7 +24,6 @@ 
 
 #include "avformat.h"
 #include "libavutil/log.h"
-#include "libavutil/opt.h"
 
 typedef struct FFRawVideoDemuxerContext {
     const AVClass *class;     /**< Class for private options. */
@@ -39,7 +38,7 @@  typedef struct FFRawDemuxerContext {
     int raw_packet_size;
 } FFRawDemuxerContext;
 
-extern const AVOption ff_rawvideo_options[];
+extern const AVClass ff_rawvideo_demuxer_class;
 extern const AVClass ff_raw_demuxer_class;
 
 int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt);
@@ -52,16 +51,7 @@  int ff_raw_subtitle_read_header(AVFormatContext *s);
 
 int ff_raw_data_read_header(AVFormatContext *s);
 
-#define FF_RAWVIDEO_DEMUXER_CLASS(name)\
-static const AVClass name ## _demuxer_class = {\
-    .class_name = #name " demuxer",\
-    .item_name  = av_default_item_name,\
-    .option     = ff_rawvideo_options,\
-    .version    = LIBAVUTIL_VERSION_INT,\
-};
-
 #define FF_DEF_RAWVIDEO_DEMUXER2(shortname, longname, probe, ext, id, flag)\
-FF_RAWVIDEO_DEMUXER_CLASS(shortname)\
 const AVInputFormat ff_ ## shortname ## _demuxer = {\
     .name           = #shortname,\
     .long_name      = NULL_IF_CONFIG_SMALL(longname),\
@@ -72,7 +62,7 @@  const AVInputFormat ff_ ## shortname ## _demuxer = {\
     .flags          = flag,\
     .raw_codec_id   = id,\
     .priv_data_size = sizeof(FFRawVideoDemuxerContext),\
-    .priv_class     = &shortname ## _demuxer_class,\
+    .priv_class     = &ff_rawvideo_demuxer_class,\
 };
 
 #define FF_DEF_RAWVIDEO_DEMUXER(shortname, longname, probe, ext, id)\