/*****************************************************************************
* macroblock.h: macroblock common functions
*****************************************************************************
- * Copyright (C) 2005-2010 x264 project
+ * Copyright (C) 2005-2014 x264 project
*
* Authors: Loren Merritt <lorenm@u.washington.edu>
* Laurent Aimar <fenrir@via.ecp.fr>
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,
+ DCT_LUMA_DC = 0,
+ DCT_LUMA_AC = 1,
+ DCT_LUMA_4x4 = 2,
+ DCT_CHROMA_DC = 3,
+ DCT_CHROMA_AC = 4,
+ DCT_LUMA_8x8 = 5,
+ DCT_CHROMAU_DC = 6,
+ DCT_CHROMAU_AC = 7,
+ DCT_CHROMAU_4x4 = 8,
+ DCT_CHROMAU_8x8 = 9,
+ DCT_CHROMAV_DC = 10,
+ DCT_CHROMAV_AC = 11,
+ DCT_CHROMAV_4x4 = 12,
+ DCT_CHROMAV_8x8 = 13,
+};
+
+static const uint8_t ctx_cat_plane[6][3] =
+{
+ { DCT_LUMA_DC, DCT_CHROMAU_DC, DCT_CHROMAV_DC},
+ { DCT_LUMA_AC, DCT_CHROMAU_AC, DCT_CHROMAV_AC},
+ {DCT_LUMA_4x4, DCT_CHROMAU_4x4, DCT_CHROMAV_4x4},
+ {0},
+ {0},
+ {DCT_LUMA_8x8, DCT_CHROMAU_8x8, DCT_CHROMAV_8x8}
};
/* Per-frame allocation: is allocated per-thread only in frame-threads mode. */
void x264_macroblock_slice_init( x264_t *h );
void x264_macroblock_thread_init( x264_t *h );
-void x264_macroblock_cache_load( x264_t *h, int mb_x, int mb_y );
-void x264_macroblock_cache_load_deblock( x264_t *h );
-void x264_macroblock_cache_load_neighbours_deblock( x264_t *h, int mb_x, int mb_y );
+void x264_macroblock_cache_load_progressive( x264_t *h, int mb_x, int mb_y );
+void x264_macroblock_cache_load_interlaced( x264_t *h, int mb_x, int mb_y );
+void x264_macroblock_deblock_strength( x264_t *h );
void x264_macroblock_cache_save( x264_t *h );
void x264_macroblock_bipred_init( x264_t *h );
void x264_mb_mc( x264_t *h );
void x264_mb_mc_8x8( x264_t *h, int i8 );
-static ALWAYS_INLINE uint32_t pack16to32( int a, int b )
+static ALWAYS_INLINE uint32_t pack16to32( uint32_t a, uint32_t b )
{
#if WORDS_BIGENDIAN
return b + (a<<16);
return a + (b<<16);
#endif
}
-static ALWAYS_INLINE uint32_t pack8to16( int a, int b )
+static ALWAYS_INLINE uint32_t pack8to16( uint32_t a, uint32_t b )
{
#if WORDS_BIGENDIAN
return b + (a<<8);
return a + (b<<8);
#endif
}
-static ALWAYS_INLINE uint32_t pack8to32( int a, int b, int c, int d )
+static ALWAYS_INLINE uint32_t pack8to32( uint32_t a, uint32_t b, uint32_t c, uint32_t d )
{
#if WORDS_BIGENDIAN
return d + (c<<8) + (b<<16) + (a<<24);
}
static ALWAYS_INLINE uint64_t pack32to64( uint32_t a, uint32_t b )
{
-#ifdef WORDS_BIGENDIAN
+#if WORDS_BIGENDIAN
return b + ((uint64_t)a<<32);
#else
return a + ((uint64_t)b<<32);
# define pack_pixel_2to4 pack16to32
#endif
-#define array_non_zero(a) array_non_zero_int(a, sizeof(a)/sizeof(dctcoef))
-#define array_non_zero_int array_non_zero_int
-static ALWAYS_INLINE int array_non_zero_int( dctcoef *v, int i_count )
-{
- for( int i = 0; i < i_count; i++ )
- if( v[i] )
- return 1;
- return 0;
-}
static ALWAYS_INLINE int x264_mb_predict_intra4x4_mode( x264_t *h, int idx )
{
const int ma = h->mb.cache.intra4x4_pred_mode[x264_scan8[idx] - 1];
i_ret = ( i_ret + 1 ) >> 1;
return i_ret & 0x7f;
}
+
+/* intra and skip are disallowed, p8x8 is conditional. */
+static const uint8_t x264_transform_allowed[X264_MBTYPE_MAX] =
+{
+ 0,0,0,0,1,2,0,1,1,1,1,1,1,1,1,1,1,1,0
+};
+
/* 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 cbp */
static ALWAYS_INLINE int x264_mb_transform_8x8_allowed( x264_t *h )
{
- // intra and skip are disallowed
- // large partitions are allowed
- // direct and 8x8 are conditional
- static const uint8_t partition_tab[X264_MBTYPE_MAX] = {
- 0,0,0,0,1,2,0,1,1,1,1,1,1,1,1,1,1,1,0,
- };
-
if( !h->pps->b_transform_8x8_mode )
return 0;
if( h->mb.i_type != P_8x8 )
- return partition_tab[h->mb.i_type];
+ return x264_transform_allowed[h->mb.i_type];
return M32( h->mb.i_sub_partition ) == D_L0_8x8*0x01010101;
}