[FFmpeg-cvslog] rawdec: refactor private option for raw video demuxers

Anton Khirnov git at videolan.org
Sat Sep 17 22:45:11 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Sep 14 14:03:55 2011 +0200| [85d982f1e2c3efb8d5622caea162cede3f6c0e21] | committer: Anton Khirnov

rawdec: refactor private option for raw video demuxers

pixel_format/video_size only apply to 'rawvideo' (==uncompressed) demuxer
and make no sense for the other raw (== containerless) demuxers. Keep
only the framerate option for those.

Also use unique classes for all raw video demuxers

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85d982f1e2c3efb8d5622caea162cede3f6c0e21
---

 libavformat/ingenientdec.c |    4 +++-
 libavformat/rawdec.c       |   15 ++-------------
 libavformat/rawdec.h       |   14 ++++++++++++--
 libavformat/rawvideodec.c  |   18 +++++++++++++++++-
 4 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/libavformat/ingenientdec.c b/libavformat/ingenientdec.c
index 50a4357..35ac649 100644
--- a/libavformat/ingenientdec.c
+++ b/libavformat/ingenientdec.c
@@ -58,6 +58,8 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
     return ret;
 }
 
+FF_RAWVIDEO_DEMUXER_CLASS(ingenient)
+
 AVInputFormat ff_ingenient_demuxer = {
     .name           = "ingenient",
     .long_name      = NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"),
@@ -67,5 +69,5 @@ AVInputFormat ff_ingenient_demuxer = {
     .flags= AVFMT_GENERIC_INDEX,
     .extensions = "cgi", // FIXME
     .value = CODEC_ID_MJPEG,
-    .priv_class = &ff_rawvideo_demuxer_class,
+    .priv_class     = &ingenient_demuxer_class,
 };
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index 0b9a082..35df5e2 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -169,21 +169,10 @@ fail:
 
 #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
 #define DEC AV_OPT_FLAG_DECODING_PARAM
-static const AVOption video_options[] = {
-    { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
-    { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC },
-    { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
+const AVOption ff_rawvideo_options[] = {
+    { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC},
     { NULL },
 };
-#undef OFFSET
-#undef DEC
-
-const AVClass ff_rawvideo_demuxer_class = {
-    .class_name     = "rawvideo demuxer",
-    .item_name      = av_default_item_name,
-    .option         = video_options,
-    .version        = LIBAVUTIL_VERSION_INT,
-};
 
 #if CONFIG_G722_DEMUXER
 AVInputFormat ff_g722_demuxer = {
diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h
index 73bfb4a..136f6c2 100644
--- a/libavformat/rawdec.h
+++ b/libavformat/rawdec.h
@@ -24,6 +24,7 @@
 
 #include "avformat.h"
 #include "libavutil/log.h"
+#include "libavutil/opt.h"
 
 typedef struct RawAudioDemuxerContext {
     AVClass *class;
@@ -38,7 +39,7 @@ typedef struct FFRawVideoDemuxerContext {
     char *framerate;          /**< String describing framerate, set by a private option. */
 } FFRawVideoDemuxerContext;
 
-extern const AVClass ff_rawvideo_demuxer_class;
+extern const AVOption ff_rawvideo_options[];
 
 int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap);
 
@@ -48,7 +49,16 @@ int ff_raw_audio_read_header(AVFormatContext *s, AVFormatParameters *ap);
 
 int ff_raw_video_read_header(AVFormatContext *s, AVFormatParameters *ap);
 
+#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_DEMUXER(shortname, longname, probe, ext, id)\
+FF_RAWVIDEO_DEMUXER_CLASS(shortname)\
 AVInputFormat ff_ ## shortname ## _demuxer = {\
     .name           = #shortname,\
     .long_name      = NULL_IF_CONFIG_SMALL(longname),\
@@ -59,7 +69,7 @@ AVInputFormat ff_ ## shortname ## _demuxer = {\
     .flags          = AVFMT_GENERIC_INDEX,\
     .value          = id,\
     .priv_data_size = sizeof(FFRawVideoDemuxerContext),\
-    .priv_class     = &ff_rawvideo_demuxer_class,\
+    .priv_class     = &shortname ## _demuxer_class,\
 };
 
 #endif /* AVFORMAT_RAWDEC_H */
diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c
index e1c52ab..7b9d34e 100644
--- a/libavformat/rawvideodec.c
+++ b/libavformat/rawvideodec.c
@@ -44,6 +44,22 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
     return 0;
 }
 
+#define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+static const AVOption rawvideo_options[] = {
+    { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
+    { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC },
+    { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
+    { NULL },
+};
+
+static const AVClass rawvideo_demuxer_class = {
+    .class_name = "rawvideo demuxer",
+    .item_name  = av_default_item_name,
+    .option     = rawvideo_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 AVInputFormat ff_rawvideo_demuxer = {
     .name           = "rawvideo",
     .long_name      = NULL_IF_CONFIG_SMALL("raw video format"),
@@ -53,5 +69,5 @@ AVInputFormat ff_rawvideo_demuxer = {
     .flags= AVFMT_GENERIC_INDEX,
     .extensions = "yuv,cif,qcif,rgb",
     .value = CODEC_ID_RAWVIDEO,
-    .priv_class = &ff_rawvideo_demuxer_class,
+    .priv_class = &rawvideo_demuxer_class,
 };



More information about the ffmpeg-cvslog mailing list