forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'simplify/u15' into simplify/w1b

Browse files at this commit

756d8d69f4e3e7c910b39aede5d1b918b81e1661Ahmet Kaan GümüşParent: 2eb48e52d30662
crates/ec-dnxhd/src/tables.rsmodified+1 -5
@@ -2,17 +2,13 @@
22
33 pub(crate) const FLAG_INTERLACED: u16 = 1;
44 pub(crate) const FLAG_MBAFF: u16 = 2;
5-#[allow(dead_code)]
6-pub(crate) const FLAG_444: u16 = 4;
75
86 /// One compression id (CID): frame geometry and the code tables it uses.
9-/// `width`, `height` and `coding_unit_size` are 0 for the DNxHR ids (variable);
7+/// `width` and `coding_unit_size` are 0 for the DNxHR ids (variable);
108 /// `bit_depth` is 0 when the frame header states it.
119 pub(crate) struct CidEntry {
1210 pub cid: u32,
1311 pub width: u32,
14- #[allow(dead_code)]
15- pub height: u32,
1612 pub coding_unit_size: u32,
1713 pub flags: u16,
1814 pub bit_depth: u32,
crates/ec-dnxhd/src/tables_gen.rsmodified+20 -20
@@ -632,64 +632,64 @@ static T_1250_RUN: [u8; 62] = [
632632 ];
633633
634634 pub(crate) static CID_TABLE: [CidEntry; 20] = [
635- CidEntry { cid: 1235, width: 1920, height: 1080, coding_unit_size: 917504, flags: 0, bit_depth: 10, eob_index: 4,
635+ CidEntry { cid: 1235, width: 1920, coding_unit_size: 917504, flags: 0, bit_depth: 10, eob_index: 4,
636636 luma_weight: &T_1235_LUMA_WEIGHT, chroma_weight: &T_1235_CHROMA_WEIGHT, dc_codes: &T_1235_DC_CODES, dc_bits: &T_1235_DC_BITS,
637637 ac_codes: &T_1235_AC_CODES, ac_bits: &T_1235_AC_BITS, ac_info: &T_1235_AC_INFO, run_codes: &T_1235_RUN_CODES, run_bits: &T_1235_RUN_BITS, run: &T_1235_RUN },
638- CidEntry { cid: 1237, width: 1920, height: 1080, coding_unit_size: 606208, flags: 0, bit_depth: 8, eob_index: 3,
638+ CidEntry { cid: 1237, width: 1920, coding_unit_size: 606208, flags: 0, bit_depth: 8, eob_index: 3,
639639 luma_weight: &T_1237_LUMA_WEIGHT, chroma_weight: &T_1237_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
640640 ac_codes: &T_1237_AC_CODES, ac_bits: &T_1237_AC_BITS, ac_info: &T_1237_AC_INFO, run_codes: &T_1237_RUN_CODES, run_bits: &T_1237_RUN_BITS, run: &T_1237_RUN },
641- CidEntry { cid: 1238, width: 1920, height: 1080, coding_unit_size: 917504, flags: 0, bit_depth: 8, eob_index: 4,
641+ CidEntry { cid: 1238, width: 1920, coding_unit_size: 917504, flags: 0, bit_depth: 8, eob_index: 4,
642642 luma_weight: &T_1238_LUMA_WEIGHT, chroma_weight: &T_1238_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
643643 ac_codes: &T_1238_AC_CODES, ac_bits: &T_1238_AC_BITS, ac_info: &T_1238_AC_INFO, run_codes: &T_1235_RUN_CODES, run_bits: &T_1235_RUN_BITS, run: &T_1238_RUN },
644- CidEntry { cid: 1241, width: 1920, height: 1080, coding_unit_size: 458752, flags: FLAG_INTERLACED, bit_depth: 10, eob_index: 4,
644+ CidEntry { cid: 1241, width: 1920, coding_unit_size: 458752, flags: FLAG_INTERLACED, bit_depth: 10, eob_index: 4,
645645 luma_weight: &T_1241_LUMA_WEIGHT, chroma_weight: &T_1241_CHROMA_WEIGHT, dc_codes: &T_1235_DC_CODES, dc_bits: &T_1235_DC_BITS,
646646 ac_codes: &T_1235_AC_CODES, ac_bits: &T_1235_AC_BITS, ac_info: &T_1235_AC_INFO, run_codes: &T_1235_RUN_CODES, run_bits: &T_1235_RUN_BITS, run: &T_1235_RUN },
647- CidEntry { cid: 1242, width: 1920, height: 1080, coding_unit_size: 303104, flags: FLAG_INTERLACED, bit_depth: 8, eob_index: 3,
647+ CidEntry { cid: 1242, width: 1920, coding_unit_size: 303104, flags: FLAG_INTERLACED, bit_depth: 8, eob_index: 3,
648648 luma_weight: &T_1242_LUMA_WEIGHT, chroma_weight: &T_1242_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
649649 ac_codes: &T_1237_AC_CODES, ac_bits: &T_1237_AC_BITS, ac_info: &T_1237_AC_INFO, run_codes: &T_1237_RUN_CODES, run_bits: &T_1237_RUN_BITS, run: &T_1237_RUN },
650- CidEntry { cid: 1243, width: 1920, height: 1080, coding_unit_size: 458752, flags: FLAG_INTERLACED, bit_depth: 8, eob_index: 4,
650+ CidEntry { cid: 1243, width: 1920, coding_unit_size: 458752, flags: FLAG_INTERLACED, bit_depth: 8, eob_index: 4,
651651 luma_weight: &T_1243_LUMA_WEIGHT, chroma_weight: &T_1243_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
652652 ac_codes: &T_1238_AC_CODES, ac_bits: &T_1238_AC_BITS, ac_info: &T_1238_AC_INFO, run_codes: &T_1235_RUN_CODES, run_bits: &T_1235_RUN_BITS, run: &T_1238_RUN },
653- CidEntry { cid: 1244, width: 1440, height: 1080, coding_unit_size: 303104, flags: FLAG_INTERLACED, bit_depth: 8, eob_index: 3,
653+ CidEntry { cid: 1244, width: 1440, coding_unit_size: 303104, flags: FLAG_INTERLACED, bit_depth: 8, eob_index: 3,
654654 luma_weight: &T_1260_LUMA_WEIGHT, chroma_weight: &T_1260_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
655655 ac_codes: &T_1237_AC_CODES, ac_bits: &T_1237_AC_BITS, ac_info: &T_1237_AC_INFO, run_codes: &T_1237_RUN_CODES, run_bits: &T_1237_RUN_BITS, run: &T_1237_RUN },
656- CidEntry { cid: 1250, width: 1280, height: 720, coding_unit_size: 458752, flags: 0, bit_depth: 10, eob_index: 4,
656+ CidEntry { cid: 1250, width: 1280, coding_unit_size: 458752, flags: 0, bit_depth: 10, eob_index: 4,
657657 luma_weight: &T_1250_LUMA_WEIGHT, chroma_weight: &T_1250_CHROMA_WEIGHT, dc_codes: &T_1235_DC_CODES, dc_bits: &T_1235_DC_BITS,
658658 ac_codes: &T_1250_AC_CODES, ac_bits: &T_1250_AC_BITS, ac_info: &T_1250_AC_INFO, run_codes: &T_1250_RUN_CODES, run_bits: &T_1250_RUN_BITS, run: &T_1250_RUN },
659- CidEntry { cid: 1251, width: 1280, height: 720, coding_unit_size: 458752, flags: 0, bit_depth: 8, eob_index: 4,
659+ CidEntry { cid: 1251, width: 1280, coding_unit_size: 458752, flags: 0, bit_depth: 8, eob_index: 4,
660660 luma_weight: &T_1251_LUMA_WEIGHT, chroma_weight: &T_1251_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
661661 ac_codes: &T_1251_AC_CODES, ac_bits: &T_1251_AC_BITS, ac_info: &T_1251_AC_INFO, run_codes: &T_1250_RUN_CODES, run_bits: &T_1250_RUN_BITS, run: &T_1250_RUN },
662- CidEntry { cid: 1252, width: 1280, height: 720, coding_unit_size: 303104, flags: 0, bit_depth: 8, eob_index: 5,
662+ CidEntry { cid: 1252, width: 1280, coding_unit_size: 303104, flags: 0, bit_depth: 8, eob_index: 5,
663663 luma_weight: &T_1252_LUMA_WEIGHT, chroma_weight: &T_1252_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
664664 ac_codes: &T_1252_AC_CODES, ac_bits: &T_1252_AC_BITS, ac_info: &T_1252_AC_INFO, run_codes: &T_1250_RUN_CODES, run_bits: &T_1250_RUN_BITS, run: &T_1250_RUN },
665- CidEntry { cid: 1253, width: 1920, height: 1080, coding_unit_size: 188416, flags: 0, bit_depth: 8, eob_index: 3,
665+ CidEntry { cid: 1253, width: 1920, coding_unit_size: 188416, flags: 0, bit_depth: 8, eob_index: 3,
666666 luma_weight: &T_1237_LUMA_WEIGHT, chroma_weight: &T_1237_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
667667 ac_codes: &T_1237_AC_CODES, ac_bits: &T_1237_AC_BITS, ac_info: &T_1237_AC_INFO, run_codes: &T_1237_RUN_CODES, run_bits: &T_1237_RUN_BITS, run: &T_1237_RUN },
668- CidEntry { cid: 1256, width: 1920, height: 1080, coding_unit_size: 1835008, flags: FLAG_444, bit_depth: 10, eob_index: 4,
668+ CidEntry { cid: 1256, width: 1920, coding_unit_size: 1835008, flags: 0, bit_depth: 10, eob_index: 4,
669669 luma_weight: &T_1235_LUMA_WEIGHT, chroma_weight: &T_1235_LUMA_WEIGHT, dc_codes: &T_1235_DC_CODES, dc_bits: &T_1235_DC_BITS,
670670 ac_codes: &T_1235_AC_CODES, ac_bits: &T_1235_AC_BITS, ac_info: &T_1235_AC_INFO, run_codes: &T_1235_RUN_CODES, run_bits: &T_1235_RUN_BITS, run: &T_1235_RUN },
671- CidEntry { cid: 1258, width: 960, height: 720, coding_unit_size: 212992, flags: 0, bit_depth: 8, eob_index: 5,
671+ CidEntry { cid: 1258, width: 960, coding_unit_size: 212992, flags: 0, bit_depth: 8, eob_index: 5,
672672 luma_weight: &T_1252_LUMA_WEIGHT, chroma_weight: &T_1252_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
673673 ac_codes: &T_1252_AC_CODES, ac_bits: &T_1252_AC_BITS, ac_info: &T_1252_AC_INFO, run_codes: &T_1250_RUN_CODES, run_bits: &T_1250_RUN_BITS, run: &T_1250_RUN },
674- CidEntry { cid: 1259, width: 1440, height: 1080, coding_unit_size: 417792, flags: 0, bit_depth: 8, eob_index: 3,
674+ CidEntry { cid: 1259, width: 1440, coding_unit_size: 417792, flags: 0, bit_depth: 8, eob_index: 3,
675675 luma_weight: &T_1237_LUMA_WEIGHT, chroma_weight: &T_1237_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
676676 ac_codes: &T_1237_AC_CODES, ac_bits: &T_1237_AC_BITS, ac_info: &T_1237_AC_INFO, run_codes: &T_1237_RUN_CODES, run_bits: &T_1237_RUN_BITS, run: &T_1237_RUN },
677- CidEntry { cid: 1260, width: 1440, height: 1080, coding_unit_size: 417792, flags: FLAG_INTERLACED | FLAG_MBAFF, bit_depth: 8, eob_index: 3,
677+ CidEntry { cid: 1260, width: 1440, coding_unit_size: 417792, flags: FLAG_INTERLACED | FLAG_MBAFF, bit_depth: 8, eob_index: 3,
678678 luma_weight: &T_1260_LUMA_WEIGHT, chroma_weight: &T_1260_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
679679 ac_codes: &T_1237_AC_CODES, ac_bits: &T_1237_AC_BITS, ac_info: &T_1237_AC_INFO, run_codes: &T_1237_RUN_CODES, run_bits: &T_1237_RUN_BITS, run: &T_1237_RUN },
680- CidEntry { cid: 1270, width: 0, height: 0, coding_unit_size: 0, flags: FLAG_444, bit_depth: 0, eob_index: 4,
680+ CidEntry { cid: 1270, width: 0, coding_unit_size: 0, flags: 0, bit_depth: 0, eob_index: 4,
681681 luma_weight: &T_1235_LUMA_WEIGHT, chroma_weight: &T_1235_LUMA_WEIGHT, dc_codes: &T_1235_DC_CODES, dc_bits: &T_1235_DC_BITS,
682682 ac_codes: &T_1235_AC_CODES, ac_bits: &T_1235_AC_BITS, ac_info: &T_1235_AC_INFO, run_codes: &T_1235_RUN_CODES, run_bits: &T_1235_RUN_BITS, run: &T_1235_RUN },
683- CidEntry { cid: 1271, width: 0, height: 0, coding_unit_size: 0, flags: 0, bit_depth: 0, eob_index: 4,
683+ CidEntry { cid: 1271, width: 0, coding_unit_size: 0, flags: 0, bit_depth: 0, eob_index: 4,
684684 luma_weight: &T_1241_LUMA_WEIGHT, chroma_weight: &T_1241_CHROMA_WEIGHT, dc_codes: &T_1235_DC_CODES, dc_bits: &T_1235_DC_BITS,
685685 ac_codes: &T_1235_AC_CODES, ac_bits: &T_1235_AC_BITS, ac_info: &T_1235_AC_INFO, run_codes: &T_1235_RUN_CODES, run_bits: &T_1235_RUN_BITS, run: &T_1235_RUN },
686- CidEntry { cid: 1272, width: 0, height: 0, coding_unit_size: 0, flags: 0, bit_depth: 8, eob_index: 4,
686+ CidEntry { cid: 1272, width: 0, coding_unit_size: 0, flags: 0, bit_depth: 8, eob_index: 4,
687687 luma_weight: &T_1238_LUMA_WEIGHT, chroma_weight: &T_1238_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
688688 ac_codes: &T_1238_AC_CODES, ac_bits: &T_1238_AC_BITS, ac_info: &T_1238_AC_INFO, run_codes: &T_1235_RUN_CODES, run_bits: &T_1235_RUN_BITS, run: &T_1238_RUN },
689- CidEntry { cid: 1273, width: 0, height: 0, coding_unit_size: 0, flags: 0, bit_depth: 8, eob_index: 3,
689+ CidEntry { cid: 1273, width: 0, coding_unit_size: 0, flags: 0, bit_depth: 8, eob_index: 3,
690690 luma_weight: &T_1237_LUMA_WEIGHT, chroma_weight: &T_1237_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
691691 ac_codes: &T_1237_AC_CODES, ac_bits: &T_1237_AC_BITS, ac_info: &T_1237_AC_INFO, run_codes: &T_1237_RUN_CODES, run_bits: &T_1237_RUN_BITS, run: &T_1237_RUN },
692- CidEntry { cid: 1274, width: 0, height: 0, coding_unit_size: 0, flags: 0, bit_depth: 8, eob_index: 3,
692+ CidEntry { cid: 1274, width: 0, coding_unit_size: 0, flags: 0, bit_depth: 8, eob_index: 3,
693693 luma_weight: &T_1237_LUMA_WEIGHT, chroma_weight: &T_1237_CHROMA_WEIGHT, dc_codes: &T_1237_DC_CODES, dc_bits: &T_1237_DC_BITS,
694694 ac_codes: &T_1237_AC_CODES, ac_bits: &T_1237_AC_BITS, ac_info: &T_1237_AC_INFO, run_codes: &T_1237_RUN_CODES, run_bits: &T_1237_RUN_BITS, run: &T_1237_RUN },
695695 ];
crates/ec-dnxhd/tests/ffmpeg_parity.rsmodified+124 -0
@@ -7,6 +7,7 @@ mod common;
77 use common::*;
88 use ec_dnxhd::{Chroma, DnxhdDecoder, Picture};
99 use ec_core::registry::{CodecId, CodecParameters};
10+use ec_core::error::Error;
1011
1112 struct Case {
1213 tag: &'static str,
@@ -384,3 +385,126 @@ fn matroska_carries_dnxhd_too() {
384385 assert_eq!(avi_frames(&avi), mov_frames(&mov));
385386 let _ = std::fs::remove_dir_all(&dir);
386387 }
388+
389+fn decoder() -> DnxhdDecoder {
390+ DnxhdDecoder::new(CodecParameters::new(CodecId::Dnxhd)).unwrap()
391+}
392+
393+fn encode_one(tag: &str, pix: &str, enc: &[&str]) -> Vec<u8> {
394+ let dir = scratch(tag);
395+ let out = dir.join("a.mov");
396+ let lavfi = format!("testsrc2=size=320x176:rate=25,format={pix}");
397+ let mut args = vec!["-f", "lavfi", "-i", &lavfi, "-frames:v", "1", "-c:v", "dnxhd"];
398+ args.extend_from_slice(enc);
399+ args.push(out.to_str().unwrap());
400+ assert!(ffmpeg(&args));
401+ let f = mov_frames(&out).remove(0);
402+ let _ = std::fs::remove_dir_all(&dir);
403+ f
404+}
405+
406+fn refused(r: Result<ec_core::frame::VideoFrame, Error>, what: &str) {
407+ match r {
408+ Err(Error::Unsupported { what: w, .. }) => {
409+ assert!(w.contains(what), "refusal names {w:?}, wanted {what:?}")
410+ }
411+ other => panic!("expected an Unsupported({what}), got {:?}", other.map(|f| f.format)),
412+ }
413+}
414+
415+#[test]
416+fn alpha_rgb_and_act_variants_are_refused_by_name() {
417+ let sq = encode_one("ref-sq", "yuv422p", &["-profile:v", "dnxhr_sq"]);
418+ assert!(decoder().decode_bytes(&sq).is_ok());
419+
420+ let mut alpha = sq.clone();
421+ alpha[7] |= 1;
422+ refused(decoder().decode_bytes(&alpha), "alpha");
423+
424+ let mut act = sq.clone();
425+ act[0x2c] |= 1;
426+ refused(decoder().decode_bytes(&act), "adaptive colour transform");
427+
428+ // GBR (RGB) 4:4:4: ffmpeg writes it with the ACT flag clear.
429+ let rgb = encode_one("ref-rgb", "gbrp10le", &["-profile:v", "dnxhr_444"]);
430+ refused(decoder().decode_bytes(&rgb), "RGB");
431+ // The same encoder's YCbCr 4:4:4 is accepted.
432+ let yuv = encode_one("ref-444", "yuv444p10le", &["-profile:v", "dnxhr_444"]);
433+ assert!(decoder().decode_bytes(&yuv).is_ok());
434+}
435+
436+#[test]
437+fn unknown_cids_and_bad_headers_are_errors() {
438+ let sq = encode_one("ref-bad", "yuv422p", &["-profile:v", "dnxhr_sq"]);
439+ let mut bad = sq.clone();
440+ bad[0x28..0x2c].copy_from_slice(&1239u32.to_be_bytes());
441+ assert!(matches!(decoder().decode_bytes(&bad), Err(Error::Unsupported { .. })));
442+ let mut bad = sq.clone();
443+ bad[2] = 0x55;
444+ assert!(decoder().decode_bytes(&bad).is_err());
445+ assert!(decoder().decode_bytes(&sq[..100]).is_err());
446+ assert!(decoder().decode_bytes(&[]).is_err());
447+ // Depth indicator that contradicts the CID.
448+ let mut bad = sq.clone();
449+ bad[0x28..0x2c].copy_from_slice(&1235u32.to_be_bytes());
450+ assert!(decoder().decode_bytes(&bad).is_err());
451+}
452+
453+#[test]
454+fn damaged_frames_never_panic() {
455+ let hq = encode_one("ref-dmg", "yuv422p10le", &["-profile:v", "dnxhr_hqx"]);
456+ let mut dec = decoder();
457+ let mut s = 0x9E37_79B9_7F4A_7C15u64;
458+ let mut next = move || {
459+ s ^= s << 13;
460+ s ^= s >> 7;
461+ s ^= s << 17;
462+ s
463+ };
464+ for round in 0..400 {
465+ let mut f = hq.clone();
466+ match round % 4 {
467+ 0 => {
468+ for _ in 0..1 + next() % 8 {
469+ let i = (next() as usize) % f.len();
470+ f[i] ^= 1 << (next() % 8);
471+ }
472+ }
473+ 1 => {
474+ // Headers only.
475+ for _ in 0..1 + next() % 4 {
476+ let i = (next() as usize) % 0x300.min(f.len());
477+ f[i] = next() as u8;
478+ }
479+ }
480+ 2 => f.truncate((next() as usize) % f.len()),
481+ _ => {
482+ let i = (next() as usize) % f.len();
483+ for b in &mut f[i..] {
484+ *b = next() as u8;
485+ }
486+ }
487+ }
488+ let _ = dec.decode_bytes(&f);
489+ let _ = dec.decode_native(&f);
490+ }
491+ // The decoder is still usable afterwards.
492+ assert!(dec.decode_bytes(&hq).is_ok());
493+}
494+
495+#[test]
496+fn registry_decoder_path_returns_a_frame() {
497+ use ec_core::registry::Decoder;
498+ let hq = encode_one("ref-reg", "yuv422p", &["-profile:v", "dnxhr_hq"]);
499+ let mut d = decoder();
500+ let pkt = ec_core::packet::Packet::new(0, ec_core::timebase::TimeBase::new(1, 25), hq);
501+ d.send_packet(&pkt).unwrap();
502+ let frame = d.receive_frame().unwrap();
503+ assert!(matches!(frame, ec_core::frame::Frame::Video(_)));
504+ assert!(d.receive_frame().unwrap_err().is_need_more());
505+ d.flush().unwrap();
506+ assert!(d.receive_frame().unwrap_err().is_eof());
507+ let params = d.codec_parameters();
508+ assert_eq!(params.video().unwrap().width, 320);
509+ assert!(DnxhdDecoder::new(CodecParameters::new(CodecId::H264)).is_err());
510+}
crates/ec-dnxhd/tests/refusals.rsdeleted+0 -131
@@ -1,131 +0,0 @@
1-#![allow(clippy::too_many_arguments, clippy::needless_range_loop, clippy::len_zero)]
2-//! Streams the decoder refuses by name, and damaged input that must never panic.
3-
4-mod common;
5-use common::*;
6-use ec_core::error::Error;
7-use ec_core::registry::{CodecId, CodecParameters};
8-use ec_dnxhd::DnxhdDecoder;
9-
10-fn decoder() -> DnxhdDecoder {
11- DnxhdDecoder::new(CodecParameters::new(CodecId::Dnxhd)).unwrap()
12-}
13-
14-fn encode_one(tag: &str, pix: &str, enc: &[&str]) -> Vec<u8> {
15- let dir = scratch(tag);
16- let out = dir.join("a.mov");
17- let lavfi = format!("testsrc2=size=320x176:rate=25,format={pix}");
18- let mut args = vec!["-f", "lavfi", "-i", &lavfi, "-frames:v", "1", "-c:v", "dnxhd"];
19- args.extend_from_slice(enc);
20- args.push(out.to_str().unwrap());
21- assert!(ffmpeg(&args));
22- let f = mov_frames(&out).remove(0);
23- let _ = std::fs::remove_dir_all(&dir);
24- f
25-}
26-
27-fn refused(r: Result<ec_core::frame::VideoFrame, Error>, what: &str) {
28- match r {
29- Err(Error::Unsupported { what: w, .. }) => {
30- assert!(w.contains(what), "refusal names {w:?}, wanted {what:?}")
31- }
32- other => panic!("expected an Unsupported({what}), got {:?}", other.map(|f| f.format)),
33- }
34-}
35-
36-#[test]
37-fn alpha_rgb_and_act_variants_are_refused_by_name() {
38- let sq = encode_one("ref-sq", "yuv422p", &["-profile:v", "dnxhr_sq"]);
39- assert!(decoder().decode_bytes(&sq).is_ok());
40-
41- let mut alpha = sq.clone();
42- alpha[7] |= 1;
43- refused(decoder().decode_bytes(&alpha), "alpha");
44-
45- let mut act = sq.clone();
46- act[0x2c] |= 1;
47- refused(decoder().decode_bytes(&act), "adaptive colour transform");
48-
49- // GBR (RGB) 4:4:4: ffmpeg writes it with the ACT flag clear.
50- let rgb = encode_one("ref-rgb", "gbrp10le", &["-profile:v", "dnxhr_444"]);
51- refused(decoder().decode_bytes(&rgb), "RGB");
52- // The same encoder's YCbCr 4:4:4 is accepted.
53- let yuv = encode_one("ref-444", "yuv444p10le", &["-profile:v", "dnxhr_444"]);
54- assert!(decoder().decode_bytes(&yuv).is_ok());
55-}
56-
57-#[test]
58-fn unknown_cids_and_bad_headers_are_errors() {
59- let sq = encode_one("ref-bad", "yuv422p", &["-profile:v", "dnxhr_sq"]);
60- let mut bad = sq.clone();
61- bad[0x28..0x2c].copy_from_slice(&1239u32.to_be_bytes());
62- assert!(matches!(decoder().decode_bytes(&bad), Err(Error::Unsupported { .. })));
63- let mut bad = sq.clone();
64- bad[2] = 0x55;
65- assert!(decoder().decode_bytes(&bad).is_err());
66- assert!(decoder().decode_bytes(&sq[..100]).is_err());
67- assert!(decoder().decode_bytes(&[]).is_err());
68- // Depth indicator that contradicts the CID.
69- let mut bad = sq.clone();
70- bad[0x28..0x2c].copy_from_slice(&1235u32.to_be_bytes());
71- assert!(decoder().decode_bytes(&bad).is_err());
72-}
73-
74-#[test]
75-fn damaged_frames_never_panic() {
76- let hq = encode_one("ref-dmg", "yuv422p10le", &["-profile:v", "dnxhr_hqx"]);
77- let mut dec = decoder();
78- let mut s = 0x9E37_79B9_7F4A_7C15u64;
79- let mut next = move || {
80- s ^= s << 13;
81- s ^= s >> 7;
82- s ^= s << 17;
83- s
84- };
85- for round in 0..400 {
86- let mut f = hq.clone();
87- match round % 4 {
88- 0 => {
89- for _ in 0..1 + next() % 8 {
90- let i = (next() as usize) % f.len();
91- f[i] ^= 1 << (next() % 8);
92- }
93- }
94- 1 => {
95- // Headers only.
96- for _ in 0..1 + next() % 4 {
97- let i = (next() as usize) % 0x300.min(f.len());
98- f[i] = next() as u8;
99- }
100- }
101- 2 => f.truncate((next() as usize) % f.len()),
102- _ => {
103- let i = (next() as usize) % f.len();
104- for b in &mut f[i..] {
105- *b = next() as u8;
106- }
107- }
108- }
109- let _ = dec.decode_bytes(&f);
110- let _ = dec.decode_native(&f);
111- }
112- // The decoder is still usable afterwards.
113- assert!(dec.decode_bytes(&hq).is_ok());
114-}
115-
116-#[test]
117-fn registry_decoder_path_returns_a_frame() {
118- use ec_core::registry::Decoder;
119- let hq = encode_one("ref-reg", "yuv422p", &["-profile:v", "dnxhr_hq"]);
120- let mut d = decoder();
121- let pkt = ec_core::packet::Packet::new(0, ec_core::timebase::TimeBase::new(1, 25), hq);
122- d.send_packet(&pkt).unwrap();
123- let frame = d.receive_frame().unwrap();
124- assert!(matches!(frame, ec_core::frame::Frame::Video(_)));
125- assert!(d.receive_frame().unwrap_err().is_need_more());
126- d.flush().unwrap();
127- assert!(d.receive_frame().unwrap_err().is_eof());
128- let params = d.codec_parameters();
129- assert_eq!(params.video().unwrap().width, 320);
130- assert!(DnxhdDecoder::new(CodecParameters::new(CodecId::H264)).is_err());
131-}
crates/ec-dv/src/lib.rsmodified+7 -7
@@ -6,11 +6,11 @@
66 //! blocks, macroblocks and video segments, so planes are byte-identical to FFmpeg's native
77 //! `yuv411p` / `yuv420p` / `yuv422p` output.
88 //!
9-//! * [`DvVideoDecoder`] / [`DvPicture`] -- frame in, native planes out (4:1:1 stays 4:1:1).
9+//! * [`DvVideoDecoder`] / `DvPicture` -- frame in, native planes out (4:1:1 stays 4:1:1).
1010 //! * [`DvDecoder`] -- the `ec_core` [`Decoder`](ec_core::registry::Decoder). It widens 4:1:1 to
1111 //! `I422` by exact chroma duplication (ec-core has no `I411`); 4:2:0 -> `I420`; 4:2:2 -> `I422`.
1212 //! * [`extract_audio`] -- the PCM in the audio DIF blocks (16-bit linear and 12-bit non-linear,
13-//! both returned as 16-bit linear) as [`DvAudio`]. No audio `CodecId` is involved: audio leaves
13+//! both returned as 16-bit linear) as `DvAudio`. No audio `CodecId` is involved: audio leaves
1414 //! this crate as PCM, and [`DvDemuxer`] publishes it as `PcmS16Le` streams.
1515 //! * [`DvDemuxer`], [`is_dv`] -- raw `.dv` / `.dif` files.
1616 #![forbid(unsafe_code)]
@@ -24,8 +24,8 @@ mod profile;
2424 mod tables;
2525 mod video;
2626
27-pub use audio::{DvAudio, extract_audio};
28-pub use decoder::{DvDecoder, output_format, to_video_frame};
29-pub use demux::{DvDemuxer, dv_probe_score, is_dv};
30-pub use profile::{Chroma, PROFILES, PROFILE_BYTES, Profile, frame_profile};
31-pub use video::{DvPicture, DvVideoDecoder, is_dv_header};
27+pub use audio::extract_audio;
28+pub use decoder::{DvDecoder, output_format};
29+pub use demux::{DvDemuxer, is_dv};
30+pub use profile::{Chroma, PROFILES, Profile, frame_profile};
31+pub use video::DvVideoDecoder;
crates/ec-dv/src/video.rsmodified+1 -6
@@ -6,7 +6,7 @@ use ec_core::error::{Error, Result};
66 use ec_core::frame::Interlace;
77
88 use crate::idct::{idct248_tile, idct_tile};
9-use crate::profile::{Chroma, PROFILE_BYTES, Profile, WorkChunk, frame_profile, work_chunks};
9+use crate::profile::{Chroma, Profile, WorkChunk, frame_profile, work_chunks};
1010 use crate::tables::*;
1111
1212 const DV_VIDEO_CONTROL: u8 = 0x61;
@@ -669,11 +669,6 @@ fn last_row_field_luma(out: &mut Out, plane: usize, off: usize, stride: usize, b
669669 put_block_8x4(&blocks[3][32..], out, plane, off + 24 + stride, s2);
670670 }
671671
672-/// `true` when `buf` starts a plausible DV frame header (DIF header block of a DV file).
673-pub fn is_dv_header(buf: &[u8]) -> bool {
674- buf.len() >= PROFILE_BYTES && (buf[0] == 0x1f) && buf[1] & 0x07 == 0x07 && buf[2] == 0 && (buf[3] & 0x7f) == 0x3f
675-}
676-
677672 #[cfg(test)]
678673 mod tests {
679674 use super::ZIGZAG;
crates/ec-dv/tests/perf.rsdeleted+0 -60
@@ -1,60 +0,0 @@
1-//! Throughput floor: SD >= 300 fps, HD >= 60 fps (release builds only).
2-mod common;
3-
4-use std::time::Instant;
5-
6-use common::*;
7-use ec_dv::DvVideoDecoder;
8-
9-fn fps(f: &Flavour) -> Option<f64> {
10- let path = make(f, "perf", "dv", true, 10)?;
11- let data = std::fs::read(path).unwrap();
12- let fs = ec_dv::frame_profile(None, &data).unwrap().frame_size;
13- let frames: Vec<&[u8]> = data.chunks_exact(fs).collect();
14- let mut d = DvVideoDecoder::new();
15- d.decode(frames[0]).unwrap();
16- let start = Instant::now();
17- let mut n = 0u32;
18- while start.elapsed().as_secs_f64() < 1.0 || n < 20 {
19- for fr in &frames {
20- std::hint::black_box(d.decode(fr).unwrap());
21- n += 1;
22- }
23- }
24- Some(f64::from(n) / start.elapsed().as_secs_f64())
25-}
26-
27-/// A shared machine under load cannot show the floor: the check is skipped (and says so) when the
28-/// 1-minute load average exceeds half the cores, which is how the lane servers look while other
29-/// jobs run. An idle machine enforces the floor.
30-fn machine_is_busy() -> bool {
31- let load = std::fs::read_to_string("/proc/loadavg")
32- .ok()
33- .and_then(|s| s.split_whitespace().next().and_then(|v| v.parse::<f64>().ok()));
34- let cores = std::thread::available_parallelism().map_or(1, |n| n.get()) as f64;
35- load.is_some_and(|l| l > cores * 0.5)
36-}
37-
38-#[test]
39-fn decode_speed() {
40- let mut bad = Vec::new();
41- for f in FLAVOURS {
42- let hd = f.size.starts_with("1440") || f.size.starts_with("1280") || f.size.starts_with("960");
43- let mut r = 0f64;
44- for _ in 0..3 {
45- let Some(x) = fps(f) else { panic!("fixture {}", f.name) };
46- r = r.max(x);
47- if r >= if hd { 60.0 } else { 300.0 } {
48- break;
49- }
50- }
51- eprintln!("{}: {r:.0} fps", f.name);
52- if !cfg!(debug_assertions) && !machine_is_busy() {
53- let floor = if hd { 60.0 } else { 300.0 };
54- if r < floor {
55- bad.push(format!("{}: {r:.0} fps < {floor}", f.name));
56- }
57- }
58- }
59- assert!(bad.is_empty(), "{bad:?}");
60-}
crates/ec-dv/tests/robust.rsdeleted+0 -91
@@ -1,91 +0,0 @@
1-//! Damaged and hostile input: nothing may panic, and decoding is deterministic.
2-use ec_dv::{DvVideoDecoder, PROFILES, extract_audio};
3-
4-struct Rng(u64);
5-impl Rng {
6- fn next(&mut self) -> u64 {
7- self.0 = self.0.wrapping_mul(6364136223846793005).wrapping_add(1442695040888963407);
8- self.0 >> 33
9- }
10-}
11-
12-fn frame_for(p: &ec_dv::Profile, rng: &mut Rng, header_bytes: bool) -> Vec<u8> {
13- let mut f: Vec<u8> = (0..p.frame_size).map(|_| rng.next() as u8).collect();
14- if header_bytes {
15- f[3] = (f[3] & 0x7f) | (p.dsf << 7);
16- f[80 * 5 + 48 + 3] = p.video_stype;
17- f[4] &= 0xf8;
18- for b in 0..p.frame_size / 80 {
19- // plausible DIF headers keep the segment status nibbles equal, as real streams do
20- f[b * 80 + 3] = (f[b * 80 + 3] & 0x0f) | 0xf0;
21- }
22- f[3] = (f[3] & 0x7f) | (p.dsf << 7);
23- f[80 * 5 + 48 + 3] = p.video_stype;
24- }
25- f
26-}
27-
28-#[test]
29-fn random_frames_of_every_profile_do_not_panic() {
30- let mut rng = Rng(7);
31- for (i, p) in PROFILES.iter().enumerate() {
32- if i == 2 || i == 9 {
33- continue; // PAL 4:1:1 / IEC 61883-5 share their header bytes with other entries
34- }
35- for round in 0..6 {
36- let f = frame_for(p, &mut rng, round % 2 == 0);
37- let mut d = DvVideoDecoder::new();
38- if round % 2 == 1 {
39- let _ = d.decode(&f); // random header: an error is fine, a panic is not
40- let _ = extract_audio(&f);
41- continue;
42- }
43- let a = d.decode(&f).unwrap_or_else(|e| panic!("profile {i} round {round}: {e:?}"));
44- let b = DvVideoDecoder::new().decode(&f).unwrap();
45- assert_eq!(a.planes, b.planes, "decode must be deterministic");
46- assert_eq!((a.width, a.height), (p.width, p.height));
47- let _ = extract_audio(&f);
48- }
49- }
50-}
51-
52-#[test]
53-fn bit_flips_and_truncations_do_not_panic() {
54- let mut rng = Rng(99);
55- let p = &PROFILES[0];
56- let base = frame_for(p, &mut rng, true);
57- let mut d = DvVideoDecoder::new();
58- for n in 0..200 {
59- let mut f = base.clone();
60- for _ in 0..(1 + n % 20) {
61- let at = rng.next() as usize % f.len();
62- f[at] ^= 1 << (rng.next() % 8);
63- }
64- let _ = d.decode(&f);
65- let cut = rng.next() as usize % f.len();
66- let _ = d.decode(&f[..cut]);
67- let _ = extract_audio(&f[..cut]);
68- let _ = extract_audio(&f);
69- }
70-}
71-
72-#[test]
73-fn all_headers_with_hostile_audio_packs() {
74- let mut rng = Rng(5);
75- for p in PROFILES.iter() {
76- for _ in 0..20 {
77- let mut f = frame_for(p, &mut rng, true);
78- for c in 0..10usize {
79- let offs = if c & 1 == 1 { 80 * 6 + 3 + c * 12000 } else { 80 * 6 + 80 * 16 * 3 + 3 + c * 12000 };
80- if offs + 5 < f.len() {
81- f[offs] = 0x50;
82- f[offs + 1] = rng.next() as u8;
83- f[offs + 3] = rng.next() as u8;
84- f[offs + 4] = rng.next() as u8;
85- }
86- }
87- let _ = extract_audio(&f);
88- let _ = DvVideoDecoder::new().decode(&f);
89- }
90- }
91-}
crates/ec-prores/src/idct.rsmodified+17 -23
@@ -13,8 +13,6 @@ use wide::{i16x8, i32x4, i32x8};
1313
1414 /// Scalar implementation in raster layout, a line-for-line port of ffmpeg's.
1515 pub mod reference {
16- #![allow(dead_code)]
17-
1816 pub struct K {
1917 /// `a` (even part) coefficient rows for r2, r4, r6.
2018 pub a2: [i32; 4],
@@ -119,6 +117,20 @@ pub mod reference {
119117 out
120118 }
121119
120+ pub fn put_dc<const B12: bool>(dst: &mut [u8], stride: usize, dc: i16) {
121+ let k = if B12 { &K12 } else { &K10 };
122+ let (lo, hi): (i16, i16) = if B12 { (4, 4091) } else { (4, 1019) };
123+ let t = (i32::from(dc).wrapping_add(1) >> 1) as i16;
124+ let c0 = t.wrapping_add(8192) as i32;
125+ let bias = (1i32 << (k.col_shift - 1)) / k.w4;
126+ let v = ((k.w4.wrapping_mul(c0.wrapping_add(bias)) >> k.col_shift) as i16).clamp(lo, hi) as u16;
127+ for r in 0..8 {
128+ for c in dst[r * stride * 2..r * stride * 2 + 16].as_chunks_mut::<2>().0.iter_mut() {
129+ *c = v.to_le_bytes();
130+ }
131+ }
132+ }
133+
122134 /// Run the IDCT on an already dequantised `block` and store the clipped 8x8 result at
123135 /// `dst[0]`, row pitch `stride`. With `dc_only` only `block[0]` is read (the block's other
124136 /// coefficients are zero), which is exact: the shortcut rows and columns of the full
@@ -128,15 +140,7 @@ pub mod reference {
128140 let k = if B12 { &K12 } else { &K10 };
129141 let (lo, hi): (i16, i16) = if B12 { (4, 4091) } else { (4, 1019) };
130142 if dc_only {
131- let t = (i32::from(block[0]).wrapping_add(1) >> 1) as i16;
132- let c0 = t.wrapping_add(8192) as i32;
133- let bias = (1i32 << (k.col_shift - 1)) / k.w4;
134- let v = ((k.w4.wrapping_mul(c0.wrapping_add(bias)) >> k.col_shift) as i16).clamp(lo, hi) as u16;
135- for r in 0..8 {
136- for c in dst[r * stride * 2..r * stride * 2 + 16].as_chunks_mut::<2>().0.iter_mut() {
137- *c = v.to_le_bytes();
138- }
139- }
143+ put_dc::<B12>(dst, stride, block[0]);
140144 return;
141145 }
142146 for r in 0..8 {
@@ -153,7 +157,7 @@ pub mod reference {
153157 }
154158 }
155159
156-use reference::{K10, K12};
160+use reference::K10;
157161 use archmage::{SimdToken, X64V1Token};
158162 use reference::K;
159163
@@ -369,18 +373,8 @@ fn idct_put_10(dst: &mut [u8], stride: usize, block: &[i16; 64]) {
369373 #[inline(always)]
370374 pub fn idct_put<const B12: bool>(dst: &mut [u8], stride: usize, block: &mut [i16; 64]) {
371375 let dc_only = block[1..].iter().fold(0, |a, &x| a | x) == 0;
372- let k = if B12 { &K12 } else { &K10 };
373- let (lo, hi): (i16, i16) = if B12 { (4, 4091) } else { (4, 1019) };
374376 if dc_only {
375- let t = (i32::from(block[0]).wrapping_add(1) >> 1) as i16;
376- let c0 = t.wrapping_add(8192) as i32;
377- let bias = (1i32 << (k.col_shift - 1)) / k.w4;
378- let v = ((k.w4.wrapping_mul(c0.wrapping_add(bias)) >> k.col_shift) as i16).clamp(lo, hi) as u16;
379- for r in 0..8 {
380- for c in dst[r * stride * 2..r * stride * 2 + 16].as_chunks_mut::<2>().0.iter_mut() {
381- *c = v.to_le_bytes();
382- }
383- }
377+ reference::put_dc::<B12>(dst, stride, block[0]);
384378 return;
385379 }
386380 if B12 {
crates/ec-prores/tests/perf.rsdeleted+0 -43
@@ -1,43 +0,0 @@
1-//! Throughput of 1080p 4:2:2 HQ (ffmpeg-encoded, light noise so the entropy coder has work).
2-//! Prints fps for 1 and 4 threads; set `EC_PRORES_MIN_FPS` to assert the single-thread rate.
3-
4-mod common;
5-use common::*;
6-
7-#[test]
8-fn hd_hq_throughput() {
9- let dir = scratch("perf");
10- let mov = dir.join("hd.mov");
11- assert!(run(&[
12- "-f", "lavfi", "-i", "testsrc2=size=1920x1080:rate=25,noise=alls=12:allf=t",
13- "-frames:v", "24", "-c:v", "prores_ks", "-profile", "3", "-pix_fmt", "yuv422p10le",
14- mov.to_str().unwrap(),
15- ]));
16- let bytes = std::fs::read(&mov).unwrap();
17- let pk = packets(&bytes);
18- let mut single = 0.0;
19- for threads in [1usize, 4] {
20- let mut dec = decoder(threads);
21- // Warm up, then best of 10 passes.
22- for p in &pk {
23- dec.decode(p).unwrap();
24- }
25- let mut best = f64::MAX;
26- for _ in 0..10 {
27- let t0 = std::time::Instant::now();
28- for p in &pk {
29- std::hint::black_box(dec.decode(p).unwrap());
30- }
31- best = best.min(t0.elapsed().as_secs_f64());
32- }
33- let fps = pk.len() as f64 / best;
34- eprintln!("1080p 422 HQ, {} bytes/frame, {threads} thread(s): {fps:.1} fps", bytes.len() / pk.len());
35- if threads == 1 {
36- single = fps;
37- }
38- }
39- if let Some(min) = std::env::var("EC_PRORES_MIN_FPS").ok().and_then(|v| v.parse::<f64>().ok()) {
40- assert!(single >= min, "single-thread {single:.1} fps below {min}");
41- }
42- let _ = std::fs::remove_dir_all(dir);
43-}
crates/ec-prores/tests/robust.rsdeleted+0 -135
@@ -1,135 +0,0 @@
1-//! Robustness: truncated, corrupted and hostile frames must never panic, and refusals must name
2-//! what they refused.
3-
4-mod common;
5-use common::*;
6-use ec_core::Error;
7-
8-struct Rng(u64);
9-impl Rng {
10- fn next(&mut self) -> u64 {
11- self.0 ^= self.0 << 13;
12- self.0 ^= self.0 >> 7;
13- self.0 ^= self.0 << 17;
14- self.0
15- }
16- fn below(&mut self, n: usize) -> usize {
17- (self.next() % n.max(1) as u64) as usize
18- }
19-}
20-
21-/// Small frames: progressive 422, interlaced 422, 4444 with alpha.
22-fn frames() -> Vec<Vec<u8>> {
23- static CACHE: std::sync::OnceLock<Vec<Vec<u8>>> = std::sync::OnceLock::new();
24- CACHE.get_or_init(make_frames).clone()
25-}
26-
27-fn make_frames() -> Vec<Vec<u8>> {
28- let dir = scratch("robust");
29- let mut out = Vec::new();
30- for (i, (prof, fmt, extra)) in [
31- ("3", "yuv422p10le", ""),
32- ("1", "yuv422p10le", "+ildct"),
33- ("4", "yuva444p10le", ""),
34- ]
35- .into_iter()
36- .enumerate()
37- {
38- let mov = dir.join(format!("r{i}.mov"));
39- let mut a = vec![
40- "-f", "lavfi", "-i", "testsrc2=size=100x70:rate=25,noise=alls=20:allf=t", "-frames:v", "1",
41- "-c:v", "prores_ks", "-profile", prof, "-pix_fmt", fmt,
42- ];
43- if !extra.is_empty() {
44- a.extend(["-flags", extra]);
45- }
46- a.push(mov.to_str().unwrap());
47- assert!(run(&a));
48- out.push(packets(&std::fs::read(&mov).unwrap()).remove(0));
49- }
50- let _ = std::fs::remove_dir_all(dir);
51- out
52-}
53-
54-#[test]
55-fn truncations_never_panic() {
56- let fs = frames();
57- for f in &fs {
58- let mut d = decoder(2);
59- assert!(d.decode(f).is_ok());
60- for n in (0..f.len()).step_by(7).chain(0..40) {
61- let _ = d.decode(&f[..n.min(f.len())]);
62- }
63- }
64-}
65-
66-#[test]
67-fn corruptions_never_panic() {
68- let fs = frames();
69- let mut rng = Rng(0x9E3779B97F4A7C15);
70- for f in &fs {
71- let mut d = decoder(3);
72- for round in 0..400 {
73- let mut g = f.clone();
74- let flips = 1 + rng.below(8);
75- for _ in 0..flips {
76- // Half the hits land in the headers, where the structure lives.
77- let at = if round % 2 == 0 { rng.below(g.len().min(200)) } else { rng.below(g.len()) };
78- g[at] ^= 1 << rng.below(8);
79- }
80- let _ = d.decode(&g);
81- }
82- }
83-}
84-
85-#[test]
86-fn garbage_is_refused_by_name() {
87- let mut d = decoder(1);
88- let mut rng = Rng(7);
89- for len in [0usize, 1, 7, 8, 27, 28, 200, 5000] {
90- let g: Vec<u8> = (0..len).map(|_| rng.next() as u8).collect();
91- assert!(d.decode(&g).is_err());
92- }
93- // Right magic, nonsense after it.
94- let mut g = vec![0u8; 300];
95- g[..4].copy_from_slice(&300u32.to_be_bytes());
96- g[4..8].copy_from_slice(b"icpf");
97- match d.decode(&g) {
98- Err(Error::Unsupported { .. } | Error::Corrupt { .. }) => {}
99- other => panic!("expected a named refusal, got {:?}", other.map(|f| f.width)),
100- }
101-}
102-
103-#[test]
104-fn hostile_dimensions_are_bounded() {
105- let fs = frames();
106- let mut g = fs[0].clone();
107- // width/height at frame-header bytes 8..12 (after size+icpf: offset 8+8).
108- g[16..20].copy_from_slice(&[0xFF, 0xFF, 0xFF, 0xFF]);
109- let t = std::time::Instant::now();
110- assert!(decoder(1).decode(&g).is_err());
111- assert!(t.elapsed().as_secs() < 5);
112- g[16..20].copy_from_slice(&[0, 0, 0, 0]);
113- assert!(decoder(1).decode(&g).is_err());
114-}
115-
116-#[test]
117-fn wrong_codec_is_unsupported() {
118- use ec_core::registry::{CodecId, CodecParameters};
119- match ec_prores::ProResDecoder::new(CodecParameters::new(CodecId::H264)) {
120- Err(Error::Unsupported { .. }) => {}
121- _ => panic!("expected Unsupported"),
122- }
123-}
124-
125-/// `EC_SEED_DIR=crates/ec-prores/fuzz/corpus/decode_prores cargo test -p ec-prores --test robust -- --ignored dump_seeds`
126-#[test]
127-#[ignore]
128-fn dump_seeds() {
129- let dir = std::env::var("EC_SEED_DIR").expect("EC_SEED_DIR");
130- std::fs::create_dir_all(&dir).unwrap();
131- let fs = frames();
132- for (i, f) in fs.iter().enumerate() {
133- std::fs::write(format!("{dir}/seed{i}.bin"), f).unwrap();
134- }
135-}