[FFmpeg-cvslog] r19961 - trunk/libavformat/wav.c

diego subversion
Tue Sep 22 13:19:36 CEST 2009


Author: diego
Date: Tue Sep 22 13:19:36 2009
New Revision: 19961

Log:
Rearrange wav_muxer and {wav|w64}_demuxer blocks to be under proper #ifdefs.
Fixes compilation with --disable-optimizations --disable-demuxers.

Modified:
   trunk/libavformat/wav.c

Modified: trunk/libavformat/wav.c
==============================================================================
--- trunk/libavformat/wav.c	Tue Sep 22 13:17:29 2009	(r19960)
+++ trunk/libavformat/wav.c	Tue Sep 22 13:19:36 2009	(r19961)
@@ -119,8 +119,24 @@ static int wav_write_trailer(AVFormatCon
     }
     return 0;
 }
+
+AVOutputFormat wav_muxer = {
+    "wav",
+    NULL_IF_CONFIG_SMALL("WAV format"),
+    "audio/x-wav",
+    "wav",
+    sizeof(WAVContext),
+    CODEC_ID_PCM_S16LE,
+    CODEC_ID_NONE,
+    wav_write_header,
+    wav_write_packet,
+    wav_write_trailer,
+    .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0},
+};
 #endif /* CONFIG_WAV_MUXER */
 
