Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/itx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ fn inv_txfm_add<BD: BitDepth>(
let row_clip_max = !row_clip_min;
let col_clip_max = !col_clip_min;

// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's itx_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
Comment on lines +99 to +101
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// before read, matching the uninitialized C counterpart in dav1d's itx_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
// before read, matching the uninitialized C counterpart in dav1d's `itx_tmpl.c`.
// Could use `MaybeUninit` to avoid zeroing, but this is a Rust fallback function
// (only used when asm is unavailable). See PR #1397 and #1399.

Could you fix these for the others, too?

let mut tmp = [0; 64 * 64];
let mut c = &mut tmp[..];
for y in 0..sh {
Expand Down Expand Up @@ -304,6 +308,10 @@ fn inv_txfm_add_wht_wht_4x4_rust<BD: BitDepth>(

let coeff = &mut coeff[..W * H];

// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's itx_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut tmp = [0; W * H];
let mut c = &mut tmp[..];
for y in 0..H {
Expand Down
20 changes: 20 additions & 0 deletions src/looprestoration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ fn wiener_rust<BD: BitDepth>(
) {
// Wiener filtering is applied to a maximum stripe height of 64 + 3 pixels
// of padding above and below
// TODO(perf): These buffers are zero-initialized but only need to be written
// before read, matching the uninitialized C counterparts in dav1d's looprestoration_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut tmp = [0.into(); (64 + 3 + 3) * REST_UNIT_STRIDE];

padding::<BD>(&mut tmp, p, left, lpf, lpf_off, w, h, edges);
Expand Down Expand Up @@ -650,6 +654,10 @@ fn selfguided_filter<BD: BitDepth>(

// Selfguided filter is applied to a maximum stripe height of 64 + 3 pixels
// of padding above and below
// TODO(perf): These buffers are zero-initialized but only need to be written
// before read, matching the uninitialized C counterparts in dav1d's looprestoration_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut sumsq = [0; (64 + 2 + 2) * REST_UNIT_STRIDE];
// By inverting `a` and `b` after the boxsums, `b` can be of `BD::Coef` instead of `i32`.
let mut sum = [0.as_::<BD::Coef>(); (64 + 2 + 2) * REST_UNIT_STRIDE];
Expand Down Expand Up @@ -803,6 +811,10 @@ fn sgr_5x5_rust<BD: BitDepth>(
) {
// Selfguided filter is applied to a maximum stripe height of 64 + 3 pixels
// of padding above and below
// TODO(perf): These buffers are zero-initialized but only need to be written
// before read, matching the uninitialized C counterparts in dav1d's looprestoration_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut tmp = [0.as_(); (64 + 3 + 3) * REST_UNIT_STRIDE];

// Selfguided filter outputs to a maximum stripe height of 64 and a
Expand Down Expand Up @@ -867,6 +879,10 @@ fn sgr_3x3_rust<BD: BitDepth>(
edges: LrEdgeFlags,
bd: BD,
) {
// TODO(perf): These buffers are zero-initialized but only need to be written
// before read, matching the uninitialized C counterparts in dav1d's looprestoration_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut tmp = [0.as_(); (64 + 3 + 3) * REST_UNIT_STRIDE];
let mut dst = [0.as_(); 64 * 384];

Expand Down Expand Up @@ -928,6 +944,10 @@ fn sgr_mix_rust<BD: BitDepth>(
edges: LrEdgeFlags,
bd: BD,
) {
// TODO(perf): These buffers are zero-initialized but only need to be written
// before read, matching the uninitialized C counterparts in dav1d's looprestoration_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut tmp = [0.as_(); (64 + 3 + 3) * REST_UNIT_STRIDE];
let mut dst0 = [0.as_(); 64 * 384];
let mut dst1 = [0.as_(); 64 * 384];
Expand Down
40 changes: 40 additions & 0 deletions src/mc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ fn put_8tap_rust<BD: BitDepth>(
if let Some(fh) = fh {
if let Some(fv) = fv {
let tmp_h = h + 7;
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0i16; MID_STRIDE]; 135]; // Default::default()

for y in 0..tmp_h {
Expand Down Expand Up @@ -223,6 +227,10 @@ fn put_8tap_scaled_rust<BD: BitDepth>(
let intermediate_bits = bd.get_intermediate_bits();
let intermediate_rnd = (1 << intermediate_bits) >> 1;
let tmp_h = ((h - 1) * dy + my >> 10) + 8;
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0i16; MID_STRIDE]; 256 + 7]; // Default::default()

for y in 0..tmp_h {
Expand Down Expand Up @@ -284,6 +292,10 @@ fn prep_8tap_rust<BD: BitDepth>(
if let Some(fh) = fh {
if let Some(fv) = fv {
let tmp_h = h + 7;
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0i16; MID_STRIDE]; 135]; // Default::default()

for y in 0..tmp_h {
Expand Down Expand Up @@ -344,6 +356,10 @@ fn prep_8tap_scaled_rust<BD: BitDepth>(
) {
let intermediate_bits = bd.get_intermediate_bits();
let tmp_h = ((h - 1) * dy + my >> 10) + 8;
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0i16; MID_STRIDE]; 256 + 7]; // Default::default()

for y in 0..tmp_h {
Expand Down Expand Up @@ -417,6 +433,10 @@ fn put_bilin_rust<BD: BitDepth>(

if mx != 0 {
if my != 0 {
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0i16; MID_STRIDE]; 129]; // Default::default()
let tmp_h = h + 1;

Expand Down Expand Up @@ -479,6 +499,10 @@ fn put_bilin_scaled_rust<BD: BitDepth>(
) {
let intermediate_bits = bd.get_intermediate_bits();
let tmp_h = ((h - 1) * dy + my >> 10) + 2;
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0i16; MID_STRIDE]; 256 + 1];

for y in 0..tmp_h {
Expand Down Expand Up @@ -523,6 +547,10 @@ fn prep_bilin_rust<BD: BitDepth>(
let intermediate_bits = bd.get_intermediate_bits();
if mx != 0 {
if my != 0 {
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0i16; MID_STRIDE]; 129];
let tmp_h = h + 1;

Expand Down Expand Up @@ -581,6 +609,10 @@ fn prep_bilin_scaled_rust<BD: BitDepth>(
) {
let intermediate_bits = bd.get_intermediate_bits();
let tmp_h = ((h - 1) * dy + my >> 10) + 2;
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0i16; MID_STRIDE]; 256 + 1];

for y in 0..tmp_h {
Expand Down Expand Up @@ -828,6 +860,10 @@ fn warp_affine_8x8_rust<BD: BitDepth>(
const H: usize = 15;

let intermediate_bits = bd.get_intermediate_bits();
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0; W]; H];

for y in 0..H {
Expand Down Expand Up @@ -879,6 +915,10 @@ fn warp_affine_8x8t_rust<BD: BitDepth>(
const H: usize = 15;

let intermediate_bits = bd.get_intermediate_bits();
// TODO(perf): This buffer is zero-initialized but only needs to be written
// before read, matching the uninitialized C counterpart in dav1d's mc_tmpl.c.
// Could use MaybeUninit to avoid zeroing, but this is a Rust fallback function
// (only used when ASM is unavailable). See PR #1397 and #1399.
let mut mid = [[0; W]; H];

for y in 0..H {
Expand Down
Loading