@@ -15,11 +15,12 @@ pub fn ycbcr_to_bgra(input: YCbCrBuffer<'_>, mut output: &mut [u8]) -> io::Resul
15
15
Ok ( ( ) )
16
16
}
17
17
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 )
19
19
where
20
- I : IntoIterator < Item = & ' a [ u8 ] > ,
20
+ I : ExactSizeIterator < Item = & ' a [ u8 ] > ,
21
21
C : Fn ( & [ u8 ] ) -> Rgb ,
22
22
{
23
+ assert ! ( input. len( ) >= HINT ) ;
23
24
for ( i, pixel) in input. into_iter ( ) . enumerate ( ) {
24
25
let pixel = YCbCr :: from ( conv ( pixel) ) ;
25
26
@@ -85,7 +86,7 @@ pub fn to_ycbcr(
85
86
let bpp = format. bytes_per_pixel ( ) as usize ;
86
87
87
88
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) ;
89
90
input = & input[ stride..] ;
90
91
y = & mut y[ width..] ;
91
92
cb = & mut cb[ width..] ;
@@ -144,6 +145,12 @@ impl<'a> Iterator for TileIterator<'a> {
144
145
}
145
146
}
146
147
148
+ impl ExactSizeIterator for TileIterator < ' _ > {
149
+ fn len ( & self ) -> usize {
150
+ 64 * 64
151
+ }
152
+ }
153
+
147
154
#[ allow( clippy:: too_many_arguments) ]
148
155
pub fn to_64x64_ycbcr_tile (
149
156
input : & [ u8 ] ,
@@ -162,7 +169,7 @@ pub fn to_64x64_ycbcr_tile(
162
169
let bpp = format. bytes_per_pixel ( ) as usize ;
163
170
164
171
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) ;
166
173
}
167
174
168
175
/// Convert a 16-bit RDP color to RGB representation. Input value should be represented in
0 commit comments