Browse code

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

Anton Khirnov authored on 2011/09/14 21:03:55
Showing 4 changed files
... ...
@@ -58,6 +58,8 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
58 58
     return ret;
59 59
 }
60 60
 
61
+FF_RAWVIDEO_DEMUXER_CLASS(ingenient)
62
+
61 63
 AVInputFormat ff_ingenient_demuxer = {
62 64
     .name           = "ingenient",
63 65
     .long_name      = NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"),
... ...
@@ -67,5 +69,5 @@ AVInputFormat ff_ingenient_demuxer = {
67 67
     .flags= AVFMT_GENERIC_INDEX,
68 68
     .extensions = "cgi", // FIXME
69 69
     .value = CODEC_ID_MJPEG,
70
-    .priv_class = &ff_rawvideo_demuxer_class,
70
+    .priv_class     = &ingenient_demuxer_class,
71 71
 };
... ...
@@ -169,21 +169,10 @@ fail:
169 169
 
170 170
 #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
171 171
 #define DEC AV_OPT_FLAG_DECODING_PARAM
172
-static const AVOption video_options[] = {
173
-    { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
174
-    { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC },
175
-    { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
172
+const AVOption ff_rawvideo_options[] = {
173
+    { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC},
176 174
     { NULL },
177 175
 };
178
-#undef OFFSET
179
-#undef DEC
180
-
181
-const AVClass ff_rawvideo_demuxer_class = {
182
-    .class_name     = "rawvideo demuxer",
183
-    .item_name      = av_default_item_name,
184
-    .option         = video_options,
185
-    .version        = LIBAVUTIL_VERSION_INT,
186
-};
187 176
 
188 177
 #if CONFIG_G722_DEMUXER
189 178
 AVInputFormat ff_g722_demuxer = {
... ...
@@ -24,6 +24,7 @@
24 24
 
25 25
 #include "avformat.h"
26 26
 #include "libavutil/log.h"
27
+#include "libavutil/opt.h"
27 28
 
28 29
 typedef struct RawAudioDemuxerContext {
29 30
     AVClass *class;
... ...
@@ -38,7 +39,7 @@ typedef struct FFRawVideoDemuxerContext {
38 38
     char *framerate;          /**< String describing framerate, set by a private option. */
39 39
 } FFRawVideoDemuxerContext;
40 40
 
41
-extern const AVClass ff_rawvideo_demuxer_class;
41
+extern const AVOption ff_rawvideo_options[];
42 42
 
43 43
 int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap);
44 44
 
... ...
@@ -48,7 +49,16 @@ int ff_raw_audio_read_header(AVFormatContext *s, AVFormatParameters *ap);
48 48
 
49 49
 int ff_raw_video_read_header(AVFormatContext *s, AVFormatParameters *ap);
50 50
 
51
+#define FF_RAWVIDEO_DEMUXER_CLASS(name)\
52
+static const AVClass name ## _demuxer_class = {\
53
+    .class_name = #name " demuxer",\
54
+    .item_name  = av_default_item_name,\
55
+    .option     = ff_rawvideo_options,\
56
+    .version    = LIBAVUTIL_VERSION_INT,\
57
+};
58
+
51 59
 #define FF_DEF_RAWVIDEO_DEMUXER(shortname, longname, probe, ext, id)\
60
+FF_RAWVIDEO_DEMUXER_CLASS(shortname)\
52 61
 AVInputFormat ff_ ## shortname ## _demuxer = {\
53 62
     .name           = #shortname,\
54 63
     .long_name      = NULL_IF_CONFIG_SMALL(longname),\
... ...
@@ -59,7 +69,7 @@ AVInputFormat ff_ ## shortname ## _demuxer = {\
59 59
     .flags          = AVFMT_GENERIC_INDEX,\
60 60
     .value          = id,\
61 61
     .priv_data_size = sizeof(FFRawVideoDemuxerContext),\
62
-    .priv_class     = &ff_rawvideo_demuxer_class,\
62
+    .priv_class     = &shortname ## _demuxer_class,\
63 63
 };
64 64
 
65 65
 #endif /* AVFORMAT_RAWDEC_H */
... ...
@@ -44,6 +44,22 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
44 44
     return 0;
45 45
 }
46 46
 
47
+#define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
48
+#define DEC AV_OPT_FLAG_DECODING_PARAM
49
+static const AVOption rawvideo_options[] = {
50
+    { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
51
+    { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC },
52
+    { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
53
+    { NULL },
54
+};
55
+
56
+static const AVClass rawvideo_demuxer_class = {
57
+    .class_name = "rawvideo demuxer",
58
+    .item_name  = av_default_item_name,
59
+    .option     = rawvideo_options,
60
+    .version    = LIBAVUTIL_VERSION_INT,
61
+};
62
+
47 63
 AVInputFormat ff_rawvideo_demuxer = {
48 64
     .name           = "rawvideo",
49 65
     .long_name      = NULL_IF_CONFIG_SMALL("raw video format"),
... ...
@@ -53,5 +69,5 @@ AVInputFormat ff_rawvideo_demuxer = {
53 53
     .flags= AVFMT_GENERIC_INDEX,
54 54
     .extensions = "yuv,cif,qcif,rgb",
55 55
     .value = CODEC_ID_RAWVIDEO,
56
-    .priv_class = &ff_rawvideo_demuxer_class,
56
+    .priv_class = &rawvideo_demuxer_class,
57 57
 };