forked from webrtc-rs/media
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic implementation of audio buffer and sample
- Loading branch information
1 parent
0acd4a6
commit 960bba3
Showing
8 changed files
with
1,009 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
|
||
use webrtc_media::audio::buffer::{ | ||
layout::{Deinterleaved, Interleaved}, | ||
Buffer, | ||
}; | ||
|
||
fn benchmark_from(c: &mut Criterion) { | ||
type Sample = i32; | ||
let channels = 4; | ||
let frames = 100_000; | ||
let deinterleaved_buffer: Buffer<Sample, Deinterleaved> = { | ||
let samples = (0..(channels * frames)).map(|i| i as i32).collect(); | ||
Buffer::new(samples, channels) | ||
}; | ||
let interleaved_buffer: Buffer<Sample, Interleaved> = { | ||
let samples = (0..(channels * frames)).map(|i| i as i32).collect(); | ||
Buffer::new(samples, channels) | ||
}; | ||
|
||
c.bench_function("Buffer<T, Interleaved> => Buffer<T, Deinterleaved>", |b| { | ||
b.iter(|| { | ||
black_box(Buffer::<Sample, Interleaved>::from( | ||
deinterleaved_buffer.as_ref(), | ||
)); | ||
}) | ||
}); | ||
|
||
c.bench_function("Buffer<T, Deinterleaved> => Buffer<T, Interleaved>", |b| { | ||
b.iter(|| { | ||
black_box(Buffer::<Sample, Deinterleaved>::from( | ||
interleaved_buffer.as_ref(), | ||
)); | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, benchmark_from); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub mod buffer; | ||
mod sample; | ||
|
||
pub use sample::Sample; |
Oops, something went wrong.