Mercurial > libavcodec.hg
changeset 6098:b7905ea98b8f libavcodec
add crc check to ac3 decoder
author | jbr |
---|---|
date | Thu, 03 Jan 2008 02:26:29 +0000 |
parents | ed7190bd3530 |
children | a2b438bcb1d2 |
files | ac3dec.c |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ac3dec.c Wed Jan 02 19:24:42 2008 +0000 +++ b/ac3dec.c Thu Jan 03 02:26:29 2008 +0000 @@ -35,6 +35,7 @@ #include "avcodec.h" #include "ac3_parser.h" #include "bitstream.h" +#include "crc.h" #include "dsputil.h" #include "random.h" @@ -1101,15 +1102,21 @@ return -1; } - avctx->sample_rate = s->sample_rate; - avctx->bit_rate = s->bit_rate; - /* check that reported frame size fits in input buffer */ if(s->frame_size > buf_size) { av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); return -1; } + /* check for crc mismatch */ + if(av_crc(av_crc8005, 0, &buf[2], s->frame_size-2)) { + av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); + return -1; + } + + avctx->sample_rate = s->sample_rate; + avctx->bit_rate = s->bit_rate; + /* channel config */ s->out_channels = s->channels; if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&