Gm r2 -- non-IDENTITY global motion decode compiles
Browse files at this commit9018cff8496198bc91de3af85a26b5a9834f9607Parent: 5417eab- feat
- gm r2 -- non-IDENTITY global motion decode compiles
2 changed files +48 -3
crates/ec-av1/src/decode.rsmodified+47 -3
| @@ -6170,6 +6170,18 @@ fn decode_inter_block( | |||
| 6170 | }; | 6170 | }; |
| 6171 | (mv, false) | 6171 | (mv, false) |
| 6172 | }; | 6172 | }; |
| 6173 | + // lane-gm r2: the two libaom predicates single-ref GLOBALMV | ||
| 6174 | + // blocks need -- `is_global_mv_block` (blockd.h:421-429, mode | ||
| 6175 | + // GLOBAL* AND model > TRANSLATION AND min(bw,bh) >= 8px, gating | ||
| 6176 | + // `motion_mode_eligible`/`MiInfo::is_global_mv0` below) and | ||
| 6177 | + // `is_nontrans_global_motion` (reconinter.h:420-425, model != | ||
| 6178 | + // TRANSLATION -- IDENTITY counts here -- gating the interp | ||
| 6179 | + // filter suppress below). Do NOT unify these. | ||
| 6180 | + let gm_model = global_motion[(ref_frame - LAST_FRAME) as usize].model; | ||
| 6181 | + let min_bw_bh4 = bw4.min(bh4); | ||
| 6182 | + let is_global_mv_block = is_globalmv && gm_model as u8 > 1 && min_bw_bh4 >= 2; | ||
| 6183 | + let gm_nontrans = | ||
| 6184 | + is_globalmv && gm_model != ec_av1_syntax::WarpModel::Translation && min_bw_bh4 >= 2; | ||
| 6173 | if std::env::var_os("EC_AV1_TELL").is_some() { | 6185 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 6174 | eprintln!( | 6186 | eprintln!( |
| 6175 | "TELL mi_row={mi_row} mi_col={mi_col} label=post_assign_mv tell={} range={}", | 6187 | "TELL mi_row={mi_row} mi_col={mi_col} label=post_assign_mv tell={} range={}", |
| @@ -6254,7 +6266,12 @@ fn decode_inter_block( | |||
| 6254 | && interintra_mode.is_none() | 6266 | && interintra_mode.is_none() |
| 6255 | && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty() | 6267 | && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty() |
| 6256 | || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1) | 6268 | || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1) |
| 6257 | - .is_empty()); | 6269 | + .is_empty()) |
| 6270 | + // libaom `motion_mode_allowed`: a GLOBALMV block whose model | ||
| 6271 | + // is non-IDENTITY-non-TRANSLATION under free (non-integer) | ||
| 6272 | + // mv reads no motion_mode/obmc symbol at all -- implicit | ||
| 6273 | + // SIMPLE_TRANSLATION. | ||
| 6274 | + && !(is_global_mv_block && !force_integer_mv); | ||
| 6258 | let mut obmc_selected = false; | 6275 | let mut obmc_selected = false; |
| 6259 | // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL | 6276 | // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL |
| 6260 | // *and* the local warp estimate is valid (`!wm_params.invalid`, | 6277 | // *and* the local warp estimate is valid (`!wm_params.invalid`, |
| @@ -6391,7 +6408,7 @@ fn decode_inter_block( | |||
| 6391 | cdfs, | 6408 | cdfs, |
| 6392 | interp_fixed, | 6409 | interp_fixed, |
| 6393 | enable_dual_filter, | 6410 | enable_dual_filter, |
| 6394 | - is_globalmv || warped_selected, | 6411 | + gm_nontrans || warped_selected, |
| 6395 | above_filter_ctx, | 6412 | above_filter_ctx, |
| 6396 | left_filter_ctx, | 6413 | left_filter_ctx, |
| 6397 | false, | 6414 | false, |
| @@ -6433,7 +6450,7 @@ fn decode_inter_block( | |||
| 6433 | is_new_mv, | 6450 | is_new_mv, |
| 6434 | size: bw4, | 6451 | size: bw4, |
| 6435 | size_h: bh4, | 6452 | size_h: bh4, |
| 6436 | - is_global_mv0: false, | 6453 | + is_global_mv0: is_global_mv_block, |
| 6437 | is_global_mv1: false, | 6454 | is_global_mv1: false, |
| 6438 | }, | 6455 | }, |
| 6439 | ); | 6456 | ); |
| @@ -7018,6 +7035,7 @@ fn decode_inter_block8( | |||
| 7018 | mi_cols as usize, | 7035 | mi_cols as usize, |
| 7019 | mi_rows as usize, | 7036 | mi_rows as usize, |
| 7020 | &NO_SIGN_BIAS, | 7037 | &NO_SIGN_BIAS, |
| 7038 | + &crate::mvstack::NO_GM_MV, | ||
| 7021 | None, | 7039 | None, |
| 7022 | ); | 7040 | ); |
| 7023 | let compound_mode = if skip_mode { | 7041 | let compound_mode = if skip_mode { |
| @@ -7037,6 +7055,9 @@ fn decode_inter_block8( | |||
| 7037 | compound_mode, | 7055 | compound_mode, |
| 7038 | allow_high_precision_mv, | 7056 | allow_high_precision_mv, |
| 7039 | force_integer_mv, | 7057 | force_integer_mv, |
| 7058 | + // leaf8 stays gm-inert (sanctioned partial landing, see | ||
| 7059 | + // this fn's own GLOBALMV refusal below). | ||
| 7060 | + ((0, 0), (0, 0)), | ||
| 7040 | ); | 7061 | ); |
| 7041 | 7062 | ||
| 7042 | // spec 5.11.25: same gating [`decode_inter_block`]'s own | 7063 | // spec 5.11.25: same gating [`decode_inter_block`]'s own |
| @@ -7891,6 +7912,7 @@ pub fn decode_inter_frame_tile( | |||
| 7891 | allow_high_precision_mv, | 7912 | allow_high_precision_mv, |
| 7892 | force_integer_mv, | 7913 | force_integer_mv, |
| 7893 | NO_SIGN_BIAS, | 7914 | NO_SIGN_BIAS, |
| 7915 | + [ec_av1_syntax::WarpParams::default(); 7], | ||
| 7894 | interp_fixed, | 7916 | interp_fixed, |
| 7895 | enable_dual_filter, | 7917 | enable_dual_filter, |
| 7896 | 0, | 7918 | 0, |
| @@ -7930,6 +7952,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 7930 | allow_high_precision_mv: bool, | 7952 | allow_high_precision_mv: bool, |
| 7931 | force_integer_mv: bool, | 7953 | force_integer_mv: bool, |
| 7932 | sign_bias_table: SignBiasTable, | 7954 | sign_bias_table: SignBiasTable, |
| 7955 | + // lane-gm r2: this frame header's own `global_motion` table (spec | ||
| 7956 | + // 5.9.24), threaded to every `decode_inter_block` call below. | ||
| 7957 | + global_motion: [ec_av1_syntax::WarpParams; 7], | ||
| 7933 | interp_fixed: Option<mc::InterpFilterKind>, | 7958 | interp_fixed: Option<mc::InterpFilterKind>, |
| 7934 | enable_dual_filter: bool, | 7959 | enable_dual_filter: bool, |
| 7935 | // lane-av1tmvp: `order_hint`/`order_hint_bits`/`ref_order_hints` are | 7960 | // lane-av1tmvp: `order_hint`/`order_hint_bits`/`ref_order_hints` are |
| @@ -8183,6 +8208,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8183 | &ref_v, | 8208 | &ref_v, |
| 8184 | &ref_slots, | 8209 | &ref_slots, |
| 8185 | &sign_bias_table, | 8210 | &sign_bias_table, |
| 8211 | + &global_motion, | ||
| 8186 | base_q_idx, | 8212 | base_q_idx, |
| 8187 | TxbSet::Luma32, | 8213 | TxbSet::Luma32, |
| 8188 | TxbSet::Luma32Inter, | 8214 | TxbSet::Luma32Inter, |
| @@ -8256,6 +8282,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8256 | &ref_v, | 8282 | &ref_v, |
| 8257 | &ref_slots, | 8283 | &ref_slots, |
| 8258 | &sign_bias_table, | 8284 | &sign_bias_table, |
| 8285 | + &global_motion, | ||
| 8259 | base_q_idx, | 8286 | base_q_idx, |
| 8260 | TxbSet::Luma16, | 8287 | TxbSet::Luma16, |
| 8261 | if reduced_tx_set { | 8288 | if reduced_tx_set { |
| @@ -8432,6 +8459,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8432 | &ref_v, | 8459 | &ref_v, |
| 8433 | &ref_slots, | 8460 | &ref_slots, |
| 8434 | &sign_bias_table, | 8461 | &sign_bias_table, |
| 8462 | + &global_motion, | ||
| 8435 | base_q_idx, | 8463 | base_q_idx, |
| 8436 | TxbSet::Luma32, | 8464 | TxbSet::Luma32, |
| 8437 | TxbSet::Luma32Inter, | 8465 | TxbSet::Luma32Inter, |
| @@ -8482,6 +8510,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8482 | &ref_v, | 8510 | &ref_v, |
| 8483 | &ref_slots, | 8511 | &ref_slots, |
| 8484 | &sign_bias_table, | 8512 | &sign_bias_table, |
| 8513 | + &global_motion, | ||
| 8485 | base_q_idx, | 8514 | base_q_idx, |
| 8486 | TxbSet::Luma16, | 8515 | TxbSet::Luma16, |
| 8487 | if reduced_tx_set { | 8516 | if reduced_tx_set { |
| @@ -8533,6 +8562,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8533 | &ref_v, | 8562 | &ref_v, |
| 8534 | &ref_slots, | 8563 | &ref_slots, |
| 8535 | &sign_bias_table, | 8564 | &sign_bias_table, |
| 8565 | + &global_motion, | ||
| 8536 | base_q_idx, | 8566 | base_q_idx, |
| 8537 | TxbSet::Luma16, | 8567 | TxbSet::Luma16, |
| 8538 | if reduced_tx_set { | 8568 | if reduced_tx_set { |
| @@ -8594,6 +8624,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8594 | &ref_v, | 8624 | &ref_v, |
| 8595 | &ref_slots, | 8625 | &ref_slots, |
| 8596 | &sign_bias_table, | 8626 | &sign_bias_table, |
| 8627 | + &global_motion, | ||
| 8597 | base_q_idx, | 8628 | base_q_idx, |
| 8598 | TxbSet::Luma32, | 8629 | TxbSet::Luma32, |
| 8599 | TxbSet::Luma32Inter, | 8630 | TxbSet::Luma32Inter, |
| @@ -8640,6 +8671,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8640 | &ref_v, | 8671 | &ref_v, |
| 8641 | &ref_slots, | 8672 | &ref_slots, |
| 8642 | &sign_bias_table, | 8673 | &sign_bias_table, |
| 8674 | + &global_motion, | ||
| 8643 | base_q_idx, | 8675 | base_q_idx, |
| 8644 | TxbSet::Luma32, | 8676 | TxbSet::Luma32, |
| 8645 | TxbSet::Luma32Inter, | 8677 | TxbSet::Luma32Inter, |
| @@ -8691,6 +8723,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8691 | &ref_v, | 8723 | &ref_v, |
| 8692 | &ref_slots, | 8724 | &ref_slots, |
| 8693 | &sign_bias_table, | 8725 | &sign_bias_table, |
| 8726 | + &global_motion, | ||
| 8694 | base_q_idx, | 8727 | base_q_idx, |
| 8695 | TxbSet::Luma32, | 8728 | TxbSet::Luma32, |
| 8696 | TxbSet::Luma32Inter, | 8729 | TxbSet::Luma32Inter, |
| @@ -8737,6 +8770,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8737 | &ref_v, | 8770 | &ref_v, |
| 8738 | &ref_slots, | 8771 | &ref_slots, |
| 8739 | &sign_bias_table, | 8772 | &sign_bias_table, |
| 8773 | + &global_motion, | ||
| 8740 | base_q_idx, | 8774 | base_q_idx, |
| 8741 | TxbSet::Luma32, | 8775 | TxbSet::Luma32, |
| 8742 | TxbSet::Luma32Inter, | 8776 | TxbSet::Luma32Inter, |
| @@ -8789,6 +8823,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8789 | &ref_v, | 8823 | &ref_v, |
| 8790 | &ref_slots, | 8824 | &ref_slots, |
| 8791 | &sign_bias_table, | 8825 | &sign_bias_table, |
| 8826 | + &global_motion, | ||
| 8792 | base_q_idx, | 8827 | base_q_idx, |
| 8793 | TxbSet::Luma16, | 8828 | TxbSet::Luma16, |
| 8794 | if reduced_tx_set { | 8829 | if reduced_tx_set { |
| @@ -8839,6 +8874,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8839 | &ref_v, | 8874 | &ref_v, |
| 8840 | &ref_slots, | 8875 | &ref_slots, |
| 8841 | &sign_bias_table, | 8876 | &sign_bias_table, |
| 8877 | + &global_motion, | ||
| 8842 | base_q_idx, | 8878 | base_q_idx, |
| 8843 | TxbSet::Luma16, | 8879 | TxbSet::Luma16, |
| 8844 | if reduced_tx_set { | 8880 | if reduced_tx_set { |
| @@ -8889,6 +8925,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8889 | &ref_v, | 8925 | &ref_v, |
| 8890 | &ref_slots, | 8926 | &ref_slots, |
| 8891 | &sign_bias_table, | 8927 | &sign_bias_table, |
| 8928 | + &global_motion, | ||
| 8892 | base_q_idx, | 8929 | base_q_idx, |
| 8893 | TxbSet::Luma32, | 8930 | TxbSet::Luma32, |
| 8894 | TxbSet::Luma32Inter, | 8931 | TxbSet::Luma32Inter, |
| @@ -8940,6 +8977,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8940 | &ref_v, | 8977 | &ref_v, |
| 8941 | &ref_slots, | 8978 | &ref_slots, |
| 8942 | &sign_bias_table, | 8979 | &sign_bias_table, |
| 8980 | + &global_motion, | ||
| 8943 | base_q_idx, | 8981 | base_q_idx, |
| 8944 | TxbSet::Luma16, | 8982 | TxbSet::Luma16, |
| 8945 | if reduced_tx_set { | 8983 | if reduced_tx_set { |
| @@ -8990,6 +9028,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8990 | &ref_v, | 9028 | &ref_v, |
| 8991 | &ref_slots, | 9029 | &ref_slots, |
| 8992 | &sign_bias_table, | 9030 | &sign_bias_table, |
| 9031 | + &global_motion, | ||
| 8993 | base_q_idx, | 9032 | base_q_idx, |
| 8994 | TxbSet::Luma16, | 9033 | TxbSet::Luma16, |
| 8995 | if reduced_tx_set { | 9034 | if reduced_tx_set { |
| @@ -9040,6 +9079,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9040 | &ref_v, | 9079 | &ref_v, |
| 9041 | &ref_slots, | 9080 | &ref_slots, |
| 9042 | &sign_bias_table, | 9081 | &sign_bias_table, |
| 9082 | + &global_motion, | ||
| 9043 | base_q_idx, | 9083 | base_q_idx, |
| 9044 | TxbSet::Luma32, | 9084 | TxbSet::Luma32, |
| 9045 | TxbSet::Luma32Inter, | 9085 | TxbSet::Luma32Inter, |
| @@ -9092,6 +9132,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9092 | &ref_v, | 9132 | &ref_v, |
| 9093 | &ref_slots, | 9133 | &ref_slots, |
| 9094 | &sign_bias_table, | 9134 | &sign_bias_table, |
| 9135 | + &global_motion, | ||
| 9095 | base_q_idx, | 9136 | base_q_idx, |
| 9096 | TxbSet::Luma32, | 9137 | TxbSet::Luma32, |
| 9097 | TxbSet::Luma32Inter, | 9138 | TxbSet::Luma32Inter, |
| @@ -9138,6 +9179,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9138 | &ref_v, | 9179 | &ref_v, |
| 9139 | &ref_slots, | 9180 | &ref_slots, |
| 9140 | &sign_bias_table, | 9181 | &sign_bias_table, |
| 9182 | + &global_motion, | ||
| 9141 | base_q_idx, | 9183 | base_q_idx, |
| 9142 | TxbSet::Luma16, | 9184 | TxbSet::Luma16, |
| 9143 | if reduced_tx_set { | 9185 | if reduced_tx_set { |
| @@ -9188,6 +9230,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9188 | &ref_v, | 9230 | &ref_v, |
| 9189 | &ref_slots, | 9231 | &ref_slots, |
| 9190 | &sign_bias_table, | 9232 | &sign_bias_table, |
| 9233 | + &global_motion, | ||
| 9191 | base_q_idx, | 9234 | base_q_idx, |
| 9192 | TxbSet::Luma16, | 9235 | TxbSet::Luma16, |
| 9193 | if reduced_tx_set { | 9236 | if reduced_tx_set { |
| @@ -9958,6 +10001,7 @@ mod tests { | |||
| 9958 | &ref_v, | 10001 | &ref_v, |
| 9959 | &[None; 8], | 10002 | &[None; 8], |
| 9960 | &NO_SIGN_BIAS, | 10003 | &NO_SIGN_BIAS, |
| 10004 | + &[ec_av1_syntax::WarpParams::default(); 7], | ||
| 9961 | 100, | 10005 | 100, |
| 9962 | TxbSet::Luma16, | 10006 | TxbSet::Luma16, |
| 9963 | TxbSet::Luma16Inter, | 10007 | TxbSet::Luma16Inter, |
crates/ec-av1/src/stream.rsmodified+1 -0
| @@ -374,6 +374,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 374 | header.allow_high_precision_mv, | 374 | header.allow_high_precision_mv, |
| 375 | header.force_integer_mv, | 375 | header.force_integer_mv, |
| 376 | header.ref_frame_sign_bias, | 376 | header.ref_frame_sign_bias, |
| 377 | + header.global_motion, | ||
| 377 | interp_fixed, | 378 | interp_fixed, |
| 378 | enable_dual_filter, | 379 | enable_dual_filter, |
| 379 | order_hint_bits, | 380 | order_hint_bits, |