Lossless report -- rules, fixtures, deferred
Browse files at this commitc0a6d4471d05be17e713f668e0deb2e18b360b84Parent: 1e1a080- docs
- lossless report -- rules, fixtures, deferred
1 changed file +29 -38
- lanes/lossless.report.md +29 -38
lanes/lossless.report.mdmodified+29 -38
| @@ -1,42 +1,33 @@ | ||
| 1 | 1 | # lane-lossless — AV1 lossless (qindex 0) decode |
| 2 | 2 | |
| 3 | -Branch `lane-lossless`, base `7ba28bcd`. Status: IN PROGRESS. | |
| 3 | +Branch `lane-lossless`, base `7ba28bcd`. Status: KEY-frame half SHIPPED, inter half refused by name. | |
| 4 | 4 | |
| 5 | -## Done (commits b56bb30f, d26c55bb wip) | |
| 6 | -- `transform.rs::inverse_wht4x4` — libaom `av1_iwht4x4_16_add_c` | |
| 7 | - (`aom_dsp/inv_txfm.c:22`), inputs shifted by `UNIT_QUANT_SHIFT` (2). Test | |
| 8 | - `transform::lossless_tx_tests::the_walsh_hadamard_round_trip_is_exact` PASSES. | |
| 9 | -- `TxParams::lossless` + `dequant_and_inverse_wht4x4`: the residual of a | |
| 10 | - lossless unit comes off the WHT, not the DCT/ADST network | |
| 11 | - (`av1/common/idct.c` `inv_txfm_add`: `if (txfm_param->lossless) { assert(tx_type | |
| 12 | - == DCT_DCT); av1_iwht4x4_add(...); return; }`). | |
| 13 | -- Per-frame `CodedLossless` flag (`decode::set_lossless`/`lossless`), set in | |
| 14 | - `stream.rs` where the refusal used to be. A frame MIXING lossless and lossy | |
| 15 | - segments is still refused by name (all rules are per segment there). | |
| 16 | -- TX_4X4 forcing: `decode_block` (tables/scans/tx swapped to the 4x4 ones), | |
| 17 | - `decode_leaf8`, and `depth_to_tx_wh` (every HORZ/VERT strip reader) -- | |
| 18 | - libaom `read_tx_size` (`decodeframe.c`): `if (xd->lossless[segment_id]) | |
| 19 | - return TX_4X4;` before anything else. | |
| 20 | -- No `tx_type` symbol, DCT_DCT on every plane: libaom `read_tx_type` | |
| 21 | - (`decodetxb.c`) returns early at `qindex == 0`; `av1_get_tx_type` | |
| 22 | - (`blockd.h`) returns DCT_DCT for a lossless block. | |
| 23 | -- `is_cfl_allowed` narrowing (`blockd.h`): under lossless CfL is offered only | |
| 24 | - when the chroma plane block is BLOCK_4X4, i.e. a luma block <= 8x8 | |
| 25 | - (`decode::cfl_allowed_px`, the one point every intra reader routes through). | |
| 26 | -- `txb_skip_chroma_4` widened 3 -> 6 rows: `get_txb_ctx`'s `+10` rows | |
| 27 | - (chroma plane block larger than its transform) are reachable at TX_4X4 only | |
| 28 | - on a lossless frame -- `av1_default_txb_skip_cdfs[0][TX_4X4][10..13]` = | |
| 29 | - 9961/30242/32117 and are the neutral 16384 in every other q-context, which | |
| 30 | - is libaom's own confirmation of the rule. | |
| 5 | +## Rules implemented (each with its libaom reference) | |
| 6 | +| rule | libaom | where | | |
| 7 | +|---|---|---| | |
| 8 | +| TX_4X4 on every plane, no `tx_depth`/`txfm_split` symbol | `read_tx_size` (`av1/decoder/decodeframe.c`): `if (xd->lossless[..]) return TX_4X4;` before `max_txsize_rect_lookup` | `decode::lossless_tx`, `decode_block`, `decode_leaf8`, `depth_to_tx_wh`, `read_block_tx_size`(+`_rect`), `read_inter_luma8` | | |
| 9 | +| Walsh-Hadamard inverse instead of DCT/ADST | `inv_txfm_add` (`av1/common/idct.c`): `if (txfm_param->lossless) { assert(tx_type == DCT_DCT); av1_iwht4x4_add(...); }`; kernel `av1_highbd_iwht4x4_16_add_c` (`av1/common/av1_inv_txfm2d.c:20`), inputs `>> UNIT_QUANT_SHIFT` (2) | `transform::inverse_wht4x4` / `dequant_and_inverse_wht4x4`, `TxParams::lossless` | | |
| 10 | +| no `tx_type` symbol | `read_tx_type` (`av1/decoder/decodetxb.c`): "No need to read transform type for lossless mode(qindex==0)" | `read_plane`/`read_inter_plane`/`read_inter_plane_rect`: `coding.tx_type = None` | | |
| 11 | +| DCT_DCT on every plane (so the default scan) | `av1_get_tx_type` (`av1/common/blockd.h`): lossless returns DCT_DCT | same three readers' `default_tx_type` | | |
| 12 | +| `is_cfl_allowed` narrows to a BLOCK_4X4 chroma plane block (luma <= 8x8 at 4:2:0) | `is_cfl_allowed` (`av1/common/blockd.h`) | `decode::cfl_allowed_px`, used by every intra mode reader | | |
| 13 | +| chroma coded as 4x4 units, plane-major, with `get_txb_ctx`'s `+10` rows | `decode_token_recon_block` mu-chunk loop; `av1_default_txb_skip_cdfs[0][TX_4X4][10..13]` = 9961/30242/32117 (neutral 16384 in every other q-context) | `decode_rect_split` lossless chroma branch; `cdf_state::txb_skip_chroma_4` widened 3 -> 6 rows | | |
| 14 | +| loop filter / CDEF / LR off | header-level (`coded_lossless`/`all_lossless`), already handled by the frame-header parser | unchanged | | |
| 15 | +| a frame mixing lossless and lossy segments | every rule above is per segment | refused by name | | |
| 31 | 16 | |
| 32 | -## Remaining | |
| 33 | -- The 64x64 synthetic key frame (`ffmpeg -c:v libaom-av1 -crf 0 -b:v 0`) now | |
| 34 | - parses the whole tile but still differs from ffmpeg at luma sample 0: | |
| 35 | - desync is inside the first block's coefficients (mode syntax of block 1 | |
| 36 | - matches aomdec's `EC_ISTEP`, block 2's range does not). | |
| 37 | -- Inter-frame readers (`decode_inter_block*`, sub8) not yet forced to TX_4X4. | |
| 38 | -- Filter-stage skips (deblock/CDEF/LR) are header-driven and believed already | |
| 39 | - handled by the header parser; unverified. | |
| 40 | -- Fixtures + gates: none added yet; the retired refusal gate | |
| 41 | - `a_lossless_libaom_stream_is_refused_by_name` still asserts the old refusal | |
| 42 | - and will FAIL until it is swapped for the decode-exact gate. | |
| 17 | +WHT orientation is pinned by MEASUREMENT: libaom's column-then-row-with-transpose | |
| 18 | +loop equals rows-then-columns in place on a raster grid; the other orientation | |
| 19 | +reconstructs sample 0 and DC-only units correctly and drifts +-1 elsewhere. | |
| 20 | + | |
| 21 | +## Fixtures and results (all `ffmpeg -c:v libaom-av1 -crf 0 -b:v 0`, synthetic source) | |
| 22 | +| fixture | result | | |
| 23 | +|---|---| | |
| 24 | +| 64x64, 1 key frame, 8-bit | EXACT vs ffmpeg (0/6144 samples differ); 6488 entropy steps identical to aomdec `EC_TRACE_COEFF` | | |
| 25 | +| 256x128, 2 key frames (`-g 1`), 8-bit | EXACT both frames — pinned as `stream::tests::a_lossless_libaom_key_frame_decodes_sample_exact` | | |
| 26 | +| 192x96, 2 key frames, 10-bit | EXACT both frames | | |
| 27 | +| 128x64, 4 frames (`-g 4`, inter) | refused by name — pinned as `stream::tests::a_lossless_inter_frame_is_refused_by_name` | | |
| 28 | + | |
| 29 | +## Deferred | |
| 30 | +- `deferred: lossless INTER frames — an inter block's chroma plane is still read as one transform per block (decode_inter_block's two chroma sites + the 128 mu-chunk loop); its luma leaves are already synthesized as TX_4X4 — unblocks: port the 4x4 chroma unit walk (the shape decode_rect_split's lossless branch already has) into decode_inter_block/decode_inter_block8/the sub8 readers.` | |
| 31 | +- `deferred: the 12-frame bd_rate_screen_native gate's libaom crf-5 point — that stream's inter frames now hit the named refusal instead of decoding, so the deciding gate cannot be green this round — unblocks: the inter chroma walk above.` | |
| 32 | +- `deferred: mixed lossless/lossy segments — refused by name; no libaom recipe emits one — unblocks: a segmentation fixture with per-segment qindex.` | |
| 33 | +- `deferred: 4:4:4 / monochrome lossless — the crate is 4:2:0 only.` |