---
libavformat/Makefile | 4 +-
libavformat/au.h | 39 +++++++++++++++++
libavformat/{au.c => audec.c} | 93 +----------------------------------------
libavformat/auenc.c | 97 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 140 insertions(+), 93 deletions(-)
create mode 100644 libavformat/au.h
rename libavformat/{au.c => audec.c} (61%)
create mode 100644 libavformat/auenc.c
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 89d2d42..3414611 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -71,8 +71,8 @@ OBJS-$(CONFIG_ASF_DEMUXER) += asfdec.o asf.o
asfcrypt.o \
OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o
OBJS-$(CONFIG_ASS_DEMUXER) += assdec.o
OBJS-$(CONFIG_ASS_MUXER) += assenc.o
-OBJS-$(CONFIG_AU_DEMUXER) += au.o pcm.o
-OBJS-$(CONFIG_AU_MUXER) += au.o rawenc.o
+OBJS-$(CONFIG_AU_DEMUXER) += audec.o pcm.o
+OBJS-$(CONFIG_AU_MUXER) += auenc.o rawenc.o
OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o
OBJS-$(CONFIG_AVI_MUXER) += avienc.o
OBJS-$(CONFIG_AVISYNTH) += avisynth.o
diff --git a/libavformat/au.h b/libavformat/au.h
new file mode 100644
index 0000000..a9198f6
--- /dev/null
+++ b/libavformat/au.h
@@ -0,0 +1,39 @@
+/*
+ * AU muxer/demuxer common header
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFORMAT_AU_H
+#define AVFORMAT_AU_H
+
+#include "internal.h"
+
+static const AVCodecTag codec_au_tags[] = {
+ { AV_CODEC_ID_PCM_MULAW, 1 },
+ { AV_CODEC_ID_PCM_S8, 2 },
+ { AV_CODEC_ID_PCM_S16BE, 3 },
+ { AV_CODEC_ID_PCM_S24BE, 4 },
+ { AV_CODEC_ID_PCM_S32BE, 5 },
+ { AV_CODEC_ID_PCM_F32BE, 6 },
+ { AV_CODEC_ID_PCM_F64BE, 7 },
+ { AV_CODEC_ID_PCM_ALAW, 27 },
+ { AV_CODEC_ID_NONE, 0 },
+};
+
+
+#endif /* AVFORMAT_AU_H */
diff --git a/libavformat/au.c b/libavformat/audec.c
similarity index 61%
rename from libavformat/au.c
rename to libavformat/audec.c
index e682cbf..76681e9 100644
--- a/libavformat/au.c
+++ b/libavformat/audec.c
@@ -1,5 +1,5 @@
/*
- * AU muxer and demuxer
+ * AU demuxer
* Copyright (c) 2001 Fabrice Bellard
*
* first version by Francois Revol <[email protected]>
@@ -27,24 +27,8 @@
* http://www.goice.co.jp/member/mo/formats/au.html
*/
-#include "avformat.h"
-#include "internal.h"
-#include "avio_internal.h"
#include "pcm.h"
-
-static const AVCodecTag codec_au_tags[] = {
- { AV_CODEC_ID_PCM_MULAW, 1 },
- { AV_CODEC_ID_PCM_S8, 2 },
- { AV_CODEC_ID_PCM_S16BE, 3 },
- { AV_CODEC_ID_PCM_S24BE, 4 },
- { AV_CODEC_ID_PCM_S32BE, 5 },
- { AV_CODEC_ID_PCM_F32BE, 6 },
- { AV_CODEC_ID_PCM_F64BE, 7 },
- { AV_CODEC_ID_PCM_ALAW, 27 },
- { AV_CODEC_ID_NONE, 0 },
-};
-
-#if CONFIG_AU_DEMUXER
+#include "au.h"
static int au_probe(AVProbeData *p)
{
@@ -146,76 +130,3 @@ AVInputFormat ff_au_demuxer = {
.read_seek = ff_pcm_read_seek,
.codec_tag = (const AVCodecTag* const []) { codec_au_tags, 0 },
};
-
-#endif /* CONFIG_AU_DEMUXER */
-
-#if CONFIG_AU_MUXER
-
-#include "rawenc.h"
-
-/* if we don't know the size in advance */
-#define AU_UNKNOWN_SIZE ((uint32_t)(~0))
-
-/* AUDIO_FILE header */
-static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
-{
- if (!enc->codec_tag)
- return AVERROR(EINVAL);
-
- ffio_wfourcc(pb, ".snd"); /* magic number */
- avio_wb32(pb, 24); /* header size */
- avio_wb32(pb, AU_UNKNOWN_SIZE); /* data size */
- avio_wb32(pb, enc->codec_tag); /* codec ID */
- avio_wb32(pb, enc->sample_rate);
- avio_wb32(pb, enc->channels);
-
- return 0;
-}
-
-static int au_write_header(AVFormatContext *s)
-{
- AVIOContext *pb = s->pb;
- int ret;
-
- s->priv_data = NULL;
-
- if ((ret = put_au_header(pb, s->streams[0]->codec)) < 0)
- return ret;
-
- avio_flush(pb);
-
- return 0;
-}
-
-static int au_write_trailer(AVFormatContext *s)
-{
- AVIOContext *pb = s->pb;
- int64_t file_size;
-
- if (s->pb->seekable) {
- /* update file size */
- file_size = avio_tell(pb);
- avio_seek(pb, 8, SEEK_SET);
- avio_wb32(pb, (uint32_t)(file_size - 24));
- avio_seek(pb, file_size, SEEK_SET);
- avio_flush(pb);
- }
-
- return 0;
-}
-
-AVOutputFormat ff_au_muxer = {
- .name = "au",
- .long_name = NULL_IF_CONFIG_SMALL("Sun AU"),
- .mime_type = "audio/basic",
- .extensions = "au",
- .audio_codec = AV_CODEC_ID_PCM_S16BE,
- .video_codec = AV_CODEC_ID_NONE,
- .write_header = au_write_header,
- .write_packet = ff_raw_write_packet,
- .write_trailer = au_write_trailer,
- .codec_tag = (const AVCodecTag* const []) { codec_au_tags, 0 },
- .flags = AVFMT_NOTIMESTAMPS,
-};
-
-#endif /* CONFIG_AU_MUXER */
diff --git a/libavformat/auenc.c b/libavformat/auenc.c
new file mode 100644
index 0000000..92a7eda
--- /dev/null
+++ b/libavformat/auenc.c
@@ -0,0 +1,97 @@
+/*
+ * AU muxer
+ * Copyright (c) 2001 Fabrice Bellard
+ *
+ * first version by Francois Revol <[email protected]>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Reference documents:
+ * http://www.opengroup.org/public/pubs/external/auformat.html
+ * http://www.goice.co.jp/member/mo/formats/au.html
+ */
+
+#include "avio_internal.h"
+#include "rawenc.h"
+#include "au.h"
+
+/* if we don't know the size in advance */
+#define AU_UNKNOWN_SIZE ((uint32_t)(~0))
+
+/* AUDIO_FILE header */
+static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
+{
+ if (!enc->codec_tag)
+ return AVERROR(EINVAL);
+
+ ffio_wfourcc(pb, ".snd"); /* magic number */
+ avio_wb32(pb, 24); /* header size */
+ avio_wb32(pb, AU_UNKNOWN_SIZE); /* data size */
+ avio_wb32(pb, enc->codec_tag); /* codec ID */
+ avio_wb32(pb, enc->sample_rate);
+ avio_wb32(pb, enc->channels);
+
+ return 0;
+}
+
+static int au_write_header(AVFormatContext *s)
+{
+ AVIOContext *pb = s->pb;
+ int ret;
+
+ s->priv_data = NULL;
+
+ if ((ret = put_au_header(pb, s->streams[0]->codec)) < 0)
+ return ret;
+
+ avio_flush(pb);
+
+ return 0;
+}
+
+static int au_write_trailer(AVFormatContext *s)
+{
+ AVIOContext *pb = s->pb;
+ int64_t file_size;
+
+ if (s->pb->seekable) {
+ /* update file size */
+ file_size = avio_tell(pb);
+ avio_seek(pb, 8, SEEK_SET);
+ avio_wb32(pb, (uint32_t)(file_size - 24));
+ avio_seek(pb, file_size, SEEK_SET);
+ avio_flush(pb);
+ }
+
+ return 0;
+}
+
+AVOutputFormat ff_au_muxer = {
+ .name = "au",
+ .long_name = NULL_IF_CONFIG_SMALL("Sun AU"),
+ .mime_type = "audio/basic",
+ .extensions = "au",
+ .audio_codec = AV_CODEC_ID_PCM_S16BE,
+ .video_codec = AV_CODEC_ID_NONE,
+ .write_header = au_write_header,
+ .write_packet = ff_raw_write_packet,
+ .write_trailer = au_write_trailer,
+ .codec_tag = (const AVCodecTag* const []) { codec_au_tags, 0 },
+ .flags = AVFMT_NOTIMESTAMPS,
+};
--
1.9.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel