aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2008-01-03 02:26:29 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2008-01-03 02:26:29 +0000
commitd6939960d56228e3ca2ae5937c2c0b26405c125e (patch)
treee05fe8607f4cac387ee795f0c9f995482f2fc2b4 /libavcodec
parentf7f8b4d296bc151c963d200750629fc3a1880402 (diff)
downloadffmpeg-d6939960d56228e3ca2ae5937c2c0b26405c125e.tar.gz
add crc check to ac3 decoder
Originally committed as revision 11379 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3dec.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index e18d395649..1db4a50025 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -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 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
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 &&