Commit 3542c01f authored by Raphaël Zumer's avatar Raphaël Zumer

Fix some indentation and whitespace

parent 5311eeea
...@@ -294,29 +294,29 @@ impl Context { ...@@ -294,29 +294,29 @@ impl Context {
} }
pub fn container_sequence_header(&mut self) -> Vec<u8> { pub fn container_sequence_header(&mut self) -> Vec<u8> {
use bitstream_io::*;
use std::io;
fn sequence_header_inner(seq: &Sequence) -> io::Result<Vec<u8>> { fn sequence_header_inner(seq: &Sequence) -> io::Result<Vec<u8>> {
let mut buf = Vec::new(); let mut buf = Vec::new();
{ {
let mut bw = BitWriter::endian(&mut buf, BigEndian); let mut bw = BitWriter::endian(&mut buf, BigEndian);
bw.write_bit(true)?; // marker bw.write_bit(true)?; // marker
bw.write(7, 1)?; // version bw.write(7, 1)?; // version
bw.write(3, seq.profile)?; bw.write(3, seq.profile)?;
bw.write(5, 32)?; // level bw.write(5, 32)?; // level
bw.write_bit(false)?; // tier bw.write_bit(false)?; // tier
bw.write_bit(seq.bit_depth > 8)?; // high_bitdepth bw.write_bit(seq.bit_depth > 8)?; // high_bitdepth
bw.write_bit(seq.bit_depth == 12)?; // twelve_bit bw.write_bit(seq.bit_depth == 12)?; // twelve_bit
bw.write_bit(seq.bit_depth == 1)?; // monochrome bw.write_bit(seq.bit_depth == 1)?; // monochrome
bw.write_bit(seq.bit_depth == 12)?; // twelve_bit bw.write_bit(seq.bit_depth == 12)?; // twelve_bit
bw.write_bit(seq.chroma_sampling != ChromaSampling::Cs444)?; // chroma_subsampling_x bw.write_bit(seq.chroma_sampling != ChromaSampling::Cs444)?; // chroma_subsampling_x
bw.write_bit(seq.chroma_sampling == ChromaSampling::Cs420)?; // chroma_subsampling_y bw.write_bit(seq.chroma_sampling == ChromaSampling::Cs420)?; // chroma_subsampling_y
bw.write(2, 0)?; // sample_position bw.write(2, 0)?; // sample_position
bw.write(3, 0)?; // reserved bw.write(3, 0)?; // reserved
bw.write_bit(false)?; // initial_presentation_delay_present bw.write_bit(false)?; // initial_presentation_delay_present
bw.write(4, 0)?; // reserved bw.write(4, 0)?; // reserved
} }
Ok(buf) Ok(buf)
} }
......
...@@ -45,7 +45,7 @@ fn cdef_find_dir(img: &[u16], stride: usize, var: &mut i32, coeff_shift: i32) -> ...@@ -45,7 +45,7 @@ fn cdef_find_dir(img: &[u16], stride: usize, var: &mut i32, coeff_shift: i32) ->
for i in 0..8 { for i in 0..8 {
for j in 0..8 { for j in 0..8 {
// We subtract 128 here to reduce the maximum range of the squared // We subtract 128 here to reduce the maximum range of the squared
// partial sums. // partial sums.
debug_assert!((img[i * stride + j] >> coeff_shift) <= 255); debug_assert!((img[i * stride + j] >> coeff_shift) <= 255);
let x = (img[i * stride + j] as i32 >> coeff_shift) - 128; let x = (img[i * stride + j] as i32 >> coeff_shift) - 128;
partial[0][i + j] += x; partial[0][i + j] += x;
...@@ -91,11 +91,11 @@ fn cdef_find_dir(img: &[u16], stride: usize, var: &mut i32, coeff_shift: i32) -> ...@@ -91,11 +91,11 @@ fn cdef_find_dir(img: &[u16], stride: usize, var: &mut i32, coeff_shift: i32) ->
} }
} }
// Difference between the optimal variance and the variance along the // Difference between the optimal variance and the variance along the
// orthogonal direction. Again, the sum(x^2) terms cancel out. // orthogonal direction. Again, the sum(x^2) terms cancel out.
// We'd normally divide by 840, but dividing by 1024 is close enough // We'd normally divide by 840, but dividing by 1024 is close enough
// for what we're going to do with this. */ // for what we're going to do with this. */
*var = (best_cost - cost[(best_dir + 4) & 7]) >> 10; *var = (best_cost - cost[(best_dir + 4) & 7]) >> 10;
best_dir as i32 best_dir as i32
} }
...@@ -107,7 +107,7 @@ fn constrain(diff: i32, threshold: i32, damping: i32) -> i32 { ...@@ -107,7 +107,7 @@ fn constrain(diff: i32, threshold: i32, damping: i32) -> i32 {
-1 * magnitude -1 * magnitude
} else { } else {
magnitude magnitude
} }
} else { } else {
0 0
} }
...@@ -285,12 +285,12 @@ pub fn cdef_filter_superblock(fi: &FrameInvariants, ...@@ -285,12 +285,12 @@ pub fn cdef_filter_superblock(fi: &FrameInvariants,
let in_slice = &in_plane.mut_slice(&in_po); let in_slice = &in_plane.mut_slice(&in_po);
let out_stride = out_plane.cfg.stride; let out_stride = out_plane.cfg.stride;
let mut out_slice = &mut out_plane.mut_slice(&out_po); let mut out_slice = &mut out_plane.mut_slice(&out_po);
let mut local_pri_strength; let mut local_pri_strength;
let mut local_sec_strength; let mut local_sec_strength;
let mut local_damping: i32 = cdef_damping + coeff_shift; let mut local_damping: i32 = cdef_damping + coeff_shift;
let mut local_dir: usize; let mut local_dir: usize;
if p==0 { if p==0 {
local_pri_strength = adjust_strength(cdef_pri_y_strength << coeff_shift, var); local_pri_strength = adjust_strength(cdef_pri_y_strength << coeff_shift, var);
local_sec_strength = cdef_sec_y_strength << coeff_shift; local_sec_strength = cdef_sec_y_strength << coeff_shift;
...@@ -301,7 +301,7 @@ pub fn cdef_filter_superblock(fi: &FrameInvariants, ...@@ -301,7 +301,7 @@ pub fn cdef_filter_superblock(fi: &FrameInvariants,
local_damping -= 1; local_damping -= 1;
local_dir = if cdef_pri_uv_strength != 0 {dir as usize} else {0}; local_dir = if cdef_pri_uv_strength != 0 {dir as usize} else {0};
} }
unsafe { unsafe {
cdef_filter_block(out_slice.offset_as_mutable(8*bx>>xdec,8*by>>ydec), cdef_filter_block(out_slice.offset_as_mutable(8*bx>>xdec,8*by>>ydec),
out_stride as isize, out_stride as isize,
......
...@@ -3664,7 +3664,7 @@ pub fn get_mv_class(z: u32, offset: &mut u32) -> usize { ...@@ -3664,7 +3664,7 @@ pub fn get_mv_class(z: u32, offset: &mut u32) -> usize {
c c
} }
pub fn encode_mv_component(w: &mut Writer, comp: i32, pub fn encode_mv_component(w: &mut Writer, comp: i32,
mvcomp: &mut NMVComponent, precision: MvSubpelPrecision) { mvcomp: &mut NMVComponent, precision: MvSubpelPrecision) {
assert!(comp != 0); assert!(comp != 0);
let mut offset: u32 = 0; let mut offset: u32 = 0;
...@@ -3701,7 +3701,7 @@ pub fn encode_mv_component(w: &mut Writer, comp: i32, ...@@ -3701,7 +3701,7 @@ pub fn encode_mv_component(w: &mut Writer, comp: i32,
// High precision bit // High precision bit
if precision > MvSubpelPrecision::MV_SUBPEL_LOW_PRECISION { if precision > MvSubpelPrecision::MV_SUBPEL_LOW_PRECISION {
w.symbol_with_update( w.symbol_with_update(
hp, hp,
if mv_class == MV_CLASS_0 { &mut mvcomp.class0_hp_cdf } if mv_class == MV_CLASS_0 { &mut mvcomp.class0_hp_cdf }
else { &mut mvcomp.hp_cdf}); else { &mut mvcomp.hp_cdf});
} }
......
...@@ -274,6 +274,7 @@ impl<S> WriterBase<S> { ...@@ -274,6 +274,7 @@ impl<S> WriterBase<S> {
fn new(storage: S) -> Self { fn new(storage: S) -> Self {
WriterBase { rng: 0x8000, cnt: -9, debug: false, s: storage } WriterBase { rng: 0x8000, cnt: -9, debug: false, s: storage }
} }
/// Compute low and range values from token cdf values and local state /// Compute low and range values from token cdf values and local state
fn lr_compute(&mut self, fl: u16, fh: u16, nms: u16) -> (ec_window, u16) { fn lr_compute(&mut self, fl: u16, fh: u16, nms: u16) -> (ec_window, u16) {
let u: u32; let u: u32;
...@@ -292,6 +293,7 @@ impl<S> WriterBase<S> { ...@@ -292,6 +293,7 @@ impl<S> WriterBase<S> {
(0, r as u16) (0, r as u16)
} }
} }
/// Given the current total integer number of bits used and the current value of /// Given the current total integer number of bits used and the current value of
/// rng, computes the fraction number of bits used to `OD_BITRES` precision. /// rng, computes the fraction number of bits used to `OD_BITRES` precision.
/// This is used by `od_ec_enc_tell_frac()` and `od_ec_dec_tell_frac()`. /// This is used by `od_ec_enc_tell_frac()` and `od_ec_dec_tell_frac()`.
...@@ -326,7 +328,8 @@ impl<S> WriterBase<S> { ...@@ -326,7 +328,8 @@ impl<S> WriterBase<S> {
} }
nbits - l nbits - l
} }
/// Function to update the CDF for Writer calls that do so.
// Function to update the CDF for Writer calls that do so.
fn update_cdf(cdf: &mut [u16], val: u32) { fn update_cdf(cdf: &mut [u16], val: u32) {
let nsymbs = cdf.len() - 1; let nsymbs = cdf.len() - 1;
let rate = 3 + (nsymbs >> 1).min(2) + (cdf[nsymbs] >> 4) as usize; let rate = 3 + (nsymbs >> 1).min(2) + (cdf[nsymbs] >> 4) as usize;
......
...@@ -2527,7 +2527,7 @@ fn encode_tile(sequence: &mut Sequence, fi: &FrameInvariants, fs: &mut FrameStat ...@@ -2527,7 +2527,7 @@ fn encode_tile(sequence: &mut Sequence, fi: &FrameInvariants, fs: &mut FrameStat
}; };
let bc = BlockContext::new(fi.w_in_b, fi.h_in_b); let bc = BlockContext::new(fi.w_in_b, fi.h_in_b);
// For now, restoration unit size is locked to superblock size. // For now, restoration unit size is locked to superblock size.
let rc = RestorationContext::new(fi.sb_width, fi.sb_height); let rc = RestorationContext::new(fi.sb_width, fi.sb_height);
let mut cw = ContextWriter::new(fc, bc, rc); let mut cw = ContextWriter::new(fc, bc, rc);
......
...@@ -45,8 +45,5 @@ mod api; ...@@ -45,8 +45,5 @@ mod api;
pub use api::*; pub use api::*;
pub use encoder::*; pub use encoder::*;
// #[cfg(test)]
#[cfg(all(test, feature="decode_test"))] #[cfg(all(test, feature="decode_test"))]
mod test_encode_decode; mod test_encode_decode;
...@@ -14,7 +14,6 @@ pub const RESTORE_SWITCHABLE: u8 = 1; ...@@ -14,7 +14,6 @@ pub const RESTORE_SWITCHABLE: u8 = 1;
pub const RESTORE_WIENER: u8 = 2; pub const RESTORE_WIENER: u8 = 2;
pub const RESTORE_SGRPROJ: u8 = 3; pub const RESTORE_SGRPROJ: u8 = 3;
pub const WIENER_TAPS_MIN: [i8; 3] = [ -5, -23, -17 ]; pub const WIENER_TAPS_MIN: [i8; 3] = [ -5, -23, -17 ];
pub const WIENER_TAPS_MID: [i8; 3] = [ 3, -7, 15 ]; pub const WIENER_TAPS_MID: [i8; 3] = [ 3, -7, 15 ];
pub const WIENER_TAPS_MAX: [i8; 3] = [ 10, 8, 46 ]; pub const WIENER_TAPS_MAX: [i8; 3] = [ 10, 8, 46 ];
......
...@@ -655,7 +655,7 @@ pub fn rdo_mode_decision( ...@@ -655,7 +655,7 @@ pub fn rdo_mode_decision(
let cost = wr.tell_frac() - tell; let cost = wr.tell_frac() - tell;
// For CFL, tx-domain distortion is not an option. // For CFL, tx-domain distortion is not an option.
let rd = let rd =
compute_rd_cost( compute_rd_cost(
fi, fi,
fs, fs,
...@@ -703,7 +703,7 @@ pub fn rdo_mode_decision( ...@@ -703,7 +703,7 @@ pub fn rdo_mode_decision(
} }
pub fn rdo_cfl_alpha( pub fn rdo_cfl_alpha(
fs: &mut FrameState, bo: &BlockOffset, bsize: BlockSize, bit_depth: usize, fs: &mut FrameState, bo: &BlockOffset, bsize: BlockSize, bit_depth: usize,
chroma_sampling: ChromaSampling) -> Option<CFLParams> { chroma_sampling: ChromaSampling) -> Option<CFLParams> {
let uv_tx_size = bsize.largest_uv_tx_size(chroma_sampling); let uv_tx_size = bsize.largest_uv_tx_size(chroma_sampling);
......
...@@ -87,13 +87,13 @@ fn setup_encoder( ...@@ -87,13 +87,13 @@ fn setup_encoder(
enc.low_latency = low_latency; enc.low_latency = low_latency;
let cfg = Config { let cfg = Config {
frame_info: FrameInfo { frame_info: FrameInfo {
width: w, width: w,
height: h, height: h,
bit_depth, bit_depth,
chroma_sampling, chroma_sampling,
chroma_sample_position: chroma_sample_position:
Default::default() Default::default()
}, },
timebase: Rational::new(1, 1000), timebase: Rational::new(1, 1000),
enc enc
......
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