/*****************************************************************************
* 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
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;
}