Skip to content

Commit 1d72d4f

Browse files
committed
fn dav1d_apply_grain::scaling: cfg alignment based on bitdepth and arch.
`Align1` is used when alignment wasn't specified in C to avoid have to `cfg` the uses of `scaling`.
1 parent ca941b1 commit 1d72d4f

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/fg_apply_tmpl_16.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::include::stddef::*;
22
use crate::include::stdint::*;
3-
use crate::src::align::{Align16, Align64};
3+
use crate::src::align::{Align1, Align16};
44
use ::libc;
55
extern "C" {
66
pub type Dav1dRef;
@@ -392,7 +392,7 @@ pub unsafe extern "C" fn dav1d_apply_grain_16bpc(
392392
in_0: *const Dav1dPicture,
393393
) {
394394
let mut grain_lut = Align16([[[0; 82]; 74]; 3]);
395-
let mut scaling = Align64([[0; 4096]; 3]);
395+
let mut scaling = Align1([[0; 4096]; 3]);
396396
let rows = (*out).p.h + 31 >> 5;
397397
dav1d_prep_grain_16bpc(
398398
dsp,

src/fg_apply_tmpl_8.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::include::stddef::*;
22
use crate::include::stdint::*;
3-
use crate::src::align::{Align16, Align64};
3+
use crate::src::align::Align16;
44
use ::libc;
5+
use cfg_if::cfg_if;
56
extern "C" {
67
pub type Dav1dRef;
78
fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void;
@@ -348,7 +349,17 @@ pub unsafe extern "C" fn dav1d_apply_grain_8bpc(
348349
in_0: *const Dav1dPicture,
349350
) {
350351
let mut grain_lut = Align16([[[0; 82]; 74]; 3]);
351-
let mut scaling = Align64([[0; 256]; 3]);
352+
cfg_if! {
353+
if #[cfg(target_arch = "x86_64")] {
354+
use crate::src::align::Align64;
355+
356+
let mut scaling = Align64([[0; 256]; 3]);
357+
} else {
358+
use crate::src::align::Align1;
359+
360+
let mut scaling = Align1([[0; 256]; 3]);
361+
}
362+
}
352363
let rows = (*out).p.h + 31 >> 5;
353364
dav1d_prep_grain_8bpc(
354365
dsp,

0 commit comments

Comments
 (0)