Since fade analysis is now so fast, weightp 1 now does fade analysis but no reference duplication.
This is the opposite of what it used to do (reference duplication but no fade analysis).
This also gives weightp's better fade quality to faster presets (up to superfast).
param->analyse.b_mixed_references = 0;
param->analyse.i_trellis = 0;
param->rc.b_mb_tree = 0;
- param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
+ param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
param->rc.i_lookahead = 0;
}
else if( !strcasecmp( preset, "veryfast" ) )
param->i_frame_reference = 1;
param->analyse.b_mixed_references = 0;
param->analyse.i_trellis = 0;
- param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
+ param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
param->rc.i_lookahead = 10;
}
else if( !strcasecmp( preset, "faster" ) )
param->analyse.b_mixed_references = 0;
param->i_frame_reference = 2;
param->analyse.i_subpel_refine = 4;
- param->analyse.i_weighted_pred = X264_WEIGHTP_BLIND;
+ param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
param->rc.i_lookahead = 20;
}
else if( !strcasecmp( preset, "fast" ) )
{
param->i_frame_reference = 2;
param->analyse.i_subpel_refine = 6;
+ param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
param->rc.i_lookahead = 30;
}
else if( !strcasecmp( preset, "medium" ) )
int i_refs = X264_MIN(X264_REF_MAX, (i ? 1 + !!h->param.i_bframe_pyramid : h->param.i_frame_reference) ) << h->param.b_interlaced;
if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART )
i_refs = X264_MIN(X264_REF_MAX, i_refs + 1 + (BIT_DEPTH == 8)); //smart weights add two duplicate frames, one in >8-bit
- else if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_BLIND )
- i_refs = X264_MIN(X264_REF_MAX, i_refs + 1); //blind weights add one duplicate frame
for( int j = !i; j < i_refs; j++ )
{
//SMART can weight one ref and one offset -1
numweightbuf = 2;
else
- //blind only has one weighted copy (offset -1)
+ //simple only has one weighted ref
numweightbuf = 1;
}
{
memset( h->mb.cache.skip, 0, sizeof( h->mb.cache.skip ) );
- if( h->sh.i_disable_deblocking_filter_idc != 1 && h->param.analyse.i_weighted_pred )
+ if( h->sh.i_disable_deblocking_filter_idc != 1 && h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART )
{
deblock_ref_table(-2) = -2;
deblock_ref_table(-1) = -1;
h->mb.i_neighbour = new_neighbour;
}
- if( h->param.analyse.i_weighted_pred && h->sh.i_type == SLICE_TYPE_P )
+ if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART && h->sh.i_type == SLICE_TYPE_P )
{
/* Handle reference frame duplicates */
int i8 = x264_scan8[0] - 8;
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 )
{
|| h->param.i_bframe_adaptive
|| h->param.i_scenecut_threshold
|| h->param.rc.b_mb_tree
- || h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART );
+ || h->param.analyse.i_weighted_pred );
h->frames.b_have_lowres |= h->param.rc.b_stat_read && h->param.rc.i_vbv_buffer_size > 0;
h->frames.b_have_sub8x8_esa = !!(h->param.analyse.inter & X264_ANALYSE_PSUB8x8);
if( i <= 1 ) /* empty list, definitely can't duplicate frame */
return -1;
+ //Duplication is only used in X264_WEIGHTP_SMART
+ if( h->param.analyse.i_weighted_pred != X264_WEIGHTP_SMART )
+ 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( h->fenc->i_type == X264_TYPE_P )
{
int idx = -1;
- if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART )
+ if( h->param.analyse.i_weighted_pred >= X264_WEIGHTP_SIMPLE )
{
x264_weight_t w[3];
w[1].weightfn = w[2].weightfn = NULL;
}
}
}
- else if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_BLIND )
- {
- //weighted offset=-1
- x264_weight_t w[3];
- SET_WEIGHT( w[0], 1, 1, 0, -1 );
- h->fenc->weight[0][0].i_denom = 0;
- w[1].weightfn = w[2].weightfn = NULL;
- idx = x264_weighted_reference_duplicate( h, 0, w );
- }
h->mb.ref_blind_dupe = idx;
}
if( h->sh.i_type == SLICE_TYPE_P )
{
h->stat.i_consecutive_bframes[h->fdec->i_frame - h->fref0[0]->i_frame - 1]++;
- if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART )
+ if( h->param.analyse.i_weighted_pred >= X264_WEIGHTP_SIMPLE )
{
h->stat.i_wpred[0] += !!h->sh.weight[0][0].weightfn;
h->stat.i_wpred[1] += !!h->sh.weight[0][1].weightfn || !!h->sh.weight[0][2].weightfn;
fixed_pred_modes[3][2] * 100.0 / sum_pred_modes[3],
fixed_pred_modes[3][3] * 100.0 / sum_pred_modes[3] );
- if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART && h->stat.i_frame_count[SLICE_TYPE_P] > 0 )
+ if( h->param.analyse.i_weighted_pred >= X264_WEIGHTP_SIMPLE && h->stat.i_frame_count[SLICE_TYPE_P] > 0 )
x264_log( h, X264_LOG_INFO, "Weighted P-Frames: Y:%.1f%% UV:%.1f%%\n",
h->stat.i_wpred[0] * 100.0 / h->stat.i_frame_count[SLICE_TYPE_P],
h->stat.i_wpred[1] * 100.0 / h->stat.i_frame_count[SLICE_TYPE_P] );
}
}
/* Need variance data for weighted prediction */
- if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_FAKE || h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART )
+ if( h->param.analyse.i_weighted_pred )
{
for( int mb_y = 0; mb_y < h->mb.i_mb_height; mb_y++ )
for( int mb_x = 0; mb_x < h->mb.i_mb_width; mb_x++ )
goto fail;
}
- if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART && h->sh.weight[0][0].weightfn )
+ if( h->param.analyse.i_weighted_pred >= X264_WEIGHTP_SIMPLE && h->sh.weight[0][0].weightfn )
{
if( fprintf( rc->p_stat_file_out, "w:%d,%d,%d",
h->sh.weight[0][0].i_denom, h->sh.weight[0][0].i_scale, h->sh.weight[0][0].i_offset ) < 0 )
do_search[1] = b != p1 && frames[b]->lowres_mvs[1][p1-b-1][0][0] == 0x7FFF;
if( do_search[0] )
{
- if( ( h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART ||
- h->param.analyse.i_weighted_pred == X264_WEIGHTP_FAKE ) && b == p1 )
+ if( h->param.analyse.i_weighted_pred && b == p1 )
{
x264_emms();
x264_weights_analyse( h, frames[b], frames[p0], 1 );
/* Analyse for weighted P frames */
if( !h->param.rc.b_stat_read && h->lookahead->next.list[bframes]->i_type == X264_TYPE_P
- && h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART )
+ && h->param.analyse.i_weighted_pred >= X264_WEIGHTP_SIMPLE )
{
x264_emms();
x264_weights_analyse( h, h->lookahead->next.list[bframes], h->lookahead->last_nonb, 0 );
" - superfast:\n"
" --no-mbtree --me dia --no-mixed-refs\n"
" --partitions i8x8,i4x4 --rc-lookahead 0\n"
- " --ref 1 --subme 1 --trellis 0 --weightp 0\n"
+ " --ref 1 --subme 1 --trellis 0 --weightp 1\n"
" - veryfast:\n"
" --no-mixed-refs --rc-lookahead 10\n"
- " --ref 1 --subme 2 --trellis 0 --weightp 0\n"
+ " --ref 1 --subme 2 --trellis 0 --weightp 1\n"
" - faster:\n"
" --no-mixed-refs --rc-lookahead 20\n"
" --ref 2 --subme 4 --weightp 1\n"
" - fast:\n"
" --rc-lookahead 30 --ref 2 --subme 6\n"
+ " --weightp 1\n"
" - medium:\n"
" Default settings apply.\n"
" - slow:\n"
H2( " --no-weightb Disable weighted prediction for B-frames\n" );
H1( " --weightp <integer> Weighted prediction for P-frames [%d]\n"
" - 0: Disabled\n"
- " - 1: Blind offset\n"
- " - 2: Smart analysis\n", defaults->analyse.i_weighted_pred );
+ " - 1: Weighted refs\n"
+ " - 2: Weighted refs + Duplicates\n", defaults->analyse.i_weighted_pred );
H1( " --me <string> Integer pixel motion estimation method [\"%s\"]\n",
strtable_lookup( x264_motion_est_names, defaults->analyse.i_me_method ) );
H2( " - dia: diamond search, radius 1 (fast)\n"
#include <stdarg.h>
-#define X264_BUILD 109
+#define X264_BUILD 110
/* x264_t:
* opaque handler for encoder */
#define X264_B_ADAPT_FAST 1
#define X264_B_ADAPT_TRELLIS 2
#define X264_WEIGHTP_NONE 0
-#define X264_WEIGHTP_BLIND 1
+#define X264_WEIGHTP_SIMPLE 1
#define X264_WEIGHTP_SMART 2
#define X264_B_PYRAMID_NONE 0
#define X264_B_PYRAMID_STRICT 1