+
+#if CONFIG_WAV_DEMUXER
 /* return the size of the found tag */
 static int64_t find_tag(ByteIOContext *pb, uint32_t tag1)
 {
@@ -221,79 +237,6 @@ static int64_t find_guid(ByteIOContext *
 static const uint8_t guid_data[16] = { 'd', 'a', 't', 'a',
     0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
 
-#if CONFIG_W64_DEMUXER
-
-static const uint8_t guid_riff[16] = { 'r', 'i', 'f', 'f',
-    0x2E, 0x91, 0xCF, 0x11, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00 };
-
-static const uint8_t guid_wave[16] = { 'w', 'a', 'v', 'e',
-    0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
-
-static const uint8_t guid_fmt [16] = { 'f', 'm', 't', ' ',
-    0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
-
-static int w64_probe(AVProbeData *p)
-{
-    if (p->buf_size <= 40)
-        return 0;
-    if (!memcmp(p->buf,      guid_riff, 16) &&
-        !memcmp(p->buf + 24, guid_wave, 16))
-        return AVPROBE_SCORE_MAX;
-    else
-        return 0;
-}
-
-static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
-{
-    int64_t size;
-    ByteIOContext *pb  = s->pb;
-    WAVContext    *wav = s->priv_data;
-    AVStream *st;
-    uint8_t guid[16];
-
-    get_buffer(pb, guid, 16);
-    if (memcmp(guid, guid_riff, 16))
-        return -1;
-
-    if (get_le64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
-        return -1;
-
-    get_buffer(pb, guid, 16);
-    if (memcmp(guid, guid_wave, 16)) {
-        av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
-        return -1;
-    }
-
-    size = find_guid(pb, guid_fmt);
-    if (size < 0) {
-        av_log(s, AV_LOG_ERROR, "could not find fmt guid\n");
-        return -1;
-    }
-
-    st = av_new_stream(s, 0);
-    if (!st)
-        return AVERROR(ENOMEM);
-
-    /* subtract chunk header size - normal wav file doesn't count it */
-    ff_get_wav_header(pb, st->codec, size - 24);
-    url_fskip(pb, FFALIGN(size, INT64_C(8)) - size);
-
-    st->need_parsing = AVSTREAM_PARSE_FULL;
-
-    av_set_pts_info(st, 64, 1, st->codec->sample_rate);
-
-    size = find_guid(pb, guid_data);
-    if (size < 0) {
-        av_log(s, AV_LOG_ERROR, "could not find data guid\n");
-        return -1;
-    }
-    wav->data_end = url_ftell(pb) + size - 24;
-    wav->w64      = 1;
-
-    return 0;
-}
-#endif /* CONFIG_W64_DEMUXER */
-
 #define MAX_SIZE 4096
 
 static int wav_read_packet(AVFormatContext *s,
@@ -356,7 +299,6 @@ static int wav_read_seek(AVFormatContext
     return pcm_read_seek(s, stream_index, timestamp, flags);
 }
 
-#if CONFIG_WAV_DEMUXER
 AVInputFormat wav_demuxer = {
     "wav",
     NULL_IF_CONFIG_SMALL("WAV format"),
@@ -369,25 +311,80 @@ AVInputFormat wav_demuxer = {
     .flags= AVFMT_GENERIC_INDEX,
     .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0},
 };
-#endif
+#endif /* CONFIG_WAV_DEMUXER */
 
-#if CONFIG_WAV_MUXER
-AVOutputFormat wav_muxer = {
-    "wav",
-    NULL_IF_CONFIG_SMALL("WAV format"),
-    "audio/x-wav",
-    "wav",
-    sizeof(WAVContext),
-    CODEC_ID_PCM_S16LE,
-    CODEC_ID_NONE,
-    wav_write_header,
-    wav_write_packet,
-    wav_write_trailer,
-    .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0},
-};
-#endif
 
 #if CONFIG_W64_DEMUXER
+static const uint8_t guid_riff[16] = { 'r', 'i', 'f', 'f',
+    0x2E, 0x91, 0xCF, 0x11, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00 };
+
+static const uint8_t guid_wave[16] = { 'w', 'a', 'v', 'e',
+    0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
+
+static const uint8_t guid_fmt [16] = { 'f', 'm', 't', ' ',
+    0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
+
+static int w64_probe(AVProbeData *p)
+{
+    if (p->buf_size <= 40)
+        return 0;
+    if (!memcmp(p->buf,      guid_riff, 16) &&
+        !memcmp(p->buf + 24, guid_wave, 16))
+        return AVPROBE_SCORE_MAX;
+    else
+        return 0;
+}
+
+static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
+{
+    int64_t size;
+    ByteIOContext *pb  = s->pb;
+    WAVContext    *wav = s->priv_data;
+    AVStream *st;
+    uint8_t guid[16];
+
+    get_buffer(pb, guid, 16);
+    if (memcmp(guid, guid_riff, 16))
+        return -1;
+
+    if (get_le64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
+        return -1;
+
+    get_buffer(pb, guid, 16);
+    if (memcmp(guid, guid_wave, 16)) {
+        av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
+        return -1;
+    }
+
+    size = find_guid(pb, guid_fmt);
+    if (size < 0) {
+        av_log(s, AV_LOG_ERROR, "could not find fmt guid\n");
+        return -1;
+    }
+
+    st = av_new_stream(s, 0);
+    if (!st)
+        return AVERROR(ENOMEM);
+
+    /* subtract chunk header size - normal wav file doesn't count it */
+    ff_get_wav_header(pb, st->codec, size - 24);
+    url_fskip(pb, FFALIGN(size, INT64_C(8)) - size);
+
+    st->need_parsing = AVSTREAM_PARSE_FULL;
+
+    av_set_pts_info(st, 64, 1, st->codec->sample_rate);
+
+    size = find_guid(pb, guid_data);
+    if (size < 0) {
+        av_log(s, AV_LOG_ERROR, "could not find data guid\n");
+        return -1;
+    }
+    wav->data_end = url_ftell(pb) + size - 24;
+    wav->w64      = 1;
+
+    return 0;
+}
+
 AVInputFormat w64_demuxer = {
     "w64",
     NULL_IF_CONFIG_SMALL("Sony Wave64 format"),
@@ -400,4 +397,4 @@ AVInputFormat w64_demuxer = {
     .flags = AVFMT_GENERIC_INDEX,
     .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0},
 };
-#endif
+#endif /* CONFIG_W64_DEMUXER */



More information about the ffmpeg-cvslog mailing list