Reduced_tx_set=0 -- the wider tx_type alphabets, off by default
Browse files at this commite6bf93689cf89d64ead6d5939e6a42ad88755d7eParent: c29f173- feat
- reduced_tx_set=0 -- the wider tx_type alphabets, off by default
3 changed files +170 -17
- crates/ec-av1/src/cdf_state.rs +39 -0
- crates/ec-av1/src/encode.rs +122 -17
- crates/ec-av1/src/speed.rs +9 -0
crates/ec-av1/src/cdf_state.rsmodified+39 -0
| @@ -318,11 +318,48 @@ impl TxbSet { | |||
| 318 | | Self::ChromaRect32x16 | 318 | | Self::ChromaRect32x16 |
| 319 | ) | 319 | ) |
| 320 | } | 320 | } |
| 321 | + | ||
| 322 | + /// lane-txi: this set's `reduced_tx_set == 0` counterpart -- the WIDER | ||
| 323 | + /// `tx_type` alphabet the same coefficient tables are read with when the | ||
| 324 | + /// frame header's bit is off. Every pair here is the one | ||
| 325 | + /// `decode::txbset_for`/`txbset_for_inter`/`inter_txbset_for` resolve off | ||
| 326 | + /// that bit, transcribed from the DECODER's own map so writer and reader | ||
| 327 | + /// cannot drift (class `table-and-reader-move-together`); a set with no | ||
| 328 | + /// counterpart -- intra 16x16 and 32x32, inter 32x32, 64x64, every | ||
| 329 | + /// chroma set -- is its own, and widening an already-wide set is the | ||
| 330 | + /// identity. | ||
| 331 | + pub(crate) fn wide(self) -> Self { | ||
| 332 | + match self { | ||
| 333 | + Self::Luma8 => Self::Luma8Set1, | ||
| 334 | + Self::Luma4 => Self::Luma4Set1, | ||
| 335 | + Self::Luma16Inter => Self::Luma16InterSet1, | ||
| 336 | + Self::Luma8Inter => Self::Luma8InterSet1, | ||
| 337 | + Self::Luma4Inter => Self::Luma4InterSet1, | ||
| 338 | + Self::LumaRect16x8 => Self::LumaRect16x8Set1, | ||
| 339 | + Self::LumaRect4x8 => Self::LumaRect4x8Set1, | ||
| 340 | + Self::LumaRect16x4 => Self::LumaRect16x4Set1, | ||
| 341 | + Self::LumaRect16x8Inter => Self::LumaRect16x8InterSet1, | ||
| 342 | + Self::LumaRect8x4Inter => Self::LumaRect8x4InterSet1, | ||
| 343 | + Self::LumaRect16x4Inter => Self::LumaRect16x4Inter1, | ||
| 344 | + other => other, | ||
| 345 | + } | ||
| 346 | + } | ||
| 321 | } | 347 | } |
| 322 | 348 | ||
| 323 | /// Every table a key frame's tile writer adapts. | 349 | /// Every table a key frame's tile writer adapts. |
| 324 | #[derive(Clone)] | 350 | #[derive(Clone)] |
| 325 | pub(crate) struct Cdfs { | 351 | pub(crate) struct Cdfs { |
| 352 | + /// lane-txi: this FRAME's `reduced_tx_set` header bit (spec 5.9.2). | ||
| 353 | + /// `true` -- the default, and what every stream this encoder wrote | ||
| 354 | + /// before the lane carries -- leaves [`Self::txb`]'s luma set exactly as | ||
| 355 | + /// its caller named it. `false` widens it to the `Set1` counterpart | ||
| 356 | + /// ([`TxbSet::wide`]), which is the ONE place the writer and its pricer | ||
| 357 | + /// read the bit from, so a site that forgets it cannot code the right | ||
| 358 | + /// value against the wrong CDF (class `wrong-alphabet-same-value`). | ||
| 359 | + /// The DECODER never sets this: it names the widened set itself off the | ||
| 360 | + /// header (`decode::txbset_for`), and widening an already-wide set is the | ||
| 361 | + /// identity. | ||
| 362 | + pub reduced_tx_set: bool, | ||
| 326 | /// The coefficient q-context these tables were built for (spec 8.3.2's | 363 | /// The coefficient q-context these tables were built for (spec 8.3.2's |
| 327 | /// `Get_Qctx`), so a writer can price a block against the same tables the | 364 | /// `Get_Qctx`), so a writer can price a block against the same tables the |
| 328 | /// search did (`tile::coeff_bits`). | 365 | /// search did (`tile::coeff_bits`). |
| @@ -996,6 +1033,7 @@ impl Cdfs { | |||
| 996 | /// quantizer, so they are the same for every `q_ctx`. | 1033 | /// quantizer, so they are the same for every `q_ctx`. |
| 997 | pub fn new(q_ctx: usize) -> Cdfs { | 1034 | pub fn new(q_ctx: usize) -> Cdfs { |
| 998 | Cdfs { | 1035 | Cdfs { |
| 1036 | + reduced_tx_set: true, | ||
| 999 | q_ctx, | 1037 | q_ctx, |
| 1000 | partition_w128: cdf::PARTITION_W128, | 1038 | partition_w128: cdf::PARTITION_W128, |
| 1001 | partition_w64: cdf::PARTITION_W64, | 1039 | partition_w64: cdf::PARTITION_W64, |
| @@ -1602,6 +1640,7 @@ impl Cdfs { | |||
| 1602 | 1640 | ||
| 1603 | /// The tables one table set is coded with, borrowed out of the state. | 1641 | /// The tables one table set is coded with, borrowed out of the state. |
| 1604 | pub fn txb(&mut self, set: TxbSet, mode: usize) -> TxbTables<'_> { | 1642 | pub fn txb(&mut self, set: TxbSet, mode: usize) -> TxbTables<'_> { |
| 1643 | + let set = if self.reduced_tx_set { set } else { set.wide() }; | ||
| 1605 | match set { | 1644 | match set { |
| 1606 | TxbSet::Luma32 => TxbTables { | 1645 | TxbSet::Luma32 => TxbTables { |
| 1607 | side: 32, | 1646 | side: 32, |
crates/ec-av1/src/encode.rsmodified+122 -17
| @@ -273,6 +273,15 @@ fn tx_select_inter() -> bool { | |||
| 273 | /// here. | 273 | /// here. |
| 274 | pub(crate) fn tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] { | 274 | pub(crate) fn tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] { |
| 275 | const DCT: [TxType; 1] = [TxType::DctDct]; | 275 | const DCT: [TxType; 1] = [TxType::DctDct]; |
| 276 | + const INTRA1: [TxType; 7] = [ | ||
| 277 | + TxType::DctDct, | ||
| 278 | + TxType::AdstAdst, | ||
| 279 | + TxType::AdstDct, | ||
| 280 | + TxType::DctAdst, | ||
| 281 | + TxType::Idtx, | ||
| 282 | + TxType::VDct, | ||
| 283 | + TxType::HDct, | ||
| 284 | + ]; | ||
| 276 | const INTRA2: [TxType; 5] = [ | 285 | const INTRA2: [TxType; 5] = [ |
| 277 | TxType::DctDct, | 286 | TxType::DctDct, |
| 278 | TxType::AdstAdst, | 287 | TxType::AdstAdst, |
| @@ -281,7 +290,21 @@ pub(crate) fn tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] | |||
| 281 | TxType::Idtx, | 290 | TxType::Idtx, |
| 282 | ]; | 291 | ]; |
| 283 | match set { | 292 | match set { |
| 284 | - TxbSet::Luma16 | TxbSet::Luma8 | TxbSet::Luma4 if screen && tx_type_search() => &INTRA2, | 293 | + TxbSet::Luma16 | TxbSet::Luma8 | TxbSet::Luma4 |
| 294 | + if (screen || intra_tx_all_frames()) && tx_type_search() => | ||
| 295 | + { | ||
| 296 | + &INTRA2 | ||
| 297 | + } | ||
| 298 | + // lane-txi: a `reduced_tx_set == 0` frame's intra 8x8/4x4 reads the | ||
| 299 | + // SEVEN-type `TX_SET_INTRA_1` (`decode::txbset_for`'s `Luma{8,4}Set1`; | ||
| 300 | + // 16x16 stays `TX_SET_INTRA_2`, there is no `Luma16Set1`). The two | ||
| 301 | + // extra members are the 1-D DCTs, and the order is the reader's own | ||
| 302 | + // map (`decode::tx_type_from_symbol`, 8-wide CDF). | ||
| 303 | + TxbSet::Luma8Set1 | TxbSet::Luma4Set1 | ||
| 304 | + if (screen || intra_tx_all_frames()) && tx_type_search() => | ||
| 305 | + { | ||
| 306 | + &INTRA1 | ||
| 307 | + } | ||
| 285 | _ => &DCT, | 308 | _ => &DCT, |
| 286 | } | 309 | } |
| 287 | } | 310 | } |
| @@ -308,6 +331,15 @@ pub(crate) fn tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] | |||
| 308 | pub(crate) fn inter_tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] { | 331 | pub(crate) fn inter_tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] { |
| 309 | const DCT: [TxType; 1] = [TxType::DctDct]; | 332 | const DCT: [TxType; 1] = [TxType::DctDct]; |
| 310 | const INTER3: [TxType; 2] = [TxType::DctDct, TxType::Idtx]; | 333 | const INTER3: [TxType; 2] = [TxType::DctDct, TxType::Idtx]; |
| 334 | + const INTER_WIDE: [TxType; 7] = [ | ||
| 335 | + TxType::DctDct, | ||
| 336 | + TxType::AdstAdst, | ||
| 337 | + TxType::AdstDct, | ||
| 338 | + TxType::DctAdst, | ||
| 339 | + TxType::Idtx, | ||
| 340 | + TxType::VDct, | ||
| 341 | + TxType::HDct, | ||
| 342 | + ]; | ||
| 311 | let mode = inter_tx_type_search(); | 343 | let mode = inter_tx_type_search(); |
| 312 | let on = match mode { | 344 | let on = match mode { |
| 313 | InterTxSearch::Off => false, | 345 | InterTxSearch::Off => false, |
| @@ -317,10 +349,56 @@ pub(crate) fn inter_tx_type_candidates(set: TxbSet, screen: bool) -> &'static [T | |||
| 317 | match set { | 349 | match set { |
| 318 | TxbSet::Luma32Inter if on && mode != InterTxSearch::Le16 => &INTER3, | 350 | TxbSet::Luma32Inter if on && mode != InterTxSearch::Le16 => &INTER3, |
| 319 | TxbSet::Luma16Inter | TxbSet::Luma8Inter | TxbSet::Luma4Inter if on => &INTER3, | 351 | TxbSet::Luma16Inter | TxbSet::Luma8Inter | TxbSet::Luma4Inter if on => &INTER3, |
| 352 | + // lane-txi: a `reduced_tx_set == 0` frame's inter 16x16 reads the | ||
| 353 | + // TWELVE-type `TX_SET_INTER_2` and its 8x8/4x4 `ALL16` (inter 32x32 | ||
| 354 | + // stays the two-type `DCT_IDTX`). The seven offered here are the | ||
| 355 | + // members those two alphabets SHARE with the intra set -- the four | ||
| 356 | + // DTT combinations, `IDTX` and the two 1-D DCTs -- which is the | ||
| 357 | + // candidate list rav1e's speed 6 prunes to; the FLIPADST family and | ||
| 358 | + // the 1-D ADSTs are codable and left unoffered (deferred). | ||
| 359 | + TxbSet::Luma16InterSet1 | TxbSet::Luma8InterSet1 | TxbSet::Luma4InterSet1 if on => { | ||
| 360 | + &INTER_WIDE | ||
| 361 | + } | ||
| 320 | _ => &DCT, | 362 | _ => &DCT, |
| 321 | } | 363 | } |
| 322 | } | 364 | } |
| 323 | 365 | ||
| 366 | +/// lane-txi: does THIS frame code `reduced_tx_set = 0` (spec 5.9.2), i.e. | ||
| 367 | +/// the wider `tx_type` alphabets at intra 8x8/4x4 and inter 16x16 and below? | ||
| 368 | +/// `EC_AV1_TXSET_WIDE`: `0`/`off`, `screen` (screen frames only), anything | ||
| 369 | +/// else every frame; unset takes [`crate::speed::WIDE_TX_SET`], screen-gated | ||
| 370 | +/// like both halves of the type search itself. | ||
| 371 | +pub(crate) fn wide_tx_set(screen: bool) -> bool { | ||
| 372 | + static ENV: std::sync::LazyLock<Option<InterTxSearch>> = std::sync::LazyLock::new(|| { | ||
| 373 | + crate::envflags::var("EC_AV1_TXSET_WIDE").ok().map(|v| match v.as_str() { | ||
| 374 | + "0" | "off" => InterTxSearch::Off, | ||
| 375 | + "screen" => InterTxSearch::Screen, | ||
| 376 | + _ => InterTxSearch::All, | ||
| 377 | + }) | ||
| 378 | + }); | ||
| 379 | + match ENV.unwrap_or(if crate::speed::at(&crate::speed::WIDE_TX_SET) { | ||
| 380 | + InterTxSearch::Screen | ||
| 381 | + } else { | ||
| 382 | + InterTxSearch::Off | ||
| 383 | + }) { | ||
| 384 | + InterTxSearch::Off => false, | ||
| 385 | + InterTxSearch::Screen => screen, | ||
| 386 | + _ => true, | ||
| 387 | + } | ||
| 388 | +} | ||
| 389 | + | ||
| 390 | +/// The luma [`TxbSet`] the SEARCH and its pricer name for a frame that codes | ||
| 391 | +/// `reduced_tx_set = 0`: the writer reads the bit once, off the frame's own | ||
| 392 | +/// [`crate::cdf_state::Cdfs`], but the trial that prices a type has to read | ||
| 393 | +/// the same alphabet or the two disagree on what a `tx_type` symbol costs. | ||
| 394 | +pub(crate) fn luma_set_for(set: TxbSet, screen: bool) -> TxbSet { | ||
| 395 | + if wide_tx_set(screen) { | ||
| 396 | + set.wide() | ||
| 397 | + } else { | ||
| 398 | + set | ||
| 399 | + } | ||
| 400 | +} | ||
| 401 | + | ||
| 324 | #[derive(Clone, Copy, PartialEq)] | 402 | #[derive(Clone, Copy, PartialEq)] |
| 325 | pub(crate) enum InterTxSearch { | 403 | pub(crate) enum InterTxSearch { |
| 326 | Off, | 404 | Off, |
| @@ -372,14 +450,14 @@ fn inter_tx_type_search() -> InterTxSearch { | |||
| 372 | 450 | ||
| 373 | /// The inter luma [`TxbSet`] a `tx`-sided transform unit reads, `None` for the | 451 | /// The inter luma [`TxbSet`] a `tx`-sided transform unit reads, `None` for the |
| 374 | /// 64-point one (it codes no `tx_type` symbol). | 452 | /// 64-point one (it codes no `tx_type` symbol). |
| 375 | -fn inter_luma_set(tx: usize) -> Option<TxbSet> { | 453 | +fn inter_luma_set(tx: usize, screen: bool) -> Option<TxbSet> { |
| 376 | - Some(match tx { | 454 | + Some(luma_set_for(match tx { |
| 377 | 4 => TxbSet::Luma4Inter, | 455 | 4 => TxbSet::Luma4Inter, |
| 378 | 8 => TxbSet::Luma8Inter, | 456 | 8 => TxbSet::Luma8Inter, |
| 379 | 16 => TxbSet::Luma16Inter, | 457 | 16 => TxbSet::Luma16Inter, |
| 380 | 32 => TxbSet::Luma32Inter, | 458 | 32 => TxbSet::Luma32Inter, |
| 381 | _ => return None, | 459 | _ => return None, |
| 382 | - }) | 460 | + }, screen)) |
| 383 | } | 461 | } |
| 384 | 462 | ||
| 385 | fn tx_type_search() -> bool { | 463 | fn tx_type_search() -> bool { |
| @@ -391,6 +469,17 @@ fn tx_type_search() -> bool { | |||
| 391 | ENV.unwrap_or_else(|| crate::speed::at(&crate::speed::TX_TYPE_SEARCH)) | 469 | ENV.unwrap_or_else(|| crate::speed::at(&crate::speed::TX_TYPE_SEARCH)) |
| 392 | } | 470 | } |
| 393 | 471 | ||
| 472 | +/// lane-txi: `EC_AV1_TXSET=all` offers the five-type intra set on EVERY | ||
| 473 | +/// frame -- the unconditional arm the gate measures -- instead of the screen | ||
| 474 | +/// content gate [`tx_type_candidates`] ships behind. Any other value keeps | ||
| 475 | +/// the gate (`0`/`off` still switches the search off entirely). | ||
| 476 | +fn intra_tx_all_frames() -> bool { | ||
| 477 | + static ENV: std::sync::LazyLock<bool> = std::sync::LazyLock::new(|| { | ||
| 478 | + crate::envflags::var("EC_AV1_TXSET").is_ok_and(|v| v == "all") | ||
| 479 | + }); | ||
| 480 | + *ENV | ||
| 481 | +} | ||
| 482 | + | ||
| 394 | fn tx_select() -> bool { | 483 | fn tx_select() -> bool { |
| 395 | static ENV: std::sync::LazyLock<Option<bool>> = std::sync::LazyLock::new(|| { | 484 | static ENV: std::sync::LazyLock<Option<bool>> = std::sync::LazyLock::new(|| { |
| 396 | crate::envflags::var("EC_AV1_TX_SELECT") | 485 | crate::envflags::var("EC_AV1_TX_SELECT") |
| @@ -2536,12 +2625,15 @@ impl Plane<'_> { | |||
| 2536 | let At { x, y, side, reach, .. } = at; | 2625 | let At { x, y, side, reach, .. } = at; |
| 2537 | let tx = side >> depth; | 2626 | let tx = side >> depth; |
| 2538 | let n = 1usize << depth; | 2627 | let n = 1usize << depth; |
| 2539 | - let set = match tx { | 2628 | + let set = luma_set_for( |
| 2540 | - 32 => TxbSet::Luma32, | 2629 | + match tx { |
| 2541 | - 16 => TxbSet::Luma16, | 2630 | + 32 => TxbSet::Luma32, |
| 2542 | - 8 => TxbSet::Luma8, | 2631 | + 16 => TxbSet::Luma16, |
| 2543 | - _ => TxbSet::Luma4, | 2632 | + 8 => TxbSet::Luma8, |
| 2544 | - }; | 2633 | + _ => TxbSet::Luma4, |
| 2634 | + }, | ||
| 2635 | + search.screen, | ||
| 2636 | + ); | ||
| 2545 | let mut levels = vec![0i32; side * side]; | 2637 | let mut levels = vec![0i32; side * side]; |
| 2546 | census_add(4, n * n); | 2638 | census_add(4, n * n); |
| 2547 | // A unit smaller than its block reads the neighbour magnitude table | 2639 | // A unit smaller than its block reads the neighbour magnitude table |
| @@ -4084,7 +4176,7 @@ fn commit_inter_luma( | |||
| 4084 | let mut flat_typed: Option<Trial> = None; | 4176 | let mut flat_typed: Option<Trial> = None; |
| 4085 | let mut flat_type = TxType::DctDct; | 4177 | let mut flat_type = TxType::DctDct; |
| 4086 | if !skip { | 4178 | if !skip { |
| 4087 | - if let Some(fset) = inter_luma_set(side) { | 4179 | + if let Some(fset) = inter_luma_set(side, search.screen) { |
| 4088 | let lambda = search.lambda * tx_type_lambda_mult(); | 4180 | let lambda = search.lambda * tx_type_lambda_mult(); |
| 4089 | let cost = |t: &Trial| t.sse + lambda * t.bits; | 4181 | let cost = |t: &Trial| t.sse + lambda * t.bits; |
| 4090 | for &tx_type in inter_tx_type_candidates(fset, search.screen) { | 4182 | for &tx_type in inter_tx_type_candidates(fset, search.screen) { |
| @@ -4130,7 +4222,7 @@ fn commit_inter_luma( | |||
| 4130 | // differently-predicted baseline is what would let a candidate win on | 4222 | // differently-predicted baseline is what would let a candidate win on |
| 4131 | // both terms at once (class `local-rd-on-references` vs a real | 4223 | // both terms at once (class `local-rd-on-references` vs a real |
| 4132 | // pricing defect); re-predicting it here is the only way to tell. | 4224 | // pricing defect); re-predicting it here is the only way to tell. |
| 4133 | - if let Some(fset) = inter_luma_set(side) { | 4225 | + if let Some(fset) = inter_luma_set(side, search.screen) { |
| 4134 | let here = match second { | 4226 | let here = match second { |
| 4135 | Some((mv1, ref1)) => mc_trial_compound_typed( | 4227 | Some((mv1, ref1)) => mc_trial_compound_typed( |
| 4136 | luma, x, y, side, (mv, mv1), true, reference, ref1, search.base_q_idx, | 4228 | luma, x, y, side, (mv, mv1), true, reference, ref1, search.base_q_idx, |
| @@ -4175,14 +4267,14 @@ fn commit_inter_luma( | |||
| 4175 | return (flat_ref.levels.clone(), 0, flat_gain, vec![flat_type]); | 4267 | return (flat_ref.levels.clone(), 0, flat_gain, vec![flat_type]); |
| 4176 | } | 4268 | } |
| 4177 | let tx = side / 2; | 4269 | let tx = side / 2; |
| 4178 | - let set = if tx >= 32 { | 4270 | + let set = luma_set_for(if tx >= 32 { |
| 4179 | // lane-b64b: the 64x64 root's halved transform is TX_32X32. | 4271 | // lane-b64b: the 64x64 root's halved transform is TX_32X32. |
| 4180 | TxbSet::Luma32Inter | 4272 | TxbSet::Luma32Inter |
| 4181 | } else if tx >= 16 { | 4273 | } else if tx >= 16 { |
| 4182 | TxbSet::Luma16Inter | 4274 | TxbSet::Luma16Inter |
| 4183 | } else { | 4275 | } else { |
| 4184 | TxbSet::Luma8Inter | 4276 | TxbSet::Luma8Inter |
| 4185 | - }; | 4277 | + }, search.screen); |
| 4186 | let mut levels = vec![0i32; side * side]; | 4278 | let mut levels = vec![0i32; side * side]; |
| 4187 | let (mut sse, mut bits) = (0.0, 0.0); | 4279 | let (mut sse, mut bits) = (0.0, 0.0); |
| 4188 | let mut units = Vec::with_capacity(4); | 4280 | let mut units = Vec::with_capacity(4); |
| @@ -4830,7 +4922,7 @@ fn code_square( | |||
| 4830 | y, | 4922 | y, |
| 4831 | side, | 4923 | side, |
| 4832 | reach: Reach::of(side, x, y, luma.true_width, luma.true_height, fctx), | 4924 | reach: Reach::of(side, x, y, luma.true_width, luma.true_height, fctx), |
| 4833 | - set: luma_set, | 4925 | + set: luma_set_for(luma_set, search.screen), |
| 4834 | }; | 4926 | }; |
| 4835 | let (mut luma_coeffs, mode, angle_delta, mut cost, tx_type) = | 4927 | let (mut luma_coeffs, mode, angle_delta, mut cost, tx_type) = |
| 4836 | luma.search_block(at, search, mode_bits, fctx); | 4928 | luma.search_block(at, search, mode_bits, fctx); |
| @@ -7118,6 +7210,9 @@ pub(crate) fn encode_key_frame_inner( | |||
| 7118 | IBC_SHARE.with(|c| c.set(ibc_share)); | 7210 | IBC_SHARE.with(|c| c.set(ibc_share)); |
| 7119 | let (seq, mut header) = key_frame_headers_colour(render.0, render.1, base_q_idx, color_config)?; | 7211 | let (seq, mut header) = key_frame_headers_colour(render.0, render.1, base_q_idx, color_config)?; |
| 7120 | header.allow_screen_content_tools = screen; | 7212 | header.allow_screen_content_tools = screen; |
| 7213 | + // lane-txi: the wider `tx_type` alphabets, gated by the same content | ||
| 7214 | + // rule the type search itself stands behind ([`wide_tx_set`]). | ||
| 7215 | + header.reduced_tx_set = !wide_tx_set(screen); | ||
| 7121 | header.allow_intrabc = allow_intrabc; | 7216 | header.allow_intrabc = allow_intrabc; |
| 7122 | header.render_width = render.0 as u32; | 7217 | header.render_width = render.0 as u32; |
| 7123 | header.render_height = render.1 as u32; | 7218 | header.render_height = render.1 as u32; |
| @@ -7556,7 +7651,10 @@ pub(crate) fn encode_key_frame_inner( | |||
| 7556 | // defaults again (spec 7.20's `started_from` arm) -- the first inter | 7651 | // defaults again (spec 7.20's `started_from` arm) -- the first inter |
| 7557 | // frame after it therefore starts from the defaults too. | 7652 | // frame after it therefore starts from the defaults too. |
| 7558 | let (mi_cols, mi_rows) = (header.mi_cols, header.mi_rows); | 7653 | let (mi_cols, mi_rows) = (header.mi_cols, header.mi_rows); |
| 7559 | - let cdfs = crate::cdf_state::Cdfs::new(crate::tile::q_ctx_of(base_q_idx)); | 7654 | + let mut cdfs = crate::cdf_state::Cdfs::new(crate::tile::q_ctx_of(base_q_idx)); |
| 7655 | + // lane-txi: the ONE place the writer reads the frame's `reduced_tx_set` | ||
| 7656 | + // from -- `Cdfs::txb` widens every luma set under it. | ||
| 7657 | + cdfs.reduced_tx_set = header.reduced_tx_set; | ||
| 7560 | let start_cdfs = CdfSnapshot(cdfs); | 7658 | let start_cdfs = CdfSnapshot(cdfs); |
| 7561 | // The luma restoration-unit grid this frame's `lr_params` implies | 7659 | // The luma restoration-unit grid this frame's `lr_params` implies |
| 7562 | // (`av1_lr_count_units` rounds to nearest, so a short last unit is | 7660 | // (`av1_lr_count_units` rounds to nearest, so a short last unit is |
| @@ -10448,6 +10546,9 @@ pub(crate) fn encode_inter_frame( | |||
| 10448 | let screen = seq_screen() | 10546 | let screen = seq_screen() |
| 10449 | && screen_content(&picture_y8, picture.width, true_width, true_height); | 10547 | && screen_content(&picture_y8, picture.width, true_width, true_height); |
| 10450 | header.allow_screen_content_tools = screen; | 10548 | header.allow_screen_content_tools = screen; |
| 10549 | + // lane-txi, as on the key frame: the header bit the writer's own | ||
| 10550 | + // `Cdfs` then reads for every luma `tx_type` symbol. | ||
| 10551 | + header.reduced_tx_set = !wide_tx_set(screen); | ||
| 10451 | // The search prices coefficients against the tables this frame's writer | 10552 | // The search prices coefficients against the tables this frame's writer |
| 10452 | // starts from, not against the defaults (lane-av1txbits) -- but only on a | 10553 | // starts from, not against the defaults (lane-av1txbits) -- but only on a |
| 10453 | // frame the screen detector said no to (lane-av1price2): armed HERE, after | 10554 | // frame the screen detector said no to (lane-av1price2): armed HERE, after |
| @@ -11272,9 +11373,13 @@ pub(crate) fn encode_inter_frame( | |||
| 11272 | // next frame's writer starts from them -- exactly what | 11373 | // next frame's writer starts from them -- exactly what |
| 11273 | // `crate::stream::stored_cdfs_for` hands the decoder. | 11374 | // `crate::stream::stored_cdfs_for` hands the decoder. |
| 11274 | let (mi_cols, mi_rows) = (header.mi_cols, header.mi_rows); | 11375 | let (mi_cols, mi_rows) = (header.mi_cols, header.mi_rows); |
| 11275 | - let cdfs = start_cdfs | 11376 | + let mut cdfs = start_cdfs |
| 11276 | .cloned() | 11377 | .cloned() |
| 11277 | .unwrap_or_else(|| crate::cdf_state::Cdfs::new(crate::tile::q_ctx_of(base_q_idx))); | 11378 | .unwrap_or_else(|| crate::cdf_state::Cdfs::new(crate::tile::q_ctx_of(base_q_idx))); |
| 11379 | + // lane-txi: set per frame, never inherited from the snapshot the | ||
| 11380 | + // previous frame stored -- the content gate can flip the bit between | ||
| 11381 | + // frames (class `per-tile-state-not-reset`). | ||
| 11382 | + cdfs.reduced_tx_set = header.reduced_tx_set; | ||
| 11278 | let start_cdfs = CdfSnapshot(cdfs); | 11383 | let start_cdfs = CdfSnapshot(cdfs); |
| 11279 | let reference_select_bit = header.reference_select; | 11384 | let reference_select_bit = header.reference_select; |
| 11280 | let switchable_motion_mode = header.is_motion_mode_switchable; | 11385 | let switchable_motion_mode = header.is_motion_mode_switchable; |
crates/ec-av1/src/speed.rsmodified+9 -0
| @@ -512,6 +512,15 @@ pub(crate) const TX_TYPE_SEARCH_INTER: [bool; 11] = [ | |||
| 512 | true, true, true, true, true, true, true, false, false, false, false, | 512 | true, true, true, true, true, true, true, false, false, false, false, |
| 513 | ]; | 513 | ]; |
| 514 | 514 | ||
| 515 | +/// `encode::wide_tx_set`: whether a frame codes `reduced_tx_set = 0`, the | ||
| 516 | +/// wider `tx_type` alphabets (intra 8x8/4x4 seven types, inter 16x16 twelve, | ||
| 517 | +/// inter 8x8/4x4 sixteen) instead of the reduced sets every stream this | ||
| 518 | +/// encoder wrote before lane-txi carries. OFF at every preset until the gate | ||
| 519 | +/// says otherwise; `EC_AV1_TXSET_WIDE` overrides. | ||
| 520 | +pub(crate) const WIDE_TX_SET: [bool; 11] = [ | ||
| 521 | + false, false, false, false, false, false, false, false, false, false, false, | ||
| 522 | +]; | ||
| 523 | + | ||
| 515 | /// `filter_search`: whether the deblock ladder's +-1/+-2 refinement stage runs. | 524 | /// `filter_search`: whether the deblock ladder's +-1/+-2 refinement stage runs. |
| 516 | pub(crate) const DEBLOCK_REFINE: [bool; 11] = [ | 525 | pub(crate) const DEBLOCK_REFINE: [bool; 11] = [ |
| 517 | true, true, true, true, true, true, true, false, false, false, false, | 526 | true, true, true, true, true, true, true, false, false, false, false, |