summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc')
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc42
1 files changed, 8 insertions, 34 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc b/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc
index 019d6125a2..b20fa751c1 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc
@@ -5,9 +5,7 @@
#include "lib/jxl/enc_butteraugli_comparator.h"
-#include <algorithm>
-#include <vector>
-
+#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_image_bundle.h"
namespace jxl {
@@ -24,9 +22,8 @@ Status JxlButteraugliComparator::SetReferenceImage(const ImageBundle& ref) {
/*pool=*/nullptr, &store, &ref_linear_srgb)) {
return false;
}
-
- comparator_.reset(
- new ButteraugliComparator(ref_linear_srgb->color(), params_));
+ JXL_ASSIGN_OR_RETURN(comparator_, ButteraugliComparator::Make(
+ ref_linear_srgb->color(), params_));
xsize_ = ref.xsize();
ysize_ = ref.ysize();
return true;
@@ -34,7 +31,8 @@ Status JxlButteraugliComparator::SetReferenceImage(const ImageBundle& ref) {
Status JxlButteraugliComparator::SetLinearReferenceImage(
const Image3F& linear) {
- comparator_.reset(new ButteraugliComparator(linear, params_));
+ JXL_ASSIGN_OR_RETURN(comparator_,
+ ButteraugliComparator::Make(linear, params_));
xsize_ = linear.xsize();
ysize_ = linear.ysize();
return true;
@@ -58,8 +56,9 @@ Status JxlButteraugliComparator::CompareWith(const ImageBundle& actual,
return false;
}
- ImageF temp_diffmap(xsize_, ysize_);
- comparator_->Diffmap(actual_linear_srgb->color(), temp_diffmap);
+ JXL_ASSIGN_OR_RETURN(ImageF temp_diffmap, ImageF::Create(xsize_, ysize_));
+ JXL_RETURN_IF_ERROR(
+ comparator_->Diffmap(actual_linear_srgb->color(), temp_diffmap));
if (score != nullptr) {
*score = ButteraugliScoreFromDiffmap(temp_diffmap, &params_);
@@ -79,29 +78,4 @@ float JxlButteraugliComparator::BadQualityScore() const {
return ButteraugliFuzzyInverse(0.5);
}
-float ButteraugliDistance(const ImageBundle& rgb0, const ImageBundle& rgb1,
- const ButteraugliParams& params,
- const JxlCmsInterface& cms, ImageF* distmap,
- ThreadPool* pool, bool ignore_alpha) {
- JxlButteraugliComparator comparator(params, cms);
- return ComputeScore(rgb0, rgb1, &comparator, cms, distmap, pool,
- ignore_alpha);
-}
-
-float ButteraugliDistance(const std::vector<ImageBundle>& frames0,
- const std::vector<ImageBundle>& frames1,
- const ButteraugliParams& params,
- const JxlCmsInterface& cms, ImageF* distmap,
- ThreadPool* pool) {
- JxlButteraugliComparator comparator(params, cms);
- JXL_ASSERT(frames0.size() == frames1.size());
- float max_dist = 0.0f;
- for (size_t i = 0; i < frames0.size(); ++i) {
- max_dist = std::max(
- max_dist,
- ComputeScore(frames0[i], frames1[i], &comparator, cms, distmap, pool));
- }
- return max_dist;
-}
-
} // namespace jxl