diff --git a/crates/engine/src/decode.rs b/crates/engine/src/decode.rs index c6602fe..b11fb61 100644 --- a/crates/engine/src/decode.rs +++ b/crates/engine/src/decode.rs @@ -1258,6 +1258,7 @@ fn run_span( &mut render, abort, speed, + worker_failure, ); // A *reused* session that produced nothing may simply be one this // reseek left where the driver would not follow; a session opened fresh @@ -1270,7 +1271,16 @@ fn run_span( ); opened.hw = open_hw(path, start); if let Some(hw) = opened.hw.as_mut() { - decoded = run_hw(hw, &tx, start, end, &mut render, abort, speed); + decoded = run_hw( + hw, + &tx, + start, + end, + &mut render, + abort, + speed, + worker_failure, + ); } } if decoded { @@ -2950,6 +2960,7 @@ fn run_hw( render: &mut Render, abort: &Abort, speed: Speed, + failure: &DecodeFailure, ) -> bool { let mut index = start_frame; // Pictures dropped for being late since the last one handed over; see @@ -2989,10 +3000,15 @@ fn run_hw( } Ok(None) => return true, Err(e) => { + // Before the first picture this is not a failure to report but + // the signal that software should take over, and it is reported + // by the caller that does the falling back -- saying it here as + // well would put a fault on the strip for a span that is about + // to decode cleanly. if index == start_frame { return false; } - eprintln!("hardware decode error at frame {index}: {e}"); + failure.set(format!("hardware decode error at frame {index}: {e}")); return true; } } @@ -4018,7 +4034,7 @@ fn run_av1( // the pictures decoded so far stand and the span ends. if let Err(e) = decode { if !done { - eprintln!("software AV1 decode failed at frame {index}: {e}"); + failure.set(format!("software AV1 decode failed at frame {index}: {e}")); done = true; } } diff --git a/crates/engine/tests/decode_failure.rs b/crates/engine/tests/decode_failure.rs index 2fb01ae..20ebd56 100644 --- a/crates/engine/tests/decode_failure.rs +++ b/crates/engine/tests/decode_failure.rs @@ -43,20 +43,21 @@ fn pin_software() { /// `test_av.mp4` with the last eighth of its **sample data** overwritten, and /// the file otherwise untouched: `moov` still claims every frame the header /// ever did, and the demuxer hands the decoder exactly what it always handed -/// it. The damage is bounded to the `mdat` payload on purpose -- `moov` sits -/// after `mdat` in this fixture, so a damage that ran to the end of the file -/// would take the index with it and produce an unopenable file rather than a -/// decodable one with a bad tail, which is a different defect. +/// it. +/// +/// The damage is bounded to the `mdat` payload on purpose. `moov` sits *after* +/// `mdat` in this fixture, so a damage that ran to the end of the file would +/// take the index with it and leave a file that will not open at all -- a +/// different defect, reached before a single frame is decoded and invisible to +/// the thing this test is about. /// /// Returns the scratch guard too, so the directory goes when the test ends. fn damaged() -> (Scratch, PathBuf) { let bytes = std::fs::read(asset("test_av.mp4")).expect("the fixture"); - let (data_start, data_end) = mdat_payload(&bytes).expect("an mdat"); - let mut damaged_bytes = bytes.clone(); - // What a transfer that dies part-way leaves behind, over the last eighth of - // the samples it did not finish writing. - let tail = data_start + (data_end - data_start) * 7 / 8; - damaged_bytes[tail..data_end].fill(0); + let (start, end) = mdat_payload(&bytes).expect("an mdat payload"); + let mut damaged_bytes = bytes; + let tail = start + (end - start) * 7 / 8; + damaged_bytes[tail..end].fill(0); let scratch = Scratch::file("ve_decode_failure", "mp4"); let path = PathBuf::from(&*scratch); std::fs::write(&path, &damaged_bytes).expect("write the damaged fixture");