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
-X264Encoder::X264Encoder(AVOutputFormat *oformat, bool use_separate_disk_params)
+X264Encoder::X264Encoder(const AVOutputFormat *oformat, bool use_separate_disk_params)
: wants_global_headers(oformat->flags & AVFMT_GLOBALHEADER),
use_separate_disk_params(use_separate_disk_params),
- dyn(load_x264_for_bit_depth(global_flags.x264_bit_depth))
+ dyn(load_x264_for_bit_depth(global_flags.bit_depth))
{
if (use_separate_disk_params) {
call_once(x264_disk_metrics_inited, []{
});
}
- size_t bytes_per_pixel = global_flags.x264_bit_depth > 8 ? 2 : 1;
+ size_t bytes_per_pixel = global_flags.bit_depth > 8 ? 2 : 1;
frame_pool.reset(new uint8_t[global_flags.width * global_flags.height * 2 * bytes_per_pixel * X264_QUEUE_LENGTH]);
for (unsigned i = 0; i < X264_QUEUE_LENGTH; ++i) {
free_frames.push(frame_pool.get() + i * (global_flags.width * global_flags.height * 2 * bytes_per_pixel));
free_frames.pop();
}
- size_t bytes_per_pixel = global_flags.x264_bit_depth > 8 ? 2 : 1;
+ size_t bytes_per_pixel = global_flags.bit_depth > 8 ? 2 : 1;
memcpy(qf.data, data, global_flags.width * global_flags.height * 2 * bytes_per_pixel);
{
param.i_width = global_flags.width;
param.i_height = global_flags.height;
param.i_csp = X264_CSP_NV12;
- if (global_flags.x264_bit_depth > 8) {
+ if (global_flags.bit_depth > 8) {
param.i_csp |= X264_CSP_HIGH_DEPTH;
}
param.b_vfr_input = 1;
param.i_frame_reference = 16; // Because speedcontrol is never allowed to change this above what we set at start.
}
#if X264_BUILD >= 153
- param.i_bitdepth = global_flags.x264_bit_depth;
+ param.i_bitdepth = global_flags.bit_depth;
#endif
// NOTE: These should be in sync with the ones in quicksync_encoder.cpp (sps_rbsp()).
} 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;
// 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.
}
}
- if (global_flags.x264_bit_depth > 8) {
+ if (global_flags.bit_depth > 8) {
dyn.x264_param_apply_profile(¶m, "high10");
} else {
dyn.x264_param_apply_profile(¶m, "high");
dyn.x264_picture_init(&pic);
pic.i_pts = qf.pts;
- if (global_flags.x264_bit_depth > 8) {
+ if (global_flags.bit_depth > 8) {
pic.img.i_csp = X264_CSP_NV12 | X264_CSP_HIGH_DEPTH;
pic.img.i_plane = 2;
pic.img.plane[0] = qf.data;