summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2013-02-16 06:07:49 -0300
committerPaul B Mahol <onemda@gmail.com>2013-03-02 17:22:18 +0000
commit1d5b35cc07c72c3359042a2f13f879cfb2ef549b (patch)
tree9dab06cb24886f447c955ebce858c6377202a64d
parent4ae74c63120c0a48b71cfa295c6da9da72772f81 (diff)
downloadffmpeg-streaming-1d5b35cc07c72c3359042a2f13f879cfb2ef549b.zip
ffmpeg-streaming-1d5b35cc07c72c3359042a2f13f879cfb2ef549b.tar.gz
lavc/flacdec: Add frame CRC calculation
Fixes ticket #2266 Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/flacdec.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index f264d20..91a25f0 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -533,7 +533,15 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data,
av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
return -1;
}
- bytes_read = (get_bits_count(&s->gb)+7)/8;
+ bytes_read = get_bits_count(&s->gb)/8;
+
+ if ((s->avctx->err_recognition & AV_EF_CRCCHECK) &&
+ av_crc(av_crc_get_table(AV_CRC_16_ANSI),
+ 0, buf, bytes_read)) {
+ av_log(s->avctx, AV_LOG_ERROR, "CRC error at PTS %"PRId64"\n", avpkt->pts);
+ if (s->avctx->err_recognition & AV_EF_EXPLODE)
+ return AVERROR_INVALIDDATA;
+ }
/* get output buffer */
frame->nb_samples = s->blocksize;
OpenPOWER on IntegriCloud