forge
Explore
Log in

Don't you dare go Hollow

Directional/smooth/paeth chroma in inter-frame intra blocks

Browse files at this commit

c3a0a183261be6b7af30303009a859fc2a553f9bAhmet Kaan GümüşParent: 8f6064b
  • feat
    • directional/smooth/paeth chroma in inter-frame intra blocks
Show full message
feat(av1): directional/smooth/paeth chroma in inter-frame intra blocks

decode_inter_block's intra-in-inter branch refused any non-DC/CFL uv_mode
and never computed angle_delta_uv (charter step 4 sibling to the r1/r3
keyframe fix). Mirror read_intra_mode's own already-proven pattern:
uv_predict_mode (CFL predicts as DC), angle_delta_uv read for directional
uv_mode, smooth_neighbor_uv from the chroma neighbour's own uv_mode, and
SMOOTH_UV_HITS/DIRECTIONAL_UV_HITS counted same as the keyframe path.
Full lib suite green (234/0/17 ignored) after the change -- no dedicated
gate proves an inter-frame intra block with this uv_mode actually fires
through a real aomenc stream yet (deferred, see report).
crates/ec-av1/src/decode.rsmodified+40 -14
@@ -6518,6 +6518,7 @@ fn decode_inter_block(
6518 }6518 }
6519 6519
6520 let mode_for_tx;6520 let mode_for_tx;
6521+ let uv_predict_mode;
6521 let (luma_grid, u_grid, v_grid);6522 let (luma_grid, u_grid, v_grid);
6522 let block_filter;6523 let block_filter;
6523 let ref_frame_for_lf;6524 let ref_frame_for_lf;
@@ -6662,6 +6663,7 @@ fn decode_inter_block(
6662 globalmv_for_lf = is_globalmv;6663 globalmv_for_lf = is_globalmv;
6663 ref_frame_for_lf = ref0;6664 ref_frame_for_lf = ref0;
6664 mode_for_tx = 0;6665 mode_for_tx = 0;
6666+ uv_predict_mode = DC_PRED;
6665 // lane-rect r2: `grid` (mvstack.rs's own MiGrid, distinct from6667 // lane-rect r2: `grid` (mvstack.rs's own MiGrid, distinct from
6666 // `neighbours`) must be stamped with the block's true footprint6668 // `neighbours`) must be stamped with the block's true footprint
6667 // too -- a square `bw4`x`bw4` stamp here claims a rect strip's6669 // too -- a square `bw4`x`bw4` stamp here claims a rect strip's
@@ -7682,6 +7684,7 @@ fn decode_inter_block(
7682 }7684 }
7683 }7685 }
7684 mode_for_tx = 0;7686 mode_for_tx = 0;
7687+ uv_predict_mode = DC_PRED;
7685 7688
7686 let mut pred_y = vec![0u8; side * side];7689 let mut pred_y = vec![0u8; side * side];
7687 mc::predict_with_filters(7690 mc::predict_with_filters(
@@ -7897,13 +7900,36 @@ fn decode_inter_block(
7897 }7900 }
7898 }7901 }
7899 let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);7902 let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);
7903+ if (9..=12).contains(&uv_mode) {
7904+ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
7905+ }
7900 let alpha = if uv_mode == DC_PRED {7906 let alpha = if uv_mode == DC_PRED {
7901 None7907 None
7902 } else if uv_mode == UV_CFL_PRED {7908 } else if uv_mode == UV_CFL_PRED {
7903 Some(read_cfl_alphas(dec, cdfs))7909 Some(read_cfl_alphas(dec, cdfs))
7904 } else {7910 } else {
7905- return Err(unsupported("a directional chroma mode (round 2)"));7911+ None
7906 };7912 };
7913+ // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for
7914+ // the angle-delta question, same as [`read_intra_mode`]'s own copy
7915+ // -- `uv_mode` (13) already falls outside `V_PRED..=D67_PRED` so the
7916+ // `else` branch below is exact for it either way.
7917+ let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
7918+ DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));
7919+ read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
7920+ } else {
7921+ 0
7922+ };
7923+ uv_predict_mode = if uv_mode == UV_CFL_PRED {
7924+ DC_PRED
7925+ } else {
7926+ uv_mode
7927+ };
7928+ // lane-chroma r4: same chroma edge-filter-strength neighbour check
7929+ // as [`read_intra_mode`]/[`read_intra_mode_rect`] -- the CHROMA
7930+ // neighbour's own `uv_mode`, not the luma one.
7931+ let smooth_neighbor_uv =
7932+ is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
7907 // `read_palette_mode_info` (decodemv.c:567, called from7933 // `read_palette_mode_info` (decodemv.c:567, called from
7908 // `read_intra_block_mode_info` right after `xd->cfl.store_y`, same7934 // `read_intra_block_mode_info` right after `xd->cfl.store_y`, same
7909 // gating and same corner-cut as `read_intra_mode`'s own copy above7935 // gating and same corner-cut as `read_intra_mode`'s own copy above
@@ -7969,25 +7995,25 @@ fn decode_inter_block(
7969 cpx,7995 cpx,
7970 cpy,7996 cpy,
7971 chroma_side,7997 chroma_side,
7972- DC_PRED,7998+ uv_predict_mode,
7973- 0,7999+ angle_delta_uv,
7974 reach,8000 reach,
7975 &vec![0i32; chroma_side * chroma_side],8001 &vec![0i32; chroma_side * chroma_side],
7976 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),8002 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
7977 None,8003 None,
7978- false,8004+ smooth_neighbor_uv,
7979 );8005 );
7980 v.reconstruct(8006 v.reconstruct(
7981 cpx,8007 cpx,
7982 cpy,8008 cpy,
7983 chroma_side,8009 chroma_side,
7984- DC_PRED,8010+ uv_predict_mode,
7985- 0,8011+ angle_delta_uv,
7986 reach,8012 reach,
7987 &vec![0i32; chroma_side * chroma_side],8013 &vec![0i32; chroma_side * chroma_side],
7988 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),8014 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
7989 None,8015 None,
7990- false,8016+ smooth_neighbor_uv,
7991 );8017 );
7992 luma_grid = vec![0i32; side * side];8018 luma_grid = vec![0i32; side * side];
7993 u_grid = vec![0i32; chroma_side * chroma_side];8019 u_grid = vec![0i32; chroma_side * chroma_side];
@@ -8025,8 +8051,8 @@ fn decode_inter_block(
8025 1,8051 1,
8026 around[1],8052 around[1],
8027 mode,8053 mode,
8028- DC_PRED,8054+ uv_predict_mode,
8029- 0,8055+ angle_delta_uv,
8030 reach,8056 reach,
8031 u,8057 u,
8032 cpx,8058 cpx,
@@ -8037,7 +8063,7 @@ fn decode_inter_block(
8037 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),8063 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
8038 None,8064 None,
8039 None,8065 None,
8040- false,8066+ smooth_neighbor_uv,
8041 )?;8067 )?;
8042 v_grid = read_plane(8068 v_grid = read_plane(
8043 dec,8069 dec,
@@ -8047,8 +8073,8 @@ fn decode_inter_block(
8047 2,8073 2,
8048 around[2],8074 around[2],
8049 mode,8075 mode,
8050- DC_PRED,8076+ uv_predict_mode,
8051- 0,8077+ angle_delta_uv,
8052 reach,8078 reach,
8053 v,8079 v,
8054 cpx,8080 cpx,
@@ -8059,7 +8085,7 @@ fn decode_inter_block(
8059 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),8085 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
8060 None,8086 None,
8061 None,8087 None,
8062- false,8088+ smooth_neighbor_uv,
8063 )?;8089 )?;
8064 }8090 }
8065 }8091 }
@@ -8080,7 +8106,7 @@ fn decode_inter_block(
8080 write_w,8106 write_w,
8081 write_h,8107 write_h,
8082 mode_for_tx,8108 mode_for_tx,
8083- DC_PRED,8109+ uv_predict_mode,
8084 &[luma_grid, u_grid, v_grid],8110 &[luma_grid, u_grid, v_grid],
8085 );8111 );
8086 neighbours.record_inter_rect(8112 neighbours.record_inter_rect(