edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! Generator for the two AV1 coverage cells no encoder emits, so both are |
| 2 | //! GATED rather than left as declared debt (`lanes/av1formatsweep.report.md` |
| 3 | //! §6.4 and its "declared debt" note: the `4:2:0 with an odd luma dimension` |
| 4 | //! and `4:4:0 (ss 0,1)` rows were "unmeasured and unproducible by recipe"). |
| 5 | //! |
| 6 | //! Both cells are produced here, offline, with no encoder and no ffmpeg: |
| 7 | //! |
| 8 | //! 1. **`420_odd65x65_key.obu`** -- a 4:2:0 key frame whose header declares |
| 9 | //! an ODD luma size (65x65). aomenc cannot produce this one: it rounds the |
| 10 | //! coded size DOWN to even (`av1enc_set_frame_size`; the measured |
| 11 | //! `testsrc2 131x131` y4m comes out as `max_frame=130x130`), so the cell |
| 12 | //! needs the encoder to be told what size to DECLARE. That is |
| 13 | //! [`ec_av1::encode::encode_key_frame_at_size`]: a 96x96 picture padded to |
| 14 | //! the block grid, coded with a 65x65 frame header. The result is a real, |
| 15 | //! fully decodable AV1 stream -- the gate compares it sample for sample |
| 16 | //! against the instrumented `aomdec`. |
| 17 | //! |
| 18 | //! 2. **`440_request_is_422.obu`** -- what this crate's writer produces when |
| 19 | //! it is HANDED 4:4:0 (`subsampling_x = 0`, `subsampling_y = 1`). The |
| 20 | //! cell turns out not to exist: `subsampling_y` is coded only when |
| 21 | //! `subsampling_x` is 1 (spec 5.5.2 `color_config`), so a sequence header |
| 22 | //! carries 4:2:0 `(1,1)`, 4:2:2 `(1,0)` or 4:4:4 `(0,0)` and never |
| 23 | //! `(0,1)` -- libaom's own writer ASSERTS it ("4:4:0 subsampling not |
| 24 | //! allowed in AV1", `av1/encoder/bitstream.c:2467-2468`) and its reader |
| 25 | //! forces |
| 26 | //! `subsampling_y = 0` when `subsampling_x` is 0 |
| 27 | //! (`av1_read_color_config`, `av1/decoder/decodeframe.c:4171-4175`). |
| 28 | //! aomenc having no `yuv440p` input path and ffmpeg's y4m muxer refusing |
| 29 | //! the format ("yuv4mpeg can only handle yuv444p, yuv422p, yuv420p, |
| 30 | //! yuv411p and gray8") are consequences of that, not the reason. The pin |
| 31 | //! is the byte-level evidence: a 4:4:0 request at profile 2 (4:2:2, and |
| 32 | //! no coded subsampling bit below 12 bits) lands on `(1,0)`. The frame OBU |
| 33 | //! behind it is a real 4:2:0 key frame's, byte for byte -- the subsampling |
| 34 | //! lives only in the sequence header -- so the pin is a HEADER witness, NOT |
| 35 | //! a decodable 4:2:2 stream. lane-av1422lift: it was never decodable as |
| 36 | //! one; the decoder used to refuse it at the sequence header, and now |
| 37 | //! admits the header, which is exactly why this pin may not be turned into |
| 38 | //! a 4:2:2 exactness gate. The gate |
| 39 | //! `the_440_cell_is_not_a_codable_chroma_shape` says exactly that, and the |
| 40 | //! real 4:2:2 exactness lives in `a_real_422_stream_decodes_pixel_exact` |
| 41 | //! and `the_pinned_422_corpus_cells_decode_pixel_exact`, which read |
| 42 | //! genuinely 4:2:2 pins. |
| 43 | //! |
| 44 | //! ```text |
| 45 | //! cargo run -p ec-av1 --example gen_coverage_cells -- crates/ec-av1/fixtures |
| 46 | //! sha256sum crates/ec-av1/fixtures/420_odd65x65_key.obu \ |
| 47 | //! crates/ec-av1/fixtures/440_request_is_422.obu |
| 48 | //! ``` |
| 49 | //! |
| 50 | //! Both files are deterministic: the source card is a fixed integer pattern |
| 51 | //! and the encoder is deterministic, so re-running this overwrites the pins |
| 52 | //! with the same bytes. `ec-av1` is a hand-code-only repository -- do NOT run |
| 53 | //! `cargo fmt` on this file; rustfmt runs at commit time and its churn is |
| 54 | //! accepted, never reverted. |
| 55 | |
| 56 | use Picture; |
| 57 | use ; |
| 58 | |
| 59 | /// The padded coding surface the odd cell is cut from: a whole number of |
| 60 | /// 32x32 blocks (`Picture::check`'s own rule), and a multiple of 8 above the |
| 61 | /// 65x65 it declares, so no declared column is already block-aligned. |
| 62 | const PAD: usize = 96; |
| 63 | |
| 64 | /// The odd-luma cell's DECLARED frame size. Both dimensions odd on purpose: |
| 65 | /// the 4:2:0 chroma extent is then `ROUND_POWER_OF_TWO(65, 1) = 33` in each |
| 66 | /// axis (libaom `av1_common_plane_width`, `av1/common/av1_common_int.h`), |
| 67 | /// which is where a floor (32) and a ceil (33) disagree -- the whole reason |
| 68 | /// the cell was worth closing. |
| 69 | const ODD: usize = 65; |
| 70 | |
| 71 | /// The 4:4:0 witness's frame size, and the quantizer both streams are coded |
| 72 | /// at. Even, so nothing else about the witness is unusual: the shape is 4:4:0 |
| 73 | /// and nothing else. |
| 74 | const WITNESS: usize = 64; |
| 75 | |
| 76 | /// `base_q_idx` for both cells. Mid-scale on purpose: high enough that a |
| 77 | /// block carries real coefficients (so a wrong chroma extent shows in the |
| 78 | /// output), low enough that the stream stays small. |
| 79 | const Q_IDX: u8 = 100; |
| 80 | |
| 81 | /// A deterministic, high-frequency card: a 2-D pattern whose wrapped |
| 82 | /// diagonal jumps, so every 8x8 block has real high-frequency content and |
| 83 | /// therefore real coefficients. That matters for the odd cell -- a flat or |
| 84 | /// smooth card predicts to within a quantizer step of a constant in its last |
| 85 | /// column too, so a wrong chroma extent could leave the OUTPUT unchanged and |
| 86 | /// the gate would then be green on broken code. |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | /// The chroma shape of the 4:4:0 witness: profile 0 with `subsampling_x = 0` |
| 105 | /// and `subsampling_y = 1`. Profile 0 forces neither subsampling bit (only |
| 106 | /// profile 1 forces 4:4:4 and profile 2 below 12 bits forces 4:2:2, spec |
| 107 | /// 5.5.2), so both are coded in the header and `(0, 1)` -- 4:4:0 -- is legal |
| 108 | /// there. |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | /// Writes `bytes` to `<dir>/<name>`, then reports size, FNV-1a64 and sha256. |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | /// The subsampling and the max frame size a reader gets back out of `bytes` |
| 155 | /// -- the generator never takes the shape it wrote on faith, it re-parses |
| 156 | /// its own output. |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | /// The bytes of `stream`'s single `OBU_FRAME`, OBU header and size field |
| 178 | /// included. An example cannot reach `Encoded::tile` (crate-private, and |
| 179 | /// documented as a `crate::decode` test-only reader) and does not need to: |
| 180 | /// the OBU is right there in the stream the encoder just wrote. |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 |