Unverified Commit c524d3a2 authored by Kyle Siefring's avatar Kyle Siefring Committed by GitHub
Browse files

Import enum values for simple match blocks (#884)

parent 437dafe1
......@@ -204,21 +204,20 @@ fn parse_config(matches: &ArgMatches) -> EncoderConfig {
cfg
}
pub fn map_y4m_color_space(color_space: y4m::Colorspace) -> (ChromaSampling, ChromaSamplePosition) {
pub fn map_y4m_color_space(
color_space: y4m::Colorspace
) -> (ChromaSampling, ChromaSamplePosition) {
use y4m::Colorspace::*;
use ChromaSampling::*;
use ChromaSamplePosition::*;
match color_space {
y4m::Colorspace::C420jpeg
| y4m::Colorspace::C420paldv => (ChromaSampling::Cs420, ChromaSamplePosition::Unknown),
y4m::Colorspace::C420mpeg2 => (ChromaSampling::Cs420, ChromaSamplePosition::Vertical),
y4m::Colorspace::C420
| y4m::Colorspace::C420p10
| y4m::Colorspace::C420p12 => (ChromaSampling::Cs420, ChromaSamplePosition::Colocated),
y4m::Colorspace::C422
| y4m::Colorspace::C422p10
| y4m::Colorspace::C422p12 => (ChromaSampling::Cs422, ChromaSamplePosition::Colocated),
y4m::Colorspace::C444
| y4m::Colorspace::C444p10
| y4m::Colorspace::C444p12 => (ChromaSampling::Cs444, ChromaSamplePosition::Colocated),
_ => panic!("Chroma characteristics unknown for the specified color space.")
C420jpeg | C420paldv => (Cs420, Unknown),
C420mpeg2 => (Cs420, Vertical),
C420 | C420p10 | C420p12 => (Cs420, Colocated),
C422 | C422p10 | C422p12 => (Cs422, Colocated),
C444 | C444p10 | C444p12 => (Cs444, Colocated),
_ =>
panic!("Chroma characteristics unknown for the specified color space.")
}
}
......
......@@ -202,14 +202,15 @@ impl Default for ChromaSampling {
}
impl ChromaSampling {
// Provides the sampling period in the horizontal and vertical axes.
pub fn sampling_period(self) -> (usize, usize) {
match self {
ChromaSampling::Cs420 => (2, 2),
ChromaSampling::Cs422 => (2, 1),
ChromaSampling::Cs444 => (1, 1)
}
// Provides the sampling period in the horizontal and vertical axes.
pub fn sampling_period(self) -> (usize, usize) {
use self::ChromaSampling::*;
match self {
Cs420 => (2, 2),
Cs422 => (2, 1),
Cs444 => (1, 1)
}
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
......@@ -853,15 +854,16 @@ pub enum ReferenceMode {
pub const ALL_REF_FRAMES_MASK: u32 = (1 << REF_FRAMES) - 1;
impl fmt::Display for FrameType{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FrameType::KEY => write!(f, "Key frame"),
FrameType::INTER => write!(f, "Inter frame"),
FrameType::INTRA_ONLY => write!(f, "Intra only frame"),
FrameType::SWITCH => write!(f, "Switching frame"),
}
impl fmt::Display for FrameType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::FrameType::*;
match self {
KEY => write!(f, "Key frame"),
INTER => write!(f, "Inter frame"),
INTRA_ONLY => write!(f, "Intra only frame"),
SWITCH => write!(f, "Switching frame"),
}
}
}
pub fn write_ivf_header(
......
......@@ -179,24 +179,18 @@ mod nasm {
);
fn select_put_fn_avx2(mode_x: FilterMode, mode_y: FilterMode) -> PutFn {
use self::FilterMode::*;
match (mode_x, mode_y) {
(FilterMode::REGULAR, FilterMode::REGULAR) =>
rav1e_put_8tap_regular_avx2,
(FilterMode::REGULAR, FilterMode::SMOOTH) =>
rav1e_put_8tap_regular_smooth_avx2,
(FilterMode::REGULAR, FilterMode::SHARP) =>
rav1e_put_8tap_regular_sharp_avx2,
(FilterMode::SMOOTH, FilterMode::REGULAR) =>
rav1e_put_8tap_smooth_regular_avx2,
(FilterMode::SMOOTH, FilterMode::SMOOTH) => rav1e_put_8tap_smooth_avx2,
(FilterMode::SMOOTH, FilterMode::SHARP) =>
rav1e_put_8tap_smooth_sharp_avx2,
(FilterMode::SHARP, FilterMode::REGULAR) =>
rav1e_put_8tap_sharp_regular_avx2,
(FilterMode::SHARP, FilterMode::SMOOTH) =>
rav1e_put_8tap_sharp_smooth_avx2,
(FilterMode::SHARP, FilterMode::SHARP) => rav1e_put_8tap_sharp_avx2,
(FilterMode::BILINEAR, FilterMode::BILINEAR) => rav1e_put_bilin_avx2,
(REGULAR, REGULAR) => rav1e_put_8tap_regular_avx2,
(REGULAR, SMOOTH) => rav1e_put_8tap_regular_smooth_avx2,
(REGULAR, SHARP) => rav1e_put_8tap_regular_sharp_avx2,
(SMOOTH, REGULAR) => rav1e_put_8tap_smooth_regular_avx2,
(SMOOTH, SMOOTH) => rav1e_put_8tap_smooth_avx2,
(SMOOTH, SHARP) => rav1e_put_8tap_smooth_sharp_avx2,
(SHARP, REGULAR) => rav1e_put_8tap_sharp_regular_avx2,
(SHARP, SMOOTH) => rav1e_put_8tap_sharp_smooth_avx2,
(SHARP, SHARP) => rav1e_put_8tap_sharp_avx2,
(BILINEAR, BILINEAR) => rav1e_put_bilin_avx2,
(_, _) => unreachable!()
}
}
......@@ -231,24 +225,18 @@ mod nasm {
);
fn select_prep_fn_avx2(mode_x: FilterMode, mode_y: FilterMode) -> PrepFn {
use self::FilterMode::*;
match (mode_x, mode_y) {
(FilterMode::REGULAR, FilterMode::REGULAR) =>
rav1e_prep_8tap_regular_avx2,
(FilterMode::REGULAR, FilterMode::SMOOTH) =>
rav1e_prep_8tap_regular_smooth_avx2,
(FilterMode::REGULAR, FilterMode::SHARP) =>
rav1e_prep_8tap_regular_sharp_avx2,
(FilterMode::SMOOTH, FilterMode::REGULAR) =>
rav1e_prep_8tap_smooth_regular_avx2,
(FilterMode::SMOOTH, FilterMode::SMOOTH) => rav1e_prep_8tap_smooth_avx2,
(FilterMode::SMOOTH, FilterMode::SHARP) =>
rav1e_prep_8tap_smooth_sharp_avx2,
(FilterMode::SHARP, FilterMode::REGULAR) =>
rav1e_prep_8tap_sharp_regular_avx2,
(FilterMode::SHARP, FilterMode::SMOOTH) =>
rav1e_prep_8tap_sharp_smooth_avx2,
(FilterMode::SHARP, FilterMode::SHARP) => rav1e_prep_8tap_sharp_avx2,
(FilterMode::BILINEAR, FilterMode::BILINEAR) => rav1e_prep_bilin_avx2,
(REGULAR, REGULAR) => rav1e_prep_8tap_regular_avx2,
(REGULAR, SMOOTH) => rav1e_prep_8tap_regular_smooth_avx2,
(REGULAR, SHARP) => rav1e_prep_8tap_regular_sharp_avx2,
(SMOOTH, REGULAR) => rav1e_prep_8tap_smooth_regular_avx2,
(SMOOTH, SMOOTH) => rav1e_prep_8tap_smooth_avx2,
(SMOOTH, SHARP) => rav1e_prep_8tap_smooth_sharp_avx2,
(SHARP, REGULAR) => rav1e_prep_8tap_sharp_regular_avx2,
(SHARP, SMOOTH) => rav1e_prep_8tap_sharp_smooth_avx2,
(SHARP, SHARP) => rav1e_prep_8tap_sharp_avx2,
(BILINEAR, BILINEAR) => rav1e_prep_bilin_avx2,
(_, _) => unreachable!()
}
}
......
......@@ -590,25 +590,25 @@ impl TxSize {
pub fn by_dims(w: usize, h: usize) -> TxSize {
match (w, h) {
(4, 4) => TxSize::TX_4X4,
(8, 8) => TxSize::TX_8X8,
(16, 16) => TxSize::TX_16X16,
(32, 32) => TxSize::TX_32X32,
(64, 64) => TxSize::TX_64X64,
(4, 8) => TxSize::TX_4X8,
(8, 4) => TxSize::TX_8X4,
(8, 16) => TxSize::TX_8X16,
(16, 8) => TxSize::TX_16X8,
(16, 32) => TxSize::TX_16X32,
(32, 16) => TxSize::TX_32X16,
(32, 64) => TxSize::TX_32X64,
(64, 32) => TxSize::TX_64X32,
(4, 16) => TxSize::TX_4X16,
(16, 4) => TxSize::TX_16X4,
(8, 32) => TxSize::TX_8X32,
(32, 8) => TxSize::TX_32X8,
(16, 64) => TxSize::TX_16X64,
(64, 16) => TxSize::TX_64X16,
(4, 4) => TX_4X4,
(8, 8) => TX_8X8,
(16, 16) => TX_16X16,
(32, 32) => TX_32X32,
(64, 64) => TX_64X64,
(4, 8) => TX_4X8,
(8, 4) => TX_8X4,
(8, 16) => TX_8X16,
(16, 8) => TX_16X8,
(16, 32) => TX_16X32,
(32, 16) => TX_32X16,
(32, 64) => TX_32X64,
(64, 32) => TX_64X32,
(4, 16) => TX_4X16,
(16, 4) => TX_16X4,
(8, 32) => TX_8X32,
(32, 8) => TX_32X8,
(16, 64) => TX_16X64,
(64, 16) => TX_64X16,
_ => unreachable!()
}
}
......
......@@ -283,21 +283,25 @@ pub fn rdo_tx_size_type(
luma_mode: PredictionMode, ref_frames: [usize; 2], mvs: [MotionVector; 2], skip: bool
) -> (TxSize, TxType) {
// these rules follow TX_MODE_LARGEST
let tx_size = match bsize {
BlockSize::BLOCK_4X4 => TxSize::TX_4X4,
BlockSize::BLOCK_8X8 => TxSize::TX_8X8,
BlockSize::BLOCK_16X16 => TxSize::TX_16X16,
BlockSize::BLOCK_4X8 => TxSize::TX_4X8,
BlockSize::BLOCK_8X4 => TxSize::TX_8X4,
BlockSize::BLOCK_8X16 => TxSize::TX_8X16,
BlockSize::BLOCK_16X8 => TxSize::TX_16X8,
BlockSize::BLOCK_16X32 => TxSize::TX_16X32,
BlockSize::BLOCK_32X16 => TxSize::TX_32X16,
BlockSize::BLOCK_32X32 => TxSize::TX_32X32,
BlockSize::BLOCK_32X64 => TxSize::TX_32X64,
BlockSize::BLOCK_64X32 => TxSize::TX_64X32,
BlockSize::BLOCK_64X64 => TxSize::TX_64X64,
_ => unimplemented!()
let tx_size = {
use self::BlockSize::*;
use self::TxSize::*;
match bsize {
BLOCK_4X4 => TX_4X4,
BLOCK_8X8 => TX_8X8,
BLOCK_16X16 => TX_16X16,
BLOCK_4X8 => TX_4X8,
BLOCK_8X4 => TX_8X4,
BLOCK_8X16 => TX_8X16,
BLOCK_16X8 => TX_16X8,
BLOCK_16X32 => TX_16X32,
BLOCK_32X16 => TX_32X16,
BLOCK_32X32 => TX_32X32,
BLOCK_32X64 => TX_32X64,
BLOCK_64X32 => TX_64X32,
BLOCK_64X64 => TX_64X64,
_ => unimplemented!()
}
};
cw.bc.set_tx_size(bo, tx_size);
// Were we not hardcoded to TX_MODE_LARGEST, block tx size would be written here
......
......@@ -1659,19 +1659,20 @@ impl TxfmType {
];
fn get_func(self) -> &'static TxfmFunc {
use self::TxfmType::*;
match self {
TxfmType::DCT4 => &daala_fdct4,
TxfmType::DCT8 => &daala_fdct8,
TxfmType::DCT16 => &daala_fdct16,
TxfmType::DCT32 => &daala_fdct32,
TxfmType::DCT64 => &daala_fdct64,
TxfmType::ADST4 => &daala_fdst_vii_4,
TxfmType::ADST8 => &daala_fdst8,
TxfmType::ADST16 => &daala_fdst16,
TxfmType::Identity4 => &fidentity4,
TxfmType::Identity8 => &fidentity8,
TxfmType::Identity16 => &fidentity16,
TxfmType::Identity32 => &fidentity32,
DCT4 => &daala_fdct4,
DCT8 => &daala_fdct8,
DCT16 => &daala_fdct16,
DCT32 => &daala_fdct32,
DCT64 => &daala_fdct64,
ADST4 => &daala_fdst_vii_4,
ADST8 => &daala_fdst8,
ADST16 => &daala_fdst16,
Identity4 => &fidentity4,
Identity8 => &fidentity8,
Identity16 => &fidentity16,
Identity32 => &fidentity32,
_ => unreachable!()
}
}
......@@ -1715,21 +1716,20 @@ impl Txfm2DFlipCfg {
/// Determine the flip config, returning (ud_flip, lr_flip)
fn get_flip_cfg(tx_type: TxType) -> (bool, bool) {
use self::TxType::*;
match tx_type {
TxType::DCT_DCT
| TxType::ADST_DCT
| TxType::DCT_ADST
| TxType::ADST_ADST
| TxType::IDTX
| TxType::V_DCT
| TxType::H_DCT
| TxType::V_ADST
| TxType::H_ADST => (false, false),
TxType::FLIPADST_DCT | TxType::FLIPADST_ADST | TxType::V_FLIPADST =>
(true, false),
TxType::DCT_FLIPADST | TxType::ADST_FLIPADST | TxType::H_FLIPADST =>
(false, true),
TxType::FLIPADST_FLIPADST => (true, true)
DCT_DCT
| ADST_DCT
| DCT_ADST
| ADST_ADST
| IDTX
| V_DCT
| H_DCT
| V_ADST
| H_ADST => (false, false),
FLIPADST_DCT | FLIPADST_ADST | V_FLIPADST => (true, false),
DCT_FLIPADST | ADST_FLIPADST | H_FLIPADST => (false, true),
FLIPADST_FLIPADST => (true, true)
}
}
}
......
......@@ -146,28 +146,29 @@ pub fn forward_transform(
input: &[i16], output: &mut [i32], stride: usize, tx_size: TxSize,
tx_type: TxType, bit_depth: usize
) {
use self::TxSize::*;
match tx_size {
TxSize::TX_4X4 => fht4x4(input, output, stride, tx_type, bit_depth),
TxSize::TX_8X8 => fht8x8(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X16 => fht16x16(input, output, stride, tx_type, bit_depth),
TxSize::TX_32X32 => fht32x32(input, output, stride, tx_type, bit_depth),
TxSize::TX_64X64 => fht64x64(input, output, stride, tx_type, bit_depth),
TX_4X4 => fht4x4(input, output, stride, tx_type, bit_depth),
TX_8X8 => fht8x8(input, output, stride, tx_type, bit_depth),
TX_16X16 => fht16x16(input, output, stride, tx_type, bit_depth),
TX_32X32 => fht32x32(input, output, stride, tx_type, bit_depth),
TX_64X64 => fht64x64(input, output, stride, tx_type, bit_depth),
TxSize::TX_4X8 => fht4x8(input, output, stride, tx_type, bit_depth),
TxSize::TX_8X4 => fht8x4(input, output, stride, tx_type, bit_depth),
TxSize::TX_8X16 => fht8x16(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X8 => fht16x8(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X32 => fht16x32(input, output, stride, tx_type, bit_depth),
TxSize::TX_32X16 => fht32x16(input, output, stride, tx_type, bit_depth),
TxSize::TX_32X64 => fht32x64(input, output, stride, tx_type, bit_depth),
TxSize::TX_64X32 => fht64x32(input, output, stride, tx_type, bit_depth),
TX_4X8 => fht4x8(input, output, stride, tx_type, bit_depth),
TX_8X4 => fht8x4(input, output, stride, tx_type, bit_depth),
TX_8X16 => fht8x16(input, output, stride, tx_type, bit_depth),
TX_16X8 => fht16x8(input, output, stride, tx_type, bit_depth),
TX_16X32 => fht16x32(input, output, stride, tx_type, bit_depth),
TX_32X16 => fht32x16(input, output, stride, tx_type, bit_depth),
TX_32X64 => fht32x64(input, output, stride, tx_type, bit_depth),
TX_64X32 => fht64x32(input, output, stride, tx_type, bit_depth),
TxSize::TX_4X16 => fht4x16(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X4 => fht16x4(input, output, stride, tx_type, bit_depth),
TxSize::TX_8X32 => fht8x32(input, output, stride, tx_type, bit_depth),
TxSize::TX_32X8 => fht32x8(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X64 => fht16x64(input, output, stride, tx_type, bit_depth),
TxSize::TX_64X16 => fht64x16(input, output, stride, tx_type, bit_depth),
TX_4X16 => fht4x16(input, output, stride, tx_type, bit_depth),
TX_16X4 => fht16x4(input, output, stride, tx_type, bit_depth),
TX_8X32 => fht8x32(input, output, stride, tx_type, bit_depth),
TX_32X8 => fht32x8(input, output, stride, tx_type, bit_depth),
TX_16X64 => fht16x64(input, output, stride, tx_type, bit_depth),
TX_64X16 => fht64x16(input, output, stride, tx_type, bit_depth),
}
}
......@@ -175,31 +176,29 @@ pub fn inverse_transform_add(
input: &[i32], output: &mut [u16], stride: usize, tx_size: TxSize,
tx_type: TxType, bit_depth: usize
) {
use self::TxSize::*;
match tx_size {
TxSize::TX_4X4 => iht4x4_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_8X8 => iht8x8_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X16 =>
iht16x16_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_32X32 =>
iht32x32_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_64X64 =>
iht64x64_add(input, output, stride, tx_type, bit_depth),
TX_4X4 => iht4x4_add(input, output, stride, tx_type, bit_depth),
TX_8X8 => iht8x8_add(input, output, stride, tx_type, bit_depth),
TX_16X16 => iht16x16_add(input, output, stride, tx_type, bit_depth),
TX_32X32 => iht32x32_add(input, output, stride, tx_type, bit_depth),
TX_64X64 => iht64x64_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_4X8 => iht4x8_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_8X4 => iht8x4_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_8X16 => iht8x16_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X8 => iht16x8_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X32 => iht16x32_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_32X16 => iht32x16_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_32X64 => iht32x64_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_64X32 => iht64x32_add(input, output, stride, tx_type, bit_depth),
TX_4X8 => iht4x8_add(input, output, stride, tx_type, bit_depth),
TX_8X4 => iht8x4_add(input, output, stride, tx_type, bit_depth),
TX_8X16 => iht8x16_add(input, output, stride, tx_type, bit_depth),
TX_16X8 => iht16x8_add(input, output, stride, tx_type, bit_depth),
TX_16X32 => iht16x32_add(input, output, stride, tx_type, bit_depth),
TX_32X16 => iht32x16_add(input, output, stride, tx_type, bit_depth),
TX_32X64 => iht32x64_add(input, output, stride, tx_type, bit_depth),
TX_64X32 => iht64x32_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_4X16 => iht4x16_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X4 => iht16x4_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_8X32 => iht8x32_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_32X8 => iht32x8_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_16X64 => iht16x64_add(input, output, stride, tx_type, bit_depth),
TxSize::TX_64X16 => iht64x16_add(input, output, stride, tx_type, bit_depth),
TX_4X16 => iht4x16_add(input, output, stride, tx_type, bit_depth),
TX_16X4 => iht16x4_add(input, output, stride, tx_type, bit_depth),
TX_8X32 => iht8x32_add(input, output, stride, tx_type, bit_depth),
TX_32X8 => iht32x8_add(input, output, stride, tx_type, bit_depth),
TX_16X64 => iht16x64_add(input, output, stride, tx_type, bit_depth),
TX_64X16 => iht64x16_add(input, output, stride, tx_type, bit_depth),
}
}
......
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