The inter tx-type search widens to the Set1 alphabets on reduced_tx_set=0 frames with the chroma inheritance made honest -- the frame sets its own reduced_tx_set_inter on the shared context and the writer codes every inter chroma plane with the luma type reduced to the chroma set (lane-intertx desyncs (a)+(b)), the one-D witness codes 40 V_DCT + 521 H_DCT inter units on a non-screen clip and all three planes read sample-exact through ffmpeg and decode_stream, the RED run with the chroma half neutralized desyncs the tile
Browse files at this commit630cb1189014eb4a6e5c2208b2b241f9e3b4ade1Parent: 8921cb1- fix
- the inter tx-type search widens to the Set1 alphabets on reduced_tx_set=0 frames with the chroma inheritance made honest -- the frame sets its own reduced_tx_set_inter on the shared context and the writer codes every inter chroma plane with the luma type reduced to the chroma set (lane-intertx desyncs (a)+(b)), the one-D witness codes 40 V_DCT + 521 H_DCT inter units on a non-screen clip and all three planes read sample-exact through ffmpeg and decode_stream, the RED run with the chroma half neutralized desyncs the tile
5 changed files +193 -28
- crates/ec-av1/src/cdf_state.rs +5 -4
- crates/ec-av1/src/decode.rs +10 -1
- crates/ec-av1/src/encode.rs +43 -21
- crates/ec-av1/src/encoder.rs +101 -0
- crates/ec-av1/src/tile.rs +34 -2
crates/ec-av1/src/cdf_state.rsmodified+5 -4
| @@ -278,10 +278,11 @@ pub(crate) struct TxbTables<'a> { | |||
| 278 | pub txb_skip: &'a mut [[u16; 3]], | 278 | pub txb_skip: &'a mut [[u16; 3]], |
| 279 | /// The end-of-block group, whose alphabet the transform size sets. | 279 | /// The end-of-block group, whose alphabet the transform size sets. |
| 280 | pub eob_pt: &'a mut [u16], | 280 | pub eob_pt: &'a mut [u16], |
| 281 | - /// `eob_pt`'s `TX_CLASS_HORIZ`/`TX_CLASS_VERT` sibling table (r5): read | 281 | + /// Read instead of `eob_pt` once this TU's `tx_type` is known to be |
| 282 | - /// instead of `eob_pt` once this TU's `tx_type` is known to be | 282 | + /// `V_DCT`/`H_DCT` (lane-intertx doc fix: every set here carries the |
| 283 | - /// `V_DCT`/`H_DCT`. `None` for any size/set whose `tx_type` alphabet | 283 | + /// row -- the older "none for chroma and every inter set" note |
| 284 | - /// cannot produce those two symbols (chroma, and every inter set). | 284 | + /// described the r5 alphabet, before the wider inter/chroma-reachable |
| 285 | + /// sets made those classes reachable there). | ||
| 285 | pub eob_pt_class1: Option<&'a mut [u16]>, | 286 | pub eob_pt_class1: Option<&'a mut [u16]>, |
| 286 | /// The top bit of the offset inside that group. | 287 | /// The top bit of the offset inside that group. |
| 287 | pub eob_extra: &'a mut [[u16; 3]; 9], | 288 | pub eob_extra: &'a mut [[u16; 3]; 9], |
crates/ec-av1/src/decode.rsmodified+10 -1
| @@ -18711,10 +18711,19 @@ fn read_inter_luma8( | |||
| 18711 | /// sync and only corrupted the inverse transform (one 64x64 superblock of | 18711 | /// sync and only corrupted the inverse transform (one 64x64 superblock of |
| 18712 | /// high-frequency chroma noise, luma bit-exact). | 18712 | /// high-frequency chroma noise, luma bit-exact). |
| 18713 | pub(crate) fn reduce_inherited_chroma_tx_type(t: TxType, w: usize, h: usize, fctx: &crate::decode::FrameCtx) -> TxType { | 18713 | pub(crate) fn reduce_inherited_chroma_tx_type(t: TxType, w: usize, h: usize, fctx: &crate::decode::FrameCtx) -> TxType { |
| 18714 | + reduce_inherited_chroma_tx_type_flagged(t, w, h, fctx.reduced_tx_set_inter.with(std::cell::Cell::get)) | ||
| 18715 | +} | ||
| 18716 | + | ||
| 18717 | +/// [`reduce_inherited_chroma_tx_type`] against an explicit `reduced_tx_set` | ||
| 18718 | +/// bit (lane-intertx): the WRITER calls this with the frame's own header bit | ||
| 18719 | +/// ([`crate::cdf_state::Cdfs::reduced_tx_set`]) to derive the type an inter | ||
| 18720 | +/// block's chroma transform is coded with, the same derivation its reader | ||
| 18721 | +/// makes -- it has no `FrameCtx` in reach and must not silently read one | ||
| 18722 | +/// whose value can lag the frame being written (class `stale-context-bit`). | ||
| 18723 | +pub(crate) fn reduce_inherited_chroma_tx_type_flagged(t: TxType, w: usize, h: usize, reduced: bool) -> TxType { | ||
| 18714 | use TxType::*; | 18724 | use TxType::*; |
| 18715 | let sqr_up = w.max(h); | 18725 | let sqr_up = w.max(h); |
| 18716 | let sqr = w.min(h); | 18726 | let sqr = w.min(h); |
| 18717 | - let reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get); | ||
| 18718 | // `av1_get_ext_tx_set_type(tx_size, is_inter = 1, reduced)`. | 18727 | // `av1_get_ext_tx_set_type(tx_size, is_inter = 1, reduced)`. |
| 18719 | let allowed: &[TxType] = if sqr_up > 32 { | 18728 | let allowed: &[TxType] = if sqr_up > 32 { |
| 18720 | // EXT_TX_SET_DCTONLY | 18729 | // EXT_TX_SET_DCTONLY |
crates/ec-av1/src/encode.rsmodified+43 -21
| @@ -472,21 +472,24 @@ fn inter_tx_type_search() -> InterTxSearch { | |||
| 472 | 472 | ||
| 473 | /// The inter luma [`TxbSet`] a `tx`-sided transform unit reads, `None` for the | 473 | /// The inter luma [`TxbSet`] a `tx`-sided transform unit reads, `None` for the |
| 474 | /// 64-point one (it codes no `tx_type` symbol). | 474 | /// 64-point one (it codes no `tx_type` symbol). |
| 475 | -/// lane-txw: the INTER half of the widening is still NOT applied here, and | 475 | +/// lane-txw history, resolved by lane-intertx: the INTER half of the |
| 476 | -/// the reason lane-txi recorded (the `refs` lane's DPB bookkeeping) was | 476 | +/// widening was blocked by `refusal-from-own-desync` twice over. Half of it |
| 477 | -/// WRONG -- the refusal is `refusal-from-own-desync` twice over. Half of it | ||
| 478 | /// was this writer coding a `V_DCT`/`H_DCT` unit as `TX_CLASS_2D` | 477 | /// was this writer coding a `V_DCT`/`H_DCT` unit as `TX_CLASS_2D` |
| 479 | -/// (`tile::write_coeffs`, fixed by this lane, which is what unblocked the | 478 | +/// (`tile::write_coeffs`, fixed by lane-txw, which unblocked the intra |
| 480 | -/// intra half). What remains is the CHROMA inheritance: an inter block's | 479 | +/// half). The other half was the CHROMA inheritance: an inter block's |
| 481 | /// chroma transform type is the luma type reduced to the chroma size's set | 480 | /// chroma transform type is the luma type reduced to the chroma size's set |
| 482 | /// (`decode::reduce_inherited_chroma_tx_type`), and (a) the encoder never | 481 | /// (`decode::reduce_inherited_chroma_tx_type`), and (a) the encoder never |
| 483 | -/// sets `FrameCtx::reduced_tx_set_inter`, so [`recode_inter_chroma`] reduces | 482 | +/// set `FrameCtx::reduced_tx_set_inter`, so [`recode_inter_chroma`] reduced |
| 484 | -/// against the REDUCED allowance while a `reduced_tx_set = 0` frame's | 483 | +/// against a STALE allowance, and (b) `tile::write_block_planes` coded |
| 485 | -/// decoder allows the full one, and (b) `tile::write_block_planes` codes | 484 | +/// every chroma plane as `DCT_DCT`, so an inherited 1-D type desynced the |
| 486 | -/// every chroma plane as `DCT_DCT`, so an inherited 1-D type desyncs the | 485 | +/// chroma exactly as luma did. lane-intertx fixed both -- the frame sets |
| 487 | -/// chroma exactly as luma did. Both are deferred with the wider inter search | 486 | +/// its own bit on the context (`encode_inter_frame`), the writer derives |
| 488 | -/// itself; the intra half needs neither (an intra block's chroma type comes | 487 | +/// the chroma type from this frame's own header bit |
| 489 | -/// off its own UV mode, never off luma). | 488 | +/// (`reduce_inherited_chroma_tx_type_flagged`) -- and the widened SEARCH |
| 489 | +/// names these sets through [`luma_set_for`] at its call sites, so the | ||
| 490 | +/// wider candidates are reachable and honestly priced. The intra half | ||
| 491 | +/// never needed either (an intra block's chroma type comes off its own UV | ||
| 492 | +/// mode, never off luma). | ||
| 490 | fn inter_luma_set(tx: usize) -> Option<TxbSet> { | 493 | fn inter_luma_set(tx: usize) -> Option<TxbSet> { |
| 491 | Some(match tx { | 494 | Some(match tx { |
| 492 | 4 => TxbSet::Luma4Inter, | 495 | 4 => TxbSet::Luma4Inter, |
| @@ -5109,7 +5112,15 @@ fn commit_inter_luma( | |||
| 5109 | let mut flat_typed: Option<Trial> = None; | 5112 | let mut flat_typed: Option<Trial> = None; |
| 5110 | let mut flat_type = TxType::DctDct; | 5113 | let mut flat_type = TxType::DctDct; |
| 5111 | if !skip { | 5114 | if !skip { |
| 5112 | - if let Some(fset) = inter_luma_set(side) { | 5115 | + // lane-intertx: on a `reduced_tx_set = 0` frame the search names the |
| 5116 | + // Set1 alphabet the writer codes into ([`luma_set_for`], the shape | ||
| 5117 | + // the intra search already takes), which is what makes the wider | ||
| 5118 | + // seven-type candidate list below reachable -- and prices every | ||
| 5119 | + // candidate, `IDTX` included, in the alphabet its symbol is really | ||
| 5120 | + // coded into. | ||
| 5121 | + if let Some(fset) = | ||
| 5122 | + inter_luma_set(side).map(|set| luma_set_for(set, search.screen)) | ||
| 5123 | + { | ||
| 5113 | let lambda = search.lambda * tx_type_lambda_mult(); | 5124 | let lambda = search.lambda * tx_type_lambda_mult(); |
| 5114 | let cost = |t: &Trial| t.sse + lambda * t.bits; | 5125 | let cost = |t: &Trial| t.sse + lambda * t.bits; |
| 5115 | for &tx_type in inter_tx_type_candidates(fset, search.screen) { | 5126 | for &tx_type in inter_tx_type_candidates(fset, search.screen) { |
| @@ -5200,14 +5211,17 @@ fn commit_inter_luma( | |||
| 5200 | return (flat_ref.levels.clone(), 0, flat_gain, vec![flat_type]); | 5211 | return (flat_ref.levels.clone(), 0, flat_gain, vec![flat_type]); |
| 5201 | } | 5212 | } |
| 5202 | let tx = side / 2; | 5213 | let tx = side / 2; |
| 5203 | - let set = if tx >= 32 { | 5214 | + let set = luma_set_for( |
| 5204 | - // lane-b64b: the 64x64 root's halved transform is TX_32X32. | 5215 | + if tx >= 32 { |
| 5205 | - TxbSet::Luma32Inter | 5216 | + // lane-b64b: the 64x64 root's halved transform is TX_32X32. |
| 5206 | - } else if tx >= 16 { | 5217 | + TxbSet::Luma32Inter |
| 5207 | - TxbSet::Luma16Inter | 5218 | + } else if tx >= 16 { |
| 5208 | - } else { | 5219 | + TxbSet::Luma16Inter |
| 5209 | - TxbSet::Luma8Inter | 5220 | + } else { |
| 5210 | - }; | 5221 | + TxbSet::Luma8Inter |
| 5222 | + }, | ||
| 5223 | + search.screen, | ||
| 5224 | + ); | ||
| 5211 | let mut levels = vec![0i32; side * side]; | 5225 | let mut levels = vec![0i32; side * side]; |
| 5212 | let (mut sse, mut bits) = (0.0, 0.0); | 5226 | let (mut sse, mut bits) = (0.0, 0.0); |
| 5213 | let mut units = Vec::with_capacity(4); | 5227 | let mut units = Vec::with_capacity(4); |
| @@ -12594,6 +12608,14 @@ pub(crate) fn encode_inter_frame( | |||
| 12594 | // lane-txi, as on the key frame: the header bit the writer's own | 12608 | // lane-txi, as on the key frame: the header bit the writer's own |
| 12595 | // `Cdfs` then reads for every luma `tx_type` symbol. | 12609 | // `Cdfs` then reads for every luma `tx_type` symbol. |
| 12596 | header.reduced_tx_set = !wide_tx_set(screen); | 12610 | header.reduced_tx_set = !wide_tx_set(screen); |
| 12611 | + // lane-intertx, desync (a): the frame context this value is read back | ||
| 12612 | + // through ( [`decode::reduce_inherited_chroma_tx_type`] inside | ||
| 12613 | + // `recode_inter_chroma`, and every inter decode helper the search's own | ||
| 12614 | + // trial decode shares) must carry THIS frame's bit, not whatever the | ||
| 12615 | + // previous frame's trial decode last left in the shared cell -- a stale | ||
| 12616 | + // `true` here narrows the chroma allowance the search reconstructs | ||
| 12617 | + // against under the one the header's bit actually allows. | ||
| 12618 | + fctx.reduced_tx_set_inter.set(header.reduced_tx_set); | ||
| 12597 | // The search prices coefficients against the tables this frame's writer | 12619 | // The search prices coefficients against the tables this frame's writer |
| 12598 | // starts from, not against the defaults (lane-av1txbits) -- but only on a | 12620 | // starts from, not against the defaults (lane-av1txbits) -- but only on a |
| 12599 | // frame the screen detector said no to (lane-av1price2): armed HERE, after | 12621 | // frame the screen detector said no to (lane-av1price2): armed HERE, after |
crates/ec-av1/src/encoder.rsmodified+101 -0
| @@ -4993,6 +4993,107 @@ mod tests { | |||
| 4993 | eprintln!("SKIP the ffmpeg half: no ffmpeg"); | 4993 | eprintln!("SKIP the ffmpeg half: no ffmpeg"); |
| 4994 | } | 4994 | } |
| 4995 | } | 4995 | } |
| 4996 | + /// lane-intertx's witness: on a clip the screen detector calls | ||
| 4997 | + /// NON-screen, the inter luma search offers the wider | ||
| 4998 | + /// `reduced_tx_set = 0` alphabets and CODES a 1-D `V_DCT`/`H_DCT` unit | ||
| 4999 | + /// (a `coded > 0` guard on the committed-winners census, class | ||
| 5000 | + /// `gate-blind-to-feature`), the block's chroma transforms inherit that | ||
| 5001 | + /// type reduced to the chroma size's set against the frame's own honest | ||
| 5002 | + /// header bit, and BOTH decoders reconstruct every frame sample-exact on | ||
| 5003 | + /// ALL THREE planes -- chroma is the plane the inheritance desync | ||
| 5004 | + /// corrupts, so luma-only comparisons cannot see it. | ||
| 5005 | + #[test] | ||
| 5006 | + #[ignore = "sets process-global search levers: run it alone"] | ||
| 5007 | + fn a_non_screen_inter_clip_codes_a_one_d_type_both_decoders_read_every_plane_exactly() { | ||
| 5008 | + let _knobs = crate::speed::knob_write(); | ||
| 5009 | + let _gate_lock = crate::stream::tests::lock_gate_counters(); | ||
| 5010 | + crate::encode::set_intra_tx_search(Some(true)); | ||
| 5011 | + crate::encode::set_inter_tx_search(Some(true)); | ||
| 5012 | + crate::encode::set_wide_tx_set(Some(true)); | ||
| 5013 | + crate::encode::force_screen(Some(false)); | ||
| 5014 | + let (width, height) = (320usize, 192usize); | ||
| 5015 | + // The wide witness's moving card: vertical steps (where a 1-D | ||
| 5016 | + // `V_DCT`/`H_DCT` beats the 2-D DCT on the motion-compensated | ||
| 5017 | + // residual), ramps (`ADST`) and moving plateaus (`IDTX`), translated | ||
| 5018 | + // a few samples per frame so the inter search sees real motion. | ||
| 5019 | + let sources: Vec<Picture> = (0..4) | ||
| 5020 | + .map(|t| { | ||
| 5021 | + let mut p = test_card(width, height, t * 3); | ||
| 5022 | + for y in 0..height { | ||
| 5023 | + for x in 0..width { | ||
| 5024 | + let v = match ((x + t * 5) / 16 % 2, (y + t * 3) / 16 % 2) { | ||
| 5025 | + (0, 0) => 16u16, | ||
| 5026 | + (1, 0) => 235, | ||
| 5027 | + (0, 1) => ((x + t) % 64 * 3) as u16, | ||
| 5028 | + _ => ((y + t) % 64 * 3) as u16, | ||
| 5029 | + }; | ||
| 5030 | + p.y[y * width + x] = v; | ||
| 5031 | + } | ||
| 5032 | + } | ||
| 5033 | + p | ||
| 5034 | + }) | ||
| 5035 | + .collect(); | ||
| 5036 | + let config = EncoderConfig { | ||
| 5037 | + width, | ||
| 5038 | + height, | ||
| 5039 | + base_q_idx: 90, | ||
| 5040 | + gop: 4, | ||
| 5041 | + colour: Colour::Bt709Limited, | ||
| 5042 | + tile_cols_log2: 0, | ||
| 5043 | + tile_rows_log2: 0, | ||
| 5044 | + }; | ||
| 5045 | + let mut enc = Av1Encoder::new(config).unwrap(); | ||
| 5046 | + let _ = crate::encode::take_inter_tx_type_hits(); | ||
| 5047 | + let mut stream = Vec::new(); | ||
| 5048 | + for packet in encode_all(&mut enc, &sources) { | ||
| 5049 | + stream.extend_from_slice(&packet.data); | ||
| 5050 | + } | ||
| 5051 | + let hits = crate::encode::take_inter_tx_type_hits(); | ||
| 5052 | + crate::encode::force_screen(None); | ||
| 5053 | + crate::encode::set_wide_tx_set(None); | ||
| 5054 | + crate::encode::set_inter_tx_search(None); | ||
| 5055 | + crate::encode::set_intra_tx_search(None); | ||
| 5056 | + use crate::transform::TxType; | ||
| 5057 | + eprintln!( | ||
| 5058 | + "inter wide-set witness: inter hits {hits:?}, {} bytes", | ||
| 5059 | + stream.len() | ||
| 5060 | + ); | ||
| 5061 | + assert!( | ||
| 5062 | + hits[TxType::Idtx as usize] > 0, | ||
| 5063 | + "no inter luma unit was CODED IDTX: {hits:?}" | ||
| 5064 | + ); | ||
| 5065 | + assert!( | ||
| 5066 | + hits[TxType::VDct as usize] + hits[TxType::HDct as usize] > 0, | ||
| 5067 | + "no inter luma unit was CODED a 1-D type -- the wider search \ | ||
| 5068 | + never fired on non-screen content (class gate-blind-to-feature): {hits:?}" | ||
| 5069 | + ); | ||
| 5070 | + let ours = crate::stream::decode_stream(&stream).expect("our decoder"); | ||
| 5071 | + assert_eq!(ours.len(), sources.len(), "our decoder's frames"); | ||
| 5072 | + if have_ffmpeg() { | ||
| 5073 | + let theirs = ffmpeg_decode_planes(&stream, width, height); | ||
| 5074 | + assert_eq!(theirs.len(), sources.len(), "ffmpeg's frames"); | ||
| 5075 | + let (cw, ch) = (width / 2, height / 2); | ||
| 5076 | + for (i, (a, (y, u, v))) in ours.iter().zip(&theirs).enumerate() { | ||
| 5077 | + for (name, got16, want, w) in | ||
| 5078 | + [("y", &a.y, y, width), ("u", &a.u, u, cw), ("v", &a.v, v, ch)] | ||
| 5079 | + { | ||
| 5080 | + let got: Vec<u8> = got16.iter().map(|&s| s as u8).collect(); | ||
| 5081 | + assert_eq!(got.len(), want.len(), "frame {i} {name} plane size"); | ||
| 5082 | + if let Some(at) = got.iter().zip(want.iter()).position(|(x, y)| x != y) { | ||
| 5083 | + panic!( | ||
| 5084 | + "frame {i}: {name} differs first at ({}, {}): ours {} vs ffmpeg {}", | ||
| 5085 | + at % w, | ||
| 5086 | + at / w, | ||
| 5087 | + got[at], | ||
| 5088 | + want[at], | ||
| 5089 | + ); | ||
| 5090 | + } | ||
| 5091 | + } | ||
| 5092 | + } | ||
| 5093 | + } else { | ||
| 5094 | + eprintln!("SKIP the ffmpeg half: no ffmpeg"); | ||
| 5095 | + } | ||
| 5096 | + } | ||
| 4996 | 5097 | ||
| 4997 | /// Every SHIPPED SPEED PRESET codes a stream both decoders reconstruct | 5098 | /// Every SHIPPED SPEED PRESET codes a stream both decoders reconstruct |
| 4998 | /// sample-exact -- ours and ffmpeg's -- and codes a DIFFERENT stream from | 5099 | /// sample-exact -- ours and ffmpeg's -- and codes a DIFFERENT stream from |
crates/ec-av1/src/tile.rsmodified+34 -2
| @@ -4827,6 +4827,7 @@ fn write_block( | |||
| 4827 | tx_mode, | 4827 | tx_mode, |
| 4828 | tx_select, | 4828 | tx_select, |
| 4829 | block_tx_type(block), | 4829 | block_tx_type(block), |
| 4830 | + false, | ||
| 4830 | ); | 4831 | ); |
| 4831 | neighbours.record_planes(at, side, mode, grids, !split); | 4832 | neighbours.record_planes(at, side, mode, grids, !split); |
| 4832 | clear_skip_band(neighbours, at_mi, side); | 4833 | clear_skip_band(neighbours, at_mi, side); |
| @@ -4927,6 +4928,7 @@ fn write_leaf8( | |||
| 4927 | tx_mode, | 4928 | tx_mode, |
| 4928 | tx_select, | 4929 | tx_select, |
| 4929 | block_tx_type(block), | 4930 | block_tx_type(block), |
| 4931 | + false, | ||
| 4930 | ); | 4932 | ); |
| 4931 | neighbours.record_mi_planes(leaf_mi, 8, grids, !split); | 4933 | neighbours.record_mi_planes(leaf_mi, 8, grids, !split); |
| 4932 | clear_skip_band(neighbours, leaf_mi, 8); | 4934 | clear_skip_band(neighbours, leaf_mi, 8); |
| @@ -4951,7 +4953,20 @@ fn write_block_planes( | |||
| 4951 | // This block's single luma transform type (lane-txset); chroma's is | 4953 | // This block's single luma transform type (lane-txset); chroma's is |
| 4952 | // derived from its mode by the decoder and codes no symbol. | 4954 | // derived from its mode by the decoder and codes no symbol. |
| 4953 | luma_tx_type: TxType, | 4955 | luma_tx_type: TxType, |
| 4956 | + // lane-intertx: an INTER block's chroma transforms INHERIT the luma | ||
| 4957 | + // type (reduced to the chroma set against this frame's own | ||
| 4958 | + // `reduced_tx_set` bit); an intra block's comes off its UV mode and | ||
| 4959 | + // rides `DCT_DCT`'s 2D class exactly as before. | ||
| 4960 | + inter: bool, | ||
| 4954 | ) { | 4961 | ) { |
| 4962 | + // lane-intertx, desync (b): the writer used to code every chroma plane | ||
| 4963 | + // `DCT_DCT`. Chroma codes no `tx_type` symbol, but the type names the | ||
| 4964 | + // transform class, and the class picks the scan, the `eob_pt` row and | ||
| 4965 | + // the context offsets (the lane-txw note in `write_coeffs`) -- so an | ||
| 4966 | + // inherited 1-D luma type desynced the chroma exactly as luma itself | ||
| 4967 | + // once did. The reduced bit read here is the frame's own header bit, | ||
| 4968 | + // the ONE the writer's `Cdfs` is armed with (`Cdfs::reduced_tx_set`). | ||
| 4969 | + let reduced = cdfs.reduced_tx_set; | ||
| 4955 | for (plane, (grid, scan)) in grids.iter().zip(scans.iter()).enumerate() { | 4970 | for (plane, (grid, scan)) in grids.iter().zip(scans.iter()).enumerate() { |
| 4956 | if plane == 0 && skip_luma { | 4971 | if plane == 0 && skip_luma { |
| 4957 | continue; | 4972 | continue; |
| @@ -4969,15 +4984,28 @@ fn write_block_planes( | |||
| 4969 | let before = enc.tell(); | 4984 | let before = enc.tell(); |
| 4970 | #[cfg(test)] | 4985 | #[cfg(test)] |
| 4971 | let q_ctx = cdfs.q_ctx; | 4986 | let q_ctx = cdfs.q_ctx; |
| 4987 | + let mut coding = cdfs.txb(planes[plane], mode); | ||
| 4988 | + let tx_type = if plane == 0 { | ||
| 4989 | + luma_tx_type | ||
| 4990 | + } else if inter { | ||
| 4991 | + crate::decode::reduce_inherited_chroma_tx_type_flagged( | ||
| 4992 | + luma_tx_type, | ||
| 4993 | + coding.side.min(32), | ||
| 4994 | + coding.side.min(32), | ||
| 4995 | + reduced, | ||
| 4996 | + ) | ||
| 4997 | + } else { | ||
| 4998 | + TxType::DctDct | ||
| 4999 | + }; | ||
| 4972 | write_coeffs( | 5000 | write_coeffs( |
| 4973 | enc, | 5001 | enc, |
| 4974 | - &mut cdfs.txb(planes[plane], mode), | 5002 | + &mut coding, |
| 4975 | grid, | 5003 | grid, |
| 4976 | scan, | 5004 | scan, |
| 4977 | skip_ctx, | 5005 | skip_ctx, |
| 4978 | dc_sign_ctx(around[plane].dc_vote), | 5006 | dc_sign_ctx(around[plane].dc_vote), |
| 4979 | Some(plane), | 5007 | Some(plane), |
| 4980 | - if plane == 0 { luma_tx_type } else { TxType::DctDct }, | 5008 | + tx_type, |
| 4981 | ); | 5009 | ); |
| 4982 | #[cfg(test)] | 5010 | #[cfg(test)] |
| 4983 | census_record( | 5011 | census_record( |
| @@ -7474,6 +7502,7 @@ pub(crate) fn sb_coeff_inter_frame_tile_cdfs( | |||
| 7474 | 0, | 7502 | 0, |
| 7475 | split, | 7503 | split, |
| 7476 | block_tx_type(block), | 7504 | block_tx_type(block), |
| 7505 | + true, | ||
| 7477 | ); | 7506 | ); |
| 7478 | neighbours.record_planes(sb_at, SB, 0, &grids, !split); | 7507 | neighbours.record_planes(sb_at, SB, 0, &grids, !split); |
| 7479 | } | 7508 | } |
| @@ -7938,6 +7967,7 @@ pub(crate) fn sb_coeff_inter_frame_tile_cdfs( | |||
| 7938 | mode_for_tx, | 7967 | mode_for_tx, |
| 7939 | split, | 7968 | split, |
| 7940 | block_tx_type(block), | 7969 | block_tx_type(block), |
| 7970 | + is_inter, | ||
| 7941 | ); | 7971 | ); |
| 7942 | neighbours.record_planes(at, BLOCK, mode_for_tx, &grids, !split); | 7972 | neighbours.record_planes(at, BLOCK, mode_for_tx, &grids, !split); |
| 7943 | } | 7973 | } |
| @@ -8179,6 +8209,7 @@ fn write_inter_frame_leaf( | |||
| 8179 | mode_for_tx, | 8209 | mode_for_tx, |
| 8180 | split, | 8210 | split, |
| 8181 | block_tx_type(block), | 8211 | block_tx_type(block), |
| 8212 | + is_inter, | ||
| 8182 | ); | 8213 | ); |
| 8183 | neighbours.record_planes(at, SUB, mode_for_tx, &grids, !split); | 8214 | neighbours.record_planes(at, SUB, mode_for_tx, &grids, !split); |
| 8184 | } | 8215 | } |
| @@ -8432,6 +8463,7 @@ fn write_inter_frame_leaf8( | |||
| 8432 | mode_for_tx, | 8463 | mode_for_tx, |
| 8433 | split, | 8464 | split, |
| 8434 | block_tx_type(block), | 8465 | block_tx_type(block), |
| 8466 | + is_inter, | ||
| 8435 | ); | 8467 | ); |
| 8436 | neighbours.record_mi_planes(leaf_mi, 8, &grids, !split); | 8468 | neighbours.record_mi_planes(leaf_mi, 8, &grids, !split); |
| 8437 | neighbours.record_inter_mi(leaf_mi, 8, block.skip, is_inter, block_ref(block)); | 8469 | neighbours.record_inter_mi(leaf_mi, 8, block.skip, is_inter, block_ref(block)); |