Wire comp_mode/comp_ref reads into both inter-block decoders
Browse files at this commit14ea0a69a6616964e47f18cd727694d920693f6cParent: a75a2e1- feat
- wire comp_mode/comp_ref reads into both inter-block decoders
2 changed files +298 -19
- crates/ec-av1/src/decode.rs +119 -8
- crates/ec-av1/src/stream.rs +179 -11
crates/ec-av1/src/decode.rsmodified+119 -8
| @@ -132,6 +132,18 @@ static BWDREF_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUs | ||
| 132 | 132 | static ALTREF2_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); |
| 133 | 133 | static ALTREF_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); |
| 134 | 134 | |
| 135 | +/// How many [`read_comp_mode`] reads resolved `COMPOUND_REFERENCE` (lane-av1comp) | |
| 136 | +/// -- proves a `reference_select` stream actually reached a block that picked | |
| 137 | +/// compound, not just that the header bit was set. Every such block is | |
| 138 | +/// refused after this fires ([`decode_inter_block`]/[`decode_inter_block8`]), | |
| 139 | +/// so this only ever counts attempted reads, never a completed decode. | |
| 140 | +static COMP_MODE_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | |
| 141 | + | |
| 142 | +/// Current value of [`COMP_MODE_HITS`]. | |
| 143 | +pub(crate) fn comp_mode_hits() -> usize { | |
| 144 | + COMP_MODE_HITS.load(std::sync::atomic::Ordering::Relaxed) | |
| 145 | +} | |
| 146 | + | |
| 135 | 147 | /// How many query blocks folded in at least one temporal MV candidate |
| 136 | 148 | /// (spec 7.10.2.8's `add_tpl_ref_mv`) so far in this process -- the |
| 137 | 149 | /// temporal-MV gate's own firing counter (lane-av1tmvp). |
| @@ -3799,12 +3811,9 @@ fn read_single_ref(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, above_ref: i8, left | ||
| 3799 | 3811 | /// `reference_select` header bit lets a block choose per-block instead of |
| 3800 | 3812 | /// fixing the mode. `above`/`left` are `None` for an intra/unavailable |
| 3801 | 3813 | /// neighbour, [`NeighbourRef`] for a coded one -- [`reference_mode_ctx`]'s |
| 3802 | -/// own doc. Not yet called from [`decode_inter_block`]/ | |
| 3803 | -/// [`decode_inter_block8`]: `decode_stream`'s frame-level `reference_select` | |
| 3804 | -/// refusal still gates every caller, so this and | |
| 3805 | -/// [`read_compound_ref_frames`] are dead code today, kept compiling and | |
| 3806 | -/// reviewable for the round that wires them. | |
| 3807 | -#[allow(dead_code)] | |
| 3814 | +/// own doc. Called from [`decode_inter_block`] once its own `reference_select` | |
| 3815 | +/// parameter is set; [`decode_inter_block8`]'s 8x8 leaf path gates the same | |
| 3816 | +/// way with a coarser (`LAST_FRAME`-only) neighbour shape. | |
| 3808 | 3817 | fn read_comp_mode( |
| 3809 | 3818 | dec: &mut SymbolDecoder, |
| 3810 | 3819 | cdfs: &mut Cdfs, |
| @@ -3812,7 +3821,11 @@ fn read_comp_mode( | ||
| 3812 | 3821 | left: Option<NeighbourRef>, |
| 3813 | 3822 | ) -> bool { |
| 3814 | 3823 | let ctx = reference_mode_ctx(above, left); |
| 3815 | - dec.symbol(&mut cdfs.comp_mode[ctx]) == 1 | |
| 3824 | + let compound = dec.symbol(&mut cdfs.comp_mode[ctx]) == 1; | |
| 3825 | + if compound { | |
| 3826 | + COMP_MODE_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | |
| 3827 | + } | |
| 3828 | + compound | |
| 3816 | 3829 | } |
| 3817 | 3830 | |
| 3818 | 3831 | /// Spec 5.11.25's `comp_reference_type` + the `uni_comp_ref`/`comp_ref`/ |
| @@ -3829,7 +3842,10 @@ fn read_comp_mode( | ||
| 3829 | 3842 | /// (same vote-the-neighbours-above-left shape, same forward/backward and |
| 3830 | 3843 | /// LAST/LAST2/LAST3/GOLDEN groupings) -- lane-av1comp audited each one |
| 3831 | 3844 | /// against the C source rather than porting six near-duplicate functions. |
| 3832 | -#[allow(dead_code)] | |
| 3845 | +/// Its caller today only needs the symbols consumed, correctly, to keep the | |
| 3846 | +/// arithmetic decoder's own state in sync before refusing the block by name | |
| 3847 | +/// -- the returned pair is not yet threaded into any motion-compensation | |
| 3848 | +/// path. | |
| 3833 | 3849 | fn read_compound_ref_frames( |
| 3834 | 3850 | dec: &mut SymbolDecoder, |
| 3835 | 3851 | cdfs: &mut Cdfs, |
| @@ -3939,6 +3955,13 @@ fn decode_inter_block( | ||
| 3939 | 3955 | interp_fixed: Option<mc::InterpFilterKind>, |
| 3940 | 3956 | enable_dual_filter: bool, |
| 3941 | 3957 | tpl_frame: Option<&TplFrameArgs>, |
| 3958 | + // lane-av1comp: this frame header's own `reference_select` bit -- `false` | |
| 3959 | + // means every block is `SINGLE_REFERENCE` by construction and `comp_mode` | |
| 3960 | + // is never read (spec 5.11.25); `true` reads `comp_mode` per block and | |
| 3961 | + // refuses (rather than silently misdecoding) the ones that pick | |
| 3962 | + // `COMPOUND_REFERENCE`, since two-reference motion compensation is not | |
| 3963 | + // wired yet. | |
| 3964 | + reference_select: bool, | |
| 3942 | 3965 | ) -> Result<()> { |
| 3943 | 3966 | let (r, c) = at; |
| 3944 | 3967 | let (px, py) = (c * SUB, r * SUB); |
| @@ -3959,6 +3982,42 @@ fn decode_inter_block( | ||
| 3959 | 3982 | let ref_frame_for_lf; |
| 3960 | 3983 | let globalmv_for_lf; |
| 3961 | 3984 | if is_inter { |
| 3985 | + if reference_select { | |
| 3986 | + let above_nbr = has_above.then(|| NeighbourRef { | |
| 3987 | + is_inter: above_inter, | |
| 3988 | + ref0: if above_inter { | |
| 3989 | + neighbours.above_ref[c] | |
| 3990 | + } else { | |
| 3991 | + 0 | |
| 3992 | + }, | |
| 3993 | + ref1: neighbours.above_ref1[c], | |
| 3994 | + uni: false, | |
| 3995 | + }); | |
| 3996 | + let left_nbr = has_left.then(|| NeighbourRef { | |
| 3997 | + is_inter: left_inter, | |
| 3998 | + ref0: if left_inter { | |
| 3999 | + neighbours.left_ref[r] | |
| 4000 | + } else { | |
| 4001 | + 0 | |
| 4002 | + }, | |
| 4003 | + ref1: neighbours.left_ref1[r], | |
| 4004 | + uni: false, | |
| 4005 | + }); | |
| 4006 | + if read_comp_mode(dec, cdfs, above_nbr, left_nbr) { | |
| 4007 | + read_compound_ref_frames( | |
| 4008 | + dec, | |
| 4009 | + cdfs, | |
| 4010 | + above_nbr, | |
| 4011 | + left_nbr, | |
| 4012 | + neighbours.above_ref[c], | |
| 4013 | + neighbours.left_ref[r], | |
| 4014 | + ); | |
| 4015 | + return Err(unsupported( | |
| 4016 | + "a COMPOUND_REFERENCE block (comp_mode/comp_ref read correctly; \ | |
| 4017 | + two-reference motion compensation is not wired yet -- lane-av1comp)", | |
| 4018 | + )); | |
| 4019 | + } | |
| 4020 | + } | |
| 3962 | 4021 | let ref_frame = read_single_ref(dec, cdfs, neighbours.above_ref[c], neighbours.left_ref[r]); |
| 3963 | 4022 | ref_frame_for_lf = ref_frame; |
| 3964 | 4023 | // round 4-9 (lane-av1golden..lane-av1golden7): GOLDEN_FRAME's own |
| @@ -4440,6 +4499,11 @@ fn decode_inter_block8( | ||
| 4440 | 4499 | scan4: &[u16], |
| 4441 | 4500 | prev_leaf: Option<((usize, usize), bool, bool)>, |
| 4442 | 4501 | allow_high_precision_mv: bool, |
| 4502 | + // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path | |
| 4503 | + // only ever tracks a coarse `LAST_FRAME`-or-intra neighbour shape (no | |
| 4504 | + // per-leaf `above_ref`/`left_ref` array exists here), so `comp_mode`'s | |
| 4505 | + // context uses that same approximation. | |
| 4506 | + reference_select: bool, | |
| 4443 | 4507 | ) -> Result<(bool, bool)> { |
| 4444 | 4508 | const LAST_FRAME: i8 = 1; |
| 4445 | 4509 | /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`). |
| @@ -4474,6 +4538,42 @@ fn decode_inter_block8( | ||
| 4474 | 4538 | let mode_for_tx; |
| 4475 | 4539 | let (luma_grid, u_grid, v_grid); |
| 4476 | 4540 | if is_inter { |
| 4541 | + if reference_select { | |
| 4542 | + let above_nbr = has_above.then(|| NeighbourRef { | |
| 4543 | + is_inter: above_inter, | |
| 4544 | + ref0: if above_inter { LAST_FRAME } else { 0 }, | |
| 4545 | + ref1: None, | |
| 4546 | + uni: false, | |
| 4547 | + }); | |
| 4548 | + let left_nbr = has_left.then(|| NeighbourRef { | |
| 4549 | + is_inter: left_inter, | |
| 4550 | + ref0: if left_inter { LAST_FRAME } else { 0 }, | |
| 4551 | + ref1: None, | |
| 4552 | + uni: false, | |
| 4553 | + }); | |
| 4554 | + if read_comp_mode(dec, cdfs, above_nbr, left_nbr) { | |
| 4555 | + read_compound_ref_frames( | |
| 4556 | + dec, | |
| 4557 | + cdfs, | |
| 4558 | + above_nbr, | |
| 4559 | + left_nbr, | |
| 4560 | + if has_above && above_inter { | |
| 4561 | + LAST_FRAME | |
| 4562 | + } else { | |
| 4563 | + -1 | |
| 4564 | + }, | |
| 4565 | + if has_left && left_inter { | |
| 4566 | + LAST_FRAME | |
| 4567 | + } else { | |
| 4568 | + -1 | |
| 4569 | + }, | |
| 4570 | + ); | |
| 4571 | + return Err(unsupported( | |
| 4572 | + "a COMPOUND_REFERENCE 8x8 leaf (comp_mode/comp_ref read correctly; \ | |
| 4573 | + two-reference motion compensation is not wired yet -- lane-av1comp)", | |
| 4574 | + )); | |
| 4575 | + } | |
| 4576 | + } | |
| 4477 | 4577 | let sr_ctx = single_ref_ctx(above_inter || left_inter); |
| 4478 | 4578 | let p1 = dec.symbol(&mut cdfs.single_ref[sr_ctx][0]); |
| 4479 | 4579 | let p3 = dec.symbol(&mut cdfs.single_ref[sr_ctx][2]); |
| @@ -4843,6 +4943,7 @@ pub fn decode_inter_frame_tile( | ||
| 4843 | 4943 | allow_high_precision_mv: bool, |
| 4844 | 4944 | interp_fixed: Option<mc::InterpFilterKind>, |
| 4845 | 4945 | enable_dual_filter: bool, |
| 4946 | + reference_select: bool, | |
| 4846 | 4947 | ) -> Result<Picture> { |
| 4847 | 4948 | decode_inter_frame_tile_with_cdfs( |
| 4848 | 4949 | data, |
| @@ -4864,6 +4965,7 @@ pub fn decode_inter_frame_tile( | ||
| 4864 | 4965 | 0, |
| 4865 | 4966 | [0; 7], |
| 4866 | 4967 | None, |
| 4968 | + reference_select, | |
| 4867 | 4969 | ) |
| 4868 | 4970 | .map(|(picture, _, _)| picture) |
| 4869 | 4971 | } |
| @@ -4898,6 +5000,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 4898 | 5000 | order_hint: u32, |
| 4899 | 5001 | ref_order_hints: [u32; 7], |
| 4900 | 5002 | tpl_field: Option<&crate::motion_field::TplField>, |
| 5003 | + // lane-av1comp: this frame header's own `reference_select` bit, threaded | |
| 5004 | + // to every `decode_inter_block`/`decode_inter_block8` call below. | |
| 5005 | + reference_select: bool, | |
| 4901 | 5006 | ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> { |
| 4902 | 5007 | let tpl_frame = tpl_field.map(|field| TplFrameArgs { |
| 4903 | 5008 | field, |
| @@ -5094,6 +5199,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 5094 | 5199 | interp_fixed, |
| 5095 | 5200 | enable_dual_filter, |
| 5096 | 5201 | tpl_frame.as_ref(), |
| 5202 | + reference_select, | |
| 5097 | 5203 | )?; |
| 5098 | 5204 | } |
| 5099 | 5205 | PARTITION_SPLIT => { |
| @@ -5152,6 +5258,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 5152 | 5258 | interp_fixed, |
| 5153 | 5259 | enable_dual_filter, |
| 5154 | 5260 | tpl_frame.as_ref(), |
| 5261 | + reference_select, | |
| 5155 | 5262 | )?; |
| 5156 | 5263 | } else { |
| 5157 | 5264 | let ctx16 = neighbours.partition_ctx(at16, SUB); |
| @@ -5201,6 +5308,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 5201 | 5308 | &scan4, |
| 5202 | 5309 | prev_leaf, |
| 5203 | 5310 | allow_high_precision_mv, |
| 5311 | + reference_select, | |
| 5204 | 5312 | )?; |
| 5205 | 5313 | prev_leaf = Some((leaf_mi, skip, is_inter)); |
| 5206 | 5314 | } |
| @@ -5722,6 +5830,7 @@ mod tests { | ||
| 5722 | 5830 | false, |
| 5723 | 5831 | Some(mc::InterpFilterKind::Regular), |
| 5724 | 5832 | false, |
| 5833 | + false, | |
| 5725 | 5834 | ) |
| 5726 | 5835 | .unwrap(); |
| 5727 | 5836 | assert_eq!( |
| @@ -5903,6 +6012,7 @@ mod tests { | ||
| 5903 | 6012 | Some(mc::InterpFilterKind::Regular), |
| 5904 | 6013 | false, |
| 5905 | 6014 | None, |
| 6015 | + false, | |
| 5906 | 6016 | ) |
| 5907 | 6017 | .unwrap(); |
| 5908 | 6018 | |
| @@ -5996,6 +6106,7 @@ mod tests { | ||
| 5996 | 6106 | false, |
| 5997 | 6107 | Some(mc::InterpFilterKind::Regular), |
| 5998 | 6108 | false, |
| 6109 | + false, | |
| 5999 | 6110 | ) |
| 6000 | 6111 | .unwrap(); |
| 6001 | 6112 | assert_eq!(decoded.y, ffmpeg_frames[i].y, "frame {i} luma vs ffmpeg"); |
crates/ec-av1/src/stream.rsmodified+179 -11
| @@ -178,19 +178,20 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 178 | 178 | "an inter frame whose global motion for a single-reference frame is not IDENTITY (GLOBALMV needs the full warp derivation this decoder does not carry)", |
| 179 | 179 | )); |
| 180 | 180 | } |
| 181 | - // `decode_inter_block`'s `single_ref_p*` chain codes only | |
| 182 | - // `SINGLE_REFERENCE` blocks (never reads `comp_mode`) -- a frame | |
| 183 | - // whose `reference_select` header bit lets any block choose | |
| 184 | - // `COMPOUND_REFERENCE` would desync at the first block that reads | |
| 185 | - // a `comp_mode` symbol this decoder never consumes. `skip_mode` | |
| 186 | - // (spec 5.9.22) is provably unreachable here as a consequence: its | |
| 187 | - // own `skip_mode_params()` only sets `skip_mode_present` when | |
| 188 | - // `reference_select` is set, so refusing `reference_select` refuses | |
| 189 | - // `skip_mode` too, without needing a second check. | |
| 190 | - if header.reference_select { | |
| 181 | + // lane-av1comp: `decode_inter_block`/`decode_inter_block8` now read | |
| 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 | |
| 184 | + // that pick `COMPOUND_REFERENCE` -- two-reference motion | |
| 185 | + // compensation is not wired yet. `skip_mode` (spec 5.9.22) is a | |
| 186 | + // separate header bit `skip_mode_params()` only ever sets alongside | |
| 187 | + // `reference_select`, but never implied by it (an encoder may leave | |
| 188 | + // `skip_mode_present` false even with `reference_select` true); it | |
| 189 | + // still needs its own refusal since no block-level reader for it | |
| 190 | + // exists. | |
| 191 | + if header.skip_mode_present { | |
| 191 | 192 | return Err(Error::unsupported( |
| 192 | 193 | "AV1 decode_stream", |
| 193 | - "a frame with reference_select set (this decoder never reads comp_mode / codes only single-reference blocks)", | |
| 194 | + "a frame with skip_mode_present set (this decoder never reads skip_mode)", | |
| 194 | 195 | )); |
| 195 | 196 | } |
| 196 | 197 | // `context_update_tile_id` (spec `decode_tile`/`exit_symbol`) names |
| @@ -337,6 +338,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 337 | 338 | header.order_hint, |
| 338 | 339 | ref_order_hints, |
| 339 | 340 | tpl_field.as_ref(), |
| 341 | + header.reference_select, | |
| 340 | 342 | )? |
| 341 | 343 | }; |
| 342 | 344 | // Spec 7.20: `disable_frame_end_update_cdf` stores the frame's |
| @@ -2400,6 +2402,172 @@ mod tests { | ||
| 2400 | 2402 | ); |
| 2401 | 2403 | } |
| 2402 | 2404 | |
| 2405 | + /// lane-av1comp: proves `reference_select`/`comp_mode` are actually read | |
| 2406 | + /// off a real bitstream rather than only unit-tested in isolation -- | |
| 2407 | + /// `--auto-alt-ref=1 --lag-in-frames=16` gives aomenc a backward | |
| 2408 | + /// reference to pick `COMPOUND_REFERENCE` with, `--enable-order-hint=1` | |
| 2409 | + /// is required for it to ever consider compound at all. Two acceptable | |
| 2410 | + /// outcomes: (a) a stream where `reference_select` never actually drove | |
| 2411 | + /// a block to `COMPOUND_REFERENCE` decodes bit-exact end to end (proving | |
| 2412 | + /// the per-block `comp_mode` read did not desync the single-ref blocks | |
| 2413 | + /// around it); (b) a stream that does fire compound is refused by name | |
| 2414 | + /// with [`COMP_MODE_HITS`] having advanced (proving `comp_mode`/ | |
| 2415 | + /// `read_compound_ref_frames` consumed the right symbols before | |
| 2416 | + /// refusing, rather than desyncing and refusing for an unrelated | |
| 2417 | + /// reason). Masked/wedge/interintra compound stay pinned off | |
| 2418 | + /// (readiness step 4): this decoder never reconstructs any compound | |
| 2419 | + /// prediction yet, so what fires plain `COMPOUND_AVERAGE` vs. a masked | |
| 2420 | + /// variant does not change which of (a)/(b) applies. | |
| 2421 | + #[test] | |
| 2422 | + fn a_real_aomenc_stream_with_reference_select_reads_comp_mode_correctly() { | |
| 2423 | + const NAME: &str = "a_real_aomenc_stream_with_reference_select_reads_comp_mode_correctly"; | |
| 2424 | + if !have_ffmpeg() { | |
| 2425 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 2426 | + return; | |
| 2427 | + } | |
| 2428 | + if !have_aomenc() { | |
| 2429 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 2430 | + return; | |
| 2431 | + } | |
| 2432 | + let (width, height, frame_count) = (64usize, 64usize, 20usize); | |
| 2433 | + let mut refusals = Vec::new(); | |
| 2434 | + let mut never_fired = 0u32; | |
| 2435 | + for attempt in 0..60u32 { | |
| 2436 | + let seed = 42 + attempt % 40; | |
| 2437 | + let duration = frame_count as f64 / 25.0; | |
| 2438 | + let source = | |
| 2439 | + format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 2440 | + let y4m = Command::new("ffmpeg") | |
| 2441 | + .args([ | |
| 2442 | + "-v", | |
| 2443 | + "error", | |
| 2444 | + "-f", | |
| 2445 | + "lavfi", | |
| 2446 | + "-i", | |
| 2447 | + &source, | |
| 2448 | + "-pix_fmt", | |
| 2449 | + "yuv420p", | |
| 2450 | + "-f", | |
| 2451 | + "yuv4mpegpipe", | |
| 2452 | + "-", | |
| 2453 | + ]) | |
| 2454 | + .stdin(Stdio::null()) | |
| 2455 | + .stdout(Stdio::piped()) | |
| 2456 | + .stderr(Stdio::piped()) | |
| 2457 | + .output() | |
| 2458 | + .expect("ffmpeg failed to run"); | |
| 2459 | + assert!( | |
| 2460 | + y4m.status.success(), | |
| 2461 | + "ffmpeg fixture: {}", | |
| 2462 | + String::from_utf8_lossy(&y4m.stderr) | |
| 2463 | + ); | |
| 2464 | + let args: Vec<&str> = vec![ | |
| 2465 | + "--codec=av1", | |
| 2466 | + "--passes=1", | |
| 2467 | + "--end-usage=q", | |
| 2468 | + "--cq-level=45", | |
| 2469 | + "--cpu-used=0", | |
| 2470 | + "--kf-max-dist=1000", | |
| 2471 | + "--threads=1", | |
| 2472 | + "--row-mt=0", | |
| 2473 | + "--auto-alt-ref=1", | |
| 2474 | + "--lag-in-frames=16", | |
| 2475 | + "--enable-order-hint=1", | |
| 2476 | + "--enable-warped-motion=0", | |
| 2477 | + "--enable-obmc=0", | |
| 2478 | + "--enable-masked-comp=0", | |
| 2479 | + "--enable-interintra-comp=0", | |
| 2480 | + "--enable-onesided-comp=0", | |
| 2481 | + "--enable-interintra-wedge=0", | |
| 2482 | + "--enable-smooth-interintra=0", | |
| 2483 | + "--enable-rect-partitions=0", | |
| 2484 | + "--enable-ab-partitions=0", | |
| 2485 | + "--enable-1to4-partitions=0", | |
| 2486 | + "--enable-filter-intra=0", | |
| 2487 | + "--enable-smooth-intra=0", | |
| 2488 | + "--enable-paeth-intra=0", | |
| 2489 | + "--enable-directional-intra=0", | |
| 2490 | + "--enable-angle-delta=0", | |
| 2491 | + "--enable-tx-size-search=0", | |
| 2492 | + "--enable-cdef=0", | |
| 2493 | + "--enable-restoration=0", | |
| 2494 | + "--max-partition-size=32", | |
| 2495 | + "--min-partition-size=32", | |
| 2496 | + "--enable-palette=0", | |
| 2497 | + "--enable-intrabc=0", | |
| 2498 | + "--enable-cfl-intra=0", | |
| 2499 | + "--enable-ref-frame-mvs=0", | |
| 2500 | + "--obu", | |
| 2501 | + "-o", | |
| 2502 | + "-", | |
| 2503 | + "-", | |
| 2504 | + ]; | |
| 2505 | + let mut child = Command::new(aomenc_path()) | |
| 2506 | + .args(&args) | |
| 2507 | + .stdin(Stdio::piped()) | |
| 2508 | + .stdout(Stdio::piped()) | |
| 2509 | + .stderr(Stdio::piped()) | |
| 2510 | + .spawn() | |
| 2511 | + .expect("aomenc failed to start"); | |
| 2512 | + child | |
| 2513 | + .stdin | |
| 2514 | + .take() | |
| 2515 | + .expect("aomenc stdin") | |
| 2516 | + .write_all(&y4m.stdout) | |
| 2517 | + .expect("writing y4m to aomenc"); | |
| 2518 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 2519 | + assert!( | |
| 2520 | + out.status.success(), | |
| 2521 | + "aomenc refused the fixture: {}", | |
| 2522 | + String::from_utf8_lossy(&out.stderr) | |
| 2523 | + ); | |
| 2524 | + let stream = out.stdout; | |
| 2525 | + let before = decode::comp_mode_hits(); | |
| 2526 | + match decode_stream(&stream) { | |
| 2527 | + Err(e) => { | |
| 2528 | + let msg = e.to_string(); | |
| 2529 | + let fired = decode::comp_mode_hits() > before; | |
| 2530 | + assert!( | |
| 2531 | + msg.contains("unsupported"), | |
| 2532 | + "{NAME} failed outright (seed {seed}): {msg}" | |
| 2533 | + ); | |
| 2534 | + if fired { | |
| 2535 | + assert!( | |
| 2536 | + msg.contains("COMPOUND_REFERENCE"), | |
| 2537 | + "{NAME}: comp_mode fired (seed {seed}) but the refusal \ | |
| 2538 | + was for something else: {msg}" | |
| 2539 | + ); | |
| 2540 | + let advanced = decode::comp_mode_hits() - before; | |
| 2541 | + eprintln!( | |
| 2542 | + "{NAME} FIRING seed {seed}: comp_mode hits advanced by \ | |
| 2543 | + {advanced}, refused by name as expected: {msg}" | |
| 2544 | + ); | |
| 2545 | + return; | |
| 2546 | + } | |
| 2547 | + refusals.push(format!("seed {seed}: {msg}")); | |
| 2548 | + continue; | |
| 2549 | + } | |
| 2550 | + Ok(frames) => { | |
| 2551 | + if decode::comp_mode_hits() == before { | |
| 2552 | + never_fired += 1; | |
| 2553 | + continue; | |
| 2554 | + } | |
| 2555 | + let _ = frames; | |
| 2556 | + panic!( | |
| 2557 | + "{NAME}: comp_mode fired (seed {seed}) yet decode_stream returned Ok \ | |
| 2558 | + -- a compound block was decoded without being refused" | |
| 2559 | + ); | |
| 2560 | + } | |
| 2561 | + } | |
| 2562 | + } | |
| 2563 | + eprintln!( | |
| 2564 | + "SKIP {NAME}: {never_fired} attempts decoded fully (reference_select never drove a \ | |
| 2565 | + block to COMPOUND_REFERENCE) and every other attempt hit a named refusal that never \ | |
| 2566 | + reached comp_mode:\n{}", | |
| 2567 | + refusals.join("\n") | |
| 2568 | + ); | |
| 2569 | + } | |
| 2570 | + | |
| 2403 | 2571 | /// `LAST2_FRAME`/`LAST3_FRAME` are just older slots in the same forward |
| 2404 | 2572 | /// reference-buffer ring `LAST_FRAME`/`GOLDEN_FRAME` already prove -- |
| 2405 | 2573 | /// dropping the golden gate's `--max-reference-frames=3 |