Skip to content

Commit

Permalink
fn dav1d_*_{8,16}bpc: Deduplicate declarations into use imports (#…
Browse files Browse the repository at this point in the history
…493)

This should be the last of the `#[no_mangle]` `fn`s that aren't
`DAV1D_API`, and the only `extern "C" {}` `fn`s imported should be asm
`fn`s.

Note that in b62e49e the existing signature was wrong (it used `*mut
c_void`) so I have to remove the casts to `*mut c_void`.
  • Loading branch information
kkysen authored Sep 25, 2023
2 parents 29a6929 + 60b26ef commit dcdf130
Show file tree
Hide file tree
Showing 25 changed files with 97 additions and 332 deletions.
3 changes: 1 addition & 2 deletions src/cdef_apply_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ unsafe extern "C" fn adjust_strength(strength: c_int, var: c_uint) -> c_int {
return strength * (4 + i) + 8 >> 4;
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_cdef_brow_16bpc(
pub unsafe fn dav1d_cdef_brow_16bpc(
tc: *mut Dav1dTaskContext,
p: *const *mut pixel,
lflvl: *const Av1Filter,
Expand Down
3 changes: 1 addition & 2 deletions src/cdef_apply_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ unsafe extern "C" fn adjust_strength(strength: c_int, var: c_uint) -> c_int {
return strength * (4 + i) + 8 >> 4;
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_cdef_brow_8bpc(
pub unsafe fn dav1d_cdef_brow_8bpc(
tc: *mut Dav1dTaskContext,
p: *const *mut pixel,
lflvl: *const Av1Filter,
Expand Down
3 changes: 1 addition & 2 deletions src/cdef_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,8 @@ unsafe extern "C" fn cdef_filter_4x4_neon_erased(
);
}

#[no_mangle]
#[cold]
pub unsafe extern "C" fn dav1d_cdef_dsp_init_16bpc(c: *mut Dav1dCdefDSPContext) {
pub unsafe fn dav1d_cdef_dsp_init_16bpc(c: *mut Dav1dCdefDSPContext) {
(*c).dir = cdef_find_dir_c_erased;
(*c).fb[0] = cdef_filter_block_8x8_c_erased;
(*c).fb[1] = cdef_filter_block_4x8_c_erased;
Expand Down
3 changes: 1 addition & 2 deletions src/cdef_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,8 @@ unsafe extern "C" fn cdef_filter_8x8_neon_erased(
);
}

#[no_mangle]
#[cold]
pub unsafe extern "C" fn dav1d_cdef_dsp_init_8bpc(c: *mut Dav1dCdefDSPContext) {
pub unsafe fn dav1d_cdef_dsp_init_8bpc(c: *mut Dav1dCdefDSPContext) {
(*c).dir = cdef_find_dir_c_erased;
(*c).fb[0] = cdef_filter_block_8x8_c_erased;
(*c).fb[1] = cdef_filter_block_4x8_c_erased;
Expand Down
122 changes: 32 additions & 90 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use crate::include::dav1d::headers::DAV1D_WM_TYPE_TRANSLATION;
use crate::include::stdatomic::atomic_int;
use crate::include::stdatomic::atomic_uint;
use crate::src::align::Align16;
use crate::src::cdef::Dav1dCdefDSPContext;
use crate::src::cdf::dav1d_cdf_thread_alloc;
use crate::src::cdf::dav1d_cdf_thread_copy;
use crate::src::cdf::dav1d_cdf_thread_init_static;
Expand Down Expand Up @@ -69,7 +68,6 @@ use crate::src::env::get_partition_ctx;
use crate::src::env::get_poc_diff;
use crate::src::env::get_tx_ctx;
use crate::src::env::BlockContext;
use crate::src::filmgrain::Dav1dFilmGrainDSPContext;
use crate::src::internal::CodedBlockInfo;
use crate::src::internal::Dav1dContext;
use crate::src::internal::Dav1dFrameContext;
Expand All @@ -83,8 +81,6 @@ use crate::src::intra_edge::EdgeFlags;
use crate::src::intra_edge::EdgeNode;
use crate::src::intra_edge::EdgeTip;
use crate::src::intra_edge::EDGE_I444_TOP_HAS_RIGHT;
use crate::src::ipred::Dav1dIntraPredDSPContext;
use crate::src::itx::Dav1dInvTxfmDSPContext;
use crate::src::levels::mv;
use crate::src::levels::Av1Block;
use crate::src::levels::BS_128x128;
Expand Down Expand Up @@ -157,7 +153,6 @@ use crate::src::lf_mask::Av1Filter;
use crate::src::lf_mask::Av1Restoration;
use crate::src::lf_mask::Av1RestorationUnit;
use crate::src::log::dav1d_log;
use crate::src::loopfilter::Dav1dLoopFilterDSPContext;
use crate::src::looprestoration::dav1d_loop_restoration_dsp_init;
use crate::src::mc::dav1d_mc_dsp_init;
use crate::src::mem::dav1d_alloc_aligned;
Expand Down Expand Up @@ -242,92 +237,39 @@ use std::slice;
use std::sync::atomic::AtomicI32;
use std::sync::atomic::Ordering;

#[cfg(feature = "bitdepth_16")]
use crate::include::common::bitdepth::BitDepth16;

#[cfg(feature = "bitdepth_8")]
use crate::include::common::bitdepth::BitDepth8;

extern "C" {
#[cfg(feature = "bitdepth_8")]
fn dav1d_cdef_dsp_init_8bpc(c: *mut Dav1dCdefDSPContext);
#[cfg(feature = "bitdepth_16")]
fn dav1d_cdef_dsp_init_16bpc(c: *mut Dav1dCdefDSPContext);
#[cfg(feature = "bitdepth_8")]
fn dav1d_film_grain_dsp_init_8bpc(c: *mut Dav1dFilmGrainDSPContext);
#[cfg(feature = "bitdepth_16")]
fn dav1d_film_grain_dsp_init_16bpc(c: *mut Dav1dFilmGrainDSPContext);
#[cfg(feature = "bitdepth_8")]
fn dav1d_intra_pred_dsp_init_8bpc(c: *mut Dav1dIntraPredDSPContext);
#[cfg(feature = "bitdepth_16")]
fn dav1d_intra_pred_dsp_init_16bpc(c: *mut Dav1dIntraPredDSPContext);
#[cfg(feature = "bitdepth_8")]
fn dav1d_itx_dsp_init_8bpc(c: *mut Dav1dInvTxfmDSPContext, bpc: c_int);
#[cfg(feature = "bitdepth_16")]
fn dav1d_itx_dsp_init_16bpc(c: *mut Dav1dInvTxfmDSPContext, bpc: c_int);
#[cfg(feature = "bitdepth_8")]
fn dav1d_loop_filter_dsp_init_8bpc(c: *mut Dav1dLoopFilterDSPContext);
#[cfg(feature = "bitdepth_16")]
fn dav1d_loop_filter_dsp_init_16bpc(c: *mut Dav1dLoopFilterDSPContext);
#[cfg(feature = "bitdepth_8")]
fn dav1d_recon_b_intra_8bpc(
t: *mut Dav1dTaskContext,
bs: BlockSize,
intra_edge_flags: EdgeFlags,
b: *const Av1Block,
);
#[cfg(feature = "bitdepth_16")]
fn dav1d_recon_b_intra_16bpc(
t: *mut Dav1dTaskContext,
bs: BlockSize,
intra_edge_flags: EdgeFlags,
b: *const Av1Block,
);
#[cfg(feature = "bitdepth_8")]
fn dav1d_recon_b_inter_8bpc(
t: *mut Dav1dTaskContext,
bs: BlockSize,
b: *const Av1Block,
) -> c_int;
#[cfg(feature = "bitdepth_16")]
fn dav1d_recon_b_inter_16bpc(
t: *mut Dav1dTaskContext,
bs: BlockSize,
b: *const Av1Block,
) -> c_int;
#[cfg(feature = "bitdepth_8")]
fn dav1d_filter_sbrow_8bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_16")]
fn dav1d_filter_sbrow_16bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_8")]
fn dav1d_filter_sbrow_deblock_cols_8bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_16")]
fn dav1d_filter_sbrow_deblock_cols_16bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_8")]
fn dav1d_filter_sbrow_deblock_rows_8bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_16")]
fn dav1d_filter_sbrow_deblock_rows_16bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_8")]
fn dav1d_filter_sbrow_cdef_8bpc(tc: *mut Dav1dTaskContext, sby: c_int);
#[cfg(feature = "bitdepth_16")]
fn dav1d_filter_sbrow_cdef_16bpc(tc: *mut Dav1dTaskContext, sby: c_int);
#[cfg(feature = "bitdepth_8")]
fn dav1d_filter_sbrow_resize_8bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_16")]
fn dav1d_filter_sbrow_resize_16bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_8")]
fn dav1d_filter_sbrow_lr_8bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_16")]
fn dav1d_filter_sbrow_lr_16bpc(f: *mut Dav1dFrameContext, sby: c_int);
#[cfg(feature = "bitdepth_8")]
fn dav1d_backup_ipred_edge_8bpc(t: *mut Dav1dTaskContext);
#[cfg(feature = "bitdepth_16")]
fn dav1d_backup_ipred_edge_16bpc(t: *mut Dav1dTaskContext);
#[cfg(feature = "bitdepth_8")]
fn dav1d_read_coef_blocks_8bpc(t: *mut Dav1dTaskContext, bs: BlockSize, b: *const Av1Block);
#[cfg(feature = "bitdepth_16")]
fn dav1d_read_coef_blocks_16bpc(t: *mut Dav1dTaskContext, bs: BlockSize, b: *const Av1Block);
}
use crate::{
include::common::bitdepth::BitDepth8, src::cdef_tmpl_8::dav1d_cdef_dsp_init_8bpc,
src::filmgrain_tmpl_8::dav1d_film_grain_dsp_init_8bpc,
src::ipred_tmpl_8::dav1d_intra_pred_dsp_init_8bpc, src::itx_tmpl_8::dav1d_itx_dsp_init_8bpc,
src::loopfilter_tmpl_8::dav1d_loop_filter_dsp_init_8bpc,
src::recon_tmpl_8::dav1d_backup_ipred_edge_8bpc, src::recon_tmpl_8::dav1d_filter_sbrow_8bpc,
src::recon_tmpl_8::dav1d_filter_sbrow_cdef_8bpc,
src::recon_tmpl_8::dav1d_filter_sbrow_deblock_cols_8bpc,
src::recon_tmpl_8::dav1d_filter_sbrow_deblock_rows_8bpc,
src::recon_tmpl_8::dav1d_filter_sbrow_lr_8bpc,
src::recon_tmpl_8::dav1d_filter_sbrow_resize_8bpc,
src::recon_tmpl_8::dav1d_read_coef_blocks_8bpc, src::recon_tmpl_8::dav1d_recon_b_inter_8bpc,
src::recon_tmpl_8::dav1d_recon_b_intra_8bpc,
};

#[cfg(feature = "bitdepth_16")]
use crate::{
include::common::bitdepth::BitDepth16, src::cdef_tmpl_16::dav1d_cdef_dsp_init_16bpc,
src::filmgrain_tmpl_16::dav1d_film_grain_dsp_init_16bpc,
src::ipred_tmpl_16::dav1d_intra_pred_dsp_init_16bpc,
src::itx_tmpl_16::dav1d_itx_dsp_init_16bpc,
src::loopfilter_tmpl_16::dav1d_loop_filter_dsp_init_16bpc,
src::recon_tmpl_16::dav1d_backup_ipred_edge_16bpc,
src::recon_tmpl_16::dav1d_filter_sbrow_16bpc,
src::recon_tmpl_16::dav1d_filter_sbrow_cdef_16bpc,
src::recon_tmpl_16::dav1d_filter_sbrow_deblock_cols_16bpc,
src::recon_tmpl_16::dav1d_filter_sbrow_deblock_rows_16bpc,
src::recon_tmpl_16::dav1d_filter_sbrow_lr_16bpc,
src::recon_tmpl_16::dav1d_filter_sbrow_resize_16bpc,
src::recon_tmpl_16::dav1d_read_coef_blocks_16bpc,
src::recon_tmpl_16::dav1d_recon_b_inter_16bpc, src::recon_tmpl_16::dav1d_recon_b_intra_16bpc,
};

fn init_quant_tables(
seq_hdr: &Dav1dSequenceHeader,
Expand Down
9 changes: 3 additions & 6 deletions src/fg_apply_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ unsafe extern "C" fn generate_scaling(
}
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_prep_grain_16bpc(
pub unsafe fn dav1d_prep_grain_16bpc(
dsp: *const Dav1dFilmGrainDSPContext,
out: *mut Dav1dPicture,
in_0: *const Dav1dPicture,
Expand Down Expand Up @@ -224,8 +223,7 @@ pub unsafe extern "C" fn dav1d_prep_grain_16bpc(
}
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_apply_grain_row_16bpc(
pub unsafe fn dav1d_apply_grain_row_16bpc(
dsp: *const Dav1dFilmGrainDSPContext,
out: *mut Dav1dPicture,
in_0: *const Dav1dPicture,
Expand Down Expand Up @@ -334,8 +332,7 @@ pub unsafe extern "C" fn dav1d_apply_grain_row_16bpc(
};
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_apply_grain_16bpc(
pub unsafe fn dav1d_apply_grain_16bpc(
dsp: *const Dav1dFilmGrainDSPContext,
out: *mut Dav1dPicture,
in_0: *const Dav1dPicture,
Expand Down
9 changes: 3 additions & 6 deletions src/fg_apply_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ unsafe extern "C" fn generate_scaling(
);
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_prep_grain_8bpc(
pub unsafe fn dav1d_prep_grain_8bpc(
dsp: *const Dav1dFilmGrainDSPContext,
out: *mut Dav1dPicture,
in_0: *const Dav1dPicture,
Expand Down Expand Up @@ -189,8 +188,7 @@ pub unsafe extern "C" fn dav1d_prep_grain_8bpc(
}
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_apply_grain_row_8bpc(
pub unsafe fn dav1d_apply_grain_row_8bpc(
dsp: *const Dav1dFilmGrainDSPContext,
out: *mut Dav1dPicture,
in_0: *const Dav1dPicture,
Expand Down Expand Up @@ -298,8 +296,7 @@ pub unsafe extern "C" fn dav1d_apply_grain_row_8bpc(
};
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_apply_grain_8bpc(
pub unsafe fn dav1d_apply_grain_8bpc(
dsp: *const Dav1dFilmGrainDSPContext,
out: *mut Dav1dPicture,
in_0: *const Dav1dPicture,
Expand Down
3 changes: 1 addition & 2 deletions src/filmgrain_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1842,9 +1842,8 @@ unsafe extern "C" fn fguv_32x32xn_444_neon(
}
}

#[no_mangle]
#[cold]
pub unsafe extern "C" fn dav1d_film_grain_dsp_init_16bpc(c: *mut Dav1dFilmGrainDSPContext) {
pub unsafe fn dav1d_film_grain_dsp_init_16bpc(c: *mut Dav1dFilmGrainDSPContext) {
(*c).generate_grain_y = Some(generate_grain_y_c_erased);
(*c).generate_grain_uv[(DAV1D_PIXEL_LAYOUT_I420 - 1) as usize] =
Some(generate_grain_uv_420_c_erased);
Expand Down
3 changes: 1 addition & 2 deletions src/filmgrain_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1775,9 +1775,8 @@ unsafe extern "C" fn fguv_32x32xn_444_neon(
}
}

#[no_mangle]
#[cold]
pub unsafe extern "C" fn dav1d_film_grain_dsp_init_8bpc(c: *mut Dav1dFilmGrainDSPContext) {
pub unsafe fn dav1d_film_grain_dsp_init_8bpc(c: *mut Dav1dFilmGrainDSPContext) {
(*c).generate_grain_y = Some(generate_grain_y_c_erased);
(*c).generate_grain_uv[(DAV1D_PIXEL_LAYOUT_I420 - 1) as usize] =
Some(generate_grain_uv_420_c_erased);
Expand Down
3 changes: 1 addition & 2 deletions src/ipred_prepare_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ static mut av1_intra_prediction_edges: [av1_intra_prediction_edge; 14] =
needs_left_needs_top_needs_topleft_needs_topright_needs_bottomleft: [0; 1],
}; N_IMPL_INTRA_PRED_MODES];

#[no_mangle]
pub unsafe extern "C" fn dav1d_prepare_intra_edges_16bpc(
pub unsafe fn dav1d_prepare_intra_edges_16bpc(
x: c_int,
have_left: c_int,
y: c_int,
Expand Down
3 changes: 1 addition & 2 deletions src/ipred_prepare_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ static mut av1_intra_prediction_edges: [av1_intra_prediction_edge; 14] =
needs_left_needs_top_needs_topleft_needs_topright_needs_bottomleft: [0; 1],
}; N_IMPL_INTRA_PRED_MODES];

#[no_mangle]
pub unsafe extern "C" fn dav1d_prepare_intra_edges_8bpc(
pub unsafe fn dav1d_prepare_intra_edges_8bpc(
x: c_int,
have_left: c_int,
y: c_int,
Expand Down
3 changes: 1 addition & 2 deletions src/ipred_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2117,9 +2117,8 @@ unsafe fn ipred_z1_neon(
};
}

#[no_mangle]
#[cold]
pub unsafe extern "C" fn dav1d_intra_pred_dsp_init_16bpc(c: *mut Dav1dIntraPredDSPContext) {
pub unsafe fn dav1d_intra_pred_dsp_init_16bpc(c: *mut Dav1dIntraPredDSPContext) {
(*c).intra_pred[DC_PRED as usize] = Some(ipred_dc_c_erased);
(*c).intra_pred[DC_128_PRED as usize] = Some(ipred_dc_128_c_erased);
(*c).intra_pred[TOP_DC_PRED as usize] = Some(ipred_dc_top_c_erased);
Expand Down
3 changes: 1 addition & 2 deletions src/ipred_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2036,9 +2036,8 @@ unsafe fn ipred_z1_neon(
};
}

#[no_mangle]
#[cold]
pub unsafe extern "C" fn dav1d_intra_pred_dsp_init_8bpc(c: *mut Dav1dIntraPredDSPContext) {
pub unsafe fn dav1d_intra_pred_dsp_init_8bpc(c: *mut Dav1dIntraPredDSPContext) {
(*c).intra_pred[DC_PRED as usize] = Some(ipred_dc_c_erased);
(*c).intra_pred[DC_128_PRED as usize] = Some(ipred_dc_128_c_erased);
(*c).intra_pred[TOP_DC_PRED as usize] = Some(ipred_dc_top_c_erased);
Expand Down
3 changes: 1 addition & 2 deletions src/itx_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,10 +1039,9 @@ unsafe extern "C" fn itx_dsp_init_arm(c: *mut Dav1dInvTxfmDSPContext, bpc: c_int
Some(dav1d_inv_txfm_add_dct_dct_64x64_16bpc_neon);
}

#[no_mangle]
#[cold]
#[rustfmt::skip]
pub unsafe extern "C" fn dav1d_itx_dsp_init_16bpc(
pub unsafe fn dav1d_itx_dsp_init_16bpc(
c: *mut Dav1dInvTxfmDSPContext,
mut _bpc: c_int,
) {
Expand Down
3 changes: 1 addition & 2 deletions src/itx_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,10 +792,9 @@ unsafe extern "C" fn itx_dsp_init_arm(c: *mut Dav1dInvTxfmDSPContext, mut _bpc:
(*c).itxfm_add[TX_64X64 as usize][DCT_DCT as usize] = Some(dav1d_inv_txfm_add_dct_dct_64x64_8bpc_neon);
}

#[no_mangle]
#[cold]
#[rustfmt::skip]
pub unsafe extern "C" fn dav1d_itx_dsp_init_8bpc(
pub unsafe fn dav1d_itx_dsp_init_8bpc(
c: *mut Dav1dInvTxfmDSPContext,
mut _bpc: c_int,
) {
Expand Down
13 changes: 3 additions & 10 deletions src/lf_apply_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,7 @@ unsafe extern "C" fn backup_lpf(
};
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_copy_lpf_16bpc(
f: *mut Dav1dFrameContext,
src: *const *mut pixel,
sby: c_int,
) {
pub unsafe fn dav1d_copy_lpf_16bpc(f: *mut Dav1dFrameContext, src: *const *mut pixel, sby: c_int) {
let have_tt = ((*(*f).c).n_tc > 1 as c_uint) as c_int;
let resize = ((*(*f).frame_hdr).width[0] != (*(*f).frame_hdr).width[1]) as c_int;
let offset = 8 * (sby != 0) as c_int;
Expand Down Expand Up @@ -515,8 +510,7 @@ unsafe extern "C" fn filter_plane_rows_uv(
}
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_loopfilter_sbrow_cols_16bpc(
pub unsafe fn dav1d_loopfilter_sbrow_cols_16bpc(
f: *const Dav1dFrameContext,
p: *const *mut pixel,
lflvl: *mut Av1Filter,
Expand Down Expand Up @@ -721,8 +715,7 @@ pub unsafe extern "C" fn dav1d_loopfilter_sbrow_cols_16bpc(
}
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_loopfilter_sbrow_rows_16bpc(
pub unsafe fn dav1d_loopfilter_sbrow_rows_16bpc(
f: *const Dav1dFrameContext,
p: *const *mut pixel,
lflvl: *mut Av1Filter,
Expand Down
Loading

0 comments on commit dcdf130

Please sign in to comment.