[FFmpeg-devel] [RFC][PATCH 2/3] lavu: Add CRC64-ECMA standard tables
James Almer
jamrial at gmail.com
Sun Jan 27 07:52:14 CET 2013
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavutil/crc.c | 9 +++
libavutil/crc.h | 2 +
libavutil/crc_data.h | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/ref/fate/crc | 2 +
4 files changed, 189 insertions(+)
diff --git a/libavutil/crc.c b/libavutil/crc.c
index 792e898..169ee6c 100644
--- a/libavutil/crc.c
+++ b/libavutil/crc.c
@@ -36,6 +36,8 @@ static struct {
[AV_CRC_16_CCITT] = { 0, 16, 0x1021 },
[AV_CRC_32_IEEE] = { 0, 32, 0x04C11DB7 },
[AV_CRC_32_IEEE_LE] = { 1, 32, 0xEDB88320 },
+ [AV_CRC_64_ECMA] = { 0, 64, 0x42F0E1EBA9EA3693 },
+ [AV_CRC_64_ECMA_LE] = { 1, 64, 0xC96C5795D7870F42 },
};
static AVCRC av_crc_table[AV_CRC_MAX][257];
#endif
@@ -132,6 +134,9 @@ int main(void)
{
uint8_t buf[1999];
int i;
+ int64_t p2[2][3] = { { AV_CRC_64_ECMA_LE, 0xC96C5795D7870F42, 0x2982E0F1680E2980 },
+ { AV_CRC_64_ECMA , 0x42F0E1EBA9EA3693, 0x7B2F602DA34611BF },
+ };
int p[4][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 },
{ AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 },
{ AV_CRC_16_ANSI , 0x8005 , 0x1FBB },
@@ -142,6 +147,10 @@ int main(void)
for (i = 0; i < sizeof(buf); i++)
buf[i] = i + i * i;
+ for (i = 0; i < 2; i++) {
+ ctx = av_crc_get_table(p2[i][0]);
+ printf("crc %016llX = %016llX\n", p2[i][1], av_crc2(ctx, 0, buf, sizeof(buf)));
+ }
for (i = 0; i < 4; i++) {
ctx = av_crc_get_table(p[i][0]);
printf("crc %08X = %X\n", p[i][1], av_crc(ctx, 0, buf, sizeof(buf)));
diff --git a/libavutil/crc.h b/libavutil/crc.h
index ca693a2..6579bf9 100644
--- a/libavutil/crc.h
+++ b/libavutil/crc.h
@@ -33,6 +33,8 @@ typedef enum {
AV_CRC_16_CCITT,
AV_CRC_32_IEEE,
AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */
+ AV_CRC_64_ECMA,
+ AV_CRC_64_ECMA_LE, /*< reversed bitorder version of AV_CRC_64_ECMA */
AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */
}AVCRCId;
diff --git a/libavutil/crc_data.h b/libavutil/crc_data.h
index afa25e7..2dbd005 100644
--- a/libavutil/crc_data.h
+++ b/libavutil/crc_data.h
@@ -208,6 +208,182 @@ static const AVCRC av_crc_table[AV_CRC_MAX][257] = {
0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D, 0x00000001
},
+ [AV_CRC_64_ECMA] = {
+ 0x0000000000000000, 0x9336EAA9EBE1F042, 0x266DD453D7C3E185,
+ 0xB55B3EFA3C2211C7, 0xDFEC420E45663349, 0x4CDAA8A7AE87C30B,
+ 0xF981965D92A5D2CC, 0x6AB77CF47944228E, 0xBED9851C8ACC6692,
+ 0x2DEF6FB5612D96D0, 0x98B4514F5D0F8717, 0x0B82BBE6B6EE7755,
+ 0x6135C712CFAA55DB, 0xF2032DBB244BA599, 0x475813411869B45E,
+ 0xD46EF9E8F388441C, 0xEF85E190FF783D66, 0x7CB30B391499CD24,
+ 0xC9E835C328BBDCE3, 0x5ADEDF6AC35A2CA1, 0x3069A39EBA1E0E2F,
+ 0xA35F493751FFFE6D, 0x160477CD6DDDEFAA, 0x85329D64863C1FE8,
+ 0x515C648C75B45BF4, 0xC26A8E259E55ABB6, 0x7731B0DFA277BA71,
+ 0xE4075A7649964A33, 0x8EB0268230D268BD, 0x1D86CC2BDB3398FF,
+ 0xA8DDF2D1E7118938, 0x3BEB18780CF0797A, 0xDE0BC321FFF17ACC,
+ 0x4D3D298814108A8E, 0xF866177228329B49, 0x6B50FDDBC3D36B0B,
+ 0x01E7812FBA974985, 0x92D16B865176B9C7, 0x278A557C6D54A800,
+ 0xB4BCBFD586B55842, 0x60D2463D753D1C5E, 0xF3E4AC949EDCEC1C,
+ 0x46BF926EA2FEFDDB, 0xD58978C7491F0D99, 0xBF3E0433305B2F17,
+ 0x2C08EE9ADBBADF55, 0x9953D060E798CE92, 0x0A653AC90C793ED0,
+ 0x318E22B1008947AA, 0xA2B8C818EB68B7E8, 0x17E3F6E2D74AA62F,
+ 0x84D51C4B3CAB566D, 0xEE6260BF45EF74E3, 0x7D548A16AE0E84A1,
+ 0xC80FB4EC922C9566, 0x5B395E4579CD6524, 0x8F57A7AD8A452138,
+ 0x1C614D0461A4D17A, 0xA93A73FE5D86C0BD, 0x3A0C9957B66730FF,
+ 0x50BBE5A3CF231271, 0xC38D0F0A24C2E233, 0x76D631F018E0F3F4,
+ 0xE5E0DB59F30103B6, 0x2F216CEA150205DA, 0xBC178643FEE3F598,
+ 0x094CB8B9C2C1E45F, 0x9A7A52102920141D, 0xF0CD2EE450643693,
+ 0x63FBC44DBB85C6D1, 0xD6A0FAB787A7D716, 0x4596101E6C462754,
+ 0x91F8E9F69FCE6348, 0x02CE035F742F930A, 0xB7953DA5480D82CD,
+ 0x24A3D70CA3EC728F, 0x4E14ABF8DAA85001, 0xDD2241513149A043,
+ 0x68797FAB0D6BB184, 0xFB4F9502E68A41C6, 0xC0A48D7AEA7A38BC,
+ 0x539267D3019BC8FE, 0xE6C959293DB9D939, 0x75FFB380D658297B,
+ 0x1F48CF74AF1C0BF5, 0x8C7E25DD44FDFBB7, 0x39251B2778DFEA70,
+ 0xAA13F18E933E1A32, 0x7E7D086660B65E2E, 0xED4BE2CF8B57AE6C,
+ 0x5810DC35B775BFAB, 0xCB26369C5C944FE9, 0xA1914A6825D06D67,
+ 0x32A7A0C1CE319D25, 0x87FC9E3BF2138CE2, 0x14CA749219F27CA0,
+ 0xF12AAFCBEAF37F16, 0x621C456201128F54, 0xD7477B983D309E93,
+ 0x44719131D6D16ED1, 0x2EC6EDC5AF954C5F, 0xBDF0076C4474BC1D,
+ 0x08AB39967856ADDA, 0x9B9DD33F93B75D98, 0x4FF32AD7603F1984,
+ 0xDCC5C07E8BDEE9C6, 0x699EFE84B7FCF801, 0xFAA8142D5C1D0843,
+ 0x901F68D925592ACD, 0x03298270CEB8DA8F, 0xB672BC8AF29ACB48,
+ 0x25445623197B3B0A, 0x1EAF4E5B158B4270, 0x8D99A4F2FE6AB232,
+ 0x38C29A08C248A3F5, 0xABF470A129A953B7, 0xC1430C5550ED7139,
+ 0x5275E6FCBB0C817B, 0xE72ED806872E90BC, 0x741832AF6CCF60FE,
+ 0xA076CB479F4724E2, 0x334021EE74A6D4A0, 0x861B1F144884C567,
+ 0x152DF5BDA3653525, 0x7F9A8949DA2117AB, 0xECAC63E031C0E7E9,
+ 0x59F75D1A0DE2F62E, 0xCAC1B7B3E603066C, 0xCD74327DC0E5FAF6,
+ 0x5E42D8D42B040AB4, 0xEB19E62E17261B73, 0x782F0C87FCC7EB31,
+ 0x129870738583C9BF, 0x81AE9ADA6E6239FD, 0x34F5A4205240283A,
+ 0xA7C34E89B9A1D878, 0x73ADB7614A299C64, 0xE09B5DC8A1C86C26,
+ 0x55C063329DEA7DE1, 0xC6F6899B760B8DA3, 0xAC41F56F0F4FAF2D,
+ 0x3F771FC6E4AE5F6F, 0x8A2C213CD88C4EA8, 0x191ACB95336DBEEA,
+ 0x22F1D3ED3F9DC790, 0xB1C73944D47C37D2, 0x049C07BEE85E2615,
+ 0x97AAED1703BFD657, 0xFD1D91E37AFBF4D9, 0x6E2B7B4A911A049B,
+ 0xDB7045B0AD38155C, 0x4846AF1946D9E51E, 0x9C2856F1B551A102,
+ 0x0F1EBC585EB05140, 0xBA4582A262924087, 0x2973680B8973B0C5,
+ 0x43C414FFF037924B, 0xD0F2FE561BD66209, 0x65A9C0AC27F473CE,
+ 0xF69F2A05CC15838C, 0x137FF15C3F14803A, 0x80491BF5D4F57078,
+ 0x3512250FE8D761BF, 0xA624CFA6033691FD, 0xCC93B3527A72B373,
+ 0x5FA559FB91934331, 0xEAFE6701ADB152F6, 0x79C88DA84650A2B4,
+ 0xADA67440B5D8E6A8, 0x3E909EE95E3916EA, 0x8BCBA013621B072D,
+ 0x18FD4ABA89FAF76F, 0x724A364EF0BED5E1, 0xE17CDCE71B5F25A3,
+ 0x5427E21D277D3464, 0xC71108B4CC9CC426, 0xFCFA10CCC06CBD5C,
+ 0x6FCCFA652B8D4D1E, 0xDA97C49F17AF5CD9, 0x49A12E36FC4EAC9B,
+ 0x231652C2850A8E15, 0xB020B86B6EEB7E57, 0x057B869152C96F90,
+ 0x964D6C38B9289FD2, 0x422395D04AA0DBCE, 0xD1157F79A1412B8C,
+ 0x644E41839D633A4B, 0xF778AB2A7682CA09, 0x9DCFD7DE0FC6E887,
+ 0x0EF93D77E42718C5, 0xBBA2038DD8050902, 0x2894E92433E4F940,
+ 0xE2555E97D5E7FF2C, 0x7163B43E3E060F6E, 0xC4388AC402241EA9,
+ 0x570E606DE9C5EEEB, 0x3DB91C999081CC65, 0xAE8FF6307B603C27,
+ 0x1BD4C8CA47422DE0, 0x88E22263ACA3DDA2, 0x5C8CDB8B5F2B99BE,
+ 0xCFBA3122B4CA69FC, 0x7AE10FD888E8783B, 0xE9D7E57163098879,
+ 0x836099851A4DAAF7, 0x1056732CF1AC5AB5, 0xA50D4DD6CD8E4B72,
+ 0x363BA77F266FBB30, 0x0DD0BF072A9FC24A, 0x9EE655AEC17E3208,
+ 0x2BBD6B54FD5C23CF, 0xB88B81FD16BDD38D, 0xD23CFD096FF9F103,
+ 0x410A17A084180141, 0xF451295AB83A1086, 0x6767C3F353DBE0C4,
+ 0xB3093A1BA053A4D8, 0x203FD0B24BB2549A, 0x9564EE487790455D,
+ 0x065204E19C71B51F, 0x6CE57815E5359791, 0xFFD392BC0ED467D3,
+ 0x4A88AC4632F67614, 0xD9BE46EFD9178656, 0x3C5E9DB62A1685E0,
+ 0xAF68771FC1F775A2, 0x1A3349E5FDD56465, 0x8905A34C16349427,
+ 0xE3B2DFB86F70B6A9, 0x70843511849146EB, 0xC5DF0BEBB8B3572C,
+ 0x56E9E1425352A76E, 0x828718AAA0DAE372, 0x11B1F2034B3B1330,
+ 0xA4EACCF9771902F7, 0x37DC26509CF8F2B5, 0x5D6B5AA4E5BCD03B,
+ 0xCE5DB00D0E5D2079, 0x7B068EF7327F31BE, 0xE830645ED99EC1FC,
+ 0xD3DB7C26D56EB886, 0x40ED968F3E8F48C4, 0xF5B6A87502AD5903,
+ 0x668042DCE94CA941, 0x0C373E2890088BCF, 0x9F01D4817BE97B8D,
+ 0x2A5AEA7B47CB6A4A, 0xB96C00D2AC2A9A08, 0x6D02F93A5FA2DE14,
+ 0xFE341393B4432E56, 0x4B6F2D6988613F91, 0xD859C7C06380CFD3,
+ 0xB2EEBB341AC4ED5D, 0x21D8519DF1251D1F, 0x94836F67CD070CD8,
+ 0x07B585CE26E6FC9A, 0x0000000000000001
+ },
+ [AV_CRC_64_ECMA_LE] = {
+ 0x0000000000000000, 0xB32E4CBE03A75F6F, 0xF4843657A840A05B,
+ 0x47AA7AE9ABE7FF34, 0x7BD0C384FF8F5E33, 0xC8FE8F3AFC28015C,
+ 0x8F54F5D357CFFE68, 0x3C7AB96D5468A107, 0xF7A18709FF1EBC66,
+ 0x448FCBB7FCB9E309, 0x0325B15E575E1C3D, 0xB00BFDE054F94352,
+ 0x8C71448D0091E255, 0x3F5F08330336BD3A, 0x78F572DAA8D1420E,
+ 0xCBDB3E64AB761D61, 0x7D9BA13851336649, 0xCEB5ED8652943926,
+ 0x891F976FF973C612, 0x3A31DBD1FAD4997D, 0x064B62BCAEBC387A,
+ 0xB5652E02AD1B6715, 0xF2CF54EB06FC9821, 0x41E11855055BC74E,
+ 0x8A3A2631AE2DDA2F, 0x39146A8FAD8A8540, 0x7EBE1066066D7A74,
+ 0xCD905CD805CA251B, 0xF1EAE5B551A2841C, 0x42C4A90B5205DB73,
+ 0x056ED3E2F9E22447, 0xB6409F5CFA457B28, 0xFB374270A266CC92,
+ 0x48190ECEA1C193FD, 0x0FB374270A266CC9, 0xBC9D3899098133A6,
+ 0x80E781F45DE992A1, 0x33C9CD4A5E4ECDCE, 0x7463B7A3F5A932FA,
+ 0xC74DFB1DF60E6D95, 0x0C96C5795D7870F4, 0xBFB889C75EDF2F9B,
+ 0xF812F32EF538D0AF, 0x4B3CBF90F69F8FC0, 0x774606FDA2F72EC7,
+ 0xC4684A43A15071A8, 0x83C230AA0AB78E9C, 0x30EC7C140910D1F3,
+ 0x86ACE348F355AADB, 0x3582AFF6F0F2F5B4, 0x7228D51F5B150A80,
+ 0xC10699A158B255EF, 0xFD7C20CC0CDAF4E8, 0x4E526C720F7DAB87,
+ 0x09F8169BA49A54B3, 0xBAD65A25A73D0BDC, 0x710D64410C4B16BD,
+ 0xC22328FF0FEC49D2, 0x85895216A40BB6E6, 0x36A71EA8A7ACE989,
+ 0x0ADDA7C5F3C4488E, 0xB9F3EB7BF06317E1, 0xFE5991925B84E8D5,
+ 0x4D77DD2C5823B7BA, 0x64B62BCAEBC387A1, 0xD7986774E864D8CE,
+ 0x90321D9D438327FA, 0x231C512340247895, 0x1F66E84E144CD992,
+ 0xAC48A4F017EB86FD, 0xEBE2DE19BC0C79C9, 0x58CC92A7BFAB26A6,
+ 0x9317ACC314DD3BC7, 0x2039E07D177A64A8, 0x67939A94BC9D9B9C,
+ 0xD4BDD62ABF3AC4F3, 0xE8C76F47EB5265F4, 0x5BE923F9E8F53A9B,
+ 0x1C4359104312C5AF, 0xAF6D15AE40B59AC0, 0x192D8AF2BAF0E1E8,
+ 0xAA03C64CB957BE87, 0xEDA9BCA512B041B3, 0x5E87F01B11171EDC,
+ 0x62FD4976457FBFDB, 0xD1D305C846D8E0B4, 0x96797F21ED3F1F80,
+ 0x2557339FEE9840EF, 0xEE8C0DFB45EE5D8E, 0x5DA24145464902E1,
+ 0x1A083BACEDAEFDD5, 0xA9267712EE09A2BA, 0x955CCE7FBA6103BD,
+ 0x267282C1B9C65CD2, 0x61D8F8281221A3E6, 0xD2F6B4961186FC89,
+ 0x9F8169BA49A54B33, 0x2CAF25044A02145C, 0x6B055FEDE1E5EB68,
+ 0xD82B1353E242B407, 0xE451AA3EB62A1500, 0x577FE680B58D4A6F,
+ 0x10D59C691E6AB55B, 0xA3FBD0D71DCDEA34, 0x6820EEB3B6BBF755,
+ 0xDB0EA20DB51CA83A, 0x9CA4D8E41EFB570E, 0x2F8A945A1D5C0861,
+ 0x13F02D374934A966, 0xA0DE61894A93F609, 0xE7741B60E174093D,
+ 0x545A57DEE2D35652, 0xE21AC88218962D7A, 0x5134843C1B317215,
+ 0x169EFED5B0D68D21, 0xA5B0B26BB371D24E, 0x99CA0B06E7197349,
+ 0x2AE447B8E4BE2C26, 0x6D4E3D514F59D312, 0xDE6071EF4CFE8C7D,
+ 0x15BB4F8BE788911C, 0xA6950335E42FCE73, 0xE13F79DC4FC83147,
+ 0x521135624C6F6E28, 0x6E6B8C0F1807CF2F, 0xDD45C0B11BA09040,
+ 0x9AEFBA58B0476F74, 0x29C1F6E6B3E0301B, 0xC96C5795D7870F42,
+ 0x7A421B2BD420502D, 0x3DE861C27FC7AF19, 0x8EC62D7C7C60F076,
+ 0xB2BC941128085171, 0x0192D8AF2BAF0E1E, 0x4638A2468048F12A,
+ 0xF516EEF883EFAE45, 0x3ECDD09C2899B324, 0x8DE39C222B3EEC4B,
+ 0xCA49E6CB80D9137F, 0x7967AA75837E4C10, 0x451D1318D716ED17,
+ 0xF6335FA6D4B1B278, 0xB199254F7F564D4C, 0x02B769F17CF11223,
+ 0xB4F7F6AD86B4690B, 0x07D9BA1385133664, 0x4073C0FA2EF4C950,
+ 0xF35D8C442D53963F, 0xCF273529793B3738, 0x7C0979977A9C6857,
+ 0x3BA3037ED17B9763, 0x888D4FC0D2DCC80C, 0x435671A479AAD56D,
+ 0xF0783D1A7A0D8A02, 0xB7D247F3D1EA7536, 0x04FC0B4DD24D2A59,
+ 0x3886B22086258B5E, 0x8BA8FE9E8582D431, 0xCC0284772E652B05,
+ 0x7F2CC8C92DC2746A, 0x325B15E575E1C3D0, 0x8175595B76469CBF,
+ 0xC6DF23B2DDA1638B, 0x75F16F0CDE063CE4, 0x498BD6618A6E9DE3,
+ 0xFAA59ADF89C9C28C, 0xBD0FE036222E3DB8, 0x0E21AC88218962D7,
+ 0xC5FA92EC8AFF7FB6, 0x76D4DE52895820D9, 0x317EA4BB22BFDFED,
+ 0x8250E80521188082, 0xBE2A516875702185, 0x0D041DD676D77EEA,
+ 0x4AAE673FDD3081DE, 0xF9802B81DE97DEB1, 0x4FC0B4DD24D2A599,
+ 0xFCEEF8632775FAF6, 0xBB44828A8C9205C2, 0x086ACE348F355AAD,
+ 0x34107759DB5DFBAA, 0x873E3BE7D8FAA4C5, 0xC094410E731D5BF1,
+ 0x73BA0DB070BA049E, 0xB86133D4DBCC19FF, 0x0B4F7F6AD86B4690,
+ 0x4CE50583738CB9A4, 0xFFCB493D702BE6CB, 0xC3B1F050244347CC,
+ 0x709FBCEE27E418A3, 0x3735C6078C03E797, 0x841B8AB98FA4B8F8,
+ 0xADDA7C5F3C4488E3, 0x1EF430E13FE3D78C, 0x595E4A08940428B8,
+ 0xEA7006B697A377D7, 0xD60ABFDBC3CBD6D0, 0x6524F365C06C89BF,
+ 0x228E898C6B8B768B, 0x91A0C532682C29E4, 0x5A7BFB56C35A3485,
+ 0xE955B7E8C0FD6BEA, 0xAEFFCD016B1A94DE, 0x1DD181BF68BDCBB1,
+ 0x21AB38D23CD56AB6, 0x9285746C3F7235D9, 0xD52F0E859495CAED,
+ 0x6601423B97329582, 0xD041DD676D77EEAA, 0x636F91D96ED0B1C5,
+ 0x24C5EB30C5374EF1, 0x97EBA78EC690119E, 0xAB911EE392F8B099,
+ 0x18BF525D915FEFF6, 0x5F1528B43AB810C2, 0xEC3B640A391F4FAD,
+ 0x27E05A6E926952CC, 0x94CE16D091CE0DA3, 0xD3646C393A29F297,
+ 0x604A2087398EADF8, 0x5C3099EA6DE60CFF, 0xEF1ED5546E415390,
+ 0xA8B4AFBDC5A6ACA4, 0x1B9AE303C601F3CB, 0x56ED3E2F9E224471,
+ 0xE5C372919D851B1E, 0xA26908783662E42A, 0x114744C635C5BB45,
+ 0x2D3DFDAB61AD1A42, 0x9E13B115620A452D, 0xD9B9CBFCC9EDBA19,
+ 0x6A978742CA4AE576, 0xA14CB926613CF817, 0x1262F598629BA778,
+ 0x55C88F71C97C584C, 0xE6E6C3CFCADB0723, 0xDA9C7AA29EB3A624,
+ 0x69B2361C9D14F94B, 0x2E184CF536F3067F, 0x9D36004B35545910,
+ 0x2B769F17CF112238, 0x9858D3A9CCB67D57, 0xDFF2A94067518263,
+ 0x6CDCE5FE64F6DD0C, 0x50A65C93309E7C0B, 0xE388102D33392364,
+ 0xA4226AC498DEDC50, 0x170C267A9B79833F, 0xDCD7181E300F9E5E,
+ 0x6FF954A033A8C131, 0x28532E49984F3E05, 0x9B7D62F79BE8616A,
+ 0xA707DB9ACF80C06D, 0x14299724CC279F02, 0x5383EDCD67C06036,
+ 0xE0ADA17364673F59, 0x0000000000000001
+ },
};
#endif /* AVUTIL_CRC_DATA_H */
diff --git a/tests/ref/fate/crc b/tests/ref/fate/crc
index 1c24aea..ce82b47 100644
--- a/tests/ref/fate/crc
+++ b/tests/ref/fate/crc
@@ -1,3 +1,5 @@
+crc C96C5795D7870F42 = 2982E0F1680E2980
+crc 42F0E1EBA9EA3693 = 7B2F602DA34611BF
crc EDB88320 = 3D5CDD04
crc 04C11DB7 = E0BAF5C0
crc 00008005 = BB1F
--
1.7.12.4
More information about the ffmpeg-devel
mailing list