From 82d5e6faa6aa8ca8888481019513782ef9701240 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Tue, 27 Sep 2005 19:59:09 +0000 Subject: [PATCH] with B-pyramid, forget old refs in POC order instead of coded order. (before, b_skip was unavailable with pyramid and ref=1) git-svn-id: svn://svn.videolan.org/x264/trunk@305 df754926-b1dd-0310-bc7b-ec298dee348c --- common/macroblock.c | 4 ++-- encoder/encoder.c | 12 +++++------- encoder/set.c | 4 +++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/macroblock.c b/common/macroblock.c index f0f81da1..014b41b0 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -977,8 +977,8 @@ void x264_macroblock_cache_init( x264_t *h ) for( i=0; i<2; i++ ) { - int i_refs = i ? 1 + h->param.b_bframe_pyramid : h->param.i_frame_reference; - for( j=0; j < i_refs; j++ ) + int i_refs = (i ? 1 : h->param.i_frame_reference) + h->param.b_bframe_pyramid; + for( j=0; j < i_refs && j < 16; j++ ) h->mb.mvr[i][j] = x264_malloc( 2 * i_mb_count * sizeof( int16_t ) ); } diff --git a/encoder/encoder.c b/encoder/encoder.c index 97adeb90..caccf660 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -315,7 +315,6 @@ static void x264_slice_header_write( bs_t *s, x264_slice_header_t *sh, int i_nal else { bs_write1( s, 0 ); /* adaptive_ref_pic_marking_mode_flag */ - /* FIXME */ } } @@ -403,11 +402,6 @@ static int x264_validate_parameters( x264_t *h ) h->param.i_bframe = x264_clip3( h->param.i_bframe, 0, X264_BFRAME_MAX ); h->param.i_bframe_bias = x264_clip3( h->param.i_bframe_bias, -90, 100 ); h->param.b_bframe_pyramid = h->param.b_bframe_pyramid && h->param.i_bframe > 1; - h->frames.i_delay = h->param.i_bframe; - h->frames.i_max_ref0 = h->param.i_frame_reference; - h->frames.i_max_ref1 = h->param.b_bframe_pyramid ? 2 - : h->param.i_bframe ? 1 : 0; - h->frames.i_max_dpb = X264_MIN( 16, h->frames.i_max_ref0 + h->frames.i_max_ref1 ) + 1; 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 ); @@ -544,6 +538,11 @@ x264_t *x264_encoder_open ( x264_param_t *param ) h->mb.i_mb_count = h->sps->i_mb_width * h->sps->i_mb_height; /* Init frames. */ + h->frames.i_delay = h->param.i_bframe; + h->frames.i_max_ref0 = h->param.i_frame_reference; + h->frames.i_max_ref1 = h->sps->vui.i_num_reorder_frames; + h->frames.i_max_dpb = h->sps->vui.i_max_dec_frame_buffering + 1; + for( i = 0; i < X264_BFRAME_MAX + 3; i++ ) { h->frames.current[i] = NULL; @@ -851,7 +850,6 @@ static inline void x264_reference_update( x264_t *h ) h->frames.last_nonb = h->fdec; /* move frame in the buffer */ - /* FIXME: override to forget earliest pts, not earliest dts */ h->fdec = h->frames.reference[h->frames.i_max_dpb-1]; for( i = h->frames.i_max_dpb-1; i > 0; i-- ) { diff --git a/encoder/set.c b/encoder/set.c index 212bdb01..5afd7330 100644 --- a/encoder/set.c +++ b/encoder/set.c @@ -113,8 +113,10 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param ) } sps->vui.i_num_reorder_frames = param->b_bframe_pyramid ? 2 : param->i_bframe ? 1 : 0; + /* extra slot with pyramid so that we don't have to override the + * order of forgetting old pictures */ sps->vui.i_max_dec_frame_buffering = - sps->i_num_ref_frames = X264_MIN(16, param->i_frame_reference + sps->vui.i_num_reorder_frames); + sps->i_num_ref_frames = X264_MIN(16, param->i_frame_reference + sps->vui.i_num_reorder_frames + param->b_bframe_pyramid); sps->b_gaps_in_frame_num_value_allowed = 0; sps->i_mb_width = ( param->i_width + 15 ) / 16; -- GitLab