]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
mlp: split simple inline function that xors 4 bytes into one.
authorramiro <ramiro@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Thu, 14 Aug 2008 03:58:05 +0000 (03:58 +0000)
committerramiro <ramiro@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Thu, 14 Aug 2008 03:58:05 +0000 (03:58 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@14747 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/mlp.c
libavcodec/mlp.h
libavcodec/mlpdec.c

index f2a02765743d5053ef857754b5f550496b0f4750..2ac2e658f16e5beee1bd716897f567aae8a42182 100644 (file)
@@ -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;
index dc6856727a44b57cb9181834cc0da9fd2c5ae47c..a434cd1a229935d5442d7e1ca647c854edd153ff 100644 (file)
@@ -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 */
index d44c9b0b292ecdc99b1ec03192cd8f6dc6d2a230..421abdece1312d421c8710bb60b12de10e2e512a 100644 (file)
@@ -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",