Compile the r1 UV-palette WIP + gate it against a real aomenc stream
Browse files at this commit03d0151c7932d0c4baaf3ee080e0cad7e1beef41Parent: 168c232- fix
- compile the r1 UV-palette WIP + gate it against a real aomenc stream
2 changed files +120 -1
- crates/ec-av1/src/decode.rs +2 -1
- crates/ec-av1/src/stream.rs +118 -0
crates/ec-av1/src/decode.rsmodified+2 -1
| @@ -4391,7 +4391,7 @@ fn decode_leaf8( | |||
| 4391 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec | 4391 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec |
| 4392 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other | 4392 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other |
| 4393 | // `decode_block` caller at 16x16 and up. | 4393 | // `decode_block` caller at 16x16 and up. |
| 4394 | - let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, _palette_y) = | 4394 | + let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, _palette_y, _palette_uv) = |
| 4395 | read_intra_mode( | 4395 | read_intra_mode( |
| 4396 | dec, | 4396 | dec, |
| 4397 | cdfs, | 4397 | cdfs, |
| @@ -4404,6 +4404,7 @@ fn decode_leaf8( | |||
| 4404 | allow_screen_content_tools, | 4404 | allow_screen_content_tools, |
| 4405 | allow_intrabc, | 4405 | allow_intrabc, |
| 4406 | None, | 4406 | None, |
| 4407 | + &[], | ||
| 4407 | leaf_mi.0, | 4408 | leaf_mi.0, |
| 4408 | leaf_mi.1, | 4409 | leaf_mi.1, |
| 4409 | )?; | 4410 | )?; |
crates/ec-av1/src/stream.rsmodified+118 -0
| @@ -1707,6 +1707,124 @@ mod tests { | |||
| 1707 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg"); | 1707 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg"); |
| 1708 | } | 1708 | } |
| 1709 | 1709 | ||
| 1710 | + /// A real `aomenc` palette-**UV** fixture (lane-palette2 r2): `testsrc2` | ||
| 1711 | + /// (the multicoloured AV1 test pattern -- flat, few-colour, repetitive | ||
| 1712 | + /// per-region colour *and* chroma, unlike `smptebars=hue=s=0` above, | ||
| 1713 | + /// which flattened chroma to a single value specifically to avoid | ||
| 1714 | + /// exercising this path). Same square-only recipe as the palette-Y gate | ||
| 1715 | + /// (`--enable-rect-partitions=0`/`-ab-`/`-1to4-`, fixed 32x32 partition) | ||
| 1716 | + /// so a UV palette block never lands inside the still-refused HORZ/VERT | ||
| 1717 | + /// screen-content strip. HARD-asserts [`decode::palette_uv_hits`] moved | ||
| 1718 | + /// -- a stream that never reads a real UV palette block would decode (or | ||
| 1719 | + /// not) by construction without proving this milestone at all | ||
| 1720 | + /// ([[gate-blind-to-feature]]). | ||
| 1721 | + #[test] | ||
| 1722 | + fn a_real_aomenc_stream_with_palette_uv_decodes_pixel_exact() { | ||
| 1723 | + const NAME: &str = "a_real_aomenc_stream_with_palette_uv_decodes_pixel_exact"; | ||
| 1724 | + if !have_ffmpeg() { | ||
| 1725 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 1726 | + return; | ||
| 1727 | + } | ||
| 1728 | + if !have_aomenc() { | ||
| 1729 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 1730 | + return; | ||
| 1731 | + } | ||
| 1732 | + let source = "testsrc2=size=64x64:rate=25"; | ||
| 1733 | + fn render(source: &str) -> Vec<u8> { | ||
| 1734 | + Command::new("ffmpeg") | ||
| 1735 | + .args([ | ||
| 1736 | + "-v", | ||
| 1737 | + "error", | ||
| 1738 | + "-f", | ||
| 1739 | + "lavfi", | ||
| 1740 | + "-i", | ||
| 1741 | + source, | ||
| 1742 | + "-pix_fmt", | ||
| 1743 | + "yuv420p", | ||
| 1744 | + "-t", | ||
| 1745 | + "0.16", | ||
| 1746 | + "-f", | ||
| 1747 | + "yuv4mpegpipe", | ||
| 1748 | + "-", | ||
| 1749 | + ]) | ||
| 1750 | + .stdin(Stdio::null()) | ||
| 1751 | + .stdout(Stdio::piped()) | ||
| 1752 | + .stderr(Stdio::piped()) | ||
| 1753 | + .output() | ||
| 1754 | + .expect("ffmpeg failed to run") | ||
| 1755 | + .stdout | ||
| 1756 | + } | ||
| 1757 | + let y4m_a = render(source); | ||
| 1758 | + let y4m_b = render(source); | ||
| 1759 | + assert_eq!( | ||
| 1760 | + y4m_a, y4m_b, | ||
| 1761 | + "testsrc2 must render byte-identical across two runs" | ||
| 1762 | + ); | ||
| 1763 | + let y4m = y4m_a; | ||
| 1764 | + let mut child = Command::new(aomenc_path()) | ||
| 1765 | + .args([ | ||
| 1766 | + "--codec=av1", | ||
| 1767 | + "--passes=1", | ||
| 1768 | + "--end-usage=q", | ||
| 1769 | + "--cq-level=30", | ||
| 1770 | + "--cpu-used=0", | ||
| 1771 | + "--threads=1", | ||
| 1772 | + "--row-mt=0", | ||
| 1773 | + "--sb-size=64", | ||
| 1774 | + "--tune-content=screen", | ||
| 1775 | + "--enable-palette=1", | ||
| 1776 | + "--enable-intrabc=0", | ||
| 1777 | + "--enable-rect-partitions=0", | ||
| 1778 | + "--enable-ab-partitions=0", | ||
| 1779 | + "--enable-1to4-partitions=0", | ||
| 1780 | + "--min-partition-size=32", | ||
| 1781 | + "--max-partition-size=32", | ||
| 1782 | + "--enable-filter-intra=0", | ||
| 1783 | + "--enable-cdef=0", | ||
| 1784 | + "--enable-restoration=0", | ||
| 1785 | + "--enable-tx-size-search=0", | ||
| 1786 | + "--loopfilter-control=0", | ||
| 1787 | + "--obu", | ||
| 1788 | + "-o", | ||
| 1789 | + "-", | ||
| 1790 | + "-", | ||
| 1791 | + ]) | ||
| 1792 | + .stdin(Stdio::piped()) | ||
| 1793 | + .stdout(Stdio::piped()) | ||
| 1794 | + .stderr(Stdio::piped()) | ||
| 1795 | + .spawn() | ||
| 1796 | + .expect("aomenc failed to start"); | ||
| 1797 | + child | ||
| 1798 | + .stdin | ||
| 1799 | + .take() | ||
| 1800 | + .expect("aomenc stdin") | ||
| 1801 | + .write_all(&y4m) | ||
| 1802 | + .expect("writing y4m to aomenc"); | ||
| 1803 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 1804 | + assert!( | ||
| 1805 | + out.status.success(), | ||
| 1806 | + "aomenc refused the fixture: {}", | ||
| 1807 | + String::from_utf8_lossy(&out.stderr) | ||
| 1808 | + ); | ||
| 1809 | + let stream = out.stdout; | ||
| 1810 | + let before = decode::palette_uv_hits(); | ||
| 1811 | + let frames = match decode_stream(&stream) { | ||
| 1812 | + Ok(frames) => frames, | ||
| 1813 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | ||
| 1814 | + }; | ||
| 1815 | + assert!( | ||
| 1816 | + decode::palette_uv_hits() > before, | ||
| 1817 | + "palette_uv_mode never fired decoding this stream -- gate is vacuous" | ||
| 1818 | + ); | ||
| 1819 | + let frame_count = frames.len(); | ||
| 1820 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 64, 64, frame_count); | ||
| 1821 | + for i in 0..frame_count { | ||
| 1822 | + assert_eq!(frames[i].y, ffmpeg_frames[i].y, "luma vs ffmpeg, frame {i}"); | ||
| 1823 | + assert_eq!(frames[i].u, ffmpeg_frames[i].u, "U vs ffmpeg, frame {i}"); | ||
| 1824 | + assert_eq!(frames[i].v, ffmpeg_frames[i].v, "V vs ffmpeg, frame {i}"); | ||
| 1825 | + } | ||
| 1826 | + } | ||
| 1827 | + | ||
| 1710 | /// As [`a_real_aomenc_filter_intra_stream_decodes_pixel_exact`]'s | 1828 | /// As [`a_real_aomenc_filter_intra_stream_decodes_pixel_exact`]'s |
| 1711 | /// harness, but with the deblocking filter left *on* (no | 1829 | /// harness, but with the deblocking filter left *on* (no |
| 1712 | /// `--loopfilter-control=0`) at a crf high enough that libaom actually | 1830 | /// `--loopfilter-control=0`) at a crf high enough that libaom actually |