Skip to content

Commit

Permalink
correctly check brightness capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
erazortt committed Feb 12, 2024
1 parent 7ac41cf commit 103f8aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 0 additions & 6 deletions DoViBaker/AvisynthEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,13 @@ AVSValue __cdecl Create_RealDoViTonemap(
{
env->ThrowError("DoViTonemap: input must be planar RGB");
}

if (kneeOffset < 0.5 || kneeOffset > 2){
env->ThrowError("DoViTonemap: valid range of knee offset is [0.5; 2.0]");
}

if (targetMaxNits < 0 || targetMinNits < 0) {
env->ThrowError("DoViTonemap: target capabilities must be given explicitly");
}

if (targetMaxNits < targetMinNits || masterMaxNits < masterMinNits) {
env->ThrowError("DoViTonemap: values given are invalid");
}

switch (clip->GetVideoInfo().BitsPerComponent())
{
case 10: return new DoViTonemap<10>(clip, targetMaxNits, targetMinNits, masterMaxNits, masterMinNits, lumScale, kneeOffset, normalizeOutput, env); break;
Expand Down
11 changes: 8 additions & 3 deletions DoViBaker/DoViTonemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ DoViTonemap<signalBitDepth>::DoViTonemap(
if (targetMinPq * 2 > targetMaxPq) {
// prevent EETF tapering to fail from a too low value of the taper power
env->ThrowError("DoViTonemap: Value for 'targetMinNits' is too large to process");
return;
}
if (targetMaxPq < targetMinPq) {
env->ThrowError("DoViTonemap: target capabilities given are invalid");
}
if (masterMaxPq < masterMinPq) {
env->ThrowError("DoViTonemap: master capabilities given are invalid");
}

doviEetf = new DoViEetf<signalBitDepth>(kneeOffset, normalizeOutput);
Expand Down Expand Up @@ -79,12 +84,12 @@ PVideoFrame DoViTonemap<signalBitDepth>::GetFrame(int n, IScriptEnvironment* env
if (dynamicLumScale) {
if (env->propNumElements(env->getFramePropsRO(src), "_dovi_dynamic_luminosity_scale") > -1) {
scale = env->propGetFloat(env->getFramePropsRO(src), "_dovi_dynamic_luminosity_scale", 0, 0);
} else env->ThrowError("DoViTonemap: Expected frame property not available. Set 'lumSacle' explicitly.");
} else env->ThrowError("DoViTonemap: Expected frame property not available. Set 'lumScale' explicitly.");
}

if (maxPq != masterMaxPq || minPq != masterMinPq || std::abs(scale-lumScale)>0.001f) {
masterMinPq = minPq;
masterMaxPq = maxPq;
masterMinPq = minPq;
lumScale = scale;
doviEetf->generateEETF(
targetMaxPq,
Expand Down

0 comments on commit 103f8aa

Please sign in to comment.