]> git.sesse.net Git - x264/blobdiff - common/vlc.c
cli: Refactor filter option parsing
[x264] / common / vlc.c
index e6dc77a1abd30b79ae0b5e1779b37c8273b93039..cc9ed9d0416bab727eec0c3b1666a237bfd91fb9 100644 (file)
@@ -1,11 +1,11 @@
 /*****************************************************************************
  * vlc.c : vlc tables
  *****************************************************************************
- * Copyright (C) 2003-2011 x264 project
+ * Copyright (C) 2003-2016 x264 project
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Fiona Glaser <fiona@x264.com>
- *          Henrik Gramner <hengar-6@student.ltu.se>
+ *          Henrik Gramner <henrik@gramner.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -852,15 +852,17 @@ void x264_cavlc_init( x264_t *h )
             dct[j] = i&(1<<j);
         int total = h->quantf.coeff_level_run[DCT_LUMA_4x4]( dct, &runlevel );
         int zeros = runlevel.last + 1 - total;
+        uint32_t mask = i << (x264_clz( i ) + 1);
         for( int j = 0; j < total-1 && zeros > 0; j++ )
         {
             int idx = X264_MIN(zeros, 7) - 1;
-            int run = runlevel.run[j];
+            int run = x264_clz( mask );
             int len = run_before[idx][run].i_size;
             size += len;
             bits <<= len;
             bits |= run_before[idx][run].i_bits;
             zeros -= run;
+            mask <<= run + 1;
         }
         x264_run_before[i] = (bits << 5) + size;
     }