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

src/itx.rs: Deduplicate w/ generics #683

Merged
merged 6 commits into from
Mar 20, 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
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ mod asm {
let mut nasm = nasm_rs::Build::new();
nasm.min_version(2, 14, 0);
nasm.files(asm_file_paths);
#[cfg(debug_assertions)]
nasm.flag("-g");
#[cfg(debug_assertions)]
nasm.flag("-Fdwarf");
nasm.flag(&format!("-I{}/", out_dir.to_str().unwrap()));
nasm.flag("-Isrc/");
let obj = nasm.compile_objects().unwrap_or_else(|e| {
Expand All @@ -295,6 +299,7 @@ mod asm {
.files(asm_file_paths)
.include(".")
.include(&out_dir)
.debug(cfg!(debug_assertions))
.compile(rav1dasm);
}

Expand Down
27 changes: 25 additions & 2 deletions include/common/bitdepth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ impl BitDepth for BitDepth16 {
self.bitdepth_max
}

/// 4 for 10 bits/component.
/// 2 for 12 bits/component.
/// - 4 for 10 bits/component.
/// - 2 for 12 bits/component.
fn get_intermediate_bits(&self) -> u8 {
14 - self.bitdepth()
}
Expand Down Expand Up @@ -568,6 +568,26 @@ macro_rules! bd_fn {
}};
}

/// Select and declare a [`BitDepth`]-dependent `extern "C" fn`.
///
/// Similar to [`bd_fn!`] except that it selects which [`BitDepth`] `fn`
/// based on `$bpc:literal bpc` instead of `$BD:ty`.
macro_rules! bpc_fn {
($bpc:literal bpc, $name:ident, $asm:ident) => {{
use $crate::include::common::bitdepth::fn_identity;

bpc_fn!(fn_identity, $bpc bpc, $name, $asm)
}};

($decl_fn:path, $bpc:literal bpc, $name:ident, $asm:ident) => {{
use paste::paste;

paste! {
$decl_fn!(fn [<dav1d_ $name _ $bpc bpc_ $asm>])
}
}};
}

#[cfg(feature = "asm")]
macro_rules! fn_identity {
(fn $name:ident) => {
Expand All @@ -578,5 +598,8 @@ macro_rules! fn_identity {
#[cfg(feature = "asm")]
pub(crate) use bd_fn;

#[cfg(feature = "asm")]
pub(crate) use bpc_fn;

#[cfg(feature = "asm")]
pub(crate) use fn_identity;
3 changes: 0 additions & 3 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ pub mod src {
mod ipred_prepare;
mod itx;
mod itx_1d;
#[cfg(feature = "bitdepth_16")]
mod itx_tmpl_16;
mod itx_tmpl_8;
mod levels;
mod lf_apply;
mod lf_mask;
Expand Down
11 changes: 3 additions & 8 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ use crate::src::intra_edge::EdgeFlags;
use crate::src::intra_edge::EdgeIndex;
use crate::src::intra_edge::IntraEdges;
use crate::src::ipred::rav1d_intra_pred_dsp_init;
use crate::src::itx::rav1d_itx_dsp_init;
use crate::src::levels::mv;
use crate::src::levels::Av1Block;
use crate::src::levels::BS_128x128;
Expand Down Expand Up @@ -217,12 +218,6 @@ use std::slice;
use std::sync::atomic::AtomicI32;
use std::sync::atomic::Ordering;

#[cfg(feature = "bitdepth_8")]
use crate::src::itx_tmpl_8::rav1d_itx_dsp_init_8bpc;

#[cfg(feature = "bitdepth_16")]
use crate::src::itx_tmpl_16::rav1d_itx_dsp_init_16bpc;

fn init_quant_tables(
seq_hdr: &Rav1dSequenceHeader,
frame_hdr: &Rav1dFrameHeader,
Expand Down Expand Up @@ -4959,7 +4954,7 @@ pub unsafe fn rav1d_submit_frame(c: &mut Rav1dContext) -> Rav1dResult {
8 => {
rav1d_cdef_dsp_init::<BitDepth8>(&mut dsp.cdef);
rav1d_intra_pred_dsp_init::<BitDepth8>(&mut dsp.ipred);
rav1d_itx_dsp_init_8bpc(&mut dsp.itx, bpc);
rav1d_itx_dsp_init::<BitDepth8>(&mut dsp.itx, bpc);
rav1d_loop_filter_dsp_init::<BitDepth8>(&mut dsp.lf);
rav1d_loop_restoration_dsp_init::<BitDepth8>(&mut dsp.lr, bpc);
rav1d_mc_dsp_init::<BitDepth8>(&mut dsp.mc);
Expand All @@ -4969,7 +4964,7 @@ pub unsafe fn rav1d_submit_frame(c: &mut Rav1dContext) -> Rav1dResult {
10 | 12 => {
rav1d_cdef_dsp_init::<BitDepth16>(&mut dsp.cdef);
rav1d_intra_pred_dsp_init::<BitDepth16>(&mut dsp.ipred);
rav1d_itx_dsp_init_16bpc(&mut dsp.itx, bpc);
rav1d_itx_dsp_init::<BitDepth16>(&mut dsp.itx, bpc);
rav1d_loop_filter_dsp_init::<BitDepth16>(&mut dsp.lf);
rav1d_loop_restoration_dsp_init::<BitDepth16>(&mut dsp.lr, bpc);
rav1d_mc_dsp_init::<BitDepth16>(&mut dsp.mc);
Expand Down
Loading
Loading