edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust375.4 MiB231663eTahinli3 months ago1475 commits
| 1 | //! Sub-pel motion compensation, spec 7.11.3 ("Motion vector scaling process" |
| 2 | //! through "Block inter predictor process"), the REGULAR (`EIGHTTAP`) filter |
| 3 | //! only, 8-bit samples only. |
| 4 | //! |
| 5 | //! A block's inter prediction is separable: an 8-tap horizontal pass over the |
| 6 | //! reference, rounded down by `InterRound0`, feeds an 8-tap vertical pass |
| 7 | //! over that intermediate, rounded down by `InterRound1`. Both fractions run |
| 8 | //! in 1/16-pel steps -- luma motion vectors are stored at 1/8-pel and always |
| 9 | //! land on an even step; chroma vectors, once scaled for subsampling, can |
| 10 | //! land on any of the 16. |
| 11 | |
| 12 | /// `Round2` (spec 4.7): halves round up. |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | /// `InterRound0` (spec 7.11.3.2), 8-bit, non-compound: the shift the |
| 22 | /// horizontal pass's sum is brought down by before it is stored as the |
| 23 | /// intermediate. |
| 24 | const INTER_ROUND_0: u32 = 3; |
| 25 | /// `InterRound1` (spec 7.11.3.2), 8-bit, non-compound: the shift the vertical |
| 26 | /// pass's sum is brought down by to land back on an 8-bit sample. Composed |
| 27 | /// with `INTER_ROUND_0` the two shifts are the filter's own gain (each pass |
| 28 | /// sums to 128, `128 * 128 == 1 << 14 == 1 << (INTER_ROUND_0 + INTER_ROUND_1)`) |
| 29 | /// -- so an identity or DC input comes back exactly, by construction of the |
| 30 | /// table rather than by a fitted constant. |
| 31 | const INTER_ROUND_1: u32 = 11; |
| 32 | |
| 33 | /// `Subpel_Filters[EIGHTTAP]` (spec 7.11.3.3): 16 rows, one per 1/16-pel |
| 34 | /// fraction, each an 8-tap kernel centred so tap index 3 lands on the integer |
| 35 | /// sample (fraction 0 is the identity tap `[.., 128, ..]`). |
| 36 | const SUBPEL_FILTERS: = |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | ; |
| 54 | |
| 55 | /// `Subpel_Filters[EIGHTTAP]`'s narrow-block counterpart (spec 7.11.3.4's |
| 56 | /// filter selection is per-axis: a `predict` axis whose output block |
| 57 | /// dimension is 4 or less reads this table instead of [`SUBPEL_FILTERS`]), |
| 58 | /// mirroring `av1_sub_pel_filters_4` (`filter.h`): the same 8-slot shape but |
| 59 | /// zeroed at taps 0/1/6/7, so a 4-wide (or 4-tall) block's filter never |
| 60 | /// reaches a full 3 samples past its own edge. Every 4:2:0 chroma block |
| 61 | /// under an 8x8 (or smaller) luma leaf hits this on at least one axis -- |
| 62 | /// this is not an edge case, it is the common chroma shape. |
| 63 | const SUBPEL_FILTERS_4: = |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | ; |
| 81 | |
| 82 | /// `Subpel_Filters[EIGHTTAP_SMOOTH]` (`filter.h`'s `av1_sub_pel_filters_8smooth`). |
| 83 | const SUBPEL_FILTERS_SMOOTH: = |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | ; |
| 101 | |
| 102 | /// `SUBPEL_FILTERS_SMOOTH`'s narrow-block counterpart (`av1_sub_pel_filters_4smooth`). |
| 103 | const SUBPEL_FILTERS_SMOOTH_4: = |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | ; |
| 121 | |
| 122 | /// `Subpel_Filters[EIGHTTAP_SHARP]` (`av1_sub_pel_filters_8sharp`). A block |
| 123 | /// whose dimension is 4 or less does NOT read this table: spec 7.11.3.4's |
| 124 | /// `filterIdx` sends both EIGHTTAP and EIGHTTAP_SHARP to filter index 4, and |
| 125 | /// libaom agrees -- `av1_interp_4tap[MULTITAP_SHARP]` is `av1_sub_pel_filters_4`, |
| 126 | /// the REGULAR narrow kernel (`filter.h:243`), not a sharp one (lane-gmaffine r5). |
| 127 | const SUBPEL_FILTERS_SHARP: = |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | ; |
| 145 | |
| 146 | /// `Subpel_Filters[BILINEAR]` (`av1_bilinear_filters`) -- also never swapped |
| 147 | /// for a narrow-block table (it is already only 2 non-zero taps). |
| 148 | const SUBPEL_FILTERS_BILINEAR: = |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | ; |
| 166 | |
| 167 | /// Which of the spec's four `interpolation_filter` kernels a block's motion |
| 168 | /// compensation reads (spec 6.8.9 / `frame_header`'s `interpolation_filter`). |
| 169 | /// A frame codes exactly one of these when not `Switchable`; a `Switchable` |
| 170 | /// frame codes one per block per direction (spec 5.11.20's |
| 171 | /// `read_interp_filter`, see `decode::decode_inter_block`), so `predict`'s |
| 172 | /// callers resolve `Switchable` to a concrete pair of kinds themselves -- |
| 173 | /// this type only ever names the resolved kernel, never `Switchable` itself. |
| 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 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | /// A reference sample at `(x, y)`, clamped to the frame's true (unpadded) |
| 227 | /// extent -- `true_width`/`true_height`, which can be narrower than |
| 228 | /// `stride` -- rather than read out of range (spec 7.11.3.4's `Clip3` |
| 229 | /// against the frame's edges): a motion vector that points past the true |
| 230 | /// edge repeats the true edge's sample instead of panicking or picking up |
| 231 | /// whatever this encoder's own uncoded padding columns/rows hold. |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | /// Predicts one `block_w * block_h` block into `dst`, row-major, from |
| 247 | /// `reference` (row-major, stride `stride`, true content |
| 248 | /// `true_width` x `true_height` -- a reference frame's decoded picture |
| 249 | /// buffer can be wider/taller than the true frame it holds, when this |
| 250 | /// encoder pads a picture to a whole number of superblocks; a spec decoder |
| 251 | /// never codes syntax for those extra columns/rows, so motion compensation |
| 252 | /// must clamp to the true extent, not the buffer's own stride). |
| 253 | /// |
| 254 | /// `x_q4` / `y_q4` are the block's top-left position in the reference, in |
| 255 | /// 1/16-pel units (an integer MV has its low 4 bits zero); this function |
| 256 | /// splits each into its whole-sample part and its 0..16 fraction itself, so |
| 257 | /// the caller need not pre-split a motion vector. |
| 258 | /// |
| 259 | /// # Panics |
| 260 | /// Panics when `dst` is not `block_w * block_h` long, or the reference is |
| 261 | /// empty. |
| 262 | // one reference plane, one position, one block shape |
| 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 | /// [`predict`], selecting the interpolation filter kernel explicitly (spec |
| 289 | /// 6.8.9's `interpolation_filter`) instead of always `Regular` -- the same |
| 290 | /// kernel both directions. |
| 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 | /// [`predict_with_filter`], with the horizontal (`interp_filter[0]`) and |
| 320 | /// vertical (`interp_filter[1]`) kernels chosen independently -- spec |
| 321 | /// 5.11.20's per-block `SWITCHABLE` read is per-direction (`enable_dual_filter`), |
| 322 | /// so the two passes can genuinely differ. |
| 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 | /// `REF_SCALE_SHIFT`'s "no scaling" value (spec 7.11.3.3, libaom `scale.h` |
| 419 | /// `REF_NO_SCALE`): `x_scale_fp == REF_NO_SCALE` means the stored reference's |
| 420 | /// luma width equals the current frame's, so [`predict_scaled`] reduces |
| 421 | /// exactly to [`predict_with_filters`] (verified in |
| 422 | /// `predict_scaled_at_no_scale_matches_predict_with_filters` below). |
| 423 | pub const REF_NO_SCALE: i64 = 1 << 14; |
| 424 | |
| 425 | /// The horizontal scale ratio spec 7.11.3.3 derives from luma widths only |
| 426 | /// (libaom `av1_setup_scale_factors_for_frame`, luma widths, `REF_SCALE_SHIFT |
| 427 | /// == 14`): `other_width` is the stored reference picture's own luma width, |
| 428 | /// `this_width` the current frame's coded luma width. AV1 superres never |
| 429 | /// scales height (r8's derivation), so there is no vertical counterpart. |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | thread_local! |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | /// Current value of [`PREDICT_SCALED_HITS`]. |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | thread_local! |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | /// Current value of [`INTER_PRED_HITS`]. |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | /// `ROUND_POWER_OF_TWO_SIGNED` (libaom `common/common.h`): halves round away |
| 471 | /// from zero's *magnitude* -- negative inputs are rounded like their |
| 472 | /// negation, not truncated toward zero the way a plain arithmetic shift |
| 473 | /// would. |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | /// Spec 7.11.3.3's horizontal pass on a (possibly) scaled reference, shared |
| 483 | /// by [`predict_scaled`] and [`predict_compound_intermediate`] -- the two |
| 484 | /// differ only in their VERTICAL rounding ([`INTER_ROUND_1`] vs |
| 485 | /// [`INTER_ROUND_1_COMPOUND`]), never here. Each output column walks the |
| 486 | /// reference by `x_step_qn` (the Q14 scale rounded down to the Q10 |
| 487 | /// `SCALE_SUBPEL_BITS` grid) and picks its own filter phase from the low |
| 488 | /// bits, so `x_scale_fp == REF_NO_SCALE` reduces to the ordinary stride-1 |
| 489 | /// whole-pel walk with one fixed phase (pinned by |
| 490 | /// `predict_scaled_at_no_scale_matches_predict_with_filters`). |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 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 | /// [`predict_with_filters`]'s scaled-reference counterpart (spec 7.11.3.3): |
| 531 | /// used only when the stored reference's luma width differs from the current |
| 532 | /// frame's (`use_superres` on a non-key frame). `x_scale_fp` is |
| 533 | /// [`scale_factor`]'s ratio ([`REF_NO_SCALE`] reproduces |
| 534 | /// `predict_with_filters` bit-exact, pinned by |
| 535 | /// `predict_scaled_at_no_scale_matches_predict_with_filters`). Per r8's |
| 536 | /// derivation AV1 superres never scales height, so `y_q4`'s whole-sample / |
| 537 | /// fraction split and the vertical pass are untouched -- only the horizontal |
| 538 | /// pass's per-column integer position and filter phase come from a scaled |
| 539 | /// walk (`x_qn`) instead of a fixed stride-1 one. |
| 540 | /// |
| 541 | /// # Panics |
| 542 | /// Panics when `dst` is not `block_w * block_h` long, or the reference is |
| 543 | /// empty. |
| 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 | /// `InterRound1` for a compound ref (spec 7.11.3.2's `isCompound` branch, |
| 606 | /// `COMPOUND_ROUND1_BITS` in libaom's `convolve.h`): 4 bits shallower than |
| 607 | /// [`INTER_ROUND_1`] so the vertical pass lands in the `CONV_BUF` domain |
| 608 | /// (still above 8-bit pixel range) instead of a finished sample -- |
| 609 | /// `predict_compound_intermediate` below stops there and leaves the final |
| 610 | /// clip to whichever combine step (simple/distance-weighted average, or a |
| 611 | /// future masked blend) runs on the pair of intermediates. |
| 612 | const INTER_ROUND_1_COMPOUND: u32 = 7; |
| 613 | |
| 614 | /// `InterPostRound` (spec 7.11.3.2): `2 * FILTER_BITS - (InterRound0 + |
| 615 | /// InterRound1)` with the *compound* `InterRound1` above -- `2*7 - (3+7) == |
| 616 | /// 4`. [`combine_compound`] folds this together with `DIST_PRECISION_BITS` |
| 617 | /// (below) into one final shift. |
| 618 | const INTER_POST_ROUND: u32 = 4; |
| 619 | |
| 620 | /// `DIST_PRECISION_BITS` (spec 7.11.3.15 / libaom `enums.h`): the two |
| 621 | /// weights [`combine_compound`] takes always sum to `1 << 4 == 16`, whether |
| 622 | /// they are the simple-average split (8/8) or a distance-weighted split |
| 623 | /// from [`crate::compound::dist_wtd_comp_weight_assign`]. |
| 624 | const DIST_PRECISION_BITS: u32 = 4; |
| 625 | |
| 626 | /// [`predict_with_filters`]'s compound counterpart: same two-pass separable |
| 627 | /// filter, but the vertical pass rounds by [`INTER_ROUND_1_COMPOUND`] |
| 628 | /// instead of [`INTER_ROUND_1`] and is never clipped to a pixel -- the |
| 629 | /// `CONV_BUF` intermediate domain spec 7.11.3.2 keeps a compound block's two |
| 630 | /// per-reference predictions in until [`combine_compound`] blends them. |
| 631 | /// `dst` receives one `i32` per sample, row-major, same shape as |
| 632 | /// [`predict_with_filters`]'s `u8` `dst`. |
| 633 | /// |
| 634 | /// # Panics |
| 635 | /// Panics when `dst` is not `block_w * block_h` long, or the reference is |
| 636 | /// empty. |
| 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 | /// Blends two [`predict_compound_intermediate`] outputs into a finished |
| 698 | /// 8-bit block (spec 7.11.3.15's weighted-average combine, the |
| 699 | /// `comp_group_idx == 0` path -- `fwd_weight`/`bck_weight` are either the |
| 700 | /// simple-average split `(8, 8)` or [`crate::compound::dist_wtd_comp_weight_assign`]'s |
| 701 | /// output; both always sum to `1 << DIST_PRECISION_BITS`). Masked compound |
| 702 | /// (`comp_group_idx == 1`, wedge/diffwtd) is a different combine this |
| 703 | /// function does not cover -- decode.rs still refuses those by name. |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | |
| 718 | |
| 719 | |
| 720 | |
| 721 | |
| 722 | |
| 723 | |
| 724 | |
| 725 | |
| 726 | |
| 727 | /// lane-maskcomp r2: `build_compound_diffwtd_mask` (reconinter.c) -- |
| 728 | /// `DIFFWTD_38`/`DIFFWTD_38_INV` (`mask_type` bit: 0/1). Operates directly on |
| 729 | /// the two [`predict_compound_intermediate`] outputs: libaom's own |
| 730 | /// `av1_build_compound_diffwtd_mask_d16_c` runs on its CONV_BUF domain (which |
| 731 | /// carries a constant `round_offset` bias baked into every sample by its |
| 732 | /// convolve stage), but `abs(src0 - src1)` cancels an equal bias on both |
| 733 | /// sides exactly, so the unbiased `i32` intermediates this crate already |
| 734 | /// produces give the identical `diff` libaom computes. `round` is |
| 735 | /// `2*FILTER_BITS - round_0 - round_1 + (bd-8)` == [`INTER_POST_ROUND`] for |
| 736 | /// 8-bit content (`round_0=3`, compound `round_1=7`, `bd=8`). |
| 737 | |
| 738 | |
| 739 | |
| 740 | |
| 741 | |
| 742 | |
| 743 | |
| 744 | |
| 745 | |
| 746 | |
| 747 | |
| 748 | |
| 749 | |
| 750 | |
| 751 | |
| 752 | |
| 753 | /// lane-maskcomp r2: `aom_lowbd_blend_a64_d16_mask_c` (blend_a64_mask.c), |
| 754 | /// algebraically simplified to this crate's unbiased `i32` intermediate |
| 755 | /// domain the same way [`diffwtd_mask`]'s doc comment derives -- libaom's |
| 756 | /// `res -= round_offset` step cancels exactly against the bias `m + (64-m) |
| 757 | /// == 64` contributes equally from both inputs, leaving `(m*pred0 + |
| 758 | /// (64-m)*pred1) >> 6` (a plain, unrounded shift, matching the C `>>` on |
| 759 | /// `int32_t`) then one final [`round2`] by [`INTER_POST_ROUND`]. `mask` is |
| 760 | /// always the LUMA-resolution mask (`mask_stride` == luma block width); |
| 761 | /// `subsampled` selects the 2x2-average chroma read (spec 7.11.3.14 / |
| 762 | /// libaom's `subw == 1 && subh == 1` branch) vs. the direct luma read. |
| 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 | /// Whole-pel identity case: [`predict_compound_intermediate`]'s two-pass |
| 798 | /// filter reduces to `16 * source_sample` exactly (the fraction-0 row is a |
| 799 | /// single `128` tap both passes, and `128*128 == 1 << 14`, `14 - 7 == 7 == |
| 800 | /// INTER_ROUND_1_COMPOUND`, so the extra `2^4` of gain the compound path |
| 801 | /// keeps over [`predict`]'s 11-bit round survives untouched) -- |
| 802 | /// [`combine_compound`] then divides that back out exactly with an 8/8 |
| 803 | /// simple-average weight split, so a compound block whose two references |
| 804 | /// (and MVs) happen to coincide reproduces the plain source sample, not an |
| 805 | /// off-by-one from double rounding. |
| 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 | |
| 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 | |
| 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 | |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 | |
| 1107 | |
| 1108 | |
| 1109 | |
| 1110 | |
| 1111 | |
| 1112 | |
| 1113 | |
| 1114 | |
| 1115 | |
| 1116 | |
| 1117 | |
| 1118 | |
| 1119 | |
| 1120 | |
| 1121 | |
| 1122 | |
| 1123 | |
| 1124 | |
| 1125 | |
| 1126 | |
| 1127 | |
| 1128 | |
| 1129 | |
| 1130 | |
| 1131 | |
| 1132 | |
| 1133 | |
| 1134 | |
| 1135 | |
| 1136 | |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | |
| 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 |