#include "common.h"
#define MKVLC( a, b ) { a, b }
-const vlc_t x264_coeff_token[5][17*4] =
+const vlc_t x264_coeff0_token[5] =
+{
+ MKVLC( 0x1, 1 ), /* str=1 */
+ MKVLC( 0x3, 2 ), /* str=11 */
+ MKVLC( 0xf, 4 ), /* str=1111 */
+ MKVLC( 0x3, 6 ), /* str=000011 */
+ MKVLC( 0x1, 2 ) /* str=01 */
+};
+
+const vlc_t x264_coeff_token[5][16*4] =
{
/* table 0 */
{
- MKVLC( 0x1, 1 ), /* str=1 */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
-
MKVLC( 0x5, 6 ), /* str=000101 */
MKVLC( 0x1, 2 ), /* str=01 */
MKVLC( 0x0, 0 ), /* str= */
/* table 1 */
{
- MKVLC( 0x3, 2 ), /* str=11 */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
-
MKVLC( 0xb, 6 ), /* str=001011 */
MKVLC( 0x2, 2 ), /* str=10 */
MKVLC( 0x0, 0 ), /* str= */
},
/* table 2 */
{
- MKVLC( 0xf, 4 ), /* str=1111 */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
-
MKVLC( 0xf, 6 ), /* str=001111 */
MKVLC( 0xe, 4 ), /* str=1110 */
MKVLC( 0x0, 0 ), /* str= */
/* table 3 */
{
- MKVLC( 0x3, 6 ), /* str=000011 */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
-
MKVLC( 0x0, 6 ), /* str=000000 */
MKVLC( 0x1, 6 ), /* str=000001 */
MKVLC( 0x0, 0 ), /* str= */
/* table 4 */
{
- MKVLC( 0x1, 2 ), /* str=01 */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
- MKVLC( 0x0, 0 ), /* str= */
-
MKVLC( 0x7, 6 ), /* str=000111 */
MKVLC( 0x1, 1 ), /* str=1 */
MKVLC( 0x0, 0 ), /* str= */
};
/* x264_run_before[__MIN( i_zero_left -1, 6 )][run_before] */
-const vlc_t x264_run_before[7][15] =
+const vlc_t x264_run_before[7][16] =
{
{ /* i_zero_left 1 */
MKVLC( 0x1, 1 ), /* str=1 */
if( !h->mb.cache.non_zero_count[x264_scan8[i_idx]] )
{
- bs_write_vlc( s, x264_coeff_token[nC][0] );
+ bs_write_vlc( s, x264_coeff0_token[nC] );
return;
}
i_sign >>= 3-i_trailing;
/* total/trailing */
- bs_write_vlc( s, x264_coeff_token[nC][i_total*4+i_trailing] );
+ bs_write_vlc( s, x264_coeff_token[nC][i_total*4+i_trailing-4] );
i_suffix_length = i_total > 10 && i_trailing < 3;
if( i_trailing > 0 || RDO_SKIP_BS )
}
else if( i_mb_type == P_8x8 )
{
- int b_sub_ref0;
+ int b_sub_ref;
if( (h->mb.cache.ref[0][x264_scan8[0]] | h->mb.cache.ref[0][x264_scan8[ 4]] |
h->mb.cache.ref[0][x264_scan8[8]] | h->mb.cache.ref[0][x264_scan8[12]]) == 0 )
{
bs_write_ue( s, 4 );
- b_sub_ref0 = 0;
+ b_sub_ref = 0;
}
else
{
bs_write_ue( s, 3 );
- b_sub_ref0 = 1;
+ b_sub_ref = h->mb.pic.i_fref[0] > 1;
}
/* sub mb type */
bs_write( s, 4, 0xf );
/* ref0 */
- if( h->mb.pic.i_fref[0] > 1 && b_sub_ref0 )
+ if( b_sub_ref )
{
bs_write_te( s, h->mb.pic.i_fref[0] - 1, h->mb.cache.ref[0][x264_scan8[0]] );
bs_write_te( s, h->mb.pic.i_fref[0] - 1, h->mb.cache.ref[0][x264_scan8[4]] );