diff options
Diffstat (limited to 'lib/jxl/icc_codec.cc')
-rw-r--r-- | lib/jxl/icc_codec.cc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/jxl/icc_codec.cc b/lib/jxl/icc_codec.cc index dd83fbe..a1f118e 100644 --- a/lib/jxl/icc_codec.cc +++ b/lib/jxl/icc_codec.cc @@ -11,13 +11,11 @@ #include <string> #include <vector> -#include "lib/jxl/aux_out.h" -#include "lib/jxl/aux_out_fwd.h" #include "lib/jxl/base/byte_order.h" -#include "lib/jxl/common.h" #include "lib/jxl/dec_ans.h" #include "lib/jxl/fields.h" #include "lib/jxl/icc_codec_common.h" +#include "lib/jxl/padded_bytes.h" namespace jxl { namespace { @@ -53,6 +51,19 @@ void Shuffle(uint8_t* data, size_t size, size_t width) { // 63-bit values). constexpr const size_t kPreambleSize = 22; // enough for reading 2 VarInts +uint64_t DecodeVarInt(const uint8_t* input, size_t inputSize, size_t* pos) { + size_t i; + uint64_t ret = 0; + for (i = 0; *pos + i < inputSize && i < 10; ++i) { + ret |= uint64_t(input[*pos + i] & 127) << uint64_t(7 * i); + // If the next-byte flag is not set, stop + if ((input[*pos + i] & 128) == 0) break; + } + // TODO(user): Return a decoding error if i == 10. + *pos += i + 1; + return ret; +} + } // namespace // Mimics the beginning of UnpredictICC for quick validity check. @@ -98,7 +109,8 @@ Status UnpredictICC(const uint8_t* enc, size_t size, PaddedBytes* result) { pos = commands_end; // pos in data stream // Header - PaddedBytes header = ICCInitialHeaderPrediction(); + PaddedBytes header; + header.append(ICCInitialHeaderPrediction()); EncodeUint32(0, osize, &header); for (size_t i = 0; i <= kICCHeaderSize; i++) { if (result->size() == osize) { @@ -380,12 +392,4 @@ Status ICCReader::CheckEOI(BitReader* reader) { "Not enough bytes for reading ICC profile"); } -Status ReadICC(BitReader* JXL_RESTRICT reader, PaddedBytes* JXL_RESTRICT icc, - size_t output_limit) { - ICCReader icc_reader; - JXL_RETURN_IF_ERROR(icc_reader.Init(reader, output_limit)); - JXL_RETURN_IF_ERROR(icc_reader.Process(reader, icc)); - return true; -} - } // namespace jxl |