switch enable abr

This commit is contained in:
csf 2022-06-30 18:24:36 +08:00
parent 09937049a6
commit a5ab0db5b9
2 changed files with 12 additions and 1 deletions

View File

@ -343,6 +343,7 @@ impl Decoder {
} }
} }
#[cfg(feature = "hwcodec")]
fn check_hwcodec_config() -> bool { fn check_hwcodec_config() -> bool {
if let Some(v) = Config2::get().options.get("enable-hwcodec") { if let Some(v) = Config2::get().options.get("enable-hwcodec") {
return v != "N"; return v != "N";

View File

@ -243,6 +243,15 @@ impl VideoQoS {
*self = Default::default(); *self = Default::default();
} }
fn check_abr_config(&mut self) -> bool {
self.enable_abr = if let Some(v) = Config2::get().options.get("enable-abr") {
v != "N"
} else {
true // default is true
};
self.enable_abr
}
pub fn convert_quality(q: i32) -> i32 { pub fn convert_quality(q: i32) -> i32 {
if q == ImageQuality::Balanced.value() { if q == ImageQuality::Balanced.value() {
100 * 2 / 3 100 * 2 / 3
@ -548,8 +557,9 @@ fn run(sp: GenericService) -> ResultType<()> {
video_qos.set_size(width as _, height as _); video_qos.set_size(width as _, height as _);
let mut spf = video_qos.spf(); let mut spf = video_qos.spf();
let bitrate = video_qos.generate_bitrate()?; let bitrate = video_qos.generate_bitrate()?;
let abr = video_qos.check_abr_config();
log::info!("init bitrate={}", bitrate); log::info!("init bitrate={}, abr enabled:{}", bitrate, abr);
let encoder_cfg = match Encoder::current_hw_encoder_name() { let encoder_cfg = match Encoder::current_hw_encoder_name() {
Some(codec_name) => EncoderCfg::HW(HwEncoderConfig { Some(codec_name) => EncoderCfg::HW(HwEncoderConfig {