]> git.sesse.net Git - x264/blobdiff - common/macroblock.h
change default level to "5.1"
[x264] / common / macroblock.h
index ec0b0ae465d094ccf91f4465e3c7952cdaf4060b..d41c09a63a8a4ad0dba6dfeaec7fb33c5cb70055 100644 (file)
@@ -29,41 +29,50 @@ enum macroblock_position_e
     MB_LEFT     = 0x01,
     MB_TOP      = 0x02,
     MB_TOPRIGHT = 0x04,
+    MB_TOPLEFT  = 0x08,
 
     MB_PRIVATE  = 0x10,
 };
 
 
 /* XXX mb_type isn't the one written in the bitstream -> only internal usage */
-#define IS_INTRA(type) ( (type) == I_4x4 || (type) == I_16x16 )
+#define IS_INTRA(type) ( (type) == I_4x4 || (type) == I_8x8 || (type) == I_16x16 )
 #define IS_SKIP(type)  ( (type) == P_SKIP || (type) == B_SKIP )
 #define IS_DIRECT(type)  ( (type) == B_DIRECT )
 enum mb_class_e
 {
     I_4x4           = 0,
-    I_16x16         = 1,
-    I_PCM           = 2,
-
-    P_L0            = 3,
-    P_8x8           = 4,
-    P_SKIP          = 5,
-
-    B_DIRECT        = 6,
-    B_L0_L0         = 7,
-    B_L0_L1         = 8,
-    B_L0_BI         = 9,
-    B_L1_L0         = 10,
-    B_L1_L1         = 11,
-    B_L1_BI         = 12,
-    B_BI_L0         = 13,
-    B_BI_L1         = 14,
-    B_BI_BI         = 15,
-    B_8x8           = 16,
-    B_SKIP          = 17,
+    I_8x8           = 1,
+    I_16x16         = 2,
+    I_PCM           = 3,
+
+    P_L0            = 4,
+    P_8x8           = 5,
+    P_SKIP          = 6,
+
+    B_DIRECT        = 7,
+    B_L0_L0         = 8,
+    B_L0_L1         = 9,
+    B_L0_BI         = 10,
+    B_L1_L0         = 11,
+    B_L1_L1         = 12,
+    B_L1_BI         = 13,
+    B_BI_L0         = 14,
+    B_BI_L1         = 15,
+    B_BI_BI         = 16,
+    B_8x8           = 17,
+    B_SKIP          = 18,
+};
+static const int x264_mb_type_fix[19] =
+{
+    I_4x4, I_4x4, I_16x16, I_PCM,
+    P_L0, P_8x8, P_SKIP,
+    B_DIRECT, B_L0_L0, B_L0_L1, B_L0_BI, B_L1_L0, B_L1_L1,
+    B_L1_BI, B_BI_L0, B_BI_L1, B_BI_BI, B_8x8, B_SKIP
 };
-static const int x264_mb_type_list0_table[18][2] =
+static const int x264_mb_type_list0_table[19][2] =
 {
-    {0,0}, {0,0}, {0,0},    /* INTRA */
+    {0,0}, {0,0}, {0,0}, {0,0}, /* INTRA */
     {1,1},                  /* P_L0 */
     {0,0},                  /* P_8x8 */
     {1,1},                  /* P_SKIP */
@@ -74,9 +83,9 @@ static const int x264_mb_type_list0_table[18][2] =
     {0,0},                  /* B_8x8 */
     {0,0}                   /* B_SKIP */
 };
-static const int x264_mb_type_list1_table[18][2] =
+static const int x264_mb_type_list1_table[19][2] =
 {
-    {0,0}, {0,0}, {0,0},    /* INTRA */
+    {0,0}, {0,0}, {0,0}, {0,0}, /* INTRA */
     {0,0},                  /* P_L0 */
     {0,0},                  /* P_8x8 */
     {0,0},                  /* P_SKIP */
@@ -147,6 +156,59 @@ static const int x264_mb_partition_count_table[17] =
     /* Partition */
     4, 2, 2, 1
 };
