Browse code

pcmdec: use unique classes for all pcm demuxers.

Anton Khirnov authored on 2011/09/14 16:54:29
Showing 3 changed files
... ...
@@ -22,6 +22,8 @@
22 22
 #include "avformat.h"
23 23
 #include "rawdec.h"
24 24
 #include "pcm.h"
25
+#include "libavutil/log.h"
26
+#include "libavutil/opt.h"
25 27
 
26 28
 #define RAW_SAMPLES     1024
27 29
 
... ...
@@ -46,7 +48,19 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
46 46
     return ret;
47 47
 }
48 48
 
49
+static const AVOption pcm_options[] = {
50
+    { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
51
+    { "channels",    "", offsetof(RawAudioDemuxerContext, channels),    FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
52
+    { NULL },
53
+};
54
+
49 55
 #define PCMDEF(name, long_name, ext, codec) \
56
+static const AVClass name ## _demuxer_class = {\
57
+    .class_name = #name " demuxer",\
58
+    .item_name  = av_default_item_name,\
59
+    .option     = pcm_options,\
60
+    .version    = LIBAVUTIL_VERSION_INT,\
61
+};\
50 62
 AVInputFormat ff_pcm_ ## name ## _demuxer = {\
51 63
     #name,\
52 64
     NULL_IF_CONFIG_SMALL(long_name),\
... ...
@@ -59,7 +73,7 @@ AVInputFormat ff_pcm_ ## name ## _demuxer = {\
59 59
     .flags= AVFMT_GENERIC_INDEX,\
60 60
     .extensions = ext,\
61 61
     .value = codec,\
62
-    .priv_class = &ff_rawaudio_demuxer_class,\
62
+    .priv_class = &name ## _demuxer_class,\
63 63
 };
64 64
 
65 65
 PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
... ...
@@ -167,19 +167,6 @@ fail:
167 167
 
168 168
 /* Note: Do not forget to add new entries to the Makefile as well. */
169 169
 
170
-static const AVOption audio_options[] = {
171
-    { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
172
-    { "channels",    "", offsetof(RawAudioDemuxerContext, channels),    FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
173
-    { NULL },
174
-};
175
-
176
-const AVClass ff_rawaudio_demuxer_class = {
177
-    .class_name     = "rawaudio demuxer",
178
-    .item_name      = av_default_item_name,
179
-    .option         = audio_options,
180
-    .version        = LIBAVUTIL_VERSION_INT,
181
-};
182
-
183 170
 #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
184 171
 #define DEC AV_OPT_FLAG_DECODING_PARAM
185 172
 static const AVOption video_options[] = {
... ...
@@ -38,7 +38,6 @@ 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_rawaudio_demuxer_class;
42 41
 extern const AVClass ff_rawvideo_demuxer_class;
43 42
 
44 43
 int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap);