wip(av1): lane-realworld cdef_idx + delta q/lf, uncommitted at the 75-turn cap
Browse files at this commit7fc9065f719fe21546c0a7819c37b48ff6a13fa4Parent: 929da2f2 changed files +125 -21
- crates/ec-av1/src/decode.rs +120 -8
- crates/ec-av1/src/stream.rs +5 -13
crates/ec-av1/src/decode.rsmodified+120 -8
| @@ -66,6 +66,73 @@ pub(crate) fn filter_intra_hits() -> usize { | |||
| 66 | FILTER_INTRA_HITS.with(|c| c.get()) | 66 | FILTER_INTRA_HITS.with(|c| c.get()) |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | +/// lane-realworld r1: this frame's `cdef.bits` (spec 5.9.19), threaded into | ||
| 70 | +/// [`maybe_read_cdef_idx`] the same way [`ENABLE_EDGE_FILTER`] threads a | ||
| 71 | +/// frame-level flag through the recursive block decode -- `0` (the default) | ||
| 72 | +/// makes every call a true no-op, matching every existing gate stream's | ||
| 73 | +/// `cdef_bits == 0` behaviour exactly. | ||
| 74 | +thread_local! { | ||
| 75 | + static CDEF_BITS: std::cell::Cell<u8> = const { std::cell::Cell::new(0) }; | ||
| 76 | +} | ||
| 77 | +/// Whether this superblock's single CDEF unit (this decoder has no 128x128 | ||
| 78 | +/// SB, so the SB IS the CDEF unit) has already had its `cdef_idx` literal | ||
| 79 | +/// read -- reset to `false` at the top of each superblock in the two tile | ||
| 80 | +/// loops, spec `read_cdef`'s `cdef_transmitted[index]`. | ||
| 81 | +thread_local! { | ||
| 82 | + static CDEF_TRANSMITTED: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; | ||
| 83 | +} | ||
| 84 | +/// Number of superblock columns in the current tile's grid, so | ||
| 85 | +/// [`maybe_read_cdef_idx`] can turn an `(mi_r, mi_c)` into a flat index into | ||
| 86 | +/// [`CDEF_IDX_GRID`]. | ||
| 87 | +thread_local! { | ||
| 88 | + static CDEF_SB_COLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 89 | +} | ||
| 90 | +/// One resolved `cdef_idx` per superblock, read by [`apply_cdef`] to select | ||
| 91 | +/// which of the header's `1 << cdef.bits` strength pairs applies to that | ||
| 92 | +/// superblock's samples. | ||
| 93 | +thread_local! { | ||
| 94 | + static CDEF_IDX_GRID: std::cell::RefCell<Vec<u8>> = std::cell::RefCell::new(Vec::new()); | ||
| 95 | +} | ||
| 96 | +/// How many real (`cdef.bits > 0`) `cdef_idx` literals [`maybe_read_cdef_idx`] | ||
| 97 | +/// has read, across every call in the process -- the gate's proof that a | ||
| 98 | +/// `cdef_bits > 0` stream actually reached the new reader rather than every | ||
| 99 | +/// superblock coincidentally being all-skip. | ||
| 100 | +thread_local! { | ||
| 101 | + static CDEF_IDX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +/// Current value of [`CDEF_IDX_HITS`]. | ||
| 105 | +pub(crate) fn cdef_idx_hits() -> usize { | ||
| 106 | + CDEF_IDX_HITS.with(|c| c.get()) | ||
| 107 | +} | ||
| 108 | + | ||
| 109 | +/// `read_cdef` (spec 5.11.56, libaom `decodemv.c:read_cdef`), called right | ||
| 110 | +/// after `skip` is known at every block-decode call site. A no-op at | ||
| 111 | +/// `cdef.bits == 0` (0-bit literal, nothing to consume) -- and | ||
| 112 | +/// `read_cdef_params` already forces `bits = 0` under `coded_lossless`/ | ||
| 113 | +/// `allow_intrabc`, so neither needs a separate check here. Reads once per | ||
| 114 | +/// superblock, at the first non-skip block. | ||
| 115 | +fn maybe_read_cdef_idx(dec: &mut SymbolDecoder, mi_r: usize, mi_c: usize, skip: bool) { | ||
| 116 | + let bits = CDEF_BITS.with(|c| c.get()); | ||
| 117 | + if bits == 0 || skip || CDEF_TRANSMITTED.with(|c| c.get()) { | ||
| 118 | + return; | ||
| 119 | + } | ||
| 120 | + let idx = dec.literal(u32::from(bits)) as u8; | ||
| 121 | + CDEF_TRANSMITTED.with(|c| c.set(true)); | ||
| 122 | + CDEF_IDX_HITS.with(|c| c.set(c.get() + 1)); | ||
| 123 | + let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); | ||
| 124 | + let sb_cols = CDEF_SB_COLS.with(|c| c.get()); | ||
| 125 | + if sb_cols > 0 { | ||
| 126 | + CDEF_IDX_GRID.with(|g| { | ||
| 127 | + let mut g = g.borrow_mut(); | ||
| 128 | + let i = sb_r * sb_cols + sb_c; | ||
| 129 | + if i < g.len() { | ||
| 130 | + g[i] = idx; | ||
| 131 | + } | ||
| 132 | + }); | ||
| 133 | + } | ||
| 134 | +} | ||
| 135 | + | ||
| 69 | /// How many 4-pixel deblocking edge groups [`edge_params`] has actually | 136 | /// How many 4-pixel deblocking edge groups [`edge_params`] has actually |
| 70 | /// selected for filtering, across every call in the process -- the same | 137 | /// selected for filtering, across every call in the process -- the same |
| 71 | /// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream | 138 | /// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream |
| @@ -1928,6 +1995,8 @@ fn read_intra_mode_rect( | |||
| 1928 | enable_filter_intra: bool, | 1995 | enable_filter_intra: bool, |
| 1929 | skip_ctx: usize, | 1996 | skip_ctx: usize, |
| 1930 | allow_screen_content_tools: bool, | 1997 | allow_screen_content_tools: bool, |
| 1998 | + mi_r: usize, | ||
| 1999 | + mi_c: usize, | ||
| 1931 | ) -> Result<( | 2000 | ) -> Result<( |
| 1932 | bool, | 2001 | bool, |
| 1933 | usize, | 2002 | usize, |
| @@ -1948,6 +2017,7 @@ fn read_intra_mode_rect( | |||
| 1948 | )); | 2017 | )); |
| 1949 | } | 2018 | } |
| 1950 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; | 2019 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; |
| 2020 | + maybe_read_cdef_idx(dec, mi_r, mi_c, skip); | ||
| 1951 | let above_ctx = INTRA_MODE_CTX[above_mode]; | 2021 | let above_ctx = INTRA_MODE_CTX[above_mode]; |
| 1952 | let left_ctx = INTRA_MODE_CTX[left_mode]; | 2022 | let left_ctx = INTRA_MODE_CTX[left_mode]; |
| 1953 | let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); | 2023 | let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); |
| @@ -2089,6 +2159,8 @@ fn decode_block_rect( | |||
| 2089 | enable_filter_intra, | 2159 | enable_filter_intra, |
| 2090 | neighbours.skip_txfm_ctx(r * (SUB / MI), c * (SUB / MI)), | 2160 | neighbours.skip_txfm_ctx(r * (SUB / MI), c * (SUB / MI)), |
| 2091 | allow_screen_content_tools, | 2161 | allow_screen_content_tools, |
| 2162 | + r * (SUB / MI), | ||
| 2163 | + c * (SUB / MI), | ||
| 2092 | )?; | 2164 | )?; |
| 2093 | if filter_intra.is_some() { | 2165 | if filter_intra.is_some() { |
| 2094 | // `predict_filter_intra` (spec 7.11.2.3) is square-only in this | 2166 | // `predict_filter_intra` (spec 7.11.2.3) is square-only in this |
| @@ -2371,6 +2443,7 @@ fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 { | |||
| 2371 | symbol as i32 - ANGLE_DELTA_ZERO as i32 | 2443 | symbol as i32 - ANGLE_DELTA_ZERO as i32 |
| 2372 | } | 2444 | } |
| 2373 | 2445 | ||
| 2446 | +#[allow(clippy::too_many_arguments)] | ||
| 2374 | fn read_intra_mode( | 2447 | fn read_intra_mode( |
| 2375 | dec: &mut SymbolDecoder, | 2448 | dec: &mut SymbolDecoder, |
| 2376 | cdfs: &mut Cdfs, | 2449 | cdfs: &mut Cdfs, |
| @@ -2382,6 +2455,8 @@ fn read_intra_mode( | |||
| 2382 | skip_ctx: usize, | 2455 | skip_ctx: usize, |
| 2383 | allow_screen_content_tools: bool, | 2456 | allow_screen_content_tools: bool, |
| 2384 | allow_intrabc: bool, | 2457 | allow_intrabc: bool, |
| 2458 | + mi_r: usize, | ||
| 2459 | + mi_c: usize, | ||
| 2385 | ) -> Result<( | 2460 | ) -> Result<( |
| 2386 | bool, | 2461 | bool, |
| 2387 | usize, | 2462 | usize, |
| @@ -2396,6 +2471,9 @@ fn read_intra_mode( | |||
| 2396 | if trace { | 2471 | if trace { |
| 2397 | eprintln!("TRACE skip value={}", skip as i32); | 2472 | eprintln!("TRACE skip value={}", skip as i32); |
| 2398 | } | 2473 | } |
| 2474 | + // spec order (see the comment below on `read_intrabc_info`): `skip`, | ||
| 2475 | + // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here. | ||
| 2476 | + maybe_read_cdef_idx(dec, mi_r, mi_c, skip); | ||
| 2399 | // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at | 2477 | // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at |
| 2400 | // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before | 2478 | // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before |
| 2401 | // `mbmi->mode` is ever read): a `use_intrabc` symbol only present on an | 2479 | // `mbmi->mode` is ever read): a `use_intrabc` symbol only present on an |
| @@ -2981,6 +3059,8 @@ fn decode_block( | |||
| 2981 | neighbours.skip_txfm_ctx(r * (SUB / MI), c * (SUB / MI)), | 3059 | neighbours.skip_txfm_ctx(r * (SUB / MI), c * (SUB / MI)), |
| 2982 | allow_screen_content_tools, | 3060 | allow_screen_content_tools, |
| 2983 | allow_intrabc, | 3061 | allow_intrabc, |
| 3062 | + r * (SUB / MI), | ||
| 3063 | + c * (SUB / MI), | ||
| 2984 | )?; | 3064 | )?; |
| 2985 | // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED` | 3065 | // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED` |
| 2986 | // (13) predicts as `DC_PRED` with the [`cfl_scaled`] nudge carrying the | 3066 | // (13) predicts as `DC_PRED` with the [`cfl_scaled`] nudge carrying the |
| @@ -3299,6 +3379,8 @@ fn decode_leaf8( | |||
| 3299 | neighbours.skip_txfm_ctx(leaf_mi.0, leaf_mi.1), | 3379 | neighbours.skip_txfm_ctx(leaf_mi.0, leaf_mi.1), |
| 3300 | allow_screen_content_tools, | 3380 | allow_screen_content_tools, |
| 3301 | allow_intrabc, | 3381 | allow_intrabc, |
| 3382 | + leaf_mi.0, | ||
| 3383 | + leaf_mi.1, | ||
| 3302 | )?; | 3384 | )?; |
| 3303 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 3385 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 3304 | DC_PRED | 3386 | DC_PRED |
| @@ -4315,13 +4397,32 @@ fn apply_cdef( | |||
| 4315 | cdef: &CdefParams, | 4397 | cdef: &CdefParams, |
| 4316 | skip_grid: &Neighbours, | 4398 | skip_grid: &Neighbours, |
| 4317 | ) { | 4399 | ) { |
| 4318 | - if cdef.y_pri_strength[0] == 0 | 4400 | + // `cdef.bits == 0` still means "no filtering at all" whenever the single |
| 4401 | + // (index 0) strength pair is all-zero -- the fast path every existing | ||
| 4402 | + // gate stream takes. A `bits > 0` frame can still be all-zero-strength | ||
| 4403 | + // at every index, but that is rare enough not to special-case; the | ||
| 4404 | + // per-superblock lookup below degrades to the same index-0 read anyway | ||
| 4405 | + // when [`CDEF_IDX_GRID`] was never populated (`bits == 0`). | ||
| 4406 | + if cdef.bits == 0 | ||
| 4407 | + && cdef.y_pri_strength[0] == 0 | ||
| 4319 | && cdef.y_sec_strength[0] == 0 | 4408 | && cdef.y_sec_strength[0] == 0 |
| 4320 | && cdef.uv_pri_strength[0] == 0 | 4409 | && cdef.uv_pri_strength[0] == 0 |
| 4321 | && cdef.uv_sec_strength[0] == 0 | 4410 | && cdef.uv_sec_strength[0] == 0 |
| 4322 | { | 4411 | { |
| 4323 | return; | 4412 | return; |
| 4324 | } | 4413 | } |
| 4414 | + let sb_cols = CDEF_SB_COLS.with(|c| c.get()); | ||
| 4415 | + let idx_grid = CDEF_IDX_GRID.with(|g| g.borrow().clone()); | ||
| 4416 | + let strength_idx = |mi_r: usize, mi_c: usize| -> usize { | ||
| 4417 | + if sb_cols == 0 { | ||
| 4418 | + return 0; | ||
| 4419 | + } | ||
| 4420 | + let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); | ||
| 4421 | + idx_grid | ||
| 4422 | + .get(sb_r * sb_cols + sb_c) | ||
| 4423 | + .copied() | ||
| 4424 | + .unwrap_or(0) as usize | ||
| 4425 | + }; | ||
| 4325 | let src_y = y.data.clone(); | 4426 | let src_y = y.data.clone(); |
| 4326 | let src_u = u.data.clone(); | 4427 | let src_u = u.data.clone(); |
| 4327 | let src_v = v.data.clone(); | 4428 | let src_v = v.data.clone(); |
| @@ -4332,6 +4433,7 @@ fn apply_cdef( | |||
| 4332 | let mut mi_c = 0usize; | 4433 | let mut mi_c = 0usize; |
| 4333 | while mi_c < skip_grid.mi_cols { | 4434 | while mi_c < skip_grid.mi_cols { |
| 4334 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { | 4435 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 4436 | + let sidx = strength_idx(mi_r, mi_c); | ||
| 4335 | let (ox, oy) = (mi_c * 4, mi_r * 4); | 4437 | let (ox, oy) = (mi_c * 4, mi_r * 4); |
| 4336 | let (y_stride, y_true_w, y_true_h) = (y.width, y.true_width, y.true_height); | 4438 | let (y_stride, y_true_w, y_true_h) = (y.width, y.true_width, y.true_height); |
| 4337 | let sample_y = |r: i32, c: i32| -> i32 { | 4439 | let sample_y = |r: i32, c: i32| -> i32 { |
| @@ -4351,10 +4453,10 @@ fn apply_cdef( | |||
| 4351 | // -- each plane zeroes the shared direction when *its own* | 4453 | // -- each plane zeroes the shared direction when *its own* |
| 4352 | // frame-level primary strength is 0, independent of the | 4454 | // frame-level primary strength is 0, independent of the |
| 4353 | // per-block adjusted `t` and of the other plane's strength. | 4455 | // per-block adjusted `t` and of the other plane's strength. |
| 4354 | - let y_dir = if cdef.y_pri_strength[0] != 0 { dir } else { 0 }; | 4456 | + let y_dir = if cdef.y_pri_strength[sidx] != 0 { dir } else { 0 }; |
| 4355 | - let t = cdef_adjust_strength(i32::from(cdef.y_pri_strength[0]), var); | 4457 | + let t = cdef_adjust_strength(i32::from(cdef.y_pri_strength[sidx]), var); |
| 4356 | let enable_primary = t != 0; | 4458 | let enable_primary = t != 0; |
| 4357 | - let enable_secondary = cdef.y_sec_strength[0] != 0; | 4459 | + let enable_secondary = cdef.y_sec_strength[sidx] != 0; |
| 4358 | if enable_primary || enable_secondary { | 4460 | if enable_primary || enable_secondary { |
| 4359 | cdef_filter_block( | 4461 | cdef_filter_block( |
| 4360 | sample_y, | 4462 | sample_y, |
| @@ -4364,7 +4466,7 @@ fn apply_cdef( | |||
| 4364 | 8, | 4466 | 8, |
| 4365 | 8, | 4467 | 8, |
| 4366 | t, | 4468 | t, |
| 4367 | - i32::from(cdef.y_sec_strength[0]), | 4469 | + i32::from(cdef.y_sec_strength[sidx]), |
| 4368 | y_dir, | 4470 | y_dir, |
| 4369 | damping, | 4471 | damping, |
| 4370 | damping, | 4472 | damping, |
| @@ -4373,10 +4475,10 @@ fn apply_cdef( | |||
| 4373 | ); | 4475 | ); |
| 4374 | } | 4476 | } |
| 4375 | 4477 | ||
| 4376 | - let t_uv = i32::from(cdef.uv_pri_strength[0]); | 4478 | + let t_uv = i32::from(cdef.uv_pri_strength[sidx]); |
| 4377 | let uv_dir = if t_uv != 0 { dir } else { 0 }; | 4479 | let uv_dir = if t_uv != 0 { dir } else { 0 }; |
| 4378 | let enable_primary_uv = t_uv != 0; | 4480 | let enable_primary_uv = t_uv != 0; |
| 4379 | - let enable_secondary_uv = cdef.uv_sec_strength[0] != 0; | 4481 | + let enable_secondary_uv = cdef.uv_sec_strength[sidx] != 0; |
| 4380 | if enable_primary_uv || enable_secondary_uv { | 4482 | if enable_primary_uv || enable_secondary_uv { |
| 4381 | let (cox, coy) = (ox / 2, oy / 2); | 4483 | let (cox, coy) = (ox / 2, oy / 2); |
| 4382 | for (plane, src_p) in [(&mut *u, &src_u), (&mut *v, &src_v)] { | 4484 | for (plane, src_p) in [(&mut *u, &src_u), (&mut *v, &src_v)] { |
| @@ -4398,7 +4500,7 @@ fn apply_cdef( | |||
| 4398 | 4, | 4500 | 4, |
| 4399 | 4, | 4501 | 4, |
| 4400 | t_uv, | 4502 | t_uv, |
| 4401 | - i32::from(cdef.uv_sec_strength[0]), | 4503 | + i32::from(cdef.uv_sec_strength[sidx]), |
| 4402 | uv_dir, | 4504 | uv_dir, |
| 4403 | damping_uv, | 4505 | damping_uv, |
| 4404 | damping_uv, | 4506 | damping_uv, |
| @@ -4497,6 +4599,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 4497 | } | 4599 | } |
| 4498 | ENABLE_EDGE_FILTER.with(|f| f.set(enable_edge_filter)); | 4600 | ENABLE_EDGE_FILTER.with(|f| f.set(enable_edge_filter)); |
| 4499 | let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI)); | 4601 | let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI)); |
| 4602 | + CDEF_BITS.with(|c| c.set(cdef.bits)); | ||
| 4603 | + CDEF_SB_COLS.with(|c| c.set(sb_cols as usize)); | ||
| 4604 | + CDEF_IDX_GRID.with(|g| *g.borrow_mut() = vec![0u8; sb_cols as usize * sb_rows as usize]); | ||
| 4500 | let (cols32, rows32) = block_grid(mi_cols, mi_rows); | 4605 | let (cols32, rows32) = block_grid(mi_cols, mi_rows); |
| 4501 | let (true_width, true_height) = ((mi_cols * 4) as usize, (mi_rows * 4) as usize); | 4606 | let (true_width, true_height) = ((mi_cols * 4) as usize, (mi_rows * 4) as usize); |
| 4502 | let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); | 4607 | let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); |
| @@ -4547,6 +4652,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 4547 | for sb_r in 0..sb_rows { | 4652 | for sb_r in 0..sb_rows { |
| 4548 | neighbours.start_row(); | 4653 | neighbours.start_row(); |
| 4549 | for sb_c in 0..sb_cols { | 4654 | for sb_c in 0..sb_cols { |
| 4655 | + CDEF_TRANSMITTED.with(|c| c.set(false)); | ||
| 4550 | let at = (sb_r as usize * 4, sb_c as usize * 4); | 4656 | let at = (sb_r as usize * 4, sb_c as usize * 4); |
| 4551 | let ctx = neighbours.partition_ctx(at, SB); | 4657 | let ctx = neighbours.partition_ctx(at, SB); |
| 4552 | let (has_cols, has_rows) = ( | 4658 | let (has_cols, has_rows) = ( |
| @@ -6378,6 +6484,7 @@ fn decode_inter_block( | |||
| 6378 | 6484 | ||
| 6379 | let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]); | 6485 | let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]); |
| 6380 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; | 6486 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| 6487 | + maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip); | ||
| 6381 | // lane-warp r5: see `reject_residual` -- a square-block decode of a | 6488 | // lane-warp r5: see `reject_residual` -- a square-block decode of a |
| 6382 | // HORZ_B strip is symbol-exact only for `skip` (no residual, no | 6489 | // HORZ_B strip is symbol-exact only for `skip` (no residual, no |
| 6383 | // motion_mode/warp symbol), so gate here before any further read. | 6490 | // motion_mode/warp symbol), so gate here before any further read. |
| @@ -8105,6 +8212,7 @@ fn decode_inter_block8( | |||
| 8105 | 8212 | ||
| 8106 | let skip_ctx = usize::from(above_skip) + usize::from(left_skip); | 8213 | let skip_ctx = usize::from(above_skip) + usize::from(left_skip); |
| 8107 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; | 8214 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| 8215 | + maybe_read_cdef_idx(dec, leaf_mi.0, leaf_mi.1, skip); | ||
| 8108 | 8216 | ||
| 8109 | let (has_above, has_left) = (leaf_mi.0 > 0, leaf_mi.1 > 0); | 8217 | let (has_above, has_left) = (leaf_mi.0 > 0, leaf_mi.1 > 0); |
| 8110 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); | 8218 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); |
| @@ -9163,6 +9271,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9163 | } | 9271 | } |
| 9164 | let (cols, rows) = block_grid(mi_cols, mi_rows); | 9272 | let (cols, rows) = block_grid(mi_cols, mi_rows); |
| 9165 | let (sb_cols, sb_rows) = (cols.div_ceil(2), rows.div_ceil(2)); | 9273 | let (sb_cols, sb_rows) = (cols.div_ceil(2), rows.div_ceil(2)); |
| 9274 | + CDEF_BITS.with(|c| c.set(cdef.bits)); | ||
| 9275 | + CDEF_SB_COLS.with(|c| c.set(sb_cols as usize)); | ||
| 9276 | + CDEF_IDX_GRID.with(|g| *g.borrow_mut() = vec![0u8; sb_cols as usize * sb_rows as usize]); | ||
| 9166 | let (width, height) = (cols as usize * BLOCK, rows as usize * BLOCK); | 9277 | let (width, height) = (cols as usize * BLOCK, rows as usize * BLOCK); |
| 9167 | 9278 | ||
| 9168 | let ref_y = PlaneBuf { | 9279 | let ref_y = PlaneBuf { |
| @@ -9275,6 +9386,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9275 | for sb_r in 0..sb_rows { | 9386 | for sb_r in 0..sb_rows { |
| 9276 | neighbours.start_row(); | 9387 | neighbours.start_row(); |
| 9277 | for sb_c in 0..sb_cols { | 9388 | for sb_c in 0..sb_cols { |
| 9389 | + CDEF_TRANSMITTED.with(|c| c.set(false)); | ||
| 9278 | let sb_at = (sb_r as usize * 4, sb_c as usize * 4); | 9390 | let sb_at = (sb_r as usize * 4, sb_c as usize * 4); |
| 9279 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); | 9391 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); |
| 9280 | let (has_cols, has_rows) = ( | 9392 | let (has_cols, has_rows) = ( |
crates/ec-av1/src/stream.rsmodified+5 -13
| @@ -125,19 +125,11 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 125 | })?; | 125 | })?; |
| 126 | // `read_cdef` (spec `decodeframe.c`, called at the first non-skip | 126 | // `read_cdef` (spec `decodeframe.c`, called at the first non-skip |
| 127 | // block of each 64x64) only reads a literal `cdef_idx` when | 127 | // block of each 64x64) only reads a literal `cdef_idx` when |
| 128 | - // `cdef_bits > 0`; at `cdef_bits == 0` there is nothing to read (this | 128 | + // `cdef_bits > 0`; at `cdef_bits == 0` there is nothing to read (a |
| 129 | - // crate's own writer's only case, and both `lane-av1cdef` gate | 129 | + // true no-op). lane-realworld r1: the per-64x64 `cdef_idx` literal is |
| 130 | - // streams'), so the per-block symbol this crate's tile readers never | 130 | + // now read (`maybe_read_cdef_idx` in decode.rs) and threaded into |
| 131 | - // consume is a true no-op there. A `cdef_bits > 0` stream would | 131 | + // [`crate::decode::apply_cdef`]'s per-superblock strength lookup, so |
| 132 | - // desync the moment it hit a real strength selector this decoder | 132 | + // a `cdef_bits > 0` stream no longer needs this refusal. |
| 133 | - // never reads — refuse that by name rather than silently miscode, | ||
| 134 | - // the same pattern as the other round-2 refusals below. | ||
| 135 | - if header.cdef.bits != 0 { | ||
| 136 | - return Err(Error::unsupported( | ||
| 137 | - "AV1 decode_stream", | ||
| 138 | - "a frame with cdef_bits > 0 (this decoder never reads the per-64x64 cdef_idx symbol)", | ||
| 139 | - )); | ||
| 140 | - } | ||
| 141 | // An intra frame's `decode_key_frame_tile*` now reads `tx_depth` | 133 | // An intra frame's `decode_key_frame_tile*` now reads `tx_depth` |
| 142 | // under `TxMode::Select` (lane-av1txsel, spec 5.11.16): the key-frame | 134 | // under `TxMode::Select` (lane-av1txsel, spec 5.11.16): the key-frame |
| 143 | // decode path threads `tx_select` through `decode_block`/ | 135 | // decode path threads `tx_select` through `decode_block`/ |