From: Anton Mitrofanov Date: Sat, 21 Jun 2014 19:52:39 +0000 (+0400) Subject: Fix b-pyramid MMCO remove for frame-packing==5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fda920e6f1e4a8f76680c001962542866408114;p=libx264 Fix b-pyramid MMCO remove for frame-packing==5 --- diff --git a/encoder/encoder.c b/encoder/encoder.c index e4840461..bf96f45b 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -2154,6 +2154,31 @@ static inline void x264_reference_build_list( x264_t *h, int i_poc ) h->fref[1][h->i_ref[1]++] = h->frames.reference[i]; } + if( h->sh.i_mmco_remove_from_end ) + { + /* Order ref0 for MMCO remove */ + do + { + b_ok = 1; + for( int i = 0; i < h->i_ref[0] - 1; i++ ) + { + if( h->fref[0][i]->i_frame < h->fref[0][i+1]->i_frame ) + { + XCHG( x264_frame_t*, h->fref[0][i], h->fref[0][i+1] ); + b_ok = 0; + break; + } + } + } while( !b_ok ); + + for( int i = h->i_ref[0]-1; i >= h->i_ref[0] - h->sh.i_mmco_remove_from_end; i-- ) + { + int diff = h->i_frame_num - h->fref[0][i]->i_frame_num; + h->sh.mmco[h->sh.i_mmco_command_count].i_poc = h->fref[0][i]->i_poc; + h->sh.mmco[h->sh.i_mmco_command_count++].i_difference_of_pic_nums = diff; + } + } + /* Order reference lists by distance from the current frame. */ for( int list = 0; list < 2; list++ ) { @@ -2176,14 +2201,6 @@ static inline void x264_reference_build_list( x264_t *h, int i_poc ) } while( !b_ok ); } - if( h->sh.i_mmco_remove_from_end ) - for( int i = h->i_ref[0]-1; i >= h->i_ref[0] - h->sh.i_mmco_remove_from_end; i-- ) - { - int diff = h->i_frame_num - h->fref[0][i]->i_frame_num; - h->sh.mmco[h->sh.i_mmco_command_count].i_poc = h->fref[0][i]->i_poc; - h->sh.mmco[h->sh.i_mmco_command_count++].i_difference_of_pic_nums = diff; - } - x264_reference_check_reorder( h ); h->i_ref[1] = X264_MIN( h->i_ref[1], h->frames.i_max_ref1 );