Submit a correct pointer to av_free() on shutdown.
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.
---
Use av_freep as Hendrik Leppkes pointed out.
libavcodec/pcm-dvd.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
index 9fd6d13..172e93a 100644
--- a/libavcodec/pcm-dvd.c
+++ b/libavcodec/pcm-dvd.c
@@ -1,6 +1,6 @@
/*
* LPCM codecs for PCM formats found in Video DVD streams
- * Copyright (c) 2009-2013 Christian Schmidt
+ * Copyright (c) 2013 Christian Schmidt
*
* This file is part of Libav.
*
@@ -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;
}
@@ -55,8 +54,7 @@ static av_cold int pcm_dvd_decode_uninit(AVCodecContext
*avctx)
{
PCMDVDContext *s = avctx->priv_data;
- if (s->extra_samples)
- av_free(s->extra_samples);
+ av_freep(&s->extra_samples);
return 0;
}
@@ -81,6 +79,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) {
--
1.8.2.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel