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 {
}
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>> {
let mut buf = Vec::new();
{
let mut bw = BitWriter::endian(&mut buf, BigEndian);
bw.write_bit(true)?; // marker
bw.write(7, 1)?; // version
bw.write(3, seq.profile)?;
bw.write(5, 32)?; // level
bw.write_bit(false)?; // tier
bw.write_bit(seq.bit_depth > 8)?; // high_bitdepth
bw.write_bit(seq.bit_depth == 12)?; // twelve_bit
bw.write_bit(seq.bit_depth == 1)?; // monochrome
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::Cs420)?; // chroma_subsampling_y
bw.write(2, 0)?; // sample_position
bw.write(3, 0)?; // reserved
bw.write_bit(false)?; // initial_presentation_delay_present
bw.write(4, 0)?; // reserved
let mut bw = BitWriter::endian(&mut buf, BigEndian);
bw.write_bit(true)?; // marker
bw.write(7, 1)?; // version
bw.write(3, seq.profile)?;
bw.write(5, 32)?; // level
bw.write_bit(false)?; // tier
bw.write_bit(seq.bit_depth > 8)?; // high_bitdepth
bw.write_bit(seq.bit_depth == 12)?; // twelve_bit
bw.write_bit(seq.bit_depth == 1)?; // monochrome
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::Cs420)?; // chroma_subsampling_y
bw.write(2, 0)?; // sample_position
bw.write(3, 0)?; // reserved
bw.write_bit(false)?; // initial_presentation_delay_present
bw.write(4, 0)?; // reserved
}
Ok(buf)
}
......
......@@ -45,7 +45,7 @@ fn cdef_find_dir(img: &[u16], stride: usize, var: &mut i32, coeff_shift: i32) ->
for i in 0..8 {
for j in 0..8 {
// 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);
let x = (img[i * stride + j] as i32 >> coeff_shift) - 128;
partial[0][i + j] += x;
......@@ -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
// 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
// for what we're going to do with this. */
*var = (best_cost - cost[(best_dir + 4) & 7]) >> 10;
best_dir as i32
}
......@@ -107,7 +107,7 @@ fn constrain(diff: i32, threshold: i32, damping: i32) -> i32 {
-1 * magnitude
} else {
magnitude
}
}
} else {
0
}
......@@ -285,12 +285,12 @@ pub fn cdef_filter_superblock(fi: &FrameInvariants,
let in_slice = &in_plane.mut_slice(&in_po);
let out_stride = out_plane.cfg.stride;
let mut out_slice = &mut out_plane.mut_slice(&out_po);
let mut local_pri_strength;
let mut local_sec_strength;
let mut local_damping: i32 = cdef_damping + coeff_shift;
let mut local_dir: usize;
if p==0 {
local_pri_strength = adjust_strength(cdef_pri_y_strength << coeff_shift, var);
local_sec_strength = cdef_sec_y_strength << coeff_shift;
......@@ -301,7 +301,7 @@ pub fn cdef_filter_superblock(fi: &FrameInvariants,
local_damping -= 1;
local_dir = if cdef_pri_uv_strength != 0 {dir as usize} else {0};
}
unsafe {
cdef_filter_block(out_slice.offset_as_mutable(8*bx>>xdec,8*by>>ydec),
out_stride as isize,
......
......@@ -3664,7 +3664,7 @@ pub fn get_mv_class(z: u32, offset: &mut u32) -> usize {
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) {
assert!(comp != 0);
let mut offset: u32 = 0;
......@@ -3701,7 +3701,7 @@ pub fn encode_mv_component(w: &mut Writer, comp: i32,
// High precision bit
if precision > MvSubpelPrecision::MV_SUBPEL_LOW_PRECISION {
w.symbol_with_update(
hp,
hp,
if mv_class == MV_CLASS_0 { &mut mvcomp.class0_hp_cdf }
else { &mut mvcomp.hp_cdf});
}
......
......@@ -274,6 +274,7 @@ impl<S> WriterBase<S> {
fn new(storage: S) -> Self {
WriterBase { rng: 0x8000, cnt: -9, debug: false, s: storage }
}
/// 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) {
let u: u32;
......@@ -292,6 +293,7 @@ impl<S> WriterBase<S> {
(0, r as u16)
}
}
/// 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.
/// This is used by `od_ec_enc_tell_frac()` and `od_ec_dec_tell_frac()`.
......@@ -326,7 +328,8 @@ impl<S> WriterBase<S> {
}
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) {
let nsymbs = cdf.len() - 1;
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
};
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 mut cw = ContextWriter::new(fc, bc, rc);
......
......@@ -45,8 +45,5 @@ mod api;
pub use api::*;
pub use encoder::*;
// #[cfg(test)]
#[cfg(all(test, feature="decode_test"))]
mod test_encode_decode;
......@@ -14,7 +14,6 @@ pub const RESTORE_SWITCHABLE: u8 = 1;
pub const RESTORE_WIENER: u8 = 2;
pub const RESTORE_SGRPROJ: u8 = 3;
pub const WIENER_TAPS_MIN: [i8; 3] = [ -5, -23, -17 ];
pub const WIENER_TAPS_MID: [i8; 3] = [ 3, -7, 15 ];
pub const WIENER_TAPS_MAX: [i8; 3] = [ 10, 8, 46 ];
......
......@@ -655,7 +655,7 @@ pub fn rdo_mode_decision(
let cost = wr.tell_frac() - tell;
// For CFL, tx-domain distortion is not an option.
let rd =
let rd =
compute_rd_cost(
fi,
fs,
......@@ -703,7 +703,7 @@ pub fn rdo_mode_decision(
}
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> {
let uv_tx_size = bsize.largest_uv_tx_size(chroma_sampling);
......
......@@ -87,13 +87,13 @@ fn setup_encoder(
enc.low_latency = low_latency;
let cfg = Config {
frame_info: FrameInfo {
width: w,
height: h,
bit_depth,
chroma_sampling,
chroma_sample_position:
Default::default()
frame_info: FrameInfo {
width: w,
height: h,
bit_depth,
chroma_sampling,
chroma_sample_position:
Default::default()
},
timebase: Rational::new(1, 1000),
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