/* number of neighbors (top and left) that used 8x8 dct */
int i_neighbour_transform_size;
- int b_transform_8x8_allowed;
int i_neighbour_interlaced;
} cache;
int x264_mb_transform_8x8_allowed( x264_t *h )
{
- if( IS_SKIP( h->mb.i_type ) )
+ // 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,2,1,1,1,1,1,1,1,1,1,2,0,
+ };
+ int p, i;
+
+ if( !h->pps->b_transform_8x8_mode )
return 0;
- if( h->mb.i_type == P_8x8 || h->mb.i_type == B_8x8 )
+ p = partition_tab[h->mb.i_type];
+ if( p < 2 )
+ return p;
+ else if( h->mb.i_type == B_DIRECT )
+ return h->sps->b_direct8x8_inference;
+ else if( h->mb.i_type == P_8x8 )
+ {
+ if( !(h->param.analyse.inter & X264_ANALYSE_PSUB8x8) )
+ return 1;
+ for( i=0; i<4; i++ )
+ if( h->mb.i_sub_partition[i] != D_L0_8x8 )
+ return 0;
+ return 1;
+ }
+ else // B_8x8
{
- int i;
- for( i = 0; i < 4; i++ )
- if( !IS_SUB8x8(h->mb.i_sub_partition[i])
- || ( h->mb.i_sub_partition[i] == D_DIRECT_8x8 && !h->sps->b_direct8x8_inference ) )
- {
+ // x264 currently doesn't use sub-8x8 B partitions, so don't check for them
+ if( h->sps->b_direct8x8_inference )
+ return 1;
+ for( i=0; i<4; i++ )
+ if( h->mb.i_sub_partition[i] == D_DIRECT_8x8 )
return 0;
- }
+ return 1;
}
- if( h->mb.i_type == B_DIRECT && !h->sps->b_direct8x8_inference )
- return 0;
-
- return 1;
}
void x264_mb_predict_mv( x264_t *h, int i_list, int idx, int i_width, int mvp[2] )
/* 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 */
+ * doesn't check for cbp */
int x264_mb_transform_8x8_allowed( x264_t *h );
void x264_mb_mc( x264_t *h );
static inline void x264_mb_analyse_transform( x264_t *h )
{
- h->mb.cache.b_transform_8x8_allowed =
- h->pps->b_transform_8x8_mode
- && !IS_INTRA( h->mb.i_type ) && x264_mb_transform_8x8_allowed( h );
-
- if( h->mb.cache.b_transform_8x8_allowed && h->param.analyse.b_transform_8x8 )
+ if( x264_mb_transform_8x8_allowed( h ) && h->param.analyse.b_transform_8x8 )
{
int i_cost4, i_cost8;
/* FIXME only luma mc is needed */
static inline void x264_mb_analyse_transform_rd( x264_t *h, x264_mb_analysis_t *a, int *i_satd, int *i_rd )
{
- h->mb.cache.b_transform_8x8_allowed =
- h->pps->b_transform_8x8_mode && x264_mb_transform_8x8_allowed( h );
-
- if( h->mb.cache.b_transform_8x8_allowed && h->param.analyse.b_transform_8x8 )
+ if( x264_mb_transform_8x8_allowed( h ) && h->param.analyse.b_transform_8x8 )
{
int i_rd8;
x264_analyse_update_cache( h, a );
x264_cabac_mb_cbp_chroma( h, cb );
}
- if( h->mb.cache.b_transform_8x8_allowed && h->mb.i_cbp_luma && !IS_INTRA(i_mb_type) )
+ if( x264_mb_transform_8x8_allowed( h ) && h->mb.i_cbp_luma )
{
x264_cabac_mb_transform_size( h, cb );
}
}
/* transform size 8x8 flag */
- if( h->mb.cache.b_transform_8x8_allowed && h->mb.i_cbp_luma && !IS_INTRA(i_mb_type) )
+ if( x264_mb_transform_8x8_allowed( h ) && h->mb.i_cbp_luma )
{
bs_write1( s, h->mb.b_transform_8x8 );
}