Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn get_rect_tx_log_ratio into associated function for TxSize #3353

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/transform/inverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use crate::util::*;
use super::clamp_value;
use super::consts::*;
use super::get_1d_tx_types;
use super::get_rect_tx_log_ratio;
use super::half_btf;
use super::TxSize;
use super::TxType;
Expand Down Expand Up @@ -1644,13 +1643,14 @@ pub(crate) mod rust {
// For 64 point transforms, rely on the last 32 columns being initialized
// to zero for filling out missing input coeffs.
let mut buffer = vec![0i32; width * height].into_boxed_slice();
let rect_type = get_rect_tx_log_ratio(width, height);
let rect_type = tx_size.rect_ratio_log2();
let tx_types_1d = get_1d_tx_types(tx_type);
let lossless = tx_type == TxType::WHT_WHT;

// perform inv txfm on every row
let range = bd + 8;
let txfm_fn = INV_TXFM_FNS[tx_types_1d.1 as usize][ILog::ilog(width) - 3];
let txfm_fn =
INV_TXFM_FNS[tx_types_1d.1 as usize][tx_size.width_log2() - 2];
// 64 point transforms only signal 32 coeffs. We only take chunks of 32
// and skip over the last 32 transforms here.
for (r, buffer_slice) in (0..height.min(32)).zip(buffer.chunks_mut(width))
Expand Down Expand Up @@ -1678,7 +1678,8 @@ pub(crate) mod rust {

// perform inv txfm on every col
let range = cmp::max(bd + 6, 16);
let txfm_fn = INV_TXFM_FNS[tx_types_1d.0 as usize][ILog::ilog(height) - 3];
let txfm_fn =
INV_TXFM_FNS[tx_types_1d.0 as usize][tx_size.height_log2() - 2];
for c in 0..width {
let mut temp_in: [i32; 64] = [0; 64];
let mut temp_out: [i32; 64] = [0; 64];
Expand Down
17 changes: 7 additions & 10 deletions src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ impl TxSize {
pub const fn is_rect(self) -> bool {
self.width_log2() != self.height_log2()
}

/// Returns log2(width / height), e.g. `TX_16x4` -> log2(16 / 4) = 2
#[inline]
pub const fn rect_ratio_log2(self) -> i8 {
self.width_log2() as i8 - self.height_log2() as i8
}
}

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd)]
Expand All @@ -286,13 +292,6 @@ pub enum TxSet {
TX_SET_INTER_1, // TX_SET_ALL16
}

/// Utility function that returns the log of the ratio of the col and row sizes.
#[inline]
pub fn get_rect_tx_log_ratio(col: usize, row: usize) -> i8 {
debug_assert!(col > 0 && row > 0);
ILog::ilog(col) as i8 - ILog::ilog(row) as i8
}

// performs half a butterfly
#[inline]
const fn half_btf(w0: i32, in0: i32, w1: i32, in1: i32, bit: usize) -> i32 {
Expand Down Expand Up @@ -548,9 +547,7 @@ mod test {
tx_size.width(),
tx_size.height()
);
assert!(
get_rect_tx_log_ratio(tx_size.width(), tx_size.height()) == expected
);
assert!(tx_size.rect_ratio_log2() == expected);
}
}

Expand Down
Loading