Skip to content

Commit

Permalink
1:1 conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
mooman219 committed Dec 29, 2021
1 parent a1e533d commit 426e938
Show file tree
Hide file tree
Showing 58 changed files with 120 additions and 107 deletions.
6 changes: 3 additions & 3 deletions symphonia-bundle-flac/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::cmp;
use std::num::Wrapping;
use core::cmp;
use core::num::Wrapping;

use symphonia_core::audio::{AudioBuffer, AudioBufferRef, AsAudioBufferRef};
use symphonia_core::audio::{Signal, SignalSpec};
Expand Down Expand Up @@ -252,7 +252,7 @@ impl Decoder for FlacDecoder {
// Only generate the expected and decoded MD5 checksum strings if logging is
// enabled at the debug level.
if log_enabled!(log::Level::Debug) {
use std::fmt::Write;
use core::fmt::Write;

let mut expected_s = String::with_capacity(32);
let mut decoded_s = String::with_capacity(32);
Expand Down
2 changes: 2 additions & 0 deletions symphonia-bundle-flac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#![allow(clippy::identity_op)]
#![allow(clippy::manual_range_contains)]

extern crate alloc;

mod decoder;
mod demuxer;
mod frame;
Expand Down
4 changes: 2 additions & 2 deletions symphonia-bundle-flac/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::cmp::min;
use std::collections::VecDeque;
use core::cmp::min;
use alloc::collections::VecDeque;

use symphonia_core::checksum::Crc16Ansi;
use symphonia_core::errors::{Result, Error};
Expand Down
4 changes: 2 additions & 2 deletions symphonia-bundle-flac/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::mem;
use std::vec::Vec;
use core::mem;
use alloc::vec::Vec;

use symphonia_core::audio::{AudioBuffer, Signal};
use symphonia_core::checksum::Md5;
Expand Down
4 changes: 2 additions & 2 deletions symphonia-bundle-mp3/src/demuxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl FormatReader for Mp3Reader {
let header = header::parse_frame_header(header::sync_frame(&mut self.reader)?)?;

// Position of the frame header.
let frame_pos = self.reader.pos() - std::mem::size_of::<u32>() as u64;
let frame_pos = self.reader.pos() - core::mem::size_of::<u32>() as u64;

// Calculate the duration of the frame.
let duration = SAMPLES_PER_GRANULE * header.n_granules() as u64;
Expand Down Expand Up @@ -225,7 +225,7 @@ impl FormatReader for Mp3Reader {
if main_data_begin > 0 {
// The maximum number of reference frames is limited to the number of frames
// read and the number of previous frames recorded.
let max_ref_frames = std::cmp::min(n_frames, frames.len());
let max_ref_frames = core::cmp::min(n_frames, frames.len());

while n_ref_frames < max_ref_frames {
ref_frame = &frames[(n_frames - n_ref_frames - 1) & REF_FRAMES_MASK];
Expand Down
8 changes: 4 additions & 4 deletions symphonia-bundle-mp3/src/layer3/hybrid_synthesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Justification: Some loops are better expressed without a range loop.
#![allow(clippy::needless_range_loop)]

use std::f64;
use core::f64;

use lazy_static::lazy_static;

Expand Down Expand Up @@ -445,7 +445,7 @@ pub fn frequency_inversion(samples: &mut [f32; 576]) {
mod tests {
use super::IMDCT_WINDOWS;
use super::imdct12_win;
use std::f64;
use core::f64;

fn imdct12_analytical(x: &[f32; 6]) -> [f32; 12] {
const PI_24: f64 = f64::consts::PI / 24.0;
Expand Down Expand Up @@ -623,7 +623,7 @@ mod imdct36 {
1.931_851_652_578_136_6, // m=1
1.812_615_574_073_299_9, // m=2
1.638_304_088_577_983_6, // m=3
std::f32::consts::SQRT_2, // m=4
core::f32::consts::SQRT_2, // m=4
1.147_152_872_702_092_3, // m=5
0.845_236_523_481_398_9, // m=6
0.517_638_090_205_041_9, // m=7
Expand Down Expand Up @@ -735,7 +735,7 @@ mod imdct36 {
#[cfg(test)]
mod tests {
use super::imdct36;
use std::f64;
use core::f64;

fn imdct36_analytical(x: &[f32; 18]) -> [f32; 36] {
let mut result = [0f32; 36];
Expand Down
2 changes: 1 addition & 1 deletion symphonia-bundle-mp3/src/layer3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::fmt;
use core::fmt;

use symphonia_core::audio::{AudioBuffer, Signal};
use symphonia_core::errors::{Result, decode_error, Error};
Expand Down
4 changes: 2 additions & 2 deletions symphonia-bundle-mp3/src/layer3/requantize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::cmp::min;
use std::{f32, f64};
use core::cmp::min;
use core::{f32, f64};

use symphonia_core::errors::Result;
use symphonia_core::io::ReadBitsLtr;
Expand Down
4 changes: 2 additions & 2 deletions symphonia-bundle-mp3/src/layer3/stereo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::cmp::max;
use std::{f64, f32};
use core::cmp::max;
use core::{f64, f32};

use symphonia_core::errors::{Result, decode_error};

Expand Down
2 changes: 1 addition & 1 deletion symphonia-bundle-mp3/src/synthesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ fn dct32(x: &[f32; 32], y: &mut [f32; 32]) {
#[cfg(test)]
mod tests {
use super::dct32;
use std::f64;
use core::f64;

fn dct32_analytical(x: &[f32; 32]) -> [f32; 32] {
const PI_32: f64 = f64::consts::PI / 32.0;
Expand Down
2 changes: 1 addition & 1 deletion symphonia-check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ fn run_check(

// The number of samples that can be compared given the current state of the reference
// and target sample buffers.
let n_test_samples = std::cmp::min(ref_samples.len(), tgt_samples.len());
let n_test_samples = core::cmp::min(ref_samples.len(), tgt_samples.len());

// Perform the comparison.
for (&t, &r) in tgt_samples[..n_test_samples].iter()
Expand Down
4 changes: 2 additions & 2 deletions symphonia-codec-aac/src/aac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::f32::consts;
use std::fmt;
use core::f32::consts;
use core::fmt;

use symphonia_core::errors::{decode_error, unsupported_error, Result};
use symphonia_core::io::{ReadBitsLtr, FiniteBitStream, BitReaderLtr};
Expand Down
2 changes: 1 addition & 1 deletion symphonia-codec-aac/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::f32::consts;
use core::f32::consts;

/// Window types.
#[derive(Debug,Clone,Copy,PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion symphonia-codec-alac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Disable to better express the specification.
#![allow(clippy::collapsible_else_if)]

use std::cmp::min;
use core::cmp::min;

use symphonia_core::audio::{
AsAudioBufferRef, AudioBuffer, AudioBufferRef, Channels, Signal, SignalSpec,
Expand Down
1 change: 1 addition & 0 deletions symphonia-codec-vorbis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ edition = "2018"

[dependencies]
log = "0.4"
hashbrown = "0.11.2"
symphonia-core = { version = "0.4", path = "../symphonia-core" }
symphonia-utils-xiph = { version = "0.4", path = "../symphonia-utils-xiph" }
4 changes: 2 additions & 2 deletions symphonia-codec-vorbis/src/codebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::usize;
use core::usize;

use symphonia_core::errors::{Result, decode_error};
use symphonia_core::io::{vlc::{BitOrder, Codebook, CodebookBuilder, Entry32x32}, ReadBitsRtl};
Expand Down Expand Up @@ -283,7 +283,7 @@ impl VorbisCodebook {

let num = bs.read_bits_leq32(num_bits)?;

code_lens.extend(std::iter::repeat(cur_len as u8).take(num as usize));
code_lens.extend(core::iter::repeat(cur_len as u8).take(num as usize));

cur_len += 1;
cur_entry += num;
Expand Down
6 changes: 3 additions & 3 deletions symphonia-codec-vorbis/src/floor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::cmp::min;
use std::collections::HashSet;
use core::cmp::min;
use hashbrown::HashSet;

use symphonia_core::errors::{Error, Result, decode_error};
use symphonia_core::io::{ReadBitsRtl, BitReaderRtl};
Expand Down Expand Up @@ -286,7 +286,7 @@ impl Floor for Floor0 {
&self.setup.floor0_map_long
};

let omega_step = std::f32::consts::PI / f32::from(self.setup.floor0_bark_map_size);
let omega_step = core::f32::consts::PI / f32::from(self.setup.floor0_bark_map_size);

let mut i = 0;

Expand Down
2 changes: 1 addition & 1 deletion symphonia-codec-vorbis/src/residue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::cmp::min;
use core::cmp::min;
use std::io;

use symphonia_core::errors::{Error, Result, decode_error};
Expand Down
2 changes: 1 addition & 1 deletion symphonia-codec-vorbis/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::f64::consts;
use core::f64::consts;

/// For a given window size, generates the curve of the left-half of the window.
fn generate_win_curve(bs: usize) -> Vec<f32> {
Expand Down
1 change: 1 addition & 0 deletions symphonia-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ bitflags = "1.2.1"
bytemuck = "1.7"
lazy_static = "1.4.0"
log = "0.4"
hashbrown = "0.11.2"
10 changes: 5 additions & 5 deletions symphonia-core/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
//! The `audio` module provides primitives for working with multi-channel audio buffers of varying
//! sample formats.

use std::borrow::Cow;
use std::fmt;
use std::marker::PhantomData;
use std::mem;
use std::vec::Vec;
use alloc::borrow::Cow;
use core::fmt;
use core::marker::PhantomData;
use core::mem;
use alloc::vec::Vec;

use arrayvec::ArrayVec;
use bitflags::bitflags;
Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/checksum/md5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::cmp;
use core::cmp;

use crate::io::Monitor;

Expand Down
6 changes: 3 additions & 3 deletions symphonia-core/src/codecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
//! The `codec` module provides the traits and support structures necessary to implement audio codec
//! decoders.

use std::collections::HashMap;
use std::default::Default;
use std::fmt;
use hashbrown::HashMap;
use core::default::Default;
use core::fmt;

use crate::audio::{AudioBufferRef, Channels, Layout};
use crate::errors::{Result, unsupported_error};
Expand Down
4 changes: 2 additions & 2 deletions symphonia-core/src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub mod dither {
//! Multiple dithering algorithms are provided, each drawing noise from a different probability
//! distribution. In addition to different distributions, a dithering algorithm may also shape
//! the noise such that the bulk of the noise is placed in an inaudible frequency range.
use std::marker::PhantomData;
use core::marker::PhantomData;
use super::FromSample;
use crate::sample::{u24, i24};
use crate::sample::Sample;
Expand Down Expand Up @@ -638,7 +638,7 @@ where

#[cfg(test)]
mod tests {
use std::{u8, i8, u16, i16, u32, i32};
use core::{u8, i8, u16, i16, u32, i32};
use crate::sample::{u24, i24, Sample};
use super::FromSample;

Expand Down
4 changes: 2 additions & 2 deletions symphonia-core/src/dsp/dct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! The (I)DCT algorithms in this module are not general purpose and are specialized for use in
//! typical audio compression applications. Therefore, some constraints may apply.

use std::f64;
use core::f64;

use lazy_static::lazy_static;

Expand Down Expand Up @@ -711,7 +711,7 @@ fn dct_ii_32(x: &mut [f32]) {
#[cfg(test)]
mod tests {
use super::*;
use std::f64;
use core::f64;

fn dct_analytical(x: &[f32], y: &mut [f32]) {
let n = x.len();
Expand Down
4 changes: 2 additions & 2 deletions symphonia-core/src/dsp/mdct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! The (I)MDCT algorithms in this module are not general purpose and are specialized for use in
//! typical audio compression applications. Therefore, some constraints may apply.

use std::f64;
use core::f64;

use super::dct::Dct;

Expand Down Expand Up @@ -134,7 +134,7 @@ impl Imdct {

#[cfg(test)]
mod tests {
use std::f64;
use core::f64;
use super::*;

fn imdct_analytical(x: &[f32], y: &mut [f32], scale: f64) {
Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! The `errors` module defines the common error type.

use std::error;
use std::fmt;
use core::fmt;
use std::io;
use std::result;

Expand Down

0 comments on commit 426e938

Please sign in to comment.