Commit 4b326701 authored by Michael Bebenita's avatar Michael Bebenita Committed by Thomas Daede

Add 16 byte alignment.

Fix doc examples.

Remove cfg_attr.
parent fae08519
......@@ -61,6 +61,7 @@ make -j8
* src/quantize.rs - Quantization and dequantization functions for coefficients.
* src/rdo.rs - RDO-related structures and distortion computation functions.
* src/transform.rs - Implementations of DCT and ADST transforms.
* src/util.rs - Misc utility code.
* src/bin/rav1e.rs - rav1e command line tool.
* src/bin/rav1erepl.rs - Command line tool for debugging.
* aom_build/ - Local submodule of libaom. Some C functions and constants are used directly. Also used for benchmarking and testing.
......
......@@ -24,5 +24,6 @@ ignore = [
# "benches/bench.rs", # Clean
# "src/bin/rav1e.rs", # Clean
# "src/bin/rav1repl.rs", # Clean
# "src/util.rs", # Clean
"tests/aom.rs",
]
......@@ -34,6 +34,7 @@ pub mod transform;
pub mod quantize;
pub mod predict;
pub mod rdo;
pub mod util;
use context::*;
use partition::*;
......@@ -43,6 +44,7 @@ use plane::*;
use rdo::*;
use ec::*;
use std::fmt;
use util::*;
extern {
pub fn av1_rtcd();
......@@ -533,8 +535,6 @@ fn diff(dst: &mut [i16], src1: &PlaneSlice, src2: &PlaneSlice, width: usize, hei
}
}
use std::mem::uninitialized;
// For a transform block,
// predict, transform, quantize, write coefficients to a bitstream,
// dequantize, inverse-transform.
......@@ -548,29 +548,28 @@ pub fn encode_tx_block(fi: &FrameInvariants, fs: &mut FrameState, cw: &mut Conte
if skip { return; }
let mut residual: [i16; 64*64] = unsafe { uninitialized() };
let mut coeffs_storage: [i32; 64*64] = unsafe { uninitialized() };
let mut rcoeffs: [i32; 64*64] = unsafe { uninitialized() };
let coeffs = &mut coeffs_storage[..tx_size.area()];
let mut residual: AlignedArray<[i16; 64 * 64]> = UninitializedAlignedArray();
let mut coeffs_storage: AlignedArray<[i32; 64 * 64]> = UninitializedAlignedArray();
let mut rcoeffs: AlignedArray<[i32; 64 * 64]> = UninitializedAlignedArray();
let coeffs = &mut coeffs_storage.array[..tx_size.area()];
diff(&mut residual,
diff(&mut residual.array,
&fs.input.planes[p].slice(po),
&rec.slice(po),
tx_size.width(),
tx_size.height());
forward_transform(&residual, coeffs, tx_size.width(), tx_size, tx_type);
forward_transform(&residual.array, coeffs, tx_size.width(), tx_size, tx_type);
quantize_in_place(fi.qindex, coeffs, tx_size);
cw.write_coeffs_lv_map(p, bo, &coeffs, tx_size, tx_type, plane_bsize, xdec, ydec,
fi.use_reduced_tx_set);
// Reconstruct
dequantize(fi.qindex, &coeffs, &mut rcoeffs, tx_size);
dequantize(fi.qindex, &coeffs, &mut rcoeffs.array, tx_size);
inverse_transform_add(&rcoeffs, &mut rec.mut_slice(po).as_mut_slice(), stride, tx_size, tx_type);
inverse_transform_add(&rcoeffs.array, &mut rec.mut_slice(po).as_mut_slice(), stride, tx_size, tx_type);
}
fn encode_block(fi: &FrameInvariants, fs: &mut FrameState, cw: &mut ContextWriter,
......
// Copyright (c) 2017-2018, The rav1e contributors. All rights reserved
//
// This source code is subject to the terms of the BSD 2 Clause License and
// the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
// was not distributed with this source code in the LICENSE file, you can
// obtain it at www.aomedia.org/license/software. If the Alliance for Open
// Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
#[repr(align(16))]
struct Align16;
/// A 16 byte aligned array.
/// # Examples
/// ```
/// extern crate rav1e;
/// use rav1e::util::*;
///
/// let mut x: AlignedArray<[i16; 64 * 64]> = AlignedArray([0; 64 * 64]);
/// assert!(x.array.as_ptr() as usize % 16 == 0);
///
/// let mut x: AlignedArray<[i16; 64 * 64]> = UninitializedAlignedArray();
/// assert!(x.array.as_ptr() as usize % 16 == 0);
/// ```
pub struct AlignedArray<ARRAY>
where
ARRAY: ?Sized
{
_alignment: [Align16; 0],
pub array: ARRAY
}
#[allow(non_snake_case)]
pub fn AlignedArray<ARRAY>(array: ARRAY) -> AlignedArray<ARRAY> {
AlignedArray {
_alignment: [],
array
}
}
#[allow(non_snake_case)]
pub fn UninitializedAlignedArray<ARRAY>() -> AlignedArray<ARRAY> {
use std::mem;
AlignedArray(unsafe { mem::uninitialized() })
}
#[test]
fn sanity() {
let a: AlignedArray<_> = AlignedArray([0u8; 3]);
assert!(a.array.as_ptr() as usize % 16 == 0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment