wip(hbd): scale intra no-neighbour fallback (127/128/129) by bit depth
Browse files at this commitf973434227342b3df328ff6f91a87448efc8f9b0Parent: 386939c1 changed file +7 -4
crates/ec-av1/src/intra.rsmodified+7 -4
| @@ -158,21 +158,24 @@ impl Edges { | ||
| 158 | 158 | row.resize(want, last); |
| 159 | 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 | 164 | let above_row = match (above, left) { |
| 162 | 165 | (Some(a), _) => extend(a), |
| 163 | 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 | 169 | let left_col = match (left, above) { |
| 167 | 170 | (Some(l), _) => extend(l), |
| 168 | 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 | 174 | let corner = match (corner, above, left) { |
| 172 | 175 | (Some(c), Some(_), Some(_)) => i32::from(c), |
| 173 | 176 | (_, Some(a), _) => i32::from(a[0]), |
| 174 | 177 | (_, None, Some(l)) => i32::from(l[0]), |
| 175 | - (_, None, None) => 128, | |
| 178 | + (_, None, None) => base, | |
| 176 | 179 | }; |
| 177 | 180 | let with_corner = |edge: Vec<i32>| { |
| 178 | 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 | 600 | ((sum + (samples.len() as u32 >> 1)) / samples.len() as u32) as i32 |
| 598 | 601 | }; |
| 599 | 602 | match (&above, &left) { |
| 600 | - (None, None) => 128, | |
| 603 | + (None, None) => 1i32 << (crate::decode::bit_depth() - 1), | |
| 601 | 604 | (Some(a), None) => average(a), |
| 602 | 605 | (None, Some(l)) => average(l), |
| 603 | 606 | (Some(a), Some(l)) if bw == bh => { |