Read the unread use_filter_intra flag
Browse files at this commitbeeeec5972c4e7264be4f38a4a97b46b902af65aParent: 120854a- fix
- read the unread use_filter_intra flag
- audit the same blindness class
4 changed files +127 -6
- crates/ec-av1/src/cdf.rs +14 -0
- crates/ec-av1/src/cdf_state.rs +7 -0
- crates/ec-av1/src/decode.rs +73 -5
- crates/ec-av1/src/stream.rs +33 -1
crates/ec-av1/src/cdf.rsmodified+14 -0
| @@ -312,6 +312,20 @@ pub const UV_MODE_CFL: [[u16; 15]; 13] = [ | |||
| 312 | /// the spec's own table, is `AOM_ICDF`-inverted). | 312 | /// the spec's own table, is `AOM_ICDF`-inverted). |
| 313 | pub const CFL_SIGN: [u16; 9] = [1418, 2123, 13340, 18405, 26972, 28343, 32294, 32768, 0]; | 313 | pub const CFL_SIGN: [u16; 9] = [1418, 2123, 13340, 18405, 26972, 28343, 32294, 32768, 0]; |
| 314 | 314 | ||
| 315 | +/// `default_filter_intra_cdfs` (entropymode.c), the `use_filter_intra` flag's | ||
| 316 | +/// prior, indexed by block-size class: `[0]`=4x4, `[1]`=8x8, `[2]`=16x16, | ||
| 317 | +/// `[3]`=32x32 -- the only square sizes `av1_filter_intra_allowed_bsize` | ||
| 318 | +/// (width and height both <=32) ever offers this decoder's square blocks. | ||
| 319 | +pub const FILTER_INTRA: [[u16; 3]; 4] = [ | ||
| 320 | + [4621, 32768, 0], | ||
| 321 | + [7866, 32768, 0], | ||
| 322 | + [12408, 32768, 0], | ||
| 323 | + [22343, 32768, 0], | ||
| 324 | +]; | ||
| 325 | +/// `default_filter_intra_mode_cdf` (entropymode.c): which of the five | ||
| 326 | +/// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. | ||
| 327 | +pub const FILTER_INTRA_MODE: [u16; 6] = [8949, 12776, 17211, 29558, 32768, 0]; | ||
| 328 | + | ||
| 315 | /// `Default_Cfl_Alpha_Cdf` (spec 9.4): a `UV_CFL_PRED` block's per-plane | 329 | /// `Default_Cfl_Alpha_Cdf` (spec 9.4): a `UV_CFL_PRED` block's per-plane |
| 316 | /// alpha magnitude (spec 5.11.45's `cfl_alpha_u`/`cfl_alpha_v`), indexed by | 330 | /// alpha magnitude (spec 5.11.45's `cfl_alpha_u`/`cfl_alpha_v`), indexed by |
| 317 | /// the joint sign's context (`CFL_CONTEXT_U`/`CFL_CONTEXT_V`, | 331 | /// the joint sign's context (`CFL_CONTEXT_U`/`CFL_CONTEXT_V`, |
crates/ec-av1/src/cdf_state.rsmodified+7 -0
| @@ -239,6 +239,11 @@ pub(crate) struct Cdfs { | |||
| 239 | /// The two motion vector components' own tables: separate owned state, | 239 | /// The two motion vector components' own tables: separate owned state, |
| 240 | /// since spec 8.3.2 adapts one component without touching the other. | 240 | /// since spec 8.3.2 adapts one component without touching the other. |
| 241 | pub mv_comp: [MvComponentCdfs; 2], | 241 | pub mv_comp: [MvComponentCdfs; 2], |
| 242 | + /// The `use_filter_intra` flag, indexed by block-size class (`[0]`=4x4, | ||
| 243 | + /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32) -- see [`cdf::FILTER_INTRA`]. | ||
| 244 | + pub filter_intra: [[u16; 3]; 4], | ||
| 245 | + /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks. | ||
| 246 | + pub filter_intra_mode: [u16; 6], | ||
| 242 | } | 247 | } |
| 243 | 248 | ||
| 244 | /// One motion vector component's adapting state (spec 9.4's `Default_Mv_*`, | 249 | /// One motion vector component's adapting state (spec 9.4's `Default_Mv_*`, |
| @@ -643,6 +648,8 @@ impl Cdfs { | |||
| 643 | drl_mode: cdf::DRL_MODE, | 648 | drl_mode: cdf::DRL_MODE, |
| 644 | mv_joint: cdf::MV_JOINT, | 649 | mv_joint: cdf::MV_JOINT, |
| 645 | mv_comp: [MvComponentCdfs::new(), MvComponentCdfs::new()], | 650 | mv_comp: [MvComponentCdfs::new(), MvComponentCdfs::new()], |
| 651 | + filter_intra: cdf::FILTER_INTRA, | ||
| 652 | + filter_intra_mode: cdf::FILTER_INTRA_MODE, | ||
| 646 | } | 653 | } |
| 647 | } | 654 | } |
| 648 | 655 | ||
crates/ec-av1/src/decode.rsmodified+73 -5
| @@ -557,12 +557,27 @@ impl Neighbours { | |||
| 557 | /// offered (`cfl`, `is_cfl_allowed`, spec 5.11.5), chroma-from-luma -- the | 557 | /// offered (`cfl`, `is_cfl_allowed`, spec 5.11.5), chroma-from-luma -- the |
| 558 | /// third element carries that mode's `(alpha_q3_u, alpha_q3_v)`, `None` for | 558 | /// third element carries that mode's `(alpha_q3_u, alpha_q3_v)`, `None` for |
| 559 | /// plain DC chroma. | 559 | /// plain DC chroma. |
| 560 | +/// A block-size class index into [`cdf::FILTER_INTRA`]/`Cdfs::filter_intra`, | ||
| 561 | +/// or `None` when `side` is past `av1_filter_intra_allowed_bsize`'s <=32 | ||
| 562 | +/// bound (spec `filter_intra_mode_info` never reads a symbol there). | ||
| 563 | +fn filter_intra_size_class(side: usize) -> Option<usize> { | ||
| 564 | + match side { | ||
| 565 | + 4 => Some(0), | ||
| 566 | + 8 => Some(1), | ||
| 567 | + 16 => Some(2), | ||
| 568 | + 32 => Some(3), | ||
| 569 | + _ => None, | ||
| 570 | + } | ||
| 571 | +} | ||
| 572 | + | ||
| 560 | fn read_intra_mode( | 573 | fn read_intra_mode( |
| 561 | dec: &mut SymbolDecoder, | 574 | dec: &mut SymbolDecoder, |
| 562 | cdfs: &mut Cdfs, | 575 | cdfs: &mut Cdfs, |
| 563 | above_mode: usize, | 576 | above_mode: usize, |
| 564 | left_mode: usize, | 577 | left_mode: usize, |
| 565 | cfl: bool, | 578 | cfl: bool, |
| 579 | + side: usize, | ||
| 580 | + enable_filter_intra: bool, | ||
| 566 | ) -> Result<(bool, usize, Option<(i32, i32)>)> { | 581 | ) -> Result<(bool, usize, Option<(i32, i32)>)> { |
| 567 | let trace = std::env::var_os("EC_AV1_TRACE").is_some(); | 582 | let trace = std::env::var_os("EC_AV1_TRACE").is_some(); |
| 568 | let skip = dec.symbol(&mut cdfs.skip[0]) != 0; | 583 | let skip = dec.symbol(&mut cdfs.skip[0]) != 0; |
| @@ -601,6 +616,36 @@ fn read_intra_mode( | |||
| 601 | } else { | 616 | } else { |
| 602 | return Err(unsupported("a directional chroma mode (round 2)")); | 617 | return Err(unsupported("a directional chroma mode (round 2)")); |
| 603 | }; | 618 | }; |
| 619 | + // `read_filter_intra_mode_info` (spec 5.11.14, libaom decodemv.c): a | ||
| 620 | + // `use_filter_intra` symbol this decoder never read at all until | ||
| 621 | + // lane-av1real r10 -- silently skipping it left every bit past a | ||
| 622 | + // DC_PRED block at <=32x32 read one symbol short of libaom for the rest | ||
| 623 | + // of the tile (the pinned CfL stream's actual bug: partition/skip/mode | ||
| 624 | + // matched bit-exact, then `eob_pt` read 5 instead of 6, because this | ||
| 625 | + // symbol's bits were never consumed). | ||
| 626 | + if mode == DC_PRED | ||
| 627 | + && enable_filter_intra | ||
| 628 | + && let Some(class) = filter_intra_size_class(side) | ||
| 629 | + { | ||
| 630 | + let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[class]) != 0; | ||
| 631 | + if trace { | ||
| 632 | + eprintln!( | ||
| 633 | + "TRACE use_filter_intra side={side} value={}", | ||
| 634 | + use_filter_intra as i32 | ||
| 635 | + ); | ||
| 636 | + } | ||
| 637 | + if use_filter_intra { | ||
| 638 | + // libaom still reads `filter_intra_mode` to stay in sync, but | ||
| 639 | + // this decoder does not implement filter-intra prediction | ||
| 640 | + // (spec 7.11.2.3's 5-tap recursive filter) -- refuse rather | ||
| 641 | + // than silently miscode the reconstruction, the same pattern | ||
| 642 | + // as this crate's other `Error::unsupported` refusals. | ||
| 643 | + let _ = dec.symbol(&mut cdfs.filter_intra_mode); | ||
| 644 | + return Err(unsupported( | ||
| 645 | + "a filter-intra block (this decoder does not implement the 5.11.14 recursive predictor)", | ||
| 646 | + )); | ||
| 647 | + } | ||
| 648 | + } | ||
| 604 | Ok((skip, mode, alpha)) | 649 | Ok((skip, mode, alpha)) |
| 605 | } | 650 | } |
| 606 | 651 | ||
| @@ -856,6 +901,7 @@ fn decode_block( | |||
| 856 | u: &mut PlaneBuf, | 901 | u: &mut PlaneBuf, |
| 857 | v: &mut PlaneBuf, | 902 | v: &mut PlaneBuf, |
| 858 | base_q_idx: u8, | 903 | base_q_idx: u8, |
| 904 | + enable_filter_intra: bool, | ||
| 859 | ) -> Result<()> { | 905 | ) -> Result<()> { |
| 860 | let (r, c) = at; | 906 | let (r, c) = at; |
| 861 | let (px, py) = (c * SUB, r * SUB); | 907 | let (px, py) = (c * SUB, r * SUB); |
| @@ -865,6 +911,8 @@ fn decode_block( | |||
| 865 | neighbours.above_mode[c], | 911 | neighbours.above_mode[c], |
| 866 | neighbours.left_mode[r], | 912 | neighbours.left_mode[r], |
| 867 | cfl, | 913 | cfl, |
| 914 | + side, | ||
| 915 | + enable_filter_intra, | ||
| 868 | )?; | 916 | )?; |
| 869 | let reach = Reach::of(side, px, py, y.width, y.height); | 917 | let reach = Reach::of(side, px, py, y.width, y.height); |
| 870 | let (luma_grid, u_grid, v_grid); | 918 | let (luma_grid, u_grid, v_grid); |
| @@ -966,6 +1014,7 @@ fn decode_leaf8( | |||
| 966 | u: &mut PlaneBuf, | 1014 | u: &mut PlaneBuf, |
| 967 | v: &mut PlaneBuf, | 1015 | v: &mut PlaneBuf, |
| 968 | base_q_idx: u8, | 1016 | base_q_idx: u8, |
| 1017 | + enable_filter_intra: bool, | ||
| 969 | ) -> Result<usize> { | 1018 | ) -> Result<usize> { |
| 970 | let (r, c) = outer_at; | 1019 | let (r, c) = outer_at; |
| 971 | let mut above_mode = neighbours.above_mode[c]; | 1020 | let mut above_mode = neighbours.above_mode[c]; |
| @@ -980,7 +1029,15 @@ fn decode_leaf8( | |||
| 980 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec | 1029 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec |
| 981 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other | 1030 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other |
| 982 | // `decode_block` caller at 16x16 and up. | 1031 | // `decode_block` caller at 16x16 and up. |
| 983 | - let (skip, mode, alpha) = read_intra_mode(dec, cdfs, above_mode, left_mode, true)?; | 1032 | + let (skip, mode, alpha) = read_intra_mode( |
| 1033 | + dec, | ||
| 1034 | + cdfs, | ||
| 1035 | + above_mode, | ||
| 1036 | + left_mode, | ||
| 1037 | + true, | ||
| 1038 | + 8, | ||
| 1039 | + enable_filter_intra, | ||
| 1040 | + )?; | ||
| 984 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); | 1041 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); |
| 985 | let reach = Reach::of(8, px, py, y.width, y.height); | 1042 | let reach = Reach::of(8, px, py, y.width, y.height); |
| 986 | let (cpx, cpy) = (px / 2, py / 2); | 1043 | let (cpx, cpy) = (px / 2, py / 2); |
| @@ -1096,6 +1153,7 @@ pub fn decode_key_frame_tile( | |||
| 1096 | base_q_idx: u8, | 1153 | base_q_idx: u8, |
| 1097 | frame_width: u32, | 1154 | frame_width: u32, |
| 1098 | frame_height: u32, | 1155 | frame_height: u32, |
| 1156 | + enable_filter_intra: bool, | ||
| 1099 | ) -> Result<Picture> { | 1157 | ) -> Result<Picture> { |
| 1100 | if mi_cols == 0 || mi_rows == 0 { | 1158 | if mi_cols == 0 || mi_rows == 0 { |
| 1101 | return Err(unsupported("a frame with no mode-info grid")); | 1159 | return Err(unsupported("a frame with no mode-info grid")); |
| @@ -1200,6 +1258,7 @@ pub fn decode_key_frame_tile( | |||
| 1200 | &mut u, | 1258 | &mut u, |
| 1201 | &mut v, | 1259 | &mut v, |
| 1202 | base_q_idx, | 1260 | base_q_idx, |
| 1261 | + enable_filter_intra, | ||
| 1203 | )?; | 1262 | )?; |
| 1204 | } | 1263 | } |
| 1205 | PARTITION_SPLIT => { | 1264 | PARTITION_SPLIT => { |
| @@ -1256,6 +1315,7 @@ pub fn decode_key_frame_tile( | |||
| 1256 | &mut u, | 1315 | &mut u, |
| 1257 | &mut v, | 1316 | &mut v, |
| 1258 | base_q_idx, | 1317 | base_q_idx, |
| 1318 | + enable_filter_intra, | ||
| 1259 | )?; | 1319 | )?; |
| 1260 | } | 1320 | } |
| 1261 | PARTITION_SPLIT => { | 1321 | PARTITION_SPLIT => { |
| @@ -1292,6 +1352,7 @@ pub fn decode_key_frame_tile( | |||
| 1292 | &mut u, | 1352 | &mut u, |
| 1293 | &mut v, | 1353 | &mut v, |
| 1294 | base_q_idx, | 1354 | base_q_idx, |
| 1355 | + enable_filter_intra, | ||
| 1295 | )?; | 1356 | )?; |
| 1296 | continue; | 1357 | continue; |
| 1297 | } | 1358 | } |
| @@ -1334,6 +1395,7 @@ pub fn decode_key_frame_tile( | |||
| 1334 | &mut u, | 1395 | &mut u, |
| 1335 | &mut v, | 1396 | &mut v, |
| 1336 | base_q_idx, | 1397 | base_q_idx, |
| 1398 | + enable_filter_intra, | ||
| 1337 | )?; | 1399 | )?; |
| 1338 | prev_leaf = Some((leaf_mi, leaf_mode)); | 1400 | prev_leaf = Some((leaf_mi, leaf_mode)); |
| 1339 | } | 1401 | } |
| @@ -1395,6 +1457,7 @@ pub fn decode_key_frame_tile( | |||
| 1395 | &mut u, | 1457 | &mut u, |
| 1396 | &mut v, | 1458 | &mut v, |
| 1397 | base_q_idx, | 1459 | base_q_idx, |
| 1460 | + enable_filter_intra, | ||
| 1398 | )?; | 1461 | )?; |
| 1399 | prev_leaf = Some((leaf_mi, leaf_mode)); | 1462 | prev_leaf = Some((leaf_mi, leaf_mode)); |
| 1400 | } | 1463 | } |
| @@ -2216,7 +2279,7 @@ mod tests { | |||
| 2216 | 2279 | ||
| 2217 | #[test] | 2280 | #[test] |
| 2218 | fn a_frame_with_no_mode_info_grid_is_refused() { | 2281 | fn a_frame_with_no_mode_info_grid_is_refused() { |
| 2219 | - assert!(decode_key_frame_tile(&[0u8; 4], 0, 32, 32, 0, 128).is_err()); | 2282 | + assert!(decode_key_frame_tile(&[0u8; 4], 0, 32, 32, 0, 128, false).is_err()); |
| 2220 | } | 2283 | } |
| 2221 | 2284 | ||
| 2222 | /// Encodes and decodes one picture with `modes`, asserting the decoder's | 2285 | /// Encodes and decodes one picture with `modes`, asserting the decoder's |
| @@ -2244,8 +2307,10 @@ mod tests { | |||
| 2244 | base_q_idx, | 2307 | base_q_idx, |
| 2245 | .. | 2308 | .. |
| 2246 | }: Encoded = crate::encode::encode_key_frame_with_modes(&picture, 40, 0.0, modes).unwrap(); | 2309 | }: Encoded = crate::encode::encode_key_frame_with_modes(&picture, 40, 0.0, modes).unwrap(); |
| 2247 | - let decoded = | 2310 | + let decoded = decode_key_frame_tile( |
| 2248 | - decode_key_frame_tile(&tile, mi_cols, mi_rows, base_q_idx, w as u32, h as u32).unwrap(); | 2311 | + &tile, mi_cols, mi_rows, base_q_idx, w as u32, h as u32, false, |
| 2312 | + ) | ||
| 2313 | + .unwrap(); | ||
| 2249 | assert_eq!(decoded.width, w, "{w}x{h}: decoded width"); | 2314 | assert_eq!(decoded.width, w, "{w}x{h}: decoded width"); |
| 2250 | assert_eq!(decoded.height, h, "{w}x{h}: decoded height"); | 2315 | assert_eq!(decoded.height, h, "{w}x{h}: decoded height"); |
| 2251 | assert_eq!(decoded.y, reconstruction.y, "{w}x{h} luma mismatch"); | 2316 | assert_eq!(decoded.y, reconstruction.y, "{w}x{h} luma mismatch"); |
| @@ -2315,7 +2380,7 @@ mod tests { | |||
| 2315 | ); | 2380 | ); |
| 2316 | enc.symbol(DC_PRED, &mut cdfs.uv_mode_no_cfl[DC_PRED]); | 2381 | enc.symbol(DC_PRED, &mut cdfs.uv_mode_no_cfl[DC_PRED]); |
| 2317 | let data = enc.finish(); | 2382 | let data = enc.finish(); |
| 2318 | - let decoded = decode_key_frame_tile(&data, 16, 16, 40, 64, 64).unwrap(); | 2383 | + let decoded = decode_key_frame_tile(&data, 16, 16, 40, 64, 64, false).unwrap(); |
| 2319 | assert!( | 2384 | assert!( |
| 2320 | decoded.y.iter().all(|&s| s == 128), | 2385 | decoded.y.iter().all(|&s| s == 128), |
| 2321 | "a skipped DC_PRED block with no neighbours predicts flat mid-grey" | 2386 | "a skipped DC_PRED block with no neighbours predicts flat mid-grey" |
| @@ -2494,6 +2559,7 @@ mod tests { | |||
| 2494 | encoded.base_q_idx, | 2559 | encoded.base_q_idx, |
| 2495 | coded_w, | 2560 | coded_w, |
| 2496 | coded_h, | 2561 | coded_h, |
| 2562 | + false, | ||
| 2497 | ) | 2563 | ) |
| 2498 | .unwrap(); | 2564 | .unwrap(); |
| 2499 | assert_eq!(ours.y, ffmpeg_decoded.y, "{width}x{height}: luma vs ffmpeg"); | 2565 | assert_eq!(ours.y, ffmpeg_decoded.y, "{width}x{height}: luma vs ffmpeg"); |
| @@ -2561,6 +2627,7 @@ mod tests { | |||
| 2561 | key.base_q_idx, | 2627 | key.base_q_idx, |
| 2562 | width as u32, | 2628 | width as u32, |
| 2563 | height as u32, | 2629 | height as u32, |
| 2630 | + false, | ||
| 2564 | ) | 2631 | ) |
| 2565 | .unwrap(); | 2632 | .unwrap(); |
| 2566 | assert_eq!( | 2633 | assert_eq!( |
| @@ -2827,6 +2894,7 @@ mod tests { | |||
| 2827 | key.base_q_idx, | 2894 | key.base_q_idx, |
| 2828 | coded_w, | 2895 | coded_w, |
| 2829 | coded_h, | 2896 | coded_h, |
| 2897 | + false, | ||
| 2830 | ) | 2898 | ) |
| 2831 | .unwrap(); | 2899 | .unwrap(); |
| 2832 | assert_eq!(reference.y, ffmpeg_frames[0].y, "frame 0 luma vs ffmpeg"); | 2900 | assert_eq!(reference.y, ffmpeg_frames[0].y, "frame 0 luma vs ffmpeg"); |
crates/ec-av1/src/stream.rsmodified+33 -1
| @@ -93,11 +93,42 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 93 | "a frame using TxMode::Select (this decoder never reads a tx_depth symbol, so it desyncs after the first intra block's mode)", | 93 | "a frame using TxMode::Select (this decoder never reads a tx_depth symbol, so it desyncs after the first intra block's mode)", |
| 94 | )); | 94 | )); |
| 95 | } | 95 | } |
| 96 | + // lane-av1real r11's blindness-audit sweep (`read_intra_frame_mode_info`, | ||
| 97 | + // libaom decodemv.c): three more per-block/per-SB symbols this crate | ||
| 98 | + // never reads at all, each gated by a header field this decoder | ||
| 99 | + // otherwise accepts uncomplaining -- the same silent-desync shape | ||
| 100 | + // `use_filter_intra` was. `allow_screen_content_tools` gates both | ||
| 101 | + // `read_intrabc_info` and `read_palette_mode_info`; `delta.q_present`/ | ||
| 102 | + // `delta.lf_present` gate `read_delta_qindex`/`read_delta_lflevel` | ||
| 103 | + // (spec 5.11.10/5.11.11, one symbol group per superblock). Refuse | ||
| 104 | + // before desyncing rather than silently miscode, the same pattern as | ||
| 105 | + // the CDEF/TxMode::Select refusals above. | ||
| 106 | + if header.allow_screen_content_tools { | ||
| 107 | + return Err(Error::unsupported( | ||
| 108 | + "AV1 decode_stream", | ||
| 109 | + "a frame with allow_screen_content_tools set (this decoder never reads intrabc/palette_mode_info)", | ||
| 110 | + )); | ||
| 111 | + } | ||
| 112 | + if header.delta.q_present || header.delta.lf_present { | ||
| 113 | + return Err(Error::unsupported( | ||
| 114 | + "AV1 decode_stream", | ||
| 115 | + "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)", | ||
| 116 | + )); | ||
| 117 | + } | ||
| 118 | + if header.segmentation.enabled { | ||
| 119 | + return Err(Error::unsupported( | ||
| 120 | + "AV1 decode_stream", | ||
| 121 | + "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)", | ||
| 122 | + )); | ||
| 123 | + } | ||
| 96 | // `Tile::offset` is relative to the buffer `parse_obu` was handed | 124 | // `Tile::offset` is relative to the buffer `parse_obu` was handed |
| 97 | // (`&data[pos..]` at the time this OBU was parsed), so it is relative | 125 | // (`&data[pos..]` at the time this OBU was parsed), so it is relative |
| 98 | // to `obu_offset`, not to `data` as a whole. | 126 | // to `obu_offset`, not to `data` as a whole. |
| 99 | let start = obu_offset + tile.offset; | 127 | let start = obu_offset + tile.offset; |
| 100 | let tile_bytes = data.get(start..start + tile.size).ok_or(Error::NeedMore)?; | 128 | let tile_bytes = data.get(start..start + tile.size).ok_or(Error::NeedMore)?; |
| 129 | + let enable_filter_intra = parser | ||
| 130 | + .sequence_header() | ||
| 131 | + .is_some_and(|seq| seq.enable_filter_intra); | ||
| 101 | 132 | ||
| 102 | let picture = if header.frame_type == FrameType::Key { | 133 | let picture = if header.frame_type == FrameType::Key { |
| 103 | decode_key_frame_tile( | 134 | decode_key_frame_tile( |
| @@ -107,6 +138,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 107 | header.quantization.base_q_idx, | 138 | header.quantization.base_q_idx, |
| 108 | header.frame_width, | 139 | header.frame_width, |
| 109 | header.frame_height, | 140 | header.frame_height, |
| 141 | + enable_filter_intra, | ||
| 110 | )? | 142 | )? |
| 111 | } else { | 143 | } else { |
| 112 | let reference = reference.as_ref().ok_or_else(|| { | 144 | let reference = reference.as_ref().ok_or_else(|| { |
| @@ -188,6 +220,7 @@ mod tests { | |||
| 188 | encoded.base_q_idx, | 220 | encoded.base_q_idx, |
| 189 | width as u32, | 221 | width as u32, |
| 190 | height as u32, | 222 | height as u32, |
| 223 | + false, | ||
| 191 | ) | 224 | ) |
| 192 | .unwrap(); | 225 | .unwrap(); |
| 193 | let via_stream = decode_stream(&encoded.stream).unwrap(); | 226 | let via_stream = decode_stream(&encoded.stream).unwrap(); |
| @@ -513,7 +546,6 @@ mod tests { | |||
| 513 | /// decode: pixel-exact against ffmpeg's own decode, not just "decoded". | 546 | /// decode: pixel-exact against ffmpeg's own decode, not just "decoded". |
| 514 | /// | 547 | /// |
| 515 | #[test] | 548 | #[test] |
| 516 | - #[ignore = "r8: BOTH remaining hypotheses from r7 are now falsified. (1) Tile-data byte offset: an independent from-spec OBU parse in Python (obu_header/leb128/full sequence_header/full uncompressed_header bit-by-bit) derives the tile group starting at absolute byte 23 in the pinned stream; `EC_AV1_TRACE`'s new `key_tile_bytes` line shows our own `decode_stream` (stream.rs `obu_offset + tile.offset`) feeds `decode_key_frame_tile` that exact same byte 23 (first8 04 c8 d9 35 3d a6 de 5e); the r7 python scripts' hardcoded literal agrees too -- three-way match, offset is not the bug. (2) mode_info symbols: `EC_AV1_TRACE` extended to partition/skip/y_mode/uv_mode (decode.rs read_intra_mode + the two partition sites); an independent Python MSAC decoder over the SAME CDF literals -- this round re-verified partition_w32_cdf[0], kf_y_mode_cdf[0][0] and uv_mode_cdf[cfl=1][DC_PRED] byte-for-byte against /tmp/libaom-src/av1/common/entropymode.c source, not trusted from a prior round -- reads partition=NONE, skip=0, y_mode=DC_PRED(0), uv_mode=DC_PRED(0), matching our decoder exactly. So the bitstream genuinely codes DC_PRED with a near-zero residual (three magnitude-2 AC coefficients) for this block, and our decode of that is bit-exact; ffmpeg's real output (a smooth 46..61 diagonal gradient) cannot come from that symbol sequence under any correct DC_PRED reconstruction. The desync is downstream of symbol decode entirely -- intra prediction (`crate::intra::predict`) or the inverse-transform/dequant path (`dequant_and_inverse_typed`) miscomputing the reconstructed pixels from a genuinely-correct DC_PRED + tiny-residual decode, not a wrong symbol. r9: trace/diff `crate::intra::predict`'s DC output and the post-dequant residual grid against an independent implementation of both, the same way r6-r8 did for the entropy layer."] | ||
| 517 | fn a_real_libaom_cfl_stream_decodes_pixel_exact() { | 549 | fn a_real_libaom_cfl_stream_decodes_pixel_exact() { |
| 518 | if !have_ffmpeg() { | 550 | if !have_ffmpeg() { |
| 519 | eprintln!("SKIP a_real_libaom_cfl_stream_decodes_pixel_exact: no ffmpeg"); | 551 | eprintln!("SKIP a_real_libaom_cfl_stream_decodes_pixel_exact: no ffmpeg"); |