summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc')
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc26
1 files changed, 18 insertions, 8 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc b/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc
index 8e92fe3452..a29fb3f299 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc
@@ -13,6 +13,7 @@
#include <vector>
#include "lib/jxl/base/byte_order.h"
+#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/enc_ans.h"
#include "lib/jxl/enc_aux_out.h"
#include "lib/jxl/fields.h"
@@ -36,7 +37,8 @@ void Unshuffle(uint8_t* data, size_t size, size_t width) {
size_t height = (size + width - 1) / width; // amount of rows of input
PaddedBytes result(size);
// i = input index, j output index
- size_t s = 0, j = 0;
+ size_t s = 0;
+ size_t j = 0;
for (size_t i = 0; i < size; i++) {
result[j] = data[i];
j += height;
@@ -71,7 +73,7 @@ Status PredictAndShuffle(size_t stride, size_t width, int order, size_t num,
return true;
}
-static inline void EncodeVarInt(uint64_t value, PaddedBytes* data) {
+inline void EncodeVarInt(uint64_t value, PaddedBytes* data) {
size_t pos = data->size();
data->resize(data->size() + 9);
size_t output_size = data->size();
@@ -83,13 +85,13 @@ static inline void EncodeVarInt(uint64_t value, PaddedBytes* data) {
// TODO(eustas): should it be `<` ?
JXL_CHECK(pos <= output_size);
// |128: Set the next byte flag
- output[pos++] = ((uint8_t)(value & 127)) | 128;
+ output[pos++] = (static_cast<uint8_t>(value & 127)) | 128;
// Remove the seven bits we just wrote
value >>= 7;
}
// TODO(eustas): should it be `<` ?
JXL_CHECK(pos <= output_size);
- output[pos++] = ((uint8_t)value) & 127;
+ output[pos++] = static_cast<uint8_t>(value & 127);
data->resize(pos);
}
@@ -235,7 +237,9 @@ Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result) {
// allowed for tagged elements to overlap, e.g. the curve for R, G and B could
// all point to the same one.
Tag tag;
- size_t tagstart = 0, tagsize = 0, clutstart = 0;
+ size_t tagstart = 0;
+ size_t tagsize = 0;
+ size_t clutstart = 0;
// Should always check tag_sane before doing math with tagsize.
const auto tag_sane = [&tagsize]() {
@@ -292,7 +296,9 @@ Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result) {
commands_add.push_back(kCommandTypeStartFirst + 5);
pos += 8;
commands_add.push_back(kCommandPredict);
- int order = 1, width = 2, stride = width;
+ int order = 1;
+ int width = 2;
+ int stride = width;
commands_add.push_back((order << 2) | (width - 1));
EncodeVarInt(num, &commands_add);
JXL_RETURN_IF_ERROR(PredictAndShuffle(stride, width, order, num, icc,
@@ -310,7 +316,9 @@ Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result) {
pos += 12;
last1 = pos;
commands_add.push_back(kCommandPredict);
- int order = 1, width = 2, stride = width;
+ int order = 1;
+ int width = 2;
+ int stride = width;
commands_add.push_back((order << 2) | (width - 1));
EncodeVarInt(num, &commands_add);
JXL_RETURN_IF_ERROR(PredictAndShuffle(stride, width, order, num, icc,
@@ -352,7 +360,9 @@ Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result) {
if (commands_add.empty() && data_add.empty() && tag == kGbd_Tag &&
tag_sane() && pos == tagstart + 8 && pos + tagsize - 8 <= size &&
pos > 16) {
- size_t width = 4, order = 0, stride = width;
+ size_t width = 4;
+ size_t order = 0;
+ size_t stride = width;
size_t num = tagsize - 8;
uint8_t flags = (order << 2) | (width - 1) | (stride == width ? 0 : 16);
commands_add.push_back(kCommandPredict);