Commit ead8dd76 authored by Vladimir Kazakov's avatar Vladimir Kazakov Committed by Luca Barbato
parent d34bc6ba
......@@ -61,4 +61,4 @@ jobs:
- cargo doc --verbose
- rustup component add clippy
- cargo clippy --version
- cargo clippy -- -D warnings -A clippy::cast_lossless -A clippy::cast_ptr_alignment -A clippy::collapsible_if -A clippy::cyclomatic_complexity -A clippy::needless_range_loop -A clippy::precedence -A clippy::too_many_arguments -A clippy::type_complexity -A clippy::verbose_bit_mask --verbose
- cargo clippy -- -D warnings -A clippy::cast_lossless -A clippy::cast_ptr_alignment -A clippy::collapsible_if -A clippy::cyclomatic_complexity -A clippy::needless_range_loop -A clippy::too_many_arguments -A clippy::type_complexity -A clippy::verbose_bit_mask --verbose
......@@ -195,8 +195,8 @@ unsafe fn cdef_filter_block<T: Pixel>(
// We use the variance of an 8x8 block to adjust the effective filter strength.
fn adjust_strength(strength: i32, var: i32) -> i32 {
let i = if (var >> 6) != 0 {cmp::min(msb(var >> 6), 12)} else {0};
if var!=0 {strength * (4 + i) + 8 >> 4} else {0}
let i = if (var >> 6) != 0 { cmp::min(msb(var >> 6), 12) } else { 0 };
if var != 0 { (strength * (4 + i) + 8) >> 4 } else { 0 }
}
// For convenience of use alongside cdef_filter_superblock, we assume
......@@ -395,10 +395,10 @@ pub fn cdef_filter_superblock<T: Pixel>(
unsafe {
let xsize = 8 >> xdec;
let ysize = 8 >> ydec;
assert!(out_slice.rows_iter().len() >= (8 * by >> ydec) + ysize);
assert!(in_slice.rows_iter().len() >= (8 * by >> ydec) + ysize + 4);
let dst = out_slice[8 * by >> ydec][8 * bx >> xdec..].as_mut_ptr();
let input = in_slice[8 * by >> ydec][8 * bx >> xdec..].as_ptr();
assert!(out_slice.rows_iter().len() >= ((8 * by) >> ydec) + ysize);
assert!(in_slice.rows_iter().len() >= ((8 * by) >> ydec) + ysize + 4);
let dst = out_slice[(8 * by) >> ydec][(8 * bx) >> xdec..].as_mut_ptr();
let input = in_slice[(8 * by) >> ydec][(8 * bx) >> xdec..].as_ptr();
cdef_filter_block(dst,
out_stride as isize,
input,
......@@ -429,8 +429,8 @@ pub fn cdef_filter_frame<T: Pixel>(fi: &FrameInvariants<T>, rec: &mut Frame<T>,
// Construct a padded copy of the reconstructed frame.
let mut padded_px: [[usize; 2]; 3] = [[0; 2]; 3];
for p in 0..3 {
padded_px[p][0] = (fb_width*64 >> rec.planes[p].cfg.xdec) + 4;
padded_px[p][1] = (fb_height*64 >> rec.planes[p].cfg.ydec) + 4;
padded_px[p][0] = ((fb_width * 64) >> rec.planes[p].cfg.xdec) + 4;
padded_px[p][1] = ((fb_height * 64) >> rec.planes[p].cfg.ydec) + 4;
}
let mut cdef_frame: Frame<u16> = Frame {
planes: [
......
......@@ -224,7 +224,7 @@ fn filter_narrow4_4(
let test = clamp(base + 3, -128 << shift, (128 << shift) - 1) >> 3;
filter2 == test
});
let filter3 = filter1 + 1 >> 1;
let filter3 = (filter1 + 1) >> 1;
[
clamp(p1 + filter3, 0, (256 << shift) - 1),
clamp(p0 + filter2, 0, (256 << shift) - 1),
......@@ -256,10 +256,10 @@ fn filter_wide6_4(
p2: i32, p1: i32, p0: i32, q0: i32, q1: i32, q2: i32
) -> [i32; 4] {
[
p2*3 + p1*2 + p0*2 + q0 + (1<<2) >> 3,
p2 + p1*2 + p0*2 + q0*2 + q1 + (1<<2) >> 3,
p1 + p0*2 + q0*2 + q1*2 + q2 + (1<<2) >> 3,
p0 + q0*2 + q1*2 + q2*3 + (1<<2) >> 3
(p2*3 + p1*2 + p0*2 + q0 + (1<<2)) >> 3,
(p2 + p1*2 + p0*2 + q0*2 + q1 + (1<<2)) >> 3,
(p1 + p0*2 + q0*2 + q1*2 + q2 + (1<<2)) >> 3,
(p0 + q0*2 + q1*2 + q2*3 + (1<<2)) >> 3
]
}
......@@ -269,12 +269,12 @@ fn filter_wide8_6(
p3: i32, p2: i32, p1: i32, p0: i32, q0: i32, q1: i32, q2: i32, q3: i32
) -> [i32; 6] {
[
p3*3 + p2*2 + p1 + p0 + q0 + (1<<2) >> 3,
p3*2 + p2 + p1*2 + p0 + q0 + q1 + (1<<2) >> 3,
p3 + p2 + p1 + p0*2 + q0 + q1 + q2 +(1<<2) >> 3,
p2 + p1 + p0 + q0*2 + q1 + q2 + q3 + (1<<2) >> 3,
p1 + p0 + q0 + q1*2 + q2 + q3*2 + (1<<2) >> 3,
p0 + q0 + q1 + q2*2 + q3*3 + (1<<2) >> 3
(p3*3 + p2*2 + p1 + p0 + q0 + (1<<2)) >> 3,
(p3*2 + p2 + p1*2 + p0 + q0 + q1 + (1<<2)) >> 3,
(p3 + p2 + p1 + p0*2 + q0 + q1 + q2 +(1<<2)) >> 3,
(p2 + p1 + p0 + q0*2 + q1 + q2 + q3 + (1<<2)) >> 3,
(p1 + p0 + q0 + q1*2 + q2 + q3*2 + (1<<2)) >> 3,
(p0 + q0 + q1 + q2*2 + q3*3 + (1<<2)) >> 3
]
}
......@@ -294,18 +294,18 @@ fn filter_wide14_12(
q1: i32, q2: i32, q3: i32, q4: i32, q5: i32, q6: i32
) -> [i32; 12] {
[
p6*7 + p5*2 + p4*2 + p3 + p2 + p1 + p0 + q0 + (1<<3) >> 4,
p6*5 + p5*2 + p4*2 + p3*2 + p2 + p1 + p0 + q0 + q1 + (1<<3) >> 4,
p6*4 + p5 + p4*2 + p3*2 + p2*2 + p1 + p0 + q0 + q1 + q2 + (1<<3) >> 4,
p6*3 + p5 + p4 + p3*2 + p2*2 + p1*2 + p0 + q0 + q1 + q2 + q3 + (1<<3) >> 4,
p6*2 + p5 + p4 + p3 + p2*2 + p1*2 + p0*2 + q0 + q1 + q2 + q3 + q4 + (1<<3) >> 4,
p6 + p5 + p4 + p3 + p2 + p1*2 + p0*2 + q0*2 + q1 + q2 + q3 + q4 + q5 + (1<<3) >> 4,
p5 + p4 + p3 + p2 + p1 + p0*2 + q0*2 + q1*2 + q2 + q3 + q4 + q5 + q6 + (1<<3) >> 4,
p4 + p3 + p2 + p1 + p0 + q0*2 + q1*2 + q2*2 + q3 + q4 + q5 + q6*2 + (1<<3) >> 4,
p3 + p2 + p1 + p0 + q0 + q1*2 + q2*2 + q3*2 + q4 + q5 + q6*3 + (1<<3) >> 4,
p2 + p1 + p0 + q0 + q1 + q2*2 + q3*2 + q4*2 + q5 + q6*4 + (1<<3) >> 4,
p1 + p0 + q0 + q1 + q2 + q3*2 + q4*2 + q5*2 + q6*5 + (1<<3) >> 4,
p0 + q0 + q1 + q2 + q3 + q4*2 + q5*2 + q6*7 + (1<<3) >> 4
(p6*7 + p5*2 + p4*2 + p3 + p2 + p1 + p0 + q0 + (1<<3)) >> 4,
(p6*5 + p5*2 + p4*2 + p3*2 + p2 + p1 + p0 + q0 + q1 + (1<<3)) >> 4,
(p6*4 + p5 + p4*2 + p3*2 + p2*2 + p1 + p0 + q0 + q1 + q2 + (1<<3)) >> 4,
(p6*3 + p5 + p4 + p3*2 + p2*2 + p1*2 + p0 + q0 + q1 + q2 + q3 + (1<<3)) >> 4,
(p6*2 + p5 + p4 + p3 + p2*2 + p1*2 + p0*2 + q0 + q1 + q2 + q3 + q4 + (1<<3)) >> 4,
(p6 + p5 + p4 + p3 + p2 + p1*2 + p0*2 + q0*2 + q1 + q2 + q3 + q4 + q5 + (1<<3)) >> 4,
(p5 + p4 + p3 + p2 + p1 + p0*2 + q0*2 + q1*2 + q2 + q3 + q4 + q5 + q6 + (1<<3)) >> 4,
(p4 + p3 + p2 + p1 + p0 + q0*2 + q1*2 + q2*2 + q3 + q4 + q5 + q6*2 + (1<<3)) >> 4,
(p3 + p2 + p1 + p0 + q0 + q1*2 + q2*2 + q3*2 + q4 + q5 + q6*3 + (1<<3)) >> 4,
(p2 + p1 + p0 + q0 + q1 + q2*2 + q3*2 + q4*2 + q5 + q6*4 + (1<<3)) >> 4,
(p1 + p0 + q0 + q1 + q2 + q3*2 + q4*2 + q5*2 + q6*5 + (1<<3)) >> 4,
(p0 + q0 + q1 + q2 + q3 + q4*2 + q5*2 + q6*7 + (1<<3)) >> 4
]
}
......@@ -343,15 +343,15 @@ fn _level_to_limit(level: i32, shift: usize) -> i32 {
}
fn limit_to_level(limit: i32, shift: usize) -> i32 {
limit + (1 << shift) - 1 >> shift
(limit + (1 << shift) - 1) >> shift
}
fn _level_to_blimit(level: i32, shift: usize) -> i32 {
3 * level + 4 << shift
(3 * level + 4) << shift
}
fn blimit_to_level(blimit: i32, shift: usize) -> i32 {
((blimit + (1 << shift) - 1 >> shift) - 2) / 3
(((blimit + (1 << shift) - 1) >> shift) - 2) / 3
}
fn _level_to_thresh(level: i32, shift: usize) -> i32 {
......@@ -359,7 +359,7 @@ fn _level_to_thresh(level: i32, shift: usize) -> i32 {
}
fn thresh_to_level(thresh: i32, shift: usize) -> i32 {
thresh + (1 << shift) - 1 >> shift << 4
(thresh + (1 << shift) - 1) >> shift << 4
}
fn nhev4(p1: i32, p0: i32, q0: i32, q1: i32, shift: usize) -> usize {
......@@ -506,7 +506,7 @@ fn deblock_size6_inner(
bd: usize,
) -> Option<[i32; 4]> {
if mask6(p2, p1, p0, q0, q1, q2, bd - 8) <= level {
let flat = 1 << bd - 8;
let flat = 1 << (bd - 8);
let x = if flat6(p2, p1, p0, q0, q1, q2) <= flat {
filter_wide6_4(p2, p1, p0, q0, q1, q2)
} else if nhev4(p1, p0, q0, q1, bd - 8) <= level {
......@@ -569,7 +569,7 @@ fn sse_size6<T: Pixel>(
src_pitch: usize,
bd: usize
) {
let flat = 1 << bd - 8;
let flat = 1 << (bd - 8);
for y in 0..4 {
let p = &rec[y]; // six taps
let a = &src[y][src_pitch..]; // four pixels to compare so offset one forward
......@@ -675,7 +675,7 @@ fn deblock_size8_inner (
bd: usize,
) -> Option<[i32; 6]> {
if mask8(p3, p2, p1, p0, q0, q1, q2, q3, bd - 8) <= level {
let flat = 1 << bd - 8;
let flat = 1 << (bd - 8);
let x = if flat8(p3, p2, p1, p0, q0, q1, q2, q3) <= flat {
filter_wide8_6(p3, p2, p1, p0, q0, q1, q2, q3)
} else if nhev4(p1, p0, q0, q1, bd - 8) <= level {
......@@ -742,7 +742,7 @@ fn sse_size8<T: Pixel>(
src_pitch: usize,
bd: usize
) {
let flat = 1 << bd - 8;
let flat = 1 << (bd - 8);
for y in 0..4 {
let p = &rec[y]; // eight taps
let a = &src[y][src_pitch..]; // six pixels to compare so offset one forward
......@@ -827,7 +827,7 @@ fn deblock_size14_inner(
) -> Option<[i32; 12]> {
// 'mask' test
if mask8(p3, p2, p1, p0, q0, q1, q2, q3, bd - 8) <= level {
let flat = 1 << bd - 8;
let flat = 1 << (bd - 8);
// inner flatness test
let x = if flat8(p3, p2, p1, p0, q0, q1, q2, q3) <= flat {
// outer flatness test
......@@ -915,7 +915,7 @@ fn sse_size14<T: Pixel>(
src_pitch: usize,
bd: usize
) {
let flat = 1 << bd - 8;
let flat = 1 << (bd - 8);
for y in 0..4 {
let p = &rec[y]; // 14 taps
let a = &src[y][src_pitch..]; // 12 pixels to compare so offset one forward
......@@ -1450,21 +1450,21 @@ pub fn deblock_filter_optimize<T: Pixel>(
match fi.sequence.bit_depth {
8 =>
if fi.frame_type == FrameType::KEY {
q * 17563 - 421_574 + (1 << 18 >> 1) >> 18
(q * 17563 - 421_574 + (1 << 18 >> 1)) >> 18
} else {
q * 6017 + 650_707 + (1 << 18 >> 1) >> 18
(q * 6017 + 650_707 + (1 << 18 >> 1)) >> 18
},
10 =>
if fi.frame_type == FrameType::KEY {
(q * 20723 + 4_060_632 + (1 << 20 >> 1) >> 20) - 4
((q * 20723 + 4_060_632 + (1 << 20 >> 1)) >> 20) - 4
} else {
q * 20723 + 4_060_632 + (1 << 20 >> 1) >> 20
(q * 20723 + 4_060_632 + (1 << 20 >> 1)) >> 20
},
12 =>
if fi.frame_type == FrameType::KEY {
(q * 20723 + 16_242_526 + (1 << 22 >> 1) >> 22) - 4
((q * 20723 + 16_242_526 + (1 << 22 >> 1)) >> 22) - 4
} else {
q * 20723 + 16_242_526 + (1 << 22 >> 1) >> 22
(q * 20723 + 16_242_526 + (1 << 22 >> 1)) >> 22
},
_ => {
assert!(false);
......
......@@ -375,8 +375,15 @@ impl<S> WriterBase<S> {
}
}
}
fn recenter(r: u32, v: u32) -> u32 {
if v > (r << 1) {v} else if v >= r {v - r << 1} else {(r - v << 1) - 1}
if v > (r << 1) {
v
} else if v >= r {
(v - r) << 1
} else {
((r - v) << 1) - 1
}
}
#[cfg(debug)]
......@@ -543,13 +550,12 @@ where
debug_assert!(32768 <= self.rng);
let rng = (self.rng >> 8) as u32;
let fh = cdf[s as usize] as u32 >> EC_PROB_SHIFT;
let r =
if s > 0 {
let r = if s > 0 {
let fl = cdf[s as usize - 1] as u32 >> EC_PROB_SHIFT;
(rng * fl >> 7 - EC_PROB_SHIFT) - (rng * fh >> 7 - EC_PROB_SHIFT) + EC_MIN_PROB
((rng * fl) >> (7 - EC_PROB_SHIFT)) - ((rng * fh) >> (7 - EC_PROB_SHIFT)) + EC_MIN_PROB
} else {
let nms1 = cdf.len() as u32 - s - 1;
self.rng as u32 - (rng * fh >> 7 - EC_PROB_SHIFT) - nms1 * EC_MIN_PROB
self.rng as u32 - ((rng * fh) >> (7 - EC_PROB_SHIFT)) - nms1 * EC_MIN_PROB
};
// The 9 here counteracts the offset of -9 baked into cnt. Don't include a termination bit.
......@@ -598,10 +604,10 @@ where
let l = msb(n as i32) as u8 + 1;
let m = (1 << l) - n;
if v < m {
self.literal(l-1, v);
self.literal(l - 1, v);
} else {
self.literal(l-1, m + (v-m >> 1));
self.literal(1, (v-m) & 1);
self.literal(l - 1, m + ((v - m) >> 1));
self.literal(1, (v - m) & 1);
}
}
}
......@@ -613,10 +619,8 @@ where
if n > 1 {
let l = (msb(n as i32) + 1) as u32;
let m = (1 << l) - n;
if v < m {
bits += l-1 << OD_BITRES;
} else {
bits += l-1 << OD_BITRES;
bits += (l - 1) << OD_BITRES;
if v >= m {
bits += 1 << OD_BITRES;
}
}
......
......@@ -832,7 +832,7 @@ impl<T: Pixel> FrameInvariants<T> {
self.ac_delta_q[pi] = 0;
}
self.lambda =
qps.lambda * ((1 << 2 * (self.sequence.bit_depth - 8)) as f64);
qps.lambda * ((1 << (2 * (self.sequence.bit_depth - 8))) as f64);
self.me_lambda = self.lambda.sqrt();
}
}
......
......@@ -70,10 +70,10 @@ impl RestorationFilter {
#[inline(always)]
fn sgrproj_sum_finish(ssq: i32, sum: i32, n: i32, one_over_n: i32, s: i32, bdm8: usize) -> (i32, i32) {
let scaled_ssq = ssq + (1 << 2*bdm8 >> 1) >> 2*bdm8;
let scaled_sum = sum + (1 << bdm8 >> 1) >> bdm8;
let scaled_ssq = (ssq + (1 << (2 * bdm8) >> 1)) >> (2 * bdm8);
let scaled_sum = (sum + (1 << bdm8 >> 1)) >> bdm8;
let p = cmp::max(0, scaled_ssq*(n as i32) - scaled_sum*scaled_sum) as u32;
let z = p*s as u32 + (1 << SGRPROJ_MTABLE_BITS >> 1) >> SGRPROJ_MTABLE_BITS;
let z = (p * s as u32 + (1 << SGRPROJ_MTABLE_BITS >> 1)) >> SGRPROJ_MTABLE_BITS;
let a:i32 = if z >= 255 {
256
} else if z == 0 {
......@@ -81,8 +81,8 @@ fn sgrproj_sum_finish(ssq: i32, sum: i32, n: i32, one_over_n: i32, s: i32, bdm8:
} else {
(((z << SGRPROJ_SGR_BITS) + z/2) / (z+1)) as i32
};
let b = ((1 << SGRPROJ_SGR_BITS) - a ) * sum * one_over_n;
(a, b + (1 << SGRPROJ_RECIP_BITS >> 1) >> SGRPROJ_RECIP_BITS)
let b = ((1 << SGRPROJ_SGR_BITS) - a) * sum * one_over_n;
(a, (b + (1 << SGRPROJ_RECIP_BITS >> 1)) >> SGRPROJ_RECIP_BITS)
}
// The addressing below is a bit confusing, made worse by LRF's odd
......@@ -372,7 +372,7 @@ fn sgrproj_box_ab_r2<T: Pixel>(af: &mut[i32; 64+2],
// boundary1 is the point where we're guaranteed all our y
// addressing will be both in the stripe and in cdeffed storage
// make even and round up
let boundary1 = (cmp::max(3, 3 - cdeffed.y - stripe_y) + 1 >> 1 << 1) as usize;
let boundary1 = ((cmp::max(3, 3 - cdeffed.y - stripe_y) + 1) >> 1 << 1) as usize;
// boundary 2 is when we have to bounds check along the bottom of
// the stripe or bottom of storage
// must be even, rounding of +1 cancels fencepost of -1
......@@ -432,7 +432,7 @@ fn sgrproj_box_f_r1<T: Pixel>(af: &[&[i32; 64+2]; 3], bf: &[&[i32; 64+2]; 3], f:
3 * (bf[0][i] + bf[2][i] + bf[0][i+2] + bf[2][i+2]) +
4 * (bf[1][i] + bf[0][i+1] + bf[1][i+1] + bf[2][i+1] + bf[1][i+2]);
let v = a * i32::cast_from(cdeffed.p(x, (y + i as isize) as usize)) + b;
f[i as usize] = v + (1 << shift >> 1) >> shift;
f[i as usize] = (v + (1 << shift >> 1)) >> shift;
}
}
......@@ -454,9 +454,9 @@ fn sgrproj_box_f_r2<T: Pixel>(af: &[&[i32; 64+2]; 3], bf: &[&[i32; 64+2]; 3], f:
5 * (bf[0][i+2] + bf[2][i+2]) +
6 * (bf[1][i+2]);
let v = (a + ao) * i32::cast_from(cdeffed.p(x, (y+i as isize) as usize)) + b + bo;
f[i as usize] = v + (1 << shift >> 1) >> shift;
f[i as usize] = (v + (1 << shift >> 1)) >> shift;
let vo = ao * i32::cast_from(cdeffed.p(x, (y + i as isize) as usize + 1)) + bo;
f[i as usize + 1] = vo + (1 << shifto >> 1) >> shifto;
f[i as usize + 1] = (vo + (1 << shifto >> 1)) >> shifto;
}
}
......@@ -543,7 +543,7 @@ pub fn sgrproj_stripe_filter<T: Pixel>(set: u8, xqd: [i8; 2], fi: &FrameInvarian
for yi in outstart..stripe_h as usize {
let u = i32::cast_from(cdeffed.p(xi, yi)) << SGRPROJ_RST_BITS;
let v = w0*f_r2[yi] + w1*u + w2*f_r1[yi];
let s = v + (1 << SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS >> 1) >> SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS;
let s = (v + (1 << (SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS) >> 1)) >> (SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS);
out[yi][xi] = T::cast_from(clamp(s, 0, (1 << bit_depth) - 1));
}
}
......@@ -699,8 +699,8 @@ fn wiener_stripe_filter<T: Pixel>(coeffs: [[i8; 3]; 2], fi: &FrameInvariants<T>,
let bit_depth = fi.sequence.bit_depth;
let round_h = if bit_depth == 12 {5} else {3};
let round_v = if bit_depth == 12 {9} else {11};
let offset = 1 << bit_depth + WIENER_BITS - round_h - 1;
let limit = (1 << bit_depth + 1 + WIENER_BITS - round_h) - 1;
let offset = 1 << (bit_depth + WIENER_BITS - round_h - 1);
let limit = (1 << (bit_depth + 1 + WIENER_BITS - round_h)) - 1;
let mut work: [i32; MAX_SB_SIZE+7] = [0; MAX_SB_SIZE+7];
let vfilter: [i32; 7] = [ coeffs[0][0] as i32,
......@@ -761,7 +761,7 @@ fn wiener_stripe_filter<T: Pixel>(coeffs: [[i8; 3]; 2], fi: &FrameInvariants<T>,
acc += hfilter[i as usize] * i32::cast_from(src_plane.p(crop_w - 1, ly));
}
acc = acc + (1 << round_h >> 1) >> round_h;
acc = (acc + (1 << round_h >> 1)) >> round_h;
work[(yi-stripe_y+3) as usize] = clamp(acc, -offset, limit-offset);
}
......@@ -770,7 +770,7 @@ fn wiener_stripe_filter<T: Pixel>(coeffs: [[i8; 3]; 2], fi: &FrameInvariants<T>,
for (i,src) in (0..7).zip(work[wi..wi+7].iter_mut()) {
acc += vfilter[i] * *src;
}
*dst = T::cast_from(clamp(acc + (1 << round_v >> 1) >> round_v, 0, (1 << bit_depth) - 1));
*dst = T::cast_from(clamp((acc + (1 << round_v >> 1)) >> round_v, 0, (1 << bit_depth) - 1));
}
}
}
......@@ -926,12 +926,12 @@ impl RestorationState {
let rp = &self.planes[pli];
let xdec = out.planes[pli].cfg.xdec;
let ydec = out.planes[pli].cfg.ydec;
let crop_w = fi.width + (1 << xdec >> 1) >> xdec;
let crop_h = fi.height + (1 << ydec >> 1) >> ydec;
let crop_w = (fi.width + (1 << xdec >> 1)) >> xdec;
let crop_h = (fi.height + (1 << ydec >> 1)) >> ydec;
for si in 0..stripe_n {
// stripe y pixel locations must be able to overspan the frame
let stripe_start_y = si as isize * 64 - 8 >> ydec;
let stripe_start_y = (si as isize * 64 - 8) >> ydec;
let stripe_size = 64 >> ydec; // one past, unlike spec
// horizontally, go rdu-by-rdu
......
......@@ -285,7 +285,7 @@ pub struct IIRBessel2 {
// The return value is 5.12.
// TODO: Mark const once we can use local variables in a const function.
fn warp_alpha(alpha: i32) -> i32 {
let i = (alpha*36 >> 24).min(16);
let i = ((alpha*36) >> 24).min(16);
let t0 = ROUGH_TAN_LOOKUP[i as usize];
let t1 = ROUGH_TAN_LOOKUP[i as usize + 1];
let d = alpha*36 - (i << 24);
......@@ -465,7 +465,7 @@ impl RCState {
// errors in the worst case.
// The 256 frame maximum means we'll require 8-10 seconds of pre-buffering
// at 24-30 fps, which is not unreasonable.
let reservoir_frame_delay = clamp(max_key_frame_interval*3 >> 1, 12, 256);
let reservoir_frame_delay = clamp((max_key_frame_interval*3) >> 1, 12, 256);
// TODO: What are the limits on these?
let npixels = (frame_width as i64)*(frame_height as i64);
// Insane framerates or frame sizes mean insane bitrates.
......
......@@ -198,8 +198,10 @@ fn cdef_dist_wxh_8x8<T: Pixel>(
let dvar = (sum_d2 - ((sum_d as i64 * sum_d as i64 + 32) >> 6)) as f64;
let sse = (sum_d2 + sum_s2 - 2 * sum_sd) as f64;
//The two constants were tuned for CDEF, but can probably be better tuned for use in general RDO
let ssim_boost = (4033_f64 / 16_384_f64) * (svar + dvar + (16_384 << 2 * coeff_shift) as f64)
/ f64::sqrt((16_265_089u64 << 4 * coeff_shift) as f64 + svar * dvar);
let ssim_boost =
(4033_f64 / 16_384_f64) *
(svar + dvar + (16_384 << (2 * coeff_shift)) as f64) /
f64::sqrt((16_265_089u64 << (4 * coeff_shift)) as f64 + svar * dvar);
(sse * ssim_boost + 0.5_f64) as u64
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment