# HG changeset patch # User lorenm # Date 1115827212 0 # Node ID 561f617e894446eb8057da43cf52c307edaae3c9 # Parent ead83e8d0c95f3db83e6133053c8a4b7a18c2e8f sync to x264 rev223 (options: ratetol, vbv_*) diff -r ead83e8d0c95 -r 561f617e8944 DOCS/man/en/mplayer.1 --- a/DOCS/man/en/mplayer.1 Wed May 11 14:42:59 2005 +0000 +++ b/DOCS/man/en/mplayer.1 Wed May 11 16:00:12 2005 +0000 @@ -7709,8 +7709,11 @@ . .TP .B bitrate= -Sets the bitrate to be used in kbits/\:second (default: off). -This is required if you want a CBR (constant bitrate) encode. +Sets the average bitrate to be used in kbits/\:second (default: off). +Since local bitrate may vary, this average may be inaccurate for +very short videos (see ratetol). +Constant bitrate can be achieved by combining this with vbv_maxrate, +at significant reduction in quality. . .TP .B qp_constant=<1\-51> @@ -7756,10 +7759,8 @@ the second pass' stats to work from. You can use all encoding options, including CPU-hungry ones. .br -The first pass may use either constant bitrate or constant quantizer. -Constant quantizer is often slightly better, but requires that you guess a -qp_constant that is somewhere near your desired bitrate. -(It is better to err on the side of lower qp_constant, i.e.\& higher bitrate.) +The first pass may use either average bitrate or constant quantizer. +ABR is recommended, since it doesn't require guessing a quantizer. Subsequent passes are ABR, and must specify bitrate. .br .I @@ -7779,7 +7780,7 @@ . .TP .B keyint_min=<1\-keyint/2> -Sets minimum interval between IDR-frames (default: keyint * 0.4). +Sets minimum interval between IDR-frames (default: 25). If scenecuts appear within this interval, they are still encoded as I-frames, but do not start a new GOP. In H.264, I-frames do not necessarily bound a closed GOP because it is @@ -7877,30 +7878,34 @@ Unless you are looking for decoding speed, you should not disable it. . .TP -.B qp_min=<1\-51> (CBR or two pass) +.B qp_min=<1\-51> (ABR or two pass) Minimum quantizer, 10\-30 seems to be a useful range (default: 10). . .TP -.B qp_max=<1\-51> (CBR or two pass) +.B qp_max=<1\-51> (ABR or two pass) maximum quantizer (default: 51) . .TP -.B qp_step=<1\-50> (CBR or two pass) -Maximum Value by which the quantizer may be incremented/decremented between -frames (default: 1). -. -.TP -.B rc_buffer_size= (CBR or two pass) -ratecontrol buffer size, in kbit (default: 1 second's worth at the bitrate you -specified) -. -.TP -.B rc_init_buffer=<0.0\-1.0> (CBR only) -Set the initial ratecontrol buffer fullness (default: 0.25). -. -.TP -.B rc_sens=<0\-100> (CBR only) -ratecontrol sensitivity (default: 4) +.B qp_step=<1\-50> (ABR or two pass) +maximum value by which the quantizer may be incremented/decremented between +frames (default: 2) +. +.TP +.B ratetol=<0.1\-100.0> (ABR or two pass) +allowed variance in average bitrate (no particular units) (default: 1.0) +. +.TP +.B vbv_maxrate= (ABR or two pass) +maximum local bitrate, in kbits/\:second (default: disabled) +. +.TP +.B vbv_bufsize= (ABR or two pass) +averaging period for vbv_maxrate, in kbits +(default: none, must be specified if vbv_maxrate is enabled) +. +.TP +.B vbv_init=<0.0\-1.0> (ABR or two pass) +initial buffer occupancy, as a fraction of vbv_bufsize (default: 0.9) . .TP .B ip_factor= @@ -7911,7 +7916,7 @@ quantizer factor between P- and B-frames (default: 1.3) . .TP -.B qcomp=<0\-1> (two pass only) +.B qcomp=<0\-1> (ABR or two pass) quantizer compression (default: 0.6). A lower value makes the bitrate more constant, while a higher value makes the quantization parameter more constant. diff -r ead83e8d0c95 -r 561f617e8944 configure --- a/configure Wed May 11 14:42:59 2005 +0000 +++ b/configure Wed May 11 16:00:12 2005 +0000 @@ -6057,7 +6057,7 @@ cat > $TMPC << EOF #include #include -#if X264_BUILD < 23 +#if X264_BUILD < 24 #error We do not support old versions of x264. Get the latest from SVN. #endif int main(void) { x264_encoder_open((void*)0); return 0; } diff -r ead83e8d0c95 -r 561f617e8944 libmpcodecs/ve_x264.c --- a/libmpcodecs/ve_x264.c Wed May 11 14:42:59 2005 +0000 +++ b/libmpcodecs/ve_x264.c Wed May 11 16:00:12 2005 +0000 @@ -62,7 +62,7 @@ static int qp_constant = 26; static int frame_ref = 1; static int keyint_max = 250; -static int keyint_min = -1; +static int keyint_min = 25; static int scenecut_threshold = 40; static int bframe = 0; static int bframe_adaptive = 1; @@ -81,12 +81,13 @@ static int chroma_qp_offset = 0; static float ip_factor = 1.4; static float pb_factor = 1.3; -static int rc_buffer_size = -1; -static float rc_init_buffer = 0.25; -static int rc_sens = 4; +static float ratetol = 1.0; +static int vbv_maxrate = 0; +static int vbv_bufsize = 0; +static float vbv_init = 0.9; static int qp_min = 10; static int qp_max = 51; -static int qp_step = 1; +static int qp_step = 2; static int pass = 0; static float qcomp = 0.6; static float qblur = 0.5; @@ -132,9 +133,10 @@ {"chroma_qp_offset", &chroma_qp_offset, CONF_TYPE_INT, CONF_RANGE, -12, 12, 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}, - {"rc_init_buffer", &rc_init_buffer, CONF_TYPE_FLOAT, CONF_RANGE, 0, 24000000, NULL}, - {"rc_sens", &rc_sens, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, + {"ratetol", &ratetol, CONF_TYPE_FLOAT, CONF_RANGE, 0.1, 100.0, NULL}, + {"vbv_maxrate", &vbv_maxrate, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL}, + {"vbv_bufsize", &vbv_bufsize, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL}, + {"vbv_init", &vbv_init, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL}, {"qp_min", &qp_min, CONF_TYPE_INT, CONF_RANGE, 1, 51, NULL}, {"qp_max", &qp_max, CONF_TYPE_INT, CONF_RANGE, 1, 51, NULL}, {"qp_step", &qp_step, CONF_TYPE_INT, CONF_RANGE, 1, 50, NULL}, @@ -165,7 +167,7 @@ x264_param_default(&mod->param); mod->param.i_frame_reference = frame_ref; mod->param.i_keyint_max = keyint_max; - mod->param.i_keyint_min = keyint_min > 0 ? keyint_min : keyint_max * 2 / 5; + mod->param.i_keyint_min = keyint_min; mod->param.i_scenecut_threshold = scenecut_threshold; mod->param.i_bframe = bframe; mod->param.b_bframe_adaptive = bframe_adaptive; @@ -189,6 +191,7 @@ mod->param.rc.f_qblur = qblur; mod->param.rc.f_complexity_blur = complexity_blur; mod->param.analyse.i_subpel_refine = subq; + mod->param.analyse.i_me_method = subq==1 ? X264_ME_DIA : X264_ME_HEX; mod->param.rc.psz_stat_out = passtmpfile; mod->param.rc.psz_stat_in = passtmpfile; if((pass & 2) && bitrate <= 0) @@ -216,16 +219,17 @@ break; } if(bitrate > 0) { - if(rc_buffer_size <= 0) - rc_buffer_size = bitrate; + if((vbv_maxrate > 0) != (vbv_bufsize > 0)) { + mp_msg(MSGT_MENCODER, MSGL_ERR, + "VBV requires both vbv_maxrate and vbv_bufsize.\n"); + return 0; + } mod->param.rc.b_cbr = 1; mod->param.rc.i_bitrate = bitrate; - mod->param.rc.i_rc_buffer_size = rc_buffer_size; - if(rc_init_buffer > 1) - mod->param.rc.i_rc_init_buffer = rc_init_buffer; - else - mod->param.rc.i_rc_init_buffer = rc_buffer_size * rc_init_buffer; - mod->param.rc.i_rc_sens = rc_sens; + mod->param.rc.f_rate_tolerance = ratetol; + mod->param.rc.i_vbv_max_bitrate = vbv_maxrate; + mod->param.rc.i_vbv_buffer_size = vbv_bufsize; + mod->param.rc.f_vbv_buffer_init = vbv_init; } mod->param.rc.f_ip_factor = ip_factor; mod->param.rc.f_pb_factor = pb_factor;