-
Notifications
You must be signed in to change notification settings - Fork 18
/
libjxl.patch
65 lines (64 loc) · 2.58 KB
/
libjxl.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
diff --git a/lib/jpegli/decode.cc b/lib/jpegli/decode.cc
index bf57115a..8747fc7f 100644
--- a/lib/jpegli/decode.cc
+++ b/lib/jpegli/decode.cc
@@ -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,6 +244,9 @@ 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];
+ if (cinfo->quant_tbl_ptrs[comp->quant_tbl_no] == nullptr) {
+ JPEGLI_ERROR("Quantization table with index %u not found", comp->quant_tbl_no);
+ }
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],
diff --git a/lib/jpegli/decode_internal.h b/lib/jpegli/decode_internal.h
index ed7baa39..4a06e582 100644
--- a/lib/jpegli/decode_internal.h
+++ b/lib/jpegli/decode_internal.h
@@ -57,6 +57,7 @@ struct jpeg_decomp_master {
bool found_soi_;
bool found_dri_;
bool found_sof_;
+ bool found_sos_;
bool found_eoi_;
size_t icc_index_;
size_t icc_total_;
diff --git a/lib/jpegli/decode_marker.cc b/lib/jpegli/decode_marker.cc
index 6ef2dd4d..eca3596a 100644
--- a/lib/jpegli/decode_marker.cc
+++ b/lib/jpegli/decode_marker.cc
@@ -104,9 +104,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();
@@ -169,6 +166,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);
@@ -339,7 +337,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;