Skip to content

Commit

Permalink
butteraugli_main and benchmark_xl: higher default intensity target fo…
Browse files Browse the repository at this point in the history
…r HDR input (libjxl#3870)

(cherry picked from commit 42422b4)
  • Loading branch information
sboukortt authored and mo271 committed Nov 26, 2024
1 parent 69d1ed1 commit 7ccdcf8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
11 changes: 7 additions & 4 deletions tools/benchmark/benchmark_xl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,14 @@ Status DoCompress(const std::string& filename, const PackedPixelFile& ppf,
const ImageBundle& ib2 = ppf2_io.Main();
if (jxl::SameSize(ppf, ppf2)) {
ButteraugliParams params;
// Hack the default intensity target value to be 80.0, the intensity
// target of sRGB images and a more reasonable viewing default than
// JPEG XL file format's default.
// Hack the default intensity target value for SDR images to be 80.0, the
// intensity target of sRGB images and a more reasonable viewing default
// than JPEG XL file format's default.
// TODO(szabadka) Support different intensity targets as well.
params.intensity_target = 80.0;
const auto& transfer_function = ib1.c_current().Tf();
params.intensity_target = transfer_function.IsPQ() ? 10000.f
: transfer_function.IsHLG() ? 1000.f
: 80.f;

const JxlCmsInterface& cms = *JxlGetDefaultCms();
JxlButteraugliComparator comparator(params, cms);
Expand Down
14 changes: 11 additions & 3 deletions tools/butteraugli_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ Status RunButteraugli(const char* pathname1, const char* pathname2,
ButteraugliParams butteraugli_params;
butteraugli_params.hf_asymmetry = 1.0f;
butteraugli_params.xmul = 1.0f;
butteraugli_params.intensity_target = intensity_target;
if (intensity_target > 0) {
butteraugli_params.intensity_target = intensity_target;
} else {
const auto& transfer_function = io1.Main().c_current().Tf();
butteraugli_params.intensity_target = transfer_function.IsPQ() ? 10000.f
: transfer_function.IsHLG()
? 1000.f
: 80.f; // sRGB intensity target.
}
const JxlCmsInterface& cms = *JxlGetDefaultCms();
JxlButteraugliComparator comparator(butteraugli_params, cms);
float distance;
Expand Down Expand Up @@ -146,15 +154,15 @@ int main(int argc, char** argv) {
" without attached profiles (such as ppm or pfm) are interpreted"
" as nonlinear sRGB. The hint format is RGB_D65_SRG_Rel_Lin for"
" linear sRGB. Intensity target is viewing conditions screen nits"
", defaults to 80.\n",
", defaults to 80 for SDR input.\n",
argv[0]);
return 1;
}
std::string distmap;
std::string raw_distmap;
std::string colorspace;
double p = 3;
float intensity_target = 80.0; // sRGB intensity target.
float intensity_target = 0.f;
for (int i = 3; i < argc; i++) {
if (std::string(argv[i]) == "--distmap" && i + 1 < argc) {
distmap = argv[++i];
Expand Down

0 comments on commit 7ccdcf8

Please sign in to comment.