From 1c8ea8e998b890299c52ece172011f2692c3d0c1 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov Date: Thu, 11 Apr 2024 19:45:31 +0200 Subject: [PATCH] fix(codecs): updated avif decoder to new api --- src/codecs/avif/decoder/mod.rs | 5 ++--- src/codecs/avif/decoder/tests.rs | 13 ++++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/codecs/avif/decoder/mod.rs b/src/codecs/avif/decoder/mod.rs index c9ee2607..c39e0e57 100644 --- a/src/codecs/avif/decoder/mod.rs +++ b/src/codecs/avif/decoder/mod.rs @@ -1,6 +1,6 @@ use std::{io::Read, marker::PhantomData}; -use zune_core::{bytestream::ZReaderTrait, colorspace::ColorSpace}; +use zune_core::colorspace::ColorSpace; use zune_image::{errors::ImageErrors, image::Image, traits::DecoderTrait}; /// A AVIF decoder @@ -24,10 +24,9 @@ impl AvifDecoder { } } -impl DecoderTrait for AvifDecoder +impl DecoderTrait for AvifDecoder where R: Read, - T: ZReaderTrait, { fn decode(&mut self) -> Result { let img = libavif::decode_rgb(&self.inner) diff --git a/src/codecs/avif/decoder/tests.rs b/src/codecs/avif/decoder/tests.rs index 7e132dea..cc0cc332 100644 --- a/src/codecs/avif/decoder/tests.rs +++ b/src/codecs/avif/decoder/tests.rs @@ -1,19 +1,14 @@ -use std::fs::read; - -use zune_core::bytestream::ZByteReader; +use std::fs::File; use super::*; #[test] fn decode() { - let file_content = read("tests/files/avif/f1t.avif").unwrap(); - - let reader = ZByteReader::new(file_content); + let file_content = File::open("tests/files/avif/f1t.avif").unwrap(); - let mut decoder = AvifDecoder::try_new(reader).unwrap(); + let mut decoder = AvifDecoder::try_new(file_content).unwrap(); - let img = - >> as DecoderTrait>>::decode(&mut decoder).unwrap(); + let img = Image::from_decoder(decoder).unwrap(); assert_eq!(img.dimensions(), (48, 80)); assert_eq!(img.colorspace(), ColorSpace::RGBA);