+static const int x264_mb_partition_pixel_table[17] =
+{
+    6, 4, 5, 3, 6, 4, 5, 3, 6, 4, 5, 3, 3, 3, 1, 2, 0
+};
+
+static const int x264_zigzag_scan4[16] =
+{
+    0,  1,  4,  8,  5,  2,  3,  6,  9, 12, 13, 10,  7, 11, 14, 15
+};
+static const int x264_zigzag_scan8[64] =
+{
+    0,  1,  8, 16,  9,  2,  3, 10, 17, 24, 32, 25, 18, 11,  4,  5,
+   12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13,  6,  7, 14, 21, 28,
+   35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
+   58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
+};  
+
+static const uint8_t block_idx_x[16] =
+{
+    0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3
+};
+static const uint8_t block_idx_y[16] =
+{
+    0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3
+};
+static const uint8_t block_idx_xy[4][4] =
+{
+    { 0, 2, 8,  10 },
+    { 1, 3, 9,  11 },
+    { 4, 6, 12, 14 },
+    { 5, 7, 13, 15 }
+};
+
+static const int i_chroma_qp_table[52] =
+{
+     0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
+    10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+    20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+    29, 30, 31, 32, 32, 33, 34, 34, 35, 35,
+    36, 36, 37, 37, 37, 38, 38, 38, 39, 39,
+    39, 39
+};
+
+enum cabac_ctx_block_cat_e
+{
+    DCT_LUMA_DC   = 0,
+    DCT_LUMA_AC   = 1,
+    DCT_LUMA_4x4  = 2,
+    DCT_CHROMA_DC = 3,
+    DCT_CHROMA_AC = 4,
+    DCT_LUMA_8x8  = 5,
+};
+
 
 void x264_macroblock_cache_init( x264_t *h );
 void x264_macroblock_slice_init( x264_t *h );
@@ -154,9 +216,7 @@ void x264_macroblock_cache_load( x264_t *h, int i_mb_x, int i_mb_y );
 void x264_macroblock_cache_save( x264_t *h );
 void x264_macroblock_cache_end( x264_t *h );
 
-void x264_mb_dequant_4x4_dc( int16_t dct[4][4], int i_qscale );
-void x264_mb_dequant_2x2_dc( int16_t dct[2][2], int i_qscale );
-void x264_mb_dequant_4x4( int16_t dct[4][4], int i_qscale );
+void x264_macroblock_bipred_init( x264_t *h );
 
 /* x264_mb_predict_mv_16x16:
  *      set mvp with predicted mv for D_16x16 block
@@ -184,13 +244,20 @@ void x264_mb_load_mv_direct8x8( x264_t *h, int idx );
  *      set mvc with D_16x16 prediction.
  *      uses all neighbors, even those that didn't end up using this ref.
  *      h->mb. need only valid values from other blocks */
-void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int mvc[5][2], int *i_mvc );
+void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int mvc[8][2], int *i_mvc );
 
 
 int  x264_mb_predict_intra4x4_mode( x264_t *h, int idx );
 int  x264_mb_predict_non_zero_code( x264_t *h, int idx );
 
+/* x264_mb_transform_8x8_allowed:
+ *      check whether any partition is smaller than 8x8 (or at least
+ *      might be, according to just partition type.)
+ *      doesn't check for intra or cbp */
+int  x264_mb_transform_8x8_allowed( x264_t *h );
+
 void x264_mb_encode_i4x4( x264_t *h, int idx, int i_qscale );
+void x264_mb_encode_i8x8( x264_t *h, int idx, int i_qscale );
 
 void x264_mb_mc( x264_t *h );
 
@@ -241,6 +308,11 @@ static inline void x264_macroblock_cache_skip( x264_t *h, int x, int y, int widt
         }
     }
 }
+static inline void x264_macroblock_cache_intra8x8_pred( x264_t *h, int x, int y, int i_mode )
+{
+    int *cache = &h->mb.cache.intra4x4_pred_mode[X264_SCAN8_0+x+8*y];
+    cache[0] = cache[1] = cache[8] = cache[9] = i_mode;
+}
 
 #endif