const int i_mb_4x4 = 4*(i_mb_y * h->mb.i_b4_stride + i_mb_x);
const int i_mb_8x8 = 2*(i_mb_y * h->mb.i_b8_stride + i_mb_x);
- int i_top_xy = -1;
+ int i_mb_xy = i_mb_y * h->mb.i_mb_stride + i_mb_x;
+ int i_top_xy = i_mb_xy - h->mb.i_mb_stride;
int i_left_xy = -1;
int i_top_type = -1; /* gcc warn */
int i_left_type= -1;
/* init index */
h->mb.i_mb_x = i_mb_x;
h->mb.i_mb_y = i_mb_y;
- h->mb.i_mb_xy = i_mb_y * h->mb.i_mb_stride + i_mb_x;
+ h->mb.i_mb_xy = i_mb_xy;
h->mb.i_b8_xy = i_mb_8x8;
h->mb.i_b4_xy = i_mb_4x4;
h->mb.i_neighbour = 0;
}
/* load cache */
- if( h->mb.i_mb_xy >= h->sh.i_first_mb + h->mb.i_mb_stride )
+ if( i_mb_xy >= h->sh.i_first_mb + h->mb.i_mb_stride )
{
- i_top_xy = h->mb.i_mb_xy - h->mb.i_mb_stride;
h->mb.i_mb_type_top =
i_top_type= h->mb.type[i_top_xy];
}
- if( i_mb_x > 0 && h->mb.i_mb_xy > h->sh.i_first_mb )
+ if( i_mb_x > 0 && i_mb_xy > h->sh.i_first_mb )
{
- i_left_xy = h->mb.i_mb_xy - 1;
+ i_left_xy = i_mb_xy - 1;
h->mb.i_mb_type_left =
- i_left_type= h->mb.type[i_left_xy];
+ i_left_type = h->mb.type[i_left_xy];
h->mb.i_neighbour |= MB_LEFT;
h->mb.cache.non_zero_count[x264_scan8[16+4+2] - 1] = 0x80;
}
- if( i_mb_x < h->sps->i_mb_width - 1 && h->mb.i_mb_xy >= h->sh.i_first_mb + h->mb.i_mb_stride - 1 )
+ if( i_mb_x < h->sps->i_mb_width - 1 && i_top_xy + 1 >= h->sh.i_first_mb )
+ {
h->mb.i_neighbour |= MB_TOPRIGHT;
- if( i_mb_x > 0 && h->mb.i_mb_xy >= h->sh.i_first_mb + h->mb.i_mb_stride + 1 )
+ h->mb.i_mb_type_topright = h->mb.type[ i_top_xy + 1 ];
+ }
+ else
+ h->mb.i_mb_type_topright = -1;
+ if( i_mb_x > 0 && i_top_xy - 1 >= h->sh.i_first_mb )
+ {
h->mb.i_neighbour |= MB_TOPLEFT;
+ h->mb.i_mb_type_topleft = h->mb.type[ i_top_xy - 1 ];
+ }
+ else
+ h->mb.i_mb_type_topleft = -1;
/* load ref/mv/mvd */
if( h->sh.i_type != SLICE_TYPE_I )
h->mb.cache.mv[i_list][i8][1] = 0;
}
- if( i_top_xy >= 0 )
+ if( h->mb.i_neighbour & MB_TOP )
{
const int i8 = x264_scan8[0] - 8;
const int ir = i_mb_8x8 - s8x8;
h->mb.cache.mv[i_list][i8][1] = 0;
}
- if( i_left_xy >= 0 )
+ if( h->mb.i_neighbour & MB_LEFT )
{
const int i8 = x264_scan8[0] - 1;
const int ir = i_mb_8x8 - 1;
if( h->param.b_cabac )
{
- if( i_top_xy >= 0 )
+ if( i_top_type >= 0 )
{
const int i8 = x264_scan8[0] - 8;
const int iv = i_mb_4x4 - s4x4;
}
}
- if( i_left_xy >= 0 )
+ if( i_left_type >= 0 )
{
const int i8 = x264_scan8[0] - 1;
const int iv = i_mb_4x4 - 1;
if( h->sh.i_type == SLICE_TYPE_B && h->param.b_cabac )
{
memset( h->mb.cache.skip, 0, X264_SCAN8_SIZE * sizeof( int8_t ) );
- if( i_left_xy >= 0 )
+ if( i_left_type >= 0 )
{
h->mb.cache.skip[x264_scan8[0] - 1] = h->mb.skipbp[i_left_xy] & 0x2;
h->mb.cache.skip[x264_scan8[8] - 1] = h->mb.skipbp[i_left_xy] & 0x8;
}
- if( i_top_xy >= 0 )
+ if( i_top_type >= 0 )
{
h->mb.cache.skip[x264_scan8[0] - 8] = h->mb.skipbp[i_top_xy] & 0x4;
h->mb.cache.skip[x264_scan8[4] - 8] = h->mb.skipbp[i_top_xy] & 0x8;
/* Fast intra decision */
if( h->mb.i_mb_xy - h->sh.i_first_mb > 4 )
{
- const unsigned int i_neighbour = h->mb.i_neighbour;
- if( ((i_neighbour&MB_LEFT) && IS_INTRA( h->mb.type[h->mb.i_mb_xy - 1] ))
- || ((i_neighbour&MB_TOP) && IS_INTRA( h->mb.type[h->mb.i_mb_xy - h->mb.i_mb_stride] ))
- || (((i_neighbour&(MB_TOP|MB_LEFT)) == (MB_TOP|MB_LEFT)) && IS_INTRA( h->mb.type[h->mb.i_mb_xy - h->mb.i_mb_stride-1 ] ))
- || ((i_neighbour&MB_TOPRIGHT) && IS_INTRA( h->mb.type[h->mb.i_mb_xy - h->mb.i_mb_stride+1 ] ))
+ if( IS_INTRA( h->mb.i_mb_type_left )
+ || IS_INTRA( h->mb.i_mb_type_top )
+ || IS_INTRA( h->mb.i_mb_type_topleft )
+ || IS_INTRA( h->mb.i_mb_type_topright )
|| (h->sh.i_type == SLICE_TYPE_P && IS_INTRA( h->fref0[0]->mb_type[h->mb.i_mb_xy] ))
|| (h->mb.i_mb_xy - h->sh.i_first_mb < 3*(h->stat.frame.i_mb_count[I_4x4] + h->stat.frame.i_mb_count[I_16x16])) )
{ /* intra is likely */ }
/* Max = 4 */
static void predict_16x16_mode_available( unsigned int i_neighbour, int *mode, int *pi_count )
{
- if( ( i_neighbour & (MB_LEFT|MB_TOP) ) == (MB_LEFT|MB_TOP) )
+ if( i_neighbour & MB_TOPLEFT )
{
/* top and left avaible */
*mode++ = I_PRED_16x16_V;
*mode++ = I_PRED_16x16_P;
*pi_count = 4;
}
- else if( ( i_neighbour & MB_LEFT ) )
+ else if( i_neighbour & MB_LEFT )
{
/* left available*/
*mode++ = I_PRED_16x16_DC_LEFT;
*mode++ = I_PRED_16x16_H;
*pi_count = 2;
}
- else if( ( i_neighbour & MB_TOP ) )
+ else if( i_neighbour & MB_TOP )
{
/* top available*/
*mode++ = I_PRED_16x16_DC_TOP;
/* Max = 4 */
static void predict_8x8_mode_available( unsigned int i_neighbour, int *mode, int *pi_count )
{
- if( ( i_neighbour & (MB_LEFT|MB_TOP) ) == (MB_LEFT|MB_TOP) )
+ if( i_neighbour & MB_TOPLEFT )
{
/* top and left avaible */
*mode++ = I_PRED_CHROMA_V;
*mode++ = I_PRED_CHROMA_P;
*pi_count = 4;
}
- else if( ( i_neighbour & MB_LEFT ) )
+ else if( i_neighbour & MB_LEFT )
{
/* left available*/
*mode++ = I_PRED_CHROMA_DC_LEFT;
*mode++ = I_PRED_CHROMA_H;
*pi_count = 2;
}
- else if( ( i_neighbour & MB_TOP ) )
+ else if( i_neighbour & MB_TOP )
{
/* top available*/
*mode++ = I_PRED_CHROMA_DC_TOP;
}
else if( h->sh.i_type == SLICE_TYPE_P )
{
- const unsigned int i_neighbour = h->mb.i_neighbour;
-
int b_skip = 0;
int i_cost;
int i_intra_cost, i_intra_type;
/* Fast P_SKIP detection */
- if( ( (i_neighbour&MB_LEFT) && h->mb.type[h->mb.i_mb_xy - 1] == P_SKIP ) ||
- ( (i_neighbour&MB_TOP) && h->mb.type[h->mb.i_mb_xy - h->mb.i_mb_stride] == P_SKIP ) ||
- ( ((i_neighbour&(MB_TOP|MB_LEFT)) == (MB_TOP|MB_LEFT) ) && h->mb.type[h->mb.i_mb_xy - h->mb.i_mb_stride-1 ] == P_SKIP ) ||
- ( (i_neighbour&MB_TOPRIGHT) && h->mb.type[h->mb.i_mb_xy - h->mb.i_mb_stride+1 ] == P_SKIP ) )
+ if( ( h->mb.i_mb_type_left == P_SKIP ) ||
+ ( h->mb.i_mb_type_top == P_SKIP ) ||
+ ( h->mb.i_mb_type_topleft == P_SKIP ) ||
+ ( h->mb.i_mb_type_topright == P_SKIP ) )
{
b_skip = x264_macroblock_probe_pskip( h );
}