Especially at the fastest settings, intra analysis was taking up the majority of MB analysis time.
This patch takes a ton more shortcuts at the fastest encoding settings, decreasing compression 0.5-5% but improving speed greatly.
Also rearrange the fastest presets a bit: now we have ultrafast, superfast, veryfast, faster.
superfast is the old veryfast (but much faster due to this patch).
veryfast is between the old veryfast and faster.
faster is the same as before except with MB-tree on.
Encoding with subme >= 5 should be unaffected by this patch.
param->rc.b_mb_tree = 0;
param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
}
- else if( !strcasecmp( preset, "veryfast" ) )
+ else if( !strcasecmp( preset, "superfast" ) )
{
param->analyse.inter = X264_ANALYSE_I8x8|X264_ANALYSE_I4x4;
param->analyse.i_me_method = X264_ME_DIA;
param->rc.b_mb_tree = 0;
param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
}
+ else if( !strcasecmp( preset, "veryfast" ) )
+ {
+ param->analyse.i_me_method = X264_ME_HEX;
+ param->analyse.i_subpel_refine = 2;
+ param->i_frame_reference = 1;
+ 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;
+ }
else if( !strcasecmp( preset, "faster" ) )
{
param->analyse.b_mixed_references = 0;
param->i_frame_reference = 2;
param->analyse.i_subpel_refine = 4;
- param->rc.b_mb_tree = 0;
param->analyse.i_weighted_pred = X264_WEIGHTP_BLIND;
+ param->rc.i_lookahead = 20;
}
else if( !strcasecmp( preset, "fast" ) )
{
/* Fast intra decision */
if( h->mb.i_mb_xy - h->sh.i_first_mb > 4 )
{
- if( IS_INTRA( h->mb.i_mb_type_left )
- || IS_INTRA( h->mb.i_mb_type_top )
- || IS_INTRA( h->mb.i_mb_type_topleft )
- || IS_INTRA( h->mb.i_mb_type_topright )
- || (h->sh.i_type == SLICE_TYPE_P && IS_INTRA( h->fref0[0]->mb_type[h->mb.i_mb_xy] ))
- || (h->mb.i_mb_xy - h->sh.i_first_mb < 3*(h->stat.frame.i_mb_count[I_4x4] + h->stat.frame.i_mb_count[I_8x8] + h->stat.frame.i_mb_count[I_16x16])) )
+ /* Always run in fast-intra mode for subme < 3 */
+ if( h->mb.i_subpel_refine > 2 &&
+ ( IS_INTRA( h->mb.i_mb_type_left ) ||
+ IS_INTRA( h->mb.i_mb_type_top ) ||
+ IS_INTRA( h->mb.i_mb_type_topleft ) ||
+ IS_INTRA( h->mb.i_mb_type_topright ) ||
+ (h->sh.i_type == SLICE_TYPE_P && IS_INTRA( h->fref0[0]->mb_type[h->mb.i_mb_xy] )) ||
+ (h->mb.i_mb_xy - h->sh.i_first_mb < 3*(h->stat.frame.i_mb_count[I_4x4] + h->stat.frame.i_mb_count[I_8x8] + h->stat.frame.i_mb_count[I_16x16])) ) )
{ /* intra is likely */ }
else
{
if( h->sh.i_type == SLICE_TYPE_B )
/* cavlc mb type prefix */
a->i_satd_i16x16 += a->i_lambda * i_mb_b_cost_table[I_16x16];
- if( a->b_fast_intra && a->i_satd_i16x16 > 2*i_satd_inter )
+
+ /* Not heavily tuned */
+ const uint8_t i16x16_thresh[11] = { 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4 };
+ int thresh = i16x16_thresh[h->mb.i_subpel_refine];
+ if( a->b_fast_intra && a->i_satd_i16x16 > (thresh*i_satd_inter)>>1 )
return;
/* 8x8 prediction selection */
a->i_satd_i8x8 = COST_MAX;
i_cost = (i_cost * cost_div_fix8[idx]) >> 8;
}
- if( X264_MIN(i_cost, a->i_satd_i16x16) > i_satd_inter*(5+!!a->i_mbrd)/4 )
+ /* Not heavily tuned */
+ const uint8_t i8x8_thresh[11] = { 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6 };
+ int thresh = i8x8_thresh[h->mb.i_subpel_refine];
+ if( X264_MIN(i_cost, a->i_satd_i16x16) > (i_satd_inter*thresh)>>2 )
return;
}
" --partitions none --ref 1 --scenecut 0\n"
" --subme 0 --trellis 0 --no-weightb\n"
" --weightp 0\n"
- " - veryfast:\n"
+ " - superfast:\n"
" --no-mbtree --me dia --no-mixed-refs\n"
" --partitions i8x8,i4x4 --ref 1\n"
" --subme 1 --trellis 0 --weightp 0\n"
+ " - veryfast:\n"
+ " --no-mbtree --no-mixed-refs --ref 1\n"
+ " --subme 2 --trellis 0 --weightp 0\n"
" - faster:\n"
- " --no-mbtree --no-mixed-refs --ref 2\n"
- " --subme 4 --weightp 1\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"
" - medium:\n"
" --me tesa --merange 24 --partitions all\n"
" --rc-lookahead 60 --ref 16 --subme 10\n"
" --trellis 2\n" );
- else H0( " - ultrafast,veryfast,faster,fast,medium\n"
- " - slow,slower,veryslow,placebo\n" );
+ else H0( " - ultrafast,superfast,veryfast,faster,fast\n"
+ " - medium,slow,slower,veryslow,placebo\n" );
H0( " --tune Tune the settings for a particular type of source\n"
" or situation\n"
" Overridden by user settings.\n"
#include <stdarg.h>
-#define X264_BUILD 91
+#define X264_BUILD 92
/* x264_t:
* opaque handler for encoder */
* (either can be NULL, which implies no preset or no tune, respectively)
*
* Currently available presets are, ordered from fastest to slowest: */
-static const char * const x264_preset_names[] = { "ultrafast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo", 0 };
+static const char * const x264_preset_names[] = { "ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo", 0 };
/* Warning: the speed of these presets scales dramatically. Ultrafast is a full
* 100 times faster than placebo!