i_mb_y = h->sh.i_first_mb / h->mb.i_mb_width;
i_mb_x = h->sh.i_first_mb % h->mb.i_mb_width;
i_skip = 0;
- int mb_size[2];
while( 1 )
{
}
int total_bits = bs_pos(&h->out.bs) + x264_cabac_pos(&h->cabac);
- mb_size[i_mb_y&1] = total_bits - mb_spos;
+ int mb_size = total_bits - mb_spos;
if( slice_max_size )
{
if( b_deblock )
x264_macroblock_deblock_strength( h );
- if( SLICE_MBAFF )
- {
- /* update ratecontrol per-mbpair in MBAFF */
- if( i_mb_y&1 )
- x264_ratecontrol_mb( h, mb_size[0]+mb_size[1] );
- }
- else
- x264_ratecontrol_mb( h, mb_size[i_mb_y&1] );
+ x264_ratecontrol_mb( h, mb_size );
if( mb_xy == h->sh.i_last_mb )
break;
static int row_bits_so_far( x264_t *h, int y )
{
int bits = 0;
- for( int i = h->i_threadslice_start+SLICE_MBAFF; i <= y; i+=(SLICE_MBAFF+1) )
+ for( int i = h->i_threadslice_start; i <= y; i++ )
bits += h->fdec->i_row_bits[i];
return bits;
}
{
float qscale = qp2qscale( qp );
float bits = row_bits_so_far( h, y );
- for( int i = y+1+SLICE_MBAFF; i < h->i_threadslice_end; i+=(1+SLICE_MBAFF) )
+ for( int i = y+1; i < h->i_threadslice_end; i++ )
bits += predict_row_size( h, i, qscale );
return bits;
}
h->fdec->i_row_bits[y] += bits;
rc->qpa_aq += h->mb.i_qp;
- if( SLICE_MBAFF )
- rc->qpa_aq += h->mb.i_last_qp;
if( h->mb.i_mb_x != h->mb.i_mb_width - 1 )
return;
x264_emms();
- rc->qpa_rc += rc->qpm * (h->mb.i_mb_width << SLICE_MBAFF);
+ rc->qpa_rc += rc->qpm * h->mb.i_mb_width;
if( !rc->b_vbv )
return;
if( h->sh.i_type == SLICE_TYPE_P && rc->qpm < h->fref[0][0]->f_row_qp[y] )
update_predictor( rc->row_pred[1], qscale, h->fdec->i_row_satds[0][0][y], h->fdec->i_row_bits[y] );
+ /* update ratecontrol per-mbpair in MBAFF */
+ if( SLICE_MBAFF && !(y&1) )
+ return;
+
/* tweak quality based on difference from predicted size */
if( y < h->i_threadslice_end-1 )
{
/* B-frames shouldn't use lower QP than their reference frames. */
if( h->sh.i_type == SLICE_TYPE_B )
{
- qp_min = X264_MAX( qp_min, X264_MAX( h->fref[0][0]->f_row_qp[y+1+SLICE_MBAFF], h->fref[1][0]->f_row_qp[y+1+SLICE_MBAFF] ) );
+ qp_min = X264_MAX( qp_min, X264_MAX( h->fref[0][0]->f_row_qp[y+1], h->fref[1][0]->f_row_qp[y+1] ) );
rc->qpm = X264_MAX( rc->qpm, qp_min );
}