[FFmpeg-devel] Small CRC32 standard tables
James Almer
jamrial at gmail.com
Sat Jun 1 06:36:38 CEST 2013
Currently, standard tables like AV_CRC_32_IEEE and such are being generated (or
provided in case the user compiles with hardcoded tables) with only 257 elements.
We're missing a considerable boost in performance by not making them with a size
of 1024 elements instead.
By applying something like this
---
diff --git a/libavutil/crc.c b/libavutil/crc.c
index 9ee5efe..bec0d80 100644
--- a/libavutil/crc.c
+++ b/libavutil/crc.c
@@ -211,6 +211,11 @@ static const AVCRC av_crc_table[AV_CRC_MAX][257] = {
},
};
#else
+#if CONFIG_SMALL
+#define AV_CRC_TABLE_SIZE 257
+#else
+#define AV_CRC_TABLE_SIZE 1024
+#endif
static struct {
uint8_t le;
uint8_t bits;
@@ -222,7 +227,7 @@ static struct {
[AV_CRC_32_IEEE] = { 0, 32, 0x04C11DB7 },
[AV_CRC_32_IEEE_LE] = { 1, 32, 0xEDB88320 },
};
-static AVCRC av_crc_table[AV_CRC_MAX][257];
+static AVCRC av_crc_table[AV_CRC_MAX][AV_CRC_TABLE_SIZE];
#endif
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size)
---
I'm getting 2x to 3x faster calculations when data.
A ~260mb file is processed in ~0.9 seconds using ffhash git head, but in ~0.4
seconds if i apply the above change.
Similarly, using a modified version of Nicolas George's hash_bench tool to run
CRC32 instead of md5 or sha, i get ~2.5 seconds with the patch above, compared to
~7 seconds without it.
Is there a reason why we're providing small tables with av_crc_get_table()?
As things are right now, using av_crc_init() with any of the standard polynomials
and a context of size 1024 will pretty much always be the better option.
Regards.
More information about the ffmpeg-devel
mailing list