From: Steinar H. Gunderson Date: Thu, 21 Jul 2022 21:42:58 +0000 (+0200) Subject: Remove the x264 VBV settings. X-Git-Tag: 2.2.0~12 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=6df6a591ad1a7dbb9c8428e26cfe4953836c57e6 Remove the x264 VBV settings. The user shouldn't generally muck around with this, so remove them. --- diff --git a/nageru/flags.cpp b/nageru/flags.cpp index 2a31422..3066d3a 100644 --- a/nageru/flags.cpp +++ b/nageru/flags.cpp @@ -176,10 +176,6 @@ void usage(Program program) fprintf(stderr, " --x264-bitrate x264 bitrate (in kilobit/sec, default %d)\n", DEFAULT_X264_OUTPUT_BIT_RATE); fprintf(stderr, " --x264-crf=VALUE quality-based VBR (-12 to 51), incompatible with --x264-bitrate and VBV\n"); - fprintf(stderr, " --x264-vbv-bufsize x264 VBV size (in kilobits, 0 = one-frame VBV,\n"); - fprintf(stderr, " default: same as --x264-bitrate, that is, one-second VBV)\n"); - fprintf(stderr, " --x264-vbv-max-bitrate x264 local max bitrate (in kilobit/sec per --vbv-bufsize,\n"); - fprintf(stderr, " 0 = no limit, default: same as --x264-bitrate, i.e., CBR)\n"); fprintf(stderr, " --x264-param=NAME[,VALUE] set any x264 parameter, for fine tuning\n"); if (program == PROGRAM_NAGERU) { fprintf(stderr, " --x264-separate-disk-preset x264 quality preset (default " X264_DEFAULT_PRESET ")\n"); @@ -293,8 +289,6 @@ void parse_flags(Program program, int argc, char * const argv[]) { "x264-speedcontrol-verbose", no_argument, 0, OPTION_X264_SPEEDCONTROL_VERBOSE }, { "x264-bitrate", required_argument, 0, OPTION_X264_BITRATE }, { "x264-crf", required_argument, 0, OPTION_X264_CRF }, - { "x264-vbv-bufsize", required_argument, 0, OPTION_X264_VBV_BUFSIZE }, - { "x264-vbv-max-bitrate", required_argument, 0, OPTION_X264_VBV_MAX_BITRATE }, { "x264-param", required_argument, 0, OPTION_X264_PARAM }, { "x264-separate-disk-preset", required_argument, 0, OPTION_X264_SEPARATE_DISK_PRESET }, { "x264-separate-disk-tune", required_argument, 0, OPTION_X264_SEPARATE_DISK_TUNE }, @@ -485,12 +479,6 @@ void parse_flags(Program program, int argc, char * const argv[]) case OPTION_X264_CRF: global_flags.x264_crf = atof(optarg); break; - case OPTION_X264_VBV_BUFSIZE: - global_flags.x264_vbv_buffer_size = atoi(optarg); - break; - case OPTION_X264_VBV_MAX_BITRATE: - global_flags.x264_vbv_max_bitrate = atoi(optarg); - break; case OPTION_X264_PARAM: global_flags.x264_extra_param.push_back(optarg); break; @@ -815,9 +803,6 @@ void parse_flags(Program program, int argc, char * const argv[]) fprintf(stderr, "ERROR: --x264-bitrate and --x264-crf are mutually incompatible.\n"); exit(1); } - if (global_flags.x264_vbv_max_bitrate != -1 && global_flags.x264_vbv_buffer_size != -1) { - fprintf(stderr, "WARNING: VBV settings are ignored with --x264-crf.\n"); - } } else if (global_flags.x264_bitrate == -1) { global_flags.x264_bitrate = DEFAULT_X264_OUTPUT_BIT_RATE; } diff --git a/nageru/flags.h b/nageru/flags.h index 40f88f3..54e971a 100644 --- a/nageru/flags.h +++ b/nageru/flags.h @@ -40,8 +40,6 @@ struct Flags { bool x264_speedcontrol_verbose = false; int x264_bitrate = -1; // In kilobit/sec. -1 = not set = DEFAULT_X264_OUTPUT_BIT_RATE. float x264_crf = HUGE_VAL; // From 51 - QP_MAX_SPEC to 51. HUGE_VAL = not set = use x264_bitrate instead. - int x264_vbv_max_bitrate = -1; // In kilobits. 0 = no limit, -1 = same as (CBR). - int x264_vbv_buffer_size = -1; // In kilobits. 0 = one-frame VBV, -1 = same as (one-second VBV). std::vector x264_extra_param; // In “key[,value]” format. int av1_preset = DEFAULT_AV1_PRESET; diff --git a/nageru/x264_encoder.cpp b/nageru/x264_encoder.cpp index 6c46c98..b38711c 100644 --- a/nageru/x264_encoder.cpp +++ b/nageru/x264_encoder.cpp @@ -60,16 +60,8 @@ void update_vbv_settings(x264_param_t *param) if (global_flags.x264_bitrate == -1) { return; } - if (global_flags.x264_vbv_buffer_size < 0) { - param->rc.i_vbv_buffer_size = param->rc.i_bitrate; // One-second VBV. - } else { - param->rc.i_vbv_buffer_size = global_flags.x264_vbv_buffer_size; - } - if (global_flags.x264_vbv_max_bitrate < 0) { - param->rc.i_vbv_max_bitrate = param->rc.i_bitrate; // CBR. - } else { - param->rc.i_vbv_max_bitrate = global_flags.x264_vbv_max_bitrate; - } + param->rc.i_vbv_buffer_size = param->rc.i_bitrate; // One-second VBV. + param->rc.i_vbv_max_bitrate = param->rc.i_bitrate; // CBR. } } // namespace @@ -212,16 +204,11 @@ void X264Encoder::init_x264() } else { param.rc.i_rc_method = X264_RC_ABR; param.rc.i_bitrate = bitrate; - } - if (!use_separate_disk_params) { - update_vbv_settings(¶m); - } - if (param.rc.i_vbv_max_bitrate > 0) { - // If the user wants VBV control to cap the max rate, it is - // also reasonable to assume that they are fine with the stream - // constantly being around that rate even for very low-complexity - // content; the obvious and extreme example being a static - // black picture. + + // If the user wants to cap the max rate, it is also reasonable + // to assume that they are fine with the stream constantly + // being around that rate even for very low-complexity content; + // the obvious and extreme example being a static black picture. // // One would think it's fine to have low-complexity content use // less bitrate, but it seems to cause problems in practice; @@ -243,6 +230,9 @@ void X264Encoder::init_x264() // thus ignores the parameter.) param.rc.b_filler = 1; } + if (!use_separate_disk_params) { + update_vbv_settings(¶m); + } // Occasionally players have problem with extremely low quantizers; // be on the safe side. Shouldn't affect quality in any meaningful way.