mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx/JBIG2: Initialize POD members
And use Array<> instead of C-style arrays.
This commit is contained in:
parent
8af140fd7b
commit
c99506da7d
Notes:
sideshowbarker
2024-07-16 20:51:53 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/c99506da7d Pull-request: https://github.com/SerenityOS/serenity/pull/23661 Reviewed-by: https://github.com/trflynn89
2 changed files with 26 additions and 26 deletions
|
@ -259,13 +259,13 @@ enum class Organization {
|
|||
};
|
||||
|
||||
struct SegmentHeader {
|
||||
u32 segment_number;
|
||||
SegmentType type;
|
||||
u32 segment_number { 0 };
|
||||
SegmentType type { SegmentType::Extension };
|
||||
Vector<u32> referred_to_segment_numbers;
|
||||
|
||||
// 7.2.6 Segment page association
|
||||
// "The first page must be numbered "1". This field may contain a value of zero; this value indicates that this segment is not associated with any page."
|
||||
u32 page_association;
|
||||
u32 page_association { 0 };
|
||||
|
||||
Optional<u32> data_length;
|
||||
};
|
||||
|
@ -289,9 +289,9 @@ private:
|
|||
BitBuffer(ByteBuffer, size_t width, size_t height, size_t pitch);
|
||||
|
||||
ByteBuffer m_bits;
|
||||
size_t m_width;
|
||||
size_t m_height;
|
||||
size_t m_pitch;
|
||||
size_t m_width { 0 };
|
||||
size_t m_height { 0 };
|
||||
size_t m_pitch { 0 };
|
||||
};
|
||||
|
||||
ErrorOr<NonnullOwnPtr<BitBuffer>> BitBuffer::create(size_t width, size_t height)
|
||||
|
@ -369,7 +369,7 @@ enum class CombinationOperator {
|
|||
|
||||
struct Page {
|
||||
IntSize size;
|
||||
CombinationOperator default_combination_operator;
|
||||
CombinationOperator default_combination_operator { CombinationOperator::Or };
|
||||
OwnPtr<BitBuffer> bits;
|
||||
};
|
||||
|
||||
|
@ -695,18 +695,19 @@ static ErrorOr<void> warn_about_multiple_pages(JBIG2LoadingContext& context)
|
|||
|
||||
// 6.2.2 Input parameters
|
||||
struct GenericRegionDecodingInputParameters {
|
||||
bool is_modified_modified_read; // "MMR" in spec.
|
||||
u32 region_width; // "GBW" in spec.
|
||||
u32 region_height; // "GBH" in spec.
|
||||
u8 gb_template;
|
||||
bool is_typical_prediction_used; // "TPGDON" in spec.
|
||||
bool is_extended_reference_template_used; // "EXTTEMPLATE" in spec.
|
||||
Optional<NonnullOwnPtr<BitBuffer>> skip_pattern; // "USESKIP", "SKIP" in spec.
|
||||
bool is_modified_modified_read { false }; // "MMR" in spec.
|
||||
u32 region_width { 0 }; // "GBW" in spec.
|
||||
u32 region_height { 0 }; // "GBH" in spec.
|
||||
u8 gb_template { 0 };
|
||||
bool is_typical_prediction_used { false }; // "TPGDON" in spec.
|
||||
bool is_extended_reference_template_used { false }; // "EXTTEMPLATE" in spec.
|
||||
Optional<NonnullOwnPtr<BitBuffer>> skip_pattern; // "USESKIP", "SKIP" in spec.
|
||||
|
||||
struct AdaptiveTemplatePixel {
|
||||
i8 x, y;
|
||||
i8 x { 0 };
|
||||
i8 y { 0 };
|
||||
};
|
||||
AdaptiveTemplatePixel adaptive_template_pixels[12]; // "GBATX" / "GBATY" in spec.
|
||||
Array<AdaptiveTemplatePixel, 12> adaptive_template_pixels; // "GBATX" / "GBATY" in spec.
|
||||
// FIXME: GBCOLS, GBCOMBOP, COLEXTFLAG
|
||||
};
|
||||
|
||||
|
@ -876,7 +877,7 @@ static ErrorOr<void> decode_immediate_generic_region(JBIG2LoadingContext& contex
|
|||
data = data.slice(sizeof(flags));
|
||||
|
||||
// 7.4.6.3 Generic region segment AT flags
|
||||
GenericRegionDecodingInputParameters::AdaptiveTemplatePixel adaptive_template_pixels[12] = {};
|
||||
Array<GenericRegionDecodingInputParameters::AdaptiveTemplatePixel, 12> adaptive_template_pixels {};
|
||||
if (!uses_mmr) {
|
||||
dbgln_if(JBIG2_DEBUG, "Non-MMR generic region, GBTEMPLATE={} TPGDON={} EXTTEMPLATE={}", arithmetic_coding_template, typical_prediction_generic_decoding_on, uses_extended_reference_template);
|
||||
|
||||
|
@ -911,8 +912,7 @@ static ErrorOr<void> decode_immediate_generic_region(JBIG2LoadingContext& contex
|
|||
inputs.is_typical_prediction_used = typical_prediction_generic_decoding_on;
|
||||
inputs.is_extended_reference_template_used = uses_extended_reference_template;
|
||||
inputs.skip_pattern = OptionalNone {};
|
||||
static_assert(sizeof(inputs.adaptive_template_pixels) == sizeof(adaptive_template_pixels));
|
||||
memcpy(inputs.adaptive_template_pixels, adaptive_template_pixels, sizeof(adaptive_template_pixels));
|
||||
inputs.adaptive_template_pixels = adaptive_template_pixels;
|
||||
auto result = TRY(generic_region_decoding_procedure(inputs, data));
|
||||
|
||||
// 8.2 Page image composition step 5)
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace JBIG2 {
|
|||
class ArithmeticDecoder {
|
||||
public:
|
||||
struct Context {
|
||||
u8 I; // Index I stored for context CX (E.2.4)
|
||||
u8 is_mps; // "More probable symbol" (E.1.1). 0 or 1.
|
||||
u8 I { 0 }; // Index I stored for context CX (E.2.4)
|
||||
u8 is_mps { 0 }; // "More probable symbol" (E.1.1). 0 or 1.
|
||||
};
|
||||
|
||||
static ErrorOr<ArithmeticDecoder> initialize(ReadonlyBytes data);
|
||||
|
@ -55,15 +55,15 @@ private:
|
|||
void BYTEIN();
|
||||
|
||||
u8 B(size_t offset = 0) const; // Byte pointed to by BP.
|
||||
size_t BP; // Pointer into compressed data.
|
||||
size_t BP { 0 }; // Pointer into compressed data.
|
||||
|
||||
// E.3.1 Decoder code register conventions
|
||||
u32 C; // Consists of u16 C_high, C_low.
|
||||
u16 A; // Current value of the fraction. Fixed precision; 0x8000 is equivalent to 0.75.
|
||||
u32 C { 0 }; // Consists of u16 C_high, C_low.
|
||||
u16 A { 0 }; // Current value of the fraction. Fixed precision; 0x8000 is equivalent to 0.75.
|
||||
|
||||
u8 CT; // Count of the number of bits in C.
|
||||
u8 CT { 0 }; // Count of the number of bits in C.
|
||||
|
||||
Context* CX;
|
||||
Context* CX { nullptr };
|
||||
static u8& I(Context* cx) { return cx->I; }
|
||||
static u8& MPS(Context* cx) { return cx->is_mps; }
|
||||
static u16 Qe(u16);
|
||||
|
|
Loading…
Reference in a new issue