7
7
// Media Patent License 1.0 was not distributed with this source code in the
8
8
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
9
9
10
+ use std:: marker:: PhantomData ;
10
11
use std:: sync:: Arc ;
11
12
12
13
use libfuzzer_sys:: arbitrary:: { Arbitrary , Error , Unstructured } ;
@@ -295,7 +296,7 @@ pub fn fuzz_encode(arbitrary: ArbitraryEncoder) {
295
296
}
296
297
297
298
#[ derive( Debug ) ]
298
- pub struct DecodeTestParameters {
299
+ pub struct DecodeTestParameters < T : Pixel > {
299
300
w : usize ,
300
301
h : usize ,
301
302
speed : usize ,
@@ -312,9 +313,10 @@ pub struct DecodeTestParameters {
312
313
tile_cols_log2 : usize ,
313
314
tile_rows_log2 : usize ,
314
315
still_picture : bool ,
316
+ pixel : PhantomData < T > ,
315
317
}
316
318
317
- impl Arbitrary for DecodeTestParameters {
319
+ impl < T : Pixel > Arbitrary for DecodeTestParameters < T > {
318
320
fn arbitrary ( u : & mut Unstructured < ' _ > ) -> Result < Self , Error > {
319
321
let mut p = Self {
320
322
w : u. int_in_range ( 16 ..=16 + 255 ) ?,
@@ -338,7 +340,11 @@ impl Arbitrary for DecodeTestParameters {
338
340
tile_cols_log2 : u. int_in_range ( 0 ..=2 ) ?,
339
341
tile_rows_log2 : u. int_in_range ( 0 ..=2 ) ?,
340
342
still_picture : bool:: arbitrary ( u) ?,
343
+ pixel : PhantomData ,
341
344
} ;
345
+ if matches ! ( T :: type_enum( ) , PixelType :: U16 ) {
346
+ p. bit_depth = * u. choose ( & [ 8 , 10 , 12 ] ) ?;
347
+ }
342
348
if !p. low_latency {
343
349
p. switch_frame_interval = 0 ;
344
350
}
@@ -350,10 +356,10 @@ impl Arbitrary for DecodeTestParameters {
350
356
}
351
357
352
358
#[ cfg( feature = "decode_test_dav1d" ) ]
353
- pub fn fuzz_encode_decode ( p : DecodeTestParameters ) {
359
+ pub fn fuzz_encode_decode < T : Pixel > ( p : DecodeTestParameters < T > ) {
354
360
use crate :: test_encode_decode:: * ;
355
361
356
- let mut dec = get_decoder :: < u8 > ( "dav1d" , p. w , p. h ) ;
362
+ let mut dec = get_decoder :: < T > ( "dav1d" , p. w , p. h ) ;
357
363
dec. encode_decode (
358
364
p. w ,
359
365
p. h ,
0 commit comments