• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #[path = "./mod.rs"]
16 mod tests;
17 
18 use crabby_avif::reformat::rgb::*;
19 use tests::*;
20 
21 #[test_case::test_case("paris_identity.avif", "paris_icc_exif_xmp.png"; "lossless_identity")]
22 #[test_case::test_case("paris_ycgco_re.avif", "paris_icc_exif_xmp.png"; "lossless_ycgco_re")]
lossless(avif_file: &str, png_file: &str)23 fn lossless(avif_file: &str, png_file: &str) {
24     let mut decoder = get_decoder(avif_file);
25     assert!(decoder.parse().is_ok());
26     if !HAS_DECODER {
27         return;
28     }
29     assert!(decoder.next_image().is_ok());
30     let decoded = decoder.image().expect("image was none");
31     let mut rgb = Image::create_from_yuv(decoded);
32     rgb.depth = 8;
33     rgb.format = Format::Rgb;
34     assert!(rgb.allocate().is_ok());
35     assert!(rgb.convert_from_yuv(decoded).is_ok());
36     let source = decode_png(png_file);
37     assert_eq!(
38         source,
39         rgb.pixels
40             .as_ref()
41             .unwrap()
42             .slice(0, source.len() as u32)
43             .unwrap()
44     );
45 }
46