[FFmpeg-devel] [PATCH]Support decoding ac3-in-wav
Carl Eugen Hoyos
cehoyos at ag.or.at
Mon Dec 3 11:42:33 CET 2012
Hi!
Attached patch allows to decode ac3-in-wav.
Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/spdif.h b/libavformat/spdif.h
index 4b11de2..7e1f903 100644
--- a/libavformat/spdif.h
+++ b/libavformat/spdif.h
@@ -23,6 +23,7 @@
#define AVFORMAT_SPDIF_H
#include <stdint.h>
+#include "avformat.h"
#define SYNCWORD1 0xF872
#define SYNCWORD2 0x4E1F
@@ -58,5 +59,6 @@ static const uint16_t spdif_mpeg_pkt_offset[2][3] = {
};
void ff_spdif_bswap_buf16(uint16_t *dst, const uint16_t *src, int w);
+int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt);
#endif /* AVFORMAT_SPDIF_H */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b7506de..78bd27f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -364,6 +364,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, AVProbeDa
{ "m4v" , AV_CODEC_ID_MPEG4 , AVMEDIA_TYPE_VIDEO },
{ "mp3" , AV_CODEC_ID_MP3 , AVMEDIA_TYPE_AUDIO },
{ "mpegvideo", AV_CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO },
+ { "spdif" , AV_CODEC_ID_AC3 , AVMEDIA_TYPE_AUDIO },
{ 0 }
};
int score;
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 62bf263..46288a9 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -35,6 +35,7 @@
#include "riff.h"
#include "avio.h"
#include "metadata.h"
+#include "spdif.h"
typedef struct WAVDemuxContext {
const AVClass *class;
@@ -409,6 +410,11 @@ static int wav_read_packet(AVFormatContext *s,
AVStream *st;
WAVDemuxContext *wav = s->priv_data;
+ if (CONFIG_SPDIF_DEMUXER &&
+ s->streams[0]->codec->codec_id == AV_CODEC_ID_AC3 &&
+ s->streams[0]->codec->codec_tag == 1)
+ return ff_spdif_read_packet(s, pkt);
+
if (wav->smv_data_ofs > 0) {
int64_t audio_dts, video_dts;
smv_retry:
More information about the ffmpeg-devel
mailing list