]> git.sesse.net Git - nageru/commitdiff
Remove the x264 VBV settings.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 21 Jul 2022 21:42:58 +0000 (23:42 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 21 Jul 2022 21:42:58 +0000 (23:42 +0200)
The user shouldn't generally muck around with this, so remove them.

nageru/flags.cpp
nageru/flags.h
nageru/x264_encoder.cpp

index 2a31422f854b723502a3680c536525a63da4dde8..3066d3afc01b5cc4db0cf96adb9c6fc0892ccca6 100644 (file)
@@ -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;
        }
index 40f88f3bd315659295565a02dd55395f553fff7f..54e971a6b0ae2f78dc399d125e2d834e1d029b7c 100644 (file)
@@ -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 <x264_bitrate> (CBR).
-       int x264_vbv_buffer_size = -1;  // In kilobits. 0 = one-frame VBV, -1 = same as <x264_bitrate> (one-second VBV).
        std::vector<std::string> x264_extra_param;  // In “key[,value]” format.
 
        int av1_preset = DEFAULT_AV1_PRESET;
index 6c46c98c689dbdd99e16275e9d3466a883e8dd9e..b38711cb571c3085b6dfb72436ba5eacff665956 100644 (file)
@@ -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(&param);
-       }
-       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(&param);
+       }
 
        // Occasionally players have problem with extremely low quantizers;
        // be on the safe side. Shouldn't affect quality in any meaningful way.