Skip to content

Commit

Permalink
Clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
szabadka committed Jul 8, 2024
1 parent d9f5b7e commit f0f655d
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 69 deletions.
18 changes: 9 additions & 9 deletions lib/extras/butteraugli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1632,15 +1632,15 @@ HWY_AFTER_NAMESPACE();
#if HWY_ONCE
namespace jxl {

HWY_EXPORT(SeparateFrequencies); // Local function.
HWY_EXPORT(MaskPsychoImage); // Local function.
HWY_EXPORT(L2DiffAsymmetric); // Local function.
HWY_EXPORT(L2Diff); // Local function.
HWY_EXPORT(SetL2Diff); // Local function.
HWY_EXPORT(CombineChannelsToDiffmap); // Local function.
HWY_EXPORT(MaltaDiffMap); // Local function.
HWY_EXPORT(MaltaDiffMapLF); // Local function.
HWY_EXPORT(OpsinDynamicsImage); // Local function.
HWY_EXPORT(SeparateFrequencies); // Local function.
HWY_EXPORT(MaskPsychoImage); // Local function.
HWY_EXPORT(L2DiffAsymmetric); // Local function.
HWY_EXPORT(L2Diff); // Local function.
HWY_EXPORT(SetL2Diff); // Local function.
HWY_EXPORT(CombineChannelsToDiffmap); // Local function.
HWY_EXPORT(MaltaDiffMap); // Local function.
HWY_EXPORT(MaltaDiffMapLF); // Local function.
HWY_EXPORT(OpsinDynamicsImage); // Local function.
HWY_EXPORT(ButteraugliDiffmapInPlace); // Local function.

#if BUTTERAUGLI_ENABLE_CHECKS
Expand Down
2 changes: 1 addition & 1 deletion lib/extras/convolve_separable5.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <hwy/foreach_target.h>
#include <hwy/highway.h>

#include "lib/jxl/base/rect.h"
#include "lib/extras/convolve-inl.h"
#include "lib/jxl/base/rect.h"

HWY_BEFORE_NAMESPACE();
namespace jxl {
Expand Down
2 changes: 1 addition & 1 deletion lib/extras/convolve_slow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

#include "lib/jxl/base/rect.h"
#include "lib/extras/convolve-inl.h"
#include "lib/extras/convolve.h"
#include "lib/jxl/base/rect.h"

namespace jxl {

Expand Down
2 changes: 1 addition & 1 deletion lib/extras/jpegli_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#include "lib/extras/enc/jpg.h"
#include "lib/extras/metrics.h"
#include "lib/extras/packed_image.h"
#include "lib/extras/test_utils.h"
#include "lib/extras/test_image.h"
#include "lib/extras/test_utils.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/base/testing.h"
Expand Down
33 changes: 14 additions & 19 deletions lib/extras/metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

#include "lib/extras/metrics.h"

#include <jxl/cms.h>
#include <math.h>
#include <stdlib.h>

#include <atomic>
#include <limits>

#include <jxl/cms.h>

#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/extras/metrics.cc"
#include <hwy/foreach_target.h>
Expand Down Expand Up @@ -153,14 +152,14 @@ void ComputeSumOfSquares(const extras::PackedPixelFile& a,
float intensity_b = GetIntensityTarget(b, c_enc_b);

if (!c_enc_a.SameColorEncoding(c_desired)) {
JXL_CHECK(ApplyColorTransform(
c_enc_a, intensity_a, srgb0, nullptr, Rect(srgb0), c_desired, cms,
nullptr, &srgb0));
JXL_CHECK(ApplyColorTransform(c_enc_a, intensity_a, srgb0, nullptr,
Rect(srgb0), c_desired, cms, nullptr,
&srgb0));
}
if (!c_enc_b.SameColorEncoding(c_desired)) {
JXL_CHECK(ApplyColorTransform(
c_enc_b, intensity_b, srgb1, nullptr, Rect(srgb1), c_desired, cms,
nullptr, &srgb1));
JXL_CHECK(ApplyColorTransform(c_enc_b, intensity_b, srgb1, nullptr,
Rect(srgb1), c_desired, cms, nullptr,
&srgb1));
}

// TODO(veluca): SIMD.
Expand Down Expand Up @@ -204,8 +203,7 @@ namespace jxl {
namespace {
float ComputeButteraugli(const Image3F& ref, const Image3F& actual,
const ButteraugliParams& params,
const JxlCmsInterface& cms,
ImageF* distmap) {
const JxlCmsInterface& cms, ImageF* distmap) {
std::unique_ptr<ButteraugliComparator> comparator;
JXL_ASSIGN_OR_DIE(comparator, ButteraugliComparator::Make(ref, params));
JXL_ASSIGN_OR_DIE(ImageF temp_distmap,
Expand All @@ -222,9 +220,8 @@ float ComputeButteraugli(const Image3F& ref, const Image3F& actual,

float ButteraugliDistance(const extras::PackedPixelFile& a,
const extras::PackedPixelFile& b,
ButteraugliParams params,
ImageF* distmap, ThreadPool* pool,
bool ignore_alpha) {
ButteraugliParams params, ImageF* distmap,
ThreadPool* pool, bool ignore_alpha) {
if (a.xsize() != b.xsize() || a.ysize() != b.ysize()) {
fprintf(stderr, "Images must have the same size for butteraugli.");
return std::numeric_limits<float>::max();
Expand Down Expand Up @@ -252,14 +249,12 @@ float ButteraugliDistance(const extras::PackedPixelFile& a,
float intensity_b = GetIntensityTarget(b, c_enc_b);

if (!c_enc_a.SameColorEncoding(c_desired)) {
JXL_CHECK(ApplyColorTransform(
c_enc_a, intensity_a, rgb0, nullptr, Rect(rgb0), c_desired, cms, pool,
&rgb0));
JXL_CHECK(ApplyColorTransform(c_enc_a, intensity_a, rgb0, nullptr,
Rect(rgb0), c_desired, cms, pool, &rgb0));
}
if (!c_enc_b.SameColorEncoding(c_desired)) {
JXL_CHECK(ApplyColorTransform(
c_enc_b, intensity_b, rgb1, nullptr, Rect(rgb1), c_desired, cms, pool,
&rgb1));
JXL_CHECK(ApplyColorTransform(c_enc_b, intensity_b, rgb1, nullptr,
Rect(rgb1), c_desired, cms, pool, &rgb1));
}

return ComputeButteraugli(rgb0, rgb1, params, cms, distmap);
Expand Down
6 changes: 2 additions & 4 deletions lib/extras/metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
#ifndef LIB_EXTRAS_METRICS_H_
#define LIB_EXTRAS_METRICS_H_

#include <stdint.h>

#include <jxl/cms_interface.h>
#include <stdint.h>

#include "lib/extras/butteraugli.h"
#include "lib/extras/packed_image.h"
Expand All @@ -23,8 +22,7 @@ namespace jxl {
float ButteraugliDistance(const extras::PackedPixelFile& a,
const extras::PackedPixelFile& b,
ButteraugliParams params = ButteraugliParams(),
ImageF* distmap = nullptr,
ThreadPool* pool = nullptr,
ImageF* distmap = nullptr, ThreadPool* pool = nullptr,
bool ignore_alpha = false);

// Computes p-norm given the butteraugli distmap.
Expand Down
4 changes: 1 addition & 3 deletions lib/extras/packed_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,7 @@ class PackedPixelFile {
PackedMetadata metadata;
PackedPixelFile() { JxlEncoderInitBasicInfo(&info); };

size_t num_frames() const {
return frames.size();
}
size_t num_frames() const { return frames.size(); }
size_t xsize() const { return info.xsize; }
size_t ysize() const { return info.ysize; }
};
Expand Down
9 changes: 4 additions & 5 deletions lib/extras/packed_image_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

#include "lib/extras/packed_image_convert.h"

#include <cstdint>

#include <jxl/cms.h>
#include <jxl/color_encoding.h>
#include <jxl/types.h>

#include <cstdint>

#include "lib/extras/image_color_transform.h"
#include "lib/jxl/base/byte_order.h"
#include "lib/jxl/base/common.h"
Expand All @@ -29,7 +29,6 @@
#include <hwy/foreach_target.h>
#include <hwy/highway.h>


HWY_BEFORE_NAMESPACE();
namespace jxl {
namespace HWY_NAMESPACE {
Expand Down Expand Up @@ -458,8 +457,8 @@ Status ConvertPackedPixelFileToImage3F(const extras::PackedPixelFile& ppf,
const extras::PackedImage& img = ppf.frames[0].color;
size_t bits_per_sample =
ppf.input_bitdepth.type == JXL_BIT_DEPTH_FROM_PIXEL_FORMAT
? extras::PackedImage::BitsPerChannel(img.format.data_type)
: ppf.info.bits_per_sample;
? extras::PackedImage::BitsPerChannel(img.format.data_type)
: ppf.info.bits_per_sample;
for (size_t c = 0; c < ppf.info.num_color_channels; ++c) {
JXL_RETURN_IF_ERROR(ConvertFromExternal(
reinterpret_cast<const uint8_t*>(img.pixels()), img.pixels_size,
Expand Down
3 changes: 1 addition & 2 deletions lib/jxl/color_encoding_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

#include <array>
#include <cstdlib> // free
#include <hwy/base.h>
#include <ostream>
#include <string>
#include <utility>

#include <hwy/base.h>

#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/status.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/benchmark/benchmark_args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "lib/extras/dec/decode.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
#include "tools/benchmark/benchmark_codec_jpeg.h" // for AddCommand..
#include "tools/benchmark/benchmark_codec_jpeg.h" // for AddCommand..

namespace jpegxl {
namespace tools {
Expand Down
11 changes: 5 additions & 6 deletions tools/benchmark/benchmark_codec_jpeg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,21 @@
#include <string>
#include <vector>

#include "lib/extras/enc/encode.h"
#include "lib/jxl/base/status.h"
#include "tools/benchmark/benchmark_args.h"
#include "tools/benchmark/benchmark_codec.h"
#include "tools/speed_stats.h"

#include "lib/extras/dec/jpegli.h"
#include "lib/extras/dec/jpg.h"
#include "lib/extras/enc/encode.h"
#include "lib/extras/enc/jpegli.h"
#include "lib/extras/enc/jpg.h"
#include "lib/extras/enc/pnm.h"
#include "lib/extras/packed_image.h"
#include "lib/extras/time.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
#include "tools/benchmark/benchmark_args.h"
#include "tools/benchmark/benchmark_codec.h"
#include "tools/benchmark/benchmark_utils.h"
#include "tools/file_io.h"
#include "tools/speed_stats.h"
#include "tools/thread_pool_internal.h"

namespace jpegxl {
Expand Down
9 changes: 4 additions & 5 deletions tools/benchmark/benchmark_xl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ void DoCompress(const std::string& filename, const PackedPixelFile& ppf,
// TODO(szabadka) Support different intensity targets as well.
params.intensity_target = 80.0;

distance = ButteraugliDistance(ppf, ppf2, params, &distmap,
inner_pool, codec->IgnoreAlpha());
distance = ButteraugliDistance(ppf, ppf2, params, &distmap, inner_pool,
codec->IgnoreAlpha());
} else {
// TODO(veluca): re-upsample and compute proper distance.
distance = 1e+4f;
Expand Down Expand Up @@ -269,9 +269,8 @@ void DoCompress(const std::string& filename, const PackedPixelFile& ppf,
if (Args()->save_decompressed && valid) {
// TODO(szabadka): Handle Args()->mul_output
jxl::extras::EncodedImage encoded;
JXL_CHECK(
jxl::extras::Encoder::FromExtension(Args()->output_extension)->Encode(
ppf2, &encoded, inner_pool));
JXL_CHECK(jxl::extras::Encoder::FromExtension(Args()->output_extension)
->Encode(ppf2, &encoded, inner_pool));
JXL_CHECK(WriteFile(decompressed_fn, encoded.bitstreams[0]));
if (!skip_butteraugli) {
float good = Args()->heatmap_good > 0.0f
Expand Down
23 changes: 11 additions & 12 deletions tools/ssimulacra2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ const int kNumScales = 6;

void ToXYB(const ColorEncoding& c_current, float intensity_target,
const ImageF* black, jxl::ThreadPool* pool,
Image3F* JXL_RESTRICT image, const JxlCmsInterface& cms) {
Image3F* JXL_RESTRICT image, const JxlCmsInterface& cms) {
if (black) JXL_ASSERT(SameSize(*image, *black));
hwy::AlignedFreeUniquePtr<float[]> premul_absorb =
hwy::AllocateAligned<float>(jxl::MaxVectorSize() * 12);
jxl::ComputePremulAbsorb(intensity_target, premul_absorb.get());
const ColorEncoding& c_linear_srgb =
ColorEncoding::LinearSRGB(c_current.IsGray());
JXL_CHECK(jxl::ApplyColorTransform(
c_current, intensity_target, *image, black,
Rect(*image), c_linear_srgb, cms, pool, image));
JXL_CHECK(jxl::ApplyColorTransform(c_current, intensity_target, *image, black,
Rect(*image), c_linear_srgb, cms, pool,
image));
JXL_CHECK(RunOnPool(
pool, 0, static_cast<uint32_t>(image->ysize()), jxl::ThreadPool::NoInit,
[&](const uint32_t task, size_t /*thread*/) {
Expand Down Expand Up @@ -460,7 +460,6 @@ StatusOr<Msssim> ComputeSSIMULACRA2(const PackedPixelFile& orig,

if (orig.xsize() != distorted.xsize() || orig.ysize() != distorted.ysize()) {
return JXL_FAILURE("Images must have the same size for SSIMULACRA2.");

}
if (orig.info.num_color_channels != distorted.info.num_color_channels) {
return JXL_FAILURE("Grayscale vs RGB comparison not supported.");
Expand All @@ -486,22 +485,22 @@ StatusOr<Msssim> ComputeSSIMULACRA2(const PackedPixelFile& orig,
float intensity_dist = GetIntensityTarget(distorted, c_enc_dist);

if (!c_enc_orig.SameColorEncoding(c_desired)) {
JXL_CHECK(ApplyColorTransform(
c_enc_orig, intensity_orig, orig2, nullptr, Rect(orig2), c_desired, cms,
nullptr, &orig2));
JXL_CHECK(ApplyColorTransform(c_enc_orig, intensity_orig, orig2, nullptr,
Rect(orig2), c_desired, cms, nullptr,
&orig2));
}
if (!c_enc_dist.SameColorEncoding(c_desired)) {
JXL_CHECK(ApplyColorTransform(
c_enc_dist, intensity_dist, dist2, nullptr, Rect(dist2), c_desired, cms,
nullptr, &dist2));
JXL_CHECK(ApplyColorTransform(c_enc_dist, intensity_dist, dist2, nullptr,
Rect(dist2), c_desired, cms, nullptr,
&dist2));
}

JXL_ASSIGN_OR_RETURN(Image3F img1, Image3F::Create(xsize, ysize));
JXL_ASSIGN_OR_RETURN(Image3F img2, Image3F::Create(xsize, ysize));
jxl::CopyImageTo(orig2, &img1);
jxl::CopyImageTo(dist2, &img2);
ToXYB(c_desired, intensity_orig, nullptr, nullptr, &img1,
*JxlGetDefaultCms());
*JxlGetDefaultCms());
ToXYB(c_desired, intensity_dist, nullptr, nullptr, &img2,
*JxlGetDefaultCms());
MakePositiveXYB(img1);
Expand Down

0 comments on commit f0f655d

Please sign in to comment.