Skip to content

Commit

Permalink
fn dav1d_*_{8,16}bpc: Deduplicate declarations into use imports f…
Browse files Browse the repository at this point in the history
…or the remaining bpc `fn`s.
  • Loading branch information
kkysen committed Sep 25, 2023
1 parent 432bbe3 commit 60b26ef
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 149 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/fg_apply_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ pub unsafe 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
3 changes: 1 addition & 2 deletions src/fg_apply_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ pub unsafe 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/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
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
13 changes: 3 additions & 10 deletions src/lf_apply_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,7 @@ unsafe extern "C" fn backup_lpf(
};
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_copy_lpf_8bpc(
f: *mut Dav1dFrameContext,
src: *const *mut pixel,
sby: c_int,
) {
pub unsafe fn dav1d_copy_lpf_8bpc(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 @@ -480,8 +475,7 @@ unsafe extern "C" fn filter_plane_rows_uv(
}
}

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

#[no_mangle]
pub unsafe extern "C" fn dav1d_loopfilter_sbrow_rows_8bpc(
pub unsafe fn dav1d_loopfilter_sbrow_rows_8bpc(
f: *const Dav1dFrameContext,
p: *const *mut pixel,
lflvl: *mut Av1Filter,
Expand Down
19 changes: 6 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use crate::src::data::dav1d_data_unref_internal;
use crate::src::data::dav1d_data_wrap_internal;
use crate::src::data::dav1d_data_wrap_user_data_internal;
use crate::src::decode::dav1d_decode_frame_exit;
use crate::src::filmgrain::Dav1dFilmGrainDSPContext;
use crate::src::internal::CodedBlockInfo;
use crate::src::internal::Dav1dContext;
use crate::src::internal::Dav1dFrameContext;
Expand Down Expand Up @@ -106,25 +105,19 @@ use std::ffi::c_ulong;
use std::ffi::c_void;
use std::process::abort;

#[cfg(feature = "bitdepth_8")]
use crate::src::fg_apply_tmpl_8::dav1d_apply_grain_8bpc;

#[cfg(feature = "bitdepth_16")]
use crate::src::fg_apply_tmpl_16::dav1d_apply_grain_16bpc;

#[cfg(target_os = "linux")]
use libc::dlsym;

#[cfg(target_os = "linux")]
use libc::sysconf;

extern "C" {
#[cfg(feature = "bitdepth_16")]
fn dav1d_apply_grain_16bpc(
dsp: *const Dav1dFilmGrainDSPContext,
out: *mut Dav1dPicture,
in_0: *const Dav1dPicture,
);
#[cfg(feature = "bitdepth_8")]
fn dav1d_apply_grain_8bpc(
dsp: *const Dav1dFilmGrainDSPContext,
out: *mut Dav1dPicture,
in_0: *const Dav1dPicture,
);
fn pthread_create(
__newthread: *mut pthread_t,
__attr: *const pthread_attr_t,
Expand Down
7 changes: 1 addition & 6 deletions src/lr_apply_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,7 @@ unsafe extern "C" fn lr_sbrow(
}
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_lr_sbrow_16bpc(
f: *mut Dav1dFrameContext,
dst: *const *mut pixel,
sby: c_int,
) {
pub unsafe fn dav1d_lr_sbrow_16bpc(f: *mut Dav1dFrameContext, dst: *const *mut pixel, sby: c_int) {
let offset_y = 8 * (sby != 0) as c_int;
let dst_stride: *const ptrdiff_t = ((*f).sr_cur.p.stride).as_mut_ptr();
let restore_planes = (*f).lf.restore_planes;
Expand Down
7 changes: 1 addition & 6 deletions src/lr_apply_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,7 @@ unsafe extern "C" fn lr_sbrow(
}
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_lr_sbrow_8bpc(
f: *mut Dav1dFrameContext,
dst: *const *mut pixel,
sby: c_int,
) {
pub unsafe fn dav1d_lr_sbrow_8bpc(f: *mut Dav1dFrameContext, dst: *const *mut pixel, sby: c_int) {
let offset_y = 8 * (sby != 0) as c_int;
let dst_stride: *const ptrdiff_t = ((*f).sr_cur.p.stride).as_mut_ptr();
let restore_planes = (*f).lf.restore_planes;
Expand Down
53 changes: 6 additions & 47 deletions src/recon_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::include::dav1d::headers::DAV1D_PIXEL_LAYOUT_I400;
use crate::include::dav1d::headers::DAV1D_PIXEL_LAYOUT_I420;
use crate::include::dav1d::headers::DAV1D_PIXEL_LAYOUT_I444;
use crate::include::dav1d::headers::DAV1D_WM_TYPE_TRANSLATION;
use crate::src::cdef_apply_tmpl_16::dav1d_cdef_brow_16bpc;
use crate::src::ctx::CaseSet;
use crate::src::env::get_uv_inter_txtp;
use crate::src::internal::CodedBlockInfo;
Expand All @@ -27,6 +28,7 @@ use crate::src::intra_edge::EDGE_I444_LEFT_HAS_BOTTOM;
use crate::src::intra_edge::EDGE_I444_TOP_HAS_RIGHT;
use crate::src::ipred_prepare::sm_flag;
use crate::src::ipred_prepare::sm_uv_flag;
use crate::src::ipred_prepare_tmpl_16::dav1d_prepare_intra_edges_16bpc;
use crate::src::levels::mv;
use crate::src::levels::Av1Block;
use crate::src::levels::BlockSize;
Expand Down Expand Up @@ -58,7 +60,11 @@ use crate::src::levels::TX_CLASS_2D;
use crate::src::levels::TX_CLASS_H;
use crate::src::levels::TX_CLASS_V;
use crate::src::levels::WHT_WHT;
use crate::src::lf_apply_tmpl_16::dav1d_copy_lpf_16bpc;
use crate::src::lf_apply_tmpl_16::dav1d_loopfilter_sbrow_cols_16bpc;
use crate::src::lf_apply_tmpl_16::dav1d_loopfilter_sbrow_rows_16bpc;
use crate::src::lf_mask::Av1Filter;
use crate::src::lr_apply_tmpl_16::dav1d_lr_sbrow_16bpc;
use crate::src::msac::dav1d_msac_decode_bool_adapt;
use crate::src::msac::dav1d_msac_decode_bool_equi;
use crate::src::msac::dav1d_msac_decode_bools;
Expand Down Expand Up @@ -98,52 +104,6 @@ use std::ffi::c_uint;
use std::ffi::c_ulong;
use std::ffi::c_void;

extern "C" {
fn dav1d_cdef_brow_16bpc(
tc: *mut Dav1dTaskContext,
p: *const *mut pixel,
lflvl: *const Av1Filter,
by_start: c_int,
by_end: c_int,
sbrow_start: c_int,
sby: c_int,
);
fn dav1d_prepare_intra_edges_16bpc(
x: c_int,
have_left: c_int,
y: c_int,
have_top: c_int,
w: c_int,
h: c_int,
edge_flags: EdgeFlags,
dst: *const pixel,
stride: ptrdiff_t,
prefilter_toplevel_sb_edge: *const pixel,
mode: IntraPredMode,
angle: *mut c_int,
tw: c_int,
th: c_int,
filter_edge: c_int,
topleft_out: *mut pixel,
bitdepth_max: c_int,
) -> IntraPredMode;
fn dav1d_loopfilter_sbrow_cols_16bpc(
f: *const Dav1dFrameContext,
p: *const *mut pixel,
lflvl: *mut Av1Filter,
sby: c_int,
start_of_tile_row: c_int,
);
fn dav1d_loopfilter_sbrow_rows_16bpc(
f: *const Dav1dFrameContext,
p: *const *mut pixel,
lflvl: *mut Av1Filter,
sby: c_int,
);
fn dav1d_copy_lpf_16bpc(f: *mut Dav1dFrameContext, src: *const *mut pixel, sby: c_int);
fn dav1d_lr_sbrow_16bpc(f: *mut Dav1dFrameContext, dst: *const *mut pixel, sby: c_int);
}

pub type pixel = u16;
pub type coef = i32;

Expand Down Expand Up @@ -1527,7 +1487,6 @@ unsafe extern "C" fn read_coef_tree(
};
}

#[no_mangle]
pub unsafe extern "C" fn dav1d_read_coef_blocks_16bpc(
t: *mut Dav1dTaskContext,
bs: BlockSize,
Expand Down
51 changes: 6 additions & 45 deletions src/recon_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::include::dav1d::headers::DAV1D_PIXEL_LAYOUT_I400;
use crate::include::dav1d::headers::DAV1D_PIXEL_LAYOUT_I420;
use crate::include::dav1d::headers::DAV1D_PIXEL_LAYOUT_I444;
use crate::include::dav1d::headers::DAV1D_WM_TYPE_TRANSLATION;
use crate::src::cdef_apply_tmpl_8::dav1d_cdef_brow_8bpc;
use crate::src::ctx::CaseSet;
use crate::src::env::get_uv_inter_txtp;
use crate::src::internal::CodedBlockInfo;
Expand All @@ -27,6 +28,7 @@ use crate::src::intra_edge::EDGE_I444_LEFT_HAS_BOTTOM;
use crate::src::intra_edge::EDGE_I444_TOP_HAS_RIGHT;
use crate::src::ipred_prepare::sm_flag;
use crate::src::ipred_prepare::sm_uv_flag;
use crate::src::ipred_prepare_tmpl_8::dav1d_prepare_intra_edges_8bpc;
use crate::src::levels::mv;
use crate::src::levels::Av1Block;
use crate::src::levels::BlockSize;
Expand Down Expand Up @@ -58,7 +60,11 @@ use crate::src::levels::TX_CLASS_2D;
use crate::src::levels::TX_CLASS_H;
use crate::src::levels::TX_CLASS_V;
use crate::src::levels::WHT_WHT;
use crate::src::lf_apply_tmpl_8::dav1d_copy_lpf_8bpc;
use crate::src::lf_apply_tmpl_8::dav1d_loopfilter_sbrow_cols_8bpc;
use crate::src::lf_apply_tmpl_8::dav1d_loopfilter_sbrow_rows_8bpc;
use crate::src::lf_mask::Av1Filter;
use crate::src::lr_apply_tmpl_8::dav1d_lr_sbrow_8bpc;
use crate::src::msac::dav1d_msac_decode_bool_adapt;
use crate::src::msac::dav1d_msac_decode_bool_equi;
use crate::src::msac::dav1d_msac_decode_bools;
Expand Down Expand Up @@ -98,51 +104,6 @@ use std::ffi::c_uint;
use std::ffi::c_ulong;
use std::ffi::c_void;

extern "C" {
fn dav1d_cdef_brow_8bpc(
tc: *mut Dav1dTaskContext,
p: *const *mut pixel,
lflvl: *const Av1Filter,
by_start: c_int,
by_end: c_int,
sbrow_start: c_int,
sby: c_int,
);
fn dav1d_prepare_intra_edges_8bpc(
x: c_int,
have_left: c_int,
y: c_int,
have_top: c_int,
w: c_int,
h: c_int,
edge_flags: EdgeFlags,
dst: *const pixel,
stride: ptrdiff_t,
prefilter_toplevel_sb_edge: *const pixel,
mode: IntraPredMode,
angle: *mut c_int,
tw: c_int,
th: c_int,
filter_edge: c_int,
topleft_out: *mut pixel,
) -> IntraPredMode;
fn dav1d_loopfilter_sbrow_cols_8bpc(
f: *const Dav1dFrameContext,
p: *const *mut pixel,
lflvl: *mut Av1Filter,
sby: c_int,
start_of_tile_row: c_int,
);
fn dav1d_loopfilter_sbrow_rows_8bpc(
f: *const Dav1dFrameContext,
p: *const *mut pixel,
lflvl: *mut Av1Filter,
sby: c_int,
);
fn dav1d_copy_lpf_8bpc(f: *mut Dav1dFrameContext, src: *const *mut pixel, sby: c_int);
fn dav1d_lr_sbrow_8bpc(f: *mut Dav1dFrameContext, dst: *const *mut pixel, sby: c_int);
}

pub type pixel = u8;
pub type coef = i16;

Expand Down

0 comments on commit 60b26ef

Please sign in to comment.