forge
Explore
Log in

Don't you dare go Hollow

wip(hbd): scale intra no-neighbour fallback (127/128/129) by bit depth

Browse files at this commit

f973434227342b3df328ff6f91a87448efc8f9b0Ahmet Kaan GümüşParent: 386939c
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 row159 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 i32600 ((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 => {