@@ -32,11 +32,21 @@ pub use crate::tiling::TilingInfo;
32
32
#[ non_exhaustive]
33
33
pub enum InvalidConfig {
34
34
/// The width is invalid.
35
- #[ error( "invalid width {0} (expected >= 16, <= 65535)" ) ]
36
- InvalidWidth ( usize ) ,
35
+ #[ error( "invalid width {0} (expected >= 16, <= {max})" ) ]
36
+ InvalidWidth {
37
+ /// The actual value.
38
+ actual : usize ,
39
+ /// The maximal supported value.
40
+ max : usize ,
41
+ } ,
37
42
/// The height is invalid.
38
- #[ error( "invalid height {0} (expected >= 16, <= 65535)" ) ]
39
- InvalidHeight ( usize ) ,
43
+ #[ error( "invalid height {0} (expected >= 16, <= {max})" ) ]
44
+ InvalidHeight {
45
+ /// The actual value.
46
+ actual : usize ,
47
+ /// The maximal supported value.
48
+ max : usize ,
49
+ } ,
40
50
/// Aspect ratio numerator is invalid.
41
51
#[ error( "invalid aspect ratio numerator {0} (expected > 0)" ) ]
42
52
InvalidAspectRatioNum ( usize ) ,
@@ -285,14 +295,22 @@ impl Config {
285
295
if ( config. still_picture && config. width < 1 )
286
296
|| ( !config. still_picture && config. width < 16 )
287
297
|| config. width > u16:: max_value ( ) as usize
298
+ || ( config. max_width != 0 && config. width > config. max_width )
288
299
{
289
- return Err ( InvalidWidth ( config. width ) ) ;
300
+ return Err ( InvalidWidth {
301
+ actual : config. width ,
302
+ max : if config. max_width != 0 { config. max_width } else { u16:: max_value ( ) as usize } ,
303
+ } ) ;
290
304
}
291
305
if ( config. still_picture && config. height < 1 )
292
306
|| ( !config. still_picture && config. height < 16 )
293
307
|| config. height > u16:: max_value ( ) as usize
308
+ || ( config. max_height != 0 && config. height > config. max_height )
294
309
{
295
- return Err ( InvalidHeight ( config. height ) ) ;
310
+ return Err ( InvalidHeight {
311
+ actual : config. height ,
312
+ max : if config. max_height != 0 { config. max_height } else { u16:: max_value ( ) as usize } ,
313
+ } ) ;
296
314
}
297
315
298
316
if config. sample_aspect_ratio . num == 0 {
@@ -313,12 +331,6 @@ impl Config {
313
331
if render_height == 0 || render_height > u16:: max_value ( ) as usize {
314
332
return Err ( InvalidRenderHeight ( render_height) ) ;
315
333
}
316
- if config. max_width != 0 && config. width > config. max_width {
317
- return Err ( InvalidWidth ( config. width ) ) ;
318
- }
319
- if config. max_height != 0 && config. height > config. max_height {
320
- return Err ( InvalidHeight ( config. height ) ) ;
321
- }
322
334
323
335
if config. rdo_lookahead_frames > MAX_RDO_LOOKAHEAD_FRAMES
324
336
|| config. rdo_lookahead_frames < 1
0 commit comments