~siretart/x264/trunk

« back to all changes in this revision

Viewing changes to encoder/cabac.c

  • Committer: Anton Mitrofanov
  • Author(s): Vittorio Giovara
  • Date: 2017-12-24 20:47:24 UTC
  • Revision ID: git-v1:71ed44c7312438fac7c5c5301e45522e57127db4
Unify 8-bit and 10-bit CLI and libraries

Add 'i_bitdepth' to x264_param_t with the corresponding '--output-depth' CLI
option to set the bit depth at runtime.

Drop the 'x264_bit_depth' global variable. Rather than hardcoding it to an
incorrect value, it's preferable to induce a linking failure. If applications
relies on this symbol this will make it more obvious where the problem is.

Add Makefile rules that compiles modules with different bit depths. Assembly
on x86 is prefixed with the 'private_prefix' define, while all other archs
modify their function prefix internally.

Templatize the main C library, x86/x86_64 assembly, ARM assembly, AARCH64
assembly, PowerPC assembly, and MIPS assembly.

The depth and cache CLI filters heavily depend on bit depth size, so they
need to be duplicated for each value. This means having to rename these
filters, and adjust the callers to use the right version.

Unfortunately the threaded input CLI module inherits a common.h dependency
(input/frame -> common/threadpool -> common/frame -> common/common) which
is extremely complicated to address in a sensible way. Instead duplicate
the module and select the appropriate one at run time.

Each bitdepth needs different checkasm compilation rules, so split the main
checkasm target into two executables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
644
644
    }
645
645
}
646
646
 
647
 
#if !RDO_SKIP_BS
648
 
extern const uint8_t x264_significant_coeff_flag_offset_8x8[2][64];
649
 
extern const uint8_t x264_last_coeff_flag_offset_8x8[63];
650
 
extern const uint8_t x264_coeff_flag_offset_chroma_422_dc[7];
651
 
extern const uint16_t x264_significant_coeff_flag_offset[2][16];
652
 
extern const uint16_t x264_last_coeff_flag_offset[2][16];
653
 
extern const uint16_t x264_coeff_abs_level_m1_offset[16];
654
 
extern const uint8_t x264_count_cat_m1[14];
655
 
#else
656
 
/* Padded to [64] for easier addressing */
657
 
const uint8_t x264_significant_coeff_flag_offset_8x8[2][64] =
658
 
{{
659
 
    0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
660
 
    4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,
661
 
    7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,
662
 
   12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12
663
 
},{
664
 
    0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,
665
 
    6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,
666
 
    9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
667
 
    9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14
668
 
}};
669
 
const uint8_t x264_last_coeff_flag_offset_8x8[63] =
670
 
{
671
 
    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
672
 
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
673
 
    3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
674
 
    5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
675
 
};
676
 
const uint8_t x264_coeff_flag_offset_chroma_422_dc[7] = { 0, 0, 1, 1, 2, 2, 2 }; /* MIN( i/2, 2 ) */
677
 
const uint16_t x264_significant_coeff_flag_offset[2][16] =
678
 
{
679
 
    { 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718, 0, 0 },
680
 
    { 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733, 0, 0 }
681
 
};
682
 
const uint16_t x264_last_coeff_flag_offset[2][16] =
683
 
{
684
 
    { 166+0, 166+15, 166+29, 166+44, 166+47, 417, 572+0, 572+15, 572+29, 690, 616+0, 616+15, 616+29, 748, 0, 0 },
685
 
    { 338+0, 338+15, 338+29, 338+44, 338+47, 451, 864+0, 864+15, 864+29, 699, 908+0, 908+15, 908+29, 757, 0, 0 }
686
 
};
687
 
const uint16_t x264_coeff_abs_level_m1_offset[16] =
688
 
{
689
 
    227+0, 227+10, 227+20, 227+30, 227+39, 426, 952+0, 952+10, 952+20, 708, 982+0, 982+10, 982+20, 766
690
 
};
691
 
const uint8_t x264_count_cat_m1[14] = {15, 14, 15, 3, 14, 63, 15, 14, 15, 63, 15, 14, 15, 63};
692
 
#endif
693
 
 
694
647
// node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
695
648
//           4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter).
696
649
/* map node ctx => cabac ctx for level=1 */