[x264-devel] [PATCH] fix bug of weighted bipred according to Rec. ITU-T H.264 (10/2016) 8.4.3
Lingjiang Fang
vacingfang at foxmail.com
Fri Jan 15 09:20:22 UTC 2021
From: Lingjiang Fang <vacingfang at tencent.com>
---
common/macroblock.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/common/macroblock.c b/common/macroblock.c
index 9a3c7132..638a5c42 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -1890,13 +1890,17 @@ void x264_macroblock_bipred_init( x264_t *h )
int poc0 = l0->i_poc + mbfield*l0->i_delta_poc[field^(i_ref0&1)];
for( int i_ref1 = 0; i_ref1 < (h->i_ref[1]<<mbfield); i_ref1++ )
{
+ int use_default = 0;
int dist_scale_factor;
x264_frame_t *l1 = h->fref[1][i_ref1>>mbfield];
int cur_poc = h->fdec->i_poc + mbfield*h->fdec->i_delta_poc[field];
int poc1 = l1->i_poc + mbfield*l1->i_delta_poc[field^(i_ref1&1)];
int td = x264_clip3( poc1 - poc0, -128, 127 );
if( td == 0 /* || pic0 is a long-term ref */ )
+ {
dist_scale_factor = 256;
+ use_default = 1;
+ }
else
{
int tb = x264_clip3( cur_poc - poc0, -128, 127 );
@@ -1907,7 +1911,7 @@ void x264_macroblock_bipred_init( x264_t *h )
h->mb.dist_scale_factor_buf[mbfield][field][i_ref0][i_ref1] = dist_scale_factor;
dist_scale_factor >>= 2;
- if( h->param.analyse.b_weighted_bipred
+ if( !use_default && h->param.analyse.b_weighted_bipred
&& dist_scale_factor >= -64
&& dist_scale_factor <= 128 )
{
--
2.29.2
More information about the x264-devel
mailing list