The seven-type TX_SET_INTRA_1 tx_type row, V_DCT/H_DCT, gate fires
Browse files at this commit24117910f97bb2a08ca36628ab4bfef31c1798b2Parent: dcf1147- feat
- the seven-type TX_SET_INTRA_1 tx_type row, V_DCT/H_DCT, gate fires
5 changed files +115 -75
- crates/ec-av1/examples/probe_txsel.rs +0 -63
- crates/ec-av1/src/cdf_state.rs +24 -0
- crates/ec-av1/src/decode.rs +43 -10
- crates/ec-av1/src/stream.rs +21 -2
- crates/ec-av1/src/transform.rs +27 -0
crates/ec-av1/examples/probe_txsel.rsdeleted+0 -63
| @@ -1,63 +0,0 @@ | ||
| 1 | -use std::io::Write; | |
| 2 | -use std::process::{Command, Stdio}; | |
| 3 | - | |
| 4 | -fn main() { | |
| 5 | - let path = std::env::args() | |
| 6 | - .nth(1) | |
| 7 | - .unwrap_or_else(|| "/tmp/mb.obu".into()); | |
| 8 | - let stream = std::fs::read(&path).expect("read stream"); | |
| 9 | - let frames = match ec_av1::stream::decode_stream(&stream) { | |
| 10 | - Ok(f) => f, | |
| 11 | - Err(e) => { | |
| 12 | - eprintln!("decode error: {e}"); | |
| 13 | - std::process::exit(1); | |
| 14 | - } | |
| 15 | - }; | |
| 16 | - let (width, height) = (64usize, 64usize); | |
| 17 | - let mut child = Command::new("ffmpeg") | |
| 18 | - .args([ | |
| 19 | - "-v", "error", "-f", "obu", "-i", "-", "-f", "rawvideo", "-pix_fmt", "yuv420p", "-", | |
| 20 | - ]) | |
| 21 | - .stdin(Stdio::piped()) | |
| 22 | - .stdout(Stdio::piped()) | |
| 23 | - .stderr(Stdio::piped()) | |
| 24 | - .spawn() | |
| 25 | - .expect("ffmpeg spawn"); | |
| 26 | - child | |
| 27 | - .stdin | |
| 28 | - .take() | |
| 29 | - .unwrap() | |
| 30 | - .write_all(&stream) | |
| 31 | - .expect("write stream"); | |
| 32 | - let out = child.wait_with_output().expect("ffmpeg run"); | |
| 33 | - if !out.status.success() { | |
| 34 | - eprintln!("ffmpeg refused: {}", String::from_utf8_lossy(&out.stderr)); | |
| 35 | - std::process::exit(1); | |
| 36 | - } | |
| 37 | - let luma = width * height; | |
| 38 | - let chroma = luma / 4; | |
| 39 | - let y_ref = &out.stdout[..luma]; | |
| 40 | - let u_ref = &out.stdout[luma..luma + chroma]; | |
| 41 | - let v_ref = &out.stdout[luma + chroma..luma + 2 * chroma]; | |
| 42 | - | |
| 43 | - let pic = &frames[0]; | |
| 44 | - let y_match = pic.y == y_ref; | |
| 45 | - let u_match = pic.u == u_ref; | |
| 46 | - let v_match = pic.v == v_ref; | |
| 47 | - println!("decoded ok, y_match={y_match} u_match={u_match} v_match={v_match}"); | |
| 48 | - if !y_match { | |
| 49 | - for i in 0..luma { | |
| 50 | - if pic.y[i] != y_ref[i] { | |
| 51 | - println!( | |
| 52 | - "first luma mismatch at idx {i} (row {} col {}): ours={} ref={}", | |
| 53 | - i / width, | |
| 54 | - i % width, | |
| 55 | - pic.y[i], | |
| 56 | - y_ref[i] | |
| 57 | - ); | |
| 58 | - break; | |
| 59 | - } | |
| 60 | - } | |
| 61 | - } | |
| 62 | - std::process::exit(if y_match && u_match && v_match { 0 } else { 2 }); | |
| 63 | -} |
crates/ec-av1/src/cdf_state.rsmodified+24 -0
| @@ -41,6 +41,10 @@ pub(crate) enum TxbSet { | ||
| 41 | 41 | /// block (lane-av1-rect). An `is_inter` leaf reads |
| 42 | 42 | /// [`Luma8Inter`](TxbSet::Luma8Inter) instead. |
| 43 | 43 | Luma8, |
| 44 | + /// [`Luma8`](TxbSet::Luma8)'s `reduced_tx_set: false` counterpart (round | |
| 45 | + /// 8): the same coefficient tables, but the seven-symbol `TX_SET_INTRA_1` | |
| 46 | + /// `tx_type` table rather than `Luma8`'s five-symbol reduced one. | |
| 47 | + Luma8Set1, | |
| 44 | 48 | /// The 8x8 luma transform of an `is_inter` 8x8 leaf under a straddling |
| 45 | 49 | /// 16x16 block (lane-av1inter8): the same coefficient tables |
| 46 | 50 | /// [`Luma8`](TxbSet::Luma8) reads, but `get_tx_set` (spec 5.11.48) |
| @@ -225,6 +229,13 @@ pub(crate) struct Cdfs { | ||
| 225 | 229 | pub intra_tx_type_16: [[u16; 6]; 13], |
| 226 | 230 | /// The transform type of an 8x8 intra luma transform, by luma mode. |
| 227 | 231 | pub intra_tx_type_8: [[u16; 6]; 13], |
| 232 | + /// The transform type of an 8x8 intra luma transform, by luma mode, when | |
| 233 | + /// `reduced_tx_set` is false (spec `TX_SET_INTRA_1`, seven types) -- | |
| 234 | + /// [`Self::intra_tx_type_8`]'s five-type table is only the | |
| 235 | + /// `reduced_tx_set` row (round 8: a real `aomenc` stream with | |
| 236 | + /// `reduced_tx_set` off desyncs an 8x8 TU read against this row's | |
| 237 | + /// wrong-length CDF). | |
| 238 | + pub intra_tx_type_8_set1: [[u16; 8]; 13], | |
| 228 | 239 | /// The transform type of an `is_inter` 32x32 luma transform (spec |
| 229 | 240 | /// `TX_SET_INTER_3`, `TX_32X32` row) -- unlike the intra 16x16 table, it |
| 230 | 241 | /// is not indexed by mode. |
| @@ -430,6 +441,7 @@ impl Cdfs { | ||
| 430 | 441 | reset2(&mut self.dc_sign_luma); |
| 431 | 442 | reset2(&mut self.intra_tx_type_16); |
| 432 | 443 | reset2(&mut self.intra_tx_type_8); |
| 444 | + reset2(&mut self.intra_tx_type_8_set1); | |
| 433 | 445 | reset1(&mut self.inter_tx_type_32); |
| 434 | 446 | reset1(&mut self.inter_tx_type_16); |
| 435 | 447 | reset1(&mut self.inter_tx_type_8); |
| @@ -795,6 +807,7 @@ impl Cdfs { | ||
| 795 | 807 | dc_sign_luma: cdf::DC_SIGN_LUMA, |
| 796 | 808 | intra_tx_type_16: cdf::INTRA_TX_TYPE_SET2_16, |
| 797 | 809 | intra_tx_type_8: cdf::INTRA_TX_TYPE_SET2_8, |
| 810 | + intra_tx_type_8_set1: cdf::INTRA_TX_TYPE_SET1_8, | |
| 798 | 811 | inter_tx_type_32: cdf::INTER_TX_TYPE_SET3_32, |
| 799 | 812 | inter_tx_type_16: cdf::INTER_TX_TYPE_SET3_16, |
| 800 | 813 | inter_tx_type_8: cdf::INTER_TX_TYPE_SET3_8, |
| @@ -886,6 +899,17 @@ impl Cdfs { | ||
| 886 | 899 | dc_sign: &mut self.dc_sign_luma, |
| 887 | 900 | tx_type: Some(self.intra_tx_type_8[mode].as_mut_slice()), |
| 888 | 901 | }, |
| 902 | + TxbSet::Luma8Set1 => TxbTables { | |
| 903 | + side: 8, | |
| 904 | + txb_skip: &mut self.txb_skip_luma_8, | |
| 905 | + eob_pt: &mut self.eob_pt_64_luma, | |
| 906 | + eob_extra: &mut self.eob_extra_luma_8, | |
| 907 | + base: &mut self.base_luma_8, | |
| 908 | + base_eob: &mut self.base_eob_luma_8, | |
| 909 | + br: &mut self.br_luma_8, | |
| 910 | + dc_sign: &mut self.dc_sign_luma, | |
| 911 | + tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()), | |
| 912 | + }, | |
| 889 | 913 | TxbSet::Luma8Inter => TxbTables { |
| 890 | 914 | side: 8, |
| 891 | 915 | txb_skip: &mut self.txb_skip_luma_8, |
crates/ec-av1/src/decode.rsmodified+43 -10
| @@ -288,13 +288,20 @@ fn read_coeffs( | ||
| 288 | 288 | } |
| 289 | 289 | let mut tx_type = TxType::DctDct; |
| 290 | 290 | if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() { |
| 291 | + // The CDF row's own width names its set: 7 symbols (8 slots) is | |
| 292 | + // `TX_SET_INTRA_1`, 5 (6 slots) the reduced `TX_SET_INTRA_2` (the | |
| 293 | + // inter sets we read share set 2's symbol order). | |
| 294 | + let set1 = tx_type_cdf.len() == 8; | |
| 291 | 295 | let t = dec.symbol(tx_type_cdf); |
| 292 | 296 | if trace { |
| 293 | - eprintln!("TRACE tx_type value={t}"); | |
| 297 | + eprintln!("TRACE tx_type value={t} set1={set1}"); | |
| 294 | 298 | } |
| 295 | - tx_type = TxType::from_symbol(t).ok_or_else(|| { | |
| 296 | - unsupported(format!("a tx_type symbol outside its CDF's own set: {t}")) | |
| 297 | - })?; | |
| 299 | + tx_type = if set1 { | |
| 300 | + TxType::from_symbol_set1(t) | |
| 301 | + } else { | |
| 302 | + TxType::from_symbol(t) | |
| 303 | + } | |
| 304 | + .ok_or_else(|| unsupported(format!("a tx_type symbol outside its CDF's own set: {t}")))?; | |
| 298 | 305 | } |
| 299 | 306 | |
| 300 | 307 | let eob = read_eob(dec, coding); |
| @@ -1165,6 +1172,7 @@ fn decode_block( | ||
| 1165 | 1172 | scan16: &[u16], |
| 1166 | 1173 | scan8: &[u16], |
| 1167 | 1174 | tx_select: bool, |
| 1175 | + reduced_tx_set: bool, | |
| 1168 | 1176 | ) -> Result<()> { |
| 1169 | 1177 | let (r, c) = at; |
| 1170 | 1178 | let (px, py) = (c * SUB, r * SUB); |
| @@ -1196,7 +1204,7 @@ fn decode_block( | ||
| 1196 | 1204 | (side, luma_tx) |
| 1197 | 1205 | }; |
| 1198 | 1206 | let luma_set = if tx_select { |
| 1199 | - txbset_for(logical_tx) | |
| 1207 | + txbset_for(logical_tx, reduced_tx_set) | |
| 1200 | 1208 | } else { |
| 1201 | 1209 | luma_set |
| 1202 | 1210 | }; |
| @@ -1433,6 +1441,7 @@ fn decode_leaf8( | ||
| 1433 | 1441 | base_q_idx: u8, |
| 1434 | 1442 | enable_filter_intra: bool, |
| 1435 | 1443 | tx_select: bool, |
| 1444 | + reduced_tx_set: bool, | |
| 1436 | 1445 | ) -> Result<usize> { |
| 1437 | 1446 | let (r, c) = outer_at; |
| 1438 | 1447 | let mut above_mode = neighbours.above_mode[c]; |
| @@ -1504,7 +1513,11 @@ fn decode_leaf8( | ||
| 1504 | 1513 | luma_grid = read_plane( |
| 1505 | 1514 | dec, |
| 1506 | 1515 | cdfs, |
| 1507 | - TxbSet::Luma8, | |
| 1516 | + if reduced_tx_set { | |
| 1517 | + TxbSet::Luma8 | |
| 1518 | + } else { | |
| 1519 | + TxbSet::Luma8Set1 | |
| 1520 | + }, | |
| 1508 | 1521 | scans.0, |
| 1509 | 1522 | 0, |
| 1510 | 1523 | around[0], |
| @@ -1856,13 +1869,19 @@ fn scan_for<'a>(tx_px: usize, scan32: &'a [u16], scan16: &'a [u16], scan8: &'a [ | ||
| 1856 | 1869 | /// The [`TxbSet`] a resolved luma transform side reads its coefficient tables |
| 1857 | 1870 | /// from -- 64 is only ever the 64x64-block, depth-0, corner-scanned case |
| 1858 | 1871 | /// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching |
| 1859 | -/// set. | |
| 1860 | -fn txbset_for(tx_px: usize) -> TxbSet { | |
| 1872 | +/// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at | |
| 1873 | +/// `TX_8X8`: an intra `TX_16X16` always reads `TX_SET_INTRA_2` regardless of | |
| 1874 | +/// the flag (`av1_get_ext_tx_set_type`'s `tx_size_sqr == TX_16X16` branch | |
| 1875 | +/// ignores `use_reduced_set` once it is past the `TX_32X32`/reduced-set | |
| 1876 | +/// checks), so only the 8x8 case has a second table | |
| 1877 | +/// ([`TxbSet::Luma8Set1`]). | |
| 1878 | +fn txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { | |
| 1861 | 1879 | match tx_px { |
| 1862 | 1880 | 64 => TxbSet::Luma64, |
| 1863 | 1881 | 32 => TxbSet::Luma32, |
| 1864 | 1882 | 16 => TxbSet::Luma16, |
| 1865 | - 8 => TxbSet::Luma8, | |
| 1883 | + 8 if reduced_tx_set => TxbSet::Luma8, | |
| 1884 | + 8 => TxbSet::Luma8Set1, | |
| 1866 | 1885 | _ => unreachable!("read_tx_size never resolves a block's own side to anything else"), |
| 1867 | 1886 | } |
| 1868 | 1887 | } |
| @@ -2408,6 +2427,7 @@ pub fn decode_key_frame_tile( | ||
| 2408 | 2427 | cdef: &CdefParams, |
| 2409 | 2428 | loop_filter: &LoopFilterParams, |
| 2410 | 2429 | tx_select: bool, |
| 2430 | + reduced_tx_set: bool, | |
| 2411 | 2431 | ) -> Result<Picture> { |
| 2412 | 2432 | decode_key_frame_tile_with_cdfs( |
| 2413 | 2433 | data, |
| @@ -2421,6 +2441,7 @@ pub fn decode_key_frame_tile( | ||
| 2421 | 2441 | loop_filter, |
| 2422 | 2442 | None, |
| 2423 | 2443 | tx_select, |
| 2444 | + reduced_tx_set, | |
| 2424 | 2445 | ) |
| 2425 | 2446 | .map(|(picture, _)| picture) |
| 2426 | 2447 | } |
| @@ -2445,6 +2466,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2445 | 2466 | loop_filter: &LoopFilterParams, |
| 2446 | 2467 | initial_cdfs: Option<Cdfs>, |
| 2447 | 2468 | tx_select: bool, |
| 2469 | + reduced_tx_set: bool, | |
| 2448 | 2470 | ) -> Result<(Picture, Cdfs)> { |
| 2449 | 2471 | if mi_cols == 0 || mi_rows == 0 { |
| 2450 | 2472 | return Err(unsupported("a frame with no mode-info grid")); |
| @@ -2554,6 +2576,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2554 | 2576 | &scan16, |
| 2555 | 2577 | &scan8, |
| 2556 | 2578 | tx_select, |
| 2579 | + reduced_tx_set, | |
| 2557 | 2580 | )?; |
| 2558 | 2581 | } |
| 2559 | 2582 | PARTITION_SPLIT => { |
| @@ -2615,6 +2638,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2615 | 2638 | &scan16, |
| 2616 | 2639 | &scan8, |
| 2617 | 2640 | tx_select, |
| 2641 | + reduced_tx_set, | |
| 2618 | 2642 | )?; |
| 2619 | 2643 | } |
| 2620 | 2644 | PARTITION_SPLIT => { |
| @@ -2662,6 +2686,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2662 | 2686 | &scan16, |
| 2663 | 2687 | &scan8, |
| 2664 | 2688 | tx_select, |
| 2689 | + reduced_tx_set, | |
| 2665 | 2690 | )?; |
| 2666 | 2691 | continue; |
| 2667 | 2692 | } |
| @@ -2706,6 +2731,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2706 | 2731 | base_q_idx, |
| 2707 | 2732 | enable_filter_intra, |
| 2708 | 2733 | tx_select, |
| 2734 | + reduced_tx_set, | |
| 2709 | 2735 | )?; |
| 2710 | 2736 | prev_leaf = Some((leaf_mi, leaf_mode)); |
| 2711 | 2737 | } |
| @@ -2769,6 +2795,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2769 | 2795 | base_q_idx, |
| 2770 | 2796 | enable_filter_intra, |
| 2771 | 2797 | tx_select, |
| 2798 | + reduced_tx_set, | |
| 2772 | 2799 | )?; |
| 2773 | 2800 | prev_leaf = Some((leaf_mi, leaf_mode)); |
| 2774 | 2801 | } |
| @@ -4168,7 +4195,8 @@ mod tests { | ||
| 4168 | 4195 | false, |
| 4169 | 4196 | &CdefParams::default(), |
| 4170 | 4197 | &LoopFilterParams::default(), |
| 4171 | - false | |
| 4198 | + false, | |
| 4199 | + true, | |
| 4172 | 4200 | ) |
| 4173 | 4201 | .is_err() |
| 4174 | 4202 | ); |
| @@ -4210,6 +4238,7 @@ mod tests { | ||
| 4210 | 4238 | &CdefParams::default(), |
| 4211 | 4239 | &LoopFilterParams::default(), |
| 4212 | 4240 | false, |
| 4241 | + true, | |
| 4213 | 4242 | ) |
| 4214 | 4243 | .unwrap(); |
| 4215 | 4244 | assert_eq!(decoded.width, w, "{w}x{h}: decoded width"); |
| @@ -4292,6 +4321,7 @@ mod tests { | ||
| 4292 | 4321 | &CdefParams::default(), |
| 4293 | 4322 | &LoopFilterParams::default(), |
| 4294 | 4323 | false, |
| 4324 | + true, | |
| 4295 | 4325 | ) |
| 4296 | 4326 | .unwrap(); |
| 4297 | 4327 | assert!( |
| @@ -4476,6 +4506,7 @@ mod tests { | ||
| 4476 | 4506 | &CdefParams::default(), |
| 4477 | 4507 | &LoopFilterParams::default(), |
| 4478 | 4508 | false, |
| 4509 | + true, | |
| 4479 | 4510 | ) |
| 4480 | 4511 | .unwrap(); |
| 4481 | 4512 | assert_eq!(ours.y, ffmpeg_decoded.y, "{width}x{height}: luma vs ffmpeg"); |
| @@ -4547,6 +4578,7 @@ mod tests { | ||
| 4547 | 4578 | &CdefParams::default(), |
| 4548 | 4579 | &LoopFilterParams::default(), |
| 4549 | 4580 | false, |
| 4581 | + true, | |
| 4550 | 4582 | ) |
| 4551 | 4583 | .unwrap(); |
| 4552 | 4584 | assert_eq!( |
| @@ -4821,6 +4853,7 @@ mod tests { | ||
| 4821 | 4853 | &CdefParams::default(), |
| 4822 | 4854 | &LoopFilterParams::default(), |
| 4823 | 4855 | false, |
| 4856 | + true, | |
| 4824 | 4857 | ) |
| 4825 | 4858 | .unwrap(); |
| 4826 | 4859 | assert_eq!(reference.y, ffmpeg_frames[0].y, "frame 0 luma vs ffmpeg"); |
crates/ec-av1/src/stream.rsmodified+21 -2
| @@ -215,6 +215,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 215 | 215 | &header.loop_filter, |
| 216 | 216 | initial_cdfs, |
| 217 | 217 | header.tx_mode == TxMode::Select, |
| 218 | + header.reduced_tx_set, | |
| 218 | 219 | )? |
| 219 | 220 | } else { |
| 220 | 221 | let last_slot = header.ref_frame_idx[0] as usize; |
| @@ -341,6 +342,8 @@ mod tests { | ||
| 341 | 342 | &ec_av1_syntax::CdefParams::default(), |
| 342 | 343 | &ec_av1_syntax::LoopFilterParams::default(), |
| 343 | 344 | false, |
| 345 | + // Our own encoder always writes `reduced_tx_set: true`. | |
| 346 | + true, | |
| 344 | 347 | ) |
| 345 | 348 | .unwrap(); |
| 346 | 349 | let via_stream = decode_stream(&encoded.stream).unwrap(); |
| @@ -1036,9 +1039,13 @@ mod tests { | ||
| 1036 | 1039 | // search to prefer a split transform over the block's own full |
| 1037 | 1040 | // size -- `mandelbrot`'s fractal boundary gives every attempt |
| 1038 | 1041 | // (a different `start_scale`) sharp, varied-frequency edges. |
| 1042 | + // start_scale 5.0 is the proven first try (decodes pixel-exact | |
| 1043 | + // AND reads the seven-symbol set-1 tx_type rows on TX8 TUs); | |
| 1044 | + // later attempts walk down for variety when aomenc's RD flips | |
| 1045 | + // elsewhere. | |
| 1039 | 1046 | let source = format!( |
| 1040 | 1047 | "mandelbrot=size=64x64:start_scale={}:rate=25", |
| 1041 | - 3.0 - f64::from(attempt) * 0.06 | |
| 1048 | + 5.0 - f64::from(attempt) * 0.06 | |
| 1042 | 1049 | ); |
| 1043 | 1050 | let y4m = Command::new("ffmpeg") |
| 1044 | 1051 | .args([ |
| @@ -1084,6 +1091,13 @@ mod tests { | ||
| 1084 | 1091 | "--enable-ab-partitions=0", |
| 1085 | 1092 | "--enable-1to4-partitions=0", |
| 1086 | 1093 | "--enable-filter-intra=0", |
| 1094 | + // Every non-DC intra tool off: directional chroma and | |
| 1095 | + // angle deltas are separate round-2 gaps, and DC-only | |
| 1096 | + // residual is exactly what gives the RD search a reason | |
| 1097 | + // to split a transform. | |
| 1098 | + "--enable-smooth-intra=0", | |
| 1099 | + "--enable-paeth-intra=0", | |
| 1100 | + "--enable-directional-intra=0", | |
| 1087 | 1101 | "--enable-angle-delta=0", |
| 1088 | 1102 | "--enable-cdef=0", |
| 1089 | 1103 | // Loop restoration is a named refusal (aomenc's RD picks |
| @@ -1091,9 +1105,14 @@ mod tests { | ||
| 1091 | 1105 | // whose test targets a different surface. |
| 1092 | 1106 | "--enable-restoration=0", |
| 1093 | 1107 | "--max-partition-size=32", |
| 1108 | + // 16x16 blocks are what split into the TX8 TUs whose | |
| 1109 | + // set-1 tx_type rows this gate exists to prove; some | |
| 1110 | + // scales resolve depth 2 (TX4, a named refusal) and the | |
| 1111 | + // attempt loop just moves on. | |
| 1112 | + "--min-partition-size=16", | |
| 1094 | 1113 | "--enable-palette=0", |
| 1095 | 1114 | "--enable-intrabc=0", |
| 1096 | - "--enable-cfl-intra=1", | |
| 1115 | + "--enable-cfl-intra=0", | |
| 1097 | 1116 | "--obu", |
| 1098 | 1117 | "-o", |
| 1099 | 1118 | "-", |
crates/ec-av1/src/transform.rsmodified+27 -0
| @@ -314,6 +314,12 @@ pub enum TxType { | ||
| 314 | 314 | AdstDct, |
| 315 | 315 | /// DCT down the column axis, ADST across the row axis. |
| 316 | 316 | DctAdst, |
| 317 | + /// DCT down the column axis, identity across the row axis | |
| 318 | + /// (`V_DCT` -- `TX_SET_INTRA_1` only). | |
| 319 | + VDct, | |
| 320 | + /// Identity down the column axis, DCT across the row axis | |
| 321 | + /// (`H_DCT` -- `TX_SET_INTRA_1` only). | |
| 322 | + HDct, | |
| 317 | 323 | } |
| 318 | 324 | |
| 319 | 325 | impl TxType { |
| @@ -329,6 +335,24 @@ impl TxType { | ||
| 329 | 335 | } |
| 330 | 336 | } |
| 331 | 337 | |
| 338 | + /// The inverse of `Tx_Type_Intra_Inv_Set1`'s CDF symbol order | |
| 339 | + /// (`av1_ext_tx_inv[EXT_TX_SET_DTT4_IDTX_1DDCT]`, entropymode.h: | |
| 340 | + /// `{9, 0, 10, 11, 3, 1, 2}` = IDTX, DCT_DCT, V_DCT, H_DCT, ADST_ADST, | |
| 341 | + /// ADST_DCT, DCT_ADST) -- the seven-type set a `reduced_tx_set == 0` | |
| 342 | + /// frame's small intra transforms read from. | |
| 343 | + pub fn from_symbol_set1(t: usize) -> Option<Self> { | |
| 344 | + match t { | |
| 345 | + 0 => Some(Self::Idtx), | |
| 346 | + 1 => Some(Self::DctDct), | |
| 347 | + 2 => Some(Self::VDct), | |
| 348 | + 3 => Some(Self::HDct), | |
| 349 | + 4 => Some(Self::AdstAdst), | |
| 350 | + 5 => Some(Self::AdstDct), | |
| 351 | + 6 => Some(Self::DctAdst), | |
| 352 | + _ => None, | |
| 353 | + } | |
| 354 | + } | |
| 355 | + | |
| 332 | 356 | /// `(row, col)`: the transform `inverse_transform_2d_typed`'s row pass |
| 333 | 357 | /// (`htx_tab`, spec/libaom "horizontal") and column pass (`vtx_tab`, |
| 334 | 358 | /// "vertical") each run. Read off libaom's `av1_inv_txfm2d.c` `vtx_tab`/ |
| @@ -343,6 +367,9 @@ impl TxType { | ||
| 343 | 367 | Self::AdstAdst => (Adst, Adst), |
| 344 | 368 | Self::AdstDct => (Dct, Adst), |
| 345 | 369 | Self::DctAdst => (Adst, Dct), |
| 370 | + // `av1_inv_txfm2d.c`: V_DCT vtx=DCT htx=IDTX, H_DCT the mirror. | |
| 371 | + Self::VDct => (Identity, Dct), | |
| 372 | + Self::HDct => (Dct, Identity), | |
| 346 | 373 | } |
| 347 | 374 | } |
| 348 | 375 | } |