From 3daa02e9c79ec46fd980bcfcd317df45539c91f6 Mon Sep 17 00:00:00 2001 From: Steven Walters Date: Sun, 8 Nov 2009 11:53:48 -0800 Subject: [PATCH] Fix assert failure in the case of forced i-frames Note that this applies to non-IDR i-frames, not IDR-frames. This fix is also required for future open-gop. --- encoder/slicetype.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/encoder/slicetype.c b/encoder/slicetype.c index 67a28613..031dd3ce 100644 --- a/encoder/slicetype.c +++ b/encoder/slicetype.c @@ -996,25 +996,27 @@ void x264_slicetype_decide( x264_t *h ) if( h->param.rc.i_rc_method != X264_RC_CQP ) { x264_mb_analysis_t a; - int p0=0, p1, b; + int p0, p1, b; + p1 = b = bframes + 1; x264_lowres_context_init( h, &a ); frames[0] = h->lookahead->last_nonb; memcpy( &frames[1], h->lookahead->next.list, (bframes+1) * sizeof(x264_frame_t*) ); if( IS_X264_TYPE_I( h->lookahead->next.list[bframes]->i_type ) ) - p0 = p1 = b = 1; + p0 = bframes + 1; else // P - p1 = b = bframes + 1; + p0 = 0; x264_slicetype_frame_cost( h, &a, frames, p0, p1, b, 0 ); - if( p0 != p1 && h->param.rc.i_vbv_buffer_size ) + if( (p0 != p1 || bframes) && h->param.rc.i_vbv_buffer_size ) { /* We need the intra costs for row SATDs. */ x264_slicetype_frame_cost( h, &a, frames, b, b, b, 0 ); /* We need B-frame costs for row SATDs. */ + p0 = 0; for( b = 1; b <= bframes; b++ ) { if( frames[b]->i_type == X264_TYPE_B ) -- 2.47.3