[FFmpeg-devel] [PATCH] wavdec: Only set the codec ID in read_header
Derek Buitenhuis
derek.buitenhuis at gmail.com
Sat Apr 2 17:57:25 CEST 2016
WAV is not a NOHEADER format, and thus should not be changing
stream codec IDs and probing in read_packet.
Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
---
Output is unchanged. FATE has been run, and I have also
run Michael's new fate-wav-ac3 test, and it passes.
---
libavformat/wavdec.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index d95596f..db1af4f 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -62,6 +62,18 @@ typedef struct WAVDemuxContext {
#if CONFIG_WAV_DEMUXER
+#define CHECK_SPDIF do { \
+ if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codec->codec_tag == 1) { \
+ enum AVCodecID codec; \
+ ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer, \
+ &codec); \
+ if (ret > AVPROBE_SCORE_EXTENSION) { \
+ s->streams[0]->codec->codec_id = codec; \
+ wav->spdif = 1; \
+ } \
+ } \
+ } while (0)
+
static int64_t next_tag(AVIOContext *pb, uint32_t *tag, int big_endian)
{
*tag = avio_rl32(pb);
@@ -528,6 +540,8 @@ break_loop:
ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
+ CHECK_SPDIF;
+
return 0;
}
@@ -561,18 +575,6 @@ static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
AVStream *st;
WAVDemuxContext *wav = s->priv_data;
- if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 &&
- s->streams[0]->codec->codec_tag == 1) {
- enum AVCodecID codec;
- ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer,
- &codec);
- if (ret > AVPROBE_SCORE_EXTENSION) {
- s->streams[0]->codec->codec_id = codec;
- wav->spdif = 1;
- } else {
- wav->spdif = -1;
- }
- }
if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1)
return ff_spdif_read_packet(s, pkt);
@@ -833,6 +835,8 @@ static int w64_read_header(AVFormatContext *s)
avio_seek(pb, data_ofs, SEEK_SET);
+ CHECK_SPDIF;
+
return 0;
}
--
2.8.0.rc3
More information about the ffmpeg-devel
mailing list