Merge branch 'lane-av1obmc' (5ea7a530): motion_mode syntax and an OBMC candidate, behind EC_AV1_OBMC
Browse files at this commit3 changed files +418 -17
- crates/ec-av1/src/decode.rs +69 -14
- crates/ec-av1/src/encode.rs +219 -3
- crates/ec-av1/src/tile.rs +130 -0
crates/ec-av1/src/decode.rsmodified+69 -14
| @@ -24179,6 +24179,25 @@ fn overlappable_left( | ||
| 24179 | 24179 | out |
| 24180 | 24180 | } |
| 24181 | 24181 | |
| 24182 | +/// libaom `motion_mode_allowed`'s neighbour term: does ANY bordering inter | |
| 24183 | +/// block sit on this block's above row or left column ("check_num_overlappable | |
| 24184 | +/// _neighbors", `obmc.h`). The single source of truth for the DECODER's own | |
| 24185 | +/// `motion_mode_eligible` and for the tile WRITER's (`tile::write_motion_mode`) | |
| 24186 | +/// -- the two disagreeing by one block writes a `motion_mode` symbol the | |
| 24187 | +/// decoder never reads (class `symbol-consumption-gap`). | |
| 24188 | +pub(crate) fn has_overlappable_neighbour( | |
| 24189 | + grid: &MiGrid, | |
| 24190 | + mi_row: usize, | |
| 24191 | + mi_col: usize, | |
| 24192 | + bw4: usize, | |
| 24193 | + bh4: usize, | |
| 24194 | + mi_cols: usize, | |
| 24195 | + mi_rows: usize, | |
| 24196 | +) -> bool { | |
| 24197 | + !overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, 1).is_empty() | |
| 24198 | + || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, 1).is_empty() | |
| 24199 | +} | |
| 24200 | + | |
| 24182 | 24201 | /// The warp-sample gather's own `has_top_right` probe (libaom `av1_findSamples` |
| 24183 | 24202 | /// calls the same `mvref_common.c` function the MV stack does). lane-sb128 r2: |
| 24184 | 24203 | /// this used to hardcode `SB_MI` (a 64x64 superblock) -- at `sb_size == 128` |
| @@ -24753,9 +24772,18 @@ nbmv=({},{}) nbref={} nbbsize={} filt={}", | ||
| 24753 | 24772 | /// how many bordering blocks actually get blended, separate from the |
| 24754 | 24773 | /// eligibility scan's own unbounded ("any at all") walk. |
| 24755 | 24774 | #[allow(clippy::too_many_arguments)] |
| 24756 | -fn obmc_plan( | |
| 24775 | +pub(crate) fn obmc_plan( | |
| 24757 | 24776 | grid: &MiGrid, |
| 24758 | - neighbours: &Neighbours, | |
| 24777 | + // The two switchable-filter bands (`Neighbours::above_filter`/ | |
| 24778 | + // `left_filter`), read only when `interp_fixed` is `None`. The ENCODER | |
| 24779 | + // (`encode.rs`'s OBMC candidate) codes a fixed interpolation filter and | |
| 24780 | + // has no `Neighbours` of its own, so it passes both empty; the reads | |
| 24781 | + // below fall back to the `[3, 3]` never-recorded sentinel, which | |
| 24782 | + // `neighbour_filter` never reaches under a fixed filter. | |
| 24783 | + // corner-cut: ceiling is a switchable-filter ENCODER -- it must build and | |
| 24784 | + // pass the real bands here, exactly as the decoder does. | |
| 24785 | + above_filter: &[[u8; 2]], | |
| 24786 | + left_filter: &[[u8; 2]], | |
| 24759 | 24787 | mi_row: usize, |
| 24760 | 24788 | mi_col: usize, |
| 24761 | 24789 | bw4: usize, |
| @@ -24822,7 +24850,7 @@ fn obmc_plan( | ||
| 24822 | 24850 | // neighbour's OWN mi-granular filter (libaom |
| 24823 | 24851 | // `av1_setup_build_prediction_by_above_pred` reads |
| 24824 | 24852 | // `above_mbmi->interp_filters`). |
| 24825 | - let above_syms = neighbours.above_filter[mi_col + src4]; | |
| 24853 | + let above_syms = above_filter.get(mi_col + src4).copied().unwrap_or([3; 2]); | |
| 24826 | 24854 | obmcrec_probe( |
| 24827 | 24855 | "above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, above_syms, |
| 24828 | 24856 | grid.get(mi_row - 1, mi_col + src4), interp_fixed.is_some(), |
| @@ -24846,7 +24874,7 @@ fn obmc_plan( | ||
| 24846 | 24874 | let mut left = Vec::new(); |
| 24847 | 24875 | for (off4, span4, nb, src4) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) |
| 24848 | 24876 | { |
| 24849 | - let left_syms = neighbours.left_filter[mi_row + src4]; | |
| 24877 | + let left_syms = left_filter.get(mi_row + src4).copied().unwrap_or([3; 2]); | |
| 24850 | 24878 | obmcrec_probe( |
| 24851 | 24879 | "left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, left_syms, |
| 24852 | 24880 | grid.get(mi_row + src4, mi_col - 1), interp_fixed.is_some(), |
| @@ -24921,7 +24949,7 @@ pub(crate) struct ObmcPlan { | ||
| 24921 | 24949 | /// (libaom `av1_build_obmc_inter_prediction`). Reads nothing but reference |
| 24922 | 24950 | /// pixels and the plan, so it runs wherever the block's prediction is built |
| 24923 | 24951 | /// -- on a recon worker when that prediction is deferred (lane-defer8). |
| 24924 | -fn obmc_run( | |
| 24952 | +pub(crate) fn obmc_run( | |
| 24925 | 24953 | plan: &ObmcPlan, |
| 24926 | 24954 | refpix: &RefPix<'_>, |
| 24927 | 24955 | pred_y: &mut [u16], |
| @@ -27249,9 +27277,9 @@ fn decode_inter_block( | ||
| 27249 | 27277 | // min(bw, bh) >= 8, false for a 16x4 / 4x16 strip. |
| 27250 | 27278 | && write_w.min(write_h) >= 8 |
| 27251 | 27279 | && interintra_mode.is_none() |
| 27252 | - && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty() | |
| 27253 | - || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1) | |
| 27254 | - .is_empty()) | |
| 27280 | + && has_overlappable_neighbour( | |
| 27281 | + grid, mi_row, mi_col, bw4, bh4, mi_cols as usize, mi_rows as usize, | |
| 27282 | + ) | |
| 27255 | 27283 | // libaom `motion_mode_allowed`: a GLOBALMV block whose model |
| 27256 | 27284 | // is non-IDENTITY-non-TRANSLATION under free (non-integer) |
| 27257 | 27285 | // mv reads no motion_mode/obmc symbol at all -- implicit |
| @@ -27603,7 +27631,8 @@ fn decode_inter_block( | ||
| 27603 | 27631 | let obmc = if obmc_selected { |
| 27604 | 27632 | Some(obmc_plan( |
| 27605 | 27633 | grid, |
| 27606 | - neighbours, | |
| 27634 | + &neighbours.above_filter, | |
| 27635 | + &neighbours.left_filter, | |
| 27607 | 27636 | mi_row, |
| 27608 | 27637 | mi_col, |
| 27609 | 27638 | bw4, |
| @@ -31988,8 +32017,9 @@ fn decode_inter_block8( | ||
| 31988 | 32017 | && !skip_mode |
| 31989 | 32018 | && interintra_mode.is_none() |
| 31990 | 32019 | && !(is_global_mv_block && !force_integer_mv) |
| 31991 | - && (!overlappable_above(grid, mi_row, mi_col, 2, mi_cols as usize, 1).is_empty() | |
| 31992 | - || !overlappable_left(grid, mi_row, mi_col, 2, mi_rows as usize, 1).is_empty()); | |
| 32020 | + && has_overlappable_neighbour( | |
| 32021 | + grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, | |
| 32022 | + ); | |
| 31993 | 32023 | let mut warp_params: Option<crate::warp::WarpParams> = None; |
| 31994 | 32024 | let mut warped_selected = false; |
| 31995 | 32025 | let mut obmc_selected = false; |
| @@ -32189,7 +32219,8 @@ fn decode_inter_block8( | ||
| 32189 | 32219 | let obmc = if obmc_selected { |
| 32190 | 32220 | Some(obmc_plan( |
| 32191 | 32221 | grid, |
| 32192 | - neighbours, | |
| 32222 | + &neighbours.above_filter, | |
| 32223 | + &neighbours.left_filter, | |
| 32193 | 32224 | mi_row, |
| 32194 | 32225 | mi_col, |
| 32195 | 32226 | 2, |
| @@ -33043,13 +33074,19 @@ pub(crate) fn decode_inter_frame_tile( | ||
| 33043 | 33074 | // starts from what the previous frame stored, not from the defaults. Same |
| 33044 | 33075 | // class as `tx_select` above, third instance. |
| 33045 | 33076 | initial_cdfs: Option<Cdfs>, |
| 33077 | + // lane-av1obmc: this frame header's own `is_motion_mode_switchable` | |
| 33078 | + // (spec 5.9.2). Hard-coding `false` here desynced every stream this | |
| 33079 | + // crate's own encoder writes once inter blocks started carrying a | |
| 33080 | + // `motion_mode` symbol (class: test asserts against a stale header). | |
| 33081 | + switchable_motion_mode: bool, | |
| 33046 | 33082 | fctx: &crate::decode::FrameCtx, |
| 33047 | 33083 | ) -> Result<Picture> { |
| 33048 | 33084 | decode_inter_frame_tile_lr( |
| 33049 | 33085 | data, mi_cols, mi_rows, base_q_idx, frame_width, frame_height, refpix, cdef, |
| 33050 | 33086 | loop_filter, allow_high_precision_mv, force_integer_mv, interp_fixed, |
| 33051 | 33087 | enable_dual_filter, reference_select, tx_select, |
| 33052 | - &LoopRestorationParams::default(), initial_cdfs, NO_SIGN_BIAS, false, fctx, | |
| 33088 | + &LoopRestorationParams::default(), initial_cdfs, NO_SIGN_BIAS, false, | |
| 33089 | + switchable_motion_mode, fctx, | |
| 33053 | 33090 | ) |
| 33054 | 33091 | } |
| 33055 | 33092 | |
| @@ -33090,6 +33127,11 @@ pub(crate) fn decode_inter_frame_tile_lr( | ||
| 33090 | 33127 | // `sign_bias` rather than beside the other bools on purpose (the |
| 33091 | 33128 | // `adjacent-same-typed-args` class). |
| 33092 | 33129 | allow_screen_content_tools: bool, |
| 33130 | + // lane-av1obmc: this frame header's own `is_motion_mode_switchable` | |
| 33131 | + // (spec 5.9.2). Hard-coding `false` here desynced every stream this | |
| 33132 | + // crate's own encoder writes once inter blocks started carrying a | |
| 33133 | + // `motion_mode` symbol (class: test asserts against a stale header). | |
| 33134 | + switchable_motion_mode: bool, | |
| 33093 | 33135 | fctx: &crate::decode::FrameCtx, |
| 33094 | 33136 | ) -> Result<Picture> { |
| 33095 | 33137 | let single_tile = TileInfo { |
| @@ -33118,6 +33160,7 @@ pub(crate) fn decode_inter_frame_tile_lr( | ||
| 33118 | 33160 | initial_cdfs, |
| 33119 | 33161 | sign_bias, |
| 33120 | 33162 | allow_screen_content_tools, |
| 33163 | + switchable_motion_mode, | |
| 33121 | 33164 | fctx, |
| 33122 | 33165 | ) |
| 33123 | 33166 | } |
| @@ -33148,6 +33191,11 @@ pub(crate) fn decode_inter_frame_tiles_lr( | ||
| 33148 | 33191 | // This frame header's own `allow_screen_content_tools` (see the |
| 33149 | 33192 | // single-tile wrapper): the palette syntax its intra blocks carry. |
| 33150 | 33193 | allow_screen_content_tools: bool, |
| 33194 | + // lane-av1obmc: this frame header's own `is_motion_mode_switchable` | |
| 33195 | + // (spec 5.9.2). Hard-coding `false` here desynced every stream this | |
| 33196 | + // crate's own encoder writes once inter blocks started carrying a | |
| 33197 | + // `motion_mode` symbol (class: test asserts against a stale header). | |
| 33198 | + switchable_motion_mode: bool, | |
| 33151 | 33199 | fctx: &crate::decode::FrameCtx, |
| 33152 | 33200 | ) -> Result<Picture> { |
| 33153 | 33201 | decode_inter_frame_tile_with_cdfs( |
| @@ -33182,7 +33230,7 @@ pub(crate) fn decode_inter_frame_tiles_lr( | ||
| 33182 | 33230 | [0; 2], |
| 33183 | 33231 | true, |
| 33184 | 33232 | tx_select, |
| 33185 | - false, | |
| 33233 | + switchable_motion_mode, | |
| 33186 | 33234 | false, |
| 33187 | 33235 | allow_screen_content_tools, |
| 33188 | 33236 | DeltaParams::default(), |
| @@ -37314,6 +37362,7 @@ mod tests { | ||
| 37314 | 37362 | false, |
| 37315 | 37363 | false, |
| 37316 | 37364 | None, |
| 37365 | + false, | |
| 37317 | 37366 | fctx, |
| 37318 | 37367 | ) |
| 37319 | 37368 | .unwrap_err(); |
| @@ -37732,6 +37781,9 @@ mod tests { | ||
| 37732 | 37781 | // This frame's own `allow_screen_content_tools`, off the |
| 37733 | 37782 | // `Encoded` the encoder handed back (stale-header class). |
| 37734 | 37783 | frame.screen, |
| 37784 | + // Same stale-header class: the bit that makes this frame's | |
| 37785 | + // inter blocks carry a `motion_mode` symbol. | |
| 37786 | + frame.switchable_motion_mode, | |
| 37735 | 37787 | fctx, |
| 37736 | 37788 | ) |
| 37737 | 37789 | .unwrap(); |
| @@ -38063,6 +38115,9 @@ mod tests { | ||
| 38063 | 38115 | // This frame's own `allow_screen_content_tools`, off the |
| 38064 | 38116 | // `Encoded` the encoder handed back (stale-header class). |
| 38065 | 38117 | frame.screen, |
| 38118 | + // Same stale-header class: the bit that makes this frame's | |
| 38119 | + // inter blocks carry a `motion_mode` symbol. | |
| 38120 | + frame.switchable_motion_mode, | |
| 38066 | 38121 | fctx, |
| 38067 | 38122 | ) |
| 38068 | 38123 | .unwrap(); |
crates/ec-av1/src/encode.rsmodified+219 -3
| @@ -693,6 +693,7 @@ pub(crate) fn crop_encoded(encoded: &Encoded, width: usize, height: usize) -> En | ||
| 693 | 693 | mi_rows: encoded.mi_rows, |
| 694 | 694 | base_q_idx: encoded.base_q_idx, |
| 695 | 695 | tx_select: encoded.tx_select, |
| 696 | + switchable_motion_mode: encoded.switchable_motion_mode, | |
| 696 | 697 | screen: encoded.screen, |
| 697 | 698 | start_cdfs: encoded.start_cdfs.clone(), |
| 698 | 699 | next_cdfs: encoded.next_cdfs.clone(), |
| @@ -747,6 +748,12 @@ pub struct Encoded { | ||
| 747 | 748 | /// a `tx_depth` frame as a `TxMode::Largest` one and desyncs at the first |
| 748 | 749 | /// block. |
| 749 | 750 | pub(crate) tx_select: bool, |
| 751 | + /// This frame header's `is_motion_mode_switchable` (spec 5.9.2) -- the | |
| 752 | + /// bit that makes every eligible single-reference inter block carry a | |
| 753 | + /// `motion_mode` symbol. Same contract as `tx_select` above: a test | |
| 754 | + /// decoding `tile` directly must pass it along or it desyncs at the | |
| 755 | + /// first eligible block. | |
| 756 | + pub(crate) switchable_motion_mode: bool, | |
| 750 | 757 | /// The CDF state this frame's tile writer started from -- the defaults |
| 751 | 758 | /// for a key frame and for the first inter frame, and the previous |
| 752 | 759 | /// frame's stored tables after that. A test that decodes `tile` directly |
| @@ -1152,7 +1159,16 @@ pub fn inter_frame_headers_slots( | ||
| 1152 | 1159 | }, |
| 1153 | 1160 | allow_high_precision_mv: false, |
| 1154 | 1161 | interpolation_filter: ec_av1_syntax::InterpolationFilter::Eighttap, |
| 1155 | - is_motion_mode_switchable: false, | |
| 1162 | + // lane-av1obmc: with this bit set every single-reference inter block | |
| 1163 | + // libaom's `motion_mode_allowed` accepts carries a `motion_mode` | |
| 1164 | + // symbol (`crate::tile::write_motion_mode`); `allow_warped_motion` | |
| 1165 | + // stays false, so the alphabet is the 2-symbol `obmc_cdf`. It is tied | |
| 1166 | + // to the OBMC knob rather than always on: with every block choosing | |
| 1167 | + // SIMPLE_TRANSLATION the symbol is pure cost (+0.07% / +0.02% on the | |
| 1168 | + // gate clip), so the DEFAULT path writes no motion_mode syntax at all | |
| 1169 | + // and stays byte-identical to the streams before this lane. A future | |
| 1170 | + // warp knob joins this disjunction. | |
| 1171 | + is_motion_mode_switchable: crate::envflags::env_flag!("EC_AV1_OBMC"), | |
| 1156 | 1172 | use_ref_frame_mvs: false, |
| 1157 | 1173 | // Forces `get_tx_set` (spec 5.11.48) to the two-symbol |
| 1158 | 1174 | // `TX_SET_INTER_3` for every inter transform below 32x32 -- the only |
| @@ -2226,6 +2242,16 @@ impl Reach { | ||
| 2226 | 2242 | } |
| 2227 | 2243 | |
| 2228 | 2244 | /// What one symbol costs against a CDF, in bits. |
| 2245 | +/// What the `motion_mode`/`obmc` symbol costs (spec 5.11.24), off the default | |
| 2246 | +/// table rather than the tile's adapted one -- the same static-CDF estimate | |
| 2247 | +/// every other symbol in this search is priced with. | |
| 2248 | +fn obmc_bits(write_w: usize, write_h: usize, obmc: bool) -> f64 { | |
| 2249 | + let Some(row) = crate::decode::motion_mode_cdf_row(write_w, write_h) else { | |
| 2250 | + return 0.0; | |
| 2251 | + }; | |
| 2252 | + symbol_bits(&cdf::OBMC[row], usize::from(obmc)) | |
| 2253 | +} | |
| 2254 | + | |
| 2229 | 2255 | pub(crate) fn symbol_bits(cdf: &[u16], symbol: usize) -> f64 { |
| 2230 | 2256 | let low = if symbol == 0 { 0 } else { cdf[symbol - 1] }; |
| 2231 | 2257 | let width = cdf[symbol] - low; |
| @@ -3855,6 +3881,7 @@ fn code_square_inter( | ||
| 3855 | 3881 | palette_uv: None, |
| 3856 | 3882 | tx_depth, |
| 3857 | 3883 | inter: Some(info), |
| 3884 | + obmc: false, | |
| 3858 | 3885 | }, |
| 3859 | 3886 | cost + dcost, |
| 3860 | 3887 | ); |
| @@ -3886,6 +3913,7 @@ fn code_square_inter( | ||
| 3886 | 3913 | palette: None, |
| 3887 | 3914 | palette_uv: None, |
| 3888 | 3915 | tx_depth, |
| 3916 | + obmc: false, | |
| 3889 | 3917 | inter: Some(InterInfo { |
| 3890 | 3918 | ref1: None, |
| 3891 | 3919 | mv1: (0, 0), |
| @@ -5047,6 +5075,8 @@ pub(crate) fn encode_key_frame_inner( | ||
| 5047 | 5075 | mi_rows: header.mi_rows, |
| 5048 | 5076 | base_q_idx, |
| 5049 | 5077 | tx_select, |
| 5078 | + // A key frame codes no inter block, so no motion_mode symbol. | |
| 5079 | + switchable_motion_mode: false, | |
| 5050 | 5080 | screen, |
| 5051 | 5081 | next_cdfs: start_cdfs.clone(), |
| 5052 | 5082 | start_cdfs, |
| @@ -5599,7 +5629,15 @@ fn search_inter_block( | ||
| 5599 | 5629 | // The COMPOUND stack of each `LAST_FRAME` + extra-reference pair, built by |
| 5600 | 5630 | // the caller off the same MI grid the tile writer will (empty unless the |
| 5601 | 5631 | // frame carries `reference_select`). |
| 5602 | - compound: &[(i8, &Picture, crate::mvstack::CompoundMvStack)], fctx: &crate::decode::FrameCtx, | |
| 5632 | + compound: &[(i8, &Picture, crate::mvstack::CompoundMvStack)], | |
| 5633 | + // lane-av1obmc: the mi grid this search's neighbours were published into | |
| 5634 | + // (`record_mi`) and this block's own place in it -- what the OBMC | |
| 5635 | + // candidate's eligibility walk and neighbour plan read, the same state | |
| 5636 | + // the tile writer will read when it codes the `motion_mode` symbol. | |
| 5637 | + grid: &MiGrid, | |
| 5638 | + (mi_row, mi_col): (usize, usize), | |
| 5639 | + (mi_rows, mi_cols): (usize, usize), | |
| 5640 | + fctx: &crate::decode::FrameCtx, | |
| 5603 | 5641 | ) -> (BlockCoeffs, f64) { |
| 5604 | 5642 | // `luma_set` is the INTRA candidates' table; the two inter candidates |
| 5605 | 5643 | // below price their coefficients through `TxbSet::Luma32Inter`, which is |
| @@ -5632,6 +5670,10 @@ fn search_inter_block( | ||
| 5632 | 5670 | mode: u8, |
| 5633 | 5671 | skip: bool, |
| 5634 | 5672 | inter: Option<InterInfo>, |
| 5673 | + /// The mode/mv syntax this candidate pays for, apart from its | |
| 5674 | + /// residual -- what the OBMC candidate below has to re-pay when it | |
| 5675 | + /// re-prices the winner's prediction. | |
| 5676 | + mode_bits: f64, | |
| 5635 | 5677 | } |
| 5636 | 5678 | let mut best: Option<Candidate> = None; |
| 5637 | 5679 | let mut consider = |candidate: Candidate| { |
| @@ -5726,6 +5768,7 @@ fn search_inter_block( | ||
| 5726 | 5768 | mode, |
| 5727 | 5769 | skip: false, |
| 5728 | 5770 | inter: None, |
| 5771 | + mode_bits: mode_bits[usize::from(mode)], | |
| 5729 | 5772 | }); |
| 5730 | 5773 | } |
| 5731 | 5774 | |
| @@ -6137,6 +6180,7 @@ fn search_inter_block( | ||
| 6137 | 6180 | v, |
| 6138 | 6181 | mode: DC_PRED, |
| 6139 | 6182 | skip, |
| 6183 | + mode_bits: bits, | |
| 6140 | 6184 | inter: Some(info), |
| 6141 | 6185 | }); |
| 6142 | 6186 | } |
| @@ -6234,12 +6278,150 @@ fn search_inter_block( | ||
| 6234 | 6278 | v, |
| 6235 | 6279 | mode: DC_PRED, |
| 6236 | 6280 | skip, |
| 6281 | + mode_bits: mode_bits_inter, | |
| 6237 | 6282 | inter: Some(info), |
| 6238 | 6283 | }); |
| 6239 | 6284 | } |
| 6240 | 6285 | } |
| 6241 | 6286 | |
| 6242 | 6287 | let best = best.expect("the search offers at least the intra modes"); |
| 6288 | + // lane-av1obmc: the OBMC candidate (spec `motion_mode == OBMC_CAUSAL`), | |
| 6289 | + // offered to the SINGLE-REFERENCE winner only -- libaom's | |
| 6290 | + // `motion_mode_allowed` fails `is_motion_variation_allowed_compound` on a | |
| 6291 | + // compound block, so the writer codes no symbol for one. The prediction | |
| 6292 | + // is built by the DECODER's own plan and blend | |
| 6293 | + // ([`crate::decode::obmc_plan`]/[`crate::decode::obmc_run`], | |
| 6294 | + // `av1_build_obmc_inter_prediction`) off the committed neighbours' mvs | |
| 6295 | + // this search's `grid` already carries, so what is priced here is what a | |
| 6296 | + // decoder reconstructs -- never a second implementation of the blend. | |
| 6297 | + // | |
| 6298 | + // MEASURED 2026-09-06 and NOT KEPT ON BY DEFAULT (`EC_AV1_OBMC=1` turns it | |
| 6299 | + // on). Native crop BD, the standing recipe, with it on against the same | |
| 6300 | + // build with it off: film 1080p +18.2/+0.9 against +18.0/+0.7, film 2160p | |
| 6301 | + // +47.3/+19.2 against +47.3/+19.2, screen +59.1/-10.0 against | |
| 6302 | + // +59.4/-10.0. That is one row down (screen -0.3 vs libaom), one flat and | |
| 6303 | + // one UP -- the keep rule wants two down and one flat, so it stays off. | |
| 6304 | + // The 640x384 gate reads the same shape louder: +79.7/+95.5/+54.2 and | |
| 6305 | + // +37.2/+56.8/+0.8 against +78.8/+95.1/+54.5 and +36.1/+56.4/+1.1. Two | |
| 6306 | + // things bound it and are the upgrade path: only the 32x32 winner is | |
| 6307 | + // offered OBMC (the 16x16/8x8 leaves in `code_square_inter` are not, and | |
| 6308 | + // that is where libaom cashes most of its OBMC gain), and the symbol/ | |
| 6309 | + // residual price here is the static-CDF estimate. | |
| 6310 | + let mut best = best; | |
| 6311 | + let mut obmc_won = false; | |
| 6312 | + if let Some(info) = best.inter.filter(|i| i.ref1.is_none()) { | |
| 6313 | + if crate::envflags::env_flag!("EC_AV1_OBMC") | |
| 6314 | + && crate::decode::has_overlappable_neighbour(grid, mi_row, mi_col, 8, 8, mi_cols, mi_rows) | |
| 6315 | + { | |
| 6316 | + let mut refs: [Option<&Picture>; 8] = [None; 8]; | |
| 6317 | + refs[LAST_FRAME as usize] = Some(reference); | |
| 6318 | + for &(r, p, _) in extra { | |
| 6319 | + refs[r as usize] = Some(p); | |
| 6320 | + } | |
| 6321 | + let refpix = crate::decode::RefPix::ready(refs); | |
| 6322 | + let plan = crate::decode::obmc_plan( | |
| 6323 | + grid, | |
| 6324 | + &[], | |
| 6325 | + &[], | |
| 6326 | + mi_row, | |
| 6327 | + mi_col, | |
| 6328 | + 8, | |
| 6329 | + 8, | |
| 6330 | + mi_rows, | |
| 6331 | + mi_cols, | |
| 6332 | + BLOCK, | |
| 6333 | + BLOCK, | |
| 6334 | + BLOCK, | |
| 6335 | + BLOCK / 2, | |
| 6336 | + x, | |
| 6337 | + y, | |
| 6338 | + x / 2, | |
| 6339 | + y / 2, | |
| 6340 | + &refpix, | |
| 6341 | + Some(mc::InterpFilterKind::Regular), | |
| 6342 | + reference.width, | |
| 6343 | + ); | |
| 6344 | + if let Ok(plan) = plan { | |
| 6345 | + let (ref_luma, ref_u, ref_v) = match extra | |
| 6346 | + .iter() | |
| 6347 | + .find(|(r, _, _)| *r == info.ref_frame) | |
| 6348 | + { | |
| 6349 | + Some(&(_, g, _)) => ( | |
| 6350 | + (&g.y, g.width, luma.true_width, luma.true_height), | |
| 6351 | + (&g.u, g.width / 2, chroma[0].true_width, chroma[0].true_height), | |
| 6352 | + (&g.v, g.width / 2, chroma[1].true_width, chroma[1].true_height), | |
| 6353 | + ), | |
| 6354 | + None => (ref_luma, ref_u, ref_v), | |
| 6355 | + }; | |
| 6356 | + let mv = info.mv; | |
| 6357 | + let mut pred = [ | |
| 6358 | + vec![0u16; BLOCK * BLOCK], | |
| 6359 | + vec![0u16; BLOCK * BLOCK / 4], | |
| 6360 | + vec![0u16; BLOCK * BLOCK / 4], | |
| 6361 | + ]; | |
| 6362 | + for (i, (r, luma_plane)) in | |
| 6363 | + [(ref_luma, true), (ref_u, false), (ref_v, false)].into_iter().enumerate() | |
| 6364 | + { | |
| 6365 | + let (px, py) = if luma_plane { (x, y) } else { (x / 2, y / 2) }; | |
| 6366 | + let side = if luma_plane { BLOCK } else { BLOCK / 2 }; | |
| 6367 | + mc::predict( | |
| 6368 | + r.0, | |
| 6369 | + r.1, | |
| 6370 | + r.2, | |
| 6371 | + r.3, | |
| 6372 | + mv_to_q4(px, mv.1, luma_plane), | |
| 6373 | + mv_to_q4(py, mv.0, luma_plane), | |
| 6374 | + side, | |
| 6375 | + side, | |
| 6376 | + &mut pred[i], | |
| 6377 | + fctx, | |
| 6378 | + ); | |
| 6379 | + } | |
| 6380 | + let [mut py_buf, mut pu_buf, mut pv_buf] = pred; | |
| 6381 | + crate::decode::obmc_run( | |
| 6382 | + &plan, &refpix, &mut py_buf, &mut pu_buf, &mut pv_buf, fctx, | |
| 6383 | + ); | |
| 6384 | + let u8s = |b: &[u16]| b.iter().map(|&v| v as u8).collect::<Vec<u8>>(); | |
| 6385 | + let luma_trial = luma.code_from_prediction( | |
| 6386 | + x, y, BLOCK, &u8s(&py_buf), false, search.base_q_idx, search.deadzone, | |
| 6387 | + TxbSet::Luma32Inter, | |
| 6388 | + ); | |
| 6389 | + let u = chroma[0].code_from_prediction( | |
| 6390 | + x / 2, y / 2, BLOCK / 2, &u8s(&pu_buf), false, search.base_q_idx, | |
| 6391 | + search.deadzone, chroma_set, | |
| 6392 | + ); | |
| 6393 | + let v = chroma[1].code_from_prediction( | |
| 6394 | + x / 2, y / 2, BLOCK / 2, &u8s(&pv_buf), false, search.base_q_idx, | |
| 6395 | + search.deadzone, chroma_set, | |
| 6396 | + ); | |
| 6397 | + let skip = luma_trial.levels.iter().all(|&l| l == 0) | |
| 6398 | + && u.levels.iter().all(|&l| l == 0) | |
| 6399 | + && v.levels.iter().all(|&l| l == 0); | |
| 6400 | + let cost = luma_trial.sse | |
| 6401 | + + u.sse | |
| 6402 | + + v.sse | |
| 6403 | + + search.lambda | |
| 6404 | + * (skip_bits(skip) | |
| 6405 | + + intra_inter_bits(true) | |
| 6406 | + + best.mode_bits | |
| 6407 | + + obmc_bits(BLOCK, BLOCK, true) | |
| 6408 | + + if skip { 0.0 } else { luma_trial.bits + u.bits + v.bits }); | |
| 6409 | + if cost < best.cost + search.lambda * obmc_bits(BLOCK, BLOCK, false) { | |
| 6410 | + obmc_won = true; | |
| 6411 | + best = Candidate { | |
| 6412 | + cost, | |
| 6413 | + luma: luma_trial, | |
| 6414 | + u, | |
| 6415 | + v, | |
| 6416 | + mode: DC_PRED, | |
| 6417 | + skip, | |
| 6418 | + mode_bits: best.mode_bits, | |
| 6419 | + inter: best.inter, | |
| 6420 | + }; | |
| 6421 | + } | |
| 6422 | + } | |
| 6423 | + } | |
| 6424 | + } | |
| 6243 | 6425 | // lane-av1txbits BUILT the transform-depth search this path lacks -- a |
| 6244 | 6426 | // 32x32 single-reference winner offered `commit_inter_luma`'s four 16x16 |
| 6245 | 6427 | // units against its flat trial, exactly as a 16x16 winner is -- and |
| @@ -6261,6 +6443,7 @@ fn search_inter_block( | ||
| 6261 | 6443 | uv_mode: DC_PRED, |
| 6262 | 6444 | skip: best.skip, |
| 6263 | 6445 | inter: best.inter, |
| 6446 | + obmc: obmc_won, | |
| 6264 | 6447 | eight: None, |
| 6265 | 6448 | dv: None, |
| 6266 | 6449 | palette: None, |
| @@ -6640,7 +6823,11 @@ pub(crate) fn encode_inter_frame( | ||
| 6640 | 6823 | reference, |
| 6641 | 6824 | &stack, |
| 6642 | 6825 | &extra, |
| 6643 | - &compound, fctx, | |
| 6826 | + &compound, | |
| 6827 | + &grid, | |
| 6828 | + (mi_row, mi_col), | |
| 6829 | + (mi_rows, mi_cols), | |
| 6830 | + fctx, | |
| 6644 | 6831 | ); |
| 6645 | 6832 | cost_whole += search.lambda * partition_bits(BLOCK, false); |
| 6646 | 6833 | let after_whole = snapshot(&luma, &chroma, (x, y), BLOCK); |
| @@ -6975,6 +7162,7 @@ pub(crate) fn encode_inter_frame( | ||
| 6975 | 7162 | .unwrap_or_else(|| crate::cdf_state::Cdfs::new(crate::tile::q_ctx_of(base_q_idx))); |
| 6976 | 7163 | let start_cdfs = CdfSnapshot(cdfs); |
| 6977 | 7164 | let reference_select_bit = header.reference_select; |
| 7165 | + let switchable_motion_mode = header.is_motion_mode_switchable; | |
| 6978 | 7166 | let order_hint_bits = seq.order_hint_bits; |
| 6979 | 7167 | let lr_horz = crate::restoration::count_units(header.frame_width, 64) as u32; |
| 6980 | 7168 | let lr_vert = crate::restoration::count_units(header.frame_height, 64) as u32; |
| @@ -6996,6 +7184,7 @@ pub(crate) fn encode_inter_frame( | ||
| 6996 | 7184 | crate::tile::arm_sign_bias(sign_bias); |
| 6997 | 7185 | // Thread-locals: every tile job arms its own worker. |
| 6998 | 7186 | crate::tile::arm_reference_select(reference_select_bit); |
| 7187 | + crate::tile::arm_motion_mode(switchable_motion_mode); | |
| 6999 | 7188 | crate::tile::arm_order_hints(order_hint_bits, order_hint, order_hints); |
| 7000 | 7189 | crate::tile::arm_screen(screen); |
| 7001 | 7190 | let mut cdfs = start_cdfs.0.clone(); |
| @@ -7122,6 +7311,7 @@ pub(crate) fn encode_inter_frame( | ||
| 7122 | 7311 | Some(start_cdfs.0.clone()), |
| 7123 | 7312 | sign_bias, |
| 7124 | 7313 | h.allow_screen_content_tools, |
| 7314 | + switchable_motion_mode, | |
| 7125 | 7315 | fctx, |
| 7126 | 7316 | ) |
| 7127 | 7317 | }, |
| @@ -7154,6 +7344,7 @@ pub(crate) fn encode_inter_frame( | ||
| 7154 | 7344 | mi_rows: header.mi_rows, |
| 7155 | 7345 | base_q_idx, |
| 7156 | 7346 | tx_select, |
| 7347 | + switchable_motion_mode, | |
| 7157 | 7348 | screen, |
| 7158 | 7349 | start_cdfs, |
| 7159 | 7350 | next_cdfs, |
| @@ -7924,6 +8115,7 @@ mod tests { | ||
| 7924 | 8115 | mv: (0, 0), |
| 7925 | 8116 | ref_mv_idx: 0, |
| 7926 | 8117 | }), |
| 8118 | + obmc: false, | |
| 7927 | 8119 | }; |
| 7928 | 8120 | let skipped_block = BlockCoeffs { |
| 7929 | 8121 | skip: true, |
| @@ -7943,6 +8135,10 @@ mod tests { | ||
| 7943 | 8135 | Quadrant::Whole(skipped_block.clone()), |
| 7944 | 8136 | Quadrant::Whole(skipped_block), |
| 7945 | 8137 | ]; |
| 8138 | + // lane-av1obmc: the header this tile is decoded under carries | |
| 8139 | + // `is_motion_mode_switchable`, so the writer must be armed with it | |
| 8140 | + // too or the decoder reads a `motion_mode` symbol nobody wrote. | |
| 8141 | + crate::tile::arm_motion_mode(inter_header.is_motion_mode_switchable); | |
| 7946 | 8142 | let tile = |
| 7947 | 8143 | crate::tile::sb_coeff_inter_frame_tile(inter_header.mi_cols, inter_header.mi_rows, 100, &blocks) |
| 7948 | 8144 | .unwrap(); |
| @@ -9493,6 +9689,14 @@ mod tests { | ||
| 9493 | 9689 | // remaining gap is the syntax the coefficient sum leaves out. That is |
| 9494 | 9690 | // the default on a non-screen frame since lane-av1price2 (this |
| 9495 | 9691 | // fixture is one), and it reads +32.6% here. |
| 9692 | + // lane-av1obmc: every eligible single-reference inter block now also | |
| 9693 | + // carries a `motion_mode` symbol the coefficient sum never counts, | |
| 9694 | + // and an OBMC block carries the more expensive of the two values -- | |
| 9695 | + // re-measured at +35.0% here with `EC_AV1_OBMC=1`. Like | |
| 9696 | + // `EC_AV1_PRICE_FRAME_CDFS=1` before it, that knob changes encoder | |
| 9697 | + // decisions, so this bound and the byte pins above FAIL BY DESIGN | |
| 9698 | + // under it; the default path (no motion_mode syntax at all) is the | |
| 9699 | + // one they are measured on. | |
| 9496 | 9700 | assert!( |
| 9497 | 9701 | worst_under <= 0.34, |
| 9498 | 9702 | "the writer spent {:.2}% more than the search priced -- more than \ |
| @@ -11017,6 +11221,18 @@ mod tests { | ||
| 11017 | 11221 | .collect::<Vec<_>>() |
| 11018 | 11222 | .join(" ") |
| 11019 | 11223 | ); |
| 11224 | + // lane-av1obmc: how many blocks actually CODED a motion_mode | |
| 11225 | + // symbol and which value they took, by footprint -- "OBMC is on" | |
| 11226 | + // as a measurement rather than a claim (class | |
| 11227 | + // `gate-blind-to-feature`). | |
| 11228 | + let mm = crate::tile::take_motion_mode_hits(); | |
| 11229 | + eprintln!( | |
| 11230 | + "{name}: motion_mode 32x32 SIMPLE={} OBMC={} | 16x16 SIMPLE={} OBMC={} | \ | |
| 11231 | + 8x8 SIMPLE={} OBMC={} ({:.1}% OBMC of {} eligible)", | |
| 11232 | + mm[0], mm[1], mm[2], mm[3], mm[4], mm[5], | |
| 11233 | + 100.0 * (mm[1] + mm[3] + mm[5]) as f64 / mm.iter().sum::<usize>().max(1) as f64, | |
| 11234 | + mm.iter().sum::<usize>(), | |
| 11235 | + ); | |
| 11020 | 11236 | let (aom, aom_wall) = |
| 11021 | 11237 | external_ladder(&source, width, height, "libaom-av1", &aom_points); |
| 11022 | 11238 | let (rav1e, rav1e_wall) = |
crates/ec-av1/src/tile.rsmodified+130 -0
| @@ -381,6 +381,99 @@ pub(crate) fn arm_reference_select(on: bool) { | ||
| 381 | 381 | REFERENCE_SELECT.with(|c| c.set(on)); |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | +thread_local! { | |
| 385 | + /// This frame header's own `is_motion_mode_switchable` bit (spec 5.9.2), | |
| 386 | + /// armed exactly like [`REFERENCE_SELECT`]. `true` makes every | |
| 387 | + /// single-reference inter block that libaom's `motion_mode_allowed` | |
| 388 | + /// accepts carry a `motion_mode`/`obmc` symbol right after its MV syntax, | |
| 389 | + /// exactly where decode.rs' `read_motion_mode` reads one. | |
| 390 | + static MOTION_MODE: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; | |
| 391 | +} | |
| 392 | + | |
| 393 | +/// Arms the frame's `is_motion_mode_switchable` bit for the next tile written | |
| 394 | +/// on this thread; cleared by [`CdefIdxGuard`] when that writer returns. | |
| 395 | +pub(crate) fn arm_motion_mode(on: bool) { | |
| 396 | + MOTION_MODE.with(|c| c.set(on)); | |
| 397 | +} | |
| 398 | + | |
| 399 | +/// How many single-reference inter blocks this writer coded a `motion_mode` | |
| 400 | +/// symbol for, split by the value it coded and by the block's own footprint | |
| 401 | +/// -- the histogram a gate prints so that "OBMC is on" is a measurement, not | |
| 402 | +/// a claim (class `gate-blind-to-feature`). Index: `0 + 2 * bucket` for | |
| 403 | +/// SIMPLE, `1 + 2 * bucket` for OBMC, bucket 0/1/2 = 32x32/16x16/8x8. | |
| 404 | +static MOTION_MODE_HITS: [std::sync::atomic::AtomicUsize; 6] = | |
| 405 | + [const { std::sync::atomic::AtomicUsize::new(0) }; 6]; | |
| 406 | + | |
| 407 | +/// Reads [`MOTION_MODE_HITS`] and zeroes it, so a gate can attribute the | |
| 408 | +/// counts to its own encode. | |
| 409 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 410 | +pub(crate) fn take_motion_mode_hits() -> [usize; 6] { | |
| 411 | + std::array::from_fn(|i| MOTION_MODE_HITS[i].swap(0, std::sync::atomic::Ordering::Relaxed)) | |
| 412 | +} | |
| 413 | + | |
| 414 | +/// `read_motion_mode`'s write side (spec 5.11.24), called on a | |
| 415 | +/// single-reference inter block right after its MV syntax and before the | |
| 416 | +/// (never switchable here) interpolation filter -- libaom's own sequential | |
| 417 | +/// order in `read_inter_block_mode_info`. | |
| 418 | +/// | |
| 419 | +/// Eligibility is decode.rs' own `motion_mode_eligible`, term for term, with | |
| 420 | +/// the terms this writer settles statically dropped: no block it codes is | |
| 421 | +/// `skip_mode`, interintra or a non-IDENTITY-global `GLOBALMV` one, so what | |
| 422 | +/// is left is the footprint floor and the overlappable-neighbour walk | |
| 423 | +/// ([`crate::decode::has_overlappable_neighbour`], shared with the decoder so | |
| 424 | +/// the two cannot drift). The frame header keeps `allow_warped_motion == 0`, | |
| 425 | +/// so the alphabet is always the 2-symbol `obmc_cdf`, never the 3-symbol | |
| 426 | +/// `motion_mode_cdf`. | |
| 427 | +fn write_motion_mode( | |
| 428 | + enc: &mut SymbolEncoder, | |
| 429 | + cdfs: &mut Cdfs, | |
| 430 | + grid: &MiGrid, | |
| 431 | + (mi_row, mi_col): (usize, usize), | |
| 432 | + (bw4, bh4): (usize, usize), | |
| 433 | + (write_w, write_h): (usize, usize), | |
| 434 | + (mi_cols, mi_rows): (usize, usize), | |
| 435 | + obmc: bool, | |
| 436 | +) -> Result<()> { | |
| 437 | + let eligible = MOTION_MODE.with(std::cell::Cell::get) | |
| 438 | + && write_w.min(write_h) >= 8 | |
| 439 | + && crate::decode::has_overlappable_neighbour( | |
| 440 | + grid, mi_row, mi_col, bw4, bh4, mi_cols, mi_rows, | |
| 441 | + ); | |
| 442 | + if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 443 | + eprintln!( | |
| 444 | + "EC_MMW mi_row={mi_row} mi_col={mi_col} w={write_w} h={write_h} elig={}", | |
| 445 | + eligible as u8 | |
| 446 | + ); | |
| 447 | + } | |
| 448 | + if !eligible { | |
| 449 | + // The encoder trialled an OBMC prediction for a block this writer | |
| 450 | + // codes as SIMPLE_TRANSLATION: its reconstruction is not the | |
| 451 | + // decoder's (class encoder-grid-drift), which is exactly what the | |
| 452 | + // `EC_COMP_MISMATCH` rung exists to catch. | |
| 453 | + if obmc && crate::envflags::env_flag!("EC_COMP_MISMATCH") { | |
| 454 | + eprintln!( | |
| 455 | + "EC_COMP_MISMATCH motion_mode enc=OBMC wrote=SIMPLE mi=({mi_row},{mi_col}) wh=({write_w}x{write_h})" | |
| 456 | + ); | |
| 457 | + } | |
| 458 | + return Ok(()); | |
| 459 | + } | |
| 460 | + let row = crate::decode::motion_mode_cdf_row(write_w, write_h).ok_or_else(|| { | |
| 461 | + Error::unsupported( | |
| 462 | + "AV1 tile", | |
| 463 | + format!("a {write_w}x{write_h} block has no motion_mode CDF row"), | |
| 464 | + ) | |
| 465 | + })?; | |
| 466 | + enc.symbol(usize::from(obmc), &mut cdfs.obmc[row]); | |
| 467 | + let bucket = match write_w.min(write_h) { | |
| 468 | + 32.. => 0, | |
| 469 | + 16 => 1, | |
| 470 | + _ => 2, | |
| 471 | + }; | |
| 472 | + MOTION_MODE_HITS[usize::from(obmc) + 2 * bucket] | |
| 473 | + .fetch_add(1, std::sync::atomic::Ordering::Relaxed); | |
| 474 | + Ok(()) | |
| 475 | +} | |
| 476 | + | |
| 384 | 477 | /// The compound half of a block's end-of-block neighbour record: nothing for |
| 385 | 478 | /// a single-reference or intra block, and `record_compound_mi`'s overwrite of |
| 386 | 479 | /// the ALTREF default for a compound one (this writer only codes |
| @@ -759,6 +852,7 @@ impl Drop for CdefIdxGuard { | ||
| 759 | 852 | SIGN_BIAS.with(|c| c.set(crate::mvstack::NO_SIGN_BIAS)); |
| 760 | 853 | SCREEN.with(|c| c.set(false)); |
| 761 | 854 | REFERENCE_SELECT.with(|c| c.set(false)); |
| 855 | + MOTION_MODE.with(|c| c.set(false)); | |
| 762 | 856 | INTRABC.with(|c| c.set(false)); |
| 763 | 857 | INTRABC_GRID.with(|c| *c.borrow_mut() = None); |
| 764 | 858 | ORDER_HINTS.with(|c| c.set((7, 0, [0; 7]))); |
| @@ -1240,6 +1334,12 @@ pub struct BlockCoeffs { | ||
| 1240 | 1334 | /// block. Only [`sb_coeff_inter_frame_tile`] codes `is_inter`; the key |
| 1241 | 1335 | /// frame writers never read this field. |
| 1242 | 1336 | pub inter: Option<InterInfo>, |
| 1337 | + /// Whether this (single-reference inter) block's prediction was built | |
| 1338 | + /// with OBMC -- spec `motion_mode == OBMC_CAUSAL`, written by | |
| 1339 | + /// [`write_motion_mode`]. `false` (the [`Default`]) is | |
| 1340 | + /// `SIMPLE_TRANSLATION`, the only motion mode this writer coded before | |
| 1341 | + /// lane-av1obmc. | |
| 1342 | + pub obmc: bool, | |
| 1243 | 1343 | /// The 8x8 leaves a straddling 16x16 block is split into (lane-av1-rect), |
| 1244 | 1344 | /// each with its own 8x8 luma transform and 4x4 chroma transforms, in |
| 1245 | 1345 | /// raster order among the leaves that are inside the true frame. `Some` |
| @@ -5439,6 +5539,16 @@ pub(crate) fn sb_coeff_inter_frame_tile_cdfs( | ||
| 5439 | 5539 | ); |
| 5440 | 5540 | } |
| 5441 | 5541 | } |
| 5542 | + write_motion_mode( | |
| 5543 | + &mut enc, | |
| 5544 | + &mut cdfs, | |
| 5545 | + &grid, | |
| 5546 | + (mi_row, mi_col), | |
| 5547 | + (8, 8), | |
| 5548 | + (BLOCK, BLOCK), | |
| 5549 | + (mi_cols as usize, mi_rows as usize), | |
| 5550 | + block.obmc, | |
| 5551 | + )?; | |
| 5442 | 5552 | mode_for_tx = 0; |
| 5443 | 5553 | } |
| 5444 | 5554 | } else { |
| @@ -5663,6 +5773,16 @@ fn write_inter_frame_leaf( | ||
| 5663 | 5773 | ); |
| 5664 | 5774 | } |
| 5665 | 5775 | } |
| 5776 | + write_motion_mode( | |
| 5777 | + enc, | |
| 5778 | + cdfs, | |
| 5779 | + grid, | |
| 5780 | + (mi_row, mi_col), | |
| 5781 | + (SUB_MI as usize, SUB_MI as usize), | |
| 5782 | + (SUB, SUB), | |
| 5783 | + (mi_cols as usize, mi_rows as usize), | |
| 5784 | + block.obmc, | |
| 5785 | + )?; | |
| 5666 | 5786 | mode_for_tx = 0; |
| 5667 | 5787 | } |
| 5668 | 5788 | } else { |
| @@ -5893,6 +6013,16 @@ fn write_inter_frame_leaf8( | ||
| 5893 | 6013 | ); |
| 5894 | 6014 | } |
| 5895 | 6015 | } |
| 6016 | + write_motion_mode( | |
| 6017 | + enc, | |
| 6018 | + cdfs, | |
| 6019 | + grid, | |
| 6020 | + (mi_row, mi_col), | |
| 6021 | + (2, 2), | |
| 6022 | + (8, 8), | |
| 6023 | + (mi_cols as usize, mi_rows as usize), | |
| 6024 | + block.obmc, | |
| 6025 | + )?; | |
| 5896 | 6026 | mode_for_tx = 0; |
| 5897 | 6027 | } |
| 5898 | 6028 | } else { |