@@ -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 {actual} (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 {actual} (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,30 @@ 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 {
303
+ config. max_width
304
+ } else {
305
+ u16:: max_value ( ) as usize
306
+ } ,
307
+ } ) ;
290
308
}
291
309
if ( config. still_picture && config. height < 1 )
292
310
|| ( !config. still_picture && config. height < 16 )
293
311
|| config. height > u16:: max_value ( ) as usize
312
+ || ( config. max_height != 0 && config. height > config. max_height )
294
313
{
295
- return Err ( InvalidHeight ( config. height ) ) ;
314
+ return Err ( InvalidHeight {
315
+ actual : config. height ,
316
+ max : if config. max_height != 0 {
317
+ config. max_height
318
+ } else {
319
+ u16:: max_value ( ) as usize
320
+ } ,
321
+ } ) ;
296
322
}
297
323
298
324
if config. sample_aspect_ratio . num == 0 {
@@ -313,12 +339,6 @@ impl Config {
313
339
if render_height == 0 || render_height > u16:: max_value ( ) as usize {
314
340
return Err ( InvalidRenderHeight ( render_height) ) ;
315
341
}
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
342
323
343
if config. rdo_lookahead_frames > MAX_RDO_LOOKAHEAD_FRAMES
324
344
|| config. rdo_lookahead_frames < 1
0 commit comments