edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! Tile payload writer (spec 5.11), for the one block coding the encoder can |
| 2 | //! produce today: a key frame whose every superblock is a single 64x64 |
| 3 | //! DC-predicted block with no residual. |
| 4 | //! |
| 5 | //! That frame decodes to a flat mid-grey picture — every sample is the value a |
| 6 | //! DC prediction with no neighbours produces — which is what makes it a usable |
| 7 | //! gate: any desync between this writer and a real decoder shows up as a |
| 8 | //! decode failure or a sample that is not mid-grey, with no metric in the way. |
| 9 | //! It is the skeleton the block modes, transform sizes and coefficients hang |
| 10 | //! off as they arrive. |
| 11 | |
| 12 | use RefCell; |
| 13 | |
| 14 | use BTreeMap; |
| 15 | use LazyLock; |
| 16 | use ; |
| 17 | |
| 18 | use ; |
| 19 | |
| 20 | use cratecdf; |
| 21 | use crate; |
| 22 | use crate; |
| 23 | use crateSymbolEncoder; |
| 24 | use crate; |
| 25 | use crateTxType; |
| 26 | |
| 27 | // --------------------------------------------------------------------------- |
| 28 | // lane-av1lr: per-64x64 `cdef_idx` (spec 5.11.56, `read_cdef`). The decoder |
| 29 | // reads ONE `cdef_idx` literal per 64x64 superblock, at that superblock's |
| 30 | // first non-skip block, and only when the frame header's `cdef_bits > 0` |
| 31 | // (`crate::decode::maybe_read_cdef_idx`). The writers below mirror that from |
| 32 | // a plan the filter search hands over, kept in a thread-local rather than |
| 33 | // threaded through every `write_*` signature -- the same shape the decoder's |
| 34 | // own `FrameCtx::cdef_transmitted` uses, and the encoder codes one tile at a |
| 35 | // time on one thread. The plan is CONSUMED by the tile writer that runs next |
| 36 | // ([`CdefIdxGuard`] clears it on every exit path, error included), so a frame |
| 37 | // that arms nothing writes no literals. |
| 38 | |
| 39 | // --------------------------------------------------------------------------- |
| 40 | // lane-av1lr: per-restoration-unit loop restoration syntax (spec 5.11.57, |
| 41 | // `read_lr`), armed by the encoder's restoration search the same way |
| 42 | // [`arm_cdef_idx`] arms the CDEF indices. LUMA ONLY and Wiener only: the |
| 43 | // frame header this encoder writes sets `FrameRestorationType[0] = WIENER` |
| 44 | // and leaves both chroma planes at `RESTORE_NONE`, so a unit codes one |
| 45 | // `restore_wiener` symbol and, when it takes the filter, its two directions |
| 46 | // against the running per-tile reference (`crate::restoration:: |
| 47 | // write_wiener_filter`, the exact inverse of the reader's own |
| 48 | // `read_wiener_filter`). |
| 49 | |
| 50 | /// One frame's per-unit restoration plan (see [`arm_lr`]). |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | thread_local! |
| 67 | |
| 68 | |
| 69 | |
| 70 | /// Arms the next tile write with one Wiener decision per luma restoration |
| 71 | /// unit. An empty `units` disarms (the frame codes no restoration at all). |
| 72 | pub |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | // --------------------------------------------------------------------------- |
| 90 | // lane-sb128: the sequence's `use_128x128_superblock`. Armed per tile write |
| 91 | // like [`arm_lr`] (the encoder codes one tile at a time per thread) rather |
| 92 | // than threaded through every writer signature. When set, the two tile |
| 93 | // writers walk 128x128 superblocks -- loop restoration and one |
| 94 | // `partition_w128` symbol at the 128 root, then the four 64x64 quadrants in |
| 95 | // libaom `decode_partition`'s own TL, TR, BL, BR order -- which is exactly |
| 96 | // what `crate::decode::read_sb128_root` reads. |
| 97 | |
| 98 | thread_local! |
| 99 | |
| 100 | |
| 101 | |
| 102 | /// Arms the next tile write with the sequence's 128x128 superblock size. |
| 103 | pub |
| 104 | |
| 105 | |
| 106 | |
| 107 | /// How many 128x128 superblock roots the writers have coded since the last |
| 108 | /// [`take_sb128_root_hits`] -- a gate reports how often the root fires rather |
| 109 | /// than assuming it does (class `gate-blind-to-feature`). Process-global |
| 110 | /// rather than thread-local because the tiles of one frame are written on |
| 111 | /// worker threads. |
| 112 | static SB128_ROOT_HITS: AtomicUsize = new; |
| 113 | |
| 114 | /// The 128x128-root count since the last call, and zero it. |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | /// Whether the next tile write codes 128x128 superblocks ([`arm_sb128`]). |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | /// The order a tile's 64x64 superblock cells are written in, mirroring |
| 125 | /// `crate::decode::sb_visit_order` exactly: plain raster at a 64 superblock, |
| 126 | /// and TL/TR/BL/BR inside each 128x128 superblock (in raster order over the |
| 127 | /// 128 grid) at a 128 one. The two flags mark the first cell of a superblock |
| 128 | /// ROW (where the left neighbour context resets) and the first cell of a |
| 129 | /// superblock (where the 128 root's own restoration units and partition |
| 130 | /// symbol are written). |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | /// The 128x128 superblock root ([`sb_write_order`]'s `sb_start` cells): the |
| 166 | /// units its own 128-sample span covers, then the partition symbol. Only |
| 167 | /// `PARTITION_SPLIT` is written -- the four 64x64 quadrants below are today's |
| 168 | /// superblocks -- and at a root the true frame edge cuts, the DECIDING |
| 169 | /// gathered bit the decoder reads instead (`read_sb128_root`). |
| 170 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 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 | /// lane-b128: one 128x128 inter block at a `PARTITION_NONE` 128 superblock |
| 215 | /// root -- the syntax `decode_inter_block` reads for `sb128_none` (decode.rs |
| 216 | /// ~35110): `skip`, `is_inter`, the reference/mode chain at the block's own |
| 217 | /// 32x32-mi window, the motion mode, and the transform syntax, with the mi |
| 218 | /// grid and every neighbour band published over all thirty-two mi cells. |
| 219 | /// |
| 220 | /// lane-b128r: a block that carries a RESIDUAL codes it as the four 64x64 mu |
| 221 | /// chunks libaom's `decode_token_recon_block` walks -- per chunk one |
| 222 | /// TX_64X64 luma unit (its coded 32x32 corner, `TxbSet::Luma64`, DCT-only at |
| 223 | /// this size) then one TX_32X32 unit per chroma plane on the offset-10 |
| 224 | /// `txb_skip` rows, each publishing its own coefficient context before the |
| 225 | /// next unit reads it. Its transform syntax is the var-tx tree's four |
| 226 | /// depth-0 `txfm_partition` symbols, one per chunk. The levels arrive packed |
| 227 | /// per plane into a 64-wide grid, chunk (cr, cc) at (cr * 32, cc * 32) |
| 228 | /// ([`crate::encode::search_root_128`]). A skipped block writes no |
| 229 | /// `cdef_idx` and no `delta_q`, exactly as the 64 root's skip arm does. |
| 230 | /// |
| 231 | /// # Errors |
| 232 | /// A block that is intra, that is compound with a residual, or whose var-tx |
| 233 | /// depth is not 0, at this size. |
| 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 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | /// lane-b128hv: one 128x64 (HORZ) or 64x128 (VERT) inter block, the two |
| 481 | /// halves a `PARTITION_HORZ`/`PARTITION_VERT` 128 superblock root carries -- |
| 482 | /// the syntax `decode_inter_block` reads for `sb128_rect` (decode.rs ~35343): |
| 483 | /// the same chain [`write_inter_block_128`] writes, at the block's own |
| 484 | /// rectangular window. Every CDF/context decision is taken at the enclosing |
| 485 | /// square `side` of 128 (what the decoder's `inter_piece!` passes), and the |
| 486 | /// block's true footprint governs only its mv-stack window, its mi/grid stamp |
| 487 | /// and its neighbour bands (decode.rs' own `write_w`/`write_h` split). |
| 488 | /// |
| 489 | /// lane-ab128: also the two 64x64 squares an AB shape codes (the `w == h` |
| 490 | /// arm below) and its 128x64 / 64x128 half. |
| 491 | /// |
| 492 | /// lane-rectres: a piece may CARRY A RESIDUAL -- the search only ever hands |
| 493 | /// one over under `EC_AV1_RECTRES` ([`crate::encode::rectres`]), and then it |
| 494 | /// is coded here exactly as `decode_inter_block` reads it: one TX_64X64 luma |
| 495 | /// unit plus a TX_32X32 chroma pair per 64x64 mu chunk (two chunks for a |
| 496 | /// half, one for a square), each depth-0 in the var-tx tree (a half codes |
| 497 | /// two `txfm_partition` flags under `TxMode::Select`, a square one). |
| 498 | /// |
| 499 | /// # Errors |
| 500 | /// A block that is intra. |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | |
| 512 | |
| 513 | |
| 514 | |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | |
| 568 | |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | |
| 659 | |
| 660 | |
| 661 | |
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 | |
| 668 | |
| 669 | |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | |
| 675 | |
| 676 | |
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | |
| 691 | |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | |
| 718 | |
| 719 | |
| 720 | |
| 721 | |
| 722 | |
| 723 | |
| 724 | |
| 725 | |
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | |
| 731 | |
| 732 | |
| 733 | |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 | |
| 739 | |
| 740 | |
| 741 | |
| 742 | |
| 743 | |
| 744 | |
| 745 | |
| 746 | |
| 747 | |
| 748 | |
| 749 | |
| 750 | |
| 751 | |
| 752 | |
| 753 | |
| 754 | |
| 755 | |
| 756 | |
| 757 | |
| 758 | |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
| 763 | |
| 764 | |
| 765 | /// lane-b128hv: how many 128x64 / 64x128 halves the inter writer has coded |
| 766 | /// since the last [`take_sb128_horz_hits`] / [`take_sb128_vert_hits`] (class |
| 767 | /// `gate-blind-to-feature`). |
| 768 | static SB128_HORZ_HITS: AtomicUsize = new; |
| 769 | /// The VERT twin of [`SB128_HORZ_HITS`]. |
| 770 | static SB128_VERT_HITS: AtomicUsize = new; |
| 771 | |
| 772 | /// The 128x64-half count since the last call, and zero it. |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | /// The 64x128-half count since the last call, and zero it. |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 | /// lane-ab128: how many AB-shape roots the inter writer has coded since the |
| 783 | /// last [`take_sb128_ab_hits`], in `PARTITION_HORZ_A` .. `_VERT_B` order |
| 784 | /// (class `gate-blind-to-feature`). |
| 785 | static SB128_AB_HITS: = |
| 786 | ; |
| 787 | |
| 788 | /// The four per-shape AB-root counts since the last call, and zero them. |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | /// lane-b128r: how many of those blocks carried a REAL residual (four |
| 794 | /// TX_64X64 luma units plus their per-chunk chroma pair) rather than being |
| 795 | /// skipped, since the last [`take_sb128_residual_hits`]. |
| 796 | static SB128_RESIDUAL_HITS: AtomicUsize = new; |
| 797 | |
| 798 | /// The 128x128-with-residual count since the last call, and zero it. |
| 799 | |
| 800 | |
| 801 | |
| 802 | /// lane-rectres: how many RECT/AB pieces (the halves and 64x64 squares |
| 803 | /// [`write_inter_block_128_rect`] codes) carried a REAL residual rather than |
| 804 | /// being skipped, since the last [`take_sb128_rectres_hits`] -- the writer |
| 805 | /// side of [`crate::encode::take_b128_rectres_hits`]'s search count. |
| 806 | static SB128_RECTRES_HITS: AtomicUsize = new; |
| 807 | |
| 808 | /// The rect/AB-piece-with-residual count since the last call, and zero it. |
| 809 | |
| 810 | |
| 811 | |
| 812 | |
| 813 | /// lane-b128r: how many of those blocks named a SECOND reference (the |
| 814 | /// compound arm at the 128 root), since the last |
| 815 | /// [`take_sb128_compound_hits`]. |
| 816 | static SB128_COMPOUND_HITS: AtomicUsize = new; |
| 817 | |
| 818 | /// The compound-128 count since the last call, and zero it. |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | /// How many 128x128 `PARTITION_NONE` blocks the inter writer has coded since |
| 824 | /// the last [`take_sb128_none_hits`] (class `gate-blind-to-feature`). |
| 825 | static SB128_NONE_HITS: AtomicUsize = new; |
| 826 | |
| 827 | /// The 128x128-block count since the last call, and zero it. |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | /// `read_lr`'s write side, called once at the top of every superblock, |
| 833 | /// before its partition symbol: writes the units this superblock's own |
| 834 | /// mi span covers (`av1_loop_restoration_corners_in_sb`; no superres, so the |
| 835 | /// column scaling is the plain mi one). |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 | |
| 841 | |
| 842 | |
| 843 | |
| 844 | |
| 845 | |
| 846 | |
| 847 | |
| 848 | |
| 849 | |
| 850 | |
| 851 | |
| 852 | |
| 853 | |
| 854 | |
| 855 | |
| 856 | |
| 857 | /// A 64x64 superblock's width in 4x4 mode-info units (`SB_MI` in |
| 858 | /// `crate::decode`), the span [`write_lr`] resolves its units over. |
| 859 | const SB_MI_W: u32 = 16; |
| 860 | |
| 861 | /// One tile's own superblock and mode-info span (spec 5.11.1's tile loop |
| 862 | /// bounds): `MiColStarts[i]..MiColStarts[i+1]` and the same down the rows, |
| 863 | /// with the superblock indices those mi bounds fall on. The writers walk |
| 864 | /// exactly this rect, and everything a block reads outside it -- the |
| 865 | /// neighbour bands, the MV grid -- is left at the "unavailable" state a |
| 866 | /// tile's own first row and column see, which is how the decoder clips them |
| 867 | /// (`MiGrid::set_tile_bounds`, `PlaneBuf::set_tile_origin`). |
| 868 | |
| 869 | pub |
| 870 | |
| 871 | |
| 872 | |
| 873 | |
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | |
| 879 | |
| 880 | |
| 881 | |
| 882 | |
| 883 | |
| 884 | |
| 885 | |
| 886 | |
| 887 | |
| 888 | |
| 889 | |
| 890 | |
| 891 | |
| 892 | |
| 893 | |
| 894 | |
| 895 | |
| 896 | |
| 897 | /// A frame's uniform tile grid (spec 5.9.15's `uniform_tile_spacing_flag` |
| 898 | /// arm, mirrored from `ec_av1_syntax::frame::read_tile_info` so that what |
| 899 | /// this encoder writes and what a decoder derives from the same two log2 |
| 900 | /// fields are the same rects). 64x64 superblocks only, which is the only |
| 901 | /// size this encoder's sequence header signals. |
| 902 | |
| 903 | pub |
| 904 | |
| 905 | |
| 906 | |
| 907 | |
| 908 | |
| 909 | |
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | |
| 915 | |
| 916 | |
| 917 | |
| 918 | |
| 919 | |
| 920 | |
| 921 | |
| 922 | |
| 923 | |
| 924 | |
| 925 | |
| 926 | |
| 927 | |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | |
| 934 | |
| 935 | |
| 936 | |
| 937 | |
| 938 | |
| 939 | |
| 940 | |
| 941 | |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | |
| 947 | |
| 948 | |
| 949 | |
| 950 | |
| 951 | |
| 952 | |
| 953 | |
| 954 | |
| 955 | |
| 956 | |
| 957 | |
| 958 | |
| 959 | |
| 960 | |
| 961 | |
| 962 | |
| 963 | |
| 964 | |
| 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | |
| 974 | |
| 975 | |
| 976 | |
| 977 | |
| 978 | |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | |
| 985 | |
| 986 | |
| 987 | |
| 988 | |
| 989 | |
| 990 | |
| 991 | |
| 992 | |
| 993 | |
| 994 | |
| 995 | |
| 996 | |
| 997 | |
| 998 | |
| 999 | |
| 1000 | |
| 1001 | |
| 1002 | |
| 1003 | |
| 1004 | /// lane-edge128: which 64x64 CDEF unit's `cdef_idx` literal covers each unit |
| 1005 | /// of this frame, in the same raster order [`arm_cdef_idx`]'s grid is in. |
| 1006 | /// |
| 1007 | /// `read_cdef` (spec 5.11.56) codes ONE literal for the block that first |
| 1008 | /// reaches a unit and copies it over every unit that block SPANS, so a whole |
| 1009 | /// 128x128 root block puts one literal in the stream for all four of its |
| 1010 | /// units -- the encoder's CDEF search, which prices a preset per unit, may |
| 1011 | /// not hand those four units different presets: only the first would be |
| 1012 | /// coded, and every decoder (ours and ffmpeg's alike) would apply it to all |
| 1013 | /// four while the encoder's own filter replay applied four different ones. |
| 1014 | /// That is the shape this map exists to collapse |
| 1015 | /// ([`crate::filter_search::pick_filters`]). |
| 1016 | /// |
| 1017 | /// lane-rectres: the same holds for a Rect128 half or an Ab128 half that |
| 1018 | /// carries a residual (`EC_AV1_RECTRES`) -- it codes one literal at its own |
| 1019 | /// origin and the decoder stamps BOTH units it spans with it, so its pair is |
| 1020 | /// collapsed onto the origin unit too. Its 64x64 squares cover exactly one |
| 1021 | /// unit each, and a SKIP-ONLY rect/AB piece codes no literal at all (the |
| 1022 | /// decoder's per-piece `cdef_transmitted` reset never fires), so neither |
| 1023 | /// touches this map -- only pieces the writer really codes a residual for. |
| 1024 | pub |
| 1025 | |
| 1026 | |
| 1027 | |
| 1028 | |
| 1029 | |
| 1030 | |
| 1031 | |
| 1032 | |
| 1033 | |
| 1034 | |
| 1035 | |
| 1036 | |
| 1037 | |
| 1038 | |
| 1039 | |
| 1040 | |
| 1041 | |
| 1042 | |
| 1043 | |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | |
| 1048 | |
| 1049 | |
| 1050 | |
| 1051 | |
| 1052 | |
| 1053 | |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | |
| 1059 | |
| 1060 | |
| 1061 | |
| 1062 | |
| 1063 | |
| 1064 | |
| 1065 | |
| 1066 | |
| 1067 | |
| 1068 | |
| 1069 | |
| 1070 | |
| 1071 | |
| 1072 | |
| 1073 | |
| 1074 | |
| 1075 | |
| 1076 | |
| 1077 | |
| 1078 | |
| 1079 | |
| 1080 | |
| 1081 | |
| 1082 | |
| 1083 | |
| 1084 | |
| 1085 | |
| 1086 | |
| 1087 | |
| 1088 | |
| 1089 | |
| 1090 | |
| 1091 | |
| 1092 | |
| 1093 | |
| 1094 | |
| 1095 | /// One frame's per-superblock `cdef_idx` plan (see [`arm_cdef_idx`]). |
| 1096 | |
| 1097 | |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 | |
| 1107 | |
| 1108 | |
| 1109 | thread_local! |
| 1110 | |
| 1111 | |
| 1112 | |
| 1113 | |
| 1114 | /// Arms the next tile write with one `cdef_idx` per 64x64 superblock. |
| 1115 | /// `bits == 0` disarms (the header codes a single strength pair, so the tile |
| 1116 | /// carries no literal at all). |
| 1117 | pub |
| 1118 | |
| 1119 | |
| 1120 | |
| 1121 | |
| 1122 | |
| 1123 | |
| 1124 | |
| 1125 | |
| 1126 | |
| 1127 | |
| 1128 | /// One frame's per-superblock quantizer plan (lane-deltaq, see |
| 1129 | /// [`arm_delta_q`]): the writer side of decode.rs `maybe_read_delta_q`. |
| 1130 | |
| 1131 | |
| 1132 | |
| 1133 | |
| 1134 | |
| 1135 | |
| 1136 | |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | |
| 1146 | thread_local! |
| 1147 | |
| 1148 | |
| 1149 | |
| 1150 | |
| 1151 | /// Arms the next tile write with one absolute `qindex` per 64x64 superblock. |
| 1152 | /// Disarmed (a plain no-op writer, byte for byte what this crate wrote before |
| 1153 | /// lane-deltaq) when `res == 0`. |
| 1154 | pub |
| 1155 | |
| 1156 | |
| 1157 | |
| 1158 | |
| 1159 | |
| 1160 | |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | |
| 1165 | thread_local! |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | |
| 1170 | /// Arms the next tile write with this frame's `ref_frame_sign_bias` (spec |
| 1171 | /// 5.9.2), the table its MV-stack scans run under. Armed the same way |
| 1172 | /// [`arm_cdef_idx`]/[`arm_lr`] are -- and disarmed by the same guard -- so |
| 1173 | /// that a frame with a backward reference needs no new parameter on the four |
| 1174 | /// nested writer helpers between here and `find_mv_stack`. A frame that never |
| 1175 | /// names a future reference leaves this alone: all-`false` is what every |
| 1176 | /// stream this crate wrote before pyramids existed codes under. |
| 1177 | pub |
| 1178 | |
| 1179 | |
| 1180 | |
| 1181 | thread_local! |
| 1182 | |
| 1183 | |
| 1184 | |
| 1185 | /// Arms the next tile write with this frame's `allow_screen_content_tools` |
| 1186 | /// (spec 5.9.2), which is what makes every intra block carry the |
| 1187 | /// `palette_y_mode`/`palette_uv_mode` symbols spec 5.11.46 |
| 1188 | /// `read_palette_mode_info` reads. Armed the same way [`arm_cdef_idx`]/ |
| 1189 | /// [`arm_sign_bias`] are -- and disarmed by the same guard -- so a frame that |
| 1190 | /// never detected screen content writes exactly the stream it wrote before |
| 1191 | /// this lane. |
| 1192 | pub |
| 1193 | |
| 1194 | |
| 1195 | |
| 1196 | thread_local! |
| 1197 | |
| 1198 | |
| 1199 | |
| 1200 | |
| 1201 | |
| 1202 | |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | |
| 1207 | |
| 1208 | /// Arms the next tile write with this frame's `(mi_rows, mi_cols)`. |
| 1209 | pub |
| 1210 | |
| 1211 | |
| 1212 | |
| 1213 | /// The armed `(mi_rows, mi_cols)`, or a grid big enough to clamp nothing. |
| 1214 | |
| 1215 | |
| 1216 | |
| 1217 | |
| 1218 | |
| 1219 | |
| 1220 | |
| 1221 | |
| 1222 | |
| 1223 | |
| 1224 | |
| 1225 | thread_local! |
| 1226 | |
| 1227 | |
| 1228 | |
| 1229 | |
| 1230 | |
| 1231 | |
| 1232 | |
| 1233 | |
| 1234 | |
| 1235 | |
| 1236 | |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | |
| 1241 | /// Arms the frame's `allow_intrabc` bit for the next tile written on this |
| 1242 | /// thread; cleared by [`CdefIdxGuard`] when that writer returns. |
| 1243 | pub |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | |
| 1248 | |
| 1249 | |
| 1250 | |
| 1251 | thread_local! |
| 1252 | |
| 1253 | |
| 1254 | |
| 1255 | |
| 1256 | |
| 1257 | |
| 1258 | |
| 1259 | |
| 1260 | |
| 1261 | /// Arms the sequence's `enable_filter_intra` bit for the next tile written on |
| 1262 | /// this thread; cleared by [`CdefIdxGuard`] when that writer returns. |
| 1263 | pub |
| 1264 | |
| 1265 | |
| 1266 | |
| 1267 | |
| 1268 | |
| 1269 | |
| 1270 | |
| 1271 | /// How many blocks this writer coded `use_filter_intra == 1`, and the |
| 1272 | /// histogram of the five `filter_intra_mode`s (index 1..=5) -- the fire count |
| 1273 | /// a gate prints so that "filter intra is on" is a measurement rather than a |
| 1274 | /// claim (class `gate-blind-to-feature`). Index 0 is the block count. |
| 1275 | static FILTER_INTRA_HITS: = |
| 1276 | ; |
| 1277 | |
| 1278 | /// Reads [`FILTER_INTRA_HITS`] and zeroes it, so a gate can attribute the |
| 1279 | /// counts to its own encode. |
| 1280 | |
| 1281 | pub |
| 1282 | |
| 1283 | |
| 1284 | |
| 1285 | /// `filter_intra_mode_info` (spec 5.11.14) written out, mirrored symbol for |
| 1286 | /// symbol from decode.rs `read_intra_mode`: a `use_filter_intra` flag on every |
| 1287 | /// DC_PRED block whose sides `av1_filter_intra_allowed_bsize` admits (both <= |
| 1288 | /// 32, [`crate::decode::filter_intra_size_class`]) and that took no luma |
| 1289 | /// palette (`av1_filter_intra_allowed`, reconintra.h:77), then the chosen mode |
| 1290 | /// of five. Sits between the palette COLOUR lists and the colour-index maps, |
| 1291 | /// where libaom reads it (`av1_visit_palette` runs after |
| 1292 | /// `read_filter_intra_mode_info`). |
| 1293 | |
| 1294 | |
| 1295 | |
| 1296 | |
| 1297 | |
| 1298 | |
| 1299 | |
| 1300 | |
| 1301 | |
| 1302 | |
| 1303 | |
| 1304 | |
| 1305 | |
| 1306 | |
| 1307 | |
| 1308 | |
| 1309 | |
| 1310 | |
| 1311 | |
| 1312 | |
| 1313 | |
| 1314 | |
| 1315 | |
| 1316 | |
| 1317 | |
| 1318 | |
| 1319 | |
| 1320 | |
| 1321 | |
| 1322 | |
| 1323 | |
| 1324 | |
| 1325 | |
| 1326 | /// The coefficient-table row a block's luma transform types are coded from: |
| 1327 | /// `fimode_to_intradir[filter_intra_mode]` for a filter-intra block, its own |
| 1328 | /// luma mode otherwise (class `filter-intra tx_type row`, decode.rs |
| 1329 | /// [`crate::decode::fi_tx_row`]). The block still PUBLISHES `DC_PRED` as its |
| 1330 | /// neighbour mode -- libaom's `mbmi->mode` is unchanged by filter intra. |
| 1331 | |
| 1332 | |
| 1333 | |
| 1334 | |
| 1335 | /// How many blocks this writer coded `use_intrabc == 1`, and the histogram of |
| 1336 | /// their DV magnitudes in full pels (index 1..=6 = 1, 2, 4, 8, 16, 32 pels |
| 1337 | /// and up, by the larger component) -- the fire count a gate prints so that |
| 1338 | /// "intrabc is on" is a measurement rather than a claim (class |
| 1339 | /// `gate-blind-to-feature`). Index 0 is the block count. |
| 1340 | static INTRABC_HITS: = |
| 1341 | ; |
| 1342 | |
| 1343 | |
| 1344 | |
| 1345 | |
| 1346 | |
| 1347 | |
| 1348 | |
| 1349 | |
| 1350 | /// Reads [`INTRABC_HITS`] and zeroes it, so a gate can attribute the counts |
| 1351 | /// to its own encode. |
| 1352 | // read only from the `#[cfg(test)]` gates |
| 1353 | pub |
| 1354 | |
| 1355 | |
| 1356 | |
| 1357 | thread_local! |
| 1358 | |
| 1359 | |
| 1360 | |
| 1361 | |
| 1362 | |
| 1363 | |
| 1364 | |
| 1365 | |
| 1366 | |
| 1367 | /// Arms the frame's `reference_select` bit for the next tile written on this |
| 1368 | /// thread; cleared by [`CdefIdxGuard`] when that writer returns. |
| 1369 | pub |
| 1370 | |
| 1371 | |
| 1372 | |
| 1373 | thread_local! |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | |
| 1378 | |
| 1379 | |
| 1380 | |
| 1381 | |
| 1382 | thread_local! |
| 1383 | |
| 1384 | |
| 1385 | |
| 1386 | |
| 1387 | |
| 1388 | |
| 1389 | |
| 1390 | |
| 1391 | |
| 1392 | |
| 1393 | |
| 1394 | |
| 1395 | |
| 1396 | |
| 1397 | |
| 1398 | |
| 1399 | /// Arms [`WARPED_MOTION`] for the next tile written on this thread. |
| 1400 | pub |
| 1401 | |
| 1402 | |
| 1403 | |
| 1404 | /// Arms the frame's `is_motion_mode_switchable` bit for the next tile written |
| 1405 | /// on this thread; cleared by [`CdefIdxGuard`] when that writer returns. |
| 1406 | pub |
| 1407 | |
| 1408 | |
| 1409 | |
| 1410 | /// How many single-reference inter blocks this writer coded a `motion_mode` |
| 1411 | /// symbol for, split by the value it coded and by the block's own footprint |
| 1412 | /// -- the histogram a gate prints so that "OBMC is on" is a measurement, not |
| 1413 | /// a claim (class `gate-blind-to-feature`). Index: `0 + 2 * bucket` for |
| 1414 | /// SIMPLE, `1 + 2 * bucket` for OBMC, bucket 0/1/2 = 32x32/16x16/8x8. |
| 1415 | static MOTION_MODE_HITS: = |
| 1416 | ; |
| 1417 | |
| 1418 | /// Reads [`MOTION_MODE_HITS`] and zeroes it, so a gate can attribute the |
| 1419 | /// counts to its own encode. |
| 1420 | // read only from the `#[cfg(test)]` gates |
| 1421 | pub |
| 1422 | |
| 1423 | |
| 1424 | |
| 1425 | /// What the 3-symbol `motion_mode` symbol costs, in bits, against the same |
| 1426 | /// frame tables [`obmc_symbol_bits`] prices the 2-symbol alphabet off -- |
| 1427 | /// which alphabet a block reads is `motion_mode_allowed`'s own choice |
| 1428 | /// ([`write_motion_mode`]). |
| 1429 | pub |
| 1430 | |
| 1431 | |
| 1432 | |
| 1433 | |
| 1434 | |
| 1435 | |
| 1436 | /// What the `motion_mode`/`obmc` symbol costs, in bits, against the tables |
| 1437 | /// this frame's writer really starts from ([`arm_pricing_cdfs`]) -- the same |
| 1438 | /// tables the coefficients are priced off since lane-av1price2, rather than |
| 1439 | /// the static defaults the symbol used to be estimated with. Falls back to |
| 1440 | /// the default table whenever the search is armed with the defaults (a key |
| 1441 | /// frame, or a screen frame the gate turned off). |
| 1442 | pub |
| 1443 | |
| 1444 | |
| 1445 | |
| 1446 | |
| 1447 | |
| 1448 | |
| 1449 | /// `read_motion_mode`'s write side (spec 5.11.24), called on a |
| 1450 | /// single-reference inter block right after its MV syntax and before the |
| 1451 | /// (never switchable here) interpolation filter -- libaom's own sequential |
| 1452 | /// order in `read_inter_block_mode_info`. |
| 1453 | /// |
| 1454 | /// Eligibility is decode.rs' own `motion_mode_eligible`, term for term, with |
| 1455 | /// the terms this writer settles statically dropped: no block it codes is |
| 1456 | /// `skip_mode`, interintra or a non-IDENTITY-global `GLOBALMV` one, so what |
| 1457 | /// is left is the footprint floor and the overlappable-neighbour walk |
| 1458 | /// ([`crate::decode::has_overlappable_neighbour`], shared with the decoder so |
| 1459 | /// the two cannot drift). The frame header keeps `allow_warped_motion == 0`, |
| 1460 | /// so the alphabet is always the 2-symbol `obmc_cdf`, never the 3-symbol |
| 1461 | /// `motion_mode_cdf`. |
| 1462 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. |
| 1463 | |
| 1464 | |
| 1465 | |
| 1466 | |
| 1467 | |
| 1468 | |
| 1469 | |
| 1470 | |
| 1471 | |
| 1472 | |
| 1473 | |
| 1474 | |
| 1475 | |
| 1476 | |
| 1477 | |
| 1478 | |
| 1479 | |
| 1480 | |
| 1481 | |
| 1482 | |
| 1483 | |
| 1484 | |
| 1485 | |
| 1486 | |
| 1487 | |
| 1488 | |
| 1489 | |
| 1490 | |
| 1491 | |
| 1492 | |
| 1493 | |
| 1494 | |
| 1495 | |
| 1496 | |
| 1497 | |
| 1498 | |
| 1499 | |
| 1500 | |
| 1501 | |
| 1502 | |
| 1503 | |
| 1504 | |
| 1505 | |
| 1506 | |
| 1507 | |
| 1508 | |
| 1509 | |
| 1510 | |
| 1511 | |
| 1512 | |
| 1513 | |
| 1514 | |
| 1515 | |
| 1516 | |
| 1517 | |
| 1518 | |
| 1519 | |
| 1520 | |
| 1521 | |
| 1522 | |
| 1523 | |
| 1524 | |
| 1525 | |
| 1526 | |
| 1527 | |
| 1528 | |
| 1529 | |
| 1530 | |
| 1531 | |
| 1532 | |
| 1533 | |
| 1534 | |
| 1535 | |
| 1536 | |
| 1537 | |
| 1538 | |
| 1539 | |
| 1540 | |
| 1541 | |
| 1542 | |
| 1543 | |
| 1544 | |
| 1545 | |
| 1546 | |
| 1547 | |
| 1548 | |
| 1549 | /// The compound half of a block's end-of-block neighbour record: nothing for |
| 1550 | /// a single-reference or intra block, and `record_compound_mi`'s overwrite of |
| 1551 | /// the ALTREF default for a compound one (this writer only codes |
| 1552 | /// `comp_group_idx == 0`, `compound_idx == 1`). |
| 1553 | |
| 1554 | |
| 1555 | |
| 1556 | |
| 1557 | |
| 1558 | |
| 1559 | |
| 1560 | |
| 1561 | |
| 1562 | |
| 1563 | |
| 1564 | /// decode.rs' own `is_uni_comp_ref`: a pair is `UNIDIR_COMP_REFERENCE` |
| 1565 | /// exactly when both references sit on the same temporal side. |
| 1566 | use crateis_uni_comp_ref; |
| 1567 | |
| 1568 | thread_local! |
| 1569 | |
| 1570 | |
| 1571 | |
| 1572 | |
| 1573 | |
| 1574 | |
| 1575 | |
| 1576 | /// Arms this frame's order hints for the next tile written on this thread. |
| 1577 | pub |
| 1578 | |
| 1579 | |
| 1580 | |
| 1581 | /// What [`arm_order_hints`] last armed: `(order_hint_bits, order_hint, |
| 1582 | /// ref_order_hints)`, for the encoder's own per-reference distance. |
| 1583 | pub |
| 1584 | |
| 1585 | |
| 1586 | |
| 1587 | thread_local! |
| 1588 | |
| 1589 | |
| 1590 | |
| 1591 | |
| 1592 | |
| 1593 | |
| 1594 | /// Arms this frame's `allow_high_precision_mv` for the next tile written -- |
| 1595 | /// or searched -- on this thread. |
| 1596 | pub |
| 1597 | |
| 1598 | |
| 1599 | |
| 1600 | /// What [`arm_high_precision_mv`] last armed on this thread. |
| 1601 | pub |
| 1602 | |
| 1603 | |
| 1604 | |
| 1605 | /// lane-hpmv's witness counters: `[0]` counts every `mv_hp`/`mv_class0_hp` |
| 1606 | /// symbol this process's writers coded (zero without |
| 1607 | /// `allow_high_precision_mv`, one per non-zero mv component with it), `[1]` |
| 1608 | /// counts the ones that came out ZERO -- an eighth-pel vector, i.e. one a |
| 1609 | /// frame without the flag cannot name at all. |
| 1610 | static HP_SYMBOLS: = |
| 1611 | |
| 1612 | |
| 1613 | ; |
| 1614 | |
| 1615 | /// Reads and clears [`HP_SYMBOLS`]: `(hp symbols coded, eighth-pel ones)`. |
| 1616 | // read only from the `#[cfg(test)]` witness |
| 1617 | pub |
| 1618 | |
| 1619 | |
| 1620 | |
| 1621 | |
| 1622 | |
| 1623 | |
| 1624 | |
| 1625 | /// [`take_hp_symbols`] without clearing -- what the NEWMV census prints. |
| 1626 | pub |
| 1627 | |
| 1628 | |
| 1629 | |
| 1630 | |
| 1631 | /// Writer-side counterpart of decode.rs `read_compound_ref_frames` (spec |
| 1632 | /// 5.11.25's `comp_reference_type`/`uni_comp_ref`/`comp_ref`/`comp_bwdref` |
| 1633 | /// trees), symbol for symbol at the same contexts -- which are, as that |
| 1634 | /// function's own doc records, `single_ref_p1_ctx`..`single_ref_p6_ctx`/ |
| 1635 | /// `uni_comp_ref_p1_ctx` under libaom's compound names. |
| 1636 | /// |
| 1637 | /// # Errors |
| 1638 | /// A pair this writer never forms (its `ref0` is not `LAST_FRAME`). |
| 1639 | |
| 1640 | |
| 1641 | |
| 1642 | |
| 1643 | |
| 1644 | |
| 1645 | |
| 1646 | |
| 1647 | |
| 1648 | |
| 1649 | |
| 1650 | |
| 1651 | |
| 1652 | |
| 1653 | |
| 1654 | |
| 1655 | |
| 1656 | |
| 1657 | |
| 1658 | |
| 1659 | |
| 1660 | |
| 1661 | |
| 1662 | |
| 1663 | |
| 1664 | |
| 1665 | |
| 1666 | |
| 1667 | |
| 1668 | |
| 1669 | |
| 1670 | |
| 1671 | |
| 1672 | |
| 1673 | |
| 1674 | |
| 1675 | |
| 1676 | |
| 1677 | |
| 1678 | |
| 1679 | |
| 1680 | |
| 1681 | |
| 1682 | |
| 1683 | |
| 1684 | |
| 1685 | |
| 1686 | |
| 1687 | |
| 1688 | |
| 1689 | |
| 1690 | |
| 1691 | |
| 1692 | |
| 1693 | |
| 1694 | |
| 1695 | |
| 1696 | |
| 1697 | |
| 1698 | |
| 1699 | |
| 1700 | |
| 1701 | |
| 1702 | |
| 1703 | |
| 1704 | |
| 1705 | |
| 1706 | |
| 1707 | |
| 1708 | |
| 1709 | |
| 1710 | |
| 1711 | |
| 1712 | |
| 1713 | |
| 1714 | |
| 1715 | |
| 1716 | |
| 1717 | |
| 1718 | |
| 1719 | |
| 1720 | |
| 1721 | /// Per-mode and per-pair fire counts of [`write_compound_block`], for the |
| 1722 | /// gate's own census (gate-blind-to-feature): modes indexed by the spec's |
| 1723 | /// `INTER_COMPOUND_MODES`, pairs by `ref1` (`LAST`..`ALTREF`). |
| 1724 | static COMPOUND_MODE_HITS: = |
| 1725 | ; |
| 1726 | static COMPOUND_PAIR_HITS: = |
| 1727 | ; |
| 1728 | |
| 1729 | /// Takes and clears the compound mode histogram. |
| 1730 | |
| 1731 | pub |
| 1732 | |
| 1733 | |
| 1734 | |
| 1735 | /// Takes and clears the compound pair histogram, indexed by the SECOND |
| 1736 | /// reference (`LAST` = 0 .. `ALTREF` = 6). |
| 1737 | |
| 1738 | pub |
| 1739 | |
| 1740 | |
| 1741 | |
| 1742 | /// Per-SIZE fire counts of [`write_compound_block`], indexed by |
| 1743 | /// `log2(bw4)` (1 = 8x8, 2 = 16x16, 3 = 32x32 and up): compound started as a |
| 1744 | /// 32x32-only tool, so the share by size is what says whether the leaf |
| 1745 | /// candidates fire at all (gate-blind-to-feature). |
| 1746 | static COMPOUND_SIZE_HITS: = |
| 1747 | ; |
| 1748 | |
| 1749 | /// Takes and clears the compound size histogram. |
| 1750 | |
| 1751 | pub |
| 1752 | |
| 1753 | |
| 1754 | |
| 1755 | /// The compound mode histogram of the LEAVES alone (`bw4 <= 4`, so 16x16 and |
| 1756 | /// below). The frame-wide histogram above cannot say whether a mode reaches |
| 1757 | /// the leaves at all, which is exactly the question every leaf compound step |
| 1758 | /// asks (gate-blind-to-feature): before lane-av1comp4 gave a leaf its second |
| 1759 | /// reference search, the two half-new modes were structurally impossible |
| 1760 | /// there and screen capture's leaf compound was 100% `NEAREST_NEARESTMV`. |
| 1761 | static COMPOUND_LEAF_MODE_HITS: = |
| 1762 | ; |
| 1763 | |
| 1764 | /// Takes and clears the leaf-only compound mode histogram. |
| 1765 | |
| 1766 | pub |
| 1767 | |
| 1768 | |
| 1769 | |
| 1770 | |
| 1771 | |
| 1772 | /// Writes one COMPOUND_REFERENCE block's whole mode chain -- the writer side |
| 1773 | /// of decode.rs' `read_compound_ref_frames` / `read_inter_compound_mode` / |
| 1774 | /// `assign_compound_mv` / `comp_group_idx` / `compound_idx` sequence, in that |
| 1775 | /// order. Returns the two motion vectors the decoder derives (what the MI |
| 1776 | /// grid must record) and whether the mode was a `NEW*` one. |
| 1777 | /// |
| 1778 | /// Only the modes [`InterMode::compound_index`] names are written, and |
| 1779 | /// only the `comp_group_idx == 0`, `compound_idx == 1` blend (spec |
| 1780 | /// `COMPOUND_AVERAGE`) -- masked compound and the distance-weighted blend are |
| 1781 | /// not searched. |
| 1782 | /// |
| 1783 | /// # Errors |
| 1784 | /// As [`write_mv`], or a pair/mode this writer does not form. |
| 1785 | |
| 1786 | |
| 1787 | |
| 1788 | |
| 1789 | |
| 1790 | |
| 1791 | |
| 1792 | |
| 1793 | |
| 1794 | |
| 1795 | |
| 1796 | |
| 1797 | |
| 1798 | |
| 1799 | |
| 1800 | |
| 1801 | |
| 1802 | |
| 1803 | |
| 1804 | |
| 1805 | |
| 1806 | |
| 1807 | |
| 1808 | |
| 1809 | |
| 1810 | |
| 1811 | |
| 1812 | |
| 1813 | |
| 1814 | |
| 1815 | |
| 1816 | |
| 1817 | |
| 1818 | |
| 1819 | |
| 1820 | |
| 1821 | |
| 1822 | |
| 1823 | |
| 1824 | |
| 1825 | |
| 1826 | |
| 1827 | |
| 1828 | |
| 1829 | |
| 1830 | |
| 1831 | |
| 1832 | |
| 1833 | |
| 1834 | |
| 1835 | |
| 1836 | |
| 1837 | |
| 1838 | |
| 1839 | |
| 1840 | |
| 1841 | |
| 1842 | |
| 1843 | |
| 1844 | |
| 1845 | |
| 1846 | |
| 1847 | |
| 1848 | |
| 1849 | |
| 1850 | |
| 1851 | |
| 1852 | |
| 1853 | |
| 1854 | |
| 1855 | |
| 1856 | |
| 1857 | |
| 1858 | |
| 1859 | |
| 1860 | |
| 1861 | |
| 1862 | |
| 1863 | |
| 1864 | |
| 1865 | |
| 1866 | |
| 1867 | |
| 1868 | |
| 1869 | |
| 1870 | |
| 1871 | |
| 1872 | |
| 1873 | |
| 1874 | |
| 1875 | |
| 1876 | |
| 1877 | |
| 1878 | |
| 1879 | |
| 1880 | |
| 1881 | |
| 1882 | |
| 1883 | |
| 1884 | |
| 1885 | |
| 1886 | |
| 1887 | |
| 1888 | |
| 1889 | |
| 1890 | |
| 1891 | |
| 1892 | |
| 1893 | |
| 1894 | |
| 1895 | |
| 1896 | |
| 1897 | |
| 1898 | |
| 1899 | |
| 1900 | |
| 1901 | |
| 1902 | |
| 1903 | |
| 1904 | |
| 1905 | |
| 1906 | |
| 1907 | |
| 1908 | |
| 1909 | |
| 1910 | |
| 1911 | |
| 1912 | |
| 1913 | |
| 1914 | |
| 1915 | |
| 1916 | |
| 1917 | |
| 1918 | |
| 1919 | |
| 1920 | |
| 1921 | |
| 1922 | |
| 1923 | |
| 1924 | |
| 1925 | |
| 1926 | |
| 1927 | |
| 1928 | |
| 1929 | |
| 1930 | |
| 1931 | |
| 1932 | |
| 1933 | |
| 1934 | |
| 1935 | |
| 1936 | |
| 1937 | |
| 1938 | |
| 1939 | |
| 1940 | |
| 1941 | |
| 1942 | |
| 1943 | |
| 1944 | |
| 1945 | |
| 1946 | |
| 1947 | |
| 1948 | |
| 1949 | |
| 1950 | |
| 1951 | |
| 1952 | /// Writer-side counterpart of decode.rs `read_comp_mode` (spec 5.11.25's |
| 1953 | /// `comp_mode`): on a `reference_select` frame every inter block whose size |
| 1954 | /// allows compound (`is_comp_ref_allowed`, always true here -- this writer's |
| 1955 | /// smallest leaf is 8x8) names SINGLE or COMPOUND, at |
| 1956 | /// `mvstack::reference_mode_ctx`'s own context off the same two neighbour |
| 1957 | /// bands decode.rs builds its `NeighbourRef` pair from. |
| 1958 | |
| 1959 | |
| 1960 | |
| 1961 | |
| 1962 | |
| 1963 | |
| 1964 | |
| 1965 | |
| 1966 | |
| 1967 | |
| 1968 | |
| 1969 | |
| 1970 | |
| 1971 | |
| 1972 | |
| 1973 | |
| 1974 | |
| 1975 | |
| 1976 | |
| 1977 | |
| 1978 | |
| 1979 | |
| 1980 | |
| 1981 | |
| 1982 | |
| 1983 | /// Clears the armed plan when the tile writer that consumed it returns. |
| 1984 | ; |
| 1985 | |
| 1986 | |
| 1987 | |
| 1988 | |
| 1989 | |
| 1990 | |
| 1991 | |
| 1992 | |
| 1993 | |
| 1994 | |
| 1995 | |
| 1996 | |
| 1997 | |
| 1998 | |
| 1999 | |
| 2000 | |
| 2001 | |
| 2002 | /// `read_cdef`'s write side, called right after every block's `skip` symbol: |
| 2003 | /// writes this superblock's `cdef_idx` literal the first time a non-skip |
| 2004 | /// block of it is coded. `mi` is the block's own position in 4x4 mode-info |
| 2005 | /// units. |
| 2006 | |
| 2007 | |
| 2008 | |
| 2009 | |
| 2010 | |
| 2011 | |
| 2012 | |
| 2013 | |
| 2014 | |
| 2015 | |
| 2016 | |
| 2017 | |
| 2018 | |
| 2019 | |
| 2020 | |
| 2021 | |
| 2022 | |
| 2023 | |
| 2024 | |
| 2025 | /// `read_delta_qindex`'s write side (spec 5.11.10), called right after every |
| 2026 | /// block's [`write_cdef_idx`] -- the spec's own `skip -> cdef -> delta_q` |
| 2027 | /// order, and decode.rs `maybe_read_delta_q` is the reader this mirrors |
| 2028 | /// symbol for symbol. A no-op unless this block sits at its superblock's own |
| 2029 | /// top-left mode-info position, and (the one case the reader skips too) when |
| 2030 | /// that block IS the whole superblock and is skipped, in which case |
| 2031 | /// `CurrentQIndex` carries over unchanged on both sides. |
| 2032 | |
| 2033 | |
| 2034 | |
| 2035 | |
| 2036 | |
| 2037 | |
| 2038 | |
| 2039 | |
| 2040 | |
| 2041 | |
| 2042 | |
| 2043 | |
| 2044 | |
| 2045 | |
| 2046 | |
| 2047 | |
| 2048 | |
| 2049 | |
| 2050 | |
| 2051 | |
| 2052 | |
| 2053 | |
| 2054 | |
| 2055 | |
| 2056 | |
| 2057 | |
| 2058 | |
| 2059 | |
| 2060 | |
| 2061 | |
| 2062 | |
| 2063 | |
| 2064 | |
| 2065 | |
| 2066 | |
| 2067 | |
| 2068 | |
| 2069 | |
| 2070 | |
| 2071 | |
| 2072 | |
| 2073 | |
| 2074 | |
| 2075 | |
| 2076 | |
| 2077 | |
| 2078 | |
| 2079 | |
| 2080 | |
| 2081 | |
| 2082 | |
| 2083 | /// round-4 av1-truesize debugging aid: prints `msg()` to stderr when the |
| 2084 | /// `EC_RNG` environment variable is set, mirroring the `EC_PART`/`EC_TOK` |
| 2085 | /// trace `/tmp/libaom-src`'s debug `aomdec` build already emits under the |
| 2086 | /// same variable, so the two traces line up symbol for symbol. Checked once |
| 2087 | /// per process, so unset (the default) costs one atomic load per call and no |
| 2088 | /// allocation. Only the real tile writer below calls this -- the mode/rate |
| 2089 | /// search's own trial encoders never do -- so the trace does not need the |
| 2090 | /// throwaway-encoder gating a whole-encoder trace would. |
| 2091 | |
| 2092 | |
| 2093 | |
| 2094 | |
| 2095 | |
| 2096 | |
| 2097 | |
| 2098 | |
| 2099 | |
| 2100 | |
| 2101 | |
| 2102 | |
| 2103 | |
| 2104 | |
| 2105 | |
| 2106 | |
| 2107 | /// `PARTITION_NONE` (spec 6.10.4): the whole block, undivided. |
| 2108 | const PARTITION_NONE: usize = 0; |
| 2109 | /// `PARTITION_HORZ` (spec 6.10.4): the block cut into a top and a bottom half. |
| 2110 | const PARTITION_HORZ: usize = 1; |
| 2111 | /// `PARTITION_VERT` (spec 6.10.4): the block cut into a left and a right half. |
| 2112 | const PARTITION_VERT: usize = 2; |
| 2113 | /// `PARTITION_SPLIT` (spec 6.10.4): the block cut into four quadrants. |
| 2114 | const PARTITION_SPLIT: usize = 3; |
| 2115 | |
| 2116 | /// The partition types whose probability mass the split-or-horizontal flag of |
| 2117 | /// a superblock hanging off the bottom of the frame gathers (spec 9.3, |
| 2118 | /// `partition_gather_vert_alike`): the flag says split, so everything vertical |
| 2119 | /// or split lands on it. |
| 2120 | const VERT_ALIKE: = ; |
| 2121 | |
| 2122 | /// The same for a superblock hanging off the right-hand edge |
| 2123 | /// (`partition_gather_horz_alike`). |
| 2124 | const HORZ_ALIKE: = ; |
| 2125 | |
| 2126 | /// Mode-info units across a 32x32 block. |
| 2127 | pub const BLOCK_MI: u32 = SB_MI / 2; |
| 2128 | |
| 2129 | /// Mode-info units across a 16x16 block, the smallest this crate's key-frame |
| 2130 | /// writer codes. |
| 2131 | pub const SUB_MI: u32 = BLOCK_MI / 2; |
| 2132 | |
| 2133 | /// spec `decode_partition`'s `hasRows`/`hasCols` (5.11.4), recomputed at |
| 2134 | /// whichever block size is asking: a block of `side_mi` mode-info units at mi |
| 2135 | /// position `pos` may be coded unsplit (its own `PARTITION_NONE`) only when |
| 2136 | /// this is true in both directions -- the frame's *true* size can put the |
| 2137 | /// boundary inside a superblock, a 32x32 quadrant or (since this writer's |
| 2138 | /// smallest block is 16x16) even a leaf, and each level must ask again with |
| 2139 | /// its own half, not just once at the superblock. |
| 2140 | pub |
| 2141 | |
| 2142 | |
| 2143 | |
| 2144 | /// The number of 32x32 block columns/rows a frame whose *true* (unpadded) |
| 2145 | /// size gives `mi_cols`/`mi_rows` is coded over: every block whose mi origin |
| 2146 | /// (`col * BLOCK_MI`) is inside the true bound is coded, so this is a |
| 2147 | /// ceiling, not the exact division a block-aligned frame would give. Shared |
| 2148 | /// by the tile writer's own iteration and by [`crate::encode`]'s block/ |
| 2149 | /// superblock generation, which must agree with it exactly. |
| 2150 | pub |
| 2151 | |
| 2152 | |
| 2153 | /// `DC_PRED` (spec 6.10.2), as both the luma and the chroma mode. |
| 2154 | const DC_PRED: usize = 0; |
| 2155 | |
| 2156 | /// `V_PRED` (spec 6.10.2), the first of the eight directional intra modes and |
| 2157 | /// so the first mode that carries an angle delta. |
| 2158 | const V_PRED: usize = 1; |
| 2159 | |
| 2160 | /// `H_PRED`, which predicts every row from the column to the block's left. |
| 2161 | |
| 2162 | const H_PRED: usize = 2; |
| 2163 | |
| 2164 | /// The last directional mode, `D67_PRED`. |
| 2165 | const D67_PRED: usize = 8; |
| 2166 | |
| 2167 | /// The number of intra modes a key frame's luma block chooses from, |
| 2168 | /// `INTRA_MODES` (spec 3). |
| 2169 | const INTRA_MODES: usize = 13; |
| 2170 | |
| 2171 | /// `Intra_Mode_Context` (spec 9.3): the five-way class each intra mode puts |
| 2172 | /// its neighbours in when they pick the CDF for the next block's mode. |
| 2173 | pub const INTRA_MODE_CTX: = ; |
| 2174 | |
| 2175 | /// The symbol an angle delta of zero codes as: the alphabet runs from -3 to |
| 2176 | /// +3, so `MAX_ANGLE_DELTA` is the middle of it. |
| 2177 | pub const ANGLE_DELTA_ZERO: usize = 3; |
| 2178 | /// Side of a superblock in 4x4 mode-info units when 128x128 superblocks are off. |
| 2179 | pub const SB_MI: u32 = 16; |
| 2180 | |
| 2181 | /// `NUM_BASE_LEVELS` (spec 3): levels above this carry a base-range tail. |
| 2182 | const NUM_BASE_LEVELS: i32 = 2; |
| 2183 | /// Where DCT_DCT sits in the spec's `Tx_Type_Intra_Inv_Set2`, the set a 16x16 |
| 2184 | /// intra luma transform picks its type from. |
| 2185 | const TX_TYPE_DCT_DCT_SET2: usize = 1; |
| 2186 | /// `COEFF_BASE_RANGE` (spec 3): how far the base-range tail reaches before the |
| 2187 | /// Golomb tail takes over. |
| 2188 | const COEFF_BASE_RANGE: i32 = 12; |
| 2189 | /// `BR_CDF_SIZE - 1` (spec 3): the largest increment one base-range symbol |
| 2190 | /// carries. |
| 2191 | const BR_STEP: i32 = 3; |
| 2192 | /// The largest level the base and base-range syntax carry between them. |
| 2193 | /// Anything above it is written as a Golomb tail on top of this. |
| 2194 | const MAX_BR_LEVEL: i32 = NUM_BASE_LEVELS + COEFF_BASE_RANGE; |
| 2195 | /// The largest level this writer codes. The Golomb tail is a length in unary |
| 2196 | /// followed by that many bits, and the spec's decoder reads at most twenty of |
| 2197 | /// each, so a level a decoder cannot read back is refused rather than written. |
| 2198 | const MAX_LEVEL: i32 = MAX_BR_LEVEL + ; |
| 2199 | |
| 2200 | /// The coefficient q-context (spec 8.3.2's `Get_Qctx`, `Default_..._Cdf`'s |
| 2201 | /// leading index) a frame's `base_q_idx` picks its default CDFs from. |
| 2202 | /// [`crate::cdf`] carries all four, one constant set per context. |
| 2203 | pub |
| 2204 | |
| 2205 | |
| 2206 | |
| 2207 | |
| 2208 | |
| 2209 | |
| 2210 | |
| 2211 | |
| 2212 | /// Both writers here code whole superblocks only: a partial one forces the |
| 2213 | /// partition syntax down the block tree, which they do not code yet. |
| 2214 | /// The probability the CDF gives one symbol on its own. |
| 2215 | |
| 2216 | |
| 2217 | |
| 2218 | |
| 2219 | /// The two-symbol CDF a partial superblock's partition flag is coded with: the |
| 2220 | /// mass of the listed partition types becomes the probability of a split, and |
| 2221 | /// the rest is the one partition the frame edge still allows. |
| 2222 | |
| 2223 | |
| 2224 | |
| 2225 | |
| 2226 | |
| 2227 | |
| 2228 | |
| 2229 | |
| 2230 | |
| 2231 | |
| 2232 | |
| 2233 | |
| 2234 | |
| 2235 | |
| 2236 | |
| 2237 | |
| 2238 | |
| 2239 | |
| 2240 | |
| 2241 | |
| 2242 | /// Writes the payload of a one-tile key frame in which every superblock is a |
| 2243 | /// skipped 64x64 DC-predicted block. |
| 2244 | /// |
| 2245 | /// `mi_cols` and `mi_rows` are the frame's dimensions in 4x4 mode-info units, |
| 2246 | /// as the frame header carries them. |
| 2247 | /// |
| 2248 | /// # Errors |
| 2249 | /// Returns an error when the frame is not a whole number of 64x64 superblocks: |
| 2250 | /// a partial superblock forces the partition syntax down the block tree, which |
| 2251 | /// this writer does not code yet. |
| 2252 | |
| 2253 | |
| 2254 | |
| 2255 | |
| 2256 | |
| 2257 | |
| 2258 | |
| 2259 | |
| 2260 | |
| 2261 | |
| 2262 | |
| 2263 | |
| 2264 | |
| 2265 | |
| 2266 | |
| 2267 | |
| 2268 | |
| 2269 | |
| 2270 | |
| 2271 | |
| 2272 | |
| 2273 | |
| 2274 | |
| 2275 | |
| 2276 | |
| 2277 | |
| 2278 | |
| 2279 | |
| 2280 | |
| 2281 | |
| 2282 | |
| 2283 | |
| 2284 | |
| 2285 | /// Writes the payload of a one-tile key frame in which every superblock is a |
| 2286 | /// 64x64 DC-predicted block carrying one luma DC coefficient of `dc_level` and |
| 2287 | /// no chroma residual. |
| 2288 | /// |
| 2289 | /// `dc_level` is a quantised level, not a sample value: the decoder multiplies |
| 2290 | /// it by the frame's DC quantiser and inverse-transforms it over the whole |
| 2291 | /// block, so the picture it makes is a flat grey some distance either side of |
| 2292 | /// the mid-grey a zero level gives. `base_q_idx` is the frame header's, and |
| 2293 | /// picks the coefficient CDFs. |
| 2294 | /// |
| 2295 | /// # Errors |
| 2296 | /// As [`dc_key_frame_tile_levels`], which this is the one-level case of. |
| 2297 | |
| 2298 | |
| 2299 | |
| 2300 | |
| 2301 | |
| 2302 | |
| 2303 | |
| 2304 | |
| 2305 | |
| 2306 | |
| 2307 | |
| 2308 | /// Writes the payload of a one-tile key frame carrying one luma DC coefficient |
| 2309 | /// per superblock, `levels` giving them in the raster order the superblocks are |
| 2310 | /// coded in. |
| 2311 | /// |
| 2312 | /// Each superblock decodes to a flat block of its own grey, so a frame written |
| 2313 | /// here is a grid of greys the caller chooses — which is what makes the sign |
| 2314 | /// context observable: a block's sign context is read off its coded neighbours, |
| 2315 | /// and a frame whose levels differ in sign exercises the three-way split that a |
| 2316 | /// single-sign frame cannot reach. |
| 2317 | /// |
| 2318 | /// # Errors |
| 2319 | /// Returns an error when the frame is not a whole number of 64x64 superblocks, |
| 2320 | /// when `levels` does not carry exactly one level per superblock, when a level |
| 2321 | /// is outside the range the base and base-range syntax carry (`-14..=14` |
| 2322 | /// without zero). |
| 2323 | |
| 2324 | |
| 2325 | |
| 2326 | |
| 2327 | |
| 2328 | |
| 2329 | |
| 2330 | |
| 2331 | |
| 2332 | |
| 2333 | |
| 2334 | |
| 2335 | |
| 2336 | |
| 2337 | |
| 2338 | |
| 2339 | |
| 2340 | |
| 2341 | |
| 2342 | |
| 2343 | |
| 2344 | |
| 2345 | |
| 2346 | |
| 2347 | |
| 2348 | |
| 2349 | |
| 2350 | |
| 2351 | |
| 2352 | |
| 2353 | |
| 2354 | |
| 2355 | |
| 2356 | |
| 2357 | |
| 2358 | |
| 2359 | |
| 2360 | |
| 2361 | |
| 2362 | |
| 2363 | |
| 2364 | |
| 2365 | |
| 2366 | |
| 2367 | |
| 2368 | |
| 2369 | |
| 2370 | |
| 2371 | |
| 2372 | |
| 2373 | |
| 2374 | |
| 2375 | |
| 2376 | |
| 2377 | |
| 2378 | |
| 2379 | |
| 2380 | |
| 2381 | |
| 2382 | |
| 2383 | |
| 2384 | |
| 2385 | |
| 2386 | |
| 2387 | |
| 2388 | |
| 2389 | |
| 2390 | |
| 2391 | |
| 2392 | |
| 2393 | |
| 2394 | |
| 2395 | |
| 2396 | |
| 2397 | |
| 2398 | /// Writes the payload of a one-tile key frame in which every superblock is |
| 2399 | /// split into four 32x32 DC-predicted blocks, each carrying one luma DC |
| 2400 | /// coefficient and no chroma residual. |
| 2401 | /// |
| 2402 | /// `levels` gives one level per 32x32 block in raster order across the frame, |
| 2403 | /// so the grid is twice as wide and twice as tall as the superblock grid. The |
| 2404 | /// blocks are coded in the z-order a superblock's split walks, but every |
| 2405 | /// block's neighbours above and to its left are coded before it either way, so |
| 2406 | /// the picture reads in raster order. |
| 2407 | /// |
| 2408 | /// # Errors |
| 2409 | /// As [`dc_key_frame_tile_levels`], with `levels` sized for the 32x32 grid. |
| 2410 | |
| 2411 | |
| 2412 | |
| 2413 | |
| 2414 | |
| 2415 | |
| 2416 | |
| 2417 | |
| 2418 | |
| 2419 | |
| 2420 | |
| 2421 | |
| 2422 | |
| 2423 | |
| 2424 | |
| 2425 | |
| 2426 | |
| 2427 | |
| 2428 | |
| 2429 | |
| 2430 | |
| 2431 | |
| 2432 | |
| 2433 | |
| 2434 | |
| 2435 | |
| 2436 | |
| 2437 | |
| 2438 | |
| 2439 | |
| 2440 | |
| 2441 | |
| 2442 | |
| 2443 | |
| 2444 | |
| 2445 | |
| 2446 | |
| 2447 | |
| 2448 | |
| 2449 | |
| 2450 | |
| 2451 | |
| 2452 | |
| 2453 | |
| 2454 | |
| 2455 | |
| 2456 | |
| 2457 | |
| 2458 | |
| 2459 | |
| 2460 | |
| 2461 | |
| 2462 | |
| 2463 | |
| 2464 | |
| 2465 | |
| 2466 | |
| 2467 | |
| 2468 | |
| 2469 | |
| 2470 | |
| 2471 | |
| 2472 | |
| 2473 | |
| 2474 | |
| 2475 | |
| 2476 | |
| 2477 | |
| 2478 | |
| 2479 | |
| 2480 | |
| 2481 | |
| 2482 | |
| 2483 | |
| 2484 | |
| 2485 | |
| 2486 | |
| 2487 | |
| 2488 | |
| 2489 | |
| 2490 | |
| 2491 | |
| 2492 | |
| 2493 | |
| 2494 | pub use *; |
| 2495 | |
| 2496 | |
| 2497 | |
| 2498 | pub use *; |
| 2499 | |
| 2500 | use *; |
| 2501 | |
| 2502 | |
| 2503 |