color-management: parametrize bt1886
This commit is contained in:
parent
c37567f1cd
commit
ef1727a186
8 changed files with 189 additions and 85 deletions
|
|
@ -21,7 +21,7 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::ordered_float::F64,
|
||||
utils::ordered_float::{F32, F64},
|
||||
wire::{
|
||||
WpImageDescriptionCreatorParamsV1Id,
|
||||
wp_image_description_creator_params_v1::{
|
||||
|
|
@ -53,14 +53,14 @@ impl WpImageDescriptionCreatorParamsV1RequestHandler for WpImageDescriptionCreat
|
|||
type Error = WpImageDescriptionCreatorParamsV1Error;
|
||||
|
||||
fn create(&self, req: Create, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let Some(eotf) = self.tf.get() else {
|
||||
let Some(mut eotf) = self.tf.get() else {
|
||||
return Err(WpImageDescriptionCreatorParamsV1Error::TfNotSet);
|
||||
};
|
||||
let Some((named_primaries, primaries)) = self.primaries.get() else {
|
||||
return Err(WpImageDescriptionCreatorParamsV1Error::PrimariesNotSet);
|
||||
};
|
||||
let default_luminance = match eotf {
|
||||
Eotf::Bt1886 => Luminance::BT1886,
|
||||
Eotf::Bt1886 { .. } => Luminance::BT1886,
|
||||
Eotf::St2084Pq => Luminance::ST2084_PQ,
|
||||
_ => Luminance::SRGB,
|
||||
};
|
||||
|
|
@ -71,6 +71,13 @@ impl WpImageDescriptionCreatorParamsV1RequestHandler for WpImageDescriptionCreat
|
|||
if luminance.max.0 <= luminance.min.0 || luminance.white.0 <= luminance.min.0 {
|
||||
return Err(WpImageDescriptionCreatorParamsV1Error::MinLuminanceTooLow);
|
||||
}
|
||||
if let Eotf::Bt1886(c) = &mut eotf {
|
||||
if luminance.min.0 == 0.0 {
|
||||
eotf = Eotf::Gamma24;
|
||||
} else {
|
||||
c.0 = (luminance.min.0 / luminance.max.0) as f32;
|
||||
}
|
||||
}
|
||||
let target_primaries = self.mastering_primaries.get().unwrap_or(primaries);
|
||||
let target_luminance = self
|
||||
.mastering_luminance
|
||||
|
|
@ -102,7 +109,7 @@ impl WpImageDescriptionCreatorParamsV1RequestHandler for WpImageDescriptionCreat
|
|||
|
||||
fn set_tf_named(&self, req: SetTfNamed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let tf = match req.tf {
|
||||
TRANSFER_FUNCTION_BT1886 => Eotf::Bt1886,
|
||||
TRANSFER_FUNCTION_BT1886 => Eotf::Bt1886(F32(0.0)),
|
||||
TRANSFER_FUNCTION_GAMMA22 => Eotf::Gamma22,
|
||||
TRANSFER_FUNCTION_GAMMA28 => Eotf::Gamma28,
|
||||
TRANSFER_FUNCTION_ST240 => Eotf::St240,
|
||||
|
|
|
|||
|
|
@ -36,8 +36,12 @@ impl WpImageDescriptionInfoV1 {
|
|||
let tf = match d.eotf {
|
||||
Eotf::Linear => TRANSFER_FUNCTION_EXT_LINEAR,
|
||||
Eotf::St2084Pq => TRANSFER_FUNCTION_ST2084_PQ,
|
||||
Eotf::Bt1886 => TRANSFER_FUNCTION_BT1886,
|
||||
Eotf::Bt1886 { .. } => TRANSFER_FUNCTION_BT1886,
|
||||
Eotf::Gamma22 => TRANSFER_FUNCTION_GAMMA22,
|
||||
Eotf::Gamma24 => {
|
||||
self.send_tf_power(EotfPow::GAMMA24);
|
||||
break 'tf;
|
||||
}
|
||||
Eotf::Gamma28 => TRANSFER_FUNCTION_GAMMA28,
|
||||
Eotf::St240 => TRANSFER_FUNCTION_ST240,
|
||||
Eotf::Log100 => TRANSFER_FUNCTION_LOG_100,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue