avcodec/dvdsubdec: Avoid branch in decode_run_8bit()
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 13 Sep 2018 02:24:49 +0000 (04:24 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 18 Nov 2018 01:35:03 +0000 (02:35 +0100)
Speed improvment 35.5 sec -> 34.7sec

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 71bf0330505e2108935d05c5c018ec65eac4b946)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/dvdsubdec.c

index 0c73fb2..79cb0c4 100644 (file)
@@ -82,10 +82,7 @@ static int decode_run_8bit(GetBitContext *gb, int *color)
 {
     int len;
     int has_run = get_bits1(gb);
-    if (get_bits1(gb))
-        *color = get_bits(gb, 8);
-    else
-        *color = get_bits(gb, 2);
+    *color = get_bits(gb, 2 + 6*get_bits1(gb));
     if (has_run) {
         if (get_bits1(gb)) {
             len = get_bits(gb, 7);