mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-07-29 11:41:45 +08:00
fix: 为 VAAPI 添加 CQP 码率控制回退
This commit is contained in:
@@ -368,6 +368,26 @@ struct CodecOptions {
|
||||
|
||||
bool set_rate_control(AVCodecContext *c, const std::string &name, int rc,
|
||||
int q) {
|
||||
if (name.find("vaapi") != std::string::npos && rc == RC_CQ) {
|
||||
// Used only after the normal bitrate-based VAAPI initialization fails.
|
||||
// Some drivers, including Intel iHD on Jasper Lake, expose CQP as their
|
||||
// only compatible rate-control mode.
|
||||
c->bit_rate = 0;
|
||||
c->rc_min_rate = 0;
|
||||
c->rc_max_rate = 0;
|
||||
c->rc_buffer_size = 0;
|
||||
c->rc_initial_buffer_occupancy = 0;
|
||||
|
||||
const int qp = q > 0 ? q : 23;
|
||||
const int ret = av_opt_set_int(c->priv_data, "qp", qp, 0);
|
||||
if (ret < 0) {
|
||||
LOG_ERROR(std::string("vaapi set qp failed, ret = ") +
|
||||
av_err2str(ret));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name.find("qsv") != std::string::npos) {
|
||||
// https://github.com/LizardByte/Sunshine/blob/3e47cd3cc8fd37a7a88be82444ff4f3c0022856b/src/video.cpp#L1635
|
||||
c->strict_std_compliance = FF_COMPLIANCE_UNOFFICIAL;
|
||||
|
||||
Reference in New Issue
Block a user