forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-sb128fix' (d14eda95): the decoder's frame context is seeded from the stream only; encoder contexts come from FrameCtx::for_encoder (the sb128 merge had raced real 128-superblock decode gates against the encoder witness)

Browse files at this commit

bbeb761be6308b1ac6dbde8b5abcab6bf4dd4c37Ahmet Kaan GümüşParent: ad81365d1b410e
crates/ec-av1/src/decode.rsmodified+20 -11
@@ -158,12 +158,11 @@ impl FrameCtx {
158 /// predecessor was born with.158 /// predecessor was born with.
159 pub(crate) fn new() -> Self {159 pub(crate) fn new() -> Self {
160 Self {160 Self {
161- // lane-sb128: an ENCODER context starts at the sequence size161+ // A DECODER context is seeded from the stream alone: every real
162- // this process encodes (`crate::encode::sb128_on`) so the mode162+ // decode overwrites this from the parsed sequence header
163- // search's own `Reach` and the filter search's internal decodes163+ // (`set_sb128`, stream.rs). The encoder's own contexts start at
164- // agree with the tile writer; every real decode overwrites it164+ // the size this process encodes -- see [`FrameCtx::for_encoder`].
165- // from the parsed sequence header (`set_sb128`, stream.rs).165+ sb128_flag: std::cell::Cell::new(false),
166- sb128_flag: std::cell::Cell::new(crate::encode::sb128_on()),
167 lossless_flag: std::cell::Cell::new(false),166 lossless_flag: std::cell::Cell::new(false),
168 cdef_bits: std::cell::Cell::new(0),167 cdef_bits: std::cell::Cell::new(0),
169 bit_depth: std::cell::Cell::new(8),168 bit_depth: std::cell::Cell::new(8),
@@ -208,11 +207,7 @@ impl FrameCtx {
208 inter_last_mc: std::cell::Cell::new(None),207 inter_last_mc: std::cell::Cell::new(None),
209 enable_edge_filter: std::cell::Cell::new(false),208 enable_edge_filter: std::cell::Cell::new(false),
210 last_frame_wide_margin: std::cell::RefCell::new(None),209 last_frame_wide_margin: std::cell::RefCell::new(None),
211- reach_sb_px: std::cell::Cell::new(if crate::encode::sb128_on() {210+ reach_sb_px: std::cell::Cell::new(crate::encode::SUPERBLOCK),
212- 128
213- } else {
214- crate::encode::SUPERBLOCK
215- }),
216 grain_bit_depth: std::cell::Cell::new(8),211 grain_bit_depth: std::cell::Cell::new(8),
217 recon_ops: std::cell::RefCell::new(Vec::new()),212 recon_ops: std::cell::RefCell::new(Vec::new()),
218 recon_spare: std::cell::RefCell::new(Vec::new()),213 recon_spare: std::cell::RefCell::new(Vec::new()),
@@ -225,6 +220,20 @@ impl FrameCtx {
225 wave_mark: std::cell::Cell::new(None),220 wave_mark: std::cell::Cell::new(None),
226 }221 }
227 }222 }
223+
224+ /// A context for the ENCODER's own trial decodes: it starts at the
225+ /// superblock size this process encodes (`crate::encode::sb128_on`) so
226+ /// the mode search's `Reach` and the filter search's internal decodes
227+ /// agree with the tile writer. A decoder never reads that knob -- doing
228+ /// so coupled every decode to the encoder's process-global and raced the
229+ /// 128-superblock decode gates against the encoder witness.
230+ pub(crate) fn for_encoder() -> Self {
231+ let ctx = Self::new();
232+ let on = crate::encode::sb128_on();
233+ ctx.sb128_flag.set(on);
234+ ctx.reach_sb_px.set(if on { 128 } else { crate::encode::SUPERBLOCK });
235+ ctx
236+ }
228 }237 }
229 238
230 /// `LocalKey::with` for a plain value: lets every former `STATIC.with(|c| ..)`239 /// `LocalKey::with` for a plain value: lets every former `STATIC.with(|c| ..)`
crates/ec-av1/src/encode.rsmodified+64 -63
@@ -4667,18 +4667,19 @@ fn cfl_on() -> bool {
4667 // the same env-flag shape `EC_AV1_FILTER_INTRA` uses. NOT an `EncoderConfig`4667 // the same env-flag shape `EC_AV1_FILTER_INTRA` uses. NOT an `EncoderConfig`
4668 // field: that struct is built by 90 literal sites in this workspace.4668 // field: that struct is built by 90 literal sites in this workspace.
4669 4669
4670-/// Whether this process's sequences code 128x128 superblocks. Read through4670+/// Whether this process's sequences code 128x128 superblocks. An ENCODER
4671-/// a process-global (not a thread-local) because the tile writers run on4671+/// knob (like `speed::SPEED`), never read by a decode: read through a
4672+/// process-global (not a thread-local) because the tile writers run on
4672 /// worker threads; `2` is "the environment has not been read yet".4673 /// worker threads; `2` is "the environment has not been read yet".
4673-static SB128: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(2);4674+static ENC_SB128: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(2);
4674 4675
4675 /// Whether this process's sequences code 128x128 superblocks.4676 /// Whether this process's sequences code 128x128 superblocks.
4676 pub(crate) fn sb128_on() -> bool {4677 pub(crate) fn sb128_on() -> bool {
4677 use std::sync::atomic::Ordering::Relaxed;4678 use std::sync::atomic::Ordering::Relaxed;
4678- match SB128.load(Relaxed) {4679+ match ENC_SB128.load(Relaxed) {
4679 2 => {4680 2 => {
4680 let on = crate::envflags::var("EC_AV1_SB128").ok().is_some_and(|v| v != "0");4681 let on = crate::envflags::var("EC_AV1_SB128").ok().is_some_and(|v| v != "0");
4681- SB128.store(u8::from(on), Relaxed);4682+ ENC_SB128.store(u8::from(on), Relaxed);
4682 on4683 on
4683 }4684 }
4684 v => v == 1,4685 v => v == 1,
@@ -4690,7 +4691,7 @@ pub(crate) fn sb128_on() -> bool {
4690 /// exactly like the speed-preset gates.4691 /// exactly like the speed-preset gates.
4691 #[cfg(test)]4692 #[cfg(test)]
4692 pub(crate) fn force_sb128(on: bool) {4693 pub(crate) fn force_sb128(on: bool) {
4693- SB128.store(u8::from(on), std::sync::atomic::Ordering::Relaxed);4694+ ENC_SB128.store(u8::from(on), std::sync::atomic::Ordering::Relaxed);
4694 }4695 }
4695 4696
4696 /// The luma loop-restoration unit size this sequence codes: a 128 superblock4697 /// The luma loop-restoration unit size this sequence codes: a 128 superblock
@@ -6456,7 +6457,7 @@ fn clip_planes_to_tile(
6456 /// Returns an error under the same conditions6457 /// Returns an error under the same conditions
6457 /// [`encode_key_frame_with_modes`] does.6458 /// [`encode_key_frame_with_modes`] does.
6458 pub fn encode_key_frame(picture: &Picture, base_q_idx: u8, deadzone: f64) -> Result<Encoded> {6459 pub fn encode_key_frame(picture: &Picture, base_q_idx: u8, deadzone: f64) -> Result<Encoded> {
6459- encode_key_frame_with_ctx(picture, base_q_idx, deadzone, &crate::decode::FrameCtx::new())6460+ encode_key_frame_with_ctx(picture, base_q_idx, deadzone, &crate::decode::FrameCtx::for_encoder())
6460 }6461 }
6461 6462
6462 /// [`encode_key_frame`] with the per-block intra modes given rather than6463 /// [`encode_key_frame`] with the per-block intra modes given rather than
@@ -6476,7 +6477,7 @@ pub fn encode_key_frame_with_modes(
6476 base_q_idx,6477 base_q_idx,
6477 deadzone,6478 deadzone,
6478 modes,6479 modes,
6479- &crate::decode::FrameCtx::new(),6480+ &crate::decode::FrameCtx::for_encoder(),
6480 )6481 )
6481 }6482 }
6482 6483
@@ -6498,7 +6499,7 @@ pub fn encode_sequence(
6498 base_q_idx: u8,6499 base_q_idx: u8,
6499 deadzone: f64,6500 deadzone: f64,
6500 ) -> Result<EncodedSequence> {6501 ) -> Result<EncodedSequence> {
6501- encode_sequence_with_ctx(pictures, base_q_idx, deadzone, &crate::decode::FrameCtx::new())6502+ encode_sequence_with_ctx(pictures, base_q_idx, deadzone, &crate::decode::FrameCtx::for_encoder())
6502 }6503 }
6503 6504
6504 pub(crate) fn encode_key_frame_with_ctx(picture: &Picture, base_q_idx: u8, deadzone: f64, fctx: &crate::decode::FrameCtx) -> Result<Encoded> {6505 pub(crate) fn encode_key_frame_with_ctx(picture: &Picture, base_q_idx: u8, deadzone: f64, fctx: &crate::decode::FrameCtx) -> Result<Encoded> {
@@ -11171,7 +11172,7 @@ mod tests {
11171 /// (the horizontal shapes, which those partitions never produce).11172 /// (the horizontal shapes, which those partitions never produce).
11172 #[test]11173 #[test]
11173 fn every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock() {11174 fn every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock() {
11174- let fctx = &crate::decode::FrameCtx::new();11175+ let fctx = &crate::decode::FrameCtx::for_encoder();
11175 // (bw, bh, has_tr len, has_tr byte sum, has_bl len, has_bl byte sum).11176 // (bw, bh, has_tr len, has_tr byte sum, has_bl len, has_bl byte sum).
11176 const SHAPES: [(usize, usize, usize, u32, usize, u32); 14] = [11177 const SHAPES: [(usize, usize, usize, u32, usize, u32); 14] = [
11177 (4, 8, 64, 9280, 64, 550),11178 (4, 8, 64, 9280, 64, 550),
@@ -11345,7 +11346,7 @@ mod tests {
11345 #[test]11346 #[test]
11346 fn the_filter_search_picks_real_filters() {11347 fn the_filter_search_picks_real_filters() {
11347 let _knobs = crate::speed::knob_read();11348 let _knobs = crate::speed::knob_read();
11348- let fctx = &crate::decode::FrameCtx::new();11349+ let fctx = &crate::decode::FrameCtx::for_encoder();
11349 let pictures: Vec<_> = (0..3).map(|i| panned_test_card(128, 128, i * 3)).collect();11350 let pictures: Vec<_> = (0..3).map(|i| panned_test_card(128, 128, i * 3)).collect();
11350 let encoded = encode_sequence_with_ctx(&pictures, 120, 0.5, fctx).unwrap();11351 let encoded = encode_sequence_with_ctx(&pictures, 120, 0.5, fctx).unwrap();
11351 let fired = encoded11352 let fired = encoded
@@ -11426,7 +11427,7 @@ mod tests {
11426 #[test]11427 #[test]
11427 fn a_smooth_gradient_key_frame_codes_whole_superblocks_and_decodes_exactly() {11428 fn a_smooth_gradient_key_frame_codes_whole_superblocks_and_decodes_exactly() {
11428 let _knobs = crate::speed::knob_read();11429 let _knobs = crate::speed::knob_read();
11429- let fctx = &crate::decode::FrameCtx::new();11430+ let fctx = &crate::decode::FrameCtx::for_encoder();
11430 // 4 x 3 superblocks, all of them wholly inside the frame.11431 // 4 x 3 superblocks, all of them wholly inside the frame.
11431 let (width, height) = (256usize, 192usize);11432 let (width, height) = (256usize, 192usize);
11432 let mut picture = Picture::grey(width, height);11433 let mut picture = Picture::grey(width, height);
@@ -11484,7 +11485,7 @@ mod tests {
11484 #[test]11485 #[test]
11485 fn ffmpeg_decodes_exactly_what_the_encoder_reconstructed() {11486 fn ffmpeg_decodes_exactly_what_the_encoder_reconstructed() {
11486 let _knobs = crate::speed::knob_read();11487 let _knobs = crate::speed::knob_read();
11487- let fctx = &crate::decode::FrameCtx::new();11488+ let fctx = &crate::decode::FrameCtx::for_encoder();
11488 if !have_ffmpeg() {11489 if !have_ffmpeg() {
11489 eprintln!("SKIP ffmpeg_decodes_exactly_what_the_encoder_reconstructed: no ffmpeg");11490 eprintln!("SKIP ffmpeg_decodes_exactly_what_the_encoder_reconstructed: no ffmpeg");
11490 return;11491 return;
@@ -11566,7 +11567,7 @@ mod tests {
11566 #[test]11567 #[test]
11567 fn a_screen_content_picture_codes_palette_blocks_ffmpeg_decodes_exactly() {11568 fn a_screen_content_picture_codes_palette_blocks_ffmpeg_decodes_exactly() {
11568 let _knobs = crate::speed::knob_read();11569 let _knobs = crate::speed::knob_read();
11569- let fctx = &crate::decode::FrameCtx::new();11570+ let fctx = &crate::decode::FrameCtx::for_encoder();
11570 let (width, height) = (192usize, 96usize);11571 let (width, height) = (192usize, 96usize);
11571 let _ = crate::tile::take_palette_hits();11572 let _ = crate::tile::take_palette_hits();
11572 let picture = screen_card(width, height);11573 let picture = screen_card(width, height);
@@ -11677,7 +11678,7 @@ mod tests {
11677 #[ignore = "needs the real-library manifest and ffmpeg"]11678 #[ignore = "needs the real-library manifest and ffmpeg"]
11678 fn probe_intrabc_key_frame() {11679 fn probe_intrabc_key_frame() {
11679 let _knobs = crate::speed::knob_write();11680 let _knobs = crate::speed::knob_write();
11680- let fctx = &crate::decode::FrameCtx::new();11681+ let fctx = &crate::decode::FrameCtx::for_encoder();
11681 let fixtures = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))11682 let fixtures = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
11682 .join("../../fixtures");11683 .join("../../fixtures");
11683 let Ok(manifest) = std::fs::read_to_string(fixtures.join("real-library-manifest.tsv")) else {11684 let Ok(manifest) = std::fs::read_to_string(fixtures.join("real-library-manifest.tsv")) else {
@@ -11727,7 +11728,7 @@ mod tests {
11727 #[test]11728 #[test]
11728 fn a_repeated_pattern_key_frame_codes_intrabc_blocks_ffmpeg_decodes_exactly() {11729 fn a_repeated_pattern_key_frame_codes_intrabc_blocks_ffmpeg_decodes_exactly() {
11729 let _knobs = crate::speed::knob_write();11730 let _knobs = crate::speed::knob_write();
11730- let fctx = &crate::decode::FrameCtx::new();11731+ let fctx = &crate::decode::FrameCtx::for_encoder();
11731 // Wide enough for the wavefront rule (`INTRABC_DELAY_SB64` = 411732 // Wide enough for the wavefront rule (`INTRABC_DELAY_SB64` = 4
11732 // superblocks of 64) and tall enough for a source superblock row11733 // superblocks of 64) and tall enough for a source superblock row
11733 // above the blocks that copy from it.11734 // above the blocks that copy from it.
@@ -11786,7 +11787,7 @@ mod tests {
11786 #[test]11787 #[test]
11787 fn a_nearestmv_block_with_one_nonzero_coefficient_decodes_clean() {11788 fn a_nearestmv_block_with_one_nonzero_coefficient_decodes_clean() {
11788 let _knobs = crate::speed::knob_write();11789 let _knobs = crate::speed::knob_write();
11789- let fctx = &crate::decode::FrameCtx::new();11790+ let fctx = &crate::decode::FrameCtx::for_encoder();
11790 if !have_ffmpeg() {11791 if !have_ffmpeg() {
11791 eprintln!(11792 eprintln!(
11792 "SKIP a_nearestmv_block_with_one_nonzero_coefficient_decodes_clean: no ffmpeg"11793 "SKIP a_nearestmv_block_with_one_nonzero_coefficient_decodes_clean: no ffmpeg"
@@ -11921,7 +11922,7 @@ mod tests {
11921 #[test]11922 #[test]
11922 fn the_final_filter_replay_matches_the_capture_decode_at_odd_sizes() {11923 fn the_final_filter_replay_matches_the_capture_decode_at_odd_sizes() {
11923 let _knobs = crate::speed::knob_write();11924 let _knobs = crate::speed::knob_write();
11924- let fctx = &crate::decode::FrameCtx::new();11925+ let fctx = &crate::decode::FrameCtx::for_encoder();
11925 crate::decode::set_verify_final_replay(true);11926 crate::decode::set_verify_final_replay(true);
11926 for &(width, height) in11927 for &(width, height) in
11927 &[(64usize, 56usize), (216, 96), (192, 120), (640, 352), (1280, 720)]11928 &[(64usize, 56usize), (216, 96), (192, 120), (640, 352), (1280, 720)]
@@ -11950,7 +11951,7 @@ mod tests {
11950 #[test]11951 #[test]
11951 fn a_frame_round_trips_at_its_own_size() {11952 fn a_frame_round_trips_at_its_own_size() {
11952 let _knobs = crate::speed::knob_read();11953 let _knobs = crate::speed::knob_read();
11953- let fctx = &crate::decode::FrameCtx::new();11954+ let fctx = &crate::decode::FrameCtx::for_encoder();
11954 if !have_ffmpeg() {11955 if !have_ffmpeg() {
11955 eprintln!("SKIP a_frame_round_trips_at_its_own_size: no ffmpeg");11956 eprintln!("SKIP a_frame_round_trips_at_its_own_size: no ffmpeg");
11956 return;11957 return;
@@ -12017,7 +12018,7 @@ mod tests {
12017 #[test]12018 #[test]
12018 fn an_854x480_picture_round_trips_through_its_padding() {12019 fn an_854x480_picture_round_trips_through_its_padding() {
12019 let _knobs = crate::speed::knob_read();12020 let _knobs = crate::speed::knob_read();
12020- let fctx = &crate::decode::FrameCtx::new();12021+ let fctx = &crate::decode::FrameCtx::for_encoder();
12021 if !have_ffmpeg() {12022 if !have_ffmpeg() {
12022 return;12023 return;
12023 }12024 }
@@ -12048,7 +12049,7 @@ mod tests {
12048 /// (`has_tr_vert_8x8` bit 16 = 0, ordinary `has_tr_8x8` bit 16 = 1).12049 /// (`has_tr_vert_8x8` bit 16 = 0, ordinary `has_tr_8x8` bit 16 = 1).
12049 #[test]12050 #[test]
12050 fn of_tu_follows_the_block_row_including_under_vert_ab() {12051 fn of_tu_follows_the_block_row_including_under_vert_ab() {
12051- let fctx = &crate::decode::FrameCtx::new();12052+ let fctx = &crate::decode::FrameCtx::for_encoder();
12052 // The 8x8 square at superblock row 1, column 0, and the TX4 unit in12053 // The 8x8 square at superblock row 1, column 0, and the TX4 unit in
12053 // its top-right corner (`col_off = 4`, `row_off = 0`): that unit's12054 // its top-right corner (`col_off = 4`, `row_off = 0`): that unit's
12054 // above-right answer is the BLOCK's, which is the whole reason a unit12055 // above-right answer is the BLOCK's, which is the whole reason a unit
@@ -12083,7 +12084,7 @@ mod tests {
12083 /// wrong for one block size while looking plausible for the other.12084 /// wrong for one block size while looking plausible for the other.
12084 #[test]12085 #[test]
12085 fn reach_matches_libaom_has_top_right_and_has_bottom_left() {12086 fn reach_matches_libaom_has_top_right_and_has_bottom_left() {
12086- let fctx = &crate::decode::FrameCtx::new();12087+ let fctx = &crate::decode::FrameCtx::for_encoder();
12087 // Transcribed from has_top_right/has_bottom_left's row_off==0,12088 // Transcribed from has_top_right/has_bottom_left's row_off==0,
12088 // col_off==0 (whole-transform) path, with MAX_MIB_SIZE_LOG2 = 5 (a12089 // col_off==0 (whole-transform) path, with MAX_MIB_SIZE_LOG2 = 5 (a
12089 // 128px reference grid) pinned as libaom pins it, independent of the12090 // 128px reference grid) pinned as libaom pins it, independent of the
@@ -12228,7 +12229,7 @@ mod tests {
12228 12229
12229 #[test]12230 #[test]
12230 fn vert_ab_partition_flips_below_left_for_the_top_right_8x8() {12231 fn vert_ab_partition_flips_below_left_for_the_top_right_8x8() {
12231- let fctx = &crate::decode::FrameCtx::new();12232+ let fctx = &crate::decode::FrameCtx::for_encoder();
12232 let (width, height) = (SUPERBLOCK * 3, SUPERBLOCK * 3);12233 let (width, height) = (SUPERBLOCK * 3, SUPERBLOCK * 3);
12233 // Interior superblock, so neither the frame edge nor the col == 0 /12234 // Interior superblock, so neither the frame edge nor the col == 0 /
12234 // last-row early returns answer instead of the table.12235 // last-row early returns answer instead of the table.
@@ -12263,7 +12264,7 @@ mod tests {
12263 #[test]12264 #[test]
12264 fn odd_dimensions_are_refused() {12265 fn odd_dimensions_are_refused() {
12265 let _knobs = crate::speed::knob_read();12266 let _knobs = crate::speed::knob_read();
12266- let fctx = &crate::decode::FrameCtx::new();12267+ let fctx = &crate::decode::FrameCtx::for_encoder();
12267 for &(width, height) in &[(1921usize, 1080usize), (1920, 1081), (63, 63)] {12268 for &(width, height) in &[(1921usize, 1080usize), (1920, 1081), (63, 63)] {
12268 let picture = Picture::grey(width, height);12269 let picture = Picture::grey(width, height);
12269 let err = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx)12270 let err = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx)
@@ -12282,7 +12283,7 @@ mod tests {
12282 #[test]12283 #[test]
12283 fn sequence_round_trips_at_a_non_multiple_size() {12284 fn sequence_round_trips_at_a_non_multiple_size() {
12284 let _knobs = crate::speed::knob_read();12285 let _knobs = crate::speed::knob_read();
12285- let fctx = &crate::decode::FrameCtx::new();12286+ let fctx = &crate::decode::FrameCtx::for_encoder();
12286 if !have_ffmpeg() {12287 if !have_ffmpeg() {
12287 eprintln!("SKIP sequence_round_trips_at_a_non_multiple_size: no ffmpeg");12288 eprintln!("SKIP sequence_round_trips_at_a_non_multiple_size: no ffmpeg");
12288 return;12289 return;
@@ -12326,7 +12327,7 @@ mod tests {
12326 #[test]12327 #[test]
12327 fn a_sequence_round_trips_at_the_exactly_half_straddle_size() {12328 fn a_sequence_round_trips_at_the_exactly_half_straddle_size() {
12328 let _knobs = crate::speed::knob_read();12329 let _knobs = crate::speed::knob_read();
12329- let fctx = &crate::decode::FrameCtx::new();12330+ let fctx = &crate::decode::FrameCtx::for_encoder();
12330 if !have_ffmpeg() {12331 if !have_ffmpeg() {
12331 eprintln!("SKIP a_sequence_round_trips_at_the_exactly_half_straddle_size: no ffmpeg");12332 eprintln!("SKIP a_sequence_round_trips_at_the_exactly_half_straddle_size: no ffmpeg");
12332 return;12333 return;
@@ -12372,7 +12373,7 @@ mod tests {
12372 #[test]12373 #[test]
12373 fn key_frame_and_inter_frame_both_encode_at_half_straddle_size() {12374 fn key_frame_and_inter_frame_both_encode_at_half_straddle_size() {
12374 let _knobs = crate::speed::knob_read();12375 let _knobs = crate::speed::knob_read();
12375- let fctx = &crate::decode::FrameCtx::new();12376+ let fctx = &crate::decode::FrameCtx::for_encoder();
12376 let (width, height) = (640usize, 360usize);12377 let (width, height) = (640usize, 360usize);
12377 let picture = Picture::grey(width, height);12378 let picture = Picture::grey(width, height);
12378 encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).expect("key frame now codes the mod-32==8 straddle");12379 encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).expect("key frame now codes the mod-32==8 straddle");
@@ -12392,7 +12393,7 @@ mod tests {
12392 #[test]12393 #[test]
12393 fn a_640x360_half_straddle_round_trips_through_ffmpeg_across_three_frames() {12394 fn a_640x360_half_straddle_round_trips_through_ffmpeg_across_three_frames() {
12394 let _knobs = crate::speed::knob_read();12395 let _knobs = crate::speed::knob_read();
12395- let fctx = &crate::decode::FrameCtx::new();12396+ let fctx = &crate::decode::FrameCtx::for_encoder();
12396 if !have_ffmpeg() {12397 if !have_ffmpeg() {
12397 eprintln!(12398 eprintln!(
12398 "SKIP a_640x360_half_straddle_round_trips_through_ffmpeg_across_three_frames: \12399 "SKIP a_640x360_half_straddle_round_trips_through_ffmpeg_across_three_frames: \
@@ -12418,7 +12419,7 @@ mod tests {
12418 #[test]12419 #[test]
12419 fn a_640x360_half_straddle_sequence_round_trips_through_ffmpeg() {12420 fn a_640x360_half_straddle_sequence_round_trips_through_ffmpeg() {
12420 let _knobs = crate::speed::knob_read();12421 let _knobs = crate::speed::knob_read();
12421- let fctx = &crate::decode::FrameCtx::new();12422+ let fctx = &crate::decode::FrameCtx::for_encoder();
12422 if !have_ffmpeg() {12423 if !have_ffmpeg() {
12423 eprintln!(12424 eprintln!(
12424 "SKIP a_640x360_half_straddle_sequence_round_trips_through_ffmpeg: no ffmpeg"12425 "SKIP a_640x360_half_straddle_sequence_round_trips_through_ffmpeg: no ffmpeg"
@@ -12478,7 +12479,7 @@ mod tests {
12478 #[ignore = "a sweep, not a gate"]12479 #[ignore = "a sweep, not a gate"]
12479 fn probe_lambda() {12480 fn probe_lambda() {
12480 let _knobs = crate::speed::knob_read();12481 let _knobs = crate::speed::knob_read();
12481- let fctx = &crate::decode::FrameCtx::new();12482+ let fctx = &crate::decode::FrameCtx::for_encoder();
12482 let mut pictures = vec![12483 let mut pictures = vec![
12483 ("test card".to_string(), test_card(160, 96)),12484 ("test card".to_string(), test_card(160, 96)),
12484 ("stripes".to_string(), stripes(160, 96, true)),12485 ("stripes".to_string(), stripes(160, 96, true)),
@@ -12510,7 +12511,7 @@ mod tests {
12510 #[ignore = "a sweep, not a gate"]12511 #[ignore = "a sweep, not a gate"]
12511 fn probe_ladder() {12512 fn probe_ladder() {
12512 let _knobs = crate::speed::knob_read();12513 let _knobs = crate::speed::knob_read();
12513- let fctx = &crate::decode::FrameCtx::new();12514+ let fctx = &crate::decode::FrameCtx::for_encoder();
12514 for (name, picture) in sweep_pictures() {12515 for (name, picture) in sweep_pictures() {
12515 let all = ladder(&picture, &KEY_FRAME_MODES, fctx);12516 let all = ladder(&picture, &KEY_FRAME_MODES, fctx);
12516 let points = all12517 let points = all
@@ -12529,7 +12530,7 @@ mod tests {
12529 #[ignore = "a sweep, not a gate"]12530 #[ignore = "a sweep, not a gate"]
12530 fn probe_split() {12531 fn probe_split() {
12531 let _knobs = crate::speed::knob_read();12532 let _knobs = crate::speed::knob_read();
12532- let fctx = &crate::decode::FrameCtx::new();12533+ let fctx = &crate::decode::FrameCtx::for_encoder();
12533 for (name, picture) in sweep_pictures() {12534 for (name, picture) in sweep_pictures() {
12534 let ladder = |split: bool| {12535 let ladder = |split: bool| {
12535 let mut points: Vec<(f64, f64)> = [110u8, 90, 70]12536 let mut points: Vec<(f64, f64)> = [110u8, 90, 70]
@@ -12611,7 +12612,7 @@ mod tests {
12611 #[test]12612 #[test]
12612 fn every_mode_decodes_to_what_the_encoder_predicted() {12613 fn every_mode_decodes_to_what_the_encoder_predicted() {
12613 let _knobs = crate::speed::knob_write();12614 let _knobs = crate::speed::knob_write();
12614- let fctx = &crate::decode::FrameCtx::new();12615+ let fctx = &crate::decode::FrameCtx::for_encoder();
12615 if !have_ffmpeg() {12616 if !have_ffmpeg() {
12616 eprintln!("SKIP every_mode_decodes_to_what_the_encoder_predicted: no ffmpeg");12617 eprintln!("SKIP every_mode_decodes_to_what_the_encoder_predicted: no ffmpeg");
12617 return;12618 return;
@@ -12655,7 +12656,7 @@ mod tests {
12655 #[test]12656 #[test]
12656 fn the_search_picks_the_direction_the_picture_runs() {12657 fn the_search_picks_the_direction_the_picture_runs() {
12657 let _knobs = crate::speed::knob_write();12658 let _knobs = crate::speed::knob_write();
12658- let fctx = &crate::decode::FrameCtx::new();12659+ let fctx = &crate::decode::FrameCtx::for_encoder();
12659 // Same confound as [`every_mode_decodes_to_what_the_encoder_predicted`]:12660 // Same confound as [`every_mode_decodes_to_what_the_encoder_predicted`]:
12660 // a filter-intra block is coded `DC_PRED` whatever mode the arm12661 // a filter-intra block is coded `DC_PRED` whatever mode the arm
12661 // offers, and these stripes are SCREEN content, where the filter arm12662 // offers, and these stripes are SCREEN content, where the filter arm
@@ -12763,7 +12764,7 @@ mod tests {
12763 #[test]12764 #[test]
12764 fn the_search_beats_dc_alone() {12765 fn the_search_beats_dc_alone() {
12765 let _knobs = crate::speed::knob_read();12766 let _knobs = crate::speed::knob_read();
12766- let fctx = &crate::decode::FrameCtx::new();12767+ let fctx = &crate::decode::FrameCtx::for_encoder();
12767 for (name, picture, want) in [12768 for (name, picture, want) in [
12768 ("test card", test_card(160, 96), -0.05),12769 ("test card", test_card(160, 96), -0.05),
12769 ("stripes", stripes(160, 96, true), -0.40),12770 ("stripes", stripes(160, 96, true), -0.40),
@@ -12806,7 +12807,7 @@ mod tests {
12806 #[ignore = "a sweep, not a gate"]12807 #[ignore = "a sweep, not a gate"]
12807 fn probe_directional() {12808 fn probe_directional() {
12808 let _knobs = crate::speed::knob_write();12809 let _knobs = crate::speed::knob_write();
12809- let fctx = &crate::decode::FrameCtx::new();12810+ let fctx = &crate::decode::FrameCtx::for_encoder();
12810 for (name, picture) in sweep_pictures() {12811 for (name, picture) in sweep_pictures() {
12811 let dc = ladder(&picture, &[DC_PRED], fctx);12812 let dc = ladder(&picture, &[DC_PRED], fctx);
12812 let flat = ladder(&picture, &NON_DIRECTIONAL, fctx);12813 let flat = ladder(&picture, &NON_DIRECTIONAL, fctx);
@@ -12881,7 +12882,7 @@ mod tests {
12881 #[test]12882 #[test]
12882 fn the_search_picks_the_diagonal_the_picture_runs() {12883 fn the_search_picks_the_diagonal_the_picture_runs() {
12883 let _knobs = crate::speed::knob_write();12884 let _knobs = crate::speed::knob_write();
12884- let fctx = &crate::decode::FrameCtx::new();12885+ let fctx = &crate::decode::FrameCtx::for_encoder();
12885 for (down_right, want) in [(true, D135_PRED), (false, D45_PRED)] {12886 for (down_right, want) in [(true, D135_PRED), (false, D45_PRED)] {
12886 let picture = diagonal(160, 96, down_right);12887 let picture = diagonal(160, 96, down_right);
12887 let (mode, count, blocks) = favourite_mode(&picture, fctx);12888 let (mode, count, blocks) = favourite_mode(&picture, fctx);
@@ -12901,7 +12902,7 @@ mod tests {
12901 #[test]12902 #[test]
12902 fn the_diagonals_beat_the_modes_that_read_no_further() {12903 fn the_diagonals_beat_the_modes_that_read_no_further() {
12903 let _knobs = crate::speed::knob_read();12904 let _knobs = crate::speed::knob_read();
12904- let fctx = &crate::decode::FrameCtx::new();12905+ let fctx = &crate::decode::FrameCtx::for_encoder();
12905 for (name, picture, want) in [12906 for (name, picture, want) in [
12906 ("down-right", diagonal(160, 96, true), -0.20),12907 ("down-right", diagonal(160, 96, true), -0.20),
12907 ("down-left", diagonal(160, 96, false), -0.20),12908 ("down-left", diagonal(160, 96, false), -0.20),
@@ -12925,7 +12926,7 @@ mod tests {
12925 #[test]12926 #[test]
12926 fn a_mode_the_encoder_cannot_predict_is_refused() {12927 fn a_mode_the_encoder_cannot_predict_is_refused() {
12927 let _knobs = crate::speed::knob_read();12928 let _knobs = crate::speed::knob_read();
12928- let fctx = &crate::decode::FrameCtx::new();12929+ let fctx = &crate::decode::FrameCtx::for_encoder();
12929 let picture = test_card(64, 64);12930 let picture = test_card(64, 64);
12930 let message = encode_key_frame_with_modes_with_ctx(&picture, 100, 0.5, &[13], fctx)12931 let message = encode_key_frame_with_modes_with_ctx(&picture, 100, 0.5, &[13], fctx)
12931 .unwrap_err()12932 .unwrap_err()
@@ -12945,7 +12946,7 @@ mod tests {
12945 #[test]12946 #[test]
12946 fn the_encoded_picture_is_the_one_that_went_in() {12947 fn the_encoded_picture_is_the_one_that_went_in() {
12947 let _knobs = crate::speed::knob_read();12948 let _knobs = crate::speed::knob_read();
12948- let fctx = &crate::decode::FrameCtx::new();12949+ let fctx = &crate::decode::FrameCtx::for_encoder();
12949 let picture = test_card(160, 96);12950 let picture = test_card(160, 96);
12950 let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap();12951 let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap();
12951 let luma = psnr(&encoded.reconstruction.y, &picture.y);12952 let luma = psnr(&encoded.reconstruction.y, &picture.y);
@@ -12968,7 +12969,7 @@ mod tests {
12968 #[test]12969 #[test]
12969 fn fidelity_and_rate_move_with_the_quantizer() {12970 fn fidelity_and_rate_move_with_the_quantizer() {
12970 let _knobs = crate::speed::knob_read();12971 let _knobs = crate::speed::knob_read();
12971- let fctx = &crate::decode::FrameCtx::new();12972+ let fctx = &crate::decode::FrameCtx::for_encoder();
12972 let picture = test_card(128, 128);12973 let picture = test_card(128, 128);
12973 let mut previous: Option<(usize, f64)> = None;12974 let mut previous: Option<(usize, f64)> = None;
12974 for &q in &[70u8, 90, 110] {12975 for &q in &[70u8, 90, 110] {
@@ -13029,7 +13030,7 @@ mod tests {
13029 #[test]13030 #[test]
13030 fn a_flat_picture_costs_almost_nothing() {13031 fn a_flat_picture_costs_almost_nothing() {
13031 let _knobs = crate::speed::knob_read();13032 let _knobs = crate::speed::knob_read();
13032- let fctx = &crate::decode::FrameCtx::new();13033+ let fctx = &crate::decode::FrameCtx::for_encoder();
13033 let mut picture = Picture::grey(128, 128);13034 let mut picture = Picture::grey(128, 128);
13034 picture.y.fill(97);13035 picture.y.fill(97);
13035 let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap();13036 let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap();
@@ -13066,7 +13067,7 @@ mod tests {
13066 #[test]13067 #[test]
13067 fn a_picture_off_the_block_grid_encodes_and_a_malformed_one_is_refused() {13068 fn a_picture_off_the_block_grid_encodes_and_a_malformed_one_is_refused() {
13068 let _knobs = crate::speed::knob_read();13069 let _knobs = crate::speed::knob_read();
13069- let fctx = &crate::decode::FrameCtx::new();13070+ let fctx = &crate::decode::FrameCtx::for_encoder();
13070 encode_key_frame_with_ctx(&Picture::grey(40, 40), 100, 0.5, fctx)13071 encode_key_frame_with_ctx(&Picture::grey(40, 40), 100, 0.5, fctx)
13071 .expect("40x40 cuts a 16x16 leaf on both axes, which is an inferred split");13072 .expect("40x40 cuts a 16x16 leaf on both axes, which is an inferred split");
13072 encode_key_frame_with_ctx(&Picture::grey(36, 40), 100, 0.5, fctx)13073 encode_key_frame_with_ctx(&Picture::grey(36, 40), 100, 0.5, fctx)
@@ -13150,7 +13151,7 @@ mod tests {
13150 #[test]13151 #[test]
13151 fn a_single_axis_straddle_round_trips_through_ffmpeg() {13152 fn a_single_axis_straddle_round_trips_through_ffmpeg() {
13152 let _knobs = crate::speed::knob_read();13153 let _knobs = crate::speed::knob_read();
13153- let fctx = &crate::decode::FrameCtx::new();13154+ let fctx = &crate::decode::FrameCtx::for_encoder();
13154 if !have_ffmpeg() {13155 if !have_ffmpeg() {
13155 eprintln!("SKIP a_single_axis_straddle_round_trips_through_ffmpeg: no ffmpeg");13156 eprintln!("SKIP a_single_axis_straddle_round_trips_through_ffmpeg: no ffmpeg");
13156 return;13157 return;
@@ -13180,7 +13181,7 @@ mod tests {
13180 #[test]13181 #[test]
13181 fn a_frame_of_real_video_decodes_to_what_the_encoder_reconstructed() {13182 fn a_frame_of_real_video_decodes_to_what_the_encoder_reconstructed() {
13182 let _knobs = crate::speed::knob_read();13183 let _knobs = crate::speed::knob_read();
13183- let fctx = &crate::decode::FrameCtx::new();13184+ let fctx = &crate::decode::FrameCtx::for_encoder();
13184 let Ok(clip) = std::env::var("EC_AV1_CLIP") else {13185 let Ok(clip) = std::env::var("EC_AV1_CLIP") else {
13185 eprintln!(13186 eprintln!(
13186 "SKIP a_frame_of_real_video_decodes_to_what_the_encoder_reconstructed: \13187 "SKIP a_frame_of_real_video_decodes_to_what_the_encoder_reconstructed: \
@@ -13312,7 +13313,7 @@ mod tests {
13312 #[test]13313 #[test]
13313 fn every_frame_of_a_sequence_decodes_to_what_the_encoder_reconstructed() {13314 fn every_frame_of_a_sequence_decodes_to_what_the_encoder_reconstructed() {
13314 let _knobs = crate::speed::knob_read();13315 let _knobs = crate::speed::knob_read();
13315- let fctx = &crate::decode::FrameCtx::new();13316+ let fctx = &crate::decode::FrameCtx::for_encoder();
13316 if !have_ffmpeg() {13317 if !have_ffmpeg() {
13317 eprintln!(13318 eprintln!(
13318 "SKIP every_frame_of_a_sequence_decodes_to_what_the_encoder_reconstructed: no ffmpeg"13319 "SKIP every_frame_of_a_sequence_decodes_to_what_the_encoder_reconstructed: no ffmpeg"
@@ -13354,7 +13355,7 @@ mod tests {
13354 #[test]13355 #[test]
13355 fn every_frame_of_a_sequence_decodes_through_our_own_decoder() {13356 fn every_frame_of_a_sequence_decodes_through_our_own_decoder() {
13356 let _knobs = crate::speed::knob_read();13357 let _knobs = crate::speed::knob_read();
13357- let fctx = &crate::decode::FrameCtx::new();13358+ let fctx = &crate::decode::FrameCtx::for_encoder();
13358 // 256x128, not the 128x64 this started at: once a leaf could search13359 // 256x128, not the 128x64 this started at: once a leaf could search
13359 // its second reference (lane-av1comp4) the small card's every13360 // its second reference (lane-av1comp4) the small card's every
13360 // eligible block went to a compound winner, which commits its flat13361 // eligible block went to a compound winner, which commits its flat
@@ -13420,7 +13421,7 @@ mod tests {
13420 #[test]13421 #[test]
13421 fn predicted_coeff_bits_track_the_tile_the_writer_wrote() {13422 fn predicted_coeff_bits_track_the_tile_the_writer_wrote() {
13422 let _knobs = crate::speed::knob_read();13423 let _knobs = crate::speed::knob_read();
13423- let fctx = &crate::decode::FrameCtx::new();13424+ let fctx = &crate::decode::FrameCtx::for_encoder();
13424 let (width, height) = (256usize, 128usize);13425 let (width, height) = (256usize, 128usize);
13425 let pictures: Vec<Picture> = (0..5)13426 let pictures: Vec<Picture> = (0..5)
13426 .map(|i| panned_test_card(width, height, i * 2))13427 .map(|i| panned_test_card(width, height, i * 2))
@@ -13525,7 +13526,7 @@ mod tests {
13525 #[test]13526 #[test]
13526 fn pricer_error_census_by_block_class() {13527 fn pricer_error_census_by_block_class() {
13527 let _knobs = crate::speed::knob_read();13528 let _knobs = crate::speed::knob_read();
13528- let fctx = &crate::decode::FrameCtx::new();13529+ let fctx = &crate::decode::FrameCtx::for_encoder();
13529 let (width, height) = (256usize, 128usize);13530 let (width, height) = (256usize, 128usize);
13530 let pictures: Vec<Picture> = (0..5)13531 let pictures: Vec<Picture> = (0..5)
13531 .map(|i| panned_test_card(width, height, i * 2))13532 .map(|i| panned_test_card(width, height, i * 2))
@@ -13598,7 +13599,7 @@ mod tests {
13598 assert!(!clips.is_empty(), "no source clip available");13599 assert!(!clips.is_empty(), "no source clip available");
13599 let (width, height, frames) = (640usize, 384usize, 6usize);13600 let (width, height, frames) = (640usize, 384usize, 6usize);
13600 for (name, path) in &clips {13601 for (name, path) in &clips {
13601- let fctx = &crate::decode::FrameCtx::new();13602+ let fctx = &crate::decode::FrameCtx::for_encoder();
13602 let source = clip_frames(path.to_str().unwrap(), "0", width, height, frames);13603 let source = clip_frames(path.to_str().unwrap(), "0", width, height, frames);
13603 SCREEN_FRAMES.iter().for_each(|c| {13604 SCREEN_FRAMES.iter().for_each(|c| {
13604 c.store(0, std::sync::atomic::Ordering::Relaxed);13605 c.store(0, std::sync::atomic::Ordering::Relaxed);
@@ -13644,7 +13645,7 @@ mod tests {
13644 #[test]13645 #[test]
13645 fn low_motion_makes_an_inter_frame_smaller_than_the_key_frame() {13646 fn low_motion_makes_an_inter_frame_smaller_than_the_key_frame() {
13646 let _knobs = crate::speed::knob_read();13647 let _knobs = crate::speed::knob_read();
13647- let fctx = &crate::decode::FrameCtx::new();13648+ let fctx = &crate::decode::FrameCtx::for_encoder();
13648 let (width, height) = (256usize, 128usize);13649 let (width, height) = (256usize, 128usize);
13649 let pictures: Vec<Picture> = (0..5)13650 let pictures: Vec<Picture> = (0..5)
13650 .map(|i| panned_test_card(width, height, i * 2))13651 .map(|i| panned_test_card(width, height, i * 2))
@@ -13682,7 +13683,7 @@ mod tests {
13682 #[ignore = "a perf probe, not a gate"]13683 #[ignore = "a perf probe, not a gate"]
13683 fn stage_timing_breakdown() {13684 fn stage_timing_breakdown() {
13684 let _knobs = crate::speed::knob_read();13685 let _knobs = crate::speed::knob_read();
13685- let fctx = &crate::decode::FrameCtx::new();13686+ let fctx = &crate::decode::FrameCtx::for_encoder();
13686 use std::time::Instant;13687 use std::time::Instant;
13687 13688
13688 for &(width, height) in &[(1920usize, 1080usize), (3840, 2160)] {13689 for &(width, height) in &[(1920usize, 1080usize), (3840, 2160)] {
@@ -13805,7 +13806,7 @@ mod tests {
13805 #[ignore = "a perf probe, not a gate"]13806 #[ignore = "a perf probe, not a gate"]
13806 fn stage_timing_breakdown_inter() {13807 fn stage_timing_breakdown_inter() {
13807 let _knobs = crate::speed::knob_read();13808 let _knobs = crate::speed::knob_read();
13808- let fctx = &crate::decode::FrameCtx::new();13809+ let fctx = &crate::decode::FrameCtx::for_encoder();
13809 use std::time::Instant;13810 use std::time::Instant;
13810 13811
13811 let (width, height) = (1280usize, 720);13812 let (width, height) = (1280usize, 720);
@@ -13854,7 +13855,7 @@ mod tests {
13854 #[ignore = "needs real clips and ffmpeg; prints numbers for the lane report to judge"]13855 #[ignore = "needs real clips and ffmpeg; prints numbers for the lane report to judge"]
13855 fn prune_k_quality_sweep() {13856 fn prune_k_quality_sweep() {
13856 let _knobs = crate::speed::knob_read();13857 let _knobs = crate::speed::knob_read();
13857- let fctx = &crate::decode::FrameCtx::new();13858+ let fctx = &crate::decode::FrameCtx::for_encoder();
13858 if !have_ffmpeg() {13859 if !have_ffmpeg() {
13859 eprintln!("SKIP prune_k_quality_sweep: no ffmpeg");13860 eprintln!("SKIP prune_k_quality_sweep: no ffmpeg");
13860 return;13861 return;
@@ -13955,7 +13956,7 @@ mod tests {
13955 #[ignore = "needs real clips and ffmpeg; prints numbers for the lane report to judge"]13956 #[ignore = "needs real clips and ffmpeg; prints numbers for the lane report to judge"]
13956 fn prune_k_quality_sweep_inter() {13957 fn prune_k_quality_sweep_inter() {
13957 let _knobs = crate::speed::knob_read();13958 let _knobs = crate::speed::knob_read();
13958- let fctx = &crate::decode::FrameCtx::new();13959+ let fctx = &crate::decode::FrameCtx::for_encoder();
13959 if !have_ffmpeg() {13960 if !have_ffmpeg() {
13960 eprintln!("SKIP prune_k_quality_sweep_inter: no ffmpeg");13961 eprintln!("SKIP prune_k_quality_sweep_inter: no ffmpeg");
13961 return;13962 return;
@@ -14085,7 +14086,7 @@ mod tests {
14085 #[test]14086 #[test]
14086 fn real_clip_encodes_within_its_quality_and_size_budget() {14087 fn real_clip_encodes_within_its_quality_and_size_budget() {
14087 let _knobs = crate::speed::knob_read();14088 let _knobs = crate::speed::knob_read();
14088- let fctx = &crate::decode::FrameCtx::new();14089+ let fctx = &crate::decode::FrameCtx::for_encoder();
14089 if !have_ffmpeg() {14090 if !have_ffmpeg() {
14090 eprintln!("SKIP real_clip_encodes_within_its_quality_and_size_budget: no ffmpeg");14091 eprintln!("SKIP real_clip_encodes_within_its_quality_and_size_budget: no ffmpeg");
14091 return;14092 return;
@@ -14147,7 +14148,7 @@ mod tests {
14147 #[test]14148 #[test]
14148 fn real_clip_encodes_within_its_quality_and_size_budget_at_a_straddle_size() {14149 fn real_clip_encodes_within_its_quality_and_size_budget_at_a_straddle_size() {
14149 let _knobs = crate::speed::knob_read();14150 let _knobs = crate::speed::knob_read();
14150- let fctx = &crate::decode::FrameCtx::new();14151+ let fctx = &crate::decode::FrameCtx::for_encoder();
14151 if !have_ffmpeg() {14152 if !have_ffmpeg() {
14152 eprintln!(14153 eprintln!(
14153 "SKIP real_clip_encodes_within_its_quality_and_size_budget_at_a_straddle_size: \14154 "SKIP real_clip_encodes_within_its_quality_and_size_budget_at_a_straddle_size: \
@@ -14205,7 +14206,7 @@ mod tests {
14205 #[ignore = "a perf probe, not a gate"]14206 #[ignore = "a perf probe, not a gate"]
14206 fn sequence_bench_sanity() {14207 fn sequence_bench_sanity() {
14207 let _knobs = crate::speed::knob_read();14208 let _knobs = crate::speed::knob_read();
14208- let fctx = &crate::decode::FrameCtx::new();14209+ let fctx = &crate::decode::FrameCtx::for_encoder();
14209 use std::time::Instant;14210 use std::time::Instant;
14210 let (width, height) = (1280usize, 720usize);14211 let (width, height) = (1280usize, 720usize);
14211 let pictures: Vec<Picture> = (0..24)14212 let pictures: Vec<Picture> = (0..24)
@@ -14229,7 +14230,7 @@ mod tests {
14229 #[ignore = "a calibration probe, not a gate"]14230 #[ignore = "a calibration probe, not a gate"]
14230 fn calibration_sweep_base_q_idx() {14231 fn calibration_sweep_base_q_idx() {
14231 let _knobs = crate::speed::knob_read();14232 let _knobs = crate::speed::knob_read();
14232- let fctx = &crate::decode::FrameCtx::new();14233+ let fctx = &crate::decode::FrameCtx::for_encoder();
14233 if !have_ffmpeg() {14234 if !have_ffmpeg() {
14234 eprintln!("SKIP calibration_sweep_base_q_idx: no ffmpeg");14235 eprintln!("SKIP calibration_sweep_base_q_idx: no ffmpeg");
14235 return;14236 return;
@@ -15216,7 +15217,7 @@ mod tests {
15216 println!("| clip | ours PSNR/bytes per point | BD-rate vs libaom | BD-rate vs rav1e | wall ours:libaom:rav1e |");15217 println!("| clip | ours PSNR/bytes per point | BD-rate vs libaom | BD-rate vs rav1e | wall ours:libaom:rav1e |");
15217 println!("|---|---|---|---|---|");15218 println!("|---|---|---|---|---|");
15218 for (name, path) in &clips {15219 for (name, path) in &clips {
15219- let fctx = &crate::decode::FrameCtx::new();15220+ let fctx = &crate::decode::FrameCtx::for_encoder();
15220 let source = clip_frames(path.to_str().unwrap(), "0", width, height, frames);15221 let source = clip_frames(path.to_str().unwrap(), "0", width, height, frames);
15221 let _ = take_partition_hits();15222 let _ = take_partition_hits();
15222 let _ = crate::tile::take_palette_hits();15223 let _ = crate::tile::take_palette_hits();
@@ -15849,7 +15850,7 @@ mod tests {
15849 println!("| clip | ours PSNR/bytes per point | BD-rate vs libaom | BD-rate vs rav1e | wall ours:libaom:rav1e (noisy) |");15850 println!("| clip | ours PSNR/bytes per point | BD-rate vs libaom | BD-rate vs rav1e | wall ours:libaom:rav1e (noisy) |");
15850 println!("|---|---|---|---|---|");15851 println!("|---|---|---|---|---|");
15851 for (name, path, seek) in &clips {15852 for (name, path, seek) in &clips {
15852- let fctx = &crate::decode::FrameCtx::new();15853+ let fctx = &crate::decode::FrameCtx::for_encoder();
15853 if probe_dims(path).is_none() {15854 if probe_dims(path).is_none() {
15854 eprintln!("SKIP {name}: ffprobe gave no size");15855 eprintln!("SKIP {name}: ffprobe gave no size");
15855 continue;15856 continue;
@@ -16118,7 +16119,7 @@ mod tests {
16118 "the probe's source differs from the gate's at the same window"16119 "the probe's source differs from the gate's at the same window"
16119 );16120 );
16120 let bytes = |src: &[Picture]| {16121 let bytes = |src: &[Picture]| {
16121- encode_sequence_with_ctx(src, q, 0.5, &crate::decode::FrameCtx::new())16122+ encode_sequence_with_ctx(src, q, 0.5, &crate::decode::FrameCtx::for_encoder())
16122 .unwrap()16123 .unwrap()
16123 .stream16124 .stream
16124 };16125 };
@@ -16152,7 +16153,7 @@ mod tests {
16152 let frames: usize = g("EC_PARITY_FRAMES").parse().unwrap();16153 let frames: usize = g("EC_PARITY_FRAMES").parse().unwrap();
16153 let q: u8 = g("EC_PARITY_Q").parse().unwrap();16154 let q: u8 = g("EC_PARITY_Q").parse().unwrap();
16154 let source = clip_frames_vf(&g("EC_PARITY_CLIP"), &g("EC_PARITY_SS"), &g("EC_PARITY_VF"), w, h, frames);16155 let source = clip_frames_vf(&g("EC_PARITY_CLIP"), &g("EC_PARITY_SS"), &g("EC_PARITY_VF"), w, h, frames);
16155- let fctx = &crate::decode::FrameCtx::new();16156+ let fctx = &crate::decode::FrameCtx::for_encoder();
16156 let e = encode_sequence_with_ctx(&source, q, 0.5, fctx).unwrap();16157 let e = encode_sequence_with_ctx(&source, q, 0.5, fctx).unwrap();
16157 let mut hash: u64 = 0xcbf2_9ce4_8422_2325;16158 let mut hash: u64 = 0xcbf2_9ce4_8422_2325;
16158 for &b in &e.stream {16159 for &b in &e.stream {
crates/ec-av1/src/encoder.rsmodified+1 -1
@@ -1191,7 +1191,7 @@ impl Av1Encoder {
1191 reference: None,1191 reference: None,
1192 next_index: 0,1192 next_index: 0,
1193 rate_loop: None,1193 rate_loop: None,
1194- fctx: crate::decode::FrameCtx::new(),1194+ fctx: crate::decode::FrameCtx::for_encoder(),
1195 pyramid: None,1195 pyramid: None,
1196 dpb: [const { None }; 8],1196 dpb: [const { None }; 8],
1197 pending: Vec::new(),1197 pending: Vec::new(),