Skip to content

Commit

Permalink
testbench: clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
astraw committed Dec 6, 2024
1 parent d3f6d28 commit 19973cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
19 changes: 8 additions & 11 deletions testbench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn unpack12be_to_16le(packed: &[u8]) -> Vec<u8> {
let src_iter = packed.chunks_exact(3);
// debug_assert_eq!(src_iter.remainder().len(), 0);
for packed in src_iter {
let vals = unpack_12be(&packed);
let vals = unpack_12be(packed);
let unpacked0 = vals[0].to_le_bytes();
let unpacked1 = vals[1].to_le_bytes();
dest.extend(unpacked0);
Expand Down Expand Up @@ -257,9 +257,9 @@ impl MyYCbCrImage {
}
println!("** {output_name}: (raw) -> y4m");

ffmpeg_to_frame(&base_path, &output_name, tif_pix_fmt)
ffmpeg_to_frame(base_path, &output_name, tif_pix_fmt)
}
pub fn view_luma<'a>(&'a self) -> DataPlane<'a> {
pub fn view_luma(&self) -> DataPlane<'_> {
let (data, stride) = match &self.planes {
&MyPlanes::Mono(ref y_plane) | &MyPlanes::YCbCr((ref y_plane, _, _)) => {
(&y_plane.data, y_plane.stride)
Expand All @@ -271,7 +271,7 @@ impl MyYCbCrImage {
bit_depth: less_avc::BitDepth::Depth8,
}
}
pub fn view<'a>(&'a self) -> YCbCrImage<'a> {
pub fn view(&self) -> YCbCrImage<'_> {
let planes = match &self.planes {
MyPlanes::Mono(y_plane) => Planes::Mono(DataPlane {
data: &y_plane.data,
Expand Down Expand Up @@ -334,8 +334,7 @@ pub fn generate_image(fmt: &PixFmt, width: u32, height: u32) -> Result<MyYCbCrIm

let image_row_mono12: Vec<u8> = values_mono12
.chunks_exact(2)
.map(pack_to_12be)
.flatten()
.flat_map(pack_to_12be)
.collect();

let valid_width = (width * 3 / 2) as usize;
Expand Down Expand Up @@ -372,12 +371,11 @@ pub fn generate_image(fmt: &PixFmt, width: u32, height: u32) -> Result<MyYCbCrIm

let image_row_chroma12: Vec<u8> = neutral_chroma12
.chunks_exact(2)
.map(pack_to_12be)
.flatten()
.flat_map(pack_to_12be)
.collect();

for row in 0..alloc_rows {
let start_idx: usize = row as usize * stride;
let start_idx: usize = row * stride;
let dest_row = &mut data[start_idx..(start_idx + valid_width_bytes)];
// dest_row.copy_from_slice(&image_row_chroma12);

Expand All @@ -388,8 +386,7 @@ pub fn generate_image(fmt: &PixFmt, width: u32, height: u32) -> Result<MyYCbCrIm
// the case, we want this to still succeed because we want
// to test that less-avc returns an
// `Error::DataShapeProblem`.
(&mut dest_row[..image_row_chroma12.len()])
.copy_from_slice(&image_row_chroma12);
dest_row[..image_row_chroma12.len()].copy_from_slice(&image_row_chroma12);
}

let chroma_plane = MyImagePlane::new_bit_depth(data, stride, BitDepth::Depth12)?;
Expand Down
8 changes: 4 additions & 4 deletions testbench/tests/test_roundtrip_ffmpeg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const ENV_VAR_NAME: &str = "LESSAVC_SAVE_TEST_H264";

fn do_save_output() -> bool {
// Potentially do not delete temporary directory
let save_output = match std::env::var_os(ENV_VAR_NAME) {

match std::env::var_os(ENV_VAR_NAME) {
Some(v) => &v != "0",
None => false,
};
save_output
}
}

const WIDTHS: &[u32] = &[14, 16, 638, 640];
Expand Down Expand Up @@ -134,7 +134,7 @@ fn check_roundtrip_ffmpeg(pixfmt: PixFmt, widths: &[u32], heights: &[u32]) -> Re
let out_fd = std::fs::File::create(&full_output_name)?;
let mut my_h264_writer = less_avc::H264Writer::new(out_fd)?;

let input_yuv = generate_image(&pixfmt, *width, *height)?;
let input_yuv = generate_image(pixfmt, *width, *height)?;
let frame_view = input_yuv.view();
my_h264_writer.write(&frame_view)?;
input_yuv
Expand Down

0 comments on commit 19973cc

Please sign in to comment.