wip(av1): mvstack global-motion substitution plumbing (inert: NO_GM_MV, all flags false)
Browse files at this commit149fd7a013aea9d68f6449c0a309a6076be0856aParent: 9f844b14 changed files +138 -14
- crates/ec-av1/src/decode.rs +23 -0
- crates/ec-av1/src/encode.rs +12 -0
- crates/ec-av1/src/mvstack.rs +87 -14
- crates/ec-av1/src/tile.rs +16 -0
crates/ec-av1/src/decode.rsmodified+23 -0
| @@ -5422,6 +5422,8 @@ fn decode_inter_block( | |||
| 5422 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), | 5422 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 5423 | size: bw4, | 5423 | size: bw4, |
| 5424 | size_h: bh4, | 5424 | size_h: bh4, |
| 5425 | + is_global_mv0: false, | ||
| 5426 | + is_global_mv1: false, | ||
| 5425 | }, | 5427 | }, |
| 5426 | ); | 5428 | ); |
| 5427 | } | 5429 | } |
| @@ -6035,6 +6037,15 @@ fn decode_inter_block( | |||
| 6035 | mi_cols as usize, | 6037 | mi_cols as usize, |
| 6036 | mi_rows as usize, | 6038 | mi_rows as usize, |
| 6037 | sign_bias_table, | 6039 | sign_bias_table, |
| 6040 | + // lane-gm r2: gm_get_motion_vector + mvstack substitution are | ||
| 6041 | + // ported and unit-tested (warp.rs, mvstack.rs) but not yet | ||
| 6042 | + // wired to this frame's real `global_motion` table -- every | ||
| 6043 | + // `MiInfo` this decoder ever writes still sets | ||
| 6044 | + // `is_global_mv0`/`is_global_mv1` to `false` (see the ctor | ||
| 6045 | + // sites), so the substitution path this table would feed is | ||
| 6046 | + // never taken yet. `NO_GM_MV` keeps this call exactly as | ||
| 6047 | + // inert as the old 0-arg call was. | ||
| 6048 | + &crate::mvstack::NO_GM_MV, | ||
| 6038 | tpl, | 6049 | tpl, |
| 6039 | ); | 6050 | ); |
| 6040 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 6051 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| @@ -6360,6 +6371,8 @@ fn decode_inter_block( | |||
| 6360 | is_new_mv, | 6371 | is_new_mv, |
| 6361 | size: bw4, | 6372 | size: bw4, |
| 6362 | size_h: bh4, | 6373 | size_h: bh4, |
| 6374 | + is_global_mv0: false, | ||
| 6375 | + is_global_mv1: false, | ||
| 6363 | }, | 6376 | }, |
| 6364 | ); | 6377 | ); |
| 6365 | } | 6378 | } |
| @@ -6606,6 +6619,8 @@ fn decode_inter_block( | |||
| 6606 | is_new_mv: false, | 6619 | is_new_mv: false, |
| 6607 | size: side / 4, | 6620 | size: side / 4, |
| 6608 | size_h: side / 4, | 6621 | size_h: side / 4, |
| 6622 | + is_global_mv0: false, | ||
| 6623 | + is_global_mv1: false, | ||
| 6609 | }, | 6624 | }, |
| 6610 | ); | 6625 | ); |
| 6611 | } | 6626 | } |
| @@ -7067,6 +7082,8 @@ fn decode_inter_block8( | |||
| 7067 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), | 7082 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 7068 | size: 2, | 7083 | size: 2, |
| 7069 | size_h: 2, | 7084 | size_h: 2, |
| 7085 | + is_global_mv0: false, | ||
| 7086 | + is_global_mv1: false, | ||
| 7070 | }, | 7087 | }, |
| 7071 | ); | 7088 | ); |
| 7072 | } | 7089 | } |
| @@ -7454,6 +7471,8 @@ fn decode_inter_block8( | |||
| 7454 | is_new_mv, | 7471 | is_new_mv, |
| 7455 | size: 2, | 7472 | size: 2, |
| 7456 | size_h: 2, | 7473 | size_h: 2, |
| 7474 | + is_global_mv0: false, | ||
| 7475 | + is_global_mv1: false, | ||
| 7457 | }, | 7476 | }, |
| 7458 | ); | 7477 | ); |
| 7459 | } | 7478 | } |
| @@ -7648,6 +7667,8 @@ fn decode_inter_block8( | |||
| 7648 | is_new_mv: false, | 7667 | is_new_mv: false, |
| 7649 | size: 2, | 7668 | size: 2, |
| 7650 | size_h: 2, | 7669 | size_h: 2, |
| 7670 | + is_global_mv0: false, | ||
| 7671 | + is_global_mv1: false, | ||
| 7651 | }, | 7672 | }, |
| 7652 | ); | 7673 | ); |
| 7653 | } | 7674 | } |
| @@ -9765,6 +9786,8 @@ mod tests { | |||
| 9765 | is_new_mv: false, | 9786 | is_new_mv: false, |
| 9766 | size: 1, | 9787 | size: 1, |
| 9767 | size_h: 1, | 9788 | size_h: 1, |
| 9789 | + is_global_mv0: false, | ||
| 9790 | + is_global_mv1: false, | ||
| 9768 | }; | 9791 | }; |
| 9769 | for col in mi_col..mi_col + bw4 { | 9792 | for col in mi_col..mi_col + bw4 { |
| 9770 | grid.set(mi_row - 1, col, neighbour(above_mv)); | 9793 | grid.set(mi_row - 1, col, neighbour(above_mv)); |
crates/ec-av1/src/encode.rsmodified+12 -0
| @@ -2618,6 +2618,8 @@ pub(crate) fn encode_inter_frame( | |||
| 2618 | is_new_mv: matches!(info.mode, InterMode::NewMv), | 2618 | is_new_mv: matches!(info.mode, InterMode::NewMv), |
| 2619 | size: 8, | 2619 | size: 8, |
| 2620 | size_h: 8, | 2620 | size_h: 8, |
| 2621 | + is_global_mv0: false, | ||
| 2622 | + is_global_mv1: false, | ||
| 2621 | }, | 2623 | }, |
| 2622 | // Intra: no vote, but still a coded cell | 2624 | // Intra: no vote, but still a coded cell |
| 2623 | // -- mvstack's extended-scan coverage | 2625 | // -- mvstack's extended-scan coverage |
| @@ -2632,6 +2634,8 @@ pub(crate) fn encode_inter_frame( | |||
| 2632 | is_new_mv: false, | 2634 | is_new_mv: false, |
| 2633 | size: 8, | 2635 | size: 8, |
| 2634 | size_h: 8, | 2636 | size_h: 8, |
| 2637 | + is_global_mv0: false, | ||
| 2638 | + is_global_mv1: false, | ||
| 2635 | }, | 2639 | }, |
| 2636 | }, | 2640 | }, |
| 2637 | ); | 2641 | ); |
| @@ -2712,6 +2716,8 @@ pub(crate) fn encode_inter_frame( | |||
| 2712 | is_new_mv: matches!(info.mode, InterMode::NewMv), | 2716 | is_new_mv: matches!(info.mode, InterMode::NewMv), |
| 2713 | size: 4, | 2717 | size: 4, |
| 2714 | size_h: 4, | 2718 | size_h: 4, |
| 2719 | + is_global_mv0: false, | ||
| 2720 | + is_global_mv1: false, | ||
| 2715 | }, | 2721 | }, |
| 2716 | None => MiInfo { | 2722 | None => MiInfo { |
| 2717 | is_inter: false, | 2723 | is_inter: false, |
| @@ -2722,6 +2728,8 @@ pub(crate) fn encode_inter_frame( | |||
| 2722 | is_new_mv: false, | 2728 | is_new_mv: false, |
| 2723 | size: 4, | 2729 | size: 4, |
| 2724 | size_h: 4, | 2730 | size_h: 4, |
| 2731 | + is_global_mv0: false, | ||
| 2732 | + is_global_mv1: false, | ||
| 2725 | }, | 2733 | }, |
| 2726 | }, | 2734 | }, |
| 2727 | ); | 2735 | ); |
| @@ -2771,6 +2779,8 @@ pub(crate) fn encode_inter_frame( | |||
| 2771 | ), | 2779 | ), |
| 2772 | size: 2, | 2780 | size: 2, |
| 2773 | size_h: 2, | 2781 | size_h: 2, |
| 2782 | + is_global_mv0: false, | ||
| 2783 | + is_global_mv1: false, | ||
| 2774 | }, | 2784 | }, |
| 2775 | None => MiInfo { | 2785 | None => MiInfo { |
| 2776 | is_inter: false, | 2786 | is_inter: false, |
| @@ -2781,6 +2791,8 @@ pub(crate) fn encode_inter_frame( | |||
| 2781 | is_new_mv: false, | 2791 | is_new_mv: false, |
| 2782 | size: 2, | 2792 | size: 2, |
| 2783 | size_h: 2, | 2793 | size_h: 2, |
| 2794 | + is_global_mv0: false, | ||
| 2795 | + is_global_mv1: false, | ||
| 2784 | }, | 2796 | }, |
| 2785 | }, | 2797 | }, |
| 2786 | ); | 2798 | ); |
crates/ec-av1/src/mvstack.rsmodified+87 -14
| @@ -141,6 +141,16 @@ pub struct MiInfo { | |||
| 141 | /// has no compound candidates). Feeds `NewMvContext` (7.10.2.8): a | 141 | /// has no compound candidates). Feeds `NewMvContext` (7.10.2.8): a |
| 142 | /// neighbour's own coded-with-NEWMV state, not this block's. | 142 | /// neighbour's own coded-with-NEWMV state, not this block's. |
| 143 | pub is_new_mv: bool, | 143 | pub is_new_mv: bool, |
| 144 | + /// Whether this unit's own coded mode was `GLOBALMV`/`GLOBAL_GLOBALMV` | ||
| 145 | + /// *and* the frame's global-motion model for its `ref_frame` is more | ||
| 146 | + /// than `TRANSLATION` (libaom's `is_global_mv_block`, checked per | ||
| 147 | + /// reference slot at donation time, mvref_common.c:88-92): when true, | ||
| 148 | + /// a scan that matches this unit on its first ref slot donates the | ||
| 149 | + /// *querying* block's own `gm_mv` there, not `mv`. | ||
| 150 | + pub is_global_mv0: bool, | ||
| 151 | + /// `is_global_mv0`, for the second ref slot (`ref_frame1`/`mv1`, | ||
| 152 | + /// mvref_common.c:116-117). | ||
| 153 | + pub is_global_mv1: bool, | ||
| 144 | /// The side, in 4x4 units, of the square block this unit belongs to (8 | 154 | /// The side, in 4x4 units, of the square block this unit belongs to (8 |
| 145 | /// for a whole 32x32 block, 4 for a 16x16 leaf -- every block this crate | 155 | /// for a whole 32x32 block, 4 for a 16x16 leaf -- every block this crate |
| 146 | /// ever codes is square, so one dimension is enough). Feeds the extended | 156 | /// ever codes is square, so one dimension is enough). Feeds the extended |
| @@ -302,6 +312,26 @@ pub type SignBiasTable = [bool; 7]; | |||
| 302 | /// hardcoded `sign_bias` stub. | 312 | /// hardcoded `sign_bias` stub. |
| 303 | pub const NO_SIGN_BIAS: SignBiasTable = [false; 7]; | 313 | pub const NO_SIGN_BIAS: SignBiasTable = [false; 7]; |
| 304 | 314 | ||
| 315 | +/// One derived global-motion `(row, col)` mv per reference frame | ||
| 316 | +/// (`table[ref_frame - LAST_FRAME]`, same shape/indexing as | ||
| 317 | +/// [`SignBiasTable`]), all computed at the *querying* block's own position | ||
| 318 | +/// -- lane-gm: a neighbour donating a candidate under `MiInfo::is_global_mv0`/ | ||
| 319 | +/// `MiInfo::is_global_mv1` contributes this table's entry for the matched | ||
| 320 | +/// ref frame, not its own stored `mv`/`mv1` (mvref_common.c:88-92/116-117). | ||
| 321 | +pub type GmMvTable = [(i32, i32); 7]; | ||
| 322 | + | ||
| 323 | +/// The all-zero table every IDENTITY/no-gm caller passes: exact whenever no | ||
| 324 | +/// unit in the grid is ever `is_global_mv0`/`is_global_mv1` (the 14-pin | ||
| 325 | +/// list's own streams), since a substitution that never triggers reads as | ||
| 326 | +/// this reduction's old hardcoded-zero behaviour. | ||
| 327 | +pub const NO_GM_MV: GmMvTable = [(0, 0); 7]; | ||
| 328 | + | ||
| 329 | +/// `table[ref_frame - LAST_FRAME]`, [`sign_bias`]'s shape for a | ||
| 330 | +/// [`GmMvTable`]. | ||
| 331 | +fn gm_mv(table: &GmMvTable, ref_frame: i8) -> (i32, i32) { | ||
| 332 | + table[(ref_frame - LAST_FRAME) as usize] | ||
| 333 | +} | ||
| 334 | + | ||
| 305 | /// libaom's `process_single_ref_mv_candidate` (mvref_common.c): folds one | 335 | /// libaom's `process_single_ref_mv_candidate` (mvref_common.c): folds one |
| 306 | /// already-coded neighbour into the stack as a low-weight (`2`, unboosted) | 336 | /// already-coded neighbour into the stack as a low-weight (`2`, unboosted) |
| 307 | /// filler entry, used only by the single-reference extension pass below. | 337 | /// filler entry, used only by the single-reference extension pass below. |
| @@ -321,19 +351,20 @@ fn process_single_ref_mv_candidate( | |||
| 321 | candidate: &MiInfo, | 351 | candidate: &MiInfo, |
| 322 | ref_frame: i8, | 352 | ref_frame: i8, |
| 323 | sign_bias_table: &SignBiasTable, | 353 | sign_bias_table: &SignBiasTable, |
| 354 | + gm: &GmMvTable, | ||
| 324 | candidates: &mut Vec<StackEntry>, | 355 | candidates: &mut Vec<StackEntry>, |
| 325 | ) { | 356 | ) { |
| 326 | if !candidate.is_inter { | 357 | if !candidate.is_inter { |
| 327 | return; | 358 | return; |
| 328 | } | 359 | } |
| 329 | - let mut slots = [(candidate.ref_frame, candidate.mv); 2]; | 360 | + let mut slots = [(candidate.ref_frame, candidate.mv, candidate.is_global_mv0); 2]; |
| 330 | let mut n_slots = 1; | 361 | let mut n_slots = 1; |
| 331 | if let (Some(rf1), Some(mv1)) = (candidate.ref_frame1, candidate.mv1) { | 362 | if let (Some(rf1), Some(mv1)) = (candidate.ref_frame1, candidate.mv1) { |
| 332 | - slots[1] = (rf1, mv1); | 363 | + slots[1] = (rf1, mv1, candidate.is_global_mv1); |
| 333 | n_slots = 2; | 364 | n_slots = 2; |
| 334 | } | 365 | } |
| 335 | - for &(rf, mv) in &slots[..n_slots] { | 366 | + for &(rf, mv, is_global) in &slots[..n_slots] { |
| 336 | - let mut this_mv = mv; | 367 | + let mut this_mv = if is_global { gm_mv(gm, rf) } else { mv }; |
| 337 | if sign_bias(sign_bias_table, rf) != sign_bias(sign_bias_table, ref_frame) { | 368 | if sign_bias(sign_bias_table, rf) != sign_bias(sign_bias_table, ref_frame) { |
| 338 | this_mv = (-this_mv.0, -this_mv.1); | 369 | this_mv = (-this_mv.0, -this_mv.1); |
| 339 | } | 370 | } |
| @@ -386,6 +417,7 @@ fn scan_row( | |||
| 386 | row_offset: isize, | 417 | row_offset: isize, |
| 387 | max_row_offset: isize, | 418 | max_row_offset: isize, |
| 388 | ref_frame: i8, | 419 | ref_frame: i8, |
| 420 | + gm: &GmMvTable, | ||
| 389 | candidates: &mut Vec<StackEntry>, | 421 | candidates: &mut Vec<StackEntry>, |
| 390 | newmv_count: &mut u32, | 422 | newmv_count: &mut u32, |
| 391 | processed_rows: &mut usize, | 423 | processed_rows: &mut usize, |
| @@ -416,7 +448,7 @@ fn scan_row( | |||
| 416 | weight = weight.max(inc as u32); | 448 | weight = weight.max(inc as u32); |
| 417 | *processed_rows = (inc as isize - row_offset - 1).max(0) as usize; | 449 | *processed_rows = (inc as isize - row_offset - 1).max(0) as usize; |
| 418 | } | 450 | } |
| 419 | - if let Some(mv) = single_ref_match(info, ref_frame) { | 451 | + if let Some(mv) = single_ref_match(info, ref_frame, gm) { |
| 420 | found = true; | 452 | found = true; |
| 421 | add_candidate(candidates, mv, len as u32 * weight); | 453 | add_candidate(candidates, mv, len as u32 * weight); |
| 422 | *newmv_count += u32::from(info.is_new_mv); | 454 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -435,14 +467,22 @@ fn scan_row( | |||
| 435 | /// compound neighbour's vote whenever the match sat in its *second* slot | 467 | /// compound neighbour's vote whenever the match sat in its *second* slot |
| 436 | /// (the class this crate's own compound-stack scan already had to close for | 468 | /// (the class this crate's own compound-stack scan already had to close for |
| 437 | /// [`find_mv_stack_compound`] -- see the module doc). | 469 | /// [`find_mv_stack_compound`] -- see the module doc). |
| 438 | -fn single_ref_match(info: &MiInfo, ref_frame: i8) -> Option<(i32, i32)> { | 470 | +fn single_ref_match(info: &MiInfo, ref_frame: i8, gm: &GmMvTable) -> Option<(i32, i32)> { |
| 439 | if !info.is_inter { | 471 | if !info.is_inter { |
| 440 | return None; | 472 | return None; |
| 441 | } | 473 | } |
| 442 | if info.ref_frame == ref_frame { | 474 | if info.ref_frame == ref_frame { |
| 443 | - Some(info.mv) | 475 | + Some(if info.is_global_mv0 { |
| 476 | + gm_mv(gm, ref_frame) | ||
| 477 | + } else { | ||
| 478 | + info.mv | ||
| 479 | + }) | ||
| 444 | } else if info.ref_frame1 == Some(ref_frame) { | 480 | } else if info.ref_frame1 == Some(ref_frame) { |
| 445 | - info.mv1 | 481 | + if info.is_global_mv1 { |
| 482 | + Some(gm_mv(gm, ref_frame)) | ||
| 483 | + } else { | ||
| 484 | + info.mv1 | ||
| 485 | + } | ||
| 446 | } else { | 486 | } else { |
| 447 | None | 487 | None |
| 448 | } | 488 | } |
| @@ -459,6 +499,7 @@ fn scan_col( | |||
| 459 | col_offset: isize, | 499 | col_offset: isize, |
| 460 | max_col_offset: isize, | 500 | max_col_offset: isize, |
| 461 | ref_frame: i8, | 501 | ref_frame: i8, |
| 502 | + gm: &GmMvTable, | ||
| 462 | candidates: &mut Vec<StackEntry>, | 503 | candidates: &mut Vec<StackEntry>, |
| 463 | newmv_count: &mut u32, | 504 | newmv_count: &mut u32, |
| 464 | processed_cols: &mut usize, | 505 | processed_cols: &mut usize, |
| @@ -489,7 +530,7 @@ fn scan_col( | |||
| 489 | weight = weight.max(inc as u32); | 530 | weight = weight.max(inc as u32); |
| 490 | *processed_cols = (inc as isize - col_offset - 1).max(0) as usize; | 531 | *processed_cols = (inc as isize - col_offset - 1).max(0) as usize; |
| 491 | } | 532 | } |
| 492 | - if let Some(mv) = single_ref_match(info, ref_frame) { | 533 | + if let Some(mv) = single_ref_match(info, ref_frame, gm) { |
| 493 | found = true; | 534 | found = true; |
| 494 | add_candidate(candidates, mv, len as u32 * weight); | 535 | add_candidate(candidates, mv, len as u32 * weight); |
| 495 | *newmv_count += u32::from(info.is_new_mv); | 536 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -511,6 +552,7 @@ fn scan_top_right( | |||
| 511 | mi_col: usize, | 552 | mi_col: usize, |
| 512 | bw4: usize, | 553 | bw4: usize, |
| 513 | ref_frame: i8, | 554 | ref_frame: i8, |
| 555 | + gm: &GmMvTable, | ||
| 514 | candidates: &mut Vec<StackEntry>, | 556 | candidates: &mut Vec<StackEntry>, |
| 515 | newmv_count: &mut u32, | 557 | newmv_count: &mut u32, |
| 516 | ) -> bool { | 558 | ) -> bool { |
| @@ -519,7 +561,7 @@ fn scan_top_right( | |||
| 519 | }; | 561 | }; |
| 520 | let col = mi_col + bw4; | 562 | let col = mi_col + bw4; |
| 521 | if let Some(info) = grid.get(row, col) | 563 | if let Some(info) = grid.get(row, col) |
| 522 | - && let Some(mv) = single_ref_match(info, ref_frame) | 564 | + && let Some(mv) = single_ref_match(info, ref_frame, gm) |
| 523 | { | 565 | { |
| 524 | add_candidate(candidates, mv, CORNER_WEIGHT); | 566 | add_candidate(candidates, mv, CORNER_WEIGHT); |
| 525 | *newmv_count += u32::from(info.is_new_mv); | 567 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -539,6 +581,7 @@ fn scan_corner( | |||
| 539 | mi_row: usize, | 581 | mi_row: usize, |
| 540 | mi_col: usize, | 582 | mi_col: usize, |
| 541 | ref_frame: i8, | 583 | ref_frame: i8, |
| 584 | + gm: &GmMvTable, | ||
| 542 | candidates: &mut Vec<StackEntry>, | 585 | candidates: &mut Vec<StackEntry>, |
| 543 | newmv_count: &mut u32, | 586 | newmv_count: &mut u32, |
| 544 | ) -> bool { | 587 | ) -> bool { |
| @@ -546,7 +589,7 @@ fn scan_corner( | |||
| 546 | return false; | 589 | return false; |
| 547 | }; | 590 | }; |
| 548 | if let Some(info) = grid.get(row, col) | 591 | if let Some(info) = grid.get(row, col) |
| 549 | - && let Some(mv) = single_ref_match(info, ref_frame) | 592 | + && let Some(mv) = single_ref_match(info, ref_frame, gm) |
| 550 | { | 593 | { |
| 551 | add_candidate(candidates, mv, CORNER_WEIGHT); | 594 | add_candidate(candidates, mv, CORNER_WEIGHT); |
| 552 | *newmv_count += u32::from(info.is_new_mv); | 595 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -613,6 +656,7 @@ pub fn find_mv_stack( | |||
| 613 | mi_cols, | 656 | mi_cols, |
| 614 | mi_rows, | 657 | mi_rows, |
| 615 | &NO_SIGN_BIAS, | 658 | &NO_SIGN_BIAS, |
| 659 | + &NO_GM_MV, | ||
| 616 | None, | 660 | None, |
| 617 | ) | 661 | ) |
| 618 | } | 662 | } |
| @@ -633,6 +677,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 633 | mi_cols: usize, | 677 | mi_cols: usize, |
| 634 | mi_rows: usize, | 678 | mi_rows: usize, |
| 635 | sign_bias_table: &SignBiasTable, | 679 | sign_bias_table: &SignBiasTable, |
| 680 | + gm: &GmMvTable, | ||
| 636 | tpl: Option<TplArgs>, | 681 | tpl: Option<TplArgs>, |
| 637 | ) -> MvStack { | 682 | ) -> MvStack { |
| 638 | let mut candidates = Vec::new(); | 683 | let mut candidates = Vec::new(); |
| @@ -670,6 +715,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 670 | -1, | 715 | -1, |
| 671 | max_row_offset, | 716 | max_row_offset, |
| 672 | ref_frame, | 717 | ref_frame, |
| 718 | + gm, | ||
| 673 | &mut candidates, | 719 | &mut candidates, |
| 674 | &mut newmv_count, | 720 | &mut newmv_count, |
| 675 | &mut processed_rows, | 721 | &mut processed_rows, |
| @@ -683,6 +729,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 683 | -1, | 729 | -1, |
| 684 | max_col_offset, | 730 | max_col_offset, |
| 685 | ref_frame, | 731 | ref_frame, |
| 732 | + gm, | ||
| 686 | &mut candidates, | 733 | &mut candidates, |
| 687 | &mut newmv_count, | 734 | &mut newmv_count, |
| 688 | &mut processed_cols, | 735 | &mut processed_cols, |
| @@ -693,6 +740,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 693 | mi_col, | 740 | mi_col, |
| 694 | bw4, | 741 | bw4, |
| 695 | ref_frame, | 742 | ref_frame, |
| 743 | + gm, | ||
| 696 | &mut candidates, | 744 | &mut candidates, |
| 697 | &mut newmv_count, | 745 | &mut newmv_count, |
| 698 | ); | 746 | ); |
| @@ -756,7 +804,9 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 756 | any_hit = true; | 804 | any_hit = true; |
| 757 | if blk_row == 0 && blk_col == 0 { | 805 | if blk_row == 0 && blk_col == 0 { |
| 758 | first_sample_missing = false; | 806 | first_sample_missing = false; |
| 759 | - first_sample_far = cand.mv.0.abs() >= 16 || cand.mv.1.abs() >= 16; | 807 | + let this_gm_mv = gm_mv(gm, ref_frame); |
| 808 | + first_sample_far = (cand.mv.0 - this_gm_mv.0).abs() >= 16 | ||
| 809 | + || (cand.mv.1 - this_gm_mv.1).abs() >= 16; | ||
| 760 | } | 810 | } |
| 761 | add_candidate(&mut candidates, cand.mv, 2); | 811 | add_candidate(&mut candidates, cand.mv, 2); |
| 762 | } | 812 | } |
| @@ -811,6 +861,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 811 | mi_row, | 861 | mi_row, |
| 812 | mi_col, | 862 | mi_col, |
| 813 | ref_frame, | 863 | ref_frame, |
| 864 | + gm, | ||
| 814 | &mut candidates, | 865 | &mut candidates, |
| 815 | &mut dummy_newmv_count, | 866 | &mut dummy_newmv_count, |
| 816 | ); | 867 | ); |
| @@ -841,6 +892,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 841 | row_offset, | 892 | row_offset, |
| 842 | max_row_offset, | 893 | max_row_offset, |
| 843 | ref_frame, | 894 | ref_frame, |
| 895 | + gm, | ||
| 844 | &mut candidates, | 896 | &mut candidates, |
| 845 | &mut dummy_newmv_count, | 897 | &mut dummy_newmv_count, |
| 846 | &mut processed_rows, | 898 | &mut processed_rows, |
| @@ -858,6 +910,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 858 | col_offset, | 910 | col_offset, |
| 859 | max_col_offset, | 911 | max_col_offset, |
| 860 | ref_frame, | 912 | ref_frame, |
| 913 | + gm, | ||
| 861 | &mut candidates, | 914 | &mut candidates, |
| 862 | &mut dummy_newmv_count, | 915 | &mut dummy_newmv_count, |
| 863 | &mut processed_cols, | 916 | &mut processed_cols, |
| @@ -918,7 +971,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 918 | let cand = grid.get(mi_row - 1, mi_col + idx); | 971 | let cand = grid.get(mi_row - 1, mi_col + idx); |
| 919 | let step = cand.map_or(1, |c| c.size).max(1); | 972 | let step = cand.map_or(1, |c| c.size).max(1); |
| 920 | if let Some(c) = cand { | 973 | if let Some(c) = cand { |
| 921 | - process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut candidates); | 974 | + process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, gm, &mut candidates); |
| 922 | } | 975 | } |
| 923 | idx += step; | 976 | idx += step; |
| 924 | } | 977 | } |
| @@ -929,7 +982,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 929 | let cand = grid.get(mi_row + idx, mi_col - 1); | 982 | let cand = grid.get(mi_row + idx, mi_col - 1); |
| 930 | let step = cand.map_or(1, |c| c.size_h).max(1); | 983 | let step = cand.map_or(1, |c| c.size_h).max(1); |
| 931 | if let Some(c) = cand { | 984 | if let Some(c) = cand { |
| 932 | - process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut candidates); | 985 | + process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, gm, &mut candidates); |
| 933 | } | 986 | } |
| 934 | idx += step; | 987 | idx += step; |
| 935 | } | 988 | } |
| @@ -1983,6 +2036,8 @@ mod tests { | |||
| 1983 | // tests only exercise the immediate/corner/top-right scans. | 2036 | // tests only exercise the immediate/corner/top-right scans. |
| 1984 | size: 1, | 2037 | size: 1, |
| 1985 | size_h: 1, | 2038 | size_h: 1, |
| 2039 | + is_global_mv0: false, | ||
| 2040 | + is_global_mv1: false, | ||
| 1986 | } | 2041 | } |
| 1987 | } | 2042 | } |
| 1988 | 2043 | ||
| @@ -2137,6 +2192,8 @@ mod tests { | |||
| 2137 | is_new_mv: true, | 2192 | is_new_mv: true, |
| 2138 | size: 1, | 2193 | size: 1, |
| 2139 | size_h: 1, | 2194 | size_h: 1, |
| 2195 | + is_global_mv0: false, | ||
| 2196 | + is_global_mv1: false, | ||
| 2140 | }, | 2197 | }, |
| 2141 | ); | 2198 | ); |
| 2142 | // Only the row matches (nearest_match == 1): newmv_count > 0 picks | 2199 | // Only the row matches (nearest_match == 1): newmv_count > 0 picks |
| @@ -2218,6 +2275,8 @@ mod tests { | |||
| 2218 | is_new_mv: false, | 2275 | is_new_mv: false, |
| 2219 | size: 8, | 2276 | size: 8, |
| 2220 | size_h: 8, | 2277 | size_h: 8, |
| 2278 | + is_global_mv0: false, | ||
| 2279 | + is_global_mv1: false, | ||
| 2221 | }, | 2280 | }, |
| 2222 | ); | 2281 | ); |
| 2223 | 2282 | ||
| @@ -2248,6 +2307,8 @@ mod tests { | |||
| 2248 | is_new_mv: false, | 2307 | is_new_mv: false, |
| 2249 | size: 8, | 2308 | size: 8, |
| 2250 | size_h: 8, | 2309 | size_h: 8, |
| 2310 | + is_global_mv0: false, | ||
| 2311 | + is_global_mv1: false, | ||
| 2251 | } | 2312 | } |
| 2252 | } | 2313 | } |
| 2253 | 2314 | ||
| @@ -2265,6 +2326,8 @@ mod tests { | |||
| 2265 | is_new_mv: false, | 2326 | is_new_mv: false, |
| 2266 | size: 8, | 2327 | size: 8, |
| 2267 | size_h: 8, | 2328 | size_h: 8, |
| 2329 | + is_global_mv0: false, | ||
| 2330 | + is_global_mv1: false, | ||
| 2268 | } | 2331 | } |
| 2269 | } | 2332 | } |
| 2270 | 2333 | ||
| @@ -2503,6 +2566,8 @@ mod tests { | |||
| 2503 | is_new_mv: false, | 2566 | is_new_mv: false, |
| 2504 | size: 1, | 2567 | size: 1, |
| 2505 | size_h: 1, | 2568 | size_h: 1, |
| 2569 | + is_global_mv0: false, | ||
| 2570 | + is_global_mv1: false, | ||
| 2506 | } | 2571 | } |
| 2507 | } | 2572 | } |
| 2508 | 2573 | ||
| @@ -2524,6 +2589,8 @@ mod tests { | |||
| 2524 | is_new_mv: false, | 2589 | is_new_mv: false, |
| 2525 | size: 1, | 2590 | size: 1, |
| 2526 | size_h: 1, | 2591 | size_h: 1, |
| 2592 | + is_global_mv0: false, | ||
| 2593 | + is_global_mv1: false, | ||
| 2527 | }, | 2594 | }, |
| 2528 | ); | 2595 | ); |
| 2529 | // Exact pair match. | 2596 | // Exact pair match. |
| @@ -2625,6 +2692,8 @@ mod tests { | |||
| 2625 | is_new_mv: false, | 2692 | is_new_mv: false, |
| 2626 | size: 1, | 2693 | size: 1, |
| 2627 | size_h: 1, | 2694 | size_h: 1, |
| 2695 | + is_global_mv0: false, | ||
| 2696 | + is_global_mv1: false, | ||
| 2628 | }; | 2697 | }; |
| 2629 | process_compound_ref_mv_candidate(&candidate, COMP_PAIR, &NO_SIGN_BIAS, &mut lists); | 2698 | process_compound_ref_mv_candidate(&candidate, COMP_PAIR, &NO_SIGN_BIAS, &mut lists); |
| 2630 | assert_eq!(lists.ref_id[0], vec![(5, 5)]); | 2699 | assert_eq!(lists.ref_id[0], vec![(5, 5)]); |
| @@ -2652,6 +2721,8 @@ mod tests { | |||
| 2652 | is_new_mv: false, | 2721 | is_new_mv: false, |
| 2653 | size: 8, | 2722 | size: 8, |
| 2654 | size_h: 8, | 2723 | size_h: 8, |
| 2724 | + is_global_mv0: false, | ||
| 2725 | + is_global_mv1: false, | ||
| 2655 | }, | 2726 | }, |
| 2656 | ); | 2727 | ); |
| 2657 | grid.set( | 2728 | grid.set( |
| @@ -2666,6 +2737,8 @@ mod tests { | |||
| 2666 | is_new_mv: false, | 2737 | is_new_mv: false, |
| 2667 | size: 8, | 2738 | size: 8, |
| 2668 | size_h: 8, | 2739 | size_h: 8, |
| 2740 | + is_global_mv0: false, | ||
| 2741 | + is_global_mv1: false, | ||
| 2669 | }, | 2742 | }, |
| 2670 | ); | 2743 | ); |
| 2671 | 2744 | ||
crates/ec-av1/src/tile.rsmodified+16 -0
| @@ -2440,6 +2440,8 @@ pub fn sb_coeff_inter_frame_tile( | |||
| 2440 | is_new_mv, | 2440 | is_new_mv, |
| 2441 | size: 8, | 2441 | size: 8, |
| 2442 | size_h: 8, | 2442 | size_h: 8, |
| 2443 | + is_global_mv0: false, | ||
| 2444 | + is_global_mv1: false, | ||
| 2443 | }, | 2445 | }, |
| 2444 | ); | 2446 | ); |
| 2445 | for dr in 0..8 { | 2447 | for dr in 0..8 { |
| @@ -2459,6 +2461,8 @@ pub fn sb_coeff_inter_frame_tile( | |||
| 2459 | is_new_mv, | 2461 | is_new_mv, |
| 2460 | size: 8, | 2462 | size: 8, |
| 2461 | size_h: 8, | 2463 | size_h: 8, |
| 2464 | + is_global_mv0: false, | ||
| 2465 | + is_global_mv1: false, | ||
| 2462 | }, | 2466 | }, |
| 2463 | ); | 2467 | ); |
| 2464 | } | 2468 | } |
| @@ -2489,6 +2493,8 @@ pub fn sb_coeff_inter_frame_tile( | |||
| 2489 | is_new_mv: false, | 2493 | is_new_mv: false, |
| 2490 | size: 8, | 2494 | size: 8, |
| 2491 | size_h: 8, | 2495 | size_h: 8, |
| 2496 | + is_global_mv0: false, | ||
| 2497 | + is_global_mv1: false, | ||
| 2492 | }, | 2498 | }, |
| 2493 | ); | 2499 | ); |
| 2494 | } | 2500 | } |
| @@ -2630,6 +2636,8 @@ fn write_inter_frame_leaf( | |||
| 2630 | is_new_mv, | 2636 | is_new_mv, |
| 2631 | size: SUB_MI as usize, | 2637 | size: SUB_MI as usize, |
| 2632 | size_h: SUB_MI as usize, | 2638 | size_h: SUB_MI as usize, |
| 2639 | + is_global_mv0: false, | ||
| 2640 | + is_global_mv1: false, | ||
| 2633 | }, | 2641 | }, |
| 2634 | ); | 2642 | ); |
| 2635 | } | 2643 | } |
| @@ -2660,6 +2668,8 @@ fn write_inter_frame_leaf( | |||
| 2660 | is_new_mv: false, | 2668 | is_new_mv: false, |
| 2661 | size: SUB_MI as usize, | 2669 | size: SUB_MI as usize, |
| 2662 | size_h: SUB_MI as usize, | 2670 | size_h: SUB_MI as usize, |
| 2671 | + is_global_mv0: false, | ||
| 2672 | + is_global_mv1: false, | ||
| 2663 | }, | 2673 | }, |
| 2664 | ); | 2674 | ); |
| 2665 | } | 2675 | } |
| @@ -2824,6 +2834,8 @@ fn write_inter_frame_leaf8( | |||
| 2824 | is_new_mv, | 2834 | is_new_mv, |
| 2825 | size: 2, | 2835 | size: 2, |
| 2826 | size_h: 2, | 2836 | size_h: 2, |
| 2837 | + is_global_mv0: false, | ||
| 2838 | + is_global_mv1: false, | ||
| 2827 | }, | 2839 | }, |
| 2828 | ); | 2840 | ); |
| 2829 | } | 2841 | } |
| @@ -2854,6 +2866,8 @@ fn write_inter_frame_leaf8( | |||
| 2854 | is_new_mv: false, | 2866 | is_new_mv: false, |
| 2855 | size: 2, | 2867 | size: 2, |
| 2856 | size_h: 2, | 2868 | size_h: 2, |
| 2869 | + is_global_mv0: false, | ||
| 2870 | + is_global_mv1: false, | ||
| 2857 | }, | 2871 | }, |
| 2858 | ); | 2872 | ); |
| 2859 | } | 2873 | } |
| @@ -5109,6 +5123,8 @@ mod tests { | |||
| 5109 | is_new_mv, | 5123 | is_new_mv, |
| 5110 | size: 8, | 5124 | size: 8, |
| 5111 | size_h: 8, | 5125 | size_h: 8, |
| 5126 | + is_global_mv0: false, | ||
| 5127 | + is_global_mv1: false, | ||
| 5112 | }, | 5128 | }, |
| 5113 | ); | 5129 | ); |
| 5114 | } | 5130 | } |