summaryrefslogtreecommitdiff
path: root/libavformat/wavdec.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-02 22:43:17 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-04-03 01:55:57 +0200
commitfcbdc44f4e0c425506d627e16a12a7031dec398d (patch)
tree89cab3a148b441a153fb1b21591be88ef4763b2a /libavformat/wavdec.c
parentde0bcea664c8ac59c524164c98b437d9935f7b52 (diff)
wavdec: Only set the codec ID in read_header
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@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/wavdec.c')
-rw-r--r--libavformat/wavdec.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index d95596f6ed..0391737828 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -60,6 +60,19 @@ typedef struct WAVDemuxContext {
int rifx; // RIFX: integer byte order for parameters is big endian
} WAVDemuxContext;
+static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
+{
+ if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codec->codec_tag == 1) {
+ enum AVCodecID codec;
+ int 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;
+ }
+ }
+}
+
#if CONFIG_WAV_DEMUXER
static int64_t next_tag(AVIOContext *pb, uint32_t *tag, int big_endian)
@@ -528,6 +541,8 @@ break_loop:
ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
+ set_spdif(s, wav);
+
return 0;
}
@@ -561,18 +576,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 +836,8 @@ static int w64_read_header(AVFormatContext *s)
avio_seek(pb, data_ofs, SEEK_SET);
+ set_spdif(s, wav);
+
return 0;
}