forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

sb128.report.md3.7 KiBHistoryRawDownload

lane-sb128 -- 128x128 superblocks in the encoder

Step 1: the sequence option, SPLIT-only roots (structural cost)

EC_AV1_SB128=1 writes use_128x128_superblock = 1 in the sequence header and makes both tile writers walk 128x128 superblocks: loop restoration and one partition_w128 symbol at the 128 root, then the four 64x64 quadrants (today's superblocks, unchanged) in libaom's TL/TR/BL/BR order. Every partition decision below the root is identical to the 64-superblock encoder, so the whole cost of the step is the extra partition symbols plus the moved loop-restoration unit size.

NOT an EncoderConfig field (deviation from the charter, stated): that struct is built by 90 literal sites in this workspace, so a new public field is a 90-file diff for a knob whose default the gate decides. EC_AV1_SB128 follows EC_AV1_FILTER_INTRA's existing shape.

What moved

  • crates/ec-av1/src/tile.rs -- arm_sb128 + sb_write_order (an exact mirror of decode::sb_visit_order) + write_sb128_root (LR over the 128 span, then PARTITION_SPLIT off partition_w128, or the DECIDING gathered bit at a root the frame edge cuts); write_lr takes its span; the no-neighbour partition sentinel is 128, not 64.
  • crates/ec-av1/src/encode.rs -- sb128_on(), lr_unit() (a 128 superblock cannot signal the 64 restoration unit at all), the sequence bit, both tile-write arming sites.
  • crates/ec-av1/src/decode.rs -- gather_of/VERT_ALIKE128/HORZ_ALIKE128 exported to the writer; an encoder FrameCtx starts at this process's superblock size so the search's Reach and the filter search's internal decodes agree with the writer.

Root cause found on the way

The writer's Neighbours used 64 as its "no neighbour" partition side. That reads identically at every level up to 64x64 but sets the bit at the 128 root (64 * 2 <= 128), so the writer coded the root's partition symbol off CDF row 3 while the decoder read row 0 -- a first-symbol desync that decoded the whole frame as one 128x128 intra block. The decoder had already fixed its own copy (decode::NO_NEIGHBOUR_SIDE, lane-sb128 r1); the writer's copy had not moved. Class: table and reader move together.

Structural cost, measured (640x384 pin clip, 4 pictures, q=150)

arm bytes vs its own control
64 SB, LR on (the shipped stream) 8562 --
128 SB, LR on 8547 -15 (-0.18%)
64 SB, EC_AV1_LR=0 8530 --
128 SB, EC_AV1_LR=0 8537 +7 (+0.08%)

So the two effects separate cleanly:

  • The extra partition symbols cost +7 bytes over 60 roots (15 128-roots per frame x 4 pictures), i.e. ~0.93 bits per root -- a SPLIT at a neighbourless root is nearly free on the partition_w128 CDF.
  • The loop-restoration unit, forced 64 -> 128 by the superblock size, saves 22 bytes (60 units per frame -> 15), and the net is -15 bytes.

CDEF indexing did NOT move: the spec clears cdef_idx per 64x64 unit inside a 128 superblock (clear_cdef at the superblock, one -1 per 64x64 position), our decoder resets cdef_transmitted at every 64 quadrant, and the writer's one-slot "already written" marker keys on the 64 grid, which the TL/TR/BL/BR order keeps contiguous. Nothing about the CDEF plan changed.

Witness (step 1)

encoder::tests::a_static_clip_codes_128x128_superblock_roots_and_decodes_sample_exact (--ignored, it sets the process-global superblock size): 256x128 x 3 frames, 8 128x128 superblock roots written, our decoder reads >= 4 PARTITION_SPLIT roots, and every frame is byte-exact between our decoder and ffmpeg.

cargo test -p ec-av1 --release --lib -- --ignored \
    a_static_clip_codes_128x128_superblock_roots --nocapture