Skip to content

Commit 2480ac0

Browse files
committed
fix(compositor): decode_frame_n refuses a software frame
get_hw_format now falls back to software when D3D11VA has no surface. decode_frame_n's callers hand its frame to Compositor::nv12_srvs, which reads a D3D11 texture, so it returns an error on that path instead. Refs #1532
1 parent b938eb3 commit 2480ac0

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎crates/compositor/src/pipeline_windows.rs‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@ unsafe fn decode_frame_n_inner(path: &str, gpu: &Gpu, n: u32) -> Result<FrameGua
334334
}
335335
averr(r, "receive_frame")?;
336336
if got == n {
337+
// Callers hand this frame to `Compositor::nv12_srvs`, which reads a D3D11
338+
// texture. `get_hw_format`'s software fallback (#1532) has none.
339+
if (*frame.0).format != AVPixelFormat::AV_PIX_FMT_D3D11 as i32 {
340+
bail!(
341+
"decode_frame_n: no D3D11 surface for this stream (format {})",
342+
(*frame.0).format
343+
);
344+
}
337345
result = clone_decoded_frame(frame.0);
338346
if result.is_null() {
339347
bail!("av_frame_clone");
@@ -3068,6 +3076,27 @@ mod tests {
30683076
);
30693077
}
30703078

3079+
/// #1532: High 10 has no D3D11 surface, so `get_hw_format` decodes it in software.
3080+
/// `decode_frame_n` must refuse that frame rather than hand it to `nv12_srvs`.
3081+
#[test]
3082+
fn decode_frame_n_rejects_a_software_frame() {
3083+
let Some(gpu) = strict_hardware_gpu("decode_frame_n_rejects_a_software_frame") else {
3084+
return;
3085+
};
3086+
let path = std::env::temp_dir().join(format!(
3087+
"openscreen-1532-decode-frame-n-{}.h264",
3088+
std::process::id()
3089+
));
3090+
std::fs::write(&path, H264_HIGH10_64X64).expect("write High 10 stream");
3091+
let error = decode_frame_error(&path, &gpu, 0);
3092+
let _ = std::fs::remove_file(&path);
3093+
assert!(
3094+
format!("{error:#}").contains("no D3D11 surface"),
3095+
"unexpected error: {error:#}"
3096+
);
3097+
println!("CORE_ASSERTIONS_COMPLETED:decode_frame_n_rejects_a_software_frame");
3098+
}
3099+
30713100
#[test]
30723101
fn h264_opens_on_d3d11va() {
30733102
let Some(gpu) = strict_hardware_gpu("h264_opens_on_d3d11va") else {

0 commit comments

Comments
 (0)