diff options
author | gpoirier <gpoirier@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-07-11 17:52:03 +0000 |
---|---|---|
committer | gpoirier <gpoirier@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-07-11 17:52:03 +0000 |
commit | c60555edbf80b05838156a103f180cdb5d405654 (patch) | |
tree | cb5f8105095ea0f5f48a8fc9e0d786ef920167b2 | |
parent | fc245d56826de987a556c0583c3094ff8f521f17 (diff) | |
download | mpv-c60555edbf80b05838156a103f180cdb5d405654.tar.bz2 mpv-c60555edbf80b05838156a103f180cdb5d405654.tar.xz |
x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15965 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | DOCS/man/en/mplayer.1 | 25 | ||||
-rw-r--r-- | libmpcodecs/ve_x264.c | 60 |
3 files changed, 66 insertions, 20 deletions
@@ -57,6 +57,7 @@ MPlayer (1.0) * XviD's encoding zones and luminance masking * raw audio muxer * fixed various bugs in the EDL code + * x264 "turbo mode" to speed up first pass of multi-pass encoding Ports: * improved timer function on Mac OS X diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 4791b0d74d..94d632bc0f 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -7947,6 +7947,31 @@ both fast and provide good quality. .REss . .TP +.B turbo=<0\-2> +Fast first pass mode. +During the first pass of a 2 or more pass encode it is possible to gain +speed through disabling some options with negligible to no impact on the +final pass output quality. +.PD 0 +.RSs +.IPs 0 +disabled (default) +.IPs 1 +reduce subq, frameref and disable some inter macroblock partition analysis +modes +.IPs 2 +reduce subq and frameref to 1, use a diamond ME search and disable all +sub-partition analysis modes +.RE +.RS +Level 1 can increase first pass speed up to 2x with no change in the global +PSNR of the final pass compared to a full quality first pass. +.br +Level 2 can increase first pass speed up to 4x with about +/- 0.05dB change +in the global PSNR of the final pass compared to a full quality first pass. +.REss +. +.TP .B keyint=<value> Sets maximum interval between IDR-frames (default: 250). Larger values save bits, thus improve quality, at the cost of seeking diff --git a/libmpcodecs/ve_x264.c b/libmpcodecs/ve_x264.c index 35c88f5653..ffdd3fd11b 100644 --- a/libmpcodecs/ve_x264.c +++ b/libmpcodecs/ve_x264.c @@ -104,6 +104,7 @@ static int threads = 1; static int level_idc = 40; static int psnr = 0; static int log_level = 2; +static int turbo = 0; m_option_t x264encopts_conf[] = { {"bitrate", &bitrate, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL}, @@ -212,24 +213,6 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width, "2 pass encoding enabled, but no bitrate specified.\n"); return 0; } - switch(pass) { - case 0: - mod->param.rc.b_stat_write = 0; - mod->param.rc.b_stat_read = 0; - break; - case 1: - mod->param.rc.b_stat_write = 1; - mod->param.rc.b_stat_read = 0; - break; - case 2: - mod->param.rc.b_stat_write = 0; - mod->param.rc.b_stat_read = 1; - break; - case 3: - mod->param.rc.b_stat_write = 1; - mod->param.rc.b_stat_read = 1; - break; - } if(bitrate > 0) { if((vbv_maxrate > 0) != (vbv_bufsize > 0)) { mp_msg(MSGT_MENCODER, MSGL_ERR, @@ -252,8 +235,6 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width, case 3: mod->param.analyse.i_me_method = X264_ME_UMH; break; case 4: mod->param.analyse.i_me_method = X264_ME_ESA; break; } - if(me_method >= 3) - mod->param.analyse.i_me_range = me_range; mod->param.analyse.inter = 0; if(p4x4mv) mod->param.analyse.inter |= X264_ANALYSE_PSUB8x8; if(p8x8mv) mod->param.analyse.inter |= X264_ANALYSE_PSUB16x16; @@ -277,6 +258,45 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width, mod->param.vui.i_sar_height = d_height*width; mod->param.i_threads = threads; + switch(pass) { + case 0: + mod->param.rc.b_stat_write = 0; + mod->param.rc.b_stat_read = 0; + break; + case 1: + /* Adjust or disable some flags to gain speed in the first pass */ + if(turbo == 1) + { + mod->param.i_frame_reference = ( frame_ref + 1 ) >> 1; + mod->param.analyse.i_subpel_refine = max( min( 3, subq - 1 ), 1 ); + mod->param.analyse.inter &= ( ~X264_ANALYSE_PSUB8x8 ); + mod->param.analyse.inter &= ( ~X264_ANALYSE_BSUB16x16 ); + } + else if(turbo == 2) + { + mod->param.i_frame_reference = 1; + mod->param.analyse.i_subpel_refine = 1; + mod->param.analyse.i_me_method = X264_ME_DIA; + mod->param.analyse.inter = 0; + mod->param.analyse.b_transform_8x8 = 0; + mod->param.analyse.b_weighted_bipred = 0; + } + mod->param.rc.b_stat_write = 1; + mod->param.rc.b_stat_read = 0; + break; + case 2: + mod->param.rc.b_stat_write = 0; + mod->param.rc.b_stat_read = 1; + break; + case 3: + mod->param.rc.b_stat_write = 1; + mod->param.rc.b_stat_read = 1; + break; + } + + if(me_method >= 3) + mod->param.analyse.i_me_range = me_range; + switch(outfmt) { case IMGFMT_I420: mod->param.i_csp = X264_CSP_I420; |