From e38c7fd2809dd0c9649cc5ebdd77aadefa5a7af5 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Mon, 1 Nov 2010 15:08:03 -0700 Subject: [PATCH] Disable weightp offset=-1 dupes with high bit depth They're a hack to compensate for crappy rounding, and thus not worth doing at high bit depth, which fixes most of the rounding issues. --- encoder/encoder.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/encoder/encoder.c b/encoder/encoder.c index 2db633a1..2b4fb049 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -760,9 +760,11 @@ static int x264_validate_parameters( x264_t *h ) h->param.analyse.i_mv_range = x264_clip3(h->param.analyse.i_mv_range, 32, 512 >> h->param.b_interlaced); } - h->param.analyse.i_weighted_pred = x264_clip3( h->param.analyse.i_weighted_pred, 0, X264_WEIGHTP_SMART ); + h->param.analyse.i_weighted_pred = x264_clip3( h->param.analyse.i_weighted_pred, X264_WEIGHTP_NONE, X264_WEIGHTP_SMART ); if( !h->param.analyse.i_weighted_pred && h->param.rc.b_mb_tree && h->param.analyse.b_psy && !h->param.b_interlaced ) h->param.analyse.i_weighted_pred = X264_WEIGHTP_FAKE; + if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_BLIND && BIT_DEPTH > 8 ) + h->param.analyse.i_weighted_pred = X264_WEIGHTP_NONE; if( h->i_thread_frames > 1 ) { @@ -1419,6 +1421,12 @@ int x264_weighted_reference_duplicate( x264_t *h, int i_ref, const x264_weight_t if( i <= 1 ) /* empty list, definitely can't duplicate frame */ return -1; + /* Duplication is a hack to compensate for crappy rounding in motion compensation. + * With high bit depth, it's not worth doing, so turn it off except in the case of + * unweighted dupes. */ + if( BIT_DEPTH > 8 && w != weight_none ) + return -1; + newframe = x264_frame_pop_blank_unused( h ); //FIXME: probably don't need to copy everything -- 2.47.3