wip(av1): gm r2 -- compound mvstack gm threading, GLOBALMV real mv, interp two-predicate split (does not compile yet)
Browse files at this commit5417eab46178ab7a9a4bcd7e387f458934284758Parent: 149fd7a2 changed files +117 -37
- crates/ec-av1/src/decode.rs +80 -18
- crates/ec-av1/src/mvstack.rs +37 -19
crates/ec-av1/src/decode.rsmodified+80 -18
| @@ -5039,6 +5039,9 @@ fn assign_compound_mv( | |||
| 5039 | mode: u8, | 5039 | mode: u8, |
| 5040 | allow_high_precision_mv: bool, | 5040 | allow_high_precision_mv: bool, |
| 5041 | force_integer_mv: bool, | 5041 | force_integer_mv: bool, |
| 5042 | + // lane-gm r2: `gm_get_motion_vector(ref0)`/`(ref1)` at this block's own | ||
| 5043 | + // position, spec 7.10.2.10's `GLOBAL_GLOBALMV` assignment. | ||
| 5044 | + global_mv: ((i32, i32), (i32, i32)), | ||
| 5042 | ) -> ((i32, i32), (i32, i32)) { | 5045 | ) -> ((i32, i32), (i32, i32)) { |
| 5043 | const NEAREST_NEARESTMV: u8 = 0; | 5046 | const NEAREST_NEARESTMV: u8 = 0; |
| 5044 | const NEAR_NEARMV: u8 = 1; | 5047 | const NEAR_NEARMV: u8 = 1; |
| @@ -5102,7 +5105,7 @@ fn assign_compound_mv( | |||
| 5102 | NEW_NEARESTMV => (read_new(dec, cdfs, new_pred.0), comp_stack.nearest_mv.1), | 5105 | NEW_NEARESTMV => (read_new(dec, cdfs, new_pred.0), comp_stack.nearest_mv.1), |
| 5103 | NEAR_NEWMV => (near.0, read_new(dec, cdfs, new_pred.1)), | 5106 | NEAR_NEWMV => (near.0, read_new(dec, cdfs, new_pred.1)), |
| 5104 | NEW_NEARMV => (read_new(dec, cdfs, new_pred.0), near.1), | 5107 | NEW_NEARMV => (read_new(dec, cdfs, new_pred.0), near.1), |
| 5105 | - GLOBAL_GLOBALMV => ((0, 0), (0, 0)), | 5108 | + GLOBAL_GLOBALMV => global_mv, |
| 5106 | _ => ( | 5109 | _ => ( |
| 5107 | read_new(dec, cdfs, new_pred.0), | 5110 | read_new(dec, cdfs, new_pred.0), |
| 5108 | read_new(dec, cdfs, new_pred.1), | 5111 | read_new(dec, cdfs, new_pred.1), |
| @@ -5110,6 +5113,35 @@ fn assign_compound_mv( | |||
| 5110 | } | 5113 | } |
| 5111 | } | 5114 | } |
| 5112 | 5115 | ||
| 5116 | +/// Derives this query block's own [`crate::mvstack::GmMvTable`] -- one | ||
| 5117 | +/// `gm_get_motion_vector` (spec 7.10.2.1) result per reference frame, at | ||
| 5118 | +/// THIS block's own `(mi_row, mi_col, bw4, bh4)` (mvstack.rs's own doc: the | ||
| 5119 | +/// table is always computed at the *querying* block's position, never a | ||
| 5120 | +/// donating neighbour's). | ||
| 5121 | +fn build_gm_mv_table( | ||
| 5122 | + global_motion: &[ec_av1_syntax::WarpParams; 7], | ||
| 5123 | + mi_row: usize, | ||
| 5124 | + mi_col: usize, | ||
| 5125 | + bw4: usize, | ||
| 5126 | + bh4: usize, | ||
| 5127 | + allow_high_precision_mv: bool, | ||
| 5128 | + force_integer_mv: bool, | ||
| 5129 | +) -> crate::mvstack::GmMvTable { | ||
| 5130 | + std::array::from_fn(|i| { | ||
| 5131 | + let gm = &global_motion[i]; | ||
| 5132 | + crate::warp::gm_get_motion_vector( | ||
| 5133 | + gm.model, | ||
| 5134 | + &gm.params, | ||
| 5135 | + mi_row, | ||
| 5136 | + mi_col, | ||
| 5137 | + bw4, | ||
| 5138 | + bh4, | ||
| 5139 | + allow_high_precision_mv, | ||
| 5140 | + force_integer_mv, | ||
| 5141 | + ) | ||
| 5142 | + }) | ||
| 5143 | +} | ||
| 5144 | + | ||
| 5113 | /// Decodes one square inter-frame block (32x32 whole or 16x16 leaf): skip, | 5145 | /// Decodes one square inter-frame block (32x32 whole or 16x16 leaf): skip, |
| 5114 | /// `is_inter`, then either the single-reference/MV-stack/motion-vector chain | 5146 | /// `is_inter`, then either the single-reference/MV-stack/motion-vector chain |
| 5115 | /// and motion-compensated reconstruction, or the inter frame's own intra | 5147 | /// and motion-compensated reconstruction, or the inter frame's own intra |
| @@ -5149,6 +5181,11 @@ fn decode_inter_block( | |||
| 5149 | // GOP), matching `GOLDEN_FRAME`'s existing empty-slot refusal below. | 5181 | // GOP), matching `GOLDEN_FRAME`'s existing empty-slot refusal below. |
| 5150 | other_refs: &RefSlots, | 5182 | other_refs: &RefSlots, |
| 5151 | sign_bias_table: &SignBiasTable, | 5183 | sign_bias_table: &SignBiasTable, |
| 5184 | + // lane-gm r2: this frame header's own `global_motion` table (spec | ||
| 5185 | + // 5.9.24), indexed `[ref_frame - LAST_FRAME]` same as `sign_bias_table` | ||
| 5186 | + // -- feeds `warp::gm_get_motion_vector` for `GLOBALMV`/`GLOBAL_GLOBALMV` | ||
| 5187 | + // assignment and the mv-stack's neighbour substitution. | ||
| 5188 | + global_motion: &[ec_av1_syntax::WarpParams; 7], | ||
| 5152 | base_q_idx: u8, | 5189 | base_q_idx: u8, |
| 5153 | luma_set_intra: TxbSet, | 5190 | luma_set_intra: TxbSet, |
| 5154 | luma_set_inter: TxbSet, | 5191 | luma_set_inter: TxbSet, |
| @@ -5350,6 +5387,15 @@ fn decode_inter_block( | |||
| 5350 | ), | 5387 | ), |
| 5351 | allow_high_precision_mv, | 5388 | allow_high_precision_mv, |
| 5352 | }); | 5389 | }); |
| 5390 | + let gm_table = build_gm_mv_table( | ||
| 5391 | + global_motion, | ||
| 5392 | + mi_row, | ||
| 5393 | + mi_col, | ||
| 5394 | + bw4, | ||
| 5395 | + bh4, | ||
| 5396 | + allow_high_precision_mv, | ||
| 5397 | + force_integer_mv, | ||
| 5398 | + ); | ||
| 5353 | let comp_stack = crate::mvstack::find_mv_stack_compound( | 5399 | let comp_stack = crate::mvstack::find_mv_stack_compound( |
| 5354 | grid, | 5400 | grid, |
| 5355 | mi_row, | 5401 | mi_row, |
| @@ -5360,6 +5406,7 @@ fn decode_inter_block( | |||
| 5360 | mi_cols as usize, | 5406 | mi_cols as usize, |
| 5361 | mi_rows as usize, | 5407 | mi_rows as usize, |
| 5362 | sign_bias_table, | 5408 | sign_bias_table, |
| 5409 | + &gm_table, | ||
| 5363 | comp_tpl, | 5410 | comp_tpl, |
| 5364 | ); | 5411 | ); |
| 5365 | let compound_mode = if skip_mode { | 5412 | let compound_mode = if skip_mode { |
| @@ -5374,8 +5421,15 @@ fn decode_inter_block( | |||
| 5374 | compound_mode, | 5421 | compound_mode, |
| 5375 | allow_high_precision_mv, | 5422 | allow_high_precision_mv, |
| 5376 | force_integer_mv, | 5423 | force_integer_mv, |
| 5424 | + (gm_table[(ref0 - LAST_FRAME) as usize], gm_table[(ref1 - LAST_FRAME) as usize]), | ||
| 5377 | ); | 5425 | ); |
| 5378 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV | 5426 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV |
| 5427 | + // spec `is_nontrans_global_motion`: ALL active refs' models must | ||
| 5428 | + // be non-TRANSLATION (IDENTITY counts) for the compound block's | ||
| 5429 | + // interp-filter read to be suppressed. | ||
| 5430 | + let gm_nontrans = is_globalmv | ||
| 5431 | + && global_motion[(ref0 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation | ||
| 5432 | + && global_motion[(ref1 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation; | ||
| 5379 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; | 5433 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; |
| 5380 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; | 5434 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; |
| 5381 | // spec `get_ref_filter_type`: matches when EITHER of the | 5435 | // spec `get_ref_filter_type`: matches when EITHER of the |
| @@ -5422,8 +5476,17 @@ fn decode_inter_block( | |||
| 5422 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), | 5476 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 5423 | size: bw4, | 5477 | size: bw4, |
| 5424 | size_h: bh4, | 5478 | size_h: bh4, |
| 5425 | - is_global_mv0: false, | 5479 | + // libaom `is_global_mv_block`: per-ref-slot, mode |
| 5426 | - is_global_mv1: false, | 5480 | + // GLOBAL_GLOBALMV, block >= 8x8, and THAT slot's |
| 5481 | + // own gm model > TRANSLATION (IDENTITY excluded | ||
| 5482 | + // too -- the two-predicate trap, distinct from | ||
| 5483 | + // `gm_nontrans` above which allows IDENTITY). | ||
| 5484 | + is_global_mv0: is_globalmv | ||
| 5485 | + && bw4.min(bh4) >= 2 | ||
| 5486 | + && global_motion[(ref0 - LAST_FRAME) as usize].model as u8 > 1, | ||
| 5487 | + is_global_mv1: is_globalmv | ||
| 5488 | + && bw4.min(bh4) >= 2 | ||
| 5489 | + && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1, | ||
| 5427 | }, | 5490 | }, |
| 5428 | ); | 5491 | ); |
| 5429 | } | 5492 | } |
| @@ -5735,7 +5798,7 @@ fn decode_inter_block( | |||
| 5735 | cdfs, | 5798 | cdfs, |
| 5736 | interp_fixed, | 5799 | interp_fixed, |
| 5737 | enable_dual_filter, | 5800 | enable_dual_filter, |
| 5738 | - is_globalmv || skip_mode, | 5801 | + gm_nontrans || skip_mode, |
| 5739 | above_filter_ctx, | 5802 | above_filter_ctx, |
| 5740 | left_filter_ctx, | 5803 | left_filter_ctx, |
| 5741 | true, | 5804 | true, |
| @@ -6027,6 +6090,15 @@ fn decode_inter_block( | |||
| 6027 | ), | 6090 | ), |
| 6028 | allow_high_precision_mv, | 6091 | allow_high_precision_mv, |
| 6029 | }); | 6092 | }); |
| 6093 | + let gm_table = build_gm_mv_table( | ||
| 6094 | + global_motion, | ||
| 6095 | + mi_row, | ||
| 6096 | + mi_col, | ||
| 6097 | + bw4, | ||
| 6098 | + bh4, | ||
| 6099 | + allow_high_precision_mv, | ||
| 6100 | + force_integer_mv, | ||
| 6101 | + ); | ||
| 6030 | let stack = find_mv_stack_with_sign_bias( | 6102 | let stack = find_mv_stack_with_sign_bias( |
| 6031 | grid, | 6103 | grid, |
| 6032 | mi_row, | 6104 | mi_row, |
| @@ -6037,15 +6109,7 @@ fn decode_inter_block( | |||
| 6037 | mi_cols as usize, | 6109 | mi_cols as usize, |
| 6038 | mi_rows as usize, | 6110 | mi_rows as usize, |
| 6039 | sign_bias_table, | 6111 | sign_bias_table, |
| 6040 | - // lane-gm r2: gm_get_motion_vector + mvstack substitution are | 6112 | + &gm_table, |
| 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, | ||
| 6049 | tpl, | 6113 | tpl, |
| 6050 | ); | 6114 | ); |
| 6051 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 6115 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| @@ -6080,11 +6144,9 @@ fn decode_inter_block( | |||
| 6080 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; | 6144 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; |
| 6081 | is_globalmv = !not_zero; | 6145 | is_globalmv = !not_zero; |
| 6082 | let mv = if !not_zero { | 6146 | let mv = if !not_zero { |
| 6083 | - // GLOBALMV: `gm_get_motion_vector` (spec 7.10.2.1) under the | 6147 | + // GLOBALMV: `gm_get_motion_vector` (spec 7.10.2.1), already |
| 6084 | - // `GmType::IDENTITY` this crate's `decode_stream` requires of | 6148 | + // computed at this block's own position in `gm_table`. |
| 6085 | - // every inter frame's `LAST_FRAME` entry (any other warp | 6149 | + gm_table[(ref_frame - LAST_FRAME) as usize] |
| 6086 | - // model is refused before the tile decoder is ever called). | ||
| 6087 | - (0, 0) | ||
| 6088 | } else { | 6150 | } else { |
| 6089 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; | 6151 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 6090 | if nearest { | 6152 | if nearest { |
crates/ec-av1/src/mvstack.rsmodified+37 -19
| @@ -351,20 +351,23 @@ fn process_single_ref_mv_candidate( | |||
| 351 | candidate: &MiInfo, | 351 | candidate: &MiInfo, |
| 352 | ref_frame: i8, | 352 | ref_frame: i8, |
| 353 | sign_bias_table: &SignBiasTable, | 353 | sign_bias_table: &SignBiasTable, |
| 354 | - gm: &GmMvTable, | ||
| 355 | candidates: &mut Vec<StackEntry>, | 354 | candidates: &mut Vec<StackEntry>, |
| 356 | ) { | 355 | ) { |
| 357 | if !candidate.is_inter { | 356 | if !candidate.is_inter { |
| 358 | return; | 357 | return; |
| 359 | } | 358 | } |
| 360 | - let mut slots = [(candidate.ref_frame, candidate.mv, candidate.is_global_mv0); 2]; | 359 | + // libaom's `process_single_ref_mv_candidate` (mvref_common.c ~440-475) |
| 360 | + // reads `candidate->mv[rf_idx]` unconditionally here -- unlike | ||
| 361 | + // `add_ref_mv_candidate`'s row/col/corner scans, this extension pass | ||
| 362 | + // never checks `is_global_mv_block`/substitutes `gm_mv_candidates`. | ||
| 363 | + let mut slots = [(candidate.ref_frame, candidate.mv); 2]; | ||
| 361 | let mut n_slots = 1; | 364 | let mut n_slots = 1; |
| 362 | if let (Some(rf1), Some(mv1)) = (candidate.ref_frame1, candidate.mv1) { | 365 | if let (Some(rf1), Some(mv1)) = (candidate.ref_frame1, candidate.mv1) { |
| 363 | - slots[1] = (rf1, mv1, candidate.is_global_mv1); | 366 | + slots[1] = (rf1, mv1); |
| 364 | n_slots = 2; | 367 | n_slots = 2; |
| 365 | } | 368 | } |
| 366 | - for &(rf, mv, is_global) in &slots[..n_slots] { | 369 | + for &(rf, mv) in &slots[..n_slots] { |
| 367 | - let mut this_mv = if is_global { gm_mv(gm, rf) } else { mv }; | 370 | + let mut this_mv = mv; |
| 368 | if sign_bias(sign_bias_table, rf) != sign_bias(sign_bias_table, ref_frame) { | 371 | if sign_bias(sign_bias_table, rf) != sign_bias(sign_bias_table, ref_frame) { |
| 369 | this_mv = (-this_mv.0, -this_mv.1); | 372 | this_mv = (-this_mv.0, -this_mv.1); |
| 370 | } | 373 | } |
| @@ -971,7 +974,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 971 | let cand = grid.get(mi_row - 1, mi_col + idx); | 974 | let cand = grid.get(mi_row - 1, mi_col + idx); |
| 972 | let step = cand.map_or(1, |c| c.size).max(1); | 975 | let step = cand.map_or(1, |c| c.size).max(1); |
| 973 | if let Some(c) = cand { | 976 | if let Some(c) = cand { |
| 974 | - process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, gm, &mut candidates); | 977 | + process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut candidates); |
| 975 | } | 978 | } |
| 976 | idx += step; | 979 | idx += step; |
| 977 | } | 980 | } |
| @@ -982,7 +985,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 982 | let cand = grid.get(mi_row + idx, mi_col - 1); | 985 | let cand = grid.get(mi_row + idx, mi_col - 1); |
| 983 | let step = cand.map_or(1, |c| c.size_h).max(1); | 986 | let step = cand.map_or(1, |c| c.size_h).max(1); |
| 984 | if let Some(c) = cand { | 987 | if let Some(c) = cand { |
| 985 | - process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, gm, &mut candidates); | 988 | + process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut candidates); |
| 986 | } | 989 | } |
| 987 | idx += step; | 990 | idx += step; |
| 988 | } | 991 | } |
| @@ -1154,6 +1157,7 @@ fn scan_row_compound( | |||
| 1154 | row_offset: isize, | 1157 | row_offset: isize, |
| 1155 | max_row_offset: isize, | 1158 | max_row_offset: isize, |
| 1156 | ref_frame: (i8, i8), | 1159 | ref_frame: (i8, i8), |
| 1160 | + gm: &GmMvTable, | ||
| 1157 | candidates: &mut Vec<CompoundStackEntry>, | 1161 | candidates: &mut Vec<CompoundStackEntry>, |
| 1158 | newmv_count: &mut u32, | 1162 | newmv_count: &mut u32, |
| 1159 | processed_rows: &mut usize, | 1163 | processed_rows: &mut usize, |
| @@ -1188,8 +1192,8 @@ fn scan_row_compound( | |||
| 1188 | found = true; | 1192 | found = true; |
| 1189 | add_compound_candidate( | 1193 | add_compound_candidate( |
| 1190 | candidates, | 1194 | candidates, |
| 1191 | - info.mv, | 1195 | + if info.is_global_mv0 { gm_mv(gm, ref_frame.0) } else { info.mv }, |
| 1192 | - info.mv1.unwrap_or((0, 0)), | 1196 | + if info.is_global_mv1 { gm_mv(gm, ref_frame.1) } else { info.mv1.unwrap_or((0, 0)) }, |
| 1193 | len as u32 * weight, | 1197 | len as u32 * weight, |
| 1194 | ); | 1198 | ); |
| 1195 | *newmv_count += u32::from(info.is_new_mv); | 1199 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -1210,6 +1214,7 @@ fn scan_col_compound( | |||
| 1210 | col_offset: isize, | 1214 | col_offset: isize, |
| 1211 | max_col_offset: isize, | 1215 | max_col_offset: isize, |
| 1212 | ref_frame: (i8, i8), | 1216 | ref_frame: (i8, i8), |
| 1217 | + gm: &GmMvTable, | ||
| 1213 | candidates: &mut Vec<CompoundStackEntry>, | 1218 | candidates: &mut Vec<CompoundStackEntry>, |
| 1214 | newmv_count: &mut u32, | 1219 | newmv_count: &mut u32, |
| 1215 | processed_cols: &mut usize, | 1220 | processed_cols: &mut usize, |
| @@ -1244,8 +1249,8 @@ fn scan_col_compound( | |||
| 1244 | found = true; | 1249 | found = true; |
| 1245 | add_compound_candidate( | 1250 | add_compound_candidate( |
| 1246 | candidates, | 1251 | candidates, |
| 1247 | - info.mv, | 1252 | + if info.is_global_mv0 { gm_mv(gm, ref_frame.0) } else { info.mv }, |
| 1248 | - info.mv1.unwrap_or((0, 0)), | 1253 | + if info.is_global_mv1 { gm_mv(gm, ref_frame.1) } else { info.mv1.unwrap_or((0, 0)) }, |
| 1249 | len as u32 * weight, | 1254 | len as u32 * weight, |
| 1250 | ); | 1255 | ); |
| 1251 | *newmv_count += u32::from(info.is_new_mv); | 1256 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -1256,12 +1261,14 @@ fn scan_col_compound( | |||
| 1256 | } | 1261 | } |
| 1257 | 1262 | ||
| 1258 | /// The compound top-right probe ([`scan_top_right`]'s pair-matched twin). | 1263 | /// The compound top-right probe ([`scan_top_right`]'s pair-matched twin). |
| 1264 | +#[allow(clippy::too_many_arguments)] | ||
| 1259 | fn scan_top_right_compound( | 1265 | fn scan_top_right_compound( |
| 1260 | grid: &MiGrid, | 1266 | grid: &MiGrid, |
| 1261 | mi_row: usize, | 1267 | mi_row: usize, |
| 1262 | mi_col: usize, | 1268 | mi_col: usize, |
| 1263 | bw4: usize, | 1269 | bw4: usize, |
| 1264 | ref_frame: (i8, i8), | 1270 | ref_frame: (i8, i8), |
| 1271 | + gm: &GmMvTable, | ||
| 1265 | candidates: &mut Vec<CompoundStackEntry>, | 1272 | candidates: &mut Vec<CompoundStackEntry>, |
| 1266 | newmv_count: &mut u32, | 1273 | newmv_count: &mut u32, |
| 1267 | ) -> bool { | 1274 | ) -> bool { |
| @@ -1276,8 +1283,8 @@ fn scan_top_right_compound( | |||
| 1276 | { | 1283 | { |
| 1277 | add_compound_candidate( | 1284 | add_compound_candidate( |
| 1278 | candidates, | 1285 | candidates, |
| 1279 | - info.mv, | 1286 | + if info.is_global_mv0 { gm_mv(gm, ref_frame.0) } else { info.mv }, |
| 1280 | - info.mv1.unwrap_or((0, 0)), | 1287 | + if info.is_global_mv1 { gm_mv(gm, ref_frame.1) } else { info.mv1.unwrap_or((0, 0)) }, |
| 1281 | CORNER_WEIGHT, | 1288 | CORNER_WEIGHT, |
| 1282 | ); | 1289 | ); |
| 1283 | *newmv_count += u32::from(info.is_new_mv); | 1290 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -1292,6 +1299,7 @@ fn scan_corner_compound( | |||
| 1292 | mi_row: usize, | 1299 | mi_row: usize, |
| 1293 | mi_col: usize, | 1300 | mi_col: usize, |
| 1294 | ref_frame: (i8, i8), | 1301 | ref_frame: (i8, i8), |
| 1302 | + gm: &GmMvTable, | ||
| 1295 | candidates: &mut Vec<CompoundStackEntry>, | 1303 | candidates: &mut Vec<CompoundStackEntry>, |
| 1296 | newmv_count: &mut u32, | 1304 | newmv_count: &mut u32, |
| 1297 | ) -> bool { | 1305 | ) -> bool { |
| @@ -1305,8 +1313,8 @@ fn scan_corner_compound( | |||
| 1305 | { | 1313 | { |
| 1306 | add_compound_candidate( | 1314 | add_compound_candidate( |
| 1307 | candidates, | 1315 | candidates, |
| 1308 | - info.mv, | 1316 | + if info.is_global_mv0 { gm_mv(gm, ref_frame.0) } else { info.mv }, |
| 1309 | - info.mv1.unwrap_or((0, 0)), | 1317 | + if info.is_global_mv1 { gm_mv(gm, ref_frame.1) } else { info.mv1.unwrap_or((0, 0)) }, |
| 1310 | CORNER_WEIGHT, | 1318 | CORNER_WEIGHT, |
| 1311 | ); | 1319 | ); |
| 1312 | *newmv_count += u32::from(info.is_new_mv); | 1320 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -1413,6 +1421,7 @@ fn combine_compound_candidates(lists: &CompoundRefLists) -> [((i32, i32), (i32, | |||
| 1413 | /// ports of libaom's real behaviour as of r5 — see the inline comments at | 1421 | /// ports of libaom's real behaviour as of r5 — see the inline comments at |
| 1414 | /// each site. | 1422 | /// each site. |
| 1415 | #[allow(clippy::too_many_arguments)] | 1423 | #[allow(clippy::too_many_arguments)] |
| 1424 | +#[allow(clippy::too_many_arguments)] | ||
| 1416 | pub fn find_mv_stack_compound( | 1425 | pub fn find_mv_stack_compound( |
| 1417 | grid: &MiGrid, | 1426 | grid: &MiGrid, |
| 1418 | mi_row: usize, | 1427 | mi_row: usize, |
| @@ -1423,6 +1432,7 @@ pub fn find_mv_stack_compound( | |||
| 1423 | mi_cols: usize, | 1432 | mi_cols: usize, |
| 1424 | mi_rows: usize, | 1433 | mi_rows: usize, |
| 1425 | sign_bias_table: &SignBiasTable, | 1434 | sign_bias_table: &SignBiasTable, |
| 1435 | + gm: &GmMvTable, | ||
| 1426 | tpl: Option<CompoundTplArgs>, | 1436 | tpl: Option<CompoundTplArgs>, |
| 1427 | ) -> CompoundMvStack { | 1437 | ) -> CompoundMvStack { |
| 1428 | let mut candidates: Vec<CompoundStackEntry> = Vec::new(); | 1438 | let mut candidates: Vec<CompoundStackEntry> = Vec::new(); |
| @@ -1454,6 +1464,7 @@ pub fn find_mv_stack_compound( | |||
| 1454 | -1, | 1464 | -1, |
| 1455 | max_row_offset, | 1465 | max_row_offset, |
| 1456 | ref_frame, | 1466 | ref_frame, |
| 1467 | + gm, | ||
| 1457 | &mut candidates, | 1468 | &mut candidates, |
| 1458 | &mut newmv_count, | 1469 | &mut newmv_count, |
| 1459 | &mut processed_rows, | 1470 | &mut processed_rows, |
| @@ -1467,6 +1478,7 @@ pub fn find_mv_stack_compound( | |||
| 1467 | -1, | 1478 | -1, |
| 1468 | max_col_offset, | 1479 | max_col_offset, |
| 1469 | ref_frame, | 1480 | ref_frame, |
| 1481 | + gm, | ||
| 1470 | &mut candidates, | 1482 | &mut candidates, |
| 1471 | &mut newmv_count, | 1483 | &mut newmv_count, |
| 1472 | &mut processed_cols, | 1484 | &mut processed_cols, |
| @@ -1477,6 +1489,7 @@ pub fn find_mv_stack_compound( | |||
| 1477 | mi_col, | 1489 | mi_col, |
| 1478 | bw4, | 1490 | bw4, |
| 1479 | ref_frame, | 1491 | ref_frame, |
| 1492 | + gm, | ||
| 1480 | &mut candidates, | 1493 | &mut candidates, |
| 1481 | &mut newmv_count, | 1494 | &mut newmv_count, |
| 1482 | ); | 1495 | ); |
| @@ -1542,10 +1555,12 @@ pub fn find_mv_stack_compound( | |||
| 1542 | let mv1 = cand1.map_or((0, 0), |c| c.mv); | 1555 | let mv1 = cand1.map_or((0, 0), |c| c.mv); |
| 1543 | if blk_row == 0 && blk_col == 0 { | 1556 | if blk_row == 0 && blk_col == 0 { |
| 1544 | first_sample_missing = false; | 1557 | first_sample_missing = false; |
| 1545 | - first_sample_far = mv0.0.abs() >= 16 | 1558 | + let this_gm0 = gm_mv(gm, ref_frame.0); |
| 1546 | - || mv0.1.abs() >= 16 | 1559 | + let this_gm1 = gm_mv(gm, ref_frame.1); |
| 1547 | - || mv1.0.abs() >= 16 | 1560 | + first_sample_far = (mv0.0 - this_gm0.0).abs() >= 16 |
| 1548 | - || mv1.1.abs() >= 16; | 1561 | + || (mv0.1 - this_gm0.1).abs() >= 16 |
| 1562 | + || (mv1.0 - this_gm1.0).abs() >= 16 | ||
| 1563 | + || (mv1.1 - this_gm1.1).abs() >= 16; | ||
| 1549 | } | 1564 | } |
| 1550 | add_compound_candidate(&mut candidates, mv0, mv1, 2); | 1565 | add_compound_candidate(&mut candidates, mv0, mv1, 2); |
| 1551 | } | 1566 | } |
| @@ -1565,6 +1580,7 @@ pub fn find_mv_stack_compound( | |||
| 1565 | mi_row, | 1580 | mi_row, |
| 1566 | mi_col, | 1581 | mi_col, |
| 1567 | ref_frame, | 1582 | ref_frame, |
| 1583 | + gm, | ||
| 1568 | &mut candidates, | 1584 | &mut candidates, |
| 1569 | &mut dummy_newmv_count, | 1585 | &mut dummy_newmv_count, |
| 1570 | ); | 1586 | ); |
| @@ -1583,6 +1599,7 @@ pub fn find_mv_stack_compound( | |||
| 1583 | row_offset, | 1599 | row_offset, |
| 1584 | max_row_offset, | 1600 | max_row_offset, |
| 1585 | ref_frame, | 1601 | ref_frame, |
| 1602 | + gm, | ||
| 1586 | &mut candidates, | 1603 | &mut candidates, |
| 1587 | &mut dummy_newmv_count, | 1604 | &mut dummy_newmv_count, |
| 1588 | &mut processed_rows, | 1605 | &mut processed_rows, |
| @@ -1600,6 +1617,7 @@ pub fn find_mv_stack_compound( | |||
| 1600 | col_offset, | 1617 | col_offset, |
| 1601 | max_col_offset, | 1618 | max_col_offset, |
| 1602 | ref_frame, | 1619 | ref_frame, |
| 1620 | + gm, | ||
| 1603 | &mut candidates, | 1621 | &mut candidates, |
| 1604 | &mut dummy_newmv_count, | 1622 | &mut dummy_newmv_count, |
| 1605 | &mut processed_cols, | 1623 | &mut processed_cols, |