changeset 7566:d112b4655bbd libavcodec

mlp: split simple inline function that xors 4 bytes into one.
author ramiro
date Thu, 14 Aug 2008 03:58:05 +0000
parents 474c7ae4b431
children 75841957d08b
files mlp.c mlp.h mlpdec.c
diffstat 3 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mlp.c	Wed Aug 13 23:36:37 2008 +0000
+++ b/mlp.c	Thu Aug 14 03:58:05 2008 +0000
@@ -110,8 +110,7 @@
     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;
--- a/mlp.h	Wed Aug 13 23:36:37 2008 +0000
+++ b/mlp.h	Thu Aug 14 03:58:05 2008 +0000
@@ -107,4 +107,12 @@
 
 void ff_mlp_init_crc();
 
+/** XOR four bytes into one. */
+static inline uint8_t xor_32_to_8(uint32_t value)
+{
+    value ^= value >> 16;
+    value ^= value >>  8;
+    return value;
+}
+
 #endif /* FFMPEG_MLP_H */
--- a/mlpdec.c	Wed Aug 13 23:36:37 2008 +0000
+++ b/mlpdec.c	Thu Aug 14 03:58:05 2008 +0000
@@ -364,10 +364,7 @@
     lossless_check = get_bits(gbp, 8);
     if (substr == m->max_decoded_substream
         && s->lossless_check_data != 0xffffffff) {
-        tmp = s->lossless_check_data;
-        tmp ^= tmp >> 16;
-        tmp ^= tmp >> 8;
-        tmp &= 0xff;
+        tmp = xor_32_to_8(s->lossless_check_data);
         if (tmp != lossless_check)
             av_log(m->avctx, AV_LOG_WARNING,
                    "Lossless check failed - expected %02x, calculated %02x.\n",