@@ -15,11 +15,12 @@ pub fn ycbcr_to_bgra(input: YCbCrBuffer<'_>, mut output: &mut [u8]) -> io::Resul
1515 Ok ( ( ) )
1616}
1717
18- fn iter_to_ycbcr < ' a , I , C > ( input : I , y : & mut [ i16 ] , cb : & mut [ i16 ] , cr : & mut [ i16 ] , conv : C )
18+ fn iter_to_ycbcr < ' a , const HINT : usize , I , C > ( input : I , y : & mut [ i16 ] , cb : & mut [ i16 ] , cr : & mut [ i16 ] , conv : C )
1919where
20- I : IntoIterator < Item = & ' a [ u8 ] > ,
20+ I : ExactSizeIterator < Item = & ' a [ u8 ] > ,
2121 C : Fn ( & [ u8 ] ) -> Rgb ,
2222{
23+ assert ! ( input. len( ) >= HINT ) ;
2324 for ( i, pixel) in input. into_iter ( ) . enumerate ( ) {
2425 let pixel = YCbCr :: from ( conv ( pixel) ) ;
2526
@@ -85,7 +86,7 @@ pub fn to_ycbcr(
8586 let bpp = format. bytes_per_pixel ( ) as usize ;
8687
8788 for _ in 0 ..height {
88- iter_to_ycbcr ( input[ ..width * bpp] . chunks_exact ( bpp) , y, cb, cr, to_rgb) ;
89+ iter_to_ycbcr :: < 1 , _ , _ > ( input[ ..width * bpp] . chunks_exact ( bpp) , y, cb, cr, to_rgb) ;
8990 input = & input[ stride..] ;
9091 y = & mut y[ width..] ;
9192 cb = & mut cb[ width..] ;
@@ -144,6 +145,12 @@ impl<'a> Iterator for TileIterator<'a> {
144145 }
145146}
146147
148+ impl ExactSizeIterator for TileIterator < ' _ > {
149+ fn len ( & self ) -> usize {
150+ 64 * 64
151+ }
152+ }
153+
147154#[ allow( clippy:: too_many_arguments) ]
148155pub fn to_64x64_ycbcr_tile (
149156 input : & [ u8 ] ,
@@ -162,7 +169,7 @@ pub fn to_64x64_ycbcr_tile(
162169 let bpp = format. bytes_per_pixel ( ) as usize ;
163170
164171 let input = TileIterator :: new ( input, width, height, stride, bpp) ;
165- iter_to_ycbcr ( input, y, cb, cr, to_rgb) ;
172+ iter_to_ycbcr :: < 4096 , _ , _ > ( input, y, cb, cr, to_rgb) ;
166173}
167174
168175/// Convert a 16-bit RDP color to RGB representation. Input value should be represented in
0 commit comments