[FFmpeg-devel] [PATCH] lavc/flacdec: Add frame CRC calculation

James Almer jamrial at gmail.com
Sat Feb 16 10:07:49 CET 2013


Fixes ticket #2266

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/flacdec.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index f264d20..17e1cd5 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -480,6 +480,11 @@ static int decode_frame(FLACContext *s)
 
     /* frame footer */
     skip_bits(gb, 16); /* data crc */
+    if ((s->avctx->err_recognition & AV_EF_CRCCHECK) && av_crc(av_crc_get_table(AV_CRC_16_ANSI),
+                                                               0, gb->buffer, get_bits_count(gb)/8)) {
+        av_log(s->avctx, AV_LOG_ERROR, "frame crc mismatch\n");
+        return AVERROR_INVALIDDATA;
+    }
 
     return 0;
 }
-- 
1.7.12.4



More information about the ffmpeg-devel mailing list