The reference feed keeps the film's own cadence, and RSS is measured alone
Browse files at this commit3c2d14b8dfefccc4b1c5652359b434cd5d3ee182Parent: 88cf2a7- test
- the reference feed keeps the film's own cadence, and RSS is measured alone
2 changed files +30 -3
- .gitignore +2 -0
- crates/ec-hw/tests/gpu.rs +28 -3
.gitignoremodified+2 -0
| @@ -1,2 +1,4 @@ | ||
| 1 | 1 | target/ |
| 2 | 2 | fixtures/ |
| 3 | +__pycache__/ | |
| 4 | +scripts/aac-tables/sbr-cache.json |
crates/ec-hw/tests/gpu.rsmodified+28 -3
| @@ -66,7 +66,13 @@ impl Reference { | ||
| 66 | 66 | let child = Command::new("ffmpeg") |
| 67 | 67 | .args(["-nostdin", "-v", "error", "-i"]) |
| 68 | 68 | .arg(path) |
| 69 | - .args(["-map", "0:v:0", "-pix_fmt", pix, "-f", "rawvideo", "-"]) | |
| 69 | + // `-fps_mode passthrough`: without it ffmpeg conforms its output to | |
| 70 | + // the container's nominal frame rate, duplicating or dropping | |
| 71 | + // pictures on a film whose real cadence differs — which shows up | |
| 72 | + // here as everything being one frame out from some point onward. | |
| 73 | + .args([ | |
| 74 | + "-map", "0:v:0", "-fps_mode", "passthrough", "-pix_fmt", pix, "-f", "rawvideo", "-", | |
| 75 | + ]) | |
| 70 | 76 | .stdout(Stdio::piped()) |
| 71 | 77 | .stderr(Stdio::null()) |
| 72 | 78 | .spawn() |
| @@ -767,6 +773,19 @@ fn rss_kb() -> u64 { | ||
| 767 | 773 | /// that unmaps on drop, and this is the test that says so out loud. |
| 768 | 774 | #[test] |
| 769 | 775 | fn long_decode_does_not_grow_the_resident_set() { |
| 776 | + // VmRSS is a process-wide number and the harness runs every test in this | |
| 777 | + // binary as a thread of one process: a sibling allocating between the | |
| 778 | + // baseline and the end reading shows up here as a 200 MB "leak". The | |
| 779 | + // measurement therefore runs in a child process holding only this test. | |
| 780 | + if std::env::var_os("EC_HW_RSS_CHILD").is_none() { | |
| 781 | + let status = Command::new(std::env::current_exe().expect("test binary path")) | |
| 782 | + .args(["--exact", "long_decode_does_not_grow_the_resident_set"]) | |
| 783 | + .env("EC_HW_RSS_CHILD", "1") | |
| 784 | + .status() | |
| 785 | + .expect("re-run this test in its own process"); | |
| 786 | + assert!(status.success(), "isolated RSS run failed"); | |
| 787 | + return; | |
| 788 | + } | |
| 770 | 789 | let Some(display) = display() else { return }; |
| 771 | 790 | let path = bitstreams().join("h264-1080p-23.976-8bit.264"); |
| 772 | 791 | if !path.exists() { |
| @@ -867,7 +886,10 @@ fn frames_export_as_dma_buf() { | ||
| 867 | 886 | // --------------------------------------------------------------------------- |
| 868 | 887 | |
| 869 | 888 | /// Turn any container into an elementary stream ffmpeg and this crate agree on. |
| 870 | -fn elementary(path: &Path, codec: Codec) -> Option<Vec<u8>> { | |
| 889 | +/// | |
| 890 | +/// `frames` bounds the extraction: piping a two-hour 4K film through memory to | |
| 891 | +/// compare its first five hundred pictures is several gigabytes of nothing. | |
| 892 | +fn elementary(path: &Path, codec: Codec, frames: usize) -> Option<Vec<u8>> { | |
| 871 | 893 | let args: &[&str] = match codec { |
| 872 | 894 | Codec::H264 => &["-bsf:v", "h264_mp4toannexb", "-f", "h264"], |
| 873 | 895 | Codec::H265 => &["-bsf:v", "hevc_mp4toannexb", "-f", "hevc"], |
| @@ -877,6 +899,9 @@ fn elementary(path: &Path, codec: Codec) -> Option<Vec<u8>> { | ||
| 877 | 899 | .args(["-nostdin", "-v", "error", "-i"]) |
| 878 | 900 | .arg(path) |
| 879 | 901 | .args(["-map", "0:v:0", "-c:v", "copy"]) |
| 902 | + // A few more coded pictures than frames wanted: reordering means the | |
| 903 | + // last few packets have not been shown yet. | |
| 904 | + .args(["-frames:v", &(frames + 16).to_string()]) | |
| 880 | 905 | .args(args) |
| 881 | 906 | .arg("-") |
| 882 | 907 | .stderr(Stdio::null()) |
| @@ -942,7 +967,7 @@ fn real_library_spot_check() { | ||
| 942 | 967 | let mut table = Vec::new(); |
| 943 | 968 | for (path, codec, ten_bit) in &wanted { |
| 944 | 969 | let path = Path::new(path); |
| 945 | - let Some(data) = elementary(path, *codec) else { | |
| 970 | + let Some(data) = elementary(path, *codec, limit) else { | |
| 946 | 971 | table.push(format!("{:<52} SKIP (no elementary stream)", short(path))); |
| 947 | 972 | continue; |
| 948 | 973 | }; |