Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Aug 16, 2019
1 parent 4cedeed commit 86b49dd
Show file tree
Hide file tree
Showing 61 changed files with 8,989 additions and 5,488 deletions.
71 changes: 44 additions & 27 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
// 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.

mod dist;
mod predict;
mod transform;
mod dist;

use rav1e::bench::api::*;
use rav1e::bench::encoder::*;
use rav1e::bench::cdef::*;
use rav1e::bench::context::*;
use rav1e::bench::ec::*;
use rav1e::bench::encoder::*;
use rav1e::bench::partition::*;
use rav1e::bench::predict::*;
use rav1e::bench::transform::*;
use rav1e::bench::rdo::*;
use rav1e::bench::transform::*;

use crate::transform::{forward_transforms, inverse_transforms};

Expand Down Expand Up @@ -65,7 +65,14 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
for &mode in RAV1E_INTRA_MODES {
let sbo = TileSuperBlockOffset(SuperBlockOffset { x: sbx, y: sby });
for p in 1..3 {
ts.qc.update(fi.base_q_idx, tx_size, mode.is_intra(), 8, fi.dc_delta_q[p], fi.ac_delta_q[p]);
ts.qc.update(
fi.base_q_idx,
tx_size,
mode.is_intra(),
8,
fi.dc_delta_q[p],
fi.ac_delta_q[p],
);
for by in 0..8 {
for bx in 0..8 {
// For ex, 8x8 tx should be applied to even numbered (bx,by)
Expand All @@ -75,7 +82,8 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
continue;
};
let bo = sbo.block_offset(bx, by);
let tx_bo = TileBlockOffset(BlockOffset { x: bo.0.x + bx, y: bo.0.y + by });
let tx_bo =
TileBlockOffset(BlockOffset { x: bo.0.x + bx, y: bo.0.y + by });
let po = tx_bo.plane_offset(&ts.input.planes[p].cfg);
encode_tx_block(
&mut fi,
Expand All @@ -84,7 +92,8 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
&mut w,
p,
bo,
0,0,
0,
0,
tx_bo,
mode,
tx_size,
Expand All @@ -95,7 +104,7 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
ac,
0,
RDOType::PixelDistRealRate,
true
true,
);
}
}
Expand Down Expand Up @@ -132,7 +141,7 @@ fn cfl_rdo(c: &mut Criterion) {
BlockSize::BLOCK_4X4,
BlockSize::BLOCK_8X8,
BlockSize::BLOCK_16X16,
BlockSize::BLOCK_32X32
BlockSize::BLOCK_32X32,
] {
let n = format!("cfl_rdo({:?})", bsize);
c.bench_function(&n, move |b| cfl_rdo_bench(b, bsize));
Expand All @@ -156,41 +165,49 @@ fn cfl_rdo_bench(b: &mut Bencher, bsize: BlockSize) {
}

fn ec_bench(c: &mut Criterion) {
c.bench_function("update_cdf_4_native", update_cdf_4_native);
c.bench_function("update_cdf_4_sse2", update_cdf_4_sse2);
c.bench_function("update_cdf_4_native", update_cdf_4_native);
c.bench_function("update_cdf_4_sse2", update_cdf_4_sse2);
}

fn update_cdf_4_native(b: &mut Bencher) {
let mut cdf = [7296, 3819, 1616, 0, 0];
b.iter(|| {
for i in 0..1000 {
WriterBase::<WriterRecorder>::update_cdf(&mut cdf, i & 3);
black_box(cdf);
}
});
let mut cdf = [7296, 3819, 1616, 0, 0];
b.iter(|| {
for i in 0..1000 {
WriterBase::<WriterRecorder>::update_cdf(&mut cdf, i & 3);
black_box(cdf);
}
});
}

fn update_cdf_4_sse2(b: &mut Bencher) {
let mut cdf = [7296, 3819, 1616, 0, 0];
b.iter(|| {
for i in 0..1000 {
WriterBase::<WriterRecorder>::update_cdf_4_sse2(&mut cdf, i & 3);
black_box(cdf);
}
});
let mut cdf = [7296, 3819, 1616, 0, 0];
b.iter(|| {
for i in 0..1000 {
WriterBase::<WriterRecorder>::update_cdf_4_sse2(&mut cdf, i & 3);
black_box(cdf);
}
});
}

criterion_group!(intra_prediction, predict::pred_bench,);

criterion_group!(cfl, cfl_rdo);
criterion_group!(cdef, cdef_frame);
criterion_group!(write_block, write_b);
criterion_group!{ name = dist;
criterion_group! { name = dist;
config = Criterion::default().warm_up_time(Duration::new(1,0));
targets = dist::get_sad, dist::get_satd
}

criterion_group!(ec, ec_bench);

criterion_main!(write_block, intra_prediction, cdef, cfl, dist,
forward_transforms, inverse_transforms, ec);
criterion_main!(
write_block,
intra_prediction,
cdef,
cfl,
dist,
forward_transforms,
inverse_transforms,
ec
);
32 changes: 16 additions & 16 deletions benches/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.

use criterion::*;
use rav1e::bench::tiling::*;
use rav1e::bench::dist;
use rav1e::bench::partition::*;
use rav1e::bench::partition::BlockSize::*;
use rav1e::bench::frame::*;
use rand::{Rng, SeedableRng};
use rand_chacha::ChaChaRng;
use rav1e::bench::dist;
use rav1e::bench::frame::*;
use rav1e::bench::partition::BlockSize::*;
use rav1e::bench::partition::*;
use rav1e::bench::tiling::*;
use rav1e::Pixel;

const DIST_BENCH_SET: &[(BlockSize, usize)] = &[
Expand All @@ -40,7 +40,6 @@ const DIST_BENCH_SET: &[(BlockSize, usize)] = &[
(BLOCK_32X8, 8),
(BLOCK_16X64, 8),
(BLOCK_64X16, 8),

(BLOCK_4X4, 10),
(BLOCK_4X8, 10),
(BLOCK_8X4, 10),
Expand All @@ -62,7 +61,7 @@ const DIST_BENCH_SET: &[(BlockSize, usize)] = &[
(BLOCK_8X32, 10),
(BLOCK_32X8, 10),
(BLOCK_16X64, 10),
(BLOCK_64X16, 10)
(BLOCK_64X16, 10),
];

fn fill_plane<T: Pixel>(ra: &mut ChaChaRng, plane: &mut Plane<T>) {
Expand All @@ -75,7 +74,9 @@ fn fill_plane<T: Pixel>(ra: &mut ChaChaRng, plane: &mut Plane<T>) {
}
}

fn new_plane<T: Pixel>(ra: &mut ChaChaRng, width: usize, height: usize) -> Plane<T> {
fn new_plane<T: Pixel>(
ra: &mut ChaChaRng, width: usize, height: usize,
) -> Plane<T> {
let mut p = Plane::new(width, height, 0, 0, 128 + 8, 128 + 8);

fill_plane(ra, &mut p);
Expand All @@ -84,15 +85,15 @@ fn new_plane<T: Pixel>(ra: &mut ChaChaRng, width: usize, height: usize) -> Plane
}

type DistFn<T> = fn(
plane_org: &PlaneRegion<'_, T>,
plane_ref: &PlaneRegion<'_, T>,
blk_w: usize,
blk_h: usize,
bit_depth: usize
plane_org: &PlaneRegion<'_, T>,
plane_ref: &PlaneRegion<'_, T>,
blk_w: usize,
blk_h: usize,
bit_depth: usize,
) -> u32;

fn run_dist_bench<T: Pixel>(
b: &mut Bencher, &(bs, bit_depth): &(BlockSize, usize), func: DistFn<T>
b: &mut Bencher, &(bs, bit_depth): &(BlockSize, usize), func: DistFn<T>,
) {
let mut ra = ChaChaRng::from_seed([0; 32]);
let bsw = bs.width();
Expand All @@ -106,8 +107,7 @@ fn run_dist_bench<T: Pixel>(
let plane_ref = rec_plane.as_region();

b.iter(|| {
let _ =
black_box(func(&plane_org, &plane_ref, bsw, bsh, bit_depth));
let _ = black_box(func(&plane_org, &plane_ref, bsw, bsh, bit_depth));
})
}

Expand Down
Loading

0 comments on commit 86b49dd

Please sign in to comment.