Skip to content

Commit

Permalink
Fix alignment in LooprestorationParams (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
randomPoison authored Apr 13, 2023
2 parents 1cb19de + 31f9901 commit ba1f32d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/looprestoration.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::include::stdint::int16_t;
use crate::include::stdint::uint32_t;
use crate::src::align::Align16;

pub type LrEdgeFlags = libc::c_uint;
pub const LR_HAVE_BOTTOM: LrEdgeFlags = 8;
Expand All @@ -19,6 +20,6 @@ pub struct LooprestorationParams_sgr {
#[derive(Copy, Clone)]
#[repr(C)]
pub union LooprestorationParams {
pub filter: [[int16_t; 8]; 2],
pub filter: Align16<[[int16_t; 8]; 2]>,
pub sgr: LooprestorationParams_sgr,
}
2 changes: 1 addition & 1 deletion src/looprestoration_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ unsafe extern "C" fn wiener_c(
padding(tmp.as_mut_ptr(), p, stride, left, lpf, w, h, edges);
let mut hor: [uint16_t; 27300] = [0; 27300];
let mut hor_ptr: *mut uint16_t = hor.as_mut_ptr();
let filter: *const [int16_t; 8] = ((*params).filter).as_ptr();
let filter: *const [int16_t; 8] = ((*params).filter.0).as_ptr();
let bitdepth: libc::c_int = 32 as libc::c_int - clz(bitdepth_max as libc::c_uint);
let round_bits_h: libc::c_int = 3 as libc::c_int
+ (bitdepth == 12 as libc::c_int) as libc::c_int * 2 as libc::c_int;
Expand Down
2 changes: 1 addition & 1 deletion src/looprestoration_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ unsafe extern "C" fn wiener_c(
padding(tmp.as_mut_ptr(), p, stride, left, lpf, w, h, edges);
let mut hor: [uint16_t; 27300] = [0; 27300];
let mut hor_ptr: *mut uint16_t = hor.as_mut_ptr();
let filter: *const [int16_t; 8] = ((*params).filter).as_ptr();
let filter: *const [int16_t; 8] = ((*params).filter.0).as_ptr();
let bitdepth: libc::c_int = 8 as libc::c_int;
let round_bits_h: libc::c_int = 3 as libc::c_int
+ (bitdepth == 12 as libc::c_int) as libc::c_int * 2 as libc::c_int;
Expand Down
4 changes: 2 additions & 2 deletions src/lr_apply_tmpl_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,10 @@ unsafe extern "C" fn lr_stripe(
);
let mut lr_fn: looprestorationfilter_fn = None;
let mut params: LooprestorationParams = LooprestorationParams {
filter: [[0; 8]; 2],
filter: [[0; 8]; 2].into(),
};
if (*lr).type_0 as libc::c_int == DAV1D_RESTORATION_WIENER as libc::c_int {
let filter: *mut [int16_t; 8] = (params.filter).as_mut_ptr();
let filter: *mut [int16_t; 8] = (params.filter.0).as_mut_ptr();
let ref mut fresh0 = (*filter
.offset(0 as libc::c_int as isize))[6 as libc::c_int as usize];
*fresh0 = (*lr).filter_h[0 as libc::c_int as usize] as int16_t;
Expand Down
4 changes: 2 additions & 2 deletions src/lr_apply_tmpl_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,10 @@ unsafe extern "C" fn lr_stripe(
);
let mut lr_fn: looprestorationfilter_fn = None;
let mut params: LooprestorationParams = LooprestorationParams {
filter: [[0; 8]; 2],
filter: [[0; 8]; 2].into(),
};
if (*lr).type_0 as libc::c_int == DAV1D_RESTORATION_WIENER as libc::c_int {
let filter: *mut [int16_t; 8] = (params.filter).as_mut_ptr();
let filter: *mut [int16_t; 8] = (params.filter.0).as_mut_ptr();
let ref mut fresh0 = (*filter
.offset(0 as libc::c_int as isize))[6 as libc::c_int as usize];
*fresh0 = (*lr).filter_h[0 as libc::c_int as usize] as int16_t;
Expand Down

0 comments on commit ba1f32d

Please sign in to comment.