Pin that no per-frame decode state is thread_local again
Browse files at this commit4c4f667615f61f75b0c0c575c7ea425409df9c41Parent: b9a9498- test
- pin that no per-frame decode state is thread_local again
1 changed file +48 -0
- crates/ec-av1/src/stream.rs +48 -0
crates/ec-av1/src/stream.rsmodified+48 -0
| @@ -32587,4 +32587,52 @@ mod tests { | |||
| 32587 | ); | 32587 | ); |
| 32588 | } | 32588 | } |
| 32589 | 32589 | ||
| 32590 | + | ||
| 32591 | + /// lane-thread1: every per-frame/per-stream decode state now lives in | ||
| 32592 | + /// [`crate::decode::FrameCtx`], not in a `thread_local!`. A static that | ||
| 32593 | + /// comes back would silently re-break frame-parallel decoding (a worker | ||
| 32594 | + /// thread sees an empty copy) without failing any pixel gate, so pin the | ||
| 32595 | + /// 38 names by name against the sources themselves. | ||
| 32596 | + #[test] | ||
| 32597 | + fn no_per_frame_state_is_thread_local_any_more() { | ||
| 32598 | + const MOVED: [&str; 38] = [ | ||
| 32599 | + "SB128", "CDEF_BITS", "BIT_DEPTH", "SUPERRES", "CDEF_TRANSMITTED", "CDEF_SB_COLS", | ||
| 32600 | + "CDEF_IDX_GRID", "DELTA_Q_PRESENT", "DELTA_Q_RES", "CURRENT_Q_IDX", "QUANT_DELTAS", | ||
| 32601 | + "DELTA_LF_PRESENT", "DELTA_LF_RES", "DELTA_LF_MULTI", "CURRENT_DELTA_LF", "SEG", | ||
| 32602 | + "SEG_IDS", "PREV_SEG_IDS", "SEG_MI_DIMS", "ABOVE_SEG_PRED", "LEFT_SEG_PRED", | ||
| 32603 | + "CUR_SEGMENT_ID", "SEG_TILE_ORIGIN", "TX_SELECT_INTER", "REDUCED_TX_SET_INTER", | ||
| 32604 | + "ENABLE_FILTER_INTRA_INTER", "PALETTE_PRED", "INTRABC_MI_GRID", "INTRABC_DV", | ||
| 32605 | + "LUMA_TX_TYPE", "INTRABC_CHROMA_TX", "INTRA_IN_INTER_MODE", "INTER_STRIP_CHROMA", | ||
| 32606 | + "INTER_LAST_MC", "ENABLE_EDGE_FILTER", "LAST_FRAME_WIDE_MARGIN", "REACH_SB_PX", | ||
| 32607 | + "GRAIN_BIT_DEPTH", | ||
| 32608 | + ]; | ||
| 32609 | + let sources = [ | ||
| 32610 | + ("decode.rs", include_str!("decode.rs")), | ||
| 32611 | + ("encode.rs", include_str!("encode.rs")), | ||
| 32612 | + ("film_grain.rs", include_str!("film_grain.rs")), | ||
| 32613 | + ]; | ||
| 32614 | + let mut back = Vec::new(); | ||
| 32615 | + for (name, src) in sources { | ||
| 32616 | + for line in src.lines() { | ||
| 32617 | + let t = line.trim_start().trim_start_matches("pub(crate) "); | ||
| 32618 | + if let Some(rest) = t.strip_prefix("static ") { | ||
| 32619 | + let ident = rest.split(':').next().unwrap_or("").trim(); | ||
| 32620 | + if MOVED.contains(&ident) { | ||
| 32621 | + back.push(format!("{name}: {ident}")); | ||
| 32622 | + } | ||
| 32623 | + } | ||
| 32624 | + } | ||
| 32625 | + } | ||
| 32626 | + assert!( | ||
| 32627 | + back.is_empty(), | ||
| 32628 | + "per-frame state is thread_local again (belongs in FrameCtx): {back:?}" | ||
| 32629 | + ); | ||
| 32630 | + // ... and the scratch pools / gate counters DID stay thread-local: | ||
| 32631 | + // this file's own counter reads run on the test thread. | ||
| 32632 | + assert!( | ||
| 32633 | + include_str!("decode.rs").contains("thread_local!"), | ||
| 32634 | + "the scratch pools and gate hit counters are still thread_local by design" | ||
| 32635 | + ); | ||
| 32636 | + } | ||
| 32637 | + | ||
| 32590 | } | 32638 | } |