[FFmpeg-devel] [RFC] add some defines for CRC polynomials

Reimar Döffinger Reimar.Doeffinger
Sun Aug 19 13:47:43 CEST 2007


Hello,
attached patch would use some defines with hopefully correct and more
useful names instead of using the raw hex numbers for the generator
polynomials.
Of course it is questionable if it is such a good idea while keeping
names like av_crcEDB88320 (which btw. is not used at all? should it be
removed?)

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavcodec/utils.c
===================================================================
--- libavcodec/utils.c	(revision 10141)
+++ libavcodec/utils.c	(working copy)
@@ -1235,9 +1235,9 @@
     av_crc8005    = av_mallocz_static(sizeof(AVCRC) * 257);
     av_crc07      = av_mallocz_static(sizeof(AVCRC) * 257);
 #endif
-    av_crc_init(av_crc04C11DB7, 0, 32, 0x04c11db7, sizeof(AVCRC)*257);
-    av_crc_init(av_crc8005    , 0, 16, 0x8005    , sizeof(AVCRC)*257);
-    av_crc_init(av_crc07      , 0,  8, 0x07      , sizeof(AVCRC)*257);
+    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)
Index: libavutil/crc.c
===================================================================
--- libavutil/crc.c	(revision 10141)
+++ libavutil/crc.c	(working copy)
@@ -94,10 +109,10 @@
 main(){
     uint8_t buf[1999];
     int i;
-    int p[4][4]={{1, 32, 0xedb88320L, 0x3D5CDD04},
-                 {0, 32, 0x04c11db7L, 0xC0F5BAE0},
-                 {0, 16, 0x8005     , 0x1FBB    },
-                 {0,  8, 0x07       , 0xE3      },};
+    int p[4][4]={{1, 32, AV_CRC_32_IEEE_LE, 0x3D5CDD04},
+                 {0, 32, AV_CRC_32_IEEE   , 0xC0F5BAE0},
+                 {0, 16, AV_CRC_16        , 0x1FBB    },
+                 {0,  8, AV_CRC_8_ATM     , 0xE3      },};
     AVCRC ctx[1 ? 1024:257];
 
     for(i=0; i<sizeof(buf); i++)
Index: libavutil/crc.h
===================================================================
--- libavutil/crc.h	(revision 10141)
+++ libavutil/crc.h	(working copy)
@@ -26,6 +26,13 @@
 
 typedef uint32_t AVCRC;
 
+#define AV_CRC_8_ATM      0x07
+#define AV_CRC_16         0x8005
+#define AV_CRC_16_CCITT   0x1021
+#define AV_CRC_32_IEEE    0x04C11DB7L
+//! reversed bitorder version of AV_CRC_32_IEEE
+#define AV_CRC_32_IEEE_LE 0xEDB88320L
+
 #if LIBAVUTIL_VERSION_INT  < (50<<16)
 extern AVCRC *av_crcEDB88320;
 extern AVCRC *av_crc04C11DB7;



More information about the ffmpeg-devel mailing list