NxN partitions mark availability per partition, matching the encoder
Browse files at this commit296a5012769ed5578ab0a95fafb8a490d2db5b88Parent: 9c113d7- fix
- NxN partitions mark availability per partition, matching the encoder
2 changed files +23 -24
crates/ec-h265/src/decode.rsmodified+18 -3
| @@ -512,10 +512,25 @@ impl CtuDecoder { | ||
| 512 | 512 | mode |
| 513 | 513 | }; |
| 514 | 514 | modes[part] = mode; |
| 515 | - // Mode only, so the next partition's MPM sees it; pixels follow | |
| 516 | - // once the residual syntax below is read. | |
| 515 | + // Mode and availability, so the next partition's `mpm_at` sees | |
| 516 | + // this one as a real coded neighbour — the encoder's own | |
| 517 | + // mode-decide loop calls `mark_coded` (which flips availability) | |
| 518 | + // immediately per partition for exactly this reason (8.4.2: an | |
| 519 | + // NxN CU's later partitions see its earlier ones as available). | |
| 520 | + // Marking modes here without also marking `decoded` left the | |
| 521 | + // second/third/fourth partition's left/above neighbour reading | |
| 522 | + // as unavailable (substituted DC) on the decoder side while the | |
| 523 | + // encoder's MPM saw the real mode, decoding the wrong MPM triple | |
| 524 | + // and desyncing every bin after it — this is what an NxN CU | |
| 525 | + // forced into existence by a boundary split (rather than chosen | |
| 526 | + // by `intra_nxn`'s RD search) actually exercises differently: | |
| 527 | + // the RD search rarely keeps NxN once a real neighbour is | |
| 528 | + // available on all four sides, so the bug went unseen until a | |
| 529 | + // picture edge forced it. | |
| 517 | 530 | let stride = self.width / 4; |
| 518 | - self.modes[(py / 4) * stride + px / 4] = mode; | |
| 531 | + let idx = (py / 4) * stride + px / 4; | |
| 532 | + self.modes[idx] = mode; | |
| 533 | + self.decoded[idx] = true; | |
| 519 | 534 | } |
| 520 | 535 | |
| 521 | 536 | let chroma_mode = self.decode_chroma_mode(dec, modes[0]); |
crates/ec-h265/tests/decode.rsmodified+5 -21
| @@ -56,32 +56,16 @@ fn decode_matches_the_encoders_own_reconstruction_over_several_ctbs() { | ||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | #[test] |
| 59 | -#[ignore = "r3 checkpoint: fails with 'end_of_slice_segment_flag 0 at CTB (2,1), \ | |
| 60 | -expected 1' — narrowed (not yet root-caused) to the interaction of the NxN \ | |
| 61 | -intra partition (PART_NxN, an 8x8 CU split into four 4x4 PUs) with a \ | |
| 62 | -boundary-forced coding-unit: forcing every 8x8 leaf to code as 2Nx2N \ | |
| 63 | -(`intra_nxn: false`) round-trips clean; forcing every 8x8 leaf to NxN \ | |
| 64 | -(EC_H265_FORCE_NXN local hack, removed) round-trips clean on an exact-CTB-\ | |
| 65 | -multiple picture (64x64, ctb 64) but reproduces this same failure on a \ | |
| 66 | -picture whose last CTU is boundary-forced-split down to 8x8 (40x50, ctb 64, \ | |
| 67 | -no WPP — cols=1 rules out the WPP substream code entirely). So: NxN syntax \ | |
| 68 | -itself is right (it round-trips away from a picture edge); the bug is in \ | |
| 69 | -what an 8x8 CU sees or does differently when the quadtree reached it via \ | |
| 70 | -the boundary force-split path (7.3.8.4, no split_cu_flag bin) rather than \ | |
| 71 | -via a decoded split_cu_flag==0 — likely `mpm_at`/`available`'s neighbour \ | |
| 72 | -lookup, since that is the only per-CU state NxN reads that a forced-split \ | |
| 73 | -ancestor could leave in a different shape than a normal split would. Next \ | |
| 74 | -round: trace `available()`/`mode_at()` at the forced-split leaf specifically \ | |
| 75 | -(cheap, no RD-search noise, since EC_H265_FORCE_NXN made this deterministic \ | |
| 76 | -without touching the passing 2Nx2N path)."] | |
| 77 | 59 | fn decode_matches_the_encoders_own_reconstruction_at_an_odd_padded_size() { |
| 78 | 60 | roundtrip_at(70, 50); |
| 79 | 61 | } |
| 80 | 62 | |
| 81 | 63 | #[test] |
| 82 | -#[ignore = "r3 checkpoint: same root cause as \ | |
| 83 | -decode_matches_the_encoders_own_reconstruction_at_an_odd_padded_size — NxN \ | |
| 84 | -at a boundary-forced 8x8 leaf; see that test's ignore reason."] | |
| 85 | 64 | fn decode_matches_the_encoders_own_reconstruction_at_another_odd_size() { |
| 86 | 65 | roundtrip_at(150, 94); |
| 87 | 66 | } |
| 67 | + | |
| 68 | +#[test] | |
| 69 | +fn decode_matches_the_encoders_own_reconstruction_at_an_extreme_odd_size() { | |
| 70 | + roundtrip_at(41, 33); | |
| 71 | +} |