Skip to content

Commit

Permalink
reduce overhead (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcroomp authored May 6, 2024
1 parent f0d9c27 commit 280bae5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/structs/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ impl ModelPerColor {
.context(here!());
}

#[inline(always)]
fn get_coef_branches(
&mut self,
num_non_zeros_bin: usize,
Expand All @@ -241,11 +242,20 @@ impl ModelPerColor {
&mut Branch,
&mut [Branch; COEF_BITS],
) {
debug_assert!(
num_non_zeros_bin < self.counts.len(),
// these bounds checks happen anyway, but we can provide more helpful error messages
// and it also means that the compiler can move the actual array references around
// if it helps with performance
assert!(
num_non_zeros_bin < NUM_NON_ZERO_7X7_BINS,
"num_non_zeros_bin {0} too high",
num_non_zeros_bin
);
assert!(zig49 < 49, "zig49 {0} too high", num_non_zeros_bin);
assert!(
best_prior_bit_len < MAX_EXPONENT,
"best_prior_bit_len {0} too high",
best_prior_bit_len
);

let exp = &mut self.counts[num_non_zeros_bin][zig49].exponent_counts[best_prior_bit_len];
let sign = &mut self.sign_counts[0][0];
Expand Down Expand Up @@ -595,6 +605,7 @@ impl Model {
(exp, sign, bits)
}

#[inline(always)]
fn read_length_sign_coef<const A: usize, const B: usize, R: Read>(
bool_reader: &mut VPXBoolReader<R>,
magnitude_branches: &mut [Branch; A],
Expand Down

0 comments on commit 280bae5

Please sign in to comment.