Commit e3243957 authored by Tristan Matthews's avatar Tristan Matthews Committed by Yushin Cho

get_log_tx_scale: remove mutable variable (#757)

* get_log_tx_scale: remove mutable variable

No functional change.

* quantize: add test for get_log_tx_scale()
parent 6521320e
......@@ -15,12 +15,8 @@ use std::mem;
pub fn get_log_tx_scale(tx_size: TxSize) -> i32 {
let num_pixels = tx_size.area();
let mut shift_bits = 0;
if num_pixels > 256 { shift_bits += 1; };
if num_pixels > 1024 { shift_bits += 1; };
shift_bits
i32::from(num_pixels > 256) + i32::from(num_pixels > 1024)
}
pub fn dc_q(qindex: u8, bit_depth: usize) -> i16 {
......@@ -93,6 +89,7 @@ fn divu_pair(x: i32, d: (u32, u32, u32)) -> i32 {
#[cfg(test)]
mod test {
use super::*;
use partition::TxSize::*;
#[test]
fn test_divu_pair() {
for d in 1..1024 {
......@@ -109,6 +106,33 @@ mod test {
println!("{:?}", b);
}
#[test]
fn test_tx_log_scale() {
let tx_sizes = [
(TX_4X4, 0),
(TX_8X8, 0),
(TX_16X16, 0),
(TX_32X32, 1),
(TX_64X64, 2),
(TX_4X8, 0),
(TX_8X4, 0),
(TX_8X16, 0),
(TX_16X8, 0),
(TX_16X32, 1),
(TX_32X16, 1),
(TX_32X64, 2),
(TX_64X32, 2),
(TX_4X16, 0),
(TX_16X4, 0),
(TX_8X32, 0),
(TX_32X8, 0),
(TX_16X64, 1),
(TX_64X16, 1),
];
for &tx_size in tx_sizes.iter() {
assert!(tx_size.1 == get_log_tx_scale(tx_size.0));
}
}
}
impl QuantizationContext {
......
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