forge
Explore
Log in

Don't you dare go Hollow

Un-swap enable_interintra_compound/enable_jnt_comp at the decode_stream call site

Browse files at this commit

6e4ad3070f0a573fa2687a65b088fd429c9cbbd3Ahmet Kaan GümüşParent: 056185d
  • fix
    • un-swap enable_interintra_compound/enable_jnt_comp at the decode_stream call site
Show full message
fix(av1): un-swap enable_interintra_compound/enable_jnt_comp at the decode_stream call site

lane-comppin r10 (session-killed right after the fix compiled; orchestrator
ran the pin and commits). ROOT CAUSE of the 10-round compound-drift hunt:
decode_stream passed enable_interintra_compound and enable_jnt_comp to
decode_inter_frame_tile_with_cdfs in each other's parameter slots -- two
adjacent same-typed bools, so the compiler was silent. Every stream whose
sequence header set the two bits DIFFERENTLY gated the interintra read on
the jnt_comp bit (and compound_idx gating on the interintra bit): an extra
or missing symbol read, then silent bit-drift for the rest of the tile.
Streams with both bits equal decoded exactly -- which is why the gates
only flaked on some aomenc content and every earlier localization pointed
at a different downstream symbol.

VERIFIED: pin sb128-compound-refs-flake.obu now decodes 24/24 frames
byte-exact (was: frame 1+ all-plane drift accumulating to delta 60).
Also in this commit: EC_AV1_SEQDUMP + remaining EC_AV1_TELL range
checkpoints (env-gated instrumentation, inert when unset).

class: adjacent-same-typed-args -- a call site passing N same-typed flags
positionally can swap a pair without any compiler or roundtrip-test signal
(our own encoder does not exercise the decode_stream path's flag plumbing);
range-ladder bisection + the r9 compare-range-not-tell rule found it.
crates/ec-av1-syntax/src/sequence.rsmodified+17 -0
@@ -372,6 +372,23 @@ impl SequenceHeader {
372 seq.enable_restoration = r.read_bit()?;372 seq.enable_restoration = r.read_bit()?;
373 seq.color_config = read_color_config(r, seq_profile)?;373 seq.color_config = read_color_config(r, seq_profile)?;
374 seq.film_grain_params_present = r.read_bit()?;374 seq.film_grain_params_present = r.read_bit()?;
375+ if std::env::var_os("EC_AV1_SEQDUMP").is_some() {
376+ eprintln!(
377+ "SEQDUMP profile={seq_profile} still={still_picture} reduced={reduced_still_picture_header} \
378+ timing_present={} op_cnt={} idc0={} level0={} frame_width_bits={frame_width_bits} \
379+ frame_height_bits={frame_height_bits} max_w={max_frame_width} max_h={max_frame_height} \
380+ frame_id_present={frame_id_numbers_present_flag} use_128={} filter_intra={} edge_filter={} \
381+ interintra={} masked={} warped={} dual_filter={} order_hint={} jnt_comp={} ref_frame_mvs={}",
382+ timing_info.is_some(),
383+ seq.operating_points.len(),
384+ seq.operating_points.first().map_or(0, |o| o.idc),
385+ seq.operating_points.first().map_or(0, |o| o.seq_level_idx),
386+ use_128x128_superblock, enable_filter_intra, enable_intra_edge_filter,
387+ seq.enable_interintra_compound, seq.enable_masked_compound,
388+ seq.enable_warped_motion, seq.enable_dual_filter, seq.enable_order_hint,
389+ seq.enable_jnt_comp, seq.enable_ref_frame_mvs
390+ );
391+ }
375 Ok(seq)392 Ok(seq)
376 }393 }
377 394
crates/ec-av1/src/decode.rsmodified+24 -0
@@ -628,6 +628,12 @@ fn read_coeffs(
628 eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}");628 eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}");
629 }629 }
630 let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1;630 let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1;
631+ if std::env::var_os("EC_AV1_TELL").is_some() {
632+ eprintln!(
633+ "TELL label=post_txb_skip ctx={skip_ctx} all_zero={} tell={} range={}",
634+ all_zero as u8, dec.debug_bitpos(), dec.debug_state().0
635+ );
636+ }
631 if trace {637 if trace {
632 eprintln!("TRACE all_zero ctx={skip_ctx} value={}", all_zero as i32);638 eprintln!("TRACE all_zero ctx={skip_ctx} value={}", all_zero as i32);
633 }639 }
@@ -5434,6 +5440,12 @@ fn decode_inter_block(
5434 ));5440 ));
5435 }5441 }
5436 }5442 }
5443+ if std::env::var_os("EC_AV1_TELL").is_some() {
5444+ eprintln!(
5445+ "TELL mi_row={mi_row} mi_col={mi_col} label=post_interintra tell={} range={}",
5446+ dec.debug_bitpos(), dec.debug_state().0
5447+ );
5448+ }
5437 // lane-motionmode round 1: `read_motion_mode` (spec 5.11.24;5449 // lane-motionmode round 1: `read_motion_mode` (spec 5.11.24;
5438 // libaom `decodemv.c` read_inter_block_mode_info, ~1520-1528),5450 // libaom `decodemv.c` read_inter_block_mode_info, ~1520-1528),
5439 // placed right after MV assignment and before the switchable5451 // placed right after MV assignment and before the switchable
@@ -5476,6 +5488,12 @@ fn decode_inter_block(
5476 OBMC_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);5488 OBMC_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
5477 }5489 }
5478 }5490 }
5491+ if std::env::var_os("EC_AV1_TELL").is_some() {
5492+ eprintln!(
5493+ "TELL mi_row={mi_row} mi_col={mi_col} label=post_motion_mode eligible={} tell={} range={}",
5494+ motion_mode_eligible as u8, dec.debug_bitpos(), dec.debug_state().0
5495+ );
5496+ }
5479 // spec `get_ref_filter_type`: a neighbour's own filter only feeds5497 // spec `get_ref_filter_type`: a neighbour's own filter only feeds
5480 // this block's switchable_interp context when that neighbour coded5498 // this block's switchable_interp context when that neighbour coded
5481 // the SAME reference frame this block is about to read -- a5499 // the SAME reference frame this block is about to read -- a
@@ -5513,6 +5531,12 @@ fn decode_inter_block(
5513 );5531 );
5514 block_filter = resolved_filter;5532 block_filter = resolved_filter;
5515 globalmv_for_lf = is_globalmv;5533 globalmv_for_lf = is_globalmv;
5534+ if std::env::var_os("EC_AV1_TELL").is_some() {
5535+ eprintln!(
5536+ "TELL mi_row={mi_row} mi_col={mi_col} label=post_interp_filter tell={} range={}",
5537+ dec.debug_bitpos(), dec.debug_state().0
5538+ );
5539+ }
5516 if std::env::var_os("EC_AV1_TRACE").is_some() {5540 if std::env::var_os("EC_AV1_TRACE").is_some() {
5517 eprintln!(5541 eprintln!(
5518 "EC_TRACE mi_row={mi_row} mi_col={mi_col} skip={} is_inter=1 mv=({},{}) is_new_mv={is_new_mv} bsize={side} ref={ref_frame} filter={:?} motion_mode_eligible={} obmc_selected={} tell={}",5542 "EC_TRACE mi_row={mi_row} mi_col={mi_col} skip={} is_inter=1 mv=({},{}) is_new_mv={is_new_mv} bsize={side} ref={ref_frame} filter={:?} motion_mode_eligible={} obmc_selected={} tell={}",
crates/ec-av1/src/stream.rsmodified+1 -1
@@ -382,8 +382,8 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
382 tpl_field.as_ref(),382 tpl_field.as_ref(),
383 header.reference_select,383 header.reference_select,
384 enable_masked_compound,384 enable_masked_compound,
385- enable_interintra_compound,
386 enable_jnt_comp,385 enable_jnt_comp,
386+ enable_interintra_compound,
387 header.skip_mode_present,387 header.skip_mode_present,
388 header.skip_mode_frame,388 header.skip_mode_frame,
389 header.reduced_tx_set,389 header.reduced_tx_set,