]> git.sesse.net Git - ffmpeg/commitdiff
avformat/matroskadec: Beautify matroska_parse_laces()
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 20 May 2020 19:24:34 +0000 (21:24 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 26 May 2020 04:19:25 +0000 (06:19 +0200)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/matroskadec.c

index b75db0dcc5e394dbe37d7c5b0ef6df9052c6a136..bb3a126c293cebb2099f2dfec4094659d1d1e3a9 100644 (file)
@@ -3037,9 +3037,9 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
     if (size <= 0)
         return AVERROR_INVALIDDATA;
 
-    *laces    = *data + 1;
-    data     += 1;
-    size     -= 1;
+    *laces = *data + 1;
+    data  += 1;
+    size  -= 1;
 
     switch (type) {
     case 0x1: /* Xiph lacing */
@@ -3049,31 +3049,26 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
         for (n = 0; n < *laces - 1; n++) {
             lace_size[n] = 0;
 
-            while (1) {
-                if (size <= total) {
+            do {
+                if (size <= total)
                     return AVERROR_INVALIDDATA;
-                }
                 temp          = *data;
                 total        += temp;
                 lace_size[n] += temp;
                 data         += 1;
                 size         -= 1;
-                if (temp != 0xff)
-                    break;
-            }
+            } while (temp ==  0xff);
         }
-        if (size < total) {
+        if (size < total)
             return AVERROR_INVALIDDATA;
-        }
 
         lace_size[n] = size - total;
         break;
     }
 
     case 0x2: /* fixed-size lacing */
-        if (size % (*laces)) {
+        if (size % (*laces))
             return AVERROR_INVALIDDATA;
-        }
         for (n = 0; n < *laces; n++)
             lace_size[n] = size / *laces;
         break;
@@ -3109,15 +3104,15 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
         }
         data += offset;
         size -= offset;
-        if (size < total) {
+        if (size < total)
             return AVERROR_INVALIDDATA;
-        }
+
         lace_size[*laces - 1] = size - total;
         break;
     }
     }
 
-    *buf      = data;
+    *buf = data;
 
     return 0;
 }