summaryrefslogtreecommitdiff
path: root/libavcodec/pcm-dvd.c
diff options
context:
space:
mode:
authorChristian Schmidt <schmidt@digadd.de>2013-09-11 16:12:27 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-09-13 12:14:05 +0200
commitd9cdb7d8d6d828bb5497ea3f0fd7edd2f3f6cc30 (patch)
tree494553f4d5f8afeef8c3d423b067e83de1bd8c96 /libavcodec/pcm-dvd.c
parent00a63bfb87af6cf7bcdf85848830a90c7e052d41 (diff)
pcm-dvd: Support channel configuration changes
The sample buffering logic does not take into account that the blocksize could change. Reset the buffer if the channel configuration changes, since if there are leftover samples, it is most likely a broken or misconcatenated stream. This could lead to negative numbers for missing_samples during decoding. Thanks to Michael Niedermeyer for pointing these out.
Diffstat (limited to 'libavcodec/pcm-dvd.c')
-rw-r--r--libavcodec/pcm-dvd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
index 9fd6d13365..3f092f646a 100644
--- a/libavcodec/pcm-dvd.c
+++ b/libavcodec/pcm-dvd.c
@@ -46,7 +46,6 @@ static av_cold int pcm_dvd_decode_init(AVCodecContext *avctx)
/* reserve space for 8 channels, 3 bytes/sample, 4 samples/block */
if (!(s->extra_samples = av_malloc(8 * 3 * 4)))
return AVERROR(ENOMEM);
- s->extra_sample_count = 0;
return 0;
}
@@ -81,6 +80,9 @@ static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header)
* header[2] dynamic range control (0x80 = off)
*/
+ /* Discard potentially existing leftover samples from old channel layout */
+ s->extra_sample_count = 0;
+
/* get the sample depth and derive the sample format from it */
avctx->bits_per_coded_sample = 16 + (header[1] >> 6 & 3) * 4;
if (avctx->bits_per_coded_sample == 28) {