wavpack: allow user to disable CRC checking

Signed-off-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
This commit is contained in:
Paul B Mahol 2012-02-10 18:51:57 +00:00 committed by Justin Ruggles
parent eeb9e61a51
commit c388558d31
1 changed files with 21 additions and 16 deletions

View File

@ -500,6 +500,21 @@ static void wv_reset_saved_context(WavpackFrameContext *s)
s->sc.crc = s->extra_sc.crc = 0xFFFFFFFF;
}
static inline int wv_check_crc(WavpackFrameContext *s, uint32_t crc,
uint32_t crc_extra_bits)
{
if (crc != s->CRC) {
av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
return AVERROR_INVALIDDATA;
}
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 AVERROR_INVALIDDATA;
}
return 0;
}
static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb,
void *dst, const int type)
{
@ -610,14 +625,9 @@ 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) &&
wv_check_crc(s, crc, crc_extra_bits))
return AVERROR_INVALIDDATA;
return count * 2;
}
@ -680,14 +690,9 @@ 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) &&
wv_check_crc(s, crc, crc_extra_bits))
return AVERROR_INVALIDDATA;
return count;
}