]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mlp.c
Bump version and update APIchanges after r25210.
[ffmpeg] / libavcodec / mlp.c
index f2a02765743d5053ef857754b5f550496b0f4750..87f7c771395c35bc1f4bda3020841012a4e168a1 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdint.h>
 
 #include "libavutil/crc.h"
+#include "libavutil/intreadwrite.h"
 #include "mlp.h"
 
 const uint8_t ff_mlp_huffman_tables[3][18][2] = {
@@ -41,28 +42,21 @@ const uint8_t ff_mlp_huffman_tables[3][18][2] = {
 };
 
 static int crc_init = 0;
-static AVCRC crc_63[1024];
-static AVCRC crc_1D[1024];
-
-
-static int crc_init_2D = 0;
-static AVCRC crc_2D[1024];
-
-int av_cold ff_mlp_init_crc2D(AVCodecParserContext *s)
-{
-    if (!crc_init_2D) {
-        av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
-        crc_init_2D = 1;
-    }
-
-    return 0;
-}
-
-void av_cold ff_mlp_init_crc()
+#if CONFIG_SMALL
+#define CRC_TABLE_SIZE 257
+#else
+#define CRC_TABLE_SIZE 1024
+#endif
+static AVCRC crc_63[CRC_TABLE_SIZE];
+static AVCRC crc_1D[CRC_TABLE_SIZE];
+static AVCRC crc_2D[CRC_TABLE_SIZE];
+
+av_cold void ff_mlp_init_crc(void)
 {
     if (!crc_init) {
         av_crc_init(crc_63, 0,  8,   0x63, sizeof(crc_63));
         av_crc_init(crc_1D, 0,  8,   0x1D, sizeof(crc_1D));
+        av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
         crc_init = 1;
     }
 }
@@ -107,11 +101,12 @@ uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size)
     uint32_t scratch = 0;
     const uint8_t *buf_end = buf + buf_size;
 
+    for (; ((intptr_t) buf & 3) && buf < buf_end; buf++)
+        scratch ^= *buf;
     for (; buf < buf_end - 3; buf += 4)
         scratch ^= *((const uint32_t*)buf);
 
-    scratch ^= scratch >> 16;
-    scratch ^= scratch >> 8;
+    scratch = xor_32_to_8(scratch);
 
     for (; buf < buf_end; buf++)
         scratch ^= *buf;