edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! Inter block shape helpers: the block tx-size readers for rect and inter blocks, the rect residual scan tables and the edge-parameter body. Moved out of `decode/mod.rs` (av1split D13); the items are unchanged apart from visibility. |
| 2 | |
| 3 | use *; |
| 4 | |
| 5 | /// `read_block_tx_size` (libaom `decodeframe.c` `parse_decode_block`'s tx |
| 6 | /// branch): every block of a `TxMode::Select` inter frame codes its transform |
| 7 | /// size right after its own mode info -- an inter non-skip block through the |
| 8 | /// recursive var-tx tree ([`read_var_tx_size`], whose leaf list this returns), |
| 9 | /// every other block through the intra `tx_depth` symbol (a skipped inter |
| 10 | /// block codes no symbol at all) plus a `set_txfm_ctxs` write. Returns the |
| 11 | /// block's own resolved transform side and the leaf list, the latter only |
| 12 | /// when the tree resolved to more than one transform unit. |
| 13 | |
| 14 | pub |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 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 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 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 | /// lane-inter4 r2: the shapes whose *rectangular inter* residual this |
| 210 | /// decoder codes -- a 2:1 strip whose own max rect transform |
| 211 | /// (`max_txsize_rect_lookup[BLOCK_32X16] == TX_32X16`) has both a |
| 212 | /// coefficient table set ([`TxbSet::LumaRect32x16Inter`], 512-coefficient |
| 213 | /// `eob_pt`) and a `tx_type` alphabet here. 64x32/64x16 strips would need a |
| 214 | /// 64-point rect transform, and 16x8/8x16 needs |
| 215 | /// `default_inter_ext_tx_cdf[2][TX_8X8]` (the 12-symbol |
| 216 | /// `DTT9_IDTX_1DDCT` row at `tx_size_sqr == TX_8X8`, only reachable through a |
| 217 | /// rect transform), neither of which exists yet -- both stay refused by name. |
| 218 | pub |
| 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 | // lane-t900 r20: the `(side, write_w, write_h)` triples the inter block path |
| 257 | // actually PRESENTS, as a thread-local bitmask -- the measured domain behind |
| 258 | // the "rectangular ... has no ... here" refusals. `side` is the square context |
| 259 | // a block reads its CDFs at and `write_w`/`write_h` its true footprint; |
| 260 | // `inter_piece!` derives `reject_residual` from exactly that inequality, so |
| 261 | // these triples are what decides whether those refusals can fire at all. Bit |
| 262 | // 31 is "a triple this table does not list", which is what makes the gate a |
| 263 | // census rather than a restatement of its own table. |
| 264 | pub const INTER_BLOCK_SHAPES: = |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | ; |
| 284 | |
| 285 | /// Bit 31 of [`inter_block_shape_mask`]: a `(side, write_w, write_h)` triple |
| 286 | /// outside [`INTER_BLOCK_SHAPES`]. |
| 287 | pub const INTER_BLOCK_SHAPE_UNLISTED: u32 = 1 << 31; |
| 288 | |
| 289 | thread_local! |
| 290 | |
| 291 | |
| 292 | |
| 293 | /// Which of [`INTER_BLOCK_SHAPES`] this THREAD has decoded (thread-local, so a |
| 294 | /// gate reading it sees only the streams it decoded itself). |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | /// The luma coefficient/`tx_type` table set of a whole-block rectangular |
| 300 | /// INTER transform unit (lane-inter4 r3). `av1_get_ext_tx_set_type` splits |
| 301 | /// the two shapes: a 32x16/16x32 unit has `tx_size_sqr_up == TX_32X32`, so |
| 302 | /// it reads the 2-symbol `EXT_TX_SET_DCT_IDTX` set regardless of |
| 303 | /// `reduced_tx_set`; a 16x8/8x16 unit has `tx_size_sqr_up == TX_16X16` and |
| 304 | /// `tx_size_sqr == TX_8X8`, so it reads `EXT_TX_SET_DCT_IDTX` when reduced |
| 305 | /// and the 16-symbol `EXT_TX_SET_ALL16` otherwise -- both at the *8x8* CDF |
| 306 | /// row (`txsize_sqr_map`), never the 16x16 one. |
| 307 | pub |
| 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 | /// The chroma table set of the same block's single rectangular chroma unit |
| 360 | /// (`av1_get_max_uv_txsize`): 16x8/8x16 under a 32x16/16x32 strip, 8x4/4x8 |
| 361 | /// under a 16x8/8x16 one. Neither codes a `tx_type` symbol -- both inherit |
| 362 | /// the luma unit's. |
| 363 | pub |
| 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 | /// libaom `size_group_lookup[bsize]` for the block shapes this decoder's |
| 407 | /// inter path reaches, from the block's TRUE footprint rather than the |
| 408 | /// square `side` corner-cut: 8x8/8x16/16x8 -> 1, 16x16/16x32/32x16 -> 2, |
| 409 | /// everything 32 and above -> 3. |
| 410 | pub |
| 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 | /// The default (2D) coefficient scan of a rectangular transform. |
| 457 | pub |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | /// lane-t900 r20, refusal D -- the three "a rectangular inter luma/chroma |
| 483 | /// transform unit whose shape has no coefficient table set here" / "a |
| 484 | /// rectangular transform unit whose shape has no coefficient scan table here" |
| 485 | /// arms, enumerated against the MEASURED domain of the inter block path |
| 486 | /// ([`INTER_BLOCK_SHAPES`], filled from three real streams by the gate |
| 487 | /// `a_block_shape_census_over_three_real_streams_leaves_the_rect_residual_refusal_unreachable`). |
| 488 | /// |
| 489 | /// What each helper is actually handed: |
| 490 | /// |
| 491 | /// * [`rect_inter_luma_set`] -- the block's own footprint (call sites at the |
| 492 | /// whole-block residual), and a var-tx LEAF shape. `sub_tx_size_map` is |
| 493 | /// square for every rect transform except TX_16X4/TX_4X16, whose leaves are |
| 494 | /// TX_8X4/TX_4X8, so the leaf domain adds exactly 8x4 and 4x8. |
| 495 | /// * [`rect_inter_chroma_set`] -- `(write_w / 2, write_h / 2)` for a 4:2:0 |
| 496 | /// block, except a 16x4/4x16 strip, whose chroma is the PAIR's 8x4 / 4x8. |
| 497 | /// * [`rect_scan`] -- the `min(w, 32) x min(h, 32)` coded corner of a rect |
| 498 | /// unit, and only when that corner is not 32x32 (a square corner goes |
| 499 | /// through the square reader with `rect_shape = Some((w, h))`). |
| 500 | /// |
| 501 | /// The 128-px halves take neither: `max_txsize_rect_lookup[BLOCK_128X64]` is |
| 502 | /// TX_64X64, so they tile into SQUARE 64x64 luma units through the mu-chunk |
| 503 | /// loop, which is why they are skipped below. |
| 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 | /// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2): |
| 573 | /// spec 5.11.17 / libaom `read_tx_size_vartx` starting from the block's own |
| 574 | /// `max_txsize_rect_lookup` entry, which for a 2:1 strip IS rectangular. The |
| 575 | /// depth-0 `txfm_partition` symbol reads its context off the rect transform's |
| 576 | /// own width/height; a `0` leaves one whole-block rect transform unit |
| 577 | /// (`None`), and a `1` splits it into `sub_tx_size_map`'s two SQUARE |
| 578 | /// sub-transforms (`sub_tx_size_map[TX_32X16] == TX_16X16`), from which the |
| 579 | /// ordinary square [`read_var_tx_size`] recursion continues at depth 1 -- so |
| 580 | /// every leaf of a split rect block is square and the existing square leaf |
| 581 | /// loop reconstructs it unchanged. |
| 582 | |
| 583 | pub |
| 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 | /// The chroma half of a whole-block rectangular INTER transform unit (both |
| 746 | /// [`decode_inter_block`] rect readers): `av1_get_max_uv_txsize(bsize)` gives |
| 747 | /// the strip's own rect chroma size at 4:2:0 (one unit for the whole block), |
| 748 | /// but at 4:4:4 the chroma plane block keeps the luma block's 64-px axis, |
| 749 | /// which `av1_get_adjusted_tx_size` caps at 32 (`TX_64X16` -> `TX_32X16`), |
| 750 | /// so it codes TWO units plane-major (every U, then every V -- |
| 751 | /// `decode_token_recon_block`'s inter branch loops `for plane` outside |
| 752 | /// `for blk_row/blk_col` inside the one mu chunk). No unit codes a `tx_type` |
| 753 | /// symbol: each inherits the block-wide luma one (`av1_get_tx_type`'s inter |
| 754 | /// UV lookup at ss 0 reads the tx_type_map at its own mi, which a single-TU |
| 755 | /// luma block fills uniformly). |
| 756 | |
| 757 | pub |
| 758 | |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 | |
| 783 | |
| 784 | |
| 785 | |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 | |
| 797 | |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 | |
| 809 | |
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 | |
| 816 | |
| 817 | |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | |
| 825 | |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 | |
| 841 | |
| 842 | |
| 843 | |
| 844 | |
| 845 | |
| 846 | |
| 847 | |
| 848 | |
| 849 | |
| 850 | |
| 851 | |
| 852 | |
| 853 | |
| 854 | |
| 855 | |
| 856 | |
| 857 | |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | |
| 863 | |
| 864 | |
| 865 | |
| 866 | |
| 867 | |
| 868 | |
| 869 | |
| 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 | |
| 898 | |
| 899 | |
| 900 | |
| 901 | |
| 902 | |
| 903 | |
| 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 | /// [`read_inter_plane`] for a rectangular transform unit (lane-inter4 r2): |
| 953 | /// the coefficients are read with the rect coefficient machinery |
| 954 | /// ([`read_coeffs_rect`], whose `TxClass` handling covers the 1D `V_*`/`H_*` |
| 955 | /// types), inverted with the rect inverse transform |
| 956 | /// ([`dequant_and_inverse_typed_wh`], which carries the 2:1 `sqrt2` scale), |
| 957 | /// and added onto the top-left `w x h` of the block's own square-strided |
| 958 | /// motion-compensated prediction buffer. Returns the *rect* coefficient grid |
| 959 | /// and the coded `tx_type`. |
| 960 | /// |
| 961 | /// `txb_skip_ctx` is 0 for luma: this unit covers the whole block, i.e. |
| 962 | /// `get_txb_ctx`'s `plane_bsize == txsize_to_bsize[tx_size]` branch. |
| 963 | |
| 964 | pub |
| 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 | |
| 1005 | |
| 1006 | |
| 1007 | |
| 1008 | |
| 1009 | |
| 1010 | |
| 1011 | |
| 1012 | |
| 1013 | |
| 1014 | |
| 1015 | |
| 1016 | |
| 1017 | |
| 1018 | |
| 1019 | |
| 1020 | |
| 1021 | |
| 1022 | |
| 1023 | |
| 1024 | |
| 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 | |
| 1096 | |
| 1097 | |
| 1098 | /// The coded `cw x ch` corner of a transform zero-extended into its true |
| 1099 | /// `w x h` grid (a 64-length axis codes only its low 32 coefficients). A |
| 1100 | /// corner that coded nothing stays the shared zero grid -- no allocation |
| 1101 | /// (lane-coefgrid). |
| 1102 | pub |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 | |
| 1107 | |
| 1108 | |
| 1109 | |
| 1110 | |
| 1111 | |
| 1112 | |
| 1113 | |
| 1114 | |
| 1115 | |
| 1116 | /// [`embed_rect_grid`] that keeps the shared zero marker zero: an all-zero |
| 1117 | /// transform unit's grid IS `Grid::Zero` (whose deref is the shared |
| 1118 | /// `ZERO_RESIDUAL`), so re-laying it would read a zero-length slice. |
| 1119 | pub |
| 1120 | |
| 1121 | |
| 1122 | |
| 1123 | |
| 1124 | |
| 1125 | |
| 1126 | /// A rect coefficient grid re-laid into the square `stride x stride` grid the |
| 1127 | /// neighbour/deblock stamps downstream of the residual expect. |
| 1128 | pub |
| 1129 | |
| 1130 | |
| 1131 | |
| 1132 | |
| 1133 | |
| 1134 | |
| 1135 | |
| 1136 | /// One 8x8 inter leaf's luma residual (lane-txselect): either the whole-8x8 |
| 1137 | /// transform, or -- when [`read_block_tx_size`]'s var-tx tree took the single |
| 1138 | /// split a `BLOCK_8X8` can take (`split`) -- the four 4x4 transform units in |
| 1139 | /// raster order, each reading its own coefficient context off the units |
| 1140 | /// already decoded before it. Returns the block's luma grid (all-zero in the |
| 1141 | /// split case, whose reconstruction has already happened unit by unit) and |
| 1142 | /// the `tx_type` chroma inherits: `av1_get_tx_type`'s colocated luma lookup, |
| 1143 | /// which for a split block lands on the top-left unit. |
| 1144 | |
| 1145 | pub |
| 1146 | |
| 1147 | |
| 1148 | |
| 1149 | |
| 1150 | |
| 1151 | |
| 1152 | |
| 1153 | |
| 1154 | |
| 1155 | |
| 1156 | |
| 1157 | |
| 1158 | |
| 1159 | |
| 1160 | |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | |
| 1165 | |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | |
| 1170 | |
| 1171 | |
| 1172 | |
| 1173 | |
| 1174 | |
| 1175 | |
| 1176 | |
| 1177 | |
| 1178 | |
| 1179 | |
| 1180 | |
| 1181 | |
| 1182 | |
| 1183 | |
| 1184 | |
| 1185 | |
| 1186 | |
| 1187 | |
| 1188 | |
| 1189 | |
| 1190 | |
| 1191 | |
| 1192 | |
| 1193 | |
| 1194 | |
| 1195 | |
| 1196 | |
| 1197 | |
| 1198 | |
| 1199 | |
| 1200 | |
| 1201 | |
| 1202 | |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | |
| 1207 | |
| 1208 | |
| 1209 | |
| 1210 | |
| 1211 | |
| 1212 | |
| 1213 | |
| 1214 | |
| 1215 | |
| 1216 | |
| 1217 | |
| 1218 | |
| 1219 | |
| 1220 | |
| 1221 | |
| 1222 | |
| 1223 | |
| 1224 | |
| 1225 | |
| 1226 | |
| 1227 | |
| 1228 | |
| 1229 | |
| 1230 | |
| 1231 | |
| 1232 | /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its |
| 1233 | /// coefficient tables from -- the inter counterpart of [`txbset_for`]. |
| 1234 | /// `av1_get_tx_type`'s chroma tail (libaom `av1/common/blockd.h:1291-1305`): |
| 1235 | /// an inter block's chroma transform inherits the *colocated luma* unit's |
| 1236 | /// coded `tx_type`, then drops back to `DCT_DCT` unless that type is a member |
| 1237 | /// of the extended set the CHROMA transform size selects |
| 1238 | /// (`av1_ext_tx_used[av1_get_ext_tx_set_type(uv_tx, 1, reduced)][tx_type]`, |
| 1239 | /// `blockd.h:1036`/`1097`). lane-golomb r7: we used to force `DCT_DCT` at |
| 1240 | /// every chroma side >= 32, but `av1_get_ext_tx_set_type`'s DCT-only rung is |
| 1241 | /// `tx_size_sqr_up > TX_32X32`; at exactly TX_32X32 an inter block reads |
| 1242 | /// `EXT_TX_SET_DCT_IDTX`, so a 64x64 inter block whose first luma leaf coded |
| 1243 | /// `IDTX` inherits IDTX on its 32x32 chroma units. `IDTX` and `DCT_DCT` are |
| 1244 | /// both `TX_CLASS_2D`, so that mistake left the entropy stream perfectly in |
| 1245 | /// sync and only corrupted the inverse transform (one 64x64 superblock of |
| 1246 | /// high-frequency chroma noise, luma bit-exact). |
| 1247 | pub |
| 1248 | |
| 1249 | |
| 1250 | |
| 1251 | |
| 1252 | |
| 1253 | |
| 1254 | |
| 1255 | |
| 1256 | |
| 1257 | |
| 1258 | |
| 1259 | |
| 1260 | |
| 1261 | /// [`reduce_inherited_chroma_tx_type`] against an explicit `reduced_tx_set` |
| 1262 | /// bit (lane-intertx): the WRITER calls this with the frame's own header bit |
| 1263 | /// ([`crate::cdf_state::Cdfs::reduced_tx_set`]) to derive the type an inter |
| 1264 | /// block's chroma transform is coded with, the same derivation its reader |
| 1265 | /// makes -- it has no `FrameCtx` in reach and must not silently read one |
| 1266 | /// whose value can lag the frame being written (class `stale-context-bit`). |
| 1267 | pub |
| 1268 | |
| 1269 | |
| 1270 | |
| 1271 | |
| 1272 | |
| 1273 | |
| 1274 | |
| 1275 | |
| 1276 | |
| 1277 | |
| 1278 | |
| 1279 | |
| 1280 | |
| 1281 | |
| 1282 | |
| 1283 | |
| 1284 | |
| 1285 | |
| 1286 | |
| 1287 | |
| 1288 | |
| 1289 | |
| 1290 | |
| 1291 | |
| 1292 | |
| 1293 | |
| 1294 | |
| 1295 | |
| 1296 | |
| 1297 | |
| 1298 | |
| 1299 | |
| 1300 | |
| 1301 | |
| 1302 | |
| 1303 | |
| 1304 | |
| 1305 | |
| 1306 | |
| 1307 | /// The [`TxbSet`] a resolved luma transform side reads its coefficient tables |
| 1308 | /// from for a block libaom's `is_inter_block` calls inter -- which an intrabc |
| 1309 | /// block is (`blockd.h:373`), so its `tx_type` comes off the inter `ext_tx` |
| 1310 | /// sets, never the mode-indexed intra ones ([`txbset_for`]). |
| 1311 | /// |
| 1312 | /// 64 is only ever the 64x64-block, depth-0, corner-scanned case |
| 1313 | /// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching |
| 1314 | /// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at |
| 1315 | /// `TX_8X8`/`TX_4X4`: an intra `TX_16X16` always reads `TX_SET_INTRA_2` |
| 1316 | /// regardless of the flag (`av1_get_ext_tx_set_type`'s |
| 1317 | /// `tx_size_sqr == TX_16X16` branch ignores `use_reduced_set` once it is past |
| 1318 | /// the `TX_32X32`/reduced-set checks), so only the 8x8 and 4x4 cases have a |
| 1319 | /// second table ([`TxbSet::Luma8Inter`]/[`TxbSet::Luma4Inter`]). |
| 1320 | /// |
| 1321 | /// lane-av1txr: the intrabc leaf sites used to call a near-duplicate |
| 1322 | /// `txbset_for_inter` whose `4` fell through to `Luma64` -- 32x32-class tables |
| 1323 | /// (a 1024-entry grid) handed to a 4x4 dequant, which panicked at |
| 1324 | /// `transform.rs`'s `inverse_transform_2d_typed_wh` the first time an intrabc |
| 1325 | /// 4x4 TU coded a non-zero coefficient (`allintra0`/cpu-used=0). The |
| 1326 | /// duplicate is gone; every inter-table site goes through this one mapping. |
| 1327 | pub |
| 1328 | |
| 1329 | |
| 1330 | |
| 1331 | |
| 1332 | |
| 1333 | |
| 1334 | |
| 1335 | |
| 1336 | |
| 1337 | |
| 1338 | |
| 1339 | |
| 1340 | |
| 1341 | |
| 1342 | |
| 1343 | |
| 1344 | |
| 1345 | |
| 1346 | /// The luma coefficient scan table for a resolved transform side -- 32/16/8/4, |
| 1347 | /// the only four sizes a `TxMode::Select` block's coded coefficient grid |
| 1348 | /// ([`read_tx_size`]'s resolved side, or 32 at the 64x64 corner case) can be. |
| 1349 | pub |
| 1350 | |
| 1351 | |
| 1352 | |
| 1353 | |
| 1354 | |
| 1355 | |
| 1356 | |
| 1357 | |
| 1358 | |
| 1359 | |
| 1360 | |
| 1361 | |
| 1362 | |
| 1363 | |
| 1364 | |
| 1365 | pub |
| 1366 | |
| 1367 | |
| 1368 | |
| 1369 | |
| 1370 | |
| 1371 | |
| 1372 | |
| 1373 | |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | |
| 1378 | /// `tx_size_wide_unit_log2`/`tx_size_high_unit_log2`: `log2(px / 4)`, the |
| 1379 | /// index [`tx_dim_to_filter_length`] and the chroma 4-vs-6 choice key on. |
| 1380 | |
| 1381 | |
| 1382 | |
| 1383 | |
| 1384 | |
| 1385 | |
| 1386 | |
| 1387 | |
| 1388 | /// spec 7.14.4's `get_filter_level`: `ref_deltas` is indexed by the block's |
| 1389 | /// reference frame, `mode_deltas` by `mode_lf_lut[mode]` -- `0` for |
| 1390 | /// `GLOBALMV`, `1` for `NEARESTMV`/`NEARMV`/`NEWMV` (intra gets no mode |
| 1391 | /// delta). `ref_frame` here is [`Neighbours::ref_grid`]'s packed cell: |
| 1392 | /// magnitude = reference (`0` = intra), sign = `GLOBALMV` (lane-av1golden2: |
| 1393 | /// the flat `mode_deltas[1]` this used before was a `LAST_FRAME`-reachable |
| 1394 | /// wrong delta on every `GLOBALMV` block, masked while any `GOLDEN_FRAME` |
| 1395 | /// block anywhere aborted the whole stream's decode before comparison). |
| 1396 | pub |
| 1397 | |
| 1398 | |
| 1399 | |
| 1400 | |
| 1401 | |
| 1402 | |
| 1403 | |
| 1404 | |
| 1405 | |
| 1406 | |
| 1407 | |
| 1408 | |
| 1409 | |
| 1410 | |
| 1411 | |
| 1412 | |
| 1413 | |
| 1414 | |
| 1415 | |
| 1416 | |
| 1417 | |
| 1418 | |
| 1419 | |
| 1420 | |
| 1421 | |
| 1422 | |
| 1423 | |
| 1424 | |
| 1425 | |
| 1426 | |
| 1427 | |
| 1428 | |
| 1429 | |
| 1430 | |
| 1431 | |
| 1432 | |
| 1433 | |
| 1434 | |
| 1435 | |
| 1436 | |
| 1437 | |
| 1438 | |
| 1439 | |
| 1440 | |
| 1441 | |
| 1442 | |
| 1443 | |
| 1444 | |
| 1445 | |
| 1446 | |
| 1447 | thread_local! |
| 1448 | |
| 1449 | |
| 1450 | |
| 1451 | |
| 1452 | |
| 1453 | |
| 1454 | |
| 1455 | |
| 1456 | |
| 1457 | |
| 1458 | /// `lf_level` over the whole `(base level, ref frame)` domain -- see |
| 1459 | /// [`LVL_CACHE`]. `lf_level`'s own first step is |
| 1460 | /// `(base0 + delta_lf).clamp(0, 63)`, so passing `b - base0` pins its base at |
| 1461 | /// `b` and the rest of the function is a pure function of `(b, ref_frame)`. |
| 1462 | |
| 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 | /// Spec 7.14.2's `set_lpf_parameters`, restricted to the uniform-level, |
| 1504 | /// no-segmentation, no-delta-LF path and to this decoder's own invariant |
| 1505 | /// that a coded block's transform is always its own full size -- so a TU |
| 1506 | /// edge is always also a PU edge, and the "both sides skipped, not a PU |
| 1507 | /// edge" suppression (which only ever fires at a non-PU-edge TU boundary) |
| 1508 | /// never applies here, letting this skip the `skip`/`skip_txfm` lookup |
| 1509 | /// entirely. Returns `None` when this 4-pixel edge group is not filtered. |
| 1510 | /// One plane pass's worth of [`edge_params`] constants (lane-deblock2): the |
| 1511 | /// seven values that used to be re-passed per 4-pixel edge group -- half of |
| 1512 | /// them on the stack, into an `inline(never)` body -- plus libaom's |
| 1513 | /// `lfi->lfthr` idea in level form: `av1_loop_filter_frame_init` builds the |
| 1514 | /// filter level for every `(base level, ref frame)` pair once per frame |
| 1515 | /// instead of running `av1_get_filter_level`'s delta arithmetic per edge. |
| 1516 | pub |
| 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 | |
| 1550 | |
| 1551 | |
| 1552 | |
| 1553 | |
| 1554 | |
| 1555 | |
| 1556 | |
| 1557 | |
| 1558 | |
| 1559 | |
| 1560 | |
| 1561 | |
| 1562 | |
| 1563 | |
| 1564 | |
| 1565 | |
| 1566 | |
| 1567 | |
| 1568 | |
| 1569 | |
| 1570 | |
| 1571 | |
| 1572 | |
| 1573 | |
| 1574 | |
| 1575 | |
| 1576 | |
| 1577 | |
| 1578 | |
| 1579 | |
| 1580 | |
| 1581 | |
| 1582 | |
| 1583 | |
| 1584 | |
| 1585 | |
| 1586 | |
| 1587 | |
| 1588 | |
| 1589 | |
| 1590 | |
| 1591 | |
| 1592 | |
| 1593 | |
| 1594 | |
| 1595 | |
| 1596 | |
| 1597 | /// Spec 7.14.2's `set_lpf_parameters`, restricted to the uniform-level, |
| 1598 | /// no-segmentation, no-delta-LF path and to this decoder's own invariant |
| 1599 | /// that a coded block's transform is always its own full size -- so a TU |
| 1600 | /// edge is always also a PU edge, and the "both sides skipped, not a PU |
| 1601 | /// edge" suppression (which only ever fires at a non-PU-edge TU boundary) |
| 1602 | /// never applies here, letting this skip the `skip`/`skip_txfm` lookup |
| 1603 | /// entirely. Returns `None` when this 4-pixel edge group is not filtered. |
| 1604 | |
| 1605 | pub |
| 1606 | |
| 1607 | |
| 1608 | |
| 1609 | |
| 1610 | |
| 1611 | |
| 1612 | |
| 1613 | |
| 1614 | |
| 1615 | |
| 1616 | |
| 1617 | |
| 1618 | |
| 1619 | |
| 1620 | |
| 1621 | |
| 1622 | |
| 1623 | |
| 1624 | |
| 1625 | |
| 1626 | |
| 1627 | |
| 1628 | |
| 1629 | /// [`edge_params`] past its transform-alignment gate. |
| 1630 | |
| 1631 | pub |
| 1632 | |
| 1633 | |
| 1634 | |
| 1635 | |
| 1636 | |
| 1637 | |
| 1638 | |
| 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 |