diff mxf.c @ 1644:f5a0cd8c23ac libavformat

Simplify klv_decode_ber_length
author reimar
date Sun, 14 Jan 2007 16:02:22 +0000
parents eeb3521e4d09
children 52215d40cb3f
line wrap: on
line diff
--- a/mxf.c	Sun Jan 14 13:57:26 2007 +0000
+++ b/mxf.c	Sun Jan 14 16:02:22 2007 +0000
@@ -182,19 +182,15 @@
 
 static int64_t klv_decode_ber_length(ByteIOContext *pb)
 {
-    int64_t size = 0;
-    uint8_t length = get_byte(pb);
-    int type = length >> 7;
-
-    if (type) { /* long form */
-        int bytes_num = length & 0x7f;
+    uint64_t size = get_byte(pb);
+    if (size & 0x80) { /* long form */
+        int bytes_num = size & 0x7f;
         /* SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes */
         if (bytes_num > 8)
             return -1;
+        size = 0;
         while (bytes_num--)
             size = size << 8 | get_byte(pb);
-    } else {
-        size = length & 0x7f;
     }
     return size;
 }