Signed-off-by: Paul B Mahol <[email protected]>
---
libavcodec/wavpack.c | 44 ++++++++++++++++++++++++++------------------
1 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 1098873..d99516d 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -408,7 +408,8 @@ static inline int wv_get_value_integer(WavpackFrameContext
*s, uint32_t *crc,
if (s->got_extra_bits && get_bits_left(&s->gb_extra_bits) >=
s->extra_bits) {
S |= get_bits(&s->gb_extra_bits, s->extra_bits);
- *crc = *crc * 9 + (S & 0xffff) * 3 + ((unsigned)S >> 16);
+ if (s->avctx->err_recognition & AV_EF_CRCCHECK)
+ *crc = *crc * 9 + (S & 0xffff) * 3 + ((unsigned)S >> 16);
}
}
@@ -488,7 +489,8 @@ static float wv_get_value_float(WavpackFrameContext *s,
uint32_t *crc, int S)
}
}
- *crc = *crc * 27 + S * 9 + exp * 3 + sign;
+ if (s->avctx->err_recognition & AV_EF_CRCCHECK)
+ *crc = *crc * 27 + S * 9 + exp * 3 + sign;
value.u = (sign << 31) | (exp << 23) | S;
return value.f;
@@ -591,7 +593,8 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s,
GetBitContext *gb,
pos = (pos + 1) & 7;
if (s->joint)
L += (R -= (L >> 1));
- crc = (crc * 3 + L) * 3 + R;
+ if (s->avctx->err_recognition & AV_EF_CRCCHECK)
+ crc = (crc * 3 + L) * 3 + R;
if (type == AV_SAMPLE_FMT_FLT) {
*dstfl++ = wv_get_value_float(s, &crc_extra_bits, L);
@@ -610,13 +613,15 @@ static inline int wv_unpack_stereo(WavpackFrameContext
*s, GetBitContext *gb,
} while (!last && count < s->samples);
wv_reset_saved_context(s);
- if (crc != s->CRC) {
- av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
- return -1;
- }
- if (s->got_extra_bits && crc_extra_bits != s->crc_extra_bits) {
- av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
- return -1;
+ if (s->avctx->err_recognition & AV_EF_CRCCHECK) {
+ if (crc != s->CRC) {
+ av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
+ return -1;
+ }
+ if (s->got_extra_bits && crc_extra_bits != s->crc_extra_bits) {
+ av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
+ return -1;
+ }
}
return count * 2;
@@ -664,7 +669,8 @@ static inline int wv_unpack_mono(WavpackFrameContext *s,
GetBitContext *gb,
s->decorr[i].samplesA[j] = T = S;
}
pos = (pos + 1) & 7;
- crc = crc * 3 + S;
+ if (s->avctx->err_recognition & AV_EF_CRCCHECK)
+ crc = crc * 3 + S;
if (type == AV_SAMPLE_FMT_FLT) {
*dstfl = wv_get_value_float(s, &crc_extra_bits, S);
@@ -680,13 +686,15 @@ static inline int wv_unpack_mono(WavpackFrameContext *s,
GetBitContext *gb,
} while (!last && count < s->samples);
wv_reset_saved_context(s);
- if (crc != s->CRC) {
- av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
- return -1;
- }
- if (s->got_extra_bits && crc_extra_bits != s->crc_extra_bits) {
- av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
- return -1;
+ if (s->avctx->err_recognition & AV_EF_CRCCHECK) {
+ if (crc != s->CRC) {
+ av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
+ return -1;
+ }
+ if (s->got_extra_bits && crc_extra_bits != s->crc_extra_bits) {
+ av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n");
+ return -1;
+ }
}
return count;
--
1.7.7
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel