From a745879568eaf4e9d91557d09e325288651cb05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 6 Sep 2026 17:59:24 +0300 Subject: [PATCH] feat(av1): a local-warp candidate behind EC_AV1_WARP The 3-symbol motion_mode alphabet in the tile writer (num_proj_ref mirrored from the decoder), the encoder-side WARPED_CAUSAL candidate built by the decoder's own find_samples/select_samples/find_projection/ warp_affine, and the frame's allow_warped_motion threaded into the encoder's trial decode -- hard-coding it false there desynced every warp-knob stream. --- crates/ec-av1/src/decode.rs | 25 +++++++++++++++++++++++-- crates/ec-av1/src/encode.rs | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 6dbe576c..281a18b7 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -33092,7 +33092,7 @@ pub(crate) fn decode_inter_frame_tile( loop_filter, allow_high_precision_mv, force_integer_mv, interp_fixed, enable_dual_filter, reference_select, tx_select, &LoopRestorationParams::default(), initial_cdfs, NO_SIGN_BIAS, false, - switchable_motion_mode, fctx, + switchable_motion_mode, false, fctx, ) } @@ -33138,6 +33138,12 @@ pub(crate) fn decode_inter_frame_tile_lr( // crate's own encoder writes once inter blocks started carrying a // `motion_mode` symbol (class: test asserts against a stale header). switchable_motion_mode: bool, + // lane-av1obmc2: this frame header's own `allow_warped_motion` (spec + // 5.9.2) -- what picks the 3-symbol `motion_mode_cdf` alphabet over the + // 2-symbol `obmc_cdf` one at a block with a warp sample. Hard-coding + // `false` here desynced every stream this crate's encoder writes with the + // warp knob on: the same stale-header class as the parameter above. + allow_warped_motion: bool, fctx: &crate::decode::FrameCtx, ) -> Result { let single_tile = TileInfo { @@ -33167,6 +33173,7 @@ pub(crate) fn decode_inter_frame_tile_lr( sign_bias, allow_screen_content_tools, switchable_motion_mode, + allow_warped_motion, fctx, ) } @@ -33202,6 +33209,12 @@ pub(crate) fn decode_inter_frame_tiles_lr( // crate's own encoder writes once inter blocks started carrying a // `motion_mode` symbol (class: test asserts against a stale header). switchable_motion_mode: bool, + // lane-av1obmc2: this frame header's own `allow_warped_motion` (spec + // 5.9.2) -- what picks the 3-symbol `motion_mode_cdf` alphabet over the + // 2-symbol `obmc_cdf` one at a block with a warp sample. Hard-coding + // `false` here desynced every stream this crate's encoder writes with the + // warp knob on: the same stale-header class as the parameter above. + allow_warped_motion: bool, fctx: &crate::decode::FrameCtx, ) -> Result { decode_inter_frame_tile_with_cdfs( @@ -33237,7 +33250,7 @@ pub(crate) fn decode_inter_frame_tiles_lr( true, tx_select, switchable_motion_mode, - false, + allow_warped_motion, allow_screen_content_tools, DeltaParams::default(), // `enable_filter_intra`: this crate's own encoder never writes the @@ -37790,6 +37803,10 @@ mod tests { // Same stale-header class: the bit that makes this frame's // inter blocks carry a `motion_mode` symbol. frame.switchable_motion_mode, + // These GOP round trips decode a tile the encoder wrote, so + // the warp bit must be the one it wrote too (lane-av1obmc2); + // the encoder only sets it under `EC_AV1_WARP`. + crate::envflags::env_flag!("EC_AV1_WARP"), fctx, ) .unwrap(); @@ -38124,6 +38141,10 @@ mod tests { // Same stale-header class: the bit that makes this frame's // inter blocks carry a `motion_mode` symbol. frame.switchable_motion_mode, + // These GOP round trips decode a tile the encoder wrote, so + // the warp bit must be the one it wrote too (lane-av1obmc2); + // the encoder only sets it under `EC_AV1_WARP`. + crate::envflags::env_flag!("EC_AV1_WARP"), fctx, ) .unwrap(); diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index 92b1aea5..0523b75c 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -7710,6 +7710,7 @@ pub(crate) fn encode_inter_frame( sign_bias, h.allow_screen_content_tools, switchable_motion_mode, + h.allow_warped_motion, fctx, ) },