Bug 1892925 - Update libjxl to a741085a1dee343f143f5fdca3212ca13d66e401 r=saschanaz

Differential Revision: https://phabricator.services.mozilla.com/D208331
This commit is contained in:
Updatebot 2024-04-26 12:59:59 +00:00
parent 26ccb2231c
commit e6a437a6c2
202 changed files with 2059 additions and 1241 deletions

View file

@ -10,9 +10,9 @@ origin:
url: https://github.com/libjxl/libjxl
release: a5e4aa1fc1fe5bee252225a2616dccde7fd35da0 (2024-04-01T20:09:39Z).
release: a741085a1dee343f143f5fdca3212ca13d66e401 (2024-04-23T11:57:55Z).
revision: a5e4aa1fc1fe5bee252225a2616dccde7fd35da0
revision: a741085a1dee343f143f5fdca3212ca13d66e401
license: Apache-2.0

View file

@ -39,6 +39,7 @@ Alistair Barrow
Andrius Lukas Narbutas <andrius4669@gmail.com>
Aous Naman <aous@unsw.edu.au>
Artem Selishchev
Aryan Pingle <realaryanpingle@gmail.com>
Biswapriyo Nath <nathbappai@gmail.com>
CanadianBaconBoi <beamconnor@gmail.com>
Damiano Albani <damiano.albani@gmail.com>
@ -53,6 +54,7 @@ Dong Xu <xdong181@gmail.com>
estrogently <41487185+estrogently@users.noreply.github.com>
Even Rouault <even.rouault@spatialys.com>
Fred Brennan <copypaste@kittens.ph>
Gerhard Huber <support@pl32.com>
gi-man
Gilles Devillers (GilDev) <gildev@gmail.com>
Heiko Becker <heirecka@exherbo.org>

View file

@ -160,7 +160,7 @@ set(JPEGXL_ENABLE_AVX512_SPR false CACHE BOOL
"Build with AVX-512FP16 support (faster on CPUs that support it, but larger binary size).")
set(JPEGXL_ENABLE_AVX512_ZEN4 false CACHE BOOL
"Build with Zen4-optimized AVX512 support (faster on CPUs that support it, but larger binary size).")
set(JPEGXL_ENABLE_WASM_TRHEADS true CACHE BOOL
set(JPEGXL_ENABLE_WASM_THREADS true CACHE BOOL
"Builds WASM modules with threads support")
# Force system dependencies.
@ -211,10 +211,12 @@ if(JPEGXL_STATIC)
# Clang developers say that in case to use "static" we have to build stdlib
# ourselves; for real use case we don't care about stdlib, as it is "granted",
# so just linking all other libraries is fine.
if (NOT MSVC AND NOT APPLE)
if (NOT MSVC)
string(APPEND CMAKE_EXE_LINKER_FLAGS " -static")
endif()
if ((NOT WIN32 AND NOT APPLE) OR CYGWIN OR MINGW)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -static-libgcc -static-libstdc++")
endif()
endif() # JPEGXL_STATIC
@ -265,7 +267,7 @@ if(JPEGXL_STATIC)
endif()
endif() # JPEGXL_STATIC
if (EMSCRIPTEN AND JPEGXL_ENABLE_WASM_TRHEADS)
if (EMSCRIPTEN AND JPEGXL_ENABLE_WASM_THREADS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")

View file

@ -10,16 +10,16 @@
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#include <jxl/decode.h>
#include <jxl/decode_cxx.h>
#include <jxl/resizable_parallel_runner.h>
#include <jxl/resizable_parallel_runner_cxx.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <cinttypes> // PRIu64
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <vector>
bool WritePAM(const char* filename, const uint8_t* buffer, size_t w, size_t h) {

File diff suppressed because it is too large Load diff

View file

@ -8,11 +8,10 @@
// Decodes APNG images in memory.
#include <stdint.h>
#include <cstdint>
#include "lib/extras/dec/color_hints.h"
#include "lib/extras/packed_image.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"

View file

@ -203,12 +203,38 @@ Status ParseTransferFunction(Tokenizer* tokenizer, JxlColorEncoding* c) {
Status ParseDescription(const std::string& description, JxlColorEncoding* c) {
*c = {};
Tokenizer tokenizer(&description, '_');
JXL_RETURN_IF_ERROR(ParseColorSpace(&tokenizer, c));
JXL_RETURN_IF_ERROR(ParseWhitePoint(&tokenizer, c));
JXL_RETURN_IF_ERROR(ParsePrimaries(&tokenizer, c));
JXL_RETURN_IF_ERROR(ParseRenderingIntent(&tokenizer, c));
JXL_RETURN_IF_ERROR(ParseTransferFunction(&tokenizer, c));
if (description == "sRGB") {
c->color_space = JXL_COLOR_SPACE_RGB;
c->white_point = JXL_WHITE_POINT_D65;
c->primaries = JXL_PRIMARIES_SRGB;
c->transfer_function = JXL_TRANSFER_FUNCTION_SRGB;
c->rendering_intent = JXL_RENDERING_INTENT_PERCEPTUAL;
} else if (description == "DisplayP3") {
c->color_space = JXL_COLOR_SPACE_RGB;
c->white_point = JXL_WHITE_POINT_D65;
c->primaries = JXL_PRIMARIES_P3;
c->transfer_function = JXL_TRANSFER_FUNCTION_SRGB;
c->rendering_intent = JXL_RENDERING_INTENT_PERCEPTUAL;
} else if (description == "Rec2100PQ") {
c->color_space = JXL_COLOR_SPACE_RGB;
c->white_point = JXL_WHITE_POINT_D65;
c->primaries = JXL_PRIMARIES_2100;
c->transfer_function = JXL_TRANSFER_FUNCTION_PQ;
c->rendering_intent = JXL_RENDERING_INTENT_RELATIVE;
} else if (description == "Rec2100HLG") {
c->color_space = JXL_COLOR_SPACE_RGB;
c->white_point = JXL_WHITE_POINT_D65;
c->primaries = JXL_PRIMARIES_2100;
c->transfer_function = JXL_TRANSFER_FUNCTION_HLG;
c->rendering_intent = JXL_RENDERING_INTENT_RELATIVE;
} else {
Tokenizer tokenizer(&description, '_');
JXL_RETURN_IF_ERROR(ParseColorSpace(&tokenizer, c));
JXL_RETURN_IF_ERROR(ParseWhitePoint(&tokenizer, c));
JXL_RETURN_IF_ERROR(ParsePrimaries(&tokenizer, c));
JXL_RETURN_IF_ERROR(ParseRenderingIntent(&tokenizer, c));
JXL_RETURN_IF_ERROR(ParseTransferFunction(&tokenizer, c));
}
return true;
}

View file

@ -91,6 +91,15 @@ bool CanDecode(Codec codec) {
}
}
std::string ListOfDecodeCodecs() {
std::string list_of_codecs("JXL, PPM, PNM, PFM, PAM, PGX");
if (CanDecode(Codec::kPNG)) list_of_codecs.append(", PNG, APNG");
if (CanDecode(Codec::kGIF)) list_of_codecs.append(", GIF");
if (CanDecode(Codec::kJPG)) list_of_codecs.append(", JPEG");
if (CanDecode(Codec::kEXR)) list_of_codecs.append(", EXR");
return list_of_codecs;
}
Status DecodeBytes(const Span<const uint8_t> bytes,
const ColorHints& color_hints, extras::PackedPixelFile* ppf,
const SizeConstraints* constraints, Codec* orig_codec) {

View file

@ -38,6 +38,8 @@ enum class Codec : uint32_t {
bool CanDecode(Codec codec);
std::string ListOfDecodeCodecs();
// If and only if extension is ".pfm", *bits_per_sample is updated to 32 so
// that Encode() would encode to PFM instead of PPM.
Codec CodecFromPath(const std::string& path,

View file

@ -17,6 +17,7 @@
#include "lib/extras/size_constraints.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/sanitizers.h"
namespace jxl {

View file

@ -6,8 +6,7 @@
#include "lib/extras/dec/jpg.h"
#if JPEGXL_ENABLE_JPEG
#include <jpeglib.h>
#include <setjmp.h>
#include "lib/jxl/base/include_jpeglib.h" // NOLINT
#endif
#include <stdint.h>

View file

@ -10,7 +10,7 @@
#include <jxl/decode_cxx.h>
#include <jxl/types.h>
#include <cinttypes>
#include <cinttypes> // PRIu32
#include "lib/extras/common.h"
#include "lib/extras/dec/color_description.h"
@ -211,7 +211,7 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size,
return false;
}
uint32_t progression_index = 0;
bool codestream_done = accepted_formats.empty();
bool codestream_done = jpeg_bytes == nullptr && accepted_formats.empty();
BoxProcessor boxes(dec);
for (;;) {
JxlDecoderStatus status = JxlDecoderProcessInput(dec);

View file

@ -5,17 +5,17 @@
#include "lib/extras/dec/pnm.h"
#include <stdlib.h>
#include <string.h>
#include <jxl/encode.h>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <mutex>
#include <cstdlib>
#include <cstring>
#include "jxl/encode.h"
#include "lib/extras/size_constraints.h"
#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
namespace jxl {

View file

@ -134,5 +134,13 @@ std::unique_ptr<Encoder> Encoder::FromExtension(std::string extension) {
return nullptr;
}
std::string ListOfEncodeCodecs() {
std::string list_of_codecs("PPM, PNM, PFM, PAM, PGX");
if (GetAPNGEncoder()) list_of_codecs.append(", PNG, APNG");
if (GetJPEGEncoder()) list_of_codecs.append(", JPEG");
if (GetEXREncoder()) list_of_codecs.append(", EXR");
return list_of_codecs;
}
} // namespace extras
} // namespace jxl

View file

@ -82,6 +82,8 @@ class Encoder {
std::unordered_map<std::string, std::string> options_;
};
std::string ListOfEncodeCodecs();
} // namespace extras
} // namespace jxl

View file

@ -454,6 +454,10 @@ Status EncodeJpeg(const PackedPixelFile& ppf, const JpegSettings& jpeg_settings,
cinfo.comp_info[i].h_samp_factor = 1;
cinfo.comp_info[i].v_samp_factor = 1;
}
} else if (!jpeg_settings.xyb) {
// Default is no chroma subsampling.
cinfo.comp_info[0].h_samp_factor = 1;
cinfo.comp_info[0].v_samp_factor = 1;
}
jpegli_enable_adaptive_quantization(
&cinfo, TO_JXL_BOOL(jpeg_settings.use_adaptive_quantization));

View file

@ -6,18 +6,15 @@
#include "lib/extras/enc/jpg.h"
#if JPEGXL_ENABLE_JPEG
#include <jpeglib.h>
#include <setjmp.h>
#include "lib/jxl/base/include_jpeglib.h" // NOLINT
#endif
#include <stdint.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <fstream>
#include <iterator>
#include <memory>
#include <numeric>
#include <sstream>
#include <utility>
#include <vector>

View file

@ -255,7 +255,7 @@ TEST(JpegliTest, JpegliHDRRoundtripTest) {
std::string testimage = "jxl/hdr_room.png";
PackedPixelFile ppf_in;
ASSERT_TRUE(ReadTestImage(testimage, &ppf_in));
EXPECT_EQ("RGB_D65_202_Rel_HLG", Description(ppf_in.color_encoding));
EXPECT_EQ("Rec2100HLG", Description(ppf_in.color_encoding));
EXPECT_EQ(16, ppf_in.info.bits_per_sample);
std::vector<uint8_t> compressed;

View file

@ -16,6 +16,7 @@
#include <hwy/highway.h>
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
HWY_BEFORE_NAMESPACE();

View file

@ -11,6 +11,7 @@
#include <cstdint>
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/dec_external_image.h"

View file

@ -14,8 +14,6 @@
#ifndef JXL_COLOR_ENCODING_H_
#define JXL_COLOR_ENCODING_H_
#include <stdint.h>
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

View file

@ -26,11 +26,16 @@ using hwy::HWY_NAMESPACE::Mul;
using hwy::HWY_NAMESPACE::MulAdd;
using hwy::HWY_NAMESPACE::Sub;
void YCbCrToRGB(float* row[kMaxComponents], size_t xsize) {
template <int kRed, int kGreen, int kBlue, int kAlpha>
void YCbCrToExtRGB(float* row[kMaxComponents], size_t xsize) {
const HWY_CAPPED(float, 8) df;
float* JXL_RESTRICT row0 = row[0];
float* JXL_RESTRICT row1 = row[1];
float* JXL_RESTRICT row2 = row[2];
const float* row_y = row[0];
const float* row_cb = row[1];
const float* row_cr = row[2];
float* row_r = row[kRed];
float* row_g = row[kGreen];
float* row_b = row[kBlue];
float* row_a = row[kAlpha];
// Full-range BT.601 as defined by JFIF Clause 7:
// https://www.itu.int/rec/T-REC-T.871-201105-I/en
@ -38,20 +43,48 @@ void YCbCrToRGB(float* row[kMaxComponents], size_t xsize) {
const auto cgcb = Set(df, -0.114f * 1.772f / 0.587f);
const auto cgcr = Set(df, -0.299f * 1.402f / 0.587f);
const auto cbcb = Set(df, 1.772f);
const auto alpha_opaque = Set(df, 127.0f / 255.0f);
for (size_t x = 0; x < xsize; x += Lanes(df)) {
const auto y_vec = Load(df, row0 + x);
const auto cb_vec = Load(df, row1 + x);
const auto cr_vec = Load(df, row2 + x);
const auto y_vec = Load(df, row_y + x);
const auto cb_vec = Load(df, row_cb + x);
const auto cr_vec = Load(df, row_cr + x);
const auto r_vec = MulAdd(crcr, cr_vec, y_vec);
const auto g_vec = MulAdd(cgcr, cr_vec, MulAdd(cgcb, cb_vec, y_vec));
const auto b_vec = MulAdd(cbcb, cb_vec, y_vec);
Store(r_vec, df, row0 + x);
Store(g_vec, df, row1 + x);
Store(b_vec, df, row2 + x);
Store(r_vec, df, row_r + x);
Store(g_vec, df, row_g + x);
Store(b_vec, df, row_b + x);
if (kAlpha >= 0) {
Store(alpha_opaque, df, row_a + x);
}
}
}
void YCbCrToRGB(float* row[kMaxComponents], size_t xsize) {
YCbCrToExtRGB<0, 1, 2, -1>(row, xsize);
}
void YCbCrToBGR(float* row[kMaxComponents], size_t xsize) {
YCbCrToExtRGB<2, 1, 0, -1>(row, xsize);
}
void YCbCrToRGBA(float* row[kMaxComponents], size_t xsize) {
YCbCrToExtRGB<0, 1, 2, 3>(row, xsize);
}
void YCbCrToBGRA(float* row[kMaxComponents], size_t xsize) {
YCbCrToExtRGB<2, 1, 0, 3>(row, xsize);
}
void YCbCrToARGB(float* row[kMaxComponents], size_t xsize) {
YCbCrToExtRGB<1, 2, 3, 0>(row, xsize);
}
void YCbCrToABGR(float* row[kMaxComponents], size_t xsize) {
YCbCrToExtRGB<3, 2, 1, 0>(row, xsize);
}
void YCCKToCMYK(float* row[kMaxComponents], size_t xsize) {
const HWY_CAPPED(float, 8) df;
float* JXL_RESTRICT row0 = row[0];
@ -66,11 +99,15 @@ void YCCKToCMYK(float* row[kMaxComponents], size_t xsize) {
}
}
void RGBToYCbCr(float* row[kMaxComponents], size_t xsize) {
template <int kRed, int kGreen, int kBlue>
void ExtRGBToYCbCr(float* row[kMaxComponents], size_t xsize) {
const HWY_CAPPED(float, 8) df;
float* JXL_RESTRICT row0 = row[0];
float* JXL_RESTRICT row1 = row[1];
float* JXL_RESTRICT row2 = row[2];
const float* row_r = row[kRed];
const float* row_g = row[kGreen];
const float* row_b = row[kBlue];
float* row_y = row[0];
float* row_cb = row[1];
float* row_cr = row[2];
// Full-range BT.601 as defined by JFIF Clause 7:
// https://www.itu.int/rec/T-REC-T.871-201105-I/en
const auto c128 = Set(df, 128.0f);
@ -85,9 +122,9 @@ void RGBToYCbCr(float* row[kMaxComponents], size_t xsize) {
const auto kNormB = Div(Set(df, 1.0f), (Add(kR, Add(kG, kAmpB))));
for (size_t x = 0; x < xsize; x += Lanes(df)) {
const auto r = Load(df, row0 + x);
const auto g = Load(df, row1 + x);
const auto b = Load(df, row2 + x);
const auto r = Load(df, row_r + x);
const auto g = Load(df, row_g + x);
const auto b = Load(df, row_b + x);
const auto r_base = Mul(r, kR);
const auto r_diff = Mul(r, kDiffR);
const auto g_base = Mul(g, kG);
@ -96,12 +133,28 @@ void RGBToYCbCr(float* row[kMaxComponents], size_t xsize) {
const auto y_base = Add(r_base, Add(g_base, b_base));
const auto cb_vec = MulAdd(Sub(b_diff, y_base), kNormB, c128);
const auto cr_vec = MulAdd(Sub(r_diff, y_base), kNormR, c128);
Store(y_base, df, row0 + x);
Store(cb_vec, df, row1 + x);
Store(cr_vec, df, row2 + x);
Store(y_base, df, row_y + x);
Store(cb_vec, df, row_cb + x);
Store(cr_vec, df, row_cr + x);
}
}
void RGBToYCbCr(float* row[kMaxComponents], size_t xsize) {
ExtRGBToYCbCr<0, 1, 2>(row, xsize);
}
void BGRToYCbCr(float* row[kMaxComponents], size_t xsize) {
ExtRGBToYCbCr<2, 1, 0>(row, xsize);
}
void ARGBToYCbCr(float* row[kMaxComponents], size_t xsize) {
ExtRGBToYCbCr<1, 2, 3>(row, xsize);
}
void ABGRToYCbCr(float* row[kMaxComponents], size_t xsize) {
ExtRGBToYCbCr<3, 2, 1>(row, xsize);
}
void CMYKToYCCK(float* row[kMaxComponents], size_t xsize) {
const HWY_CAPPED(float, 8) df;
float* JXL_RESTRICT row0 = row[0];
@ -127,7 +180,15 @@ namespace jpegli {
HWY_EXPORT(CMYKToYCCK);
HWY_EXPORT(YCCKToCMYK);
HWY_EXPORT(YCbCrToRGB);
HWY_EXPORT(YCbCrToBGR);
HWY_EXPORT(YCbCrToRGBA);
HWY_EXPORT(YCbCrToBGRA);
HWY_EXPORT(YCbCrToARGB);
HWY_EXPORT(YCbCrToABGR);
HWY_EXPORT(RGBToYCbCr);
HWY_EXPORT(BGRToYCbCr);
HWY_EXPORT(ARGBToYCbCr);
HWY_EXPORT(ABGRToYCbCr);
bool CheckColorSpaceComponents(int num_components, J_COLOR_SPACE colorspace) {
switch (colorspace) {
@ -164,16 +225,73 @@ bool CheckColorSpaceComponents(int num_components, J_COLOR_SPACE colorspace) {
void NullTransform(float* row[kMaxComponents], size_t len) {}
void FillAlpha(float* row, size_t len) {
static const float kAlpha = 127.0f / 255.0f;
for (size_t i = 0; i < len; ++i) {
row[i] = kAlpha;
}
}
// Works for BGR as well.
void GrayscaleToRGB(float* row[kMaxComponents], size_t len) {
memcpy(row[1], row[0], len * sizeof(row[1][0]));
memcpy(row[2], row[0], len * sizeof(row[2][0]));
}
// Works for BGRA as well.
void GrayscaleToRGBA(float* row[kMaxComponents], size_t len) {
memcpy(row[1], row[0], len * sizeof(row[1][0]));
memcpy(row[2], row[0], len * sizeof(row[2][0]));
FillAlpha(row[3], len);
}
// Works for ABGR as well.
void GrayscaleToARGB(float* row[kMaxComponents], size_t len) {
memcpy(row[1], row[0], len * sizeof(row[1][0]));
memcpy(row[2], row[0], len * sizeof(row[2][0]));
memcpy(row[3], row[0], len * sizeof(row[1][0]));
FillAlpha(row[0], len);
}
void GrayscaleToYCbCr(float* row[kMaxComponents], size_t len) {
memset(row[1], 0, len * sizeof(row[1][0]));
memset(row[2], 0, len * sizeof(row[2][0]));
}
void RGBToBGR(float* row[kMaxComponents], size_t len) {
for (size_t i = 0; i < len; ++i) {
std::swap(row[0][i], row[2][i]);
}
}
void RGBToRGBA(float* row[kMaxComponents], size_t len) {
FillAlpha(row[3], len);
}
void RGBToBGRA(float* row[kMaxComponents], size_t len) {
static const float kAlpha = 127.0f / 255.0f;
for (size_t i = 0; i < len; ++i) {
std::swap(row[0][i], row[2][i]);
row[3][i] = kAlpha;
}
}
void RGBToARGB(float* row[kMaxComponents], size_t len) {
memcpy(row[3], row[2], len * sizeof(row[1][0]));
memcpy(row[2], row[1], len * sizeof(row[2][0]));
memcpy(row[1], row[0], len * sizeof(row[1][0]));
FillAlpha(row[0], len);
}
void RGBToABGR(float* row[kMaxComponents], size_t len) {
static const float kAlpha = 127.0f / 255.0f;
for (size_t i = 0; i < len; ++i) {
std::swap(row[1][i], row[2][i]);
row[3][i] = row[0][i];
row[0][i] = kAlpha;
}
}
void ChooseColorTransform(j_compress_ptr cinfo) {
jpeg_comp_master* m = cinfo->master;
if (!CheckColorSpaceComponents(cinfo->input_components,
@ -226,6 +344,43 @@ void ChooseColorTransform(j_compress_ptr cinfo) {
}
}
if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||
cinfo->jpeg_color_space == JCS_YCbCr) {
switch (cinfo->in_color_space) {
#ifdef JCS_EXTENSIONS
case JCS_EXT_RGB:
case JCS_EXT_RGBX:
m->color_transform = HWY_DYNAMIC_DISPATCH(RGBToYCbCr);
break;
case JCS_EXT_BGR:
case JCS_EXT_BGRX:
m->color_transform = HWY_DYNAMIC_DISPATCH(BGRToYCbCr);
break;
case JCS_EXT_XRGB:
m->color_transform = HWY_DYNAMIC_DISPATCH(ARGBToYCbCr);
break;
case JCS_EXT_XBGR:
m->color_transform = HWY_DYNAMIC_DISPATCH(ABGRToYCbCr);
break;
#endif
#ifdef JCS_ALPHA_EXTENSIONS
case JCS_EXT_RGBA:
m->color_transform = HWY_DYNAMIC_DISPATCH(RGBToYCbCr);
break;
case JCS_EXT_BGRA:
m->color_transform = HWY_DYNAMIC_DISPATCH(BGRToYCbCr);
break;
case JCS_EXT_ARGB:
m->color_transform = HWY_DYNAMIC_DISPATCH(ARGBToYCbCr);
break;
case JCS_EXT_ABGR:
m->color_transform = HWY_DYNAMIC_DISPATCH(ABGRToYCbCr);
break;
#endif
default:; // Nothing to do.
}
}
if (m->color_transform == nullptr) {
// TODO(szabadka) Support more color transforms.
JPEGLI_ERROR("Unsupported color transform %d -> %d", cinfo->in_color_space,
@ -257,18 +412,123 @@ void ChooseColorTransform(j_decompress_ptr cinfo) {
m->color_transform = nullptr;
if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
if (cinfo->out_color_space == JCS_RGB) {
m->color_transform = GrayscaleToRGB;
switch (cinfo->out_color_space) {
case JCS_RGB:
m->color_transform = GrayscaleToRGB;
break;
#ifdef JCS_EXTENSIONS
case JCS_EXT_RGB:
case JCS_EXT_BGR:
m->color_transform = GrayscaleToRGB;
break;
case JCS_EXT_RGBX:
case JCS_EXT_BGRX:
m->color_transform = GrayscaleToRGBA;
break;
case JCS_EXT_XRGB:
case JCS_EXT_XBGR:
m->color_transform = GrayscaleToARGB;
break;
#endif
#ifdef JCS_ALPHA_EXTENSIONS
case JCS_EXT_RGBA:
case JCS_EXT_BGRA:
m->color_transform = GrayscaleToRGBA;
break;
case JCS_EXT_ARGB:
case JCS_EXT_ABGR:
m->color_transform = GrayscaleToARGB;
break;
#endif
default:
m->color_transform = nullptr;
}
} else if (cinfo->jpeg_color_space == JCS_RGB) {
if (cinfo->out_color_space == JCS_GRAYSCALE) {
m->color_transform = HWY_DYNAMIC_DISPATCH(RGBToYCbCr);
switch (cinfo->out_color_space) {
case JCS_GRAYSCALE:
m->color_transform = HWY_DYNAMIC_DISPATCH(RGBToYCbCr);
break;
#ifdef JCS_EXTENSIONS
case JCS_EXT_RGB:
m->color_transform = NullTransform;
break;
case JCS_EXT_BGR:
m->color_transform = RGBToBGR;
break;
case JCS_EXT_RGBX:
m->color_transform = RGBToRGBA;
break;
case JCS_EXT_BGRX:
m->color_transform = RGBToBGRA;
break;
case JCS_EXT_XRGB:
m->color_transform = RGBToARGB;
break;
case JCS_EXT_XBGR:
m->color_transform = RGBToABGR;
break;
#endif
#ifdef JCS_ALPHA_EXTENSIONS
case JCS_EXT_RGBA:
m->color_transform = RGBToRGBA;
break;
case JCS_EXT_BGRA:
m->color_transform = RGBToBGRA;
break;
case JCS_EXT_ARGB:
m->color_transform = RGBToARGB;
break;
case JCS_EXT_ABGR:
m->color_transform = RGBToABGR;
break;
#endif
default:
m->color_transform = nullptr;
}
} else if (cinfo->jpeg_color_space == JCS_YCbCr) {
if (cinfo->out_color_space == JCS_RGB) {
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToRGB);
} else if (cinfo->out_color_space == JCS_GRAYSCALE) {
m->color_transform = NullTransform;
switch (cinfo->out_color_space) {
case JCS_GRAYSCALE:
m->color_transform = NullTransform;
break;
case JCS_RGB:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToRGB);
break;
#ifdef JCS_EXTENSIONS
case JCS_EXT_RGB:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToRGB);
break;
case JCS_EXT_BGR:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToBGR);
break;
case JCS_EXT_RGBX:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToRGBA);
break;
case JCS_EXT_BGRX:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToBGRA);
break;
case JCS_EXT_XRGB:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToARGB);
break;
case JCS_EXT_XBGR:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToABGR);
break;
#endif
#ifdef JCS_ALPHA_EXTENSIONS
case JCS_EXT_RGBA:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToRGBA);
break;
case JCS_EXT_BGRA:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToBGRA);
break;
case JCS_EXT_ARGB:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToARGB);
break;
case JCS_EXT_ABGR:
m->color_transform = HWY_DYNAMIC_DISPATCH(YCbCrToABGR);
break;
#endif
default:
m->color_transform = nullptr;
}
} else if (cinfo->jpeg_color_space == JCS_YCCK) {
if (cinfo->out_color_space == JCS_CMYK) {

View file

@ -20,12 +20,7 @@
#ifndef LIB_JPEGLI_COMMON_H_
#define LIB_JPEGLI_COMMON_H_
/* clang-format off */
#include <stdio.h>
#include <jpeglib.h>
/* clang-format on */
#include "lib/jpegli/types.h"
#include "lib/jxl/base/include_jpeglib.h" // NOLINT
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {

View file

@ -54,6 +54,7 @@ void InitializeImage(j_decompress_ptr cinfo) {
m->found_soi_ = false;
m->found_dri_ = false;
m->found_sof_ = false;
m->found_sos_ = false;
m->found_eoi_ = false;
m->icc_index_ = 0;
m->icc_total_ = 0;
@ -243,10 +244,14 @@ void PrepareForScan(j_decompress_ptr cinfo) {
// Copy quantization tables into comp_info.
for (int i = 0; i < cinfo->comps_in_scan; ++i) {
jpeg_component_info* comp = cinfo->cur_comp_info[i];
int quant_tbl_idx = comp->quant_tbl_no;
JQUANT_TBL* quant_table = cinfo->quant_tbl_ptrs[quant_tbl_idx];
if (!quant_table) {
JPEGLI_ERROR("Quantization table with index %d not found", quant_tbl_idx);
}
if (comp->quant_table == nullptr) {
comp->quant_table = Allocate<JQUANT_TBL>(cinfo, 1, JPOOL_IMAGE);
memcpy(comp->quant_table, cinfo->quant_tbl_ptrs[comp->quant_tbl_no],
sizeof(JQUANT_TBL));
memcpy(comp->quant_table, quant_table, sizeof(JQUANT_TBL));
}
}
if (cinfo->comps_in_scan == 1) {
@ -723,16 +728,36 @@ void jpegli_calc_output_dimensions(j_decompress_ptr cinfo) {
}
}
}
if (cinfo->out_color_space == JCS_GRAYSCALE) {
cinfo->out_color_components = 1;
} else if (cinfo->out_color_space == JCS_RGB ||
cinfo->out_color_space == JCS_YCbCr) {
cinfo->out_color_components = 3;
} else if (cinfo->out_color_space == JCS_CMYK ||
cinfo->out_color_space == JCS_YCCK) {
cinfo->out_color_components = 4;
} else {
cinfo->out_color_components = cinfo->num_components;
switch (cinfo->out_color_space) {
case JCS_GRAYSCALE:
cinfo->out_color_components = 1;
break;
case JCS_RGB:
case JCS_YCbCr:
#ifdef JCS_EXTENSIONS
case JCS_EXT_RGB:
case JCS_EXT_BGR:
#endif
cinfo->out_color_components = 3;
break;
case JCS_CMYK:
case JCS_YCCK:
#ifdef JCS_EXTENSIONS
case JCS_EXT_RGBX:
case JCS_EXT_BGRX:
case JCS_EXT_XBGR:
case JCS_EXT_XRGB:
#endif
#ifdef JCS_ALPHA_EXTENSIONS
case JCS_EXT_RGBA:
case JCS_EXT_BGRA:
case JCS_EXT_ABGR:
case JCS_EXT_ARGB:
#endif
cinfo->out_color_components = 4;
break;
default:
cinfo->out_color_components = cinfo->num_components;
}
cinfo->output_components =
cinfo->quantize_colors ? 1 : cinfo->out_color_components;

View file

@ -21,6 +21,7 @@
#define LIB_JPEGLI_DECODE_H_
#include "lib/jpegli/common.h"
#include "lib/jpegli/types.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {

View file

@ -3,17 +3,27 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <jxl/types.h>
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ostream>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "lib/jpegli/decode.h"
#include "lib/jpegli/encode.h"
#include "lib/jpegli/libjpeg_test_util.h"
#include "lib/jpegli/test_params.h"
#include "lib/jpegli/test_utils.h"
#include "lib/jpegli/testing.h"
#include "lib/jxl/base/byte_order.h"
#include "lib/jpegli/types.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/sanitizers.h"
namespace jpegli {
namespace {
@ -894,7 +904,9 @@ std::vector<TestConfig> GenerateTests(bool buffered) {
all_tests.push_back(config);
}
// Tests for color transforms.
for (J_COLOR_SPACE out_color_space : {JCS_RGB, JCS_GRAYSCALE}) {
for (J_COLOR_SPACE out_color_space :
{JCS_RGB, JCS_GRAYSCALE, JCS_EXT_RGB, JCS_EXT_BGR, JCS_EXT_RGBA,
JCS_EXT_BGRA, JCS_EXT_ARGB, JCS_EXT_ABGR}) {
TestConfig config;
config.input.xsize = config.input.ysize = 256;
config.input.color_space = JCS_GRAYSCALE;
@ -903,7 +915,9 @@ std::vector<TestConfig> GenerateTests(bool buffered) {
all_tests.push_back(config);
}
for (J_COLOR_SPACE jpeg_color_space : {JCS_RGB, JCS_YCbCr}) {
for (J_COLOR_SPACE out_color_space : {JCS_RGB, JCS_YCbCr, JCS_GRAYSCALE}) {
for (J_COLOR_SPACE out_color_space :
{JCS_RGB, JCS_YCbCr, JCS_GRAYSCALE, JCS_EXT_RGB, JCS_EXT_BGR,
JCS_EXT_RGBA, JCS_EXT_BGRA, JCS_EXT_ARGB, JCS_EXT_ABGR}) {
if (jpeg_color_space == JCS_RGB && out_color_space == JCS_YCbCr) continue;
TestConfig config;
config.input.xsize = config.input.ysize = 256;
@ -1108,6 +1122,8 @@ std::vector<TestConfig> GenerateTests(bool buffered) {
TestConfig config;
config.input.xsize = xsize;
config.input.ysize = ysize;
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
all_tests.push_back(config);
}
}

View file

@ -6,14 +6,15 @@
#ifndef LIB_JPEGLI_DECODE_INTERNAL_H_
#define LIB_JPEGLI_DECODE_INTERNAL_H_
#include <stdint.h>
#include <sys/types.h>
#include <cstdint>
#include <vector>
#include "lib/jpegli/common.h"
#include "lib/jpegli/common_internal.h"
#include "lib/jpegli/huffman.h"
#include "lib/jpegli/types.h"
namespace jpegli {
@ -58,6 +59,7 @@ struct jpeg_decomp_master {
bool found_soi_;
bool found_dri_;
bool found_sof_;
bool found_sos_;
bool found_eoi_;
// Whether this jpeg has multiple scans (progressive or non-interleaved

View file

@ -103,9 +103,6 @@ void ProcessSOF(j_decompress_ptr cinfo, const uint8_t* data, size_t len) {
int quant_tbl_idx = ReadUint8(data, &pos);
JPEG_VERIFY_INPUT(quant_tbl_idx, 0, NUM_QUANT_TBLS - 1);
comp->quant_tbl_no = quant_tbl_idx;
if (cinfo->quant_tbl_ptrs[quant_tbl_idx] == nullptr) {
JPEGLI_ERROR("Quantization table with index %u not found", quant_tbl_idx);
}
comp->quant_table = nullptr; // will be allocated after SOS marker
}
JPEG_VERIFY_MARKER_END();
@ -168,6 +165,7 @@ void ProcessSOS(j_decompress_ptr cinfo, const uint8_t* data, size_t len) {
if (!m->found_sof_) {
JPEGLI_ERROR("Unexpected SOS marker.");
}
m->found_sos_ = true;
size_t pos = 2;
JPEG_VERIFY_LEN(1);
cinfo->comps_in_scan = ReadUint8(data, &pos);
@ -337,7 +335,7 @@ void ProcessDHT(j_decompress_ptr cinfo, const uint8_t* data, size_t len) {
void ProcessDQT(j_decompress_ptr cinfo, const uint8_t* data, size_t len) {
jpeg_decomp_master* m = cinfo->master;
if (m->found_sof_) {
if (m->found_sos_) {
JPEGLI_ERROR("Updating quant tables between scans is not supported.");
}
size_t pos = 2;

View file

@ -283,15 +283,15 @@ void ProcessCompressionParams(j_compress_ptr cinfo) {
JPEGLI_ERROR("Invalid sampling factor %d x %d", comp->h_samp_factor,
comp->v_samp_factor);
}
if (cinfo->num_components == 1) {
// Force samp factors to 1x1 for single-component images.
comp->h_samp_factor = comp->v_samp_factor = 1;
}
cinfo->max_h_samp_factor =
std::max(comp->h_samp_factor, cinfo->max_h_samp_factor);
cinfo->max_v_samp_factor =
std::max(comp->v_samp_factor, cinfo->max_v_samp_factor);
}
if (cinfo->num_components == 1 &&
(cinfo->max_h_samp_factor != 1 || cinfo->max_v_samp_factor != 1)) {
JPEGLI_ERROR("Sampling is not supported for simgle component image.");
}
size_t iMCU_width = DCTSIZE * cinfo->max_h_samp_factor;
size_t iMCU_height = DCTSIZE * cinfo->max_v_samp_factor;
size_t total_iMCU_cols = DivCeil(cinfo->image_width, iMCU_width);
@ -713,18 +713,31 @@ void jpegli_set_defaults(j_compress_ptr cinfo) {
void jpegli_default_colorspace(j_compress_ptr cinfo) {
CheckState(cinfo, jpegli::kEncStart);
if (cinfo->in_color_space == JCS_RGB && cinfo->master->xyb_mode) {
jpegli_set_colorspace(cinfo, JCS_RGB);
return;
}
switch (cinfo->in_color_space) {
case JCS_GRAYSCALE:
jpegli_set_colorspace(cinfo, JCS_GRAYSCALE);
break;
case JCS_RGB: {
if (cinfo->master->xyb_mode) {
jpegli_set_colorspace(cinfo, JCS_RGB);
} else {
jpegli_set_colorspace(cinfo, JCS_YCbCr);
}
case JCS_RGB:
#ifdef JCS_EXTENSIONS
case JCS_EXT_RGB:
case JCS_EXT_BGR:
case JCS_EXT_RGBX:
case JCS_EXT_BGRX:
case JCS_EXT_XRGB:
case JCS_EXT_XBGR:
#endif
#if JCS_ALPHA_EXTENSIONS
case JCS_EXT_RGBA:
case JCS_EXT_BGRA:
case JCS_EXT_ARGB:
case JCS_EXT_ABGR:
#endif
jpegli_set_colorspace(cinfo, JCS_YCbCr);
break;
}
case JCS_YCbCr:
jpegli_set_colorspace(cinfo, JCS_YCbCr);
break;
@ -806,6 +819,11 @@ void jpegli_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace) {
cinfo->comp_info[2].quant_tbl_no = 1;
cinfo->comp_info[1].dc_tbl_no = cinfo->comp_info[1].ac_tbl_no = 1;
cinfo->comp_info[2].dc_tbl_no = cinfo->comp_info[2].ac_tbl_no = 1;
// Use chroma subsampling by default
cinfo->comp_info[0].h_samp_factor = cinfo->comp_info[0].v_samp_factor = 2;
if (colorspace == JCS_YCCK) {
cinfo->comp_info[3].h_samp_factor = cinfo->comp_info[3].v_samp_factor = 2;
}
}
}

View file

@ -21,6 +21,7 @@
#define LIB_JPEGLI_ENCODE_H_
#include "lib/jpegli/common.h"
#include "lib/jpegli/types.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {

View file

@ -4,14 +4,23 @@
// license that can be found in the LICENSE file.
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ostream>
#include <sstream>
#include <string>
#include <vector>
#include "lib/jpegli/encode.h"
#include "lib/jpegli/error.h"
#include "lib/jpegli/libjpeg_test_util.h"
#include "lib/jpegli/test_params.h"
#include "lib/jpegli/test_utils.h"
#include "lib/jpegli/testing.h"
#include "lib/jxl/sanitizers.h"
#include "lib/jpegli/types.h"
#include "lib/jxl/base/status.h"
namespace jpegli {
namespace {
@ -372,6 +381,8 @@ std::vector<TestConfig> GenerateTests() {
{
TestConfig config;
config.jparams.quality = 100;
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
config.max_bpp = 6.6;
config.max_dist = 0.6;
all_tests.push_back(config);
@ -510,17 +521,23 @@ std::vector<TestConfig> GenerateTests() {
config.jparams.libjpeg_mode = true;
config.max_bpp = 2.1;
config.max_dist = 1.7;
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
all_tests.push_back(config);
}
for (J_COLOR_SPACE in_color_space : {JCS_RGB, JCS_YCbCr, JCS_GRAYSCALE}) {
for (J_COLOR_SPACE in_color_space :
{JCS_RGB, JCS_YCbCr, JCS_GRAYSCALE, JCS_EXT_RGB, JCS_EXT_BGR,
JCS_EXT_RGBA, JCS_EXT_BGRA, JCS_EXT_ARGB, JCS_EXT_ABGR}) {
for (J_COLOR_SPACE jpeg_color_space : {JCS_RGB, JCS_YCbCr, JCS_GRAYSCALE}) {
if (jpeg_color_space == JCS_RGB && in_color_space == JCS_YCbCr) continue;
if (jpeg_color_space == JCS_RGB && in_color_space >= JCS_YCbCr) continue;
TestConfig config;
config.input.xsize = config.input.ysize = 256;
config.input.color_space = in_color_space;
config.jparams.set_jpeg_colorspace = true;
config.jparams.jpeg_color_space = jpeg_color_space;
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
config.max_bpp = jpeg_color_space == JCS_RGB ? 4.5 : 1.85;
config.max_dist = jpeg_color_space == JCS_RGB ? 1.4 : 2.05;
all_tests.push_back(config);
@ -536,6 +553,8 @@ std::vector<TestConfig> GenerateTests() {
config.jparams.set_jpeg_colorspace = true;
config.jparams.jpeg_color_space = jpeg_color_space;
}
config.jparams.h_sampling = {1, 1, 1, 1};
config.jparams.v_sampling = {1, 1, 1, 1};
config.max_bpp = jpeg_color_space == JCS_CMYK ? 4.0 : 3.6;
config.max_dist = jpeg_color_space == JCS_CMYK ? 1.2 : 1.5;
all_tests.push_back(config);
@ -546,6 +565,8 @@ std::vector<TestConfig> GenerateTests() {
config.input.color_space = JCS_YCbCr;
config.max_bpp = 1.6;
config.max_dist = 1.35;
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
all_tests.push_back(config);
}
for (bool xyb : {false, true}) {
@ -596,6 +617,8 @@ std::vector<TestConfig> GenerateTests() {
table.add_raw = add_raw;
table.Generate();
config.jparams.optimize_coding = 1;
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
config.jparams.quant_tables.push_back(table);
config.jparams.quant_indexes = {0, 0, 0};
float q = (type == 0 ? 16 : type) * scale * 0.01f;
@ -614,6 +637,8 @@ std::vector<TestConfig> GenerateTests() {
config.input.ysize = 256;
config.jparams.quant_indexes = {(qidx >> 2) & 1, (qidx >> 1) & 1,
(qidx >> 0) & 1};
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
config.max_bpp = 2.25;
config.max_dist = 2.8;
all_tests.push_back(config);
@ -626,6 +651,8 @@ std::vector<TestConfig> GenerateTests() {
config.input.ysize = 256;
config.jparams.quant_indexes = {(qidx >> 2) & 1, (qidx >> 1) & 1,
(qidx >> 0) & 1};
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
CustomQuantTable table;
table.slot_idx = slot_idx;
table.Generate();
@ -643,6 +670,10 @@ std::vector<TestConfig> GenerateTests() {
config.jparams.xyb_mode = xyb;
config.jparams.quant_indexes = {(qidx >> 2) & 1, (qidx >> 1) & 1,
(qidx >> 0) & 1};
if (!xyb) {
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
}
{
CustomQuantTable table;
table.slot_idx = 0;
@ -667,6 +698,10 @@ std::vector<TestConfig> GenerateTests() {
config.input.ysize = 256;
config.jparams.xyb_mode = xyb;
config.jparams.quant_indexes = {0, 1, 2};
if (!xyb) {
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
}
{
CustomQuantTable table;
table.slot_idx = 0;
@ -738,6 +773,8 @@ std::vector<TestConfig> GenerateTests() {
}
config.jparams.progressive_mode = 0;
config.jparams.optimize_coding = 0;
config.jparams.h_sampling = {1, 1, 1};
config.jparams.v_sampling = {1, 1, 1};
config.max_bpp = 1.85;
config.max_dist = 2.05;
if (input_mode == COEFFICIENTS) {

View file

@ -3,12 +3,20 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <vector>
#include "lib/jpegli/common.h"
#include "lib/jpegli/decode.h"
#include "lib/jpegli/encode.h"
#include "lib/jpegli/error.h"
#include "lib/jpegli/libjpeg_test_util.h"
#include "lib/jpegli/test_params.h"
#include "lib/jpegli/test_utils.h"
#include "lib/jpegli/testing.h"
#include "lib/jxl/sanitizers.h"
#include "lib/jxl/base/status.h"
namespace jpegli {
namespace {
@ -996,6 +1004,9 @@ TEST(EncoderErrorHandlingTest, AddOnTableNoStringParam) {
const uint8_t kCompressed0[] = {
// SOI
0xff, 0xd8, //
// SOF
0xff, 0xc0, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, 0x01, //
0x01, 0x11, 0x00, //
// DQT
0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x03, 0x02, //
0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x05, //
@ -1004,9 +1015,6 @@ const uint8_t kCompressed0[] = {
0x0e, 0x12, 0x10, 0x0d, 0x0e, 0x11, 0x0e, 0x0b, 0x0b, 0x10, //
0x16, 0x10, 0x11, 0x13, 0x14, 0x15, 0x15, 0x15, 0x0c, 0x0f, //
0x17, 0x18, 0x16, 0x14, 0x18, 0x12, 0x14, 0x15, 0x14, //
// SOF
0xff, 0xc0, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, 0x01, //
0x01, 0x11, 0x00, //
// DHT
0xff, 0xc4, 0x00, 0xd2, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, //
0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
@ -1039,8 +1047,8 @@ const uint8_t kCompressed0[] = {
};
const size_t kLen0 = sizeof(kCompressed0);
const size_t kDQTOffset = 2;
const size_t kSOFOffset = 71;
const size_t kSOFOffset = 2;
const size_t kDQTOffset = 15;
const size_t kDHTOffset = 84;
const size_t kSOSOffset = 296;

View file

@ -3,16 +3,24 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <cmath>
#include <jxl/types.h>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <ostream>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "lib/jpegli/decode.h"
#include "lib/jpegli/libjpeg_test_util.h"
#include "lib/jpegli/test_params.h"
#include "lib/jpegli/test_utils.h"
#include "lib/jpegli/testing.h"
#include "lib/jxl/base/byte_order.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/sanitizers.h"
namespace jpegli {
namespace {

View file

@ -5,12 +5,7 @@
#include "lib/jpegli/libjpeg_test_util.h"
/* clang-format off */
#include <stdio.h>
#include <jpeglib.h>
#include <setjmp.h>
/* clang-format on */
#include "lib/jxl/base/include_jpeglib.h" // NOLINT
#include "lib/jxl/sanitizers.h"
namespace jpegli {

View file

@ -3,7 +3,18 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <ostream>
#include <sstream>
#include <string>
#include <vector>
#include "lib/jpegli/encode.h"
#include "lib/jpegli/libjpeg_test_util.h"
#include "lib/jpegli/test_params.h"
#include "lib/jpegli/test_utils.h"
#include "lib/jpegli/testing.h"
@ -130,6 +141,7 @@ TEST_P(OutputSuspensionTestParam, RawData) {
cinfo.input_components = input.components;
cinfo.in_color_space = JCS_YCbCr;
jpegli_set_defaults(&cinfo);
cinfo.comp_info[0].h_samp_factor = config.jparams.h_sampling[0];
cinfo.comp_info[0].v_samp_factor = config.jparams.v_sampling[0];
jpegli_set_progressive_level(&cinfo, 0);
cinfo.optimize_coding = FALSE;

View file

@ -3,14 +3,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <cmath>
#include <cstdint>
#include <vector>
#include "lib/jpegli/decode.h"
#include "lib/jpegli/libjpeg_test_util.h"
#include "lib/jpegli/test_utils.h"
#include "lib/jpegli/testing.h"
#include "lib/jxl/base/status.h"
namespace jpegli {
namespace {

View file

@ -3,8 +3,18 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <ostream>
#include <sstream>
#include <string>
#include <vector>
#include "lib/jpegli/decode.h"
#include "lib/jpegli/encode.h"
#include "lib/jpegli/test_params.h"
#include "lib/jpegli/test_utils.h"
#include "lib/jpegli/testing.h"

View file

@ -8,6 +8,7 @@
#include <cmath>
#include <cstdint>
#include <fstream>
#include <sstream>
#include "lib/jpegli/decode.h"
#include "lib/jpegli/encode.h"
@ -171,6 +172,18 @@ std::string ColorSpaceName(J_COLOR_SPACE colorspace) {
return "CMYK";
case JCS_YCCK:
return "YCCK";
case JCS_EXT_RGB:
return "EXT_RGB";
case JCS_EXT_BGR:
return "EXT_BGR";
case JCS_EXT_RGBA:
return "EXT_RGBA";
case JCS_EXT_BGRA:
return "EXT_BGRA";
case JCS_EXT_ARGB:
return "EXT_ARGB";
case JCS_EXT_ABGR:
return "EXT_ABGR";
default:
return "";
}
@ -301,9 +314,12 @@ std::ostream& operator<<(std::ostream& os, const CompressParams& jparams) {
void SetNumChannels(J_COLOR_SPACE colorspace, size_t* channels) {
if (colorspace == JCS_GRAYSCALE) {
*channels = 1;
} else if (colorspace == JCS_RGB || colorspace == JCS_YCbCr) {
} else if (colorspace == JCS_RGB || colorspace == JCS_YCbCr ||
colorspace == JCS_EXT_RGB || colorspace == JCS_EXT_BGR) {
*channels = 3;
} else if (colorspace == JCS_CMYK || colorspace == JCS_YCCK) {
} else if (colorspace == JCS_CMYK || colorspace == JCS_YCCK ||
colorspace == JCS_EXT_RGBA || colorspace == JCS_EXT_BGRA ||
colorspace == JCS_EXT_ARGB || colorspace == JCS_EXT_ABGR) {
*channels = 4;
} else if (colorspace == JCS_UNKNOWN) {
JXL_CHECK(*channels <= 4);
@ -330,7 +346,28 @@ void ConvertPixel(const uint8_t* input_rgb, uint8_t* out,
if (colorspace == JCS_GRAYSCALE) {
const float Y = 0.299f * r + 0.587f * g + 0.114f * b;
out8[0] = static_cast<uint8_t>(std::round(Y * kMul));
} else if (colorspace == JCS_RGB || colorspace == JCS_UNKNOWN) {
} else if (colorspace == JCS_RGB || colorspace == JCS_EXT_RGB ||
colorspace == JCS_EXT_RGBA) {
out8[0] = input_rgb[0];
out8[1] = input_rgb[1];
out8[2] = input_rgb[2];
if (colorspace == JCS_EXT_RGBA) out8[3] = 255;
} else if (colorspace == JCS_EXT_BGR || colorspace == JCS_EXT_BGRA) {
out8[2] = input_rgb[0];
out8[1] = input_rgb[1];
out8[0] = input_rgb[2];
if (colorspace == JCS_EXT_BGRA) out8[3] = 255;
} else if (colorspace == JCS_EXT_ABGR) {
out8[0] = 255;
out8[3] = input_rgb[0];
out8[2] = input_rgb[1];
out8[1] = input_rgb[2];
} else if (colorspace == JCS_EXT_ARGB) {
out8[0] = 255;
out8[1] = input_rgb[0];
out8[2] = input_rgb[1];
out8[3] = input_rgb[2];
} else if (colorspace == JCS_UNKNOWN) {
for (size_t c = 0; c < num_channels; ++c) {
out8[c] = input_rgb[std::min<size_t>(2, c)];
}
@ -390,9 +427,23 @@ void ConvertPixel(const uint8_t* input_rgb, uint8_t* out,
void ConvertToGrayscale(TestImage* img) {
if (img->color_space == JCS_GRAYSCALE) return;
JXL_CHECK(img->data_type == JPEGLI_TYPE_UINT8);
for (size_t i = 0; i < img->pixels.size(); i += 3) {
if (img->color_space == JCS_RGB) {
ConvertPixel(&img->pixels[i], &img->pixels[i / 3], JCS_GRAYSCALE, 1);
bool rgb_pre_alpha =
img->color_space == JCS_EXT_ARGB || img->color_space == JCS_EXT_ABGR;
bool rgb_post_alpha =
img->color_space == JCS_EXT_RGBA || img->color_space == JCS_EXT_BGRA;
bool rgb_alpha = rgb_pre_alpha || rgb_post_alpha;
bool is_rgb = img->color_space == JCS_RGB ||
img->color_space == JCS_EXT_RGB ||
img->color_space == JCS_EXT_BGR || rgb_alpha;
bool switch_br = img->color_space == JCS_EXT_BGR ||
img->color_space == JCS_EXT_ABGR ||
img->color_space == JCS_EXT_BGRA;
size_t stride = rgb_alpha ? 4 : 3;
size_t offset = rgb_pre_alpha ? 1 : 0;
for (size_t i = offset; i < img->pixels.size(); i += stride) {
if (is_rgb) {
if (switch_br) std::swap(img->pixels[i], img->pixels[i + 2]);
ConvertPixel(&img->pixels[i], &img->pixels[i / stride], JCS_GRAYSCALE, 1);
} else if (img->color_space == JCS_YCbCr) {
img->pixels[i / 3] = img->pixels[i];
}

View file

@ -6,22 +6,15 @@
#ifndef LIB_JPEGLI_TEST_UTILS_H_
#define LIB_JPEGLI_TEST_UTILS_H_
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
/* clang-format off */
#include <stdio.h>
#include <jpeglib.h>
#include <setjmp.h>
/* clang-format on */
#include "lib/jpegli/common.h"
#include "lib/jpegli/libjpeg_test_util.h"
#include "lib/jpegli/test_params.h"
#include "lib/jpegli/types.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/include_jpeglib.h" // NOLINT
namespace jpegli {
@ -127,4 +120,15 @@ void VerifyOutputImage(const TestImage& input, const TestImage& output,
} // namespace jpegli
#if !defined(FUZZ_TEST)
struct FuzzTestSink {
template <typename F>
FuzzTestSink WithSeeds(F) {
return *this;
}
};
#define FUZZ_TEST(A, B) \
const JXL_MAYBE_UNUSED FuzzTestSink unused##A##B = FuzzTestSink()
#endif
#endif // LIB_JPEGLI_TEST_UTILS_H_

View file

@ -3,10 +3,19 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <ostream>
#include <sstream>
#include <string>
#include <vector>
#include "lib/jpegli/decode.h"
#include "lib/jpegli/encode.h"
#include "lib/jpegli/libjpeg_test_util.h"
#include "lib/jpegli/test_params.h"
#include "lib/jpegli/test_utils.h"
#include "lib/jpegli/testing.h"
#include "lib/jxl/base/status.h"

View file

@ -62,7 +62,8 @@ static JXL_INLINE size_t ZeroDensityContext(size_t nonzeros_left, size_t k,
size_t covered_blocks,
size_t log2_covered_blocks,
size_t prev) {
JXL_DASSERT((1u << log2_covered_blocks) == covered_blocks);
JXL_DASSERT((static_cast<size_t>(1) << log2_covered_blocks) ==
covered_blocks);
nonzeros_left = (nonzeros_left + covered_blocks - 1) >> log2_covered_blocks;
k >>= log2_covered_blocks;
JXL_DASSERT(k > 0);
@ -109,7 +110,8 @@ struct BlockCtxMap {
// Non-zero context is based on number of non-zeros and block context.
// For better clustering, contexts with same number of non-zeros are grouped.
constexpr uint32_t ZeroDensityContextsOffset(uint32_t block_ctx) const {
return num_ctxs * kNonZeroBuckets + kZeroDensityContextCount * block_ctx;
return static_cast<uint32_t>(num_ctxs * kNonZeroBuckets +
kZeroDensityContextCount * block_ctx);
}
// Context map for AC coefficients consists of 2 blocks:
@ -121,7 +123,8 @@ struct BlockCtxMap {
// number of non-zeros left and
// index in scan order
constexpr uint32_t NumACContexts() const {
return num_ctxs * (kNonZeroBuckets + kZeroDensityContextCount);
return static_cast<uint32_t>(num_ctxs *
(kNonZeroBuckets + kZeroDensityContextCount));
}
// Non-zero context is based on number of non-zeros and block context.
@ -134,7 +137,7 @@ struct BlockCtxMap {
} else {
ctx = 4 + non_zeros / 2;
}
return ctx * num_ctxs + block_ctx;
return static_cast<uint32_t>(ctx * num_ctxs + block_ctx);
}
BlockCtxMap() {

View file

@ -11,9 +11,12 @@
#include <hwy/base.h> // kMaxVectorSize
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/coeff_order_fwd.h"
#include "lib/jxl/frame_dimensions.h"
#include "lib/jxl/image.h"
#include "lib/jxl/image_ops.h"
// Defines the different kinds of transforms, and heuristics to choose between

View file

@ -5,16 +5,14 @@
#include "lib/jxl/ac_strategy.h"
#include <string.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <hwy/aligned_allocator.h>
#include <hwy/base.h> // HWY_ALIGN_MAX
#include <hwy/tests/hwy_gtest.h>
#include <utility>
#include "lib/jxl/base/random.h"
#include "lib/jxl/dct_scales.h"
#include "lib/jxl/coeff_order_fwd.h"
#include "lib/jxl/dec_transforms_testonly.h"
#include "lib/jxl/enc_transforms.h"
#include "lib/jxl/simd_util.h"

View file

@ -6,23 +6,24 @@
#ifndef LIB_JXL_ANS_COMMON_H_
#define LIB_JXL_ANS_COMMON_H_
#include <stdint.h>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <hwy/base.h>
#include <hwy/cache_control.h> // Prefetch
#include <vector>
#include "lib/jxl/ans_params.h"
#include "lib/jxl/base/byte_order.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/status.h"
namespace jxl {
// Returns the precision (number of bits) that should be used to store
// a histogram count such that Log2Floor(count) == logcount.
static JXL_INLINE uint32_t GetPopulationCountPrecision(uint32_t logcount,
uint32_t shift) {
static JXL_MAYBE_UNUSED JXL_INLINE uint32_t
GetPopulationCountPrecision(uint32_t logcount, uint32_t shift) {
int32_t r = std::min<int>(
logcount, static_cast<int>(shift) -
static_cast<int>((ANS_LOG_TAB_SIZE - logcount) >> 1));

View file

@ -10,11 +10,10 @@
#include "lib/jxl/ans_params.h"
#include "lib/jxl/base/random.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_ans.h"
#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/enc_ans.h"
#include "lib/jxl/enc_aux_out.h"
#include "lib/jxl/enc_bit_writer.h"
#include "lib/jxl/testing.h"

View file

@ -8,7 +8,6 @@
// Macros for compiler version + nonstandard keywords, e.g. __builtin_expect.
#include <stdint.h>
#include <sys/types.h>
#include "lib/jxl/base/sanitizer_definitions.h"
@ -97,6 +96,11 @@
#define JXL_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
#endif
#if JXL_COMPILER_MSVC
#include <stdint.h>
using ssize_t = intptr_t;
#endif
// Returns a void* pointer which the compiler then assumes is N-byte aligned.
// Example: float* JXL_RESTRICT aligned = (float*)JXL_ASSUME_ALIGNED(in, 32);
//
@ -150,8 +154,4 @@
#define JXL_FORMAT(idx_fmt, idx_arg)
#endif
#if JXL_COMPILER_MSVC
using ssize_t = intptr_t;
#endif
#endif // LIB_JXL_BASE_COMPILER_SPECIFIC_H_

View file

@ -3,8 +3,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef LIB_JXL_EXIF_H_
#define LIB_JXL_EXIF_H_
#ifndef LIB_JXL_BASE_EXIF_H_
#define LIB_JXL_BASE_EXIF_H_
// Basic parsing of Exif (just enough for the render-impacting things
// like orientation)
@ -87,4 +87,4 @@ JXL_INLINE void InterpretExif(const std::vector<uint8_t>& exif,
} // namespace jxl
#endif // LIB_JXL_EXIF_H_
#endif // LIB_JXL_BASE_EXIF_H_

View file

@ -0,0 +1,20 @@
// Copyright (c) the JPEG XL Project Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef LIB_JXL_BASE_INCLUDE_JPEGLIB_H_
#define LIB_JXL_BASE_INCLUDE_JPEGLIB_H_
// Using this header ensures that includes go in the right order,
// not alphabetically sorted.
// NOLINTBEGIN
/* clang-format off */
#include <stdio.h> // IWYU pragma: keep
#include <jpeglib.h> // IWYU pragma: keep
#include <setjmp.h> // IWYU pragma: keep
/* clang-format on */
// NOLINTEND
#endif // LIB_JXL_BASE_INCLUDE_JPEGLIB_H_

View file

@ -3,8 +3,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef LIB_JXL_MATRIX_OPS_H_
#define LIB_JXL_MATRIX_OPS_H_
#ifndef LIB_JXL_BASE_MATRIX_OPS_H_
#define LIB_JXL_BASE_MATRIX_OPS_H_
// 3x3 matrix operations.
@ -83,4 +83,4 @@ Status Inv3x3Matrix(Matrix& matrix) {
} // namespace jxl
#endif // LIB_JXL_MATRIX_OPS_H_
#endif // LIB_JXL_BASE_MATRIX_OPS_H_

194
third_party/jpeg-xl/lib/jxl/base/rect.h vendored Normal file
View file

@ -0,0 +1,194 @@
// Copyright (c) the JPEG XL Project Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef LIB_JXL_BASE_RECT_H_
#define LIB_JXL_BASE_RECT_H_
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <sstream>
#include <string>
#include <utility> // std::move
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/status.h"
namespace jxl {
// Rectangular region in image(s). Factoring this out of Image instead of
// shifting the pointer by x0/y0 allows this to apply to multiple images with
// different resolutions (e.g. color transform and quantization field).
// Can compare using SameSize(rect1, rect2).
template <typename T>
class RectT {
public:
// Most windows are xsize_max * ysize_max, except those on the borders where
// begin + size_max > end.
constexpr RectT(T xbegin, T ybegin, size_t xsize_max, size_t ysize_max,
T xend, T yend)
: x0_(xbegin),
y0_(ybegin),
xsize_(ClampedSize(xbegin, xsize_max, xend)),
ysize_(ClampedSize(ybegin, ysize_max, yend)) {}
// Construct with origin and known size (typically from another Rect).
constexpr RectT(T xbegin, T ybegin, size_t xsize, size_t ysize)
: x0_(xbegin), y0_(ybegin), xsize_(xsize), ysize_(ysize) {}
// Construct a rect that covers a whole image/plane/ImageBundle etc.
template <typename ImageT>
explicit RectT(const ImageT& image)
: RectT(0, 0, image.xsize(), image.ysize()) {}
RectT() : RectT(0, 0, 0, 0) {}
RectT(const RectT&) = default;
RectT& operator=(const RectT&) = default;
// Construct a subrect that resides in an image/plane/ImageBundle etc.
template <typename ImageT>
RectT Crop(const ImageT& image) const {
return Intersection(RectT(image));
}
// Construct a subrect that resides in the [0, ysize) x [0, xsize) region of
// the current rect.
RectT Crop(size_t area_xsize, size_t area_ysize) const {
return Intersection(RectT(0, 0, area_xsize, area_ysize));
}
// Returns a rect that only contains `num` lines with offset `y` from `y0()`.
RectT Lines(size_t y, size_t num) const {
JXL_DASSERT(y + num <= ysize_);
return RectT(x0_, y0_ + y, xsize_, num);
}
RectT Line(size_t y) const { return Lines(y, 1); }
JXL_MUST_USE_RESULT RectT Intersection(const RectT& other) const {
return RectT(std::max(x0_, other.x0_), std::max(y0_, other.y0_), xsize_,
ysize_, std::min(x1(), other.x1()),
std::min(y1(), other.y1()));
}
JXL_MUST_USE_RESULT RectT Translate(int64_t x_offset,
int64_t y_offset) const {
return RectT(x0_ + x_offset, y0_ + y_offset, xsize_, ysize_);
}
template <template <class> class P, typename V>
V* Row(P<V>* image, size_t y) const {
JXL_DASSERT(y + y0_ >= 0);
return image->Row(y + y0_) + x0_;
}
template <template <class> class P, typename V>
const V* Row(const P<V>* image, size_t y) const {
JXL_DASSERT(y + y0_ >= 0);
return image->Row(y + y0_) + x0_;
}
template <template <class> class MP, typename V>
V* PlaneRow(MP<V>* image, const size_t c, size_t y) const {
JXL_DASSERT(y + y0_ >= 0);
return image->PlaneRow(c, y + y0_) + x0_;
}
template <template <class> class P, typename V>
const V* ConstRow(const P<V>& image, size_t y) const {
JXL_DASSERT(y + y0_ >= 0);
return image.ConstRow(y + y0_) + x0_;
}
template <template <class> class MP, typename V>
const V* ConstPlaneRow(const MP<V>& image, size_t c, size_t y) const {
JXL_DASSERT(y + y0_ >= 0);
return image.ConstPlaneRow(c, y + y0_) + x0_;
}
bool IsInside(const RectT& other) const {
return x0_ >= other.x0() && x1() <= other.x1() && y0_ >= other.y0() &&
y1() <= other.y1();
}
// Returns true if this Rect fully resides in the given image. ImageT could be
// Plane<T> or Image3<T>; however if ImageT is Rect, results are nonsensical.
template <class ImageT>
bool IsInside(const ImageT& image) const {
return IsInside(RectT(image));
}
T x0() const { return x0_; }
T y0() const { return y0_; }
size_t xsize() const { return xsize_; }
size_t ysize() const { return ysize_; }
T x1() const { return x0_ + xsize_; }
T y1() const { return y0_ + ysize_; }
RectT<T> ShiftLeft(size_t shiftx, size_t shifty) const {
return RectT<T>(x0_ * (1 << shiftx), y0_ * (1 << shifty), xsize_ << shiftx,
ysize_ << shifty);
}
RectT<T> ShiftLeft(size_t shift) const { return ShiftLeft(shift, shift); }
// Requires x0(), y0() to be multiples of 1<<shiftx, 1<<shifty.
RectT<T> CeilShiftRight(size_t shiftx, size_t shifty) const {
JXL_ASSERT(x0_ % (1 << shiftx) == 0);
JXL_ASSERT(y0_ % (1 << shifty) == 0);
return RectT<T>(x0_ / (1 << shiftx), y0_ / (1 << shifty),
DivCeil(xsize_, T{1} << shiftx),
DivCeil(ysize_, T{1} << shifty));
}
RectT<T> CeilShiftRight(std::pair<size_t, size_t> shift) const {
return CeilShiftRight(shift.first, shift.second);
}
RectT<T> CeilShiftRight(size_t shift) const {
return CeilShiftRight(shift, shift);
}
RectT<T> Extend(T border, RectT<T> parent) const {
T new_x0 = x0() > parent.x0() + border ? x0() - border : parent.x0();
T new_y0 = y0() > parent.y0() + border ? y0() - border : parent.y0();
T new_x1 = x1() + border > parent.x1() ? parent.x1() : x1() + border;
T new_y1 = y1() + border > parent.y1() ? parent.y1() : y1() + border;
return RectT<T>(new_x0, new_y0, new_x1 - new_x0, new_y1 - new_y0);
}
template <typename U>
RectT<U> As() const {
return RectT<U>(static_cast<U>(x0_), static_cast<U>(y0_),
static_cast<U>(xsize_), static_cast<U>(ysize_));
}
private:
// Returns size_max, or whatever is left in [begin, end).
static constexpr size_t ClampedSize(T begin, size_t size_max, T end) {
return (static_cast<T>(begin + size_max) <= end)
? size_max
: (end > begin ? end - begin : 0);
}
T x0_;
T y0_;
size_t xsize_;
size_t ysize_;
};
template <typename T>
std::string Description(RectT<T> r) {
std::ostringstream os;
os << "[" << r.x0() << ".." << r.x1() << ")x"
<< "[" << r.y0() << ".." << r.y1() << ")";
return os.str();
}
using Rect = RectT<size_t>;
} // namespace jxl
#endif // LIB_JXL_BASE_RECT_H_

View file

@ -11,6 +11,7 @@
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <vector>
#include "lib/jxl/base/status.h"
@ -41,6 +42,8 @@ class Span {
"Incompatible type of source.");
}
using NCT = typename std::remove_const<T>::type;
constexpr T* data() const noexcept { return ptr_; }
constexpr size_t size() const noexcept { return len_; }
@ -62,12 +65,12 @@ class Span {
len_ -= n;
}
// NCT == non-const-T; compiler will complain if NCT is not compatible with T.
template <typename NCT>
void AppendTo(std::vector<NCT>& dst) const {
dst.insert(dst.end(), begin(), end());
}
std::vector<NCT> Copy() const { return std::vector<NCT>(begin(), end()); }
private:
T* ptr_;
size_t len_;

View file

@ -7,6 +7,7 @@
#include <stdint.h>
#include <array>
#include <utility>
#include <vector>
#include "lib/jxl/base/common.h"

View file

@ -5,6 +5,9 @@
#include "lib/jxl/base/bits.h"
#include <cstddef>
#include <cstdint>
#include "lib/jxl/testing.h"
namespace jxl {

View file

@ -5,7 +5,16 @@
#include "lib/jxl/blending.h"
#include <cstddef>
#include <cstring>
#include <vector>
#include "lib/jxl/alpha.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_patch_dictionary.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image.h"
#include "lib/jxl/image_metadata.h"
namespace jxl {

View file

@ -6,8 +6,10 @@
#ifndef LIB_JXL_BLENDING_H_
#define LIB_JXL_BLENDING_H_
#include <cstddef>
#include <vector>
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_patch_dictionary.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image_metadata.h"

View file

@ -22,13 +22,12 @@
#include "lib/jxl/butteraugli/butteraugli.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <vector>
@ -40,6 +39,7 @@
#include "lib/jxl/base/fast_math-inl.h"
#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/convolve.h"
#include "lib/jxl/image_ops.h"

View file

@ -13,8 +13,6 @@
#include <memory>
#include "lib/jxl/base/compiler_specific.h"
namespace jxl {
// Functions that depend on the cache line size.

View file

@ -9,11 +9,12 @@
// Chroma-from-luma, computed using heuristics to determine the best linear
// model for the X and B channels from the Y channel.
#include <stddef.h>
#include <stdint.h>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <limits>
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/cms/opsin_params.h"
#include "lib/jxl/dec_bit_reader.h"

View file

@ -405,7 +405,7 @@ static Status WriteICCS15Fixed16(float value, size_t pos,
// Even the first value works well,...
bool ok = (-32767.995f <= value) && (value <= 32767.995f);
if (!ok) return JXL_FAILURE("ICC value is out of range / NaN");
int32_t i = value * 65536.0f + 0.5f;
int32_t i = static_cast<int32_t>(std::lround(value * 65536.0f));
// Use two's complement
uint32_t u = static_cast<uint32_t>(i);
WriteICCUint32(u, pos, icc);
@ -849,6 +849,20 @@ static std::string ToString(JxlRenderingIntent rendering_intent) {
}
static std::string ColorEncodingDescriptionImpl(const JxlColorEncoding& c) {
if (c.color_space == JXL_COLOR_SPACE_RGB &&
c.white_point == JXL_WHITE_POINT_D65) {
if (c.rendering_intent == JXL_RENDERING_INTENT_PERCEPTUAL &&
c.transfer_function == JXL_TRANSFER_FUNCTION_SRGB) {
if (c.primaries == JXL_PRIMARIES_SRGB) return "sRGB";
if (c.primaries == JXL_PRIMARIES_P3) return "DisplayP3";
}
if (c.rendering_intent == JXL_RENDERING_INTENT_RELATIVE &&
c.primaries == JXL_PRIMARIES_2100) {
if (c.transfer_function == JXL_TRANSFER_FUNCTION_PQ) return "Rec2100PQ";
if (c.transfer_function == JXL_TRANSFER_FUNCTION_HLG) return "Rec2100HLG";
}
}
std::string d = ToString(c.color_space);
bool explicit_wp_tf = (c.color_space != JXL_COLOR_SPACE_XYB);

View file

@ -6,6 +6,9 @@
#ifndef LIB_JXL_CMS_OPSIN_PARAMS_H_
#define LIB_JXL_CMS_OPSIN_PARAMS_H_
#include <array>
#include <cstddef>
#include "lib/jxl/base/matrix_ops.h"
// Constants that define the XYB color space.

View file

@ -8,6 +8,7 @@
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <utility>
#include "lib/jxl/base/common.h"

View file

@ -6,11 +6,11 @@
#ifndef LIB_JXL_COEFF_ORDER_H_
#define LIB_JXL_COEFF_ORDER_H_
#include <stddef.h>
#include <stdint.h>
#include <array>
#include <cstddef>
#include <cstdint>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/coeff_order_fwd.h"
@ -24,11 +24,12 @@ class BitReader;
static constexpr size_t kCoeffOrderLimit = 6156;
static constexpr std::array<size_t, 3 * kNumOrders + 1> kCoeffOrderOffset = {
0, 1, 2, 3, 4, 5, 6, 10, 14, 18,
34, 50, 66, 68, 70, 72, 76, 80, 84, 92,
100, 108, 172, 236, 300, 332, 364, 396, 652, 908,
1164, 1292, 1420, 1548, 2572, 3596, 4620, 5132, 5644, kCoeffOrderLimit};
static constexpr std::array<size_t, 3 * kNumOrders + 1> JXL_MAYBE_UNUSED
kCoeffOrderOffset = {
0, 1, 2, 3, 4, 5, 6, 10, 14, 18,
34, 50, 66, 68, 70, 72, 76, 80, 84, 92,
100, 108, 172, 236, 300, 332, 364, 396, 652, 908,
1164, 1292, 1420, 1548, 2572, 3596, 4620, 5132, 5644, kCoeffOrderLimit};
// TODO(eustas): rollback to constexpr once modern C++ becomes reuired.
#define CoeffOrderOffset(O, C) \

View file

@ -8,8 +8,8 @@
// Breaks circular dependency between ac_strategy and coeff_order.
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <cstdint>
#include "lib/jxl/base/compiler_specific.h"

View file

@ -10,6 +10,7 @@
#include <jxl/cms_interface.h>
#include <jxl/color_encoding.h>
#include <jxl/types.h>
#include <stddef.h>
#include <stdint.h>

View file

@ -8,6 +8,7 @@
#include <stdint.h>
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdio>
@ -20,6 +21,7 @@
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/cms/color_encoding_cms.h"
#include "lib/jxl/cms/opsin_params.h"
#include "lib/jxl/color_encoding_internal.h"
@ -417,7 +419,7 @@ TEST_F(ColorManagementTest, XYBProfile) {
}
}
}
static float kMaxError[3] = {9e-4, 4e-4, 5e-4};
static float kMaxError[3] = {8.7e-4, 4.4e-4, 5.2e-4};
printf("Maximum errors:\n");
for (size_t c = 0; c < 3; ++c) {
debug_print_color(max_err_i[c]);

View file

@ -20,6 +20,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/image.h"
HWY_BEFORE_NAMESPACE();

View file

@ -6,11 +6,10 @@
#ifndef LIB_JXL_COMPRESSED_DC_H_
#define LIB_JXL_COMPRESSED_DC_H_
#include <stddef.h>
#include <stdint.h>
#include "lib/jxl/ac_context.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image.h"
#include "lib/jxl/modular/modular_image.h"

View file

@ -12,6 +12,8 @@
#include <hwy/highway.h>
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/image_ops.h"

View file

@ -12,6 +12,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/image.h"
namespace jxl {

View file

@ -10,6 +10,7 @@
#include <hwy/foreach_target.h>
#include <hwy/highway.h>
#include "lib/jxl/base/rect.h"
#include "lib/jxl/convolve-inl.h"
HWY_BEFORE_NAMESPACE();

View file

@ -3,9 +3,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "lib/jxl/convolve.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/convolve-inl.h"
#include "lib/jxl/convolve.h"
namespace jxl {

View file

@ -10,6 +10,7 @@
#include <hwy/foreach_target.h>
#include <hwy/highway.h>
#include "lib/jxl/base/rect.h"
#include "lib/jxl/convolve-inl.h"
HWY_BEFORE_NAMESPACE();

View file

@ -11,6 +11,7 @@
#include <hwy/highway.h>
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/convolve-inl.h"
HWY_BEFORE_NAMESPACE();

View file

@ -8,6 +8,8 @@
#include <jxl/types.h>
#include <time.h>
#include <cinttypes> // PRIx64
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/convolve_test.cc"
#include <hwy/foreach_target.h>
@ -20,6 +22,7 @@
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/base/random.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/image_ops.h"
#include "lib/jxl/image_test_utils.h"
#include "lib/jxl/test_utils.h"

View file

@ -8,9 +8,8 @@
// Unoptimized DCT only for use in tests.
#include <string.h> // memcpy
#include <cmath>
#include <cstring> // memcpy
#include <vector>
#include "lib/jxl/base/common.h"

View file

@ -6,9 +6,10 @@
#ifndef LIB_JXL_DCT_UTIL_H_
#define LIB_JXL_DCT_UTIL_H_
#include <stddef.h>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <type_traits>
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/status.h"

View file

@ -10,17 +10,18 @@
// decoding table from them.
#include <jxl/types.h>
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <vector>
#include "lib/jxl/ans_common.h"
#include "lib/jxl/ans_params.h"
#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/byte_order.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/cache_aligned.h"
#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/dec_huffman.h"

View file

@ -23,6 +23,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/coeff_order.h"

View file

@ -5,10 +5,9 @@
#include "lib/jxl/dec_group.h"
#include <stdint.h>
#include <string.h>
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <memory>
#include <utility>
@ -24,6 +23,7 @@
#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/coeff_order.h"
#include "lib/jxl/common.h" // kMaxNumPasses

View file

@ -6,6 +6,13 @@
#include "lib/jxl/dec_group_border.h"
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <utility>
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/frame_dimensions.h"
namespace jxl {

View file

@ -6,14 +6,13 @@
#ifndef LIB_JXL_DEC_GROUP_BORDER_H_
#define LIB_JXL_DEC_GROUP_BORDER_H_
#include <stddef.h>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <memory>
#include "lib/jxl/base/arch_macros.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/frame_dimensions.h"
#include "lib/jxl/image.h"
namespace jxl {

View file

@ -5,9 +5,8 @@
#include "lib/jxl/dec_modular.h"
#include <stdint.h>
#include <atomic>
#include <cstdint>
#include <vector>
#include "lib/jxl/frame_header.h"
@ -19,6 +18,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/compressed_dc.h"
#include "lib/jxl/epf.h"

View file

@ -6,18 +6,23 @@
#ifndef LIB_JXL_DEC_MODULAR_H_
#define LIB_JXL_DEC_MODULAR_H_
#include <stddef.h>
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/dec_cache.h"
#include "lib/jxl/frame_dimensions.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image.h"
#include "lib/jxl/modular/encoding/dec_ma.h"
#include "lib/jxl/modular/encoding/encoding.h"
#include "lib/jxl/modular/modular_image.h"
#include "lib/jxl/quant_weights.h"
#include "lib/jxl/render_pipeline/render_pipeline.h"
namespace jxl {

View file

@ -5,11 +5,8 @@
#include "lib/jxl/dec_noise.h"
#include <stdint.h>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <cstdlib>
#include <utility>
#undef HWY_TARGET_INCLUDE
@ -18,10 +15,10 @@
#include <hwy/highway.h>
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/image_ops.h"
#include "lib/jxl/sanitizers.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/frame_dimensions.h"
#include "lib/jxl/xorshift128plus-inl.h"
HWY_BEFORE_NAMESPACE();
namespace jxl {
namespace HWY_NAMESPACE {

View file

@ -8,11 +8,11 @@
// Noise synthesis. Currently disabled.
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <utility>
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/image.h"
#include "lib/jxl/noise.h"

View file

@ -8,10 +8,12 @@
// Chooses reference patches, and avoids encoding them once per occurrence.
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <utility>
#include <vector>
#include "lib/jxl/base/status.h"

View file

@ -10,12 +10,10 @@
#define LIB_JXL_DEC_TRANSFORMS_INL_H_
#endif
#include <stddef.h>
#include <cstddef>
#include <hwy/highway.h>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/coeff_order_fwd.h"
#include "lib/jxl/dct-inl.h"
#include "lib/jxl/dct_scales.h"
HWY_BEFORE_NAMESPACE();

View file

@ -10,7 +10,6 @@
#include <hwy/foreach_target.h>
#include <hwy/highway.h>
#include "lib/jxl/dct_scales.h"
#include "lib/jxl/dec_transforms-inl.h"
namespace jxl {

View file

@ -8,8 +8,7 @@
// Facade for (non-inlined) inverse integral transforms.
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/compiler_specific.h"

View file

@ -5,7 +5,7 @@
#include "lib/jxl/dec_xyb.h"
#include <string.h>
#include <cstring>
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/dec_xyb.cc"
@ -14,13 +14,12 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/matrix_ops.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/cms/jxl_cms_internal.h"
#include "lib/jxl/cms/opsin_params.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/dec_group_border.h"
#include "lib/jxl/dec_xyb-inl.h"
#include "lib/jxl/fields.h"
#include "lib/jxl/image.h"
#include "lib/jxl/opsin_params.h"
#include "lib/jxl/quantizer.h"

View file

@ -15,6 +15,8 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/matrix_ops.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/image.h"

View file

@ -1701,7 +1701,7 @@ TEST(DecodeTest, PixelTestWithICCProfileLossy) {
EXPECT_SLIGHTLY_BELOW(
ButteraugliDistance(io0.frames, io1.frames, ba, *JxlGetDefaultCms(),
/*distmap=*/nullptr, nullptr),
0.56f);
0.58f);
JxlDecoderDestroy(dec);
}
@ -2151,7 +2151,7 @@ TEST(DecodeTest, PixelTestOpaqueSrgbLossyNoise) {
EXPECT_SLIGHTLY_BELOW(
ButteraugliDistance(io0.frames, io1.frames, ba, *JxlGetDefaultCms(),
/*distmap=*/nullptr, nullptr),
1.3f);
1.9f);
JxlDecoderDestroy(dec);
}

View file

@ -5,12 +5,11 @@
#include "lib/jxl/enc_ac_strategy.h"
#include <stdint.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/enc_ac_strategy.cc"
@ -21,6 +20,7 @@
#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/fast_math-inl.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_transforms-inl.h"
#include "lib/jxl/enc_aux_out.h"

View file

@ -7,9 +7,12 @@
#define LIB_JXL_ENC_AC_STRATEGY_H_
#include <cstddef>
#include <cstdint>
#include <hwy/aligned_allocator.h>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/enc_cache.h"

View file

@ -24,6 +24,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/fast_math-inl.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/butteraugli/butteraugli.h"
#include "lib/jxl/cms/opsin_params.h"
@ -765,7 +766,7 @@ StatusOr<ImageF> TileDistMap(const ImageF& distmap, int tile_size, int margin,
const float kDcQuantPow = 0.83f;
const float kDcQuant = 1.095924047623553f;
const float kAcQuant = 0.7381485255235064f;
const float kAcQuant = 0.725f;
// Computes the decoded image for a given set of compression parameters.
StatusOr<ImageBundle> RoundtripImage(const FrameHeader& frame_header,

View file

@ -7,10 +7,11 @@
#define LIB_JXL_ENC_ADAPTIVE_QUANTIZATION_H_
#include <jxl/cms_interface.h>
#include <stddef.h>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_cache.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image.h"

View file

@ -5,10 +5,9 @@
#include "lib/jxl/enc_ar_control_field.h"
#include <stdint.h>
#include <stdlib.h>
#include <algorithm>
#include <cstdint>
#include <cstdlib>
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/enc_ar_control_field.cc"
@ -17,6 +16,7 @@
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_params.h"
#include "lib/jxl/image.h"

View file

@ -6,11 +6,12 @@
#ifndef LIB_JXL_ENC_AR_CONTROL_FIELD_H_
#define LIB_JXL_ENC_AR_CONTROL_FIELD_H_
#include <stddef.h>
#include <cstddef>
#include <vector>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_params.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image.h"

View file

@ -5,13 +5,13 @@
#include "lib/jxl/enc_cache.h"
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <cstdint>
#include <memory>
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"

View file

@ -7,13 +7,14 @@
#define LIB_JXL_ENC_CACHE_H_
#include <jxl/cms_interface.h>
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <vector>
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dct_util.h"
#include "lib/jxl/enc_ans.h"

Some files were not shown because too many files have changed in this diff Show more