From dac2be0cc94b897749381135e248cd1844f58fda Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Thu, 22 Feb 2007 05:01:38 +0000 Subject: [PATCH] oops, scenecut detection failed to activate when using threads and not using B-frames git-svn-id: svn://svn.videolan.org/x264/trunk@623 df754926-b1dd-0310-bc7b-ec298dee348c --- encoder/encoder.c | 8 ++++++-- encoder/slicetype.c | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/encoder/encoder.c b/encoder/encoder.c index 9ebef483..e247e1e3 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -431,6 +431,8 @@ static int x264_validate_parameters( x264_t *h ) h->mb.b_direct_auto_write = h->param.analyse.i_direct_mv_pred == X264_DIRECT_PRED_AUTO && h->param.i_bframe && ( h->param.rc.b_stat_write || !h->param.rc.b_stat_read ); + if( h->param.i_scenecut_threshold < 0 ) + h->param.b_pre_scenecut = 0; h->param.i_deblocking_filter_alphac0 = x264_clip3( h->param.i_deblocking_filter_alphac0, -6, 6 ); h->param.i_deblocking_filter_beta = x264_clip3( h->param.i_deblocking_filter_beta, -6, 6 ); @@ -635,7 +637,8 @@ x264_t *x264_encoder_open ( x264_param_t *param ) h->frames.b_have_lowres = !h->param.rc.b_stat_read && ( h->param.rc.i_rc_method == X264_RC_ABR || h->param.rc.i_rc_method == X264_RC_CRF - || h->param.b_bframe_adaptive ); + || h->param.b_bframe_adaptive + || h->param.b_pre_scenecut ); h->frames.i_last_idr = - h->param.i_keyint_max; h->frames.i_input = 0; @@ -720,7 +723,8 @@ int x264_encoder_reconfig( x264_t *h, x264_param_t *param ) #define COPY(var) h->param.var = param->var COPY( i_frame_reference ); // but never uses more refs than initially specified COPY( i_bframe_bias ); - COPY( i_scenecut_threshold ); + if( h->param.i_scenecut_threshold >= 0 && param->i_scenecut_threshold >= 0 ) + COPY( i_scenecut_threshold ); // can't turn it on or off, only vary the threshold COPY( b_deblocking_filter ); COPY( i_deblocking_filter_alphac0 ); COPY( i_deblocking_filter_beta ); diff --git a/encoder/slicetype.c b/encoder/slicetype.c index c8685b92..d3e1194e 100644 --- a/encoder/slicetype.c +++ b/encoder/slicetype.c @@ -373,6 +373,8 @@ void x264_slicetype_analyse( x264_t *h ) int cost1p0, cost2p0, cost1b1, cost2p1; int idr_frame_type; + assert( h->frames.b_have_lowres ); + if( !h->frames.last_nonb ) return; frames[0] = h->frames.last_nonb; @@ -390,7 +392,7 @@ void x264_slicetype_analyse( x264_t *h ) { no_b_frames: frames[1]->i_type = X264_TYPE_P; - if( h->param.b_pre_scenecut && h->param.i_scenecut_threshold >= 0 ) + if( h->param.b_pre_scenecut ) { x264_slicetype_frame_cost( h, &a, frames, 0, 1, 1, 0 ); if( scenecut( h, frames[1], 1 ) ) @@ -449,7 +451,8 @@ void x264_slicetype_decide( x264_t *h ) h->frames.next[i]->i_type = x264_ratecontrol_slice_type( h, h->frames.next[i]->i_frame ); } - else if( h->param.i_bframe && h->param.b_bframe_adaptive ) + else if( (h->param.i_bframe && h->param.b_bframe_adaptive) + || h->param.b_pre_scenecut ) x264_slicetype_analyse( h ); for( bframes = 0;; bframes++ ) -- 2.40.0