From 276aae3b531a37ecfb3452ea4062f0a008ab22f2 Mon Sep 17 00:00:00 2001 From: Thomas Daede Date: Wed, 1 Sep 2021 06:54:29 -0700 Subject: [PATCH] Support max_width/max_height options. --- src/api/config/encoder.rs | 2 +- src/api/config/mod.rs | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/api/config/encoder.rs b/src/api/config/encoder.rs index ef8ba5725a..85992cf263 100644 --- a/src/api/config/encoder.rs +++ b/src/api/config/encoder.rs @@ -221,7 +221,7 @@ impl EncoderConfig { // has the property that the scaled distortion of a 2Nx2N block is always // equal to the sum of the scaled distortions of the NxN sub-blocks it's // made of, this is a necessary property to be able to do RDO between - // multiple partition sizes properly. Unfortunately, when tx domains + // multiple partition sizes properly. Unfortunately, when tx domain // distortion is used, distortion is only known at the tx block level which // might be bigger than 8x8. So temporal RDO is always disabled in that case. !self.speed_settings.tx_domain_distortion diff --git a/src/api/config/mod.rs b/src/api/config/mod.rs index b0527eed32..b646e71d42 100644 --- a/src/api/config/mod.rs +++ b/src/api/config/mod.rs @@ -32,11 +32,21 @@ pub use crate::tiling::TilingInfo; #[non_exhaustive] pub enum InvalidConfig { /// The width is invalid. - #[error("invalid width {0} (expected >= 16, <= 65535)")] - InvalidWidth(usize), + #[error("invalid width {0} (expected >= 16, <= {max})")] + InvalidWidth { + /// The actual value. + actual: usize, + /// The maximal supported value. + max: usize, + }, /// The height is invalid. - #[error("invalid height {0} (expected >= 16, <= 65535)")] - InvalidHeight(usize), + #[error("invalid height {0} (expected >= 16, <= {max})")] + InvalidHeight { + /// The actual value. + actual: usize, + /// The maximal supported value. + max: usize, + }, /// Aspect ratio numerator is invalid. #[error("invalid aspect ratio numerator {0} (expected > 0)")] InvalidAspectRatioNum(usize), @@ -285,14 +295,22 @@ impl Config { if (config.still_picture && config.width < 1) || (!config.still_picture && config.width < 16) || config.width > u16::max_value() as usize + || (config.max_width != 0 && config.width > config.max_width) { - return Err(InvalidWidth(config.width)); + return Err(InvalidWidth { + actual: config.width, + max: if config.max_width != 0 { config.max_width } else { u16::max_value() as usize }, + }); } if (config.still_picture && config.height < 1) || (!config.still_picture && config.height < 16) || config.height > u16::max_value() as usize + || (config.max_height != 0 && config.height > config.max_height) { - return Err(InvalidHeight(config.height)); + return Err(InvalidHeight { + actual: config.height, + max: if config.max_height != 0 { config.max_height } else { u16::max_value() as usize }, + }); } if config.sample_aspect_ratio.num == 0 {