// 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.
// Data structures that represent the non-pixel contents of a jpeg file.
// Quantization values for an 8x8 pixel block. struct JPEGQuantTable {
std::array<int32_t, kDCTBlockSize> values;
uint32_t precision = 0; // The index of this quantization table as it was parsed from the input JPEG. // Each DQT marker segment contains an 'index' field, and we save this index // here. Valid values are 0 to 3.
uint32_t index = 0; // Set to true if this table is the last one within its marker segment. bool is_last = true;
};
// Huffman code and decoding lookup table used for DC and AC coefficients. struct JPEGHuffmanCode { // Bit length histogram.
std::array<uint32_t, kJpegHuffmanMaxBitLength + 1> counts = {}; // Symbol values sorted by increasing bit lengths.
std::array<uint32_t, kJpegHuffmanAlphabetSize + 1> values = {}; // The index of the Huffman code in the current set of Huffman codes. For AC // component Huffman codes, 0x10 is added to the index. int slot_id = 0; // Set to true if this Huffman code is the last one within its marker segment. bool is_last = true;
};
// Huffman table indexes used for one component of one scan. struct JPEGComponentScanInfo {
uint32_t comp_idx;
uint32_t dc_tbl_idx;
uint32_t ac_tbl_idx;
};
// Contains information that is used in one scan. struct JPEGScanInfo { // Parameters used for progressive scans (named the same way as in the spec): // Ss : Start of spectral band in zig-zag sequence. // Se : End of spectral band in zig-zag sequence. // Ah : Successive approximation bit position, high. // Al : Successive approximation bit position, low.
uint32_t Ss;
uint32_t Se;
uint32_t Ah;
uint32_t Al;
uint32_t num_components = 0;
std::array<JPEGComponentScanInfo, 4> components; // Last codestream pass that is needed to write this scan.
uint32_t last_needed_pass = 0;
// Extra information required for bit-precise JPEG file reconstruction.
// Set of block indexes where the JPEG encoder has to flush the end-of-block // runs and refinement bits.
std::vector<uint32_t> reset_points; // The number of extra zero runs (Huffman symbol 0xf0) before the end of // block (if nonzero), indexed by block index. // All of these symbols can be omitted without changing the pixel values, but // some jpeg encoders put these at the end of blocks. typedefstruct {
uint32_t block_idx;
uint32_t num_extra_zero_runs;
} ExtraZeroRunInfo;
std::vector<ExtraZeroRunInfo> extra_zero_runs;
};
typedef int16_t coeff_t;
// Represents one component of a jpeg file. struct JPEGComponent {
JPEGComponent()
: id(0),
h_samp_factor(1),
v_samp_factor(1),
quant_idx(0),
width_in_blocks(0),
height_in_blocks(0) {}
// One-byte id of the component.
uint32_t id; // Horizontal and vertical sampling factors. // In interleaved mode, each minimal coded unit (MCU) has // h_samp_factor x v_samp_factor DCT blocks from this component. int h_samp_factor; int v_samp_factor; // The index of the quantization table used for this component.
uint32_t quant_idx; // The dimensions of the component measured in 8x8 blocks.
uint32_t width_in_blocks;
uint32_t height_in_blocks; // The DCT coefficients of this component, laid out block-by-block, divided // through the quantization matrix values.
std::vector<coeff_t> coeffs;
};
// Represents a parsed jpeg file. struct JPEGData : public Fields {
JPEGData()
: width(0), height(0), restart_interval(0), has_zero_padding_bit(false) {}
JXL_FIELDS_NAME(JPEGData) #if JPEGXL_ENABLE_TRANSCODE_JPEG // Doesn't serialize everything - skips brotli-encoded data and what is // already encoded in the codestream.
Status VisitFields(Visitor* visitor) override; #else
Status VisitFields(Visitor* /* visitor */) override { return JXL_UNREACHABLE("JPEG transcoding support not enabled");
} #endif// JPEGXL_ENABLE_TRANSCODE_JPEG
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.