Skip to content

Commit

Permalink
Fix clippy (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
mo271 authored Sep 17, 2024
1 parent 82bc598 commit 3a44e3b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
8 changes: 8 additions & 0 deletions jxl/src/entropy_coding/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ pub fn decode_varint16(br: &mut BitReader) -> Result<u16, Error> {
#[derive(UnconditionalCoder, Debug)]
struct LZ77Params {
pub enabled: bool,
// TODO(firsching): remove once we use this!
#[allow(dead_code)]
#[condition(enabled)]
#[coder(u2S(224, 512, 4096, Bits(15) + 8))]
pub min_symbol: Option<u32>,
// TODO(firsching): remove once we use this!
#[allow(dead_code)]
#[condition(enabled)]
#[coder(u2S(3, 4, Bits(2) + 5, Bits(8) + 9))]
pub min_length: Option<u32>,
Expand All @@ -48,8 +52,12 @@ enum Codes {
#[derive(Debug)]
pub struct Histograms {
lz77_params: LZ77Params,
// TODO(firsching): remove once we use this!
#[allow(dead_code)]
lz77_length_uint: Option<HybridUint>,
context_map: Vec<u8>,
// TODO(firsching): remove once we use this!
#[allow(dead_code)]
log_alpha_size: usize,
uint_configs: Vec<HybridUint>,
codes: Codes,
Expand Down
9 changes: 4 additions & 5 deletions jxl/src/entropy_coding/huffman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ impl Table {
}
} else {
let extra_bits = code_len - 14;
let old_repeat;
let repeat_delta;

let new_len = if code_len == CODE_LENGTH_REPEAT_CODE {
prev_code_len
} else {
Expand All @@ -234,13 +233,13 @@ impl Table {
repeat = 0;
repeat_code_len = new_len;
}
old_repeat = repeat;
let old_repeat = repeat;
if repeat > 0 {
repeat -= 2;
repeat <<= extra_bits;
}
repeat += br.read(extra_bits as usize)? as u8 + 3;
repeat_delta = repeat - old_repeat;
let repeat_delta = repeat - old_repeat;
if symbol + repeat_delta as usize > al_size {
return Err(Error::InvalidHuffman);
}
Expand Down Expand Up @@ -366,7 +365,7 @@ impl Table {
}
counts[len] -= 1;
let bits = (len - root_bits) as u8;
let value = sorted[symbol] as u16;
let value = sorted[symbol];
symbol += 1;
let pos = table_pos + (key as usize >> root_bits);
replicate_value(&mut table[pos..], step, TableEntry { bits, value });
Expand Down
6 changes: 6 additions & 0 deletions jxl/src/headers/color_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ pub enum RenderingIntent {
pub struct CustomXY {
#[default(0)]
#[coder(u2S(Bits(19), Bits(19) + 524288, Bits(20) + 1048576, Bits(21) + 2097152))]
// TODO(firsching): remove once we use this!
#[allow(dead_code)]
x: i32,
#[default(0)]
#[coder(u2S(Bits(19), Bits(19) + 524288, Bits(20) + 1048576, Bits(21) + 2097152))]
// TODO(firsching): remove once we use this!
#[allow(dead_code)]
y: i32,
}

Expand Down Expand Up @@ -114,6 +118,8 @@ impl CustomTransferFunction {
pub struct ColorEncoding {
#[all_default]
#[default(true)]
// TODO(firsching): remove once we use this!
#[allow(dead_code)]
all_default: bool,
#[default(false)]
pub want_icc: bool,
Expand Down
7 changes: 3 additions & 4 deletions jxl/src/headers/encodings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ impl UnconditionalCoder<()> for u64 {
1 => Ok(1 + br.read(4)?),
2 => Ok(17 + br.read(8)?),
_ => {
let mut result: u64 = br.read(12)? as u64;
let mut result: u64 = br.read(12)?;
let mut shift = 12;
while br.read(1)? == 1 {
if shift >= 60 {
assert_eq!(shift, 60);
return Ok(result | ((br.read(4)? as u64) << shift));
return Ok(result | (br.read(4)? << shift));
}
result |= (br.read(8)? as u64) << shift;
result |= br.read(8)? << shift;
shift += 8;
}
Ok(result)
Expand Down Expand Up @@ -373,7 +373,6 @@ impl UnconditionalCoder<()> for Extensions {
br: &mut BitReader,
_: &Self::Nonserialized,
) -> Result<Extensions, Error> {
use std::convert::TryFrom;
let selector = u64::read_unconditional(&(), br, &Empty {})?;
let mut total_size: u64 = 0;
for i in 0..64 {
Expand Down
2 changes: 2 additions & 0 deletions jxl/src/headers/extra_channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ enum ExtraChannel {
Optional,
}

// TODO(firsching): remove once we use this!
#[allow(dead_code)]
#[derive(UnconditionalCoder, Debug)]
#[validate]
pub struct ExtraChannelInfo {
Expand Down
2 changes: 2 additions & 0 deletions jxl/src/headers/image_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ impl ToneMapping {
}
}

// TODO(firsching): remove once we use this!
#[allow(dead_code)]
#[derive(UnconditionalCoder, Debug)]
pub struct ImageMetadata {
#[all_default]
Expand Down
4 changes: 4 additions & 0 deletions jxl/src/headers/transform_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct CustomTransformDataNonserialized {
pub xyb_encoded: bool,
}

// TODO(firsching): remove once we use this!
#[allow(dead_code)]
#[derive(UnconditionalCoder, Debug)]
pub struct OpsinInverseMatrix {
#[all_default]
Expand Down Expand Up @@ -322,6 +324,8 @@ const DEFAULT_KERN_8: [f32; 210] = [
-0.00458223,
];

// TODO(firsching): remove once we use this!
#[allow(dead_code)]
#[derive(UnconditionalCoder, Debug)]
#[nonserialized(CustomTransformDataNonserialized)]
pub struct CustomTransformData {
Expand Down

0 comments on commit 3a44e3b

Please sign in to comment.