From 5bbfe193a0a41bd2adb648c8c3f6901a575734a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 12 Sep 2013 11:31:53 +0300 Subject: vocdec: Don't update codec parameters mid-stream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we really want to support parameter changes, they need to be signalled along with the AVPackets as parameter change side data, not just changing the AVCodecContext parameters when a packet is demuxed (since there may be other earlier packets yet undecoded). Something similar was already done for the sample rate in 0883109b2, but some parameters were left changeable. This avoids having to recheck the channel count for validity for each decoded frame in (ad)pcm decoders, unless the decoders explicitly say that they accept parameter changes. Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org Signed-off-by: Martin Storsjö --- libavformat/vocdec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libavformat/vocdec.c') diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c index 4e06513735..2fb8440931 100644 --- a/libavformat/vocdec.c +++ b/libavformat/vocdec.c @@ -91,11 +91,11 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size) if (sample_rate) dec->sample_rate = sample_rate; avpriv_set_pts_info(st, 64, 1, dec->sample_rate); + dec->channels = channels; + dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id); } else avio_skip(pb, 1); - dec->channels = channels; tmp_codec = avio_r8(pb); - dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id); voc->remaining_size -= 2; max_size -= 2; channels = 1; @@ -117,10 +117,10 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size) if (!dec->sample_rate) { dec->sample_rate = avio_rl32(pb); avpriv_set_pts_info(st, 64, 1, dec->sample_rate); + dec->bits_per_coded_sample = avio_r8(pb); + dec->channels = avio_r8(pb); } else - avio_skip(pb, 4); - dec->bits_per_coded_sample = avio_r8(pb); - dec->channels = avio_r8(pb); + avio_skip(pb, 6); tmp_codec = avio_rl16(pb); avio_skip(pb, 4); voc->remaining_size -= 12; -- cgit v1.2.1