If there is hardware ram encoder as fallback, not require all adapters (#7987)
support the codec format Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
9d56e29a09
commit
a31a68ba17
@ -139,6 +139,7 @@ impl Encoder {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("new hw encoder failed: {e:?}, clear config");
|
log::error!("new hw encoder failed: {e:?}, clear config");
|
||||||
hbb_common::config::HwCodecConfig::clear_ram();
|
hbb_common::config::HwCodecConfig::clear_ram();
|
||||||
|
Self::update(EncodingUpdate::Check);
|
||||||
*ENCODE_CODEC_FORMAT.lock().unwrap() = CodecFormat::VP9;
|
*ENCODE_CODEC_FORMAT.lock().unwrap() = CodecFormat::VP9;
|
||||||
Err(e)
|
Err(e)
|
||||||
}
|
}
|
||||||
@ -151,6 +152,7 @@ impl Encoder {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("new vram encoder failed: {e:?}, clear config");
|
log::error!("new vram encoder failed: {e:?}, clear config");
|
||||||
hbb_common::config::HwCodecConfig::clear_vram();
|
hbb_common::config::HwCodecConfig::clear_vram();
|
||||||
|
Self::update(EncodingUpdate::Check);
|
||||||
*ENCODE_CODEC_FORMAT.lock().unwrap() = CodecFormat::VP9;
|
*ENCODE_CODEC_FORMAT.lock().unwrap() = CodecFormat::VP9;
|
||||||
Err(e)
|
Err(e)
|
||||||
}
|
}
|
||||||
|
@ -96,10 +96,7 @@ impl EncoderApi for HwRamEncoder {
|
|||||||
height: ctx.height as _,
|
height: ctx.height as _,
|
||||||
bitrate,
|
bitrate,
|
||||||
}),
|
}),
|
||||||
Err(_) => {
|
Err(_) => Err(anyhow!(format!("Failed to create encoder"))),
|
||||||
HwCodecConfig::clear_ram();
|
|
||||||
Err(anyhow!(format!("Failed to create encoder")))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Err(anyhow!("encoder type mismatch")),
|
_ => Err(anyhow!("encoder type mismatch")),
|
||||||
|
@ -87,10 +87,7 @@ impl EncoderApi for VRamEncoder {
|
|||||||
same_bad_len_counter: 0,
|
same_bad_len_counter: 0,
|
||||||
config,
|
config,
|
||||||
}),
|
}),
|
||||||
Err(_) => {
|
Err(_) => Err(anyhow!(format!("Failed to create encoder"))),
|
||||||
hbb_common::config::HwCodecConfig::clear_vram();
|
|
||||||
Err(anyhow!(format!("Failed to create encoder")))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Err(anyhow!("encoder type mismatch")),
|
_ => Err(anyhow!("encoder type mismatch")),
|
||||||
@ -213,32 +210,37 @@ impl VRamEncoder {
|
|||||||
CodecFormat::H265 => DataFormat::H265,
|
CodecFormat::H265 => DataFormat::H265,
|
||||||
_ => return vec![],
|
_ => return vec![],
|
||||||
};
|
};
|
||||||
let Ok(displays) = crate::Display::all() else {
|
|
||||||
log::error!("failed to get displays");
|
|
||||||
return vec![];
|
|
||||||
};
|
|
||||||
if displays.is_empty() {
|
|
||||||
log::error!("no display found");
|
|
||||||
return vec![];
|
|
||||||
}
|
|
||||||
let luids = displays
|
|
||||||
.iter()
|
|
||||||
.map(|d| d.adapter_luid())
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let v: Vec<_> = get_available_config()
|
let v: Vec<_> = get_available_config()
|
||||||
.map(|c| c.e)
|
.map(|c| c.e)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.drain(..)
|
.drain(..)
|
||||||
.filter(|c| c.data_format == data_format)
|
.filter(|c| c.data_format == data_format)
|
||||||
.collect();
|
.collect();
|
||||||
if luids
|
if crate::hwcodec::HwRamEncoder::try_get(format).is_some() {
|
||||||
.iter()
|
// has fallback, no need to require all adapters support
|
||||||
.all(|luid| v.iter().any(|f| Some(f.luid) == *luid))
|
|
||||||
{
|
|
||||||
v
|
v
|
||||||
} else {
|
} else {
|
||||||
log::info!("not all adapters support {data_format:?}, luids = {luids:?}");
|
let Ok(displays) = crate::Display::all() else {
|
||||||
vec![]
|
log::error!("failed to get displays");
|
||||||
|
return vec![];
|
||||||
|
};
|
||||||
|
if displays.is_empty() {
|
||||||
|
log::error!("no display found");
|
||||||
|
return vec![];
|
||||||
|
}
|
||||||
|
let luids = displays
|
||||||
|
.iter()
|
||||||
|
.map(|d| d.adapter_luid())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
if luids
|
||||||
|
.iter()
|
||||||
|
.all(|luid| v.iter().any(|f| Some(f.luid) == *luid))
|
||||||
|
{
|
||||||
|
v
|
||||||
|
} else {
|
||||||
|
log::info!("not all adapters support {data_format:?}, luids = {luids:?}");
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user