wip(av1): r14 skip_mode wiring, gates red — see r15
Browse files at this commit995dc90ae141df7023ffd295a66349dd7bc13428Parent: 3403b032 changed files +344 -93
- crates/ec-av1/src/decode.rs +175 -81
- crates/ec-av1/src/stream.rs +169 -12
crates/ec-av1/src/decode.rsmodified+175 -81
| @@ -144,6 +144,16 @@ pub(crate) fn comp_mode_hits() -> usize { | |||
| 144 | COMP_MODE_HITS.load(std::sync::atomic::Ordering::Relaxed) | 144 | COMP_MODE_HITS.load(std::sync::atomic::Ordering::Relaxed) |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | +/// How many blocks decoded `skip_mode == 1` (lane-av1comp round 14) -- | ||
| 148 | +/// proves a real `skip_mode_present` stream actually reached a block that | ||
| 149 | +/// picked it, not just that the frame header bit was set. | ||
| 150 | +static SKIP_MODE_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | ||
| 151 | + | ||
| 152 | +/// Current value of [`SKIP_MODE_HITS`]. | ||
| 153 | +pub(crate) fn skip_mode_hits() -> usize { | ||
| 154 | + SKIP_MODE_HITS.load(std::sync::atomic::Ordering::Relaxed) | ||
| 155 | +} | ||
| 156 | + | ||
| 147 | /// How many [`read_inter_compound_mode`] reads actually happened | 157 | /// How many [`read_inter_compound_mode`] reads actually happened |
| 148 | /// (lane-av1comp) -- proves a `COMPOUND_REFERENCE` block reached its own | 158 | /// (lane-av1comp) -- proves a `COMPOUND_REFERENCE` block reached its own |
| 149 | /// `compound_mode` symbol (past `comp_mode`/`comp_ref` and the compound | 159 | /// `compound_mode` symbol (past `comp_mode`/`comp_ref` and the compound |
| @@ -762,6 +772,11 @@ struct Neighbours { | |||
| 762 | /// `left_skip`. | 772 | /// `left_skip`. |
| 763 | above_skip: Vec<bool>, | 773 | above_skip: Vec<bool>, |
| 764 | left_skip: Vec<bool>, | 774 | left_skip: Vec<bool>, |
| 775 | + /// Whether the block above/left of this column/row coded `skip_mode` | ||
| 776 | + /// (spec 5.11.23) -- `av1_get_skip_mode_context`'s own neighbour lookup, | ||
| 777 | + /// lane-av1comp round 14. | ||
| 778 | + above_skip_mode: Vec<bool>, | ||
| 779 | + left_skip_mode: Vec<bool>, | ||
| 765 | /// Whether the block above/left was coded inter -- the `is_inter` | 780 | /// Whether the block above/left was coded inter -- the `is_inter` |
| 766 | /// context (spec `av1_get_intra_inter_context`), a duplicate of | 781 | /// context (spec `av1_get_intra_inter_context`), a duplicate of |
| 767 | /// [`crate::tile`]'s private `Neighbours::above_inter`/`left_inter`. | 782 | /// [`crate::tile`]'s private `Neighbours::above_inter`/`left_inter`. |
| @@ -841,6 +856,8 @@ impl Neighbours { | |||
| 841 | left_side_mi: vec![SB; rows * (SUB / MI)], | 856 | left_side_mi: vec![SB; rows * (SUB / MI)], |
| 842 | above_skip: vec![false; cols], | 857 | above_skip: vec![false; cols], |
| 843 | left_skip: vec![false; rows], | 858 | left_skip: vec![false; rows], |
| 859 | + above_skip_mode: vec![false; cols], | ||
| 860 | + left_skip_mode: vec![false; rows], | ||
| 844 | above_inter: vec![false; cols], | 861 | above_inter: vec![false; cols], |
| 845 | left_inter: vec![false; rows], | 862 | left_inter: vec![false; rows], |
| 846 | above_ref: vec![-1; cols], | 863 | above_ref: vec![-1; cols], |
| @@ -932,6 +949,7 @@ impl Neighbours { | |||
| 932 | self.left_side.iter_mut().for_each(|s| *s = SB); | 949 | self.left_side.iter_mut().for_each(|s| *s = SB); |
| 933 | self.left_side_mi.iter_mut().for_each(|s| *s = SB); | 950 | self.left_side_mi.iter_mut().for_each(|s| *s = SB); |
| 934 | self.left_skip.iter_mut().for_each(|s| *s = false); | 951 | self.left_skip.iter_mut().for_each(|s| *s = false); |
| 952 | + self.left_skip_mode.iter_mut().for_each(|s| *s = false); | ||
| 935 | self.left_inter.iter_mut().for_each(|i| *i = false); | 953 | self.left_inter.iter_mut().for_each(|i| *i = false); |
| 936 | self.left_ref.iter_mut().for_each(|r| *r = -1); | 954 | self.left_ref.iter_mut().for_each(|r| *r = -1); |
| 937 | self.left_ref1.iter_mut().for_each(|r| *r = None); | 955 | self.left_ref1.iter_mut().for_each(|r| *r = None); |
| @@ -955,11 +973,14 @@ impl Neighbours { | |||
| 955 | is_inter: bool, | 973 | is_inter: bool, |
| 956 | ref_frame: i8, | 974 | ref_frame: i8, |
| 957 | filter: [u8; 2], | 975 | filter: [u8; 2], |
| 976 | + skip_mode: bool, | ||
| 958 | ) { | 977 | ) { |
| 959 | let (r, c) = at; | 978 | let (r, c) = at; |
| 960 | for cell in 0..side / SUB { | 979 | for cell in 0..side / SUB { |
| 961 | self.above_skip[c + cell] = skip; | 980 | self.above_skip[c + cell] = skip; |
| 962 | self.left_skip[r + cell] = skip; | 981 | self.left_skip[r + cell] = skip; |
| 982 | + self.above_skip_mode[c + cell] = skip_mode; | ||
| 983 | + self.left_skip_mode[r + cell] = skip_mode; | ||
| 963 | self.above_inter[c + cell] = is_inter; | 984 | self.above_inter[c + cell] = is_inter; |
| 964 | self.left_inter[r + cell] = is_inter; | 985 | self.left_inter[r + cell] = is_inter; |
| 965 | self.above_ref[c + cell] = ref_frame; | 986 | self.above_ref[c + cell] = ref_frame; |
| @@ -4234,19 +4255,37 @@ fn decode_inter_block( | |||
| 4234 | order_hint_bits: u32, | 4255 | order_hint_bits: u32, |
| 4235 | order_hint: u32, | 4256 | order_hint: u32, |
| 4236 | ref_order_hints: [u32; 7], | 4257 | ref_order_hints: [u32; 7], |
| 4258 | + // lane-av1comp round 14: this frame header's own `skip_mode_present` bit | ||
| 4259 | + // and `skip_mode_frame` reference pair (spec 5.9.22, `frame.rs`'s | ||
| 4260 | + // `read_skip_mode_params`, already 1-based `MV_REFERENCE_FRAME`) -- | ||
| 4261 | + // `skip_mode` (spec 5.11.23 `read_skip_mode`) is read *before* `skip` | ||
| 4262 | + // when this is `true` (every block this decoder reaches is >= 8x8, so | ||
| 4263 | + // `is_comp_ref_allowed` never gates it further); a `true` result forces | ||
| 4264 | + // `skip_txfm`, `is_inter`, `NEAREST_NEARESTMV` of this pair with no mode/ | ||
| 4265 | + // DRL symbol read, and a plain average blend with no `comp_group_idx`/ | ||
| 4266 | + // `compound_idx` read (libaom `decodemv.c` 1604-1619, 1382-1384, 1509). | ||
| 4267 | + skip_mode_present: bool, | ||
| 4268 | + skip_mode_frame: [u8; 2], | ||
| 4237 | ) -> Result<()> { | 4269 | ) -> Result<()> { |
| 4238 | let (r, c) = at; | 4270 | let (r, c) = at; |
| 4239 | let (px, py) = (c * SUB, r * SUB); | 4271 | let (px, py) = (c * SUB, r * SUB); |
| 4240 | let (cpx, cpy) = (px / 2, py / 2); | 4272 | let (cpx, cpy) = (px / 2, py / 2); |
| 4241 | let chroma_side = side / 2; | 4273 | let chroma_side = side / 2; |
| 4242 | 4274 | ||
| 4275 | + let skip_mode_ctx = | ||
| 4276 | + usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); | ||
| 4277 | + let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; | ||
| 4278 | + if skip_mode { | ||
| 4279 | + SKIP_MODE_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 4280 | + } | ||
| 4281 | + | ||
| 4243 | let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]); | 4282 | let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]); |
| 4244 | - let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; | 4283 | + let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| 4245 | 4284 | ||
| 4246 | let (has_above, has_left) = (r > 0, c > 0); | 4285 | let (has_above, has_left) = (r > 0, c > 0); |
| 4247 | let (above_inter, left_inter) = (neighbours.above_inter[c], neighbours.left_inter[r]); | 4286 | let (above_inter, left_inter) = (neighbours.above_inter[c], neighbours.left_inter[r]); |
| 4248 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); | 4287 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); |
| 4249 | - let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; | 4288 | + let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; |
| 4250 | 4289 | ||
| 4251 | let mode_for_tx; | 4290 | let mode_for_tx; |
| 4252 | let (luma_grid, u_grid, v_grid); | 4291 | let (luma_grid, u_grid, v_grid); |
| @@ -4281,16 +4320,21 @@ fn decode_inter_block( | |||
| 4281 | uni: neighbours.left_ref1[r] | 4320 | uni: neighbours.left_ref1[r] |
| 4282 | .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[r], r1)), | 4321 | .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[r], r1)), |
| 4283 | }); | 4322 | }); |
| 4284 | - let is_compound = reference_select && read_comp_mode(dec, cdfs, above_nbr, left_nbr); | 4323 | + let is_compound = |
| 4324 | + skip_mode || (reference_select && read_comp_mode(dec, cdfs, above_nbr, left_nbr)); | ||
| 4285 | if is_compound { | 4325 | if is_compound { |
| 4286 | - let (ref0, ref1) = read_compound_ref_frames( | 4326 | + let (ref0, ref1) = if skip_mode { |
| 4287 | - dec, | 4327 | + (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8) |
| 4288 | - cdfs, | 4328 | + } else { |
| 4289 | - above_nbr, | 4329 | + read_compound_ref_frames( |
| 4290 | - left_nbr, | 4330 | + dec, |
| 4291 | - neighbours.above_ref[c], | 4331 | + cdfs, |
| 4292 | - neighbours.left_ref[r], | 4332 | + above_nbr, |
| 4293 | - ); | 4333 | + left_nbr, |
| 4334 | + neighbours.above_ref[c], | ||
| 4335 | + neighbours.left_ref[r], | ||
| 4336 | + ) | ||
| 4337 | + }; | ||
| 4294 | let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); | 4338 | let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); |
| 4295 | let bw4 = side / 4; | 4339 | let bw4 = side / 4; |
| 4296 | // spec 7.10.2.8, doubled per side (`CompoundTplArgs`): same | 4340 | // spec 7.10.2.8, doubled per side (`CompoundTplArgs`): same |
| @@ -4322,8 +4366,11 @@ fn decode_inter_block( | |||
| 4322 | sign_bias_table, | 4366 | sign_bias_table, |
| 4323 | comp_tpl, | 4367 | comp_tpl, |
| 4324 | ); | 4368 | ); |
| 4325 | - let compound_mode = | 4369 | + let compound_mode = if skip_mode { |
| 4326 | - read_inter_compound_mode(dec, cdfs, comp_stack.new_mv_ctx, comp_stack.ref_mv_ctx); | 4370 | + 0 // NEAREST_NEARESTMV, forced -- no mode symbol read |
| 4371 | + } else { | ||
| 4372 | + read_inter_compound_mode(dec, cdfs, comp_stack.new_mv_ctx, comp_stack.ref_mv_ctx) | ||
| 4373 | + }; | ||
| 4327 | let (mv0, mv1) = assign_compound_mv( | 4374 | let (mv0, mv1) = assign_compound_mv( |
| 4328 | dec, | 4375 | dec, |
| 4329 | cdfs, | 4376 | cdfs, |
| @@ -4383,7 +4430,9 @@ fn decode_inter_block( | |||
| 4383 | // as an explicit call so a future smaller block size is not | 4430 | // as an explicit call so a future smaller block size is not |
| 4384 | // silently wrong (libaom `reconinter.h::is_any_masked_compound_used`). | 4431 | // silently wrong (libaom `reconinter.h::is_any_masked_compound_used`). |
| 4385 | let group_ctx = get_comp_group_idx_context(neighbours, at, side); | 4432 | let group_ctx = get_comp_group_idx_context(neighbours, at, side); |
| 4386 | - let comp_group_idx = if enable_masked_compound && is_any_masked_compound_used_here(side) | 4433 | + let comp_group_idx = if !skip_mode |
| 4434 | + && enable_masked_compound | ||
| 4435 | + && is_any_masked_compound_used_here(side) | ||
| 4387 | { | 4436 | { |
| 4388 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) | 4437 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 4389 | } else { | 4438 | } else { |
| @@ -4396,7 +4445,7 @@ fn decode_inter_block( | |||
| 4396 | weighted/simple-average combine only, lane-av1comp", | 4445 | weighted/simple-average combine only, lane-av1comp", |
| 4397 | )); | 4446 | )); |
| 4398 | } | 4447 | } |
| 4399 | - let (fwd_offset, bck_offset, compound_idx) = if enable_jnt_comp { | 4448 | + let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { |
| 4400 | let idx_ctx = get_comp_index_context( | 4449 | let idx_ctx = get_comp_index_context( |
| 4401 | neighbours, | 4450 | neighbours, |
| 4402 | at, | 4451 | at, |
| @@ -5015,7 +5064,7 @@ fn decode_inter_block( | |||
| 5015 | } | 5064 | } |
| 5016 | } | 5065 | } |
| 5017 | neighbours.record(at, side, mode_for_tx, &[luma_grid, u_grid, v_grid]); | 5066 | neighbours.record(at, side, mode_for_tx, &[luma_grid, u_grid, v_grid]); |
| 5018 | - neighbours.record_inter(at, side, skip, is_inter, ref_frame_for_lf, block_filter); | 5067 | + neighbours.record_inter(at, side, skip, is_inter, ref_frame_for_lf, block_filter, skip_mode); |
| 5019 | if let Some((ref1, group_idx, idx)) = compound_ctx { | 5068 | if let Some((ref1, group_idx, idx)) = compound_ctx { |
| 5020 | neighbours.record_compound_ctx(at, side, ref1, group_idx, idx); | 5069 | neighbours.record_compound_ctx(at, side, ref1, group_idx, idx); |
| 5021 | } | 5070 | } |
| @@ -5081,13 +5130,21 @@ fn decode_inter_block8( | |||
| 5081 | order_hint_bits: u32, | 5130 | order_hint_bits: u32, |
| 5082 | order_hint: u32, | 5131 | order_hint: u32, |
| 5083 | ref_order_hints: [u32; 7], | 5132 | ref_order_hints: [u32; 7], |
| 5133 | + // lane-av1comp round 14: see [`decode_inter_block`]'s own doc -- this | ||
| 5134 | + // leaf has no per-leaf `above_skip_mode`/`left_skip_mode` array either, | ||
| 5135 | + // so its `skip_mode` context reuses the same [`SUB`]-grid | ||
| 5136 | + // `above_skip_mode[c]`/`left_skip_mode[r]` the enclosing 16x16 slot | ||
| 5137 | + // tracks (mirroring `above_skip`/`left_skip`'s own leaf approximation | ||
| 5138 | + // just above). | ||
| 5139 | + skip_mode_present: bool, | ||
| 5140 | + skip_mode_frame: [u8; 2], | ||
| 5084 | // lane-av1comp: `Some((ref1, comp_group_idx, compound_idx))` only for a | 5141 | // lane-av1comp: `Some((ref1, comp_group_idx, compound_idx))` only for a |
| 5085 | // real `COMPOUND_REFERENCE` leaf, for the caller's own end-of-16x16 | 5142 | // real `COMPOUND_REFERENCE` leaf, for the caller's own end-of-16x16 |
| 5086 | // `record_compound_ctx` call -- mirrors [`decode_inter_block`]'s own | 5143 | // `record_compound_ctx` call -- mirrors [`decode_inter_block`]'s own |
| 5087 | // `compound_ctx` local, just handed back instead of applied here (this | 5144 | // `compound_ctx` local, just handed back instead of applied here (this |
| 5088 | // fn's `neighbours` recording happens once for the whole straddling | 5145 | // fn's `neighbours` recording happens once for the whole straddling |
| 5089 | // 16x16 block, after every leaf). | 5146 | // 16x16 block, after every leaf). |
| 5090 | -) -> Result<(bool, bool, Option<(i8, i8, u8, u8)>)> { | 5147 | +) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>)> { |
| 5091 | const LAST_FRAME: i8 = 1; | 5148 | const LAST_FRAME: i8 = 1; |
| 5092 | /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`). | 5149 | /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`). |
| 5093 | const SIZE_GROUP_8: usize = 1; | 5150 | const SIZE_GROUP_8: usize = 1; |
| @@ -5111,18 +5168,25 @@ fn decode_inter_block8( | |||
| 5111 | left_inter = pinter; | 5168 | left_inter = pinter; |
| 5112 | } | 5169 | } |
| 5113 | } | 5170 | } |
| 5171 | + let skip_mode_ctx = | ||
| 5172 | + usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); | ||
| 5173 | + let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; | ||
| 5174 | + if skip_mode { | ||
| 5175 | + SKIP_MODE_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 5176 | + } | ||
| 5177 | + | ||
| 5114 | let skip_ctx = usize::from(above_skip) + usize::from(left_skip); | 5178 | let skip_ctx = usize::from(above_skip) + usize::from(left_skip); |
| 5115 | - let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; | 5179 | + let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| 5116 | 5180 | ||
| 5117 | let (has_above, has_left) = (leaf_mi.0 > 0, leaf_mi.1 > 0); | 5181 | let (has_above, has_left) = (leaf_mi.0 > 0, leaf_mi.1 > 0); |
| 5118 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); | 5182 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); |
| 5119 | - let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; | 5183 | + let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; |
| 5120 | 5184 | ||
| 5121 | let mode_for_tx; | 5185 | let mode_for_tx; |
| 5122 | let (luma_grid, u_grid, v_grid); | 5186 | let (luma_grid, u_grid, v_grid); |
| 5123 | let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None; | 5187 | let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None; |
| 5124 | if is_inter { | 5188 | if is_inter { |
| 5125 | - if reference_select { | 5189 | + if reference_select || skip_mode { |
| 5126 | let above_nbr = has_above.then(|| NeighbourRef { | 5190 | let above_nbr = has_above.then(|| NeighbourRef { |
| 5127 | is_inter: above_inter, | 5191 | is_inter: above_inter, |
| 5128 | ref0: if above_inter { LAST_FRAME } else { 0 }, | 5192 | ref0: if above_inter { LAST_FRAME } else { 0 }, |
| @@ -5135,23 +5199,27 @@ fn decode_inter_block8( | |||
| 5135 | ref1: None, | 5199 | ref1: None, |
| 5136 | uni: false, | 5200 | uni: false, |
| 5137 | }); | 5201 | }); |
| 5138 | - if read_comp_mode(dec, cdfs, above_nbr, left_nbr) { | 5202 | + if skip_mode || read_comp_mode(dec, cdfs, above_nbr, left_nbr) { |
| 5139 | - let (ref0, ref1) = read_compound_ref_frames( | 5203 | + let (ref0, ref1) = if skip_mode { |
| 5140 | - dec, | 5204 | + (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8) |
| 5141 | - cdfs, | 5205 | + } else { |
| 5142 | - above_nbr, | 5206 | + read_compound_ref_frames( |
| 5143 | - left_nbr, | 5207 | + dec, |
| 5144 | - if has_above && above_inter { | 5208 | + cdfs, |
| 5145 | - LAST_FRAME | 5209 | + above_nbr, |
| 5146 | - } else { | 5210 | + left_nbr, |
| 5147 | - -1 | 5211 | + if has_above && above_inter { |
| 5148 | - }, | 5212 | + LAST_FRAME |
| 5149 | - if has_left && left_inter { | 5213 | + } else { |
| 5150 | - LAST_FRAME | 5214 | + -1 |
| 5151 | - } else { | 5215 | + }, |
| 5152 | - -1 | 5216 | + if has_left && left_inter { |
| 5153 | - }, | 5217 | + LAST_FRAME |
| 5154 | - ); | 5218 | + } else { |
| 5219 | + -1 | ||
| 5220 | + }, | ||
| 5221 | + ) | ||
| 5222 | + }; | ||
| 5155 | let (mi_row, mi_col) = leaf_mi; | 5223 | let (mi_row, mi_col) = leaf_mi; |
| 5156 | // lane-av1comp: this leaf path has neither a real sign-bias | 5224 | // lane-av1comp: this leaf path has neither a real sign-bias |
| 5157 | // table nor `tpl_frame` (see this function's own doc on the | 5225 | // table nor `tpl_frame` (see this function's own doc on the |
| @@ -5171,12 +5239,16 @@ fn decode_inter_block8( | |||
| 5171 | &NO_SIGN_BIAS, | 5239 | &NO_SIGN_BIAS, |
| 5172 | None, | 5240 | None, |
| 5173 | ); | 5241 | ); |
| 5174 | - let compound_mode = read_inter_compound_mode( | 5242 | + let compound_mode = if skip_mode { |
| 5175 | - dec, | 5243 | + 0 // NEAREST_NEARESTMV, forced -- no mode symbol read |
| 5176 | - cdfs, | 5244 | + } else { |
| 5177 | - comp_stack.new_mv_ctx, | 5245 | + read_inter_compound_mode( |
| 5178 | - comp_stack.ref_mv_ctx, | 5246 | + dec, |
| 5179 | - ); | 5247 | + cdfs, |
| 5248 | + comp_stack.new_mv_ctx, | ||
| 5249 | + comp_stack.ref_mv_ctx, | ||
| 5250 | + ) | ||
| 5251 | + }; | ||
| 5180 | let (mv0, mv1) = assign_compound_mv( | 5252 | let (mv0, mv1) = assign_compound_mv( |
| 5181 | dec, | 5253 | dec, |
| 5182 | cdfs, | 5254 | cdfs, |
| @@ -5190,12 +5262,14 @@ fn decode_inter_block8( | |||
| 5190 | // slot -- the only granularity `Neighbours`' comp_group_idx/ | 5262 | // slot -- the only granularity `Neighbours`' comp_group_idx/ |
| 5191 | // compound_idx arrays track. | 5263 | // compound_idx arrays track. |
| 5192 | let group_ctx = get_comp_group_idx_context(neighbours, outer_at, SIDE); | 5264 | let group_ctx = get_comp_group_idx_context(neighbours, outer_at, SIDE); |
| 5193 | - let comp_group_idx = | 5265 | + let comp_group_idx = if !skip_mode |
| 5194 | - if enable_masked_compound && is_any_masked_compound_used_here(SIDE) { | 5266 | + && enable_masked_compound |
| 5195 | - dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) | 5267 | + && is_any_masked_compound_used_here(SIDE) |
| 5196 | - } else { | 5268 | + { |
| 5197 | - 0 | 5269 | + dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 5198 | - }; | 5270 | + } else { |
| 5271 | + 0 | ||
| 5272 | + }; | ||
| 5199 | if comp_group_idx == 1 { | 5273 | if comp_group_idx == 1 { |
| 5200 | return Err(unsupported( | 5274 | return Err(unsupported( |
| 5201 | "a masked COMPOUND_REFERENCE 8x8 leaf (comp_group_idx == 1, wedge/\ | 5275 | "a masked COMPOUND_REFERENCE 8x8 leaf (comp_group_idx == 1, wedge/\ |
| @@ -5203,7 +5277,7 @@ fn decode_inter_block8( | |||
| 5203 | weighted/simple-average combine only, lane-av1comp", | 5277 | weighted/simple-average combine only, lane-av1comp", |
| 5204 | )); | 5278 | )); |
| 5205 | } | 5279 | } |
| 5206 | - let (fwd_offset, bck_offset, compound_idx) = if enable_jnt_comp { | 5280 | + let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { |
| 5207 | let idx_ctx = get_comp_index_context( | 5281 | let idx_ctx = get_comp_index_context( |
| 5208 | neighbours, | 5282 | neighbours, |
| 5209 | outer_at, | 5283 | outer_at, |
| @@ -5417,7 +5491,7 @@ fn decode_inter_block8( | |||
| 5417 | &pred_v, | 5491 | &pred_v, |
| 5418 | )?; | 5492 | )?; |
| 5419 | } | 5493 | } |
| 5420 | - return Ok((skip, is_inter, compound_ctx8)); | 5494 | + return Ok((skip, is_inter, skip_mode, compound_ctx8)); |
| 5421 | } | 5495 | } |
| 5422 | } | 5496 | } |
| 5423 | let sr_ctx = single_ref_ctx(above_inter || left_inter); | 5497 | let sr_ctx = single_ref_ctx(above_inter || left_inter); |
| @@ -5759,7 +5833,7 @@ fn decode_inter_block8( | |||
| 5759 | } | 5833 | } |
| 5760 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); | 5834 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); |
| 5761 | neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 }); | 5835 | neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 }); |
| 5762 | - Ok((skip, is_inter, compound_ctx8)) | 5836 | + Ok((skip, is_inter, skip_mode, compound_ctx8)) |
| 5763 | } | 5837 | } |
| 5764 | 5838 | ||
| 5765 | /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes, | 5839 | /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes, |
| @@ -5814,6 +5888,8 @@ pub fn decode_inter_frame_tile( | |||
| 5814 | reference_select, | 5888 | reference_select, |
| 5815 | false, | 5889 | false, |
| 5816 | false, | 5890 | false, |
| 5891 | + false, | ||
| 5892 | + [0; 2], | ||
| 5817 | ) | 5893 | ) |
| 5818 | .map(|(picture, _, _)| picture) | 5894 | .map(|(picture, _, _)| picture) |
| 5819 | } | 5895 | } |
| @@ -5854,6 +5930,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 5854 | // lane-av1comp: `seq_params`' own compound-blend enable bits. | 5930 | // lane-av1comp: `seq_params`' own compound-blend enable bits. |
| 5855 | enable_masked_compound: bool, | 5931 | enable_masked_compound: bool, |
| 5856 | enable_jnt_comp: bool, | 5932 | enable_jnt_comp: bool, |
| 5933 | + // lane-av1comp round 14: this frame header's own `skip_mode_present`/ | ||
| 5934 | + // `skip_mode_frame` (spec 5.9.22), threaded to every `decode_inter_block`/ | ||
| 5935 | + // `decode_inter_block8` call below. | ||
| 5936 | + skip_mode_present: bool, | ||
| 5937 | + skip_mode_frame: [u8; 2], | ||
| 5857 | ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> { | 5938 | ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> { |
| 5858 | let tpl_frame = tpl_field.map(|field| TplFrameArgs { | 5939 | let tpl_frame = tpl_field.map(|field| TplFrameArgs { |
| 5859 | field, | 5940 | field, |
| @@ -6056,6 +6137,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6056 | order_hint_bits, | 6137 | order_hint_bits, |
| 6057 | order_hint, | 6138 | order_hint, |
| 6058 | ref_order_hints, | 6139 | ref_order_hints, |
| 6140 | + skip_mode_present, | ||
| 6141 | + skip_mode_frame, | ||
| 6059 | )?; | 6142 | )?; |
| 6060 | } | 6143 | } |
| 6061 | PARTITION_SPLIT => { | 6144 | PARTITION_SPLIT => { |
| @@ -6120,6 +6203,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6120 | order_hint_bits, | 6203 | order_hint_bits, |
| 6121 | order_hint, | 6204 | order_hint, |
| 6122 | ref_order_hints, | 6205 | ref_order_hints, |
| 6206 | + skip_mode_present, | ||
| 6207 | + skip_mode_frame, | ||
| 6123 | )?; | 6208 | )?; |
| 6124 | } else { | 6209 | } else { |
| 6125 | let ctx16 = neighbours.partition_ctx(at16, SUB); | 6210 | let ctx16 = neighbours.partition_ctx(at16, SUB); |
| @@ -6141,6 +6226,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6141 | .collect(); | 6226 | .collect(); |
| 6142 | let mut prev_leaf: Option<((usize, usize), bool, bool)> = None; | 6227 | let mut prev_leaf: Option<((usize, usize), bool, bool)> = None; |
| 6143 | let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None; | 6228 | let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None; |
| 6229 | + let mut last_skip_mode = false; | ||
| 6144 | for (mr, mc) in leaf_positions { | 6230 | for (mr, mc) in leaf_positions { |
| 6145 | let leaf_mi = (mr as usize, mc as usize); | 6231 | let leaf_mi = (mr as usize, mc as usize); |
| 6146 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | 6232 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); |
| @@ -6150,35 +6236,39 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6150 | "a partition below 8x8 (this encoder never writes one)", | 6236 | "a partition below 8x8 (this encoder never writes one)", |
| 6151 | )); | 6237 | )); |
| 6152 | } | 6238 | } |
| 6153 | - let (skip, is_inter, compound_ctx8) = decode_inter_block8( | 6239 | + let (skip, is_inter, skip_mode_leaf, compound_ctx8) = |
| 6154 | - &mut dec, | 6240 | + decode_inter_block8( |
| 6155 | - &mut cdfs, | 6241 | + &mut dec, |
| 6156 | - &mut neighbours, | 6242 | + &mut cdfs, |
| 6157 | - &mut grid, | 6243 | + &mut neighbours, |
| 6158 | - mi_cols, | 6244 | + &mut grid, |
| 6159 | - mi_rows, | 6245 | + mi_cols, |
| 6160 | - at16, | 6246 | + mi_rows, |
| 6161 | - leaf_mi, | 6247 | + at16, |
| 6162 | - &mut y, | 6248 | + leaf_mi, |
| 6163 | - &mut u, | 6249 | + &mut y, |
| 6164 | - &mut v, | 6250 | + &mut u, |
| 6165 | - &ref_y, | 6251 | + &mut v, |
| 6166 | - &ref_u, | 6252 | + &ref_y, |
| 6167 | - &ref_v, | 6253 | + &ref_u, |
| 6168 | - &ref_slots, | 6254 | + &ref_v, |
| 6169 | - base_q_idx, | 6255 | + &ref_slots, |
| 6170 | - &scan8, | 6256 | + base_q_idx, |
| 6171 | - &scan4, | 6257 | + &scan8, |
| 6172 | - prev_leaf, | 6258 | + &scan4, |
| 6173 | - allow_high_precision_mv, | 6259 | + prev_leaf, |
| 6174 | - reference_select, | 6260 | + allow_high_precision_mv, |
| 6175 | - enable_masked_compound, | 6261 | + reference_select, |
| 6176 | - enable_jnt_comp, | 6262 | + enable_masked_compound, |
| 6177 | - order_hint_bits, | 6263 | + enable_jnt_comp, |
| 6178 | - order_hint, | 6264 | + order_hint_bits, |
| 6179 | - ref_order_hints, | 6265 | + order_hint, |
| 6180 | - )?; | 6266 | + ref_order_hints, |
| 6267 | + skip_mode_present, | ||
| 6268 | + skip_mode_frame, | ||
| 6269 | + )?; | ||
| 6181 | prev_leaf = Some((leaf_mi, skip, is_inter)); | 6270 | prev_leaf = Some((leaf_mi, skip, is_inter)); |
| 6271 | + last_skip_mode = skip_mode_leaf; | ||
| 6182 | if compound_ctx8.is_some() { | 6272 | if compound_ctx8.is_some() { |
| 6183 | last_compound_ctx = compound_ctx8; | 6273 | last_compound_ctx = compound_ctx8; |
| 6184 | } | 6274 | } |
| @@ -6202,6 +6292,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6202 | is_inter, | 6292 | is_inter, |
| 6203 | if is_inter { LAST_FRAME } else { -1 }, | 6293 | if is_inter { LAST_FRAME } else { -1 }, |
| 6204 | [3, 3], | 6294 | [3, 3], |
| 6295 | + last_skip_mode, | ||
| 6205 | ); | 6296 | ); |
| 6206 | if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx { | 6297 | if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx { |
| 6207 | neighbours.record_inter( | 6298 | neighbours.record_inter( |
| @@ -6211,6 +6302,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6211 | is_inter, | 6302 | is_inter, |
| 6212 | ref0, | 6303 | ref0, |
| 6213 | [3, 3], | 6304 | [3, 3], |
| 6305 | + last_skip_mode, | ||
| 6214 | ); | 6306 | ); |
| 6215 | neighbours | 6307 | neighbours |
| 6216 | .record_compound_ctx(at16, SUB, ref1, group_idx, idx); | 6308 | .record_compound_ctx(at16, SUB, ref1, group_idx, idx); |
| @@ -6311,7 +6403,7 @@ mod tests { | |||
| 6311 | #[test] | 6403 | #[test] |
| 6312 | fn record_compound_ctx_stamps_ref1_for_the_next_block_to_read() { | 6404 | fn record_compound_ctx_stamps_ref1_for_the_next_block_to_read() { |
| 6313 | let mut n = Neighbours::new(4, 4, 16, 16); | 6405 | let mut n = Neighbours::new(4, 4, 16, 16); |
| 6314 | - n.record_inter((0, 0), SUB, false, true, LAST_FRAME, [3, 3]); | 6406 | + n.record_inter((0, 0), SUB, false, true, LAST_FRAME, [3, 3], false); |
| 6315 | assert_eq!(n.above_ref1[0], None, "record_inter alone never sets ref1"); | 6407 | assert_eq!(n.above_ref1[0], None, "record_inter alone never sets ref1"); |
| 6316 | n.record_compound_ctx((0, 0), SUB, ALTREF_FRAME, 0, 1); | 6408 | n.record_compound_ctx((0, 0), SUB, ALTREF_FRAME, 0, 1); |
| 6317 | assert_eq!(n.above_ref1[0], Some(ALTREF_FRAME)); | 6409 | assert_eq!(n.above_ref1[0], Some(ALTREF_FRAME)); |
| @@ -6952,6 +7044,8 @@ mod tests { | |||
| 6952 | 0, | 7044 | 0, |
| 6953 | 0, | 7045 | 0, |
| 6954 | [0; 7], | 7046 | [0; 7], |
| 7047 | + false, | ||
| 7048 | + [0; 2], | ||
| 6955 | ) | 7049 | ) |
| 6956 | .unwrap(); | 7050 | .unwrap(); |
| 6957 | 7051 | ||
crates/ec-av1/src/stream.rsmodified+169 -12
| @@ -182,18 +182,10 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 182 | // `comp_mode` per block whenever this frame's own `reference_select` | 182 | // `comp_mode` per block whenever this frame's own `reference_select` |
| 183 | // header bit is set (spec 5.11.25), and refuse by name the blocks | 183 | // header bit is set (spec 5.11.25), and refuse by name the blocks |
| 184 | // that pick `COMPOUND_REFERENCE` -- two-reference motion | 184 | // that pick `COMPOUND_REFERENCE` -- two-reference motion |
| 185 | - // compensation is not wired yet. `skip_mode` (spec 5.9.22) is a | 185 | + // compensation is not wired yet. Round 14: `skip_mode` (spec 5.9.22) |
| 186 | - // separate header bit `skip_mode_params()` only ever sets alongside | 186 | + // is wired at the block level too (forced NEAREST_NEARESTMV compound |
| 187 | - // `reference_select`, but never implied by it (an encoder may leave | 187 | + // of `skip_mode_frame`, plain average blend), so the old blanket |
| 188 | - // `skip_mode_present` false even with `reference_select` true); it | 188 | + // `skip_mode_present` refusal is gone. |
| 189 | - // still needs its own refusal since no block-level reader for it | ||
| 190 | - // exists. | ||
| 191 | - if header.skip_mode_present { | ||
| 192 | - return Err(Error::unsupported( | ||
| 193 | - "AV1 decode_stream", | ||
| 194 | - "a frame with skip_mode_present set (this decoder never reads skip_mode)", | ||
| 195 | - )); | ||
| 196 | - } | ||
| 197 | // `context_update_tile_id` (spec `decode_tile`/`exit_symbol`) names | 189 | // `context_update_tile_id` (spec `decode_tile`/`exit_symbol`) names |
| 198 | // which tile's end-of-tile adapted CDFs become the frame's own; this | 190 | // which tile's end-of-tile adapted CDFs become the frame's own; this |
| 199 | // decoder only ever decodes tile 0 (`tiles.first()` above), so a | 191 | // decoder only ever decodes tile 0 (`tiles.first()` above), so a |
| @@ -348,6 +340,8 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 348 | header.reference_select, | 340 | header.reference_select, |
| 349 | enable_masked_compound, | 341 | enable_masked_compound, |
| 350 | enable_jnt_comp, | 342 | enable_jnt_comp, |
| 343 | + header.skip_mode_present, | ||
| 344 | + header.skip_mode_frame, | ||
| 351 | )? | 345 | )? |
| 352 | }; | 346 | }; |
| 353 | // Spec 7.20: `disable_frame_end_update_cdf` stores the frame's | 347 | // Spec 7.20: `disable_frame_end_update_cdf` stores the frame's |
| @@ -2577,6 +2571,169 @@ mod tests { | |||
| 2577 | ); | 2571 | ); |
| 2578 | } | 2572 | } |
| 2579 | 2573 | ||
| 2574 | + /// lane-av1comp round 14's decisive gate for `skip_mode`: same | ||
| 2575 | + /// pin-on-mismatch pattern as [`a_real_aomenc_single_ref_gate`], proving | ||
| 2576 | + /// [`decode::skip_mode_hits`] actually advanced (a real block picked | ||
| 2577 | + /// `skip_mode`, not just that the frame header bit was set) and that the | ||
| 2578 | + /// resulting forced-compound `NEAREST_NEARESTMV` decode is still | ||
| 2579 | + /// pixel-exact against ffmpeg. `--auto-alt-ref=1 --lag-in-frames=16 | ||
| 2580 | + /// --enable-fwd-kf=0` (backward references) plus | ||
| 2581 | + /// `--enable-ref-frame-mvs=0` (unimplemented temporal MV projection, | ||
| 2582 | + /// same as every other gate here) is aomenc's own requirement for | ||
| 2583 | + /// `skip_mode_present` to ever be considered at all (spec 5.9.22 needs | ||
| 2584 | + /// both a forward and a backward reference candidate). | ||
| 2585 | + #[test] | ||
| 2586 | + fn a_real_aomenc_stream_with_compound_references_decodes_pixel_exact() { | ||
| 2587 | + const NAME: &str = "a_real_aomenc_stream_with_compound_references_decodes_pixel_exact"; | ||
| 2588 | + if !have_ffmpeg() { | ||
| 2589 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 2590 | + return; | ||
| 2591 | + } | ||
| 2592 | + if !have_aomenc() { | ||
| 2593 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 2594 | + return; | ||
| 2595 | + } | ||
| 2596 | + let (width, height, frame_count) = (64usize, 64usize, 24usize); | ||
| 2597 | + let mut refusals = Vec::new(); | ||
| 2598 | + let mut never_fired = 0u32; | ||
| 2599 | + for attempt in 0..80u32 { | ||
| 2600 | + let seed = 42 + attempt % 40; | ||
| 2601 | + let duration = frame_count as f64 / 25.0; | ||
| 2602 | + let source = | ||
| 2603 | + format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | ||
| 2604 | + let y4m = Command::new("ffmpeg") | ||
| 2605 | + .args([ | ||
| 2606 | + "-v", | ||
| 2607 | + "error", | ||
| 2608 | + "-f", | ||
| 2609 | + "lavfi", | ||
| 2610 | + "-i", | ||
| 2611 | + &source, | ||
| 2612 | + "-pix_fmt", | ||
| 2613 | + "yuv420p", | ||
| 2614 | + "-f", | ||
| 2615 | + "yuv4mpegpipe", | ||
| 2616 | + "-", | ||
| 2617 | + ]) | ||
| 2618 | + .stdin(Stdio::null()) | ||
| 2619 | + .stdout(Stdio::piped()) | ||
| 2620 | + .stderr(Stdio::piped()) | ||
| 2621 | + .output() | ||
| 2622 | + .expect("ffmpeg failed to run"); | ||
| 2623 | + assert!( | ||
| 2624 | + y4m.status.success(), | ||
| 2625 | + "ffmpeg fixture: {}", | ||
| 2626 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 2627 | + ); | ||
| 2628 | + let args: Vec<&str> = vec![ | ||
| 2629 | + "--codec=av1", | ||
| 2630 | + "--passes=1", | ||
| 2631 | + "--end-usage=q", | ||
| 2632 | + "--cq-level=45", | ||
| 2633 | + "--cpu-used=0", | ||
| 2634 | + "--kf-max-dist=1000", | ||
| 2635 | + "--threads=1", | ||
| 2636 | + "--row-mt=0", | ||
| 2637 | + "--auto-alt-ref=1", | ||
| 2638 | + "--lag-in-frames=16", | ||
| 2639 | + "--enable-fwd-kf=0", | ||
| 2640 | + "--enable-order-hint=1", | ||
| 2641 | + "--enable-warped-motion=0", | ||
| 2642 | + "--enable-obmc=0", | ||
| 2643 | + "--enable-masked-comp=0", | ||
| 2644 | + "--enable-interintra-comp=0", | ||
| 2645 | + "--enable-onesided-comp=0", | ||
| 2646 | + "--enable-interintra-wedge=0", | ||
| 2647 | + "--enable-smooth-interintra=0", | ||
| 2648 | + "--enable-rect-partitions=0", | ||
| 2649 | + "--enable-ab-partitions=0", | ||
| 2650 | + "--enable-1to4-partitions=0", | ||
| 2651 | + "--enable-filter-intra=0", | ||
| 2652 | + "--enable-smooth-intra=0", | ||
| 2653 | + "--enable-paeth-intra=0", | ||
| 2654 | + "--enable-directional-intra=0", | ||
| 2655 | + "--enable-angle-delta=0", | ||
| 2656 | + "--enable-tx-size-search=0", | ||
| 2657 | + "--enable-cdef=0", | ||
| 2658 | + "--enable-restoration=0", | ||
| 2659 | + "--max-partition-size=32", | ||
| 2660 | + "--min-partition-size=32", | ||
| 2661 | + "--enable-palette=0", | ||
| 2662 | + "--enable-intrabc=0", | ||
| 2663 | + "--enable-cfl-intra=0", | ||
| 2664 | + "--enable-ref-frame-mvs=0", | ||
| 2665 | + "--obu", | ||
| 2666 | + "-o", | ||
| 2667 | + "-", | ||
| 2668 | + "-", | ||
| 2669 | + ]; | ||
| 2670 | + let mut child = Command::new(aomenc_path()) | ||
| 2671 | + .args(&args) | ||
| 2672 | + .stdin(Stdio::piped()) | ||
| 2673 | + .stdout(Stdio::piped()) | ||
| 2674 | + .stderr(Stdio::piped()) | ||
| 2675 | + .spawn() | ||
| 2676 | + .expect("aomenc failed to start"); | ||
| 2677 | + child | ||
| 2678 | + .stdin | ||
| 2679 | + .take() | ||
| 2680 | + .expect("aomenc stdin") | ||
| 2681 | + .write_all(&y4m.stdout) | ||
| 2682 | + .expect("writing y4m to aomenc"); | ||
| 2683 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 2684 | + assert!( | ||
| 2685 | + out.status.success(), | ||
| 2686 | + "aomenc refused the fixture: {}", | ||
| 2687 | + String::from_utf8_lossy(&out.stderr) | ||
| 2688 | + ); | ||
| 2689 | + let stream = out.stdout; | ||
| 2690 | + let before = decode::skip_mode_hits(); | ||
| 2691 | + let frames = match decode_stream(&stream) { | ||
| 2692 | + Err(e) => { | ||
| 2693 | + let msg = e.to_string(); | ||
| 2694 | + assert!( | ||
| 2695 | + msg.contains("unsupported"), | ||
| 2696 | + "{NAME} failed outright (seed {seed}): {msg}" | ||
| 2697 | + ); | ||
| 2698 | + refusals.push(format!("seed {seed}: {msg}")); | ||
| 2699 | + continue; | ||
| 2700 | + } | ||
| 2701 | + Ok(frames) => frames, | ||
| 2702 | + }; | ||
| 2703 | + if decode::skip_mode_hits() == before { | ||
| 2704 | + never_fired += 1; | ||
| 2705 | + continue; | ||
| 2706 | + } | ||
| 2707 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | ||
| 2708 | + assert_eq!(frames.len(), frame_count); | ||
| 2709 | + let mismatched = frames | ||
| 2710 | + .iter() | ||
| 2711 | + .zip(&ffmpeg_frames) | ||
| 2712 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 2713 | + if mismatched { | ||
| 2714 | + if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | ||
| 2715 | + std::fs::write(&path, &stream).expect("writing pinned stream"); | ||
| 2716 | + eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | ||
| 2717 | + } | ||
| 2718 | + } | ||
| 2719 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 2720 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 2721 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | ||
| 2722 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | ||
| 2723 | + } | ||
| 2724 | + eprintln!( | ||
| 2725 | + "{NAME} FIRING seed {seed}: skip_mode hits advanced by {}", | ||
| 2726 | + decode::skip_mode_hits() - before | ||
| 2727 | + ); | ||
| 2728 | + return; | ||
| 2729 | + } | ||
| 2730 | + eprintln!( | ||
| 2731 | + "SKIP {NAME}: {never_fired} attempts decoded but never fired skip_mode, and every \ | ||
| 2732 | + other attempt hit a named refusal:\n{}", | ||
| 2733 | + refusals.join("\n") | ||
| 2734 | + ); | ||
| 2735 | + } | ||
| 2736 | + | ||
| 2580 | /// `LAST2_FRAME`/`LAST3_FRAME` are just older slots in the same forward | 2737 | /// `LAST2_FRAME`/`LAST3_FRAME` are just older slots in the same forward |
| 2581 | /// reference-buffer ring `LAST_FRAME`/`GOLDEN_FRAME` already prove -- | 2738 | /// reference-buffer ring `LAST_FRAME`/`GOLDEN_FRAME` already prove -- |
| 2582 | /// dropping the golden gate's `--max-reference-frames=3 | 2739 | /// dropping the golden gate's `--max-reference-frames=3 |