From: Laurent Aimar Date: Sun, 8 Aug 2004 16:18:49 +0000 (+0000) Subject: * encoder: simpler scene cut detection (seems better but do not check X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e96703d73226f61149e2c815a03f8443a620ffff;p=libx264 * encoder: simpler scene cut detection (seems better but do not check size anymore, so need more testing). git-svn-id: svn://svn.videolan.org/x264/trunk@20 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/encoder/encoder.c b/encoder/encoder.c index e347e1de..4d5a8c76 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -1052,20 +1052,31 @@ do_encode: #if 1 if( i_slice_type != SLICE_TYPE_I) { + int i_bias; + + int i_mb_i = i_mb_count[I_4x4] + i_mb_count[I_16x16]; + int i_mb = h->sps->i_mb_width * h->sps->i_mb_height; + if( h->param.i_iframe > 0 ) + i_bias = 30 * X264_MIN( 3*h->frames.i_last_i, h->param.i_iframe ) / h->param.i_iframe; + else + i_bias = 15; + /* Bad P will be reencoded as I */ if( i_slice_type == SLICE_TYPE_P && + 100 * i_mb_i >= (100 - i_bias) * i_mb ) + /* h->out.nal[h->out.i_nal-1].i_payload > h->i_last_intra_size + h->i_last_intra_size * (3+h->i_last_intra_qp - i_global_qp) / 16 && i_mb_count[I_4x4] + i_mb_count[I_16x16] > i_mb_count[P_SKIP] + i_mb_count[P_L0]/2 && h->out.nal[h->out.i_nal-1].i_payload > 2 * h->i_last_inter_size && - h->frames.i_last_i > 4) + h->frames.i_last_i > 4)*/ { - fprintf( stderr, "scene cut at %d size=%d last I:%d last P:%d Intra:%d Skip:%d PL0:%d\n", + fprintf( stderr, "scene cut at %d size=%d last I:%d last P:%d Intra:%d Inter=%d Ratio=%d Bias=%d (Skip:%d PL0:%d)\n", h->i_frame - 1, h->out.nal[h->out.i_nal-1].i_payload, h->i_last_intra_size, h->i_last_inter_size, - i_mb_count[I_4x4] + i_mb_count[I_16x16], + i_mb_i, i_mb, 100 * i_mb_i / i_mb, i_bias, i_mb_count[P_SKIP], i_mb_count[P_L0] );