--- plugins/x264/x264.c 2006/06/25 13:10:30 1.7 +++ plugins/x264/x264.c 2006/07/25 12:17:37 1.8 @@ -437,7 +437,7 @@ codec->stats_filename = malloc(strlen(stats_file)+1); strcpy(codec->stats_filename, stats_file); - fprintf(stderr, "set_pass_x264 %d %d %s\n", pass, total_passes, stats_file); + // fprintf(stderr, "set_pass_x264 %d %d %s\n", pass, total_passes, stats_file); return 1; } @@ -488,22 +488,28 @@ codec->params.i_fps_den = lqt_frame_duration(file, track, NULL); /* Set multipass control */ - - /* Open encoder */ - if(codec->pass == 1) + if(codec->total_passes) { - /* Strings will be made private by x264 */ - codec->params.rc.psz_stat_out = codec->stats_filename; - codec->params.rc.b_stat_write = 1; - } - else if(codec->total_passes && (codec->pass == codec->total_passes)) - { - /* Strings will be made private by x264 */ - codec->params.rc.psz_stat_in = codec->stats_filename; - codec->params.rc.b_stat_read = 1; + /* Force ABR */ + codec->params.rc.i_rc_method = X264_RC_ABR; + codec->params.rc.i_rf_constant = 0; + if(codec->pass == 1) + { + /* Strings will be made private by x264 */ + codec->params.rc.psz_stat_out = codec->stats_filename; + codec->params.rc.b_stat_write = 1; + } + else if(codec->pass == codec->total_passes) + { + /* Strings will be made private by x264 */ + codec->params.rc.psz_stat_in = codec->stats_filename; + codec->params.rc.b_stat_read = 1; + } } + /* Open encoder */ + codec->enc = x264_encoder_open(&codec->params); if(!codec->enc) { @@ -621,6 +627,14 @@ { "Auto", X264_DIRECT_PRED_AUTO } }; +enum_t rc_methods[] = + { + { "Constant quality", X264_RC_CQP }, + { "Average bitrate", X264_RC_ABR }, + { "CRF based VBR", X264_RC_CRF } + }; + + static int set_parameter(quicktime_t *file, int track, char *key, @@ -637,22 +651,11 @@ INTPARAM("x264_i_bframe_bias", codec->params.i_bframe_bias); INTPARAM("x264_b_bframe_pyramid", codec->params.b_bframe_pyramid); - if(!strcasecmp(key, "x264_i_bitrate")) - { - if(*(int*)(value)) - { - codec->params.rc.b_cbr = 1; - codec->params.rc.i_bitrate = *(int*)(value); - } - else - { - codec->params.rc.b_cbr = 0; - codec->params.rc.i_bitrate = 0; - } - found = 1; - } - + ENUMPARAM("x264_i_rc_method", codec->params.rc.i_rc_method, rc_methods); + INTPARAM("x264_i_bitrate", codec->params.rc.i_bitrate); + INTPARAM("x264_i_qp_constant", codec->params.rc.i_qp_constant); + INTPARAM("x264_i_rf_constant", codec->params.rc.i_rf_constant); INTPARAM("x264_i_qp_min", codec->params.rc.i_qp_min); INTPARAM("x264_i_qp_max", codec->params.rc.i_qp_max); INTPARAM("x264_i_qp_step", codec->params.rc.i_qp_step); --- plugins/x264/lqt_x264.c 2006/04/10 21:46:15 1.2 +++ plugins/x264/lqt_x264.c 2006/07/25 12:17:37 1.3 @@ -74,6 +74,21 @@ type: LQT_PARAMETER_SECTION }, { + name: "x264_i_rc_method", + real_name: "Ratecontrol method", + type: LQT_PARAMETER_STRINGLIST, + val_default: { val_string: "Constant quality" }, + stringlist_options: (char*[]){ "Constant quality", + "Average bitrate", + "CRF based VBR", + (char*)0 }, + help_string: "Ratecontrol method:\n\ +Constant quality: Specify a quantizer parameter below\n\ +Average bitrate: Specify a bitrate below\n\ +CRF based VBR: Specify a rate factor below\n\ +Selecting 2-pass encoding will force Average bitrate.", + }, + { name: "x264_i_bitrate", real_name: "Bitrate", type: LQT_PARAMETER_INT, @@ -81,6 +96,16 @@ help_string: "Bitrate in kbit/s. 0 means VBR (recommended)" }, { + name: "x264_i_rf_constant", + real_name: "Nominal Quantizer parameter", + type: LQT_PARAMETER_INT, + val_default: { val_int: 26 }, + val_min: { val_int: 0 }, + val_max: { val_int: 51 }, + help_string: "This selects the nominal quantizer to use (1 to 51). Lower values result in " \ + "better fidelity, but higher bitrates. 26 is a good default value. 0 means lossless." + }, + { name: "x264_i_qp_constant", real_name: "Quantizer parameter", type: LQT_PARAMETER_INT, @@ -90,7 +115,9 @@ help_string: "This selects the quantizer to use (1 to 51). Lower values result in " \ "better fidelity, but higher bitrates. 26 is a good default value. 0 means lossless." }, - { + + +{ name: "x264_i_qp_min", real_name: "Minimum quantizer parameter", type: LQT_PARAMETER_INT,