[SCM] libav/experimental: mlp: split simple inline function that xors 4 bytes into one.

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:27:31 UTC 2013


The following commit has been merged in the experimental branch:
commit a7cc783d711f0f47eb748a33b55d0c4f57ac1840
Author: Ramiro Polla <ramiro.polla at gmail.com>
Date:   Thu Aug 14 03:58:05 2008 +0000

    mlp: split simple inline function that xors 4 bytes into one.
    
    Originally committed as revision 14747 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/mlp.c b/libavcodec/mlp.c
index f2a0276..2ac2e65 100644
--- a/libavcodec/mlp.c
+++ b/libavcodec/mlp.c
@@ -110,8 +110,7 @@ uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size)
     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;
diff --git a/libavcodec/mlp.h b/libavcodec/mlp.h
index dc68567..a434cd1 100644
--- a/libavcodec/mlp.h
+++ b/libavcodec/mlp.h
@@ -107,4 +107,12 @@ int ff_mlp_init_crc2D(AVCodecParserContext *s);
 
 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 */
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index d44c9b0..421abde 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -364,10 +364,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
     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",

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list