---
I don't like it incredibly but works. Anybody has a better idea?
libavcodec/wavpack.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 233c533..06612ab 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -902,19 +902,27 @@ static int wavpack_decode_block(AVCodecContext *avctx,
int block_no,
}
t = 0;
for (i = s->terms - 1; (i >= 0) && (t < size); i--) {
+ int dec_size =
+ 4 * (s->decorr[i].value > 8) * (1 + s->stereo_in) +
+ 4 * (s->decorr[i].value < 0) +
+ 2 * s->decorr[i].value * (s->stereo_in + 1) *
+ (s->decorr[i].value <= 8 && s->decorr[i].value >= 0);
+
+ if (buf + dec_size > buf_end)
+ break;
+
+ t += dec_size;
+
if (s->decorr[i].value > 8) {
s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2;
s->decorr[i].samplesA[1] = wp_exp2(AV_RL16(buf)); buf += 2;
if (s->stereo_in) {
s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf
+= 2;
s->decorr[i].samplesB[1] = wp_exp2(AV_RL16(buf)); buf
+= 2;
- t += 4;
}
- t += 4;
} else if (s->decorr[i].value < 0) {
s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2;
s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf += 2;
- t += 4;
} else {
for (j = 0; j < s->decorr[i].value; j++) {
s->decorr[i].samplesA[j] = wp_exp2(AV_RL16(buf)); buf
+= 2;
@@ -922,7 +930,6 @@ static int wavpack_decode_block(AVCodecContext *avctx, int
block_no,
s->decorr[i].samplesB[j] = wp_exp2(AV_RL16(buf));
buf += 2;
}
}
- t += s->decorr[i].value * 2 * (s->stereo_in + 1);
}
}
got_samples = 1;
--
1.8.2.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel