[FFmpeg-devel] [PATCH]Allow muxing E-AC3 in wav
Carl Eugen Hoyos
cehoyos at ag.or.at
Sun Jan 12 22:32:14 CET 2014
Hi!
On Saturday 11 January 2014 12:02:01 am Carl Eugen Hoyos wrote:
> Attached is a patchset that allows muxing E-AC3 in wav, tested with WMP.
Moved one hunk and updated.
Carl Eugen
-------------- next part --------------
From 676be216a4fc7426ac6e56d5086ee8158e5dfc6b Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos at ag.or.at>
Date: Sun, 12 Jan 2014 22:27:58 +0100
Subject: [PATCH 1/2] Move GUID-related objects to riff.c
This simplifies the following eac3-in-wav patch.
---
libavformat/asf.h | 2 --
libavformat/asfenc.c | 6 ------
libavformat/riff.c | 25 +++++++++++++++++++++++++
libavformat/riff.h | 2 ++
libavformat/riffdec.c | 8 --------
libavformat/wtvenc.c | 10 ----------
6 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/libavformat/asf.h b/libavformat/asf.h
index acad64d..0c9598a 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -189,6 +189,4 @@ extern const AVMetadataConv ff_asf_metadata_conv[];
extern AVInputFormat ff_asf_demuxer;
-void ff_put_guid(AVIOContext *s, const ff_asf_guid *g);
-
#endif /* AVFORMAT_ASF_H */
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 8e343b3..b456730 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -223,12 +223,6 @@ static const AVCodecTag codec_asf_bmp_tags[] = {
#define PREROLL_TIME 3100
-void ff_put_guid(AVIOContext *s, const ff_asf_guid *g)
-{
- av_assert0(sizeof(*g) == 16);
- avio_write(s, *g, sizeof(*g));
-}
-
static void put_str16(AVIOContext *s, const char *tag)
{
int len;
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 52640d1..fab9ede 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/avassert.h"
#include "libavutil/error.h"
#include "libavcodec/avcodec.h"
#include "avformat.h"
@@ -456,3 +457,27 @@ const struct AVCodecTag *avformat_get_riff_audio_tags(void)
{
return ff_codec_wav_tags;
}
+
+const AVCodecGuid ff_codec_wav_guids[] = {
+ { AV_CODEC_ID_AC3, { 0x2C, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } },
+ { AV_CODEC_ID_ATRAC3P, { 0xBF, 0xAA, 0x23, 0xE9, 0x58, 0xCB, 0x71, 0x44, 0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62 } },
+ { AV_CODEC_ID_EAC3, { 0xAF, 0x87, 0xFB, 0xA7, 0x02, 0x2D, 0xFB, 0x42, 0xA4, 0xD4, 0x05, 0xCD, 0x93, 0x84, 0x3B, 0xDD } },
+ { AV_CODEC_ID_MP2, { 0x2B, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } },
+ { AV_CODEC_ID_NONE }
+};
+
+const ff_asf_guid *get_codec_guid(enum AVCodecID id, const AVCodecGuid *av_guid)
+{
+ int i;
+ for (i = 0; av_guid[i].id != AV_CODEC_ID_NONE; i++) {
+ if (id == av_guid[i].id)
+ return &(av_guid[i].guid);
+ }
+ return NULL;
+}
+
+void ff_put_guid(AVIOContext *s, const ff_asf_guid *g)
+{
+ av_assert0(sizeof(*g) == 16);
+ avio_write(s, *g, sizeof(*g));
+}
diff --git a/libavformat/riff.h b/libavformat/riff.h
index ce07869..b59c606 100644
--- a/libavformat/riff.h
+++ b/libavformat/riff.h
@@ -92,6 +92,8 @@ static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
}
void ff_get_guid(AVIOContext *s, ff_asf_guid *g);
+void ff_put_guid(AVIOContext *s, const ff_asf_guid *g);
+const ff_asf_guid *get_codec_guid(enum AVCodecID id, const AVCodecGuid *av_guid);
enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid);
diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index 559ca47..c1e9ec1 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -29,14 +29,6 @@
#include "avio_internal.h"
#include "riff.h"
-const AVCodecGuid ff_codec_wav_guids[] = {
- { AV_CODEC_ID_AC3, { 0x2C, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } },
- { AV_CODEC_ID_ATRAC3P, { 0xBF, 0xAA, 0x23, 0xE9, 0x58, 0xCB, 0x71, 0x44, 0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62 } },
- { AV_CODEC_ID_EAC3, { 0xAF, 0x87, 0xFB, 0xA7, 0x02, 0x2D, 0xFB, 0x42, 0xA4, 0xD4, 0x05, 0xCD, 0x93, 0x84, 0x3B, 0xDD } },
- { AV_CODEC_ID_MP2, { 0x2B, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } },
- { AV_CODEC_ID_NONE }
-};
-
void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
{
av_assert0(sizeof(*g) == 16); //compiler will optimize this out
diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
index 5e3b9b9..f328ca1 100644
--- a/libavformat/wtvenc.c
+++ b/libavformat/wtvenc.c
@@ -130,16 +130,6 @@ typedef struct {
#define write_pad(pb, size) ffio_fill(pb, 0, size)
-static const ff_asf_guid *get_codec_guid(enum AVCodecID id, const AVCodecGuid *av_guid)
-{
- int i;
- for (i = 0; av_guid[i].id != AV_CODEC_ID_NONE; i++) {
- if (id == av_guid[i].id)
- return &(av_guid[i].guid);
- }
- return NULL;
-}
-
/**
* Write chunk header. If header chunk (0x80000000 set) then add to list of header chunks
*/
--
1.7.10.4
-------------- next part --------------
From 373c633016c18b880f719199259fe25c83ff736a Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos at ag.or.at>
Date: Sun, 12 Jan 2014 22:28:50 +0100
Subject: [PATCH 2/2] Support writing E-AC3 in wav.
---
libavformat/riff.c | 2 ++
libavformat/riffenc.c | 5 +++++
libavformat/version.h | 2 +-
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/libavformat/riff.c b/libavformat/riff.c
index fab9ede..54fe0c6 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -414,6 +414,8 @@ const AVCodecTag ff_codec_wav_tags[] = {
{ AV_CODEC_ID_AAC, 0x1600 },
{ AV_CODEC_ID_AAC_LATM, 0x1602 },
{ AV_CODEC_ID_AC3, 0x2000 },
+ /* There is no Microsoft Format Tag for e-ac3, the guid has to be used */
+ { AV_CODEC_ID_EAC3, 0x2000 },
{ AV_CODEC_ID_DTS, 0x2001 },
{ AV_CODEC_ID_SONIC, 0x2048 },
{ AV_CODEC_ID_SONIC_LS, 0x2048 },
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 7b4b7dd..f9bb4b1 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -72,6 +72,7 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
waveformatextensible = (enc->channels > 2 && enc->channel_layout) ||
enc->sample_rate > 48000 ||
+ enc->codec_id == AV_CODEC_ID_EAC3 ||
av_get_bits_per_sample(enc->codec_id) > 16;
if (waveformatextensible)
@@ -183,10 +184,14 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
/* dwChannelMask */
avio_wl32(pb, enc->channel_layout);
/* GUID + next 3 */
+ if (enc->codec_id == AV_CODEC_ID_EAC3) {
+ ff_put_guid(pb, get_codec_guid(enc->codec_id, ff_codec_wav_guids));
+ } else {
avio_wl32(pb, enc->codec_tag);
avio_wl32(pb, 0x00100000);
avio_wl32(pb, 0xAA000080);
avio_wl32(pb, 0x719B3800);
+ }
} else {
avio_wl16(pb, riff_extradata - riff_extradata_start); /* cbSize */
}
diff --git a/libavformat/version.h b/libavformat/version.h
index 3ccbf4c..f48e86e 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MINOR 23
-#define LIBAVFORMAT_VERSION_MICRO 103
+#define LIBAVFORMAT_VERSION_MICRO 104
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
--
1.7.10.4
More information about the ffmpeg-devel
mailing list