The AV1 and hardware refusals report themselves too
Browse files at this commit5dd4f361e4b731e8945a6c4c6641dc266f0b016dParent: 6bc4cc2- fix
- the AV1 and hardware refusals report themselves too
2 changed files +30 -13
crates/engine/src/decode.rsmodified+19 -3
| @@ -1258,6 +1258,7 @@ fn run_span( | |||
| 1258 | &mut render, | 1258 | &mut render, |
| 1259 | abort, | 1259 | abort, |
| 1260 | speed, | 1260 | speed, |
| 1261 | + worker_failure, | ||
| 1261 | ); | 1262 | ); |
| 1262 | // A *reused* session that produced nothing may simply be one this | 1263 | // A *reused* session that produced nothing may simply be one this |
| 1263 | // reseek left where the driver would not follow; a session opened fresh | 1264 | // reseek left where the driver would not follow; a session opened fresh |
| @@ -1270,7 +1271,16 @@ fn run_span( | |||
| 1270 | ); | 1271 | ); |
| 1271 | opened.hw = open_hw(path, start); | 1272 | opened.hw = open_hw(path, start); |
| 1272 | if let Some(hw) = opened.hw.as_mut() { | 1273 | if let Some(hw) = opened.hw.as_mut() { |
| 1273 | - decoded = run_hw(hw, &tx, start, end, &mut render, abort, speed); | 1274 | + decoded = run_hw( |
| 1275 | + hw, | ||
| 1276 | + &tx, | ||
| 1277 | + start, | ||
| 1278 | + end, | ||
| 1279 | + &mut render, | ||
| 1280 | + abort, | ||
| 1281 | + speed, | ||
| 1282 | + worker_failure, | ||
| 1283 | + ); | ||
| 1274 | } | 1284 | } |
| 1275 | } | 1285 | } |
| 1276 | if decoded { | 1286 | if decoded { |
| @@ -2950,6 +2960,7 @@ fn run_hw( | |||
| 2950 | render: &mut Render, | 2960 | render: &mut Render, |
| 2951 | abort: &Abort, | 2961 | abort: &Abort, |
| 2952 | speed: Speed, | 2962 | speed: Speed, |
| 2963 | + failure: &DecodeFailure, | ||
| 2953 | ) -> bool { | 2964 | ) -> bool { |
| 2954 | let mut index = start_frame; | 2965 | let mut index = start_frame; |
| 2955 | // Pictures dropped for being late since the last one handed over; see | 2966 | // Pictures dropped for being late since the last one handed over; see |
| @@ -2989,10 +3000,15 @@ fn run_hw( | |||
| 2989 | } | 3000 | } |
| 2990 | Ok(None) => return true, | 3001 | Ok(None) => return true, |
| 2991 | Err(e) => { | 3002 | Err(e) => { |
| 3003 | + // Before the first picture this is not a failure to report but | ||
| 3004 | + // the signal that software should take over, and it is reported | ||
| 3005 | + // by the caller that does the falling back -- saying it here as | ||
| 3006 | + // well would put a fault on the strip for a span that is about | ||
| 3007 | + // to decode cleanly. | ||
| 2992 | if index == start_frame { | 3008 | if index == start_frame { |
| 2993 | return false; | 3009 | return false; |
| 2994 | } | 3010 | } |
| 2995 | - eprintln!("hardware decode error at frame {index}: {e}"); | 3011 | + failure.set(format!("hardware decode error at frame {index}: {e}")); |
| 2996 | return true; | 3012 | return true; |
| 2997 | } | 3013 | } |
| 2998 | } | 3014 | } |
| @@ -4018,7 +4034,7 @@ fn run_av1( | |||
| 4018 | // the pictures decoded so far stand and the span ends. | 4034 | // the pictures decoded so far stand and the span ends. |
| 4019 | if let Err(e) = decode { | 4035 | if let Err(e) = decode { |
| 4020 | if !done { | 4036 | if !done { |
| 4021 | - eprintln!("software AV1 decode failed at frame {index}: {e}"); | 4037 | + failure.set(format!("software AV1 decode failed at frame {index}: {e}")); |
| 4022 | done = true; | 4038 | done = true; |
| 4023 | } | 4039 | } |
| 4024 | } | 4040 | } |
crates/engine/tests/decode_failure.rsmodified+11 -10
| @@ -43,20 +43,21 @@ fn pin_software() { | |||
| 43 | /// `test_av.mp4` with the last eighth of its **sample data** overwritten, and | 43 | /// `test_av.mp4` with the last eighth of its **sample data** overwritten, and |
| 44 | /// the file otherwise untouched: `moov` still claims every frame the header | 44 | /// the file otherwise untouched: `moov` still claims every frame the header |
| 45 | /// ever did, and the demuxer hands the decoder exactly what it always handed | 45 | /// ever did, and the demuxer hands the decoder exactly what it always handed |
| 46 | -/// it. The damage is bounded to the `mdat` payload on purpose -- `moov` sits | 46 | +/// it. |
| 47 | -/// after `mdat` in this fixture, so a damage that ran to the end of the file | 47 | +/// |
| 48 | -/// would take the index with it and produce an unopenable file rather than a | 48 | +/// The damage is bounded to the `mdat` payload on purpose. `moov` sits *after* |
| 49 | -/// decodable one with a bad tail, which is a different defect. | 49 | +/// `mdat` in this fixture, so a damage that ran to the end of the file would |
| 50 | +/// take the index with it and leave a file that will not open at all -- a | ||
| 51 | +/// different defect, reached before a single frame is decoded and invisible to | ||
| 52 | +/// the thing this test is about. | ||
| 50 | /// | 53 | /// |
| 51 | /// Returns the scratch guard too, so the directory goes when the test ends. | 54 | /// Returns the scratch guard too, so the directory goes when the test ends. |
| 52 | fn damaged() -> (Scratch, PathBuf) { | 55 | fn damaged() -> (Scratch, PathBuf) { |
| 53 | let bytes = std::fs::read(asset("test_av.mp4")).expect("the fixture"); | 56 | let bytes = std::fs::read(asset("test_av.mp4")).expect("the fixture"); |
| 54 | - let (data_start, data_end) = mdat_payload(&bytes).expect("an mdat"); | 57 | + let (start, end) = mdat_payload(&bytes).expect("an mdat payload"); |
| 55 | - let mut damaged_bytes = bytes.clone(); | 58 | + let mut damaged_bytes = bytes; |
| 56 | - // What a transfer that dies part-way leaves behind, over the last eighth of | 59 | + let tail = start + (end - start) * 7 / 8; |
| 57 | - // the samples it did not finish writing. | 60 | + damaged_bytes[tail..end].fill(0); |
| 58 | - let tail = data_start + (data_end - data_start) * 7 / 8; | ||
| 59 | - damaged_bytes[tail..data_end].fill(0); | ||
| 60 | let scratch = Scratch::file("ve_decode_failure", "mp4"); | 61 | let scratch = Scratch::file("ve_decode_failure", "mp4"); |
| 61 | let path = PathBuf::from(&*scratch); | 62 | let path = PathBuf::from(&*scratch); |
| 62 | std::fs::write(&path, &damaged_bytes).expect("write the damaged fixture"); | 63 | std::fs::write(&path, &damaged_bytes).expect("write the damaged fixture"); |