mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
aux: add QuirkKeyValuePair type
This commit is contained in:
1 parent
3215f6afac
commit
ffb64df0a0
12 files changed
+111
-120
No files matched your search
@@ -271,7 +271,10 @@ load_image(const char* filename) {
|
||||
dia_flags |= wuffs_aux::DecodeImageArgFlags::REPORT_METADATA_GAMA;
|
||||
}
|
||||
|
||||
uint32_t wuffs_base__quirk_quality = WUFFS_BASE__QUIRK_QUALITY;
|
||||
const wuffs_aux::QuirkKeyValuePair wuffs_base__quirk_quality = {
|
||||
WUFFS_BASE__QUIRK_QUALITY,
|
||||
WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY,
|
||||
};
|
||||
|
||||
MyDecodeImageCallbacks callbacks;
|
||||
wuffs_aux::sync_io::FileInput input(file);
|
||||
|
||||
@@ -139,7 +139,7 @@ static const char* g_usage =
|
||||
uint8_t g_dst_array[DST_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__io_buffer g_dst;
|
||||
|
||||
std::vector<uint32_t> g_quirks;
|
||||
std::vector<wuffs_aux::QuirkKeyValuePair> g_quirks;
|
||||
|
||||
struct {
|
||||
int remaining_argc;
|
||||
@@ -149,9 +149,9 @@ struct {
|
||||
std::string //
|
||||
parse_flags(int argc, char** argv) {
|
||||
#if defined(WUFFS_EXAMPLE_SPEAK_JWCC_NOT_JSON)
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
#endif
|
||||
|
||||
int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name.
|
||||
@@ -175,22 +175,22 @@ parse_flags(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (!strcmp(arg, "input-allow-comments")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-extra-comma")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-inf-nan-numbers")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-jwcc") || !strcmp(arg, "jwcc")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ static const char* g_usage =
|
||||
|
||||
// ----
|
||||
|
||||
std::vector<uint32_t> g_quirks;
|
||||
std::vector<wuffs_aux::QuirkKeyValuePair> g_quirks;
|
||||
|
||||
std::string g_dst;
|
||||
|
||||
@@ -239,9 +239,9 @@ parse_flags(int argc, char** argv) {
|
||||
g_flags.max_output_depth = 0xFFFFFFFF;
|
||||
|
||||
#if defined(WUFFS_EXAMPLE_SPEAK_JWCC_NOT_JSON)
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
#endif
|
||||
|
||||
int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name.
|
||||
@@ -281,22 +281,22 @@ parse_flags(int argc, char** argv) {
|
||||
return g_usage;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-comments")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-extra-comma")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-inf-nan-numbers")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-jwcc") || !strcmp(arg, "jwcc")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(arg, "q=", 2) || !strncmp(arg, "query=", 6)) {
|
||||
@@ -547,7 +547,7 @@ main1(int argc, char** argv) {
|
||||
TRY(parse_flags(argc, argv));
|
||||
if (!g_flags.strict_json_pointer_syntax) {
|
||||
g_quirks.push_back(
|
||||
WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T);
|
||||
{WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T, 1});
|
||||
}
|
||||
|
||||
FILE* in = stdin;
|
||||
|
||||
@@ -499,11 +499,11 @@ fuzz_cpp(const uint8_t* in_ptr, size_t in_len, uint64_t hash) {
|
||||
const char* json_pointer = json_pointers[hash & 15];
|
||||
hash = wuffs_base__u64__rotate_right(hash, 4);
|
||||
|
||||
std::vector<uint32_t> quirks;
|
||||
std::vector<wuffs_aux::QuirkKeyValuePair> quirks;
|
||||
for (uint32_t i = 0; g_quirks[i]; i++) {
|
||||
uint64_t bit = 1 << (i & 63);
|
||||
if (hash & bit) {
|
||||
quirks.push_back(g_quirks[i]);
|
||||
quirks.push_back({g_quirks[i], 1});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace wuffs_aux {
|
||||
|
||||
@@ -28,6 +29,8 @@ using IOBuffer = wuffs_base__io_buffer;
|
||||
// nullptr, since calling free(nullptr) is a no-op.
|
||||
using MemOwner = std::unique_ptr<void, decltype(&free)>;
|
||||
|
||||
using QuirkKeyValuePair = std::pair<uint32_t, uint64_t>;
|
||||
|
||||
namespace sync_io {
|
||||
|
||||
// --------
|
||||
|
||||
@@ -28,15 +28,13 @@ DecodeCborCallbacks::Done(DecodeCborResult& result,
|
||||
sync_io::Input& input,
|
||||
IOBuffer& buffer) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeCborArgQuirks //
|
||||
DecodeCborArgQuirks::DefaultValue() {
|
||||
return DecodeCborArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeCborArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeCborResult //
|
||||
@@ -65,8 +63,8 @@ DecodeCbor(DecodeCborCallbacks& callbacks,
|
||||
ret_error_message = "wuffs_aux::DecodeCbor: out of memory";
|
||||
goto done;
|
||||
}
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
}
|
||||
|
||||
// Prepare the wuffs_base__tok_buffer. 256 tokens is 2KiB.
|
||||
|
||||
@@ -75,13 +75,14 @@ class DecodeCborCallbacks {
|
||||
|
||||
// DecodeCborArgQuirks wraps an optional argument to DecodeCbor.
|
||||
struct DecodeCborArgQuirks {
|
||||
explicit DecodeCborArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeCborArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeCborArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeCbor calls callbacks based on the CBOR-formatted data in input.
|
||||
|
||||
@@ -197,15 +197,13 @@ const char DecodeImage_UnsupportedPixelConfiguration[] = //
|
||||
const char DecodeImage_UnsupportedPixelFormat[] = //
|
||||
"wuffs_aux::DecodeImage: unsupported pixel format";
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeImageArgQuirks //
|
||||
DecodeImageArgQuirks::DefaultValue() {
|
||||
return DecodeImageArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeImageArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeImageArgFlags::DecodeImageArgFlags(uint64_t repr0) : repr(repr0) {}
|
||||
@@ -303,7 +301,8 @@ DecodeImage0(wuffs_base__image_decoder::unique_ptr& image_decoder,
|
||||
DecodeImageCallbacks& callbacks,
|
||||
sync_io::Input& input,
|
||||
wuffs_base__io_buffer& io_buf,
|
||||
wuffs_base__slice_u32 quirks,
|
||||
const QuirkKeyValuePair* quirks_ptr,
|
||||
const size_t quirks_len,
|
||||
uint64_t flags,
|
||||
wuffs_base__pixel_blend pixel_blend,
|
||||
wuffs_base__color_u32_argb_premul background_color,
|
||||
@@ -386,15 +385,8 @@ redirect:
|
||||
}
|
||||
|
||||
// Apply quirks.
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
// TODO: don't special-case this.
|
||||
if (quirks.ptr[i] == WUFFS_BASE__QUIRK_QUALITY) {
|
||||
image_decoder->set_quirk(
|
||||
WUFFS_BASE__QUIRK_QUALITY,
|
||||
WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY);
|
||||
continue;
|
||||
}
|
||||
image_decoder->set_quirk(quirks.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks_len; i++) {
|
||||
image_decoder->set_quirk(quirks_ptr[i].first, quirks_ptr[i].second);
|
||||
}
|
||||
|
||||
// Apply flags.
|
||||
@@ -621,10 +613,10 @@ DecodeImage(DecodeImageCallbacks& callbacks,
|
||||
}
|
||||
|
||||
wuffs_base__image_decoder::unique_ptr image_decoder(nullptr);
|
||||
DecodeImageResult result =
|
||||
DecodeImage0(image_decoder, callbacks, input, *io_buf, quirks.repr,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
DecodeImageResult result = DecodeImage0(
|
||||
image_decoder, callbacks, input, *io_buf, quirks.ptr, quirks.len,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
callbacks.Done(result, input, *io_buf, std::move(image_decoder));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -200,13 +200,14 @@ extern const char DecodeImage_UnsupportedPixelFormat[];
|
||||
|
||||
// DecodeImageArgQuirks wraps an optional argument to DecodeImage.
|
||||
struct DecodeImageArgQuirks {
|
||||
explicit DecodeImageArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeImageArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeImageArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeImageArgFlags wraps an optional argument to DecodeImage.
|
||||
|
||||
@@ -33,15 +33,13 @@ const char DecodeJson_BadJsonPointer[] = //
|
||||
const char DecodeJson_NoMatch[] = //
|
||||
"wuffs_aux::DecodeJson: no match";
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeJsonArgQuirks //
|
||||
DecodeJsonArgQuirks::DefaultValue() {
|
||||
return DecodeJsonArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeJsonArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeJsonArgJsonPointer::DecodeJsonArgJsonPointer(std::string repr0)
|
||||
@@ -386,11 +384,11 @@ DecodeJson(DecodeJsonCallbacks& callbacks,
|
||||
goto done;
|
||||
}
|
||||
bool allow_tilde_n_tilde_r_tilde_t = false;
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
if (quirks.repr.ptr[i] ==
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
if (quirks.ptr[i].first ==
|
||||
WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T) {
|
||||
allow_tilde_n_tilde_r_tilde_t = true;
|
||||
allow_tilde_n_tilde_r_tilde_t = (quirks.ptr[i].second != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,13 +76,14 @@ extern const char DecodeJson_NoMatch[];
|
||||
|
||||
// DecodeJsonArgQuirks wraps an optional argument to DecodeJson.
|
||||
struct DecodeJsonArgQuirks {
|
||||
explicit DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeJsonArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeJsonArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeJsonArgJsonPointer wraps an optional argument to DecodeJson.
|
||||
|
||||
@@ -15061,6 +15061,7 @@ struct wuffs_xz__decoder__struct {
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace wuffs_aux {
|
||||
|
||||
@@ -15073,6 +15074,8 @@ using IOBuffer = wuffs_base__io_buffer;
|
||||
// nullptr, since calling free(nullptr) is a no-op.
|
||||
using MemOwner = std::unique_ptr<void, decltype(&free)>;
|
||||
|
||||
using QuirkKeyValuePair = std::pair<uint32_t, uint64_t>;
|
||||
|
||||
namespace sync_io {
|
||||
|
||||
// --------
|
||||
@@ -15255,13 +15258,14 @@ class DecodeCborCallbacks {
|
||||
|
||||
// DecodeCborArgQuirks wraps an optional argument to DecodeCbor.
|
||||
struct DecodeCborArgQuirks {
|
||||
explicit DecodeCborArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeCborArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeCborArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeCbor calls callbacks based on the CBOR-formatted data in input.
|
||||
@@ -15469,13 +15473,14 @@ extern const char DecodeImage_UnsupportedPixelFormat[];
|
||||
|
||||
// DecodeImageArgQuirks wraps an optional argument to DecodeImage.
|
||||
struct DecodeImageArgQuirks {
|
||||
explicit DecodeImageArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeImageArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeImageArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeImageArgFlags wraps an optional argument to DecodeImage.
|
||||
@@ -15687,13 +15692,14 @@ extern const char DecodeJson_NoMatch[];
|
||||
|
||||
// DecodeJsonArgQuirks wraps an optional argument to DecodeJson.
|
||||
struct DecodeJsonArgQuirks {
|
||||
explicit DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeJsonArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeJsonArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeJsonArgJsonPointer wraps an optional argument to DecodeJson.
|
||||
@@ -77522,15 +77528,13 @@ DecodeCborCallbacks::Done(DecodeCborResult& result,
|
||||
sync_io::Input& input,
|
||||
IOBuffer& buffer) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeCborArgQuirks //
|
||||
DecodeCborArgQuirks::DefaultValue() {
|
||||
return DecodeCborArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeCborArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeCborResult //
|
||||
@@ -77559,8 +77563,8 @@ DecodeCbor(DecodeCborCallbacks& callbacks,
|
||||
ret_error_message = "wuffs_aux::DecodeCbor: out of memory";
|
||||
goto done;
|
||||
}
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
}
|
||||
|
||||
// Prepare the wuffs_base__tok_buffer. 256 tokens is 2KiB.
|
||||
@@ -78053,15 +78057,13 @@ const char DecodeImage_UnsupportedPixelConfiguration[] = //
|
||||
const char DecodeImage_UnsupportedPixelFormat[] = //
|
||||
"wuffs_aux::DecodeImage: unsupported pixel format";
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeImageArgQuirks //
|
||||
DecodeImageArgQuirks::DefaultValue() {
|
||||
return DecodeImageArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeImageArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeImageArgFlags::DecodeImageArgFlags(uint64_t repr0) : repr(repr0) {}
|
||||
@@ -78159,7 +78161,8 @@ DecodeImage0(wuffs_base__image_decoder::unique_ptr& image_decoder,
|
||||
DecodeImageCallbacks& callbacks,
|
||||
sync_io::Input& input,
|
||||
wuffs_base__io_buffer& io_buf,
|
||||
wuffs_base__slice_u32 quirks,
|
||||
const QuirkKeyValuePair* quirks_ptr,
|
||||
const size_t quirks_len,
|
||||
uint64_t flags,
|
||||
wuffs_base__pixel_blend pixel_blend,
|
||||
wuffs_base__color_u32_argb_premul background_color,
|
||||
@@ -78242,15 +78245,8 @@ redirect:
|
||||
}
|
||||
|
||||
// Apply quirks.
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
// TODO: don't special-case this.
|
||||
if (quirks.ptr[i] == WUFFS_BASE__QUIRK_QUALITY) {
|
||||
image_decoder->set_quirk(
|
||||
WUFFS_BASE__QUIRK_QUALITY,
|
||||
WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY);
|
||||
continue;
|
||||
}
|
||||
image_decoder->set_quirk(quirks.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks_len; i++) {
|
||||
image_decoder->set_quirk(quirks_ptr[i].first, quirks_ptr[i].second);
|
||||
}
|
||||
|
||||
// Apply flags.
|
||||
@@ -78477,10 +78473,10 @@ DecodeImage(DecodeImageCallbacks& callbacks,
|
||||
}
|
||||
|
||||
wuffs_base__image_decoder::unique_ptr image_decoder(nullptr);
|
||||
DecodeImageResult result =
|
||||
DecodeImage0(image_decoder, callbacks, input, *io_buf, quirks.repr,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
DecodeImageResult result = DecodeImage0(
|
||||
image_decoder, callbacks, input, *io_buf, quirks.ptr, quirks.len,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
callbacks.Done(result, input, *io_buf, std::move(image_decoder));
|
||||
return result;
|
||||
}
|
||||
@@ -78515,15 +78511,13 @@ const char DecodeJson_BadJsonPointer[] = //
|
||||
const char DecodeJson_NoMatch[] = //
|
||||
"wuffs_aux::DecodeJson: no match";
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeJsonArgQuirks //
|
||||
DecodeJsonArgQuirks::DefaultValue() {
|
||||
return DecodeJsonArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeJsonArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeJsonArgJsonPointer::DecodeJsonArgJsonPointer(std::string repr0)
|
||||
@@ -78868,11 +78862,11 @@ DecodeJson(DecodeJsonCallbacks& callbacks,
|
||||
goto done;
|
||||
}
|
||||
bool allow_tilde_n_tilde_r_tilde_t = false;
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
if (quirks.repr.ptr[i] ==
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
if (quirks.ptr[i].first ==
|
||||
WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T) {
|
||||
allow_tilde_n_tilde_r_tilde_t = true;
|
||||
allow_tilde_n_tilde_r_tilde_t = (quirks.ptr[i].second != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user