diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2008-01-04 23:09:58 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2008-01-04 23:09:58 +0000 |
commit | 3abe5fbdc4169047421e9e8794a8f190d794b929 (patch) | |
tree | 69954b6566185ceebcd2e462cdfa6c68f0393b48 /libavcodec | |
parent | 83a0d3878c54b84b21c12be1981bd30096f278f4 (diff) | |
download | ffmpeg-3abe5fbdc4169047421e9e8794a8f190d794b929.tar.gz |
improve CRC API
- don't export any global var
- provide either generated or hardcoded tables
Originally committed as revision 11409 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/ac3dec.c | 2 | ||||
-rw-r--r-- | libavcodec/ac3enc.c | 7 | ||||
-rw-r--r-- | libavcodec/flac.c | 3 | ||||
-rw-r--r-- | libavcodec/flacenc.c | 6 | ||||
-rw-r--r-- | libavcodec/utils.c | 12 |
5 files changed, 12 insertions, 18 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index ceb04b6300..5c09a2e40d 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1110,7 +1110,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, /* check for crc mismatch */ if(avctx->error_resilience > 0) { - if(av_crc(av_crc8005, 0, &buf[2], s->frame_size-2)) { + if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) { av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); return -1; } diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 4ed58e7e84..4e1fe8e475 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1141,13 +1141,16 @@ static int output_frame_end(AC3EncodeContext *s) /* Now we must compute both crcs : this is not so easy for crc1 because it is at the beginning of the data... */ frame_size_58 = (frame_size >> 1) + (frame_size >> 3); - crc1 = bswap_16(av_crc(av_crc8005, 0, frame + 4, 2 * frame_size_58 - 4)); + crc1 = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, + frame + 4, 2 * frame_size_58 - 4)); /* XXX: could precompute crc_inv */ crc_inv = pow_poly((CRC16_POLY >> 1), (16 * frame_size_58) - 16, CRC16_POLY); crc1 = mul_poly(crc_inv, crc1, CRC16_POLY); AV_WB16(frame+2,crc1); - crc2 = bswap_16(av_crc(av_crc8005, 0, frame + 2 * frame_size_58, (frame_size - frame_size_58) * 2 - 2)); + crc2 = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, + frame + 2 * frame_size_58, + (frame_size - frame_size_58) * 2 - 2)); AV_WB16(frame+2*frame_size-2,crc2); // printf("n=%d frame_size=%d\n", n, frame_size); diff --git a/libavcodec/flac.c b/libavcodec/flac.c index 6f66de74ea..2c003b099d 100644 --- a/libavcodec/flac.c +++ b/libavcodec/flac.c @@ -558,7 +558,8 @@ static int decode_frame(FLACContext *s, int alloc_data_size) } skip_bits(&s->gb, 8); - crc8= av_crc(av_crc07, 0, s->gb.buffer, get_bits_count(&s->gb)/8); + crc8 = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, + s->gb.buffer, get_bits_count(&s->gb)/8); if(crc8){ av_log(s->avctx, AV_LOG_ERROR, "header crc mismatch crc=%2X\n", crc8); return -1; diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 3e92c06939..59192a1e3e 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1283,7 +1283,8 @@ static void output_frame_header(FlacEncodeContext *s) put_bits(&s->pb, 16, s->sr_code[1]); } flush_put_bits(&s->pb); - crc = av_crc(av_crc07, 0, s->pb.buf, put_bits_count(&s->pb)>>3); + crc = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, + s->pb.buf, put_bits_count(&s->pb)>>3); put_bits(&s->pb, 8, crc); } @@ -1425,7 +1426,8 @@ static void output_frame_footer(FlacEncodeContext *s) { int crc; flush_put_bits(&s->pb); - crc = bswap_16(av_crc(av_crc8005, 0, s->pb.buf, put_bits_count(&s->pb)>>3)); + crc = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, + s->pb.buf, put_bits_count(&s->pb)>>3)); put_bits(&s->pb, 16, crc); flush_put_bits(&s->pb); } diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 7277f9222d..4a8cb8a603 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1247,17 +1247,6 @@ unsigned avcodec_build( void ) return LIBAVCODEC_BUILD; } -static void init_crcs(void){ -#if LIBAVUTIL_VERSION_INT < (50<<16) - av_crc04C11DB7= av_mallocz_static(sizeof(AVCRC) * 257); - av_crc8005 = av_mallocz_static(sizeof(AVCRC) * 257); - av_crc07 = av_mallocz_static(sizeof(AVCRC) * 257); -#endif - av_crc_init(av_crc04C11DB7, 0, 32, AV_CRC_32_IEEE, sizeof(AVCRC)*257); - av_crc_init(av_crc8005 , 0, 16, AV_CRC_16 , sizeof(AVCRC)*257); - av_crc_init(av_crc07 , 0, 8, AV_CRC_8_ATM , sizeof(AVCRC)*257); -} - void avcodec_init(void) { static int inited = 0; @@ -1267,7 +1256,6 @@ void avcodec_init(void) inited = 1; dsputil_static_init(); - init_crcs(); } void avcodec_flush_buffers(AVCodecContext *avctx) |