From a4acd9668c5674ebc501f49bed75d4138c33f032 Mon Sep 17 00:00:00 2001 From: lorenm Date: Thu, 18 Nov 2004 07:16:02 +0000 Subject: [PATCH] sync to x264 r61 (improved 2pass ratecontrol) rename option 'fullinter' to '4x4mv' git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13966 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/man/en/mplayer.1 | 23 +++++++++++++++++------ libmpcodecs/ve_x264.c | 21 ++++++++++++++------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 820a46cc67..b6c865a125 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -7091,11 +7091,11 @@ ratecontrol sensitivity (default: 4) . .TP .B ip_factor= -quantizer factor between I- and P-frames (default: 2.0) +quantizer factor between I- and P-frames (default: 1.4) . .TP .B pb_factor= -quantizer factor between P- and B-frames (default: 2.0) +quantizer factor between P- and B-frames (default: 1.4) . .TP .B pass=<1\-3> @@ -7147,18 +7147,29 @@ bitrate more constant, while a higher value makes the quantization parameter more constant. . .TP +.B cplx_blur=<0\-999> +Temporal blur of the estimated frame complexity, before curve compression +(default: 20). +Lower values allow the quantizer value to jump around more, +higher values force it to vary more smoothly. +cplx_blur ensures that each I-frame has quality comparable to the following +P-frames, and ensures that alternating high and low complexity frames +(e.g. low fps animation) do not waste bits on fluctuating quantizer. +. +.TP .B qblur=<0\-99> -Temporal blur of the quantization parameter (default: 0.5). +Temporal blur of the quantization parameter, after curve compression +(default: 0.5). Lower values allow the quantizer value to jump around more, higher values force it to vary more smoothly. . .TP -.B (no)fullinter +.B (no)4x4mv Use all available interframe macroblock types (i16x16, i4x4, p16x16, -p16x8, p8x16, p8x8, p8x4, p4x8, p4x4, pskip) +p16x8, p8x16, p8x8, p8x4, p4x8, p4x4, skip) The idea is to find the type and size that best describe a certain area of the picture, i.e.\& very effective for Anime, which usually contains -large areas of the same color (default: i16x16, i4x4, p16x16-8x8). +large areas of the same color (default: i16x16, i4x4, p16x16-8x8, skip). Depending on the source material, it can improve or degrade quality, use it with care. . diff --git a/libmpcodecs/ve_x264.c b/libmpcodecs/ve_x264.c index ab1f5147c6..dcb4a0b176 100644 --- a/libmpcodecs/ve_x264.c +++ b/libmpcodecs/ve_x264.c @@ -49,6 +49,10 @@ #include +#if X264_BUILD < 0x000c +#error We do not support old versions of x264. Get the latest from SVN. +#endif + typedef struct _h264_module_t { muxer_stream_t *mux; x264_param_t param; @@ -70,9 +74,9 @@ static int deblockalpha = 0; static int deblockbeta = 0; static int cabac = 1; static int cabacidc = -1; -static int fullinter = 0; -static float ip_factor = 2.0; -static float pb_factor = 2.0; +static int p4x4mv = 0; +static float ip_factor = 1.4; +static float pb_factor = 1.4; static int rc_buffer_size = -1; static int rc_init_buffer = -1; static int rc_sens = 4; @@ -82,7 +86,8 @@ static int qp_step = 1; static int pass = 0; static float qcomp = 0.6; static float qblur = 0.5; -static char *rc_eq = "(tex^qComp)*(avgTex^(1-qComp))"; +static float complexity_blur = 20; +static char *rc_eq = "tex*blurTex^(qComp-1)"; static int subq = 1; static int psnr = 0; static int log_level = 2; @@ -102,8 +107,8 @@ m_option_t x264encopts_conf[] = { {"cabac", &cabac, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"nocabac", &cabac, CONF_TYPE_FLAG, 0, 1, 0, NULL}, {"cabacidc", &cabacidc, CONF_TYPE_INT, CONF_RANGE, -1, 2, NULL}, - {"fullinter", &fullinter, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"nofullinter", &fullinter, CONF_TYPE_FLAG, 0, 1, 0, NULL}, + {"4x4mv", &p4x4mv, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + {"no4x4mv", &p4x4mv, CONF_TYPE_FLAG, 0, 1, 0, NULL}, {"ip_factor", &ip_factor, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0, NULL}, {"pb_factor", &pb_factor, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0, NULL}, {"rc_buffer_size", &rc_buffer_size, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL}, @@ -116,6 +121,7 @@ m_option_t x264encopts_conf[] = { {"rc_eq", &rc_eq, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"qcomp", &qcomp, CONF_TYPE_FLOAT, CONF_RANGE, 0, 1, NULL}, {"qblur", &qblur, CONF_TYPE_FLOAT, CONF_RANGE, 0, 99, NULL}, + {"cplx_blur", &complexity_blur, CONF_TYPE_FLOAT, CONF_RANGE, 0, 999, NULL}, {"subq", &subq, CONF_TYPE_INT, CONF_RANGE, 0, 5, NULL}, {"psnr", &psnr, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"nopsnr", &psnr, CONF_TYPE_FLAG, 0, 1, 0, NULL}, @@ -153,6 +159,7 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width, mod->param.rc.psz_rc_eq = rc_eq; mod->param.rc.f_qcompress = qcomp; mod->param.rc.f_qblur = qblur; + mod->param.rc.f_complexity_blur = complexity_blur; mod->param.analyse.i_subpel_refine = subq; mod->param.rc.psz_stat_out = passtmpfile; mod->param.rc.psz_stat_in = passtmpfile; @@ -191,7 +198,7 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width, mod->param.rc.i_rc_init_buffer = rc_init_buffer; mod->param.rc.i_rc_sens = rc_sens; } - if(fullinter) + if(p4x4mv) mod->param.analyse.inter = X264_ANALYSE_I4x4 | X264_ANALYSE_PSUB16x16 | X264_ANALYSE_PSUB8x8; mod->param.rc.f_ip_factor = ip_factor; mod->param.rc.f_pb_factor = pb_factor;