Merge branch 'lane-hbd': 10-bit streams decode bit-exact
Browse files at this commit7 changed files +580 -72
- crates/ec-av1/src/decode.rs +79 -48
- crates/ec-av1/src/intra.rs +7 -4
- crates/ec-av1/src/refusal_inventory.rs +2 -1
- crates/ec-av1/src/stream.rs +220 -19
- lanes/hbd-r5.charter.md +57 -0
- lanes/hbd-r5.report.md +92 -0
- lanes/hbd-r7.report.md +123 -0
crates/ec-av1/src/decode.rsmodified+79 -48
| @@ -92,6 +92,11 @@ thread_local! { | |||
| 92 | pub(crate) fn sample_max() -> i32 { | 92 | pub(crate) fn sample_max() -> i32 { |
| 93 | (1i32 << BIT_DEPTH.with(std::cell::Cell::get)) - 1 | 93 | (1i32 << BIT_DEPTH.with(std::cell::Cell::get)) - 1 |
| 94 | } | 94 | } |
| 95 | +/// The current stream's bit depth, for callers (e.g. dequant) that need the | ||
| 96 | +/// raw value rather than the derived clamp bound. | ||
| 97 | +pub(crate) fn bit_depth() -> u8 { | ||
| 98 | + BIT_DEPTH.with(std::cell::Cell::get) | ||
| 99 | +} | ||
| 95 | /// Sets [`BIT_DEPTH`] for the current thread, called once per frame from | 100 | /// Sets [`BIT_DEPTH`] for the current thread, called once per frame from |
| 96 | /// [`crate::stream`]'s decode loop. | 101 | /// [`crate::stream`]'s decode loop. |
| 97 | pub(crate) fn set_bit_depth(bit_depth: u8) { | 102 | pub(crate) fn set_bit_depth(bit_depth: u8) { |
| @@ -3237,7 +3242,7 @@ fn decode_block_rect( | |||
| 3237 | &luma_levels, | 3242 | &luma_levels, |
| 3238 | bw, | 3243 | bw, |
| 3239 | bh, | 3244 | bh, |
| 3240 | - 8, | 3245 | + crate::decode::bit_depth(), |
| 3241 | CURRENT_Q_IDX.with(|c| c.get()), | 3246 | CURRENT_Q_IDX.with(|c| c.get()), |
| 3242 | plane_q_delta(0).0, | 3247 | plane_q_delta(0).0, |
| 3243 | plane_q_delta(0).1, | 3248 | plane_q_delta(0).1, |
| @@ -3278,7 +3283,7 @@ fn decode_block_rect( | |||
| 3278 | &u_levels, | 3283 | &u_levels, |
| 3279 | chroma_w, | 3284 | chroma_w, |
| 3280 | chroma_h, | 3285 | chroma_h, |
| 3281 | - 8, | 3286 | + crate::decode::bit_depth(), |
| 3282 | CURRENT_Q_IDX.with(|c| c.get()), | 3287 | CURRENT_Q_IDX.with(|c| c.get()), |
| 3283 | plane_q_delta(1).0, | 3288 | plane_q_delta(1).0, |
| 3284 | plane_q_delta(1).1, | 3289 | plane_q_delta(1).1, |
| @@ -3318,7 +3323,7 @@ fn decode_block_rect( | |||
| 3318 | &v_levels, | 3323 | &v_levels, |
| 3319 | chroma_w, | 3324 | chroma_w, |
| 3320 | chroma_h, | 3325 | chroma_h, |
| 3321 | - 8, | 3326 | + crate::decode::bit_depth(), |
| 3322 | CURRENT_Q_IDX.with(|c| c.get()), | 3327 | CURRENT_Q_IDX.with(|c| c.get()), |
| 3323 | plane_q_delta(2).0, | 3328 | plane_q_delta(2).0, |
| 3324 | plane_q_delta(2).1, | 3329 | plane_q_delta(2).1, |
| @@ -3531,7 +3536,7 @@ fn decode_block_rect64( | |||
| 3531 | &luma_levels, | 3536 | &luma_levels, |
| 3532 | bw, | 3537 | bw, |
| 3533 | bh, | 3538 | bh, |
| 3534 | - 8, | 3539 | + crate::decode::bit_depth(), |
| 3535 | i32::from(base_q_idx), | 3540 | i32::from(base_q_idx), |
| 3536 | plane_q_delta(0).0, | 3541 | plane_q_delta(0).0, |
| 3537 | plane_q_delta(0).1, | 3542 | plane_q_delta(0).1, |
| @@ -3592,7 +3597,7 @@ fn decode_block_rect64( | |||
| 3592 | &u_levels, | 3597 | &u_levels, |
| 3593 | chroma_w, | 3598 | chroma_w, |
| 3594 | chroma_h, | 3599 | chroma_h, |
| 3595 | - 8, | 3600 | + crate::decode::bit_depth(), |
| 3596 | i32::from(base_q_idx), | 3601 | i32::from(base_q_idx), |
| 3597 | plane_q_delta(1).0, | 3602 | plane_q_delta(1).0, |
| 3598 | plane_q_delta(1).1, | 3603 | plane_q_delta(1).1, |
| @@ -3635,7 +3640,7 @@ fn decode_block_rect64( | |||
| 3635 | &v_levels, | 3640 | &v_levels, |
| 3636 | chroma_w, | 3641 | chroma_w, |
| 3637 | chroma_h, | 3642 | chroma_h, |
| 3638 | - 8, | 3643 | + crate::decode::bit_depth(), |
| 3639 | i32::from(base_q_idx), | 3644 | i32::from(base_q_idx), |
| 3640 | plane_q_delta(2).0, | 3645 | plane_q_delta(2).0, |
| 3641 | plane_q_delta(2).1, | 3646 | plane_q_delta(2).1, |
| @@ -4359,7 +4364,7 @@ fn read_plane( | |||
| 4359 | full | 4364 | full |
| 4360 | }; | 4365 | }; |
| 4361 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); | 4366 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); |
| 4362 | - let residual = dequant_and_inverse_typed(&levels, side, 8, CURRENT_Q_IDX.with(|c| c.get()), dc_delta, ac_delta, tx_type); | 4367 | + let residual = dequant_and_inverse_typed(&levels, side, bit_depth(), CURRENT_Q_IDX.with(|c| c.get()), dc_delta, ac_delta, tx_type); |
| 4363 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 4368 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 4364 | eprintln!( | 4369 | eprintln!( |
| 4365 | "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}", | 4370 | "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}", |
| @@ -5155,12 +5160,14 @@ fn cdef_constrain(diff: i32, threshold: i32, damping: i32) -> i32 { | |||
| 5155 | /// Spec 7.15.3's direction search (libaom `cdef_find_dir_c`): the dominant | 5160 | /// Spec 7.15.3's direction search (libaom `cdef_find_dir_c`): the dominant |
| 5156 | /// direction of an 8x8 luma window and the variance gap between it and its | 5161 | /// direction of an 8x8 luma window and the variance gap between it and its |
| 5157 | /// orthogonal, `sample(row, col)` reading that window's own pixels. | 5162 | /// orthogonal, `sample(row, col)` reading that window's own pixels. |
| 5158 | -fn cdef_find_dir(sample: impl Fn(usize, usize) -> i32) -> (usize, i32) { | 5163 | +fn cdef_find_dir(coeff_shift: i32, sample: impl Fn(usize, usize) -> i32) -> (usize, i32) { |
| 5159 | const DIV_TABLE: [i64; 9] = [0, 840, 420, 280, 210, 168, 140, 120, 105]; | 5164 | const DIV_TABLE: [i64; 9] = [0, 840, 420, 280, 210, 168, 140, 120, 105]; |
| 5160 | let mut partial = [[0i64; 15]; 8]; | 5165 | let mut partial = [[0i64; 15]; 8]; |
| 5161 | for i in 0..8i64 { | 5166 | for i in 0..8i64 { |
| 5162 | for j in 0..8i64 { | 5167 | for j in 0..8i64 { |
| 5163 | - let x = i64::from(sample(i as usize, j as usize)) - 128; | 5168 | + // libaom `cdef_find_dir_c`: normalise to an 8-bit sample before |
| 5169 | + // accumulating, same as `constrain`'s threshold shift below. | ||
| 5170 | + let x = i64::from(sample(i as usize, j as usize) >> coeff_shift) - 128; | ||
| 5164 | partial[0][(i + j) as usize] += x; | 5171 | partial[0][(i + j) as usize] += x; |
| 5165 | partial[1][(i + j / 2) as usize] += x; | 5172 | partial[1][(i + j / 2) as usize] += x; |
| 5166 | partial[2][i as usize] += x; | 5173 | partial[2][i as usize] += x; |
| @@ -5241,9 +5248,14 @@ fn cdef_filter_block( | |||
| 5241 | sec_damping: i32, | 5248 | sec_damping: i32, |
| 5242 | enable_primary: bool, | 5249 | enable_primary: bool, |
| 5243 | enable_secondary: bool, | 5250 | enable_secondary: bool, |
| 5251 | + coeff_shift: i32, | ||
| 5244 | ) { | 5252 | ) { |
| 5245 | let clipping_required = enable_primary && enable_secondary; | 5253 | let clipping_required = enable_primary && enable_secondary; |
| 5246 | - let pri_taps = CDEF_PRI_TAPS[(pri_strength & 1) as usize]; | 5254 | + // libaom `cdef_filter_block_internal`: `cdef_pri_taps[(pri_strength >> |
| 5255 | + // coeff_shift) & 1]` -- `pri_strength` (and its `adjust_strength` | ||
| 5256 | + // derivative) carries the bit-depth shift, so the tap-set parity bit | ||
| 5257 | + // must be read back above that shift, not off the raw low bit. | ||
| 5258 | + let pri_taps = CDEF_PRI_TAPS[((pri_strength >> coeff_shift) & 1) as usize]; | ||
| 5247 | for i in 0..bh { | 5259 | for i in 0..bh { |
| 5248 | for j in 0..bw { | 5260 | for j in 0..bw { |
| 5249 | let x = sample(i as i32, j as i32); | 5261 | let x = sample(i as i32, j as i32); |
| @@ -5563,7 +5575,10 @@ fn deblock_thresholds(level: i32, sharpness: u8) -> (i32, i32, i32) { | |||
| 5563 | } | 5575 | } |
| 5564 | 5576 | ||
| 5565 | fn sclamp(v: i32) -> i32 { | 5577 | fn sclamp(v: i32) -> i32 { |
| 5566 | - v.clamp(-128, 127) | 5578 | + // libaom's `signed_char_clamp_high`: the clamp range scales with |
| 5579 | + // `128 << (bit_depth - 8)` alongside the centering constant below. | ||
| 5580 | + let scale = 1i32 << (bit_depth() - 8); | ||
| 5581 | + v.clamp(-128 * scale, 128 * scale - 1) | ||
| 5567 | } | 5582 | } |
| 5568 | 5583 | ||
| 5569 | fn round_pow2(v: i32, n: u32) -> i32 { | 5584 | fn round_pow2(v: i32, n: u32) -> i32 { |
| @@ -5577,16 +5592,17 @@ fn filter4(mask: bool, thresh: i32, p1: i32, p0: i32, q0: i32, q1: i32) -> [i32; | |||
| 5577 | return [p1, p0, q0, q1]; | 5592 | return [p1, p0, q0, q1]; |
| 5578 | } | 5593 | } |
| 5579 | let hev = (p1 - p0).abs() > thresh || (q1 - q0).abs() > thresh; | 5594 | let hev = (p1 - p0).abs() > thresh || (q1 - q0).abs() > thresh; |
| 5580 | - let (ps1, ps0, qs0, qs1) = (p1 - 128, p0 - 128, q0 - 128, q1 - 128); | 5595 | + let centre = 128i32 << (bit_depth() - 8); |
| 5596 | + let (ps1, ps0, qs0, qs1) = (p1 - centre, p0 - centre, q0 - centre, q1 - centre); | ||
| 5581 | let outer = if hev { sclamp(ps1 - qs1) } else { 0 }; | 5597 | let outer = if hev { sclamp(ps1 - qs1) } else { 0 }; |
| 5582 | let filter = sclamp(outer + 3 * (qs0 - ps0)); | 5598 | let filter = sclamp(outer + 3 * (qs0 - ps0)); |
| 5583 | let filter1 = sclamp(filter + 4) >> 3; | 5599 | let filter1 = sclamp(filter + 4) >> 3; |
| 5584 | let filter2 = sclamp(filter + 3) >> 3; | 5600 | let filter2 = sclamp(filter + 3) >> 3; |
| 5585 | - let oq0 = sclamp(qs0 - filter1) + 128; | 5601 | + let oq0 = sclamp(qs0 - filter1) + centre; |
| 5586 | - let op0 = sclamp(ps0 + filter2) + 128; | 5602 | + let op0 = sclamp(ps0 + filter2) + centre; |
| 5587 | let tap = if hev { 0 } else { round_pow2(filter1, 1) }; | 5603 | let tap = if hev { 0 } else { round_pow2(filter1, 1) }; |
| 5588 | - let oq1 = sclamp(qs1 - tap) + 128; | 5604 | + let oq1 = sclamp(qs1 - tap) + centre; |
| 5589 | - let op1 = sclamp(ps1 + tap) + 128; | 5605 | + let op1 = sclamp(ps1 + tap) + centre; |
| 5590 | [op1, op0, oq0, oq1] | 5606 | [op1, op0, oq0, oq1] |
| 5591 | } | 5607 | } |
| 5592 | 5608 | ||
| @@ -5737,6 +5753,13 @@ fn filter_edge( | |||
| 5737 | sharpness: u8, | 5753 | sharpness: u8, |
| 5738 | ) { | 5754 | ) { |
| 5739 | let (blimit, limit, hev_thr) = deblock_thresholds(level, sharpness); | 5755 | let (blimit, limit, hev_thr) = deblock_thresholds(level, sharpness); |
| 5756 | + // libaom `highbd_filter_mask*`/`highbd_flat_mask4`/`highbd_hev_mask`: | ||
| 5757 | + // every 8-bit threshold (including the flat masks' fixed `1`) is | ||
| 5758 | + // compared against a raw pixel difference on the stream's own bit-depth | ||
| 5759 | + // scale, so each is shifted left by `bit_depth - 8` before use. | ||
| 5760 | + let shift = bit_depth() - 8; | ||
| 5761 | + let (blimit, limit, hev_thr) = (blimit << shift, limit << shift, hev_thr << shift); | ||
| 5762 | + let flat_thresh = 1i32 << shift; | ||
| 5740 | for i in 0..4isize { | 5763 | for i in 0..4isize { |
| 5741 | let center = (base as isize + i * outer_stride) as usize; | 5764 | let center = (base as isize + i * outer_stride) as usize; |
| 5742 | let idx = |k: isize| -> usize { (center as isize + k * tap_stride) as usize }; | 5765 | let idx = |k: isize| -> usize { (center as isize + k * tap_stride) as usize }; |
| @@ -5760,10 +5783,10 @@ fn filter_edge( | |||
| 5760 | && (q1 - q0).abs() <= limit | 5783 | && (q1 - q0).abs() <= limit |
| 5761 | && (q2 - q1).abs() <= limit | 5784 | && (q2 - q1).abs() <= limit |
| 5762 | && (p0 - q0).abs() * 2 + (p1 - q1).abs() / 2 <= blimit; | 5785 | && (p0 - q0).abs() * 2 + (p1 - q1).abs() / 2 <= blimit; |
| 5763 | - let flat = (p1 - p0).abs() <= 1 | 5786 | + let flat = (p1 - p0).abs() <= flat_thresh |
| 5764 | - && (q1 - q0).abs() <= 1 | 5787 | + && (q1 - q0).abs() <= flat_thresh |
| 5765 | - && (p2 - p0).abs() <= 1 | 5788 | + && (p2 - p0).abs() <= flat_thresh |
| 5766 | - && (q2 - q0).abs() <= 1; | 5789 | + && (q2 - q0).abs() <= flat_thresh; |
| 5767 | let [op1, op0, oq0, oq1] = filter6(mask, hev_thr, flat, p2, p1, p0, q0, q1, q2); | 5790 | let [op1, op0, oq0, oq1] = filter6(mask, hev_thr, flat, p2, p1, p0, q0, q1, q2); |
| 5768 | data[idx(-2)] = op1.clamp(0, sample_max()) as u16; | 5791 | data[idx(-2)] = op1.clamp(0, sample_max()) as u16; |
| 5769 | data[idx(-1)] = op0.clamp(0, sample_max()) as u16; | 5792 | data[idx(-1)] = op0.clamp(0, sample_max()) as u16; |
| @@ -5780,12 +5803,12 @@ fn filter_edge( | |||
| 5780 | && (q2 - q1).abs() <= limit | 5803 | && (q2 - q1).abs() <= limit |
| 5781 | && (q3 - q2).abs() <= limit | 5804 | && (q3 - q2).abs() <= limit |
| 5782 | && (p0 - q0).abs() * 2 + (p1 - q1).abs() / 2 <= blimit; | 5805 | && (p0 - q0).abs() * 2 + (p1 - q1).abs() / 2 <= blimit; |
| 5783 | - let flat = (p1 - p0).abs() <= 1 | 5806 | + let flat = (p1 - p0).abs() <= flat_thresh |
| 5784 | - && (q1 - q0).abs() <= 1 | 5807 | + && (q1 - q0).abs() <= flat_thresh |
| 5785 | - && (p2 - p0).abs() <= 1 | 5808 | + && (p2 - p0).abs() <= flat_thresh |
| 5786 | - && (q2 - q0).abs() <= 1 | 5809 | + && (q2 - q0).abs() <= flat_thresh |
| 5787 | - && (p3 - p0).abs() <= 1 | 5810 | + && (p3 - p0).abs() <= flat_thresh |
| 5788 | - && (q3 - q0).abs() <= 1; | 5811 | + && (q3 - q0).abs() <= flat_thresh; |
| 5789 | let [op2, op1, op0, oq0, oq1, oq2] = | 5812 | let [op2, op1, op0, oq0, oq1, oq2] = |
| 5790 | filter8(mask, hev_thr, flat, p3, p2, p1, p0, q0, q1, q2, q3); | 5813 | filter8(mask, hev_thr, flat, p3, p2, p1, p0, q0, q1, q2, q3); |
| 5791 | data[idx(-3)] = op2.clamp(0, sample_max()) as u16; | 5814 | data[idx(-3)] = op2.clamp(0, sample_max()) as u16; |
| @@ -5807,18 +5830,18 @@ fn filter_edge( | |||
| 5807 | && (q2 - q1).abs() <= limit | 5830 | && (q2 - q1).abs() <= limit |
| 5808 | && (q3 - q2).abs() <= limit | 5831 | && (q3 - q2).abs() <= limit |
| 5809 | && (p0 - q0).abs() * 2 + (p1 - q1).abs() / 2 <= blimit; | 5832 | && (p0 - q0).abs() * 2 + (p1 - q1).abs() / 2 <= blimit; |
| 5810 | - let flat = (p1 - p0).abs() <= 1 | 5833 | + let flat = (p1 - p0).abs() <= flat_thresh |
| 5811 | - && (q1 - q0).abs() <= 1 | 5834 | + && (q1 - q0).abs() <= flat_thresh |
| 5812 | - && (p2 - p0).abs() <= 1 | 5835 | + && (p2 - p0).abs() <= flat_thresh |
| 5813 | - && (q2 - q0).abs() <= 1 | 5836 | + && (q2 - q0).abs() <= flat_thresh |
| 5814 | - && (p3 - p0).abs() <= 1 | 5837 | + && (p3 - p0).abs() <= flat_thresh |
| 5815 | - && (q3 - q0).abs() <= 1; | 5838 | + && (q3 - q0).abs() <= flat_thresh; |
| 5816 | - let flat2 = (p4 - p0).abs() <= 1 | 5839 | + let flat2 = (p4 - p0).abs() <= flat_thresh |
| 5817 | - && (q4 - q0).abs() <= 1 | 5840 | + && (q4 - q0).abs() <= flat_thresh |
| 5818 | - && (p5 - p0).abs() <= 1 | 5841 | + && (p5 - p0).abs() <= flat_thresh |
| 5819 | - && (q5 - q0).abs() <= 1 | 5842 | + && (q5 - q0).abs() <= flat_thresh |
| 5820 | - && (p6 - p0).abs() <= 1 | 5843 | + && (p6 - p0).abs() <= flat_thresh |
| 5821 | - && (q6 - q0).abs() <= 1; | 5844 | + && (q6 - q0).abs() <= flat_thresh; |
| 5822 | let out = filter14( | 5845 | let out = filter14( |
| 5823 | mask, hev_thr, flat, flat2, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, | 5846 | mask, hev_thr, flat, flat2, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, |
| 5824 | q6, | 5847 | q6, |
| @@ -5945,7 +5968,10 @@ fn apply_cdef( | |||
| 5945 | let src_y = y.data.clone(); | 5968 | let src_y = y.data.clone(); |
| 5946 | let src_u = u.data.clone(); | 5969 | let src_u = u.data.clone(); |
| 5947 | let src_v = v.data.clone(); | 5970 | let src_v = v.data.clone(); |
| 5948 | - let damping = i32::from(cdef.damping); | 5971 | + // libaom `av1_cdef_filter_fb`: `pri_strength = level << coeff_shift`, |
| 5972 | + // `sec_strength <<= coeff_shift`, `damping += coeff_shift - (pli != 0)`. | ||
| 5973 | + let coeff_shift = i32::from(bit_depth()) - 8; | ||
| 5974 | + let damping = i32::from(cdef.damping) + coeff_shift; | ||
| 5949 | let damping_uv = (damping - 1).max(0); | 5975 | let damping_uv = (damping - 1).max(0); |
| 5950 | let mut mi_r = 0usize; | 5976 | let mut mi_r = 0usize; |
| 5951 | while mi_r < skip_grid.mi_rows { | 5977 | while mi_r < skip_grid.mi_rows { |
| @@ -5963,7 +5989,7 @@ fn apply_cdef( | |||
| 5963 | i32::from(src_y[ny as usize * y_stride + nx as usize]) | 5989 | i32::from(src_y[ny as usize * y_stride + nx as usize]) |
| 5964 | } | 5990 | } |
| 5965 | }; | 5991 | }; |
| 5966 | - let (dir, var) = cdef_find_dir(|r, c| { | 5992 | + let (dir, var) = cdef_find_dir(coeff_shift, |r, c| { |
| 5967 | let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1)); | 5993 | let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1)); |
| 5968 | i32::from(src_y[ny * y_stride + nx]) | 5994 | i32::from(src_y[ny * y_stride + nx]) |
| 5969 | }); | 5995 | }); |
| @@ -5972,10 +5998,12 @@ fn apply_cdef( | |||
| 5972 | // -- each plane zeroes the shared direction when *its own* | 5998 | // -- each plane zeroes the shared direction when *its own* |
| 5973 | // frame-level primary strength is 0, independent of the | 5999 | // frame-level primary strength is 0, independent of the |
| 5974 | // per-block adjusted `t` and of the other plane's strength. | 6000 | // per-block adjusted `t` and of the other plane's strength. |
| 5975 | - let y_dir = if cdef.y_pri_strength[sidx] != 0 { dir } else { 0 }; | 6001 | + let y_pri_strength = i32::from(cdef.y_pri_strength[sidx]) << coeff_shift; |
| 5976 | - let t = cdef_adjust_strength(i32::from(cdef.y_pri_strength[sidx]), var); | 6002 | + let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift; |
| 6003 | + let y_dir = if y_pri_strength != 0 { dir } else { 0 }; | ||
| 6004 | + let t = cdef_adjust_strength(y_pri_strength, var); | ||
| 5977 | let enable_primary = t != 0; | 6005 | let enable_primary = t != 0; |
| 5978 | - let enable_secondary = cdef.y_sec_strength[sidx] != 0; | 6006 | + let enable_secondary = y_sec_strength != 0; |
| 5979 | if enable_primary || enable_secondary { | 6007 | if enable_primary || enable_secondary { |
| 5980 | cdef_filter_block( | 6008 | cdef_filter_block( |
| 5981 | sample_y, | 6009 | sample_y, |
| @@ -5985,19 +6013,21 @@ fn apply_cdef( | |||
| 5985 | 8, | 6013 | 8, |
| 5986 | 8, | 6014 | 8, |
| 5987 | t, | 6015 | t, |
| 5988 | - i32::from(cdef.y_sec_strength[sidx]), | 6016 | + y_sec_strength, |
| 5989 | y_dir, | 6017 | y_dir, |
| 5990 | damping, | 6018 | damping, |
| 5991 | damping, | 6019 | damping, |
| 5992 | enable_primary, | 6020 | enable_primary, |
| 5993 | enable_secondary, | 6021 | enable_secondary, |
| 6022 | + coeff_shift, | ||
| 5994 | ); | 6023 | ); |
| 5995 | } | 6024 | } |
| 5996 | 6025 | ||
| 5997 | - let t_uv = i32::from(cdef.uv_pri_strength[sidx]); | 6026 | + let t_uv = i32::from(cdef.uv_pri_strength[sidx]) << coeff_shift; |
| 6027 | + let uv_sec_strength = i32::from(cdef.uv_sec_strength[sidx]) << coeff_shift; | ||
| 5998 | let uv_dir = if t_uv != 0 { dir } else { 0 }; | 6028 | let uv_dir = if t_uv != 0 { dir } else { 0 }; |
| 5999 | let enable_primary_uv = t_uv != 0; | 6029 | let enable_primary_uv = t_uv != 0; |
| 6000 | - let enable_secondary_uv = cdef.uv_sec_strength[sidx] != 0; | 6030 | + let enable_secondary_uv = uv_sec_strength != 0; |
| 6001 | if enable_primary_uv || enable_secondary_uv { | 6031 | if enable_primary_uv || enable_secondary_uv { |
| 6002 | let (cox, coy) = (ox / 2, oy / 2); | 6032 | let (cox, coy) = (ox / 2, oy / 2); |
| 6003 | for (plane, src_p) in [(&mut *u, &src_u), (&mut *v, &src_v)] { | 6033 | for (plane, src_p) in [(&mut *u, &src_u), (&mut *v, &src_v)] { |
| @@ -6019,12 +6049,13 @@ fn apply_cdef( | |||
| 6019 | 4, | 6049 | 4, |
| 6020 | 4, | 6050 | 4, |
| 6021 | t_uv, | 6051 | t_uv, |
| 6022 | - i32::from(cdef.uv_sec_strength[sidx]), | 6052 | + uv_sec_strength, |
| 6023 | uv_dir, | 6053 | uv_dir, |
| 6024 | damping_uv, | 6054 | damping_uv, |
| 6025 | damping_uv, | 6055 | damping_uv, |
| 6026 | enable_primary_uv, | 6056 | enable_primary_uv, |
| 6027 | enable_secondary_uv, | 6057 | enable_secondary_uv, |
| 6058 | + coeff_shift, | ||
| 6028 | ); | 6059 | ); |
| 6029 | } | 6060 | } |
| 6030 | } | 6061 | } |
| @@ -7242,7 +7273,7 @@ fn read_inter_plane( | |||
| 7242 | None, | 7273 | None, |
| 7243 | )?; | 7274 | )?; |
| 7244 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); | 7275 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); |
| 7245 | - let residual = dequant_and_inverse_typed(&grid, side, 8, CURRENT_Q_IDX.with(|c| c.get()), dc_delta, ac_delta, tx_type); | 7276 | + let residual = dequant_and_inverse_typed(&grid, side, bit_depth(), CURRENT_Q_IDX.with(|c| c.get()), dc_delta, ac_delta, tx_type); |
| 7246 | plane.reconstruct_mc(x, y, side, prediction, &residual); | 7277 | plane.reconstruct_mc(x, y, side, prediction, &residual); |
| 7247 | Ok((grid, tx_type)) | 7278 | Ok((grid, tx_type)) |
| 7248 | } | 7279 | } |
crates/ec-av1/src/intra.rsmodified+7 -4
| @@ -158,21 +158,24 @@ impl Edges { | |||
| 158 | row.resize(want, last); | 158 | row.resize(want, last); |
| 159 | row | 159 | row |
| 160 | }; | 160 | }; |
| 161 | + // Spec 7.11.2.2's no-neighbour fallback is `base = 1 << (BitDepth - 1)` | ||
| 162 | + // (128 at 8-bit): `base - 1` above, `base + 1` left, `base` corner. | ||
| 163 | + let base = 1i32 << (crate::decode::bit_depth() - 1); | ||
| 161 | let above_row = match (above, left) { | 164 | let above_row = match (above, left) { |
| 162 | (Some(a), _) => extend(a), | 165 | (Some(a), _) => extend(a), |
| 163 | (None, Some(l)) => vec![i32::from(l[0]); want], | 166 | (None, Some(l)) => vec![i32::from(l[0]); want], |
| 164 | - (None, None) => vec![127; want], | 167 | + (None, None) => vec![base - 1; want], |
| 165 | }; | 168 | }; |
| 166 | let left_col = match (left, above) { | 169 | let left_col = match (left, above) { |
| 167 | (Some(l), _) => extend(l), | 170 | (Some(l), _) => extend(l), |
| 168 | (None, Some(a)) => vec![i32::from(a[0]); want], | 171 | (None, Some(a)) => vec![i32::from(a[0]); want], |
| 169 | - (None, None) => vec![129; want], | 172 | + (None, None) => vec![base + 1; want], |
| 170 | }; | 173 | }; |
| 171 | let corner = match (corner, above, left) { | 174 | let corner = match (corner, above, left) { |
| 172 | (Some(c), Some(_), Some(_)) => i32::from(c), | 175 | (Some(c), Some(_), Some(_)) => i32::from(c), |
| 173 | (_, Some(a), _) => i32::from(a[0]), | 176 | (_, Some(a), _) => i32::from(a[0]), |
| 174 | (_, None, Some(l)) => i32::from(l[0]), | 177 | (_, None, Some(l)) => i32::from(l[0]), |
| 175 | - (_, None, None) => 128, | 178 | + (_, None, None) => base, |
| 176 | }; | 179 | }; |
| 177 | let with_corner = |edge: Vec<i32>| { | 180 | let with_corner = |edge: Vec<i32>| { |
| 178 | let mut v = Vec::with_capacity(want + 1); | 181 | let mut v = Vec::with_capacity(want + 1); |
| @@ -597,7 +600,7 @@ fn dc(above: Option<&[u16]>, left: Option<&[u16]>, bw: usize, bh: usize) -> i32 | |||
| 597 | ((sum + (samples.len() as u32 >> 1)) / samples.len() as u32) as i32 | 600 | ((sum + (samples.len() as u32 >> 1)) / samples.len() as u32) as i32 |
| 598 | }; | 601 | }; |
| 599 | match (&above, &left) { | 602 | match (&above, &left) { |
| 600 | - (None, None) => 128, | 603 | + (None, None) => 1i32 << (crate::decode::bit_depth() - 1), |
| 601 | (Some(a), None) => average(a), | 604 | (Some(a), None) => average(a), |
| 602 | (None, Some(l)) => average(l), | 605 | (None, Some(l)) => average(l), |
| 603 | (Some(a), Some(l)) if bw == bh => { | 606 | (Some(a), Some(l)) if bw == bh => { |
crates/ec-av1/src/refusal_inventory.rsmodified+2 -1
| @@ -40,7 +40,8 @@ const REFUSALS: &[&str] = &[ | |||
| 40 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 40 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 41 | "a 32x32 partition type this decoder does not code (value={part32})", | 41 | "a 32x32 partition type this decoder does not code (value={part32})", |
| 42 | "a Golomb tail longer than this decoder reads", | 42 | "a Golomb tail longer than this decoder reads", |
| 43 | - "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", | 43 | + "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)", |
| 44 | + "a bit depth other than 8 with use_superres set (superres.rs's upscale_row is hardcoded 8-bit)", | ||
| 44 | "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)", | 45 | "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)", |
| 45 | "a tx_type symbol outside its CDF's own set: {t}", | 46 | "a tx_type symbol outside its CDF's own set: {t}", |
| 46 | "an INTER 32x32 partition type this decoder does not code (value={part32})", | 47 | "an INTER 32x32 partition type this decoder does not code (value={part32})", |
crates/ec-av1/src/stream.rsmodified+220 -19
| @@ -128,6 +128,19 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 128 | } | 128 | } |
| 129 | } | 129 | } |
| 130 | let output = if header.film_grain.apply_grain { | 130 | let output = if header.film_grain.apply_grain { |
| 131 | + // lane-hbd r5: `film_grain.rs`'s grain LUT and blend are | ||
| 132 | + // hardcoded 8-bit (`[i32; 256]`, clamps at 255) -- narrowed | ||
| 133 | + // from the old blanket bit-depth refusal to only the case | ||
| 134 | + // that actually reaches unported code. | ||
| 135 | + let bit_depth = parser | ||
| 136 | + .sequence_header() | ||
| 137 | + .map_or(8, |seq| seq.color_config.bit_depth); | ||
| 138 | + if bit_depth != 8 { | ||
| 139 | + return Err(Error::unsupported( | ||
| 140 | + "AV1 decode_stream", | ||
| 141 | + "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)", | ||
| 142 | + )); | ||
| 143 | + } | ||
| 131 | let mc_identity = parser | 144 | let mc_identity = parser |
| 132 | .sequence_header() | 145 | .sequence_header() |
| 133 | .is_some_and(|seq| seq.color_config.matrix_coefficients == 0); | 146 | .is_some_and(|seq| seq.color_config.matrix_coefficients == 0); |
| @@ -222,25 +235,16 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 222 | // Neighbours::delta_lf_grid -> lf_level) are now read and applied; | 235 | // Neighbours::delta_lf_grid -> lf_level) are now read and applied; |
| 223 | // no whole-frame refusal needed here anymore. | 236 | // no whole-frame refusal needed here anymore. |
| 224 | // | 237 | // |
| 225 | - // Both AV1 files in this box's own library (a 2160p HDR10 encode and a | 238 | + // lane-hbd r5: `Picture`'s `y`/`u`/`v` are `u16` now (widened an |
| 226 | - // 1080p one, probed 2026-08-30 through `examples/decode_probe`) are | 239 | + // earlier round), `BIT_DEPTH` is wired from this frame's own sequence |
| 227 | - // `yuv420p10le`, and every buffer this decoder reconstructs into -- | 240 | + // header (`set_bit_depth` above), and a real `aomenc --bit-depth=10` |
| 228 | - // `Picture`'s `y`/`u`/`v` -- is `Vec<u8>`. A 10- or 12-bit stream would | 241 | + // stream decodes pixel-exact against ffmpeg's own decode of the same |
| 229 | - // therefore be reconstructed into 8-bit samples and compared against a | 242 | + // bytes (`a_real_aomenc_10bit_stream_decodes_pixel_exact`). The |
| 230 | - // 10-bit reference, which is silent wrongness rather than a desync: no | 243 | + // blanket refusal that used to be here is gone; `film_grain.rs` and |
| 231 | - // symbol goes unread, the pixels are just quietly truncated. Refuse it | 244 | + // `superres.rs` still refuse narrowly by name (their own hardcoded |
| 232 | - // by name until the planes are widened. `bit_depth` defaults to 8 when | 245 | + // 8-bit LUT/clamp, above), and any other rounding gap 10-bit exposes |
| 233 | - // no sequence header has been seen, which is the existing behaviour for | 246 | + // will show up as a real pixel mismatch, not a silent truncation -- |
| 234 | - // every fixture in this crate. | 247 | + // the whole reason the widen (and this wiring) happened. |
| 235 | - if parser | ||
| 236 | - .sequence_header() | ||
| 237 | - .is_some_and(|seq| seq.color_config.bit_depth != 8) | ||
| 238 | - { | ||
| 239 | - return Err(Error::unsupported( | ||
| 240 | - "AV1 decode_stream", | ||
| 241 | - "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", | ||
| 242 | - )); | ||
| 243 | - } | ||
| 244 | if header.segmentation.enabled { | 248 | if header.segmentation.enabled { |
| 245 | return Err(Error::unsupported( | 249 | return Err(Error::unsupported( |
| 246 | "AV1 decode_stream", | 250 | "AV1 decode_stream", |
| @@ -415,6 +419,15 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 415 | // inter frames are decoded on a thread that previously decoded a | 419 | // inter frames are decoded on a thread that previously decoded a |
| 416 | // different sequence would inherit that sequence's bit. | 420 | // different sequence would inherit that sequence's bit. |
| 417 | crate::decode::set_enable_edge_filter(enable_edge_filter); | 421 | crate::decode::set_enable_edge_filter(enable_edge_filter); |
| 422 | + // lane-hbd r5: `BIT_DEPTH` (decode.rs) drives `crate::decode::sample_max`, | ||
| 423 | + // which every dequant/inverse-transform clamp reads -- set per frame, | ||
| 424 | + // not once per process, for the same cross-sequence-on-one-thread | ||
| 425 | + // reason as `set_enable_edge_filter` above. Defaults to 8 when no | ||
| 426 | + // sequence header has been seen yet, matching every existing fixture. | ||
| 427 | + let bit_depth = parser | ||
| 428 | + .sequence_header() | ||
| 429 | + .map_or(8, |seq| seq.color_config.bit_depth); | ||
| 430 | + crate::decode::set_bit_depth(bit_depth); | ||
| 418 | // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits. | 431 | // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits. |
| 419 | let enable_masked_compound = parser | 432 | let enable_masked_compound = parser |
| 420 | .sequence_header() | 433 | .sequence_header() |
| @@ -496,6 +509,15 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 496 | // call above, right before anything else can overwrite it) -- | 509 | // call above, right before anything else can overwrite it) -- |
| 497 | // see `decode::take_last_frame_wide_margin`'s doc. | 510 | // see `decode::take_last_frame_wide_margin`'s doc. |
| 498 | let wide_margin = crate::decode::take_last_frame_wide_margin(); | 511 | let wide_margin = crate::decode::take_last_frame_wide_margin(); |
| 512 | + // lane-hbd r5: `upscale_row` (superres.rs) is `&[u8]`, clamping at | ||
| 513 | + // 255 -- narrowed from the old blanket bit-depth refusal to only | ||
| 514 | + // the case that actually reaches unported code. | ||
| 515 | + if header.use_superres && bit_depth != 8 { | ||
| 516 | + return Err(Error::unsupported( | ||
| 517 | + "AV1 decode_stream", | ||
| 518 | + "a bit depth other than 8 with use_superres set (superres.rs's upscale_row is hardcoded 8-bit)", | ||
| 519 | + )); | ||
| 520 | + } | ||
| 499 | let picture = if header.use_superres { | 521 | let picture = if header.use_superres { |
| 500 | crate::superres::upscale_picture( | 522 | crate::superres::upscale_picture( |
| 501 | &picture, | 523 | &picture, |
| @@ -688,6 +710,14 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 688 | } | 710 | } |
| 689 | if header.show_frame { | 711 | if header.show_frame { |
| 690 | let output = if header.film_grain.apply_grain { | 712 | let output = if header.film_grain.apply_grain { |
| 713 | + // lane-hbd r5: same 8-bit-only LUT/blend as the | ||
| 714 | + // show_existing_frame arm above. | ||
| 715 | + if bit_depth != 8 { | ||
| 716 | + return Err(Error::unsupported( | ||
| 717 | + "AV1 decode_stream", | ||
| 718 | + "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)", | ||
| 719 | + )); | ||
| 720 | + } | ||
| 691 | let mc_identity = parser | 721 | let mc_identity = parser |
| 692 | .sequence_header() | 722 | .sequence_header() |
| 693 | .is_some_and(|seq| seq.color_config.matrix_coefficients == 0); | 723 | .is_some_and(|seq| seq.color_config.matrix_coefficients == 0); |
| @@ -909,6 +939,68 @@ mod tests { | |||
| 909 | .collect() | 939 | .collect() |
| 910 | } | 940 | } |
| 911 | 941 | ||
| 942 | + /// As [`ffmpeg_decode_sequence`], but for a `yuv420p10le` stream: samples | ||
| 943 | + /// are 2-byte little-endian, one full 16-bit range regardless of the | ||
| 944 | + /// stream's real 10-bit depth (ffmpeg's rawvideo muxer never packs to the | ||
| 945 | + /// bit depth). The 8-bit helper above stays untouched -- every existing | ||
| 946 | + /// gate depends on it. | ||
| 947 | + fn ffmpeg_decode_sequence_10bit( | ||
| 948 | + stream: &[u8], | ||
| 949 | + width: usize, | ||
| 950 | + height: usize, | ||
| 951 | + frames: usize, | ||
| 952 | + ) -> Vec<Pic> { | ||
| 953 | + let mut child = Command::new("ffmpeg") | ||
| 954 | + .args([ | ||
| 955 | + "-v", "error", "-f", "obu", "-i", "-", "-f", "rawvideo", "-pix_fmt", | ||
| 956 | + "yuv420p10le", "-", | ||
| 957 | + ]) | ||
| 958 | + .stdin(Stdio::piped()) | ||
| 959 | + .stdout(Stdio::piped()) | ||
| 960 | + .stderr(Stdio::piped()) | ||
| 961 | + .spawn() | ||
| 962 | + .expect("ffmpeg failed to start"); | ||
| 963 | + child | ||
| 964 | + .stdin | ||
| 965 | + .take() | ||
| 966 | + .expect("ffmpeg stdin") | ||
| 967 | + .write_all(stream) | ||
| 968 | + .expect("writing the stream to ffmpeg"); | ||
| 969 | + let out = child.wait_with_output().expect("ffmpeg failed to run"); | ||
| 970 | + assert!( | ||
| 971 | + out.status.success(), | ||
| 972 | + "ffmpeg refused the stream: {}", | ||
| 973 | + String::from_utf8_lossy(&out.stderr) | ||
| 974 | + ); | ||
| 975 | + let (luma, chroma) = (width * height, width * height / 4); | ||
| 976 | + let frame_samples = luma + 2 * chroma; | ||
| 977 | + let frame_bytes = frame_samples * 2; | ||
| 978 | + assert_eq!( | ||
| 979 | + out.stdout.len(), | ||
| 980 | + frame_bytes * frames, | ||
| 981 | + "expected {frames} 4:2:0 10-bit frames, ffmpeg said: {}", | ||
| 982 | + String::from_utf8_lossy(&out.stderr) | ||
| 983 | + ); | ||
| 984 | + fn le16(bytes: &[u8]) -> Vec<u16> { | ||
| 985 | + bytes | ||
| 986 | + .chunks_exact(2) | ||
| 987 | + .map(|c| u16::from_le_bytes([c[0], c[1]])) | ||
| 988 | + .collect() | ||
| 989 | + } | ||
| 990 | + (0..frames) | ||
| 991 | + .map(|i| { | ||
| 992 | + let base = i * frame_bytes; | ||
| 993 | + Pic { | ||
| 994 | + width, | ||
| 995 | + height, | ||
| 996 | + y: le16(&out.stdout[base..base + luma * 2]), | ||
| 997 | + u: le16(&out.stdout[base + luma * 2..base + luma * 2 + chroma * 2]), | ||
| 998 | + v: le16(&out.stdout[base + luma * 2 + chroma * 2..base + frame_bytes]), | ||
| 999 | + } | ||
| 1000 | + }) | ||
| 1001 | + .collect() | ||
| 1002 | + } | ||
| 1003 | + | ||
| 912 | /// `decode_stream` agrees with ffmpeg/dav1d on the same wire bytes -- an | 1004 | /// `decode_stream` agrees with ffmpeg/dav1d on the same wire bytes -- an |
| 913 | /// independent decoder, not just this crate checking its own tile path. | 1005 | /// independent decoder, not just this crate checking its own tile path. |
| 914 | #[test] | 1006 | #[test] |
| @@ -1741,6 +1833,115 @@ mod tests { | |||
| 1741 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg"); | 1833 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg"); |
| 1742 | } | 1834 | } |
| 1743 | 1835 | ||
| 1836 | + /// lane-hbd r5: a real `aomenc --bit-depth=10` stream, decoded through | ||
| 1837 | + /// this crate's own 10-bit planes (`Picture` widened to `u16` in an | ||
| 1838 | + /// earlier round) and checked pixel-exact against ffmpeg's own decode of | ||
| 1839 | + /// the identical bytes via [`ffmpeg_decode_sequence_10bit`]. Confirms | ||
| 1840 | + /// (hard-asserts, not just trusts) the sequence header this stream | ||
| 1841 | + /// actually parses to says `bit_depth == 10` before trusting any pixel | ||
| 1842 | + /// match -- a stream that silently fell back to 8-bit would still | ||
| 1843 | + /// "match" trivially. | ||
| 1844 | + #[test] | ||
| 1845 | + fn a_real_aomenc_10bit_stream_decodes_pixel_exact() { | ||
| 1846 | + const NAME: &str = "a_real_aomenc_10bit_stream_decodes_pixel_exact"; | ||
| 1847 | + if !have_ffmpeg() { | ||
| 1848 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 1849 | + return; | ||
| 1850 | + } | ||
| 1851 | + if !have_aomenc() { | ||
| 1852 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 1853 | + return; | ||
| 1854 | + } | ||
| 1855 | + let (width, height) = (64usize, 64usize); | ||
| 1856 | + let y4m = Command::new("ffmpeg") | ||
| 1857 | + .args([ | ||
| 1858 | + "-v", | ||
| 1859 | + "error", | ||
| 1860 | + "-f", | ||
| 1861 | + "lavfi", | ||
| 1862 | + "-i", | ||
| 1863 | + &gradients_source(42, width, height, "duration=0.04:rate=25"), | ||
| 1864 | + "-pix_fmt", | ||
| 1865 | + "yuv420p10le", | ||
| 1866 | + "-strict", | ||
| 1867 | + "-1", | ||
| 1868 | + "-t", | ||
| 1869 | + "0.04", | ||
| 1870 | + "-f", | ||
| 1871 | + "yuv4mpegpipe", | ||
| 1872 | + "-", | ||
| 1873 | + ]) | ||
| 1874 | + .stdin(Stdio::null()) | ||
| 1875 | + .stdout(Stdio::piped()) | ||
| 1876 | + .stderr(Stdio::piped()) | ||
| 1877 | + .output() | ||
| 1878 | + .expect("ffmpeg failed to run"); | ||
| 1879 | + assert!( | ||
| 1880 | + y4m.status.success(), | ||
| 1881 | + "ffmpeg failed to render the 10-bit fixture: {}", | ||
| 1882 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 1883 | + ); | ||
| 1884 | + let mut child = Command::new(aomenc_path()) | ||
| 1885 | + .args([ | ||
| 1886 | + "--codec=av1", | ||
| 1887 | + "--passes=1", | ||
| 1888 | + "--end-usage=q", | ||
| 1889 | + "--cq-level=30", | ||
| 1890 | + "--cpu-used=0", | ||
| 1891 | + "--threads=1", | ||
| 1892 | + "--row-mt=0", | ||
| 1893 | + "--sb-size=64", | ||
| 1894 | + "--input-bit-depth=10", | ||
| 1895 | + "--bit-depth=10", | ||
| 1896 | + "--limit=1", | ||
| 1897 | + "--obu", | ||
| 1898 | + "-o", | ||
| 1899 | + "-", | ||
| 1900 | + "-", | ||
| 1901 | + ]) | ||
| 1902 | + .stdin(Stdio::piped()) | ||
| 1903 | + .stdout(Stdio::piped()) | ||
| 1904 | + .stderr(Stdio::piped()) | ||
| 1905 | + .spawn() | ||
| 1906 | + .expect("aomenc failed to start"); | ||
| 1907 | + child | ||
| 1908 | + .stdin | ||
| 1909 | + .take() | ||
| 1910 | + .expect("aomenc stdin") | ||
| 1911 | + .write_all(&y4m.stdout) | ||
| 1912 | + .expect("writing y4m to aomenc"); | ||
| 1913 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 1914 | + assert!( | ||
| 1915 | + out.status.success(), | ||
| 1916 | + "aomenc refused the 10-bit fixture: {}", | ||
| 1917 | + String::from_utf8_lossy(&out.stderr) | ||
| 1918 | + ); | ||
| 1919 | + let stream = out.stdout; | ||
| 1920 | + // Confirm the sequence header this stream actually parses to before | ||
| 1921 | + // trusting any pixel comparison below. | ||
| 1922 | + let mut probe = Av1Parser::new(); | ||
| 1923 | + let mut pos = 0usize; | ||
| 1924 | + while pos < stream.len() && probe.sequence_header().is_none() { | ||
| 1925 | + let obu = probe.parse_obu(&stream[pos..]).unwrap(); | ||
| 1926 | + pos += obu.total_size; | ||
| 1927 | + } | ||
| 1928 | + let seq = probe | ||
| 1929 | + .sequence_header() | ||
| 1930 | + .expect("stream has a sequence header OBU"); | ||
| 1931 | + assert_eq!( | ||
| 1932 | + seq.color_config.bit_depth, 10, | ||
| 1933 | + "{NAME}: aomenc did not actually write a 10-bit sequence header" | ||
| 1934 | + ); | ||
| 1935 | + let frames = match decode_stream(&stream) { | ||
| 1936 | + Ok(frames) => frames, | ||
| 1937 | + Err(e) => panic!("{NAME}: decode_stream refused a real 10-bit stream: {e}"), | ||
| 1938 | + }; | ||
| 1939 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1); | ||
| 1940 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "luma vs ffmpeg (10-bit)"); | ||
| 1941 | + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (10-bit)"); | ||
| 1942 | + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (10-bit)"); | ||
| 1943 | + } | ||
| 1944 | + | ||
| 1744 | /// A real `aomenc` palette-**UV** fixture (lane-palette2 r2): `testsrc2` | 1945 | /// A real `aomenc` palette-**UV** fixture (lane-palette2 r2): `testsrc2` |
| 1745 | /// (the multicoloured AV1 test pattern -- flat, few-colour, repetitive | 1946 | /// (the multicoloured AV1 test pattern -- flat, few-colour, repetitive |
| 1746 | /// per-region colour *and* chroma, unlike `smptebars=hue=s=0` above, | 1947 | /// per-region colour *and* chroma, unlike `smptebars=hue=s=0` above, |
lanes/hbd-r5.charter.mdadded+57 -0
| @@ -0,0 +1,57 @@ | |||
| 1 | +# lane-hbd r5 — steps 1 to 5, nothing to widen | ||
| 2 | + | ||
| 3 | +At main-merged HEAD. **The Picture widen is DONE and merged** (main fff022d, | ||
| 4 | +264/0, workspace clean). Do not re-attempt it. r4 never got to write its report | ||
| 5 | +to disk — its content is in `lanes/hbd-r4.report.md` if a later hand copied it; | ||
| 6 | +if that file is missing, do not spend turns reconstructing it, the facts you | ||
| 7 | +need are here. | ||
| 8 | + | ||
| 9 | +I also fixed one thing r4 could not see: it checked `-p ec-av1` only, and | ||
| 10 | +`tools/ec-bench` builds a `Picture` from 8-bit y4m. Widened at the call site. | ||
| 11 | +Check `--workspace --all-targets`, not just this crate, before you call a | ||
| 12 | +compile clean. | ||
| 13 | + | ||
| 14 | +## The round: charter steps 1-5, in order, each committed | ||
| 15 | +1. **Wire `decode::set_bit_depth`.** It is at `decode.rs:97`, never called, so | ||
| 16 | + the `BIT_DEPTH` thread-local is dead code defaulting to 8 — the compiler says | ||
| 17 | + so (`function set_bit_depth is never used`). Call it from `stream.rs` with | ||
| 18 | + `seq.color_config.bit_depth`, per frame before decode, not once per process. | ||
| 19 | + Everything downstream silently assumes 8 until this lands. | ||
| 20 | +2. **Narrow refusals** for the two paths that are 8-bit by construction: | ||
| 21 | + `film_grain.rs` (grain LUT is `[i32; 256]`) and `superres.rs` (`upscale_row` | ||
| 22 | + is `&[u8]`, clamps at 255). Each gets its own named `bit_depth != 8` refusal, | ||
| 23 | + declared in `refusal_inventory.rs`. These are honest scoped refusals; the | ||
| 24 | + blanket one is not. | ||
| 25 | +3. **The 10-bit gate.** `ffmpeg_decode_sequence` hardcodes `-pix_fmt yuv420p`; | ||
| 26 | + add a second helper emitting `yuv420p10le` with u16 LE parsing, leaving the | ||
| 27 | + 8-bit helper untouched — every existing gate depends on it. aomenc needs | ||
| 28 | + `--bit-depth=10` and a 10-bit input. Confirm from the sequence header that | ||
| 29 | + `bit_depth` really is 10 before trusting a pixel match, and hard-assert it. | ||
| 30 | +4. **Lift the blanket refusal** in `stream.rs`, in the SAME commit as that gate, | ||
| 31 | + updating `refusal_inventory.rs`. | ||
| 32 | +5. **His own films.** Both `yuv420p10le`: ReelB (3840x1608, HDR10, Main, | ||
| 33 | + no film grain flagged) and ReelC (1920x792, bt709, Main, no film grain). | ||
| 34 | + Extract into this worktree's `fixtures/` with | ||
| 35 | + `ffmpeg -i <file> -t 3 -c:v copy -f obu <out.obu>` (note `-f obu`), probe with | ||
| 36 | + `cargo run -p ec-av1 --example decode_probe -- <out.obu>`, and record the next | ||
| 37 | + refusal VERBATIM with the film and header state. That sentence is the next | ||
| 38 | + lane's charter. Never open his media in a GUI app. | ||
| 39 | + | ||
| 40 | +Expect 10-bit to expose rounding that 8-bit hid — the inverse transform's | ||
| 41 | +intermediate clamps already take `bit_depth`, but anything still assuming a 255 | ||
| 42 | +ceiling shows up as a small pixel delta, not a crash. Bisect against the oracle, | ||
| 43 | +not by inspection. | ||
| 44 | + | ||
| 45 | +If a step does not fit, commit the ones that do and say which. Landing red on | ||
| 46 | +this branch is fine; only merging red is forbidden, and I do the merges. | ||
| 47 | + | ||
| 48 | +## Budget discipline | ||
| 49 | +75 turns, no reset on resume. At about turn 55, stop starting new work: commit, | ||
| 50 | +and write `lanes/hbd-r5.report.md` — r4 hit the cap before it could write its | ||
| 51 | +report at all, which is the one artifact I cannot reconstruct. | ||
| 52 | + | ||
| 53 | +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-hbd`; foreground | ||
| 54 | +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms; ffmpeg | ||
| 55 | +generates bounded with `-t`; `EC_AV1_REQUIRE_AOMENC=1`; aomenc | ||
| 56 | +`--threads=1 --row-mt=0 --sb-size=64`. Sibling worktrees have live agents — | ||
| 57 | +never build in or edit them. Never push, never merge into main. | ||
lanes/hbd-r5.report.mdadded+92 -0
| @@ -0,0 +1,92 @@ | |||
| 1 | +# lane-hbd r5 report | ||
| 2 | + | ||
| 3 | +Branch `lane-hbd`, worktree `edith_codecs-hbd`. All 5 charter steps attempted, | ||
| 4 | +in order, each its own commit. `cargo check --workspace --all-targets` is | ||
| 5 | +clean. Landing red on this branch (the 10-bit gate fails) per charter | ||
| 6 | +permission -- not merged, not asked to be. | ||
| 7 | + | ||
| 8 | +## Commits this round | ||
| 9 | +1. `3478044` feat(av1): wire decode::set_bit_depth from stream.rs per frame | ||
| 10 | +2. `147a2ea` feat(av1): narrow bit_depth != 8 refusals for film_grain and superres | ||
| 11 | +3. `0ce7fef` feat(av1): 10-bit gate + lift the blanket bit_depth refusal | ||
| 12 | + | ||
| 13 | +## Step 1 -- wire set_bit_depth (DONE) | ||
| 14 | +`stream.rs` now reads `seq.color_config.bit_depth` per frame (defaulting to 8 | ||
| 15 | +with no sequence header yet) and calls `decode::set_bit_depth`, right next to | ||
| 16 | +the existing `set_enable_edge_filter` call, for the identical | ||
| 17 | +cross-sequence-on-one-thread reason. `BIT_DEPTH` is no longer dead code. | ||
| 18 | + | ||
| 19 | +## Step 2 -- narrow refusals (DONE) | ||
| 20 | +Two new named refusals in `stream.rs`, both guarding the exact unported code: | ||
| 21 | +- `film_grain.rs`'s grain LUT/blend (`[i32; 256]`, clamps at 255) -- checked at | ||
| 22 | + both `apply_grain` call sites (`show_existing_frame` and the normal | ||
| 23 | + `show_frame` path). | ||
| 24 | +- `superres.rs`'s `upscale_row` (`&[u8]`, clamps at 255) -- checked before the | ||
| 25 | + `use_superres` key-frame branch. | ||
| 26 | + | ||
| 27 | +Both declared in `refusal_inventory.rs`'s `REFUSALS` list; | ||
| 28 | +`the_decode_path_refuses_exactly_the_listed_cases` passes. | ||
| 29 | + | ||
| 30 | +## Step 3 -- the 10-bit gate (DONE, gate is RED) | ||
| 31 | +`ffmpeg_decode_sequence_10bit` (stream.rs, next to the existing 8-bit | ||
| 32 | +`ffmpeg_decode_sequence`, which is untouched) parses `yuv420p10le` rawvideo as | ||
| 33 | +u16 LE. `a_real_aomenc_10bit_stream_decodes_pixel_exact` drives a real | ||
| 34 | +`aomenc --input-bit-depth=10 --bit-depth=10 --threads=1 --row-mt=0 | ||
| 35 | +--sb-size=64` stream (gradients content, ffmpeg y4m into aomenc's stdin, same | ||
| 36 | +recipe as the existing palette-Y gate), parses the produced stream's own | ||
| 37 | +sequence header and hard-asserts `bit_depth == 10` *before* trusting any | ||
| 38 | +pixel comparison, then compares `decode_stream`'s output against | ||
| 39 | +`ffmpeg_decode_sequence_10bit` on the identical bytes. | ||
| 40 | + | ||
| 41 | +The gate runs for real -- aomenc wrote a genuine 10-bit sequence header, not a | ||
| 42 | +SKIP -- and fails on the pixel comparison: this decoder's luma comes out | ||
| 43 | +~82-117, ffmpeg's own 10-bit decode of the same bytes is ~331-471 for the same | ||
| 44 | +gradient content, roughly a factor of 4 apart (2^(10-8) squared, or two | ||
| 45 | +missed left-shifts by `bit_depth - 8`). This is NOT the "small rounding | ||
| 46 | +delta" the charter expected from unclamped intermediate math -- it is a | ||
| 47 | +systematic magnitude defect, most likely a fixed `<< (bit_depth - 8)` / | ||
| 48 | +`>> (bit_depth - 8)` this decoder never applies anywhere (DC pred's initial | ||
| 49 | +value, a reconstruction clamp, or dequant), still written as if every stream | ||
| 50 | +were 8-bit. Root-cause bisection (which stage first drops the scale) is next | ||
| 51 | +round's first job -- I did not spend remaining budget chasing it live. | ||
| 52 | + | ||
| 53 | +## Step 4 -- lift the blanket refusal (DONE, same commit as the gate) | ||
| 54 | +The old `stream.rs` blanket `"a stream whose bit depth is not 8..."` check is | ||
| 55 | +gone; `refusal_inventory.rs` updated to match (still green). The narrow | ||
| 56 | +film_grain/superres refusals from step 2 are the only bit-depth gates left. | ||
| 57 | + | ||
| 58 | +## Step 5 -- his own films (DONE) | ||
| 59 | +Extracted 3s of each into this worktree's `fixtures/hbd-r5/` (outside the | ||
| 60 | +repo via the `fixtures` symlink, so durable): | ||
| 61 | +- `ffmpeg -i ".../reelb.mkv" -t 3 -c:v copy -an -f obu reelb.obu` | ||
| 62 | +- `ffmpeg -i ".../reelcmkv" -t 3 -c:v copy -an -f obu reelc.obu` | ||
| 63 | + | ||
| 64 | +Probed with `cargo run -p ec-av1 --example decode_probe -- <file>`: | ||
| 65 | + | ||
| 66 | +- **ReelB** (Ballad of ReelB and Snakes, 2160p HDR10): | ||
| 67 | + `REFUSED: unsupported: AV1 tile (a partition below 8x8 (this decoder codes | ||
| 68 | + no leaf smaller than 8x8))` | ||
| 69 | +- **ReelC** (Director's Cut, 1080p): | ||
| 70 | + `REFUSED: unsupported: AV1 tile (a 32x32 partition type this decoder does | ||
| 71 | + not code (value=4))` | ||
| 72 | + | ||
| 73 | +Neither refusal is the bit-depth wall anymore -- lifting the blanket refusal | ||
| 74 | +is real, verified progress: both real 10-bit films now reach genuine | ||
| 75 | +partition-coverage gaps instead of being stopped before decode even starts. | ||
| 76 | +**These two refusal strings, verbatim, are the next lane's charter starting | ||
| 77 | +point** -- sub-8x8 leaf partitions (ReelB) and 32x32 partition | ||
| 78 | +type=4 (ReelC, likely `PARTITION_VERT_4` or similar AB/1-to-4 type this | ||
| 79 | +decoder's part32 match arm doesn't cover), on top of fixing the 10-bit scale | ||
| 80 | +defect found in step 3. | ||
| 81 | + | ||
| 82 | +## What's owed next round | ||
| 83 | +1. Root-cause and fix the ~4x luma scale defect the 10-bit gate found | ||
| 84 | + (bisect against the oracle per-stage, not by inspection, per the | ||
| 85 | + charter's own warning). | ||
| 86 | +2. Sub-8x8 partition leaves (ReelB' real gap). | ||
| 87 | +3. 32x32 partition value=4 (ReelC's real gap) -- check against `decode.rs`'s | ||
| 88 | + part32 match arm coverage. | ||
| 89 | + | ||
| 90 | +## Deferred | ||
| 91 | +- deferred: 10-bit gate root-cause fix — turn budget (charter's step-3/4/5 | ||
| 92 | + ordering + report-writing left no room this round) — next lane's first job. | ||
lanes/hbd-r7.report.mdadded+123 -0
| @@ -0,0 +1,123 @@ | |||
| 1 | +# lane-hbd round 7 report | ||
| 2 | + | ||
| 3 | +## Step 1: gate on d6bd69a (CDEF fix, unmeasured going in) | ||
| 4 | + | ||
| 5 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture` | ||
| 6 | +(fixed the `-j4` flag placement -- it belongs before `--`, not after, as a | ||
| 7 | +libtest arg; `cargo test -j4 -p ec-av1 --lib ... -- --nocapture`) | ||
| 8 | + | ||
| 9 | +Diff count: **1 of 4096 luma pixels off by exactly 1** (down from round 6's | ||
| 10 | +32). Chroma (U, V) exact. `left: [..., 328, ...] right: [..., 327, ...]`, | ||
| 11 | +extracted via the python re.search method. | ||
| 12 | + | ||
| 13 | +EVIDENCE: /tmp/gate_r7.log | cargo test -j4 -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture | 1/4096 luma pixels differ by 1, chroma untested (Y assert panics first) | ||
| 14 | + | ||
| 15 | +## Step 2: geometry | ||
| 16 | + | ||
| 17 | +Added a temporary per-plane diff dump (`HBD_R7_YDIFF`/`UDIFF`/`VDIFF`, since | ||
| 18 | +reverted) before the asserts to get all three planes' diffs without the | ||
| 19 | +first `assert_eq!` short-circuiting. Result: `Y: [(x=1, y=34, ours=328, | ||
| 20 | +theirs=327)]`, `U: []`, `V: []` -- a single luma pixel, near the left frame | ||
| 21 | +edge (x=1), row 34 (inside CDEF 8x8 block row 4, i.e. rows 32-39), not on | ||
| 22 | +an LR-unit or CDEF-block corner. | ||
| 23 | + | ||
| 24 | +EVIDENCE: /tmp/gate_r7c.log (dump run) | cargo test -j4 -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture | HBD_R7_YDIFF [(1, 34, 328, 327)], U/V empty | ||
| 25 | + | ||
| 26 | +## Step 3: root cause -- checked against `~/.cache/aom-oracle/src/av1/common/cdef_block.c` and `cdef.h` | ||
| 27 | + | ||
| 28 | +Ruled out, all verified line-for-line against libaom source (not rebuilt, | ||
| 29 | +read only): | ||
| 30 | +- `cdef.h:61` `constrain()` -- matches `cdef_constrain` exactly. | ||
| 31 | +- `cdef_block.c:57-110` `cdef_find_dir_c` -- matches `cdef_find_dir` exactly | ||
| 32 | + (partial-sum accumulation, div_table, cost formula, `>>128` centring). | ||
| 33 | +- `cdef_block.c:250-256` frame-boundary `CDEF_VERY_LARGE` fill -- matches | ||
| 34 | + our `ny<0||nx<0||...>=true_w/h` boundary check; this 64x64 fixture is | ||
| 35 | + exactly one superblock so every frame edge coincides with the SB edge, | ||
| 36 | + same as libaom's `frame_boundary[LEFT/RIGHT/TOP/BOTTOM]` gating. | ||
| 37 | +- `cdef_block.c:135` `Cdef_Directions` table -- byte-for-byte identical to | ||
| 38 | + our `CDEF_DIRECTIONS`. | ||
| 39 | +- `cdef_block.c:190` output rounding `(8 + sum - (sum<0)) >> 4` -- identical | ||
| 40 | + to ours. | ||
| 41 | +- `cdef_block.c:289-292` `adjust_strength` -- identical; and `cdef_block.c:388` | ||
| 42 | + confirms it's luma-only (`pli ? pri_strength : adjust_strength(...)`, | ||
| 43 | + matching our chroma path skipping it). | ||
| 44 | +- `cdef_block.c:352-360` direction reuse for 4:2:0 chroma (`xdec==ydec`, no | ||
| 45 | + `conv422`/`conv440` remap) -- matches our shared `dir`/`uv_dir` reuse. | ||
| 46 | + | ||
| 47 | +**Root cause found**: `cdef_block.c:147` | ||
| 48 | +`pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1]` -- libaom | ||
| 49 | +right-shifts `pri_strength` by `coeff_shift` *before* reading the tap-set | ||
| 50 | +parity bit, because `pri_strength` (and its `adjust_strength` derivative) | ||
| 51 | +was pre-shifted `<< coeff_shift` for the bit-depth scale up in | ||
| 52 | +`av1_cdef_filter_fb`. Our `cdef_filter_block` read `pri_strength & 1` | ||
| 53 | +directly. For 8-bit (`coeff_shift == 0`) this is a no-op and every existing | ||
| 54 | +8-bit gate stayed exact by construction. For 10-bit (`coeff_shift == 2`), | ||
| 55 | +`pri_strength` is always a multiple of 4, so `pri_strength & 1` was always | ||
| 56 | +0 -- CDEF silently always used primary tap set `{4,2}` instead of `{3,3}` | ||
| 57 | +whenever the true (unshifted) strength level was odd. This only produces a | ||
| 58 | +visible pixel difference where the wrong tap set actually changes the | ||
| 59 | +clamped/rounded output, which explains the very sparse (1/4096) residue. | ||
| 60 | + | ||
| 61 | +Fix: threaded `coeff_shift` into `cdef_filter_block` and changed the index | ||
| 62 | +to `(pri_strength >> coeff_shift) & 1`, matching libaom exactly. Both call | ||
| 63 | +sites (luma, chroma) updated. Commit `7e007da`. | ||
| 64 | + | ||
| 65 | +## Step 1 re-run after the fix | ||
| 66 | + | ||
| 67 | +`cargo test -j4 -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture` | ||
| 68 | +-> **0 diffs, all three planes** (`HBD_R7_YDIFF []`, `UDIFF []`, `VDIFF []`), | ||
| 69 | +`test result: ok`. | ||
| 70 | + | ||
| 71 | +EVIDENCE: /tmp/gate_r7c.log | cargo test -j4 -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture | test result: ok. 1 passed; 0 failed | ||
| 72 | + | ||
| 73 | +Temporary diff-dump instrumentation reverted from `stream.rs` before commit | ||
| 74 | +(the gate's own three `assert_eq!`s are the permanent check). | ||
| 75 | + | ||
| 76 | +## Step 3: full suite | ||
| 77 | + | ||
| 78 | +`cargo test -j4 -p ec-av1 --lib` (with `EC_AV1_REQUIRE_AOMENC=1`): | ||
| 79 | +**265 passed, 0 failed, 19 ignored, 0 filtered out, 203.66s.** 8-bit gates | ||
| 80 | +unaffected (they run at `coeff_shift == 0`, where the fix is a no-op). | ||
| 81 | + | ||
| 82 | +EVIDENCE: /tmp/suite_r7.log | cargo test -j4 -p ec-av1 --lib | test result: ok. 265 passed; 0 failed; 19 ignored; finished in 203.66s | ||
| 83 | + | ||
| 84 | +## Step 4: workspace check | ||
| 85 | + | ||
| 86 | +`cargo check --workspace --all-targets` -> exit 0, warnings only (doc-lint | ||
| 87 | +noise, one unused-fn/unused-var, pre-existing), no errors. | ||
| 88 | + | ||
| 89 | +EVIDENCE: /tmp/wscheck_r7.log | cargo check --workspace --all-targets | EXIT 0 | ||
| 90 | + | ||
| 91 | +## Step 5: decode_probe on real films | ||
| 92 | + | ||
| 93 | +Not run: this worktree has no `ReelB`/`ReelC` extracts in | ||
| 94 | +`fixtures/`. Per ledger `dead-end|lane-realworld r8`, those came from the | ||
| 95 | +`lane-realworld` worktree, which was destroyed by an external process | ||
| 96 | +mid-session (its commit `bd91ad0` is unreachable in any ref/reflog). round | ||
| 97 | +6's report never mentions leaving copies in *this* worktree either. | ||
| 98 | +`crates/ec-av1/examples/decode_probe.rs` exists and is unmodified this | ||
| 99 | +round -- nothing to re-run against. | ||
| 100 | + | ||
| 101 | +deferred: real-film decode_probe sweep — no fixture present in this | ||
| 102 | +worktree, source extracts lost with lane-realworld's worktree — needs the | ||
| 103 | +orchestrator to either re-extract from the originals or hand this worktree | ||
| 104 | +a copy. | ||
| 105 | + | ||
| 106 | +## Summary | ||
| 107 | + | ||
| 108 | +- Diff count after the CDEF commit (`d6bd69a`): 1/4096 luma pixels, off by | ||
| 109 | + exactly 1, chroma exact. | ||
| 110 | +- Geometry: single pixel at (x=1, y=34), inside CDEF 8x8 block row 4 near | ||
| 111 | + the left frame edge; not a block/LR-unit boundary artifact. | ||
| 112 | +- Root cause (closed): `cdef_filter_block`'s primary-tap-set index used | ||
| 113 | + `pri_strength & 1` instead of `(pri_strength >> coeff_shift) & 1` | ||
| 114 | + (libaom `cdef_block.c:147`); at `coeff_shift=2` (10-bit) this always | ||
| 115 | + selected tap set `{4,2}`, silently dropping tap set `{3,3}` for odd | ||
| 116 | + strength levels. Fixed in `7e007da`; gate now 0/4096 diffs. | ||
| 117 | +- Full suite: 265 passed, 0 failed, 19 ignored. | ||
| 118 | +- `cargo check --workspace --all-targets`: clean (exit 0). | ||
| 119 | +- HEAD: `7e007da` (report commit follows at HEAD after this write). | ||
| 120 | +- Open: real-film `decode_probe` sweep deferred (fixture missing from this | ||
| 121 | + worktree, see above). Everything else in the charter is closed and | ||
| 122 | + green -- this lane is ready for merge from a correctness standpoint, | ||
| 123 | + modulo that one deferred non-blocking sweep. | ||