Add std/tga package

This is just a placeholder decoder implementation  (and all of the
required plumbing) that produces a 1x1 reddish-purple image. Follow-up
commits will add flesh to the metaphorical bones.

TGA has no magic identifier, so MIME sniffers have to use heuristics.
The test/data/cbor-rfc-7049-examples.cbor file (which is CBOR binary
data, not a TGA image) is mistakenly sniffed as TGA. The /usr/bin/file
program makes the same classification (a false positive).

$ file test/data/cbor-rfc-7049-examples.cbor
test/data/cbor-rfc-7049-examples.cbor: Targa image data - Map 59395 x 26
x 15 +6169 +6500 - 2-bit alpha - interleave "@\033"

Some test/3pdata/tgasuite/*.tga test files, which are invalid TGA
images, are also false positives for now.

Updates #67
This commit is contained in:
Nigel Tao committed 2022-01-14 22:53:20 +11:00
1 parent db0a5a4f3a
commit 4c09c77bb9
10 files changed
+1280

No files matched your search

+1
View File
@@ -27,6 +27,7 @@
- Added `std/json`.
- Added `std/nie`.
- Added `std/png`.
- Added `std/tga`.
- Added `std/wbmp`.
- Added `tell_me_more?` mechanism.
- Added SIMD.
+12
View File
@@ -66,6 +66,7 @@ https://skia-review.googlesource.com/c/skia/+/290618
#define WUFFS_CONFIG__MODULE__LZW
#define WUFFS_CONFIG__MODULE__NIE
#define WUFFS_CONFIG__MODULE__PNG
#define WUFFS_CONFIG__MODULE__TGA
#define WUFFS_CONFIG__MODULE__WBMP
#define WUFFS_CONFIG__MODULE__ZLIB
@@ -138,6 +139,7 @@ union {
wuffs_gif__decoder gif;
wuffs_nie__decoder nie;
wuffs_png__decoder png;
wuffs_tga__decoder tga;
wuffs_wbmp__decoder wbmp;
} g_potential_decoders;
@@ -300,6 +302,16 @@ initialize_image_decoder() {
&g_potential_decoders.png);
return NULL;
case WUFFS_BASE__FOURCC__TGA:
status = wuffs_tga__decoder__initialize(
&g_potential_decoders.tga, sizeof g_potential_decoders.tga,
WUFFS_VERSION, WUFFS_INITIALIZE__DEFAULT_OPTIONS);
TRY(wuffs_base__status__message(&status));
g_image_decoder =
wuffs_tga__decoder__upcast_as__wuffs_base__image_decoder(
&g_potential_decoders.tga);
return NULL;
case WUFFS_BASE__FOURCC__WBMP:
status = wuffs_wbmp__decoder__initialize(
&g_potential_decoders.wbmp, sizeof g_potential_decoders.wbmp,
+1
View File
@@ -80,6 +80,7 @@ The Escape key quits.
#define WUFFS_CONFIG__MODULE__LZW
#define WUFFS_CONFIG__MODULE__NIE
#define WUFFS_CONFIG__MODULE__PNG
#define WUFFS_CONFIG__MODULE__TGA
#define WUFFS_CONFIG__MODULE__WBMP
#define WUFFS_CONFIG__MODULE__ZLIB
+5
View File
@@ -85,6 +85,11 @@ DecodeImageCallbacks::SelectDecoder(uint32_t fourcc,
}
#endif
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA)
case WUFFS_BASE__FOURCC__TGA:
return wuffs_tga__decoder::alloc_as__wuffs_base__image_decoder();
#endif
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__WBMP)
case WUFFS_BASE__FOURCC__WBMP:
return wuffs_wbmp__decoder::alloc_as__wuffs_base__image_decoder();
+1
View File
@@ -91,6 +91,7 @@ class DecodeImageCallbacks {
// - WUFFS_BASE__FOURCC__GIF
// - WUFFS_BASE__FOURCC__NIE
// - WUFFS_BASE__FOURCC__PNG
// - WUFFS_BASE__FOURCC__TGA
// - WUFFS_BASE__FOURCC__WBMP
virtual wuffs_base__image_decoder::unique_ptr //
SelectDecoder(uint32_t fourcc,
+903
View File
@@ -9640,6 +9640,318 @@ struct wuffs_png__decoder__struct {
// ---------------- Status Codes
// ---------------- Public Consts
#define WUFFS_TGA__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
// ---------------- Struct Declarations
typedef struct wuffs_tga__decoder__struct wuffs_tga__decoder;
#ifdef __cplusplus
extern "C" {
#endif
// ---------------- Public Initializer Prototypes
// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_tga__decoder__initialize(
wuffs_tga__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t options);
size_t
sizeof__wuffs_tga__decoder();
// ---------------- Allocs
// These functions allocate and initialize Wuffs structs. They return NULL if
// memory allocation fails. If they return non-NULL, there is no need to call
// wuffs_foo__bar__initialize, but the caller is responsible for eventually
// calling free on the returned pointer. That pointer is effectively a C++
// std::unique_ptr<T, decltype(&free)>.
wuffs_tga__decoder*
wuffs_tga__decoder__alloc();
static inline wuffs_base__image_decoder*
wuffs_tga__decoder__alloc_as__wuffs_base__image_decoder() {
return (wuffs_base__image_decoder*)(wuffs_tga__decoder__alloc());
}
// ---------------- Upcasts
static inline wuffs_base__image_decoder*
wuffs_tga__decoder__upcast_as__wuffs_base__image_decoder(
wuffs_tga__decoder* p) {
return (wuffs_base__image_decoder*)p;
}
// ---------------- Public Function Prototypes
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
wuffs_tga__decoder__set_quirk_enabled(
wuffs_tga__decoder* self,
uint32_t a_quirk,
bool a_enabled);
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__decode_image_config(
wuffs_tga__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__decode_frame_config(
wuffs_tga__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__decode_frame(
wuffs_tga__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
wuffs_tga__decoder__frame_dirty_rect(
const wuffs_tga__decoder* self);
WUFFS_BASE__MAYBE_STATIC uint32_t
wuffs_tga__decoder__num_animation_loops(
const wuffs_tga__decoder* self);
WUFFS_BASE__MAYBE_STATIC uint64_t
wuffs_tga__decoder__num_decoded_frame_configs(
const wuffs_tga__decoder* self);
WUFFS_BASE__MAYBE_STATIC uint64_t
wuffs_tga__decoder__num_decoded_frames(
const wuffs_tga__decoder* self);
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__restart_frame(
wuffs_tga__decoder* self,
uint64_t a_index,
uint64_t a_io_position);
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
wuffs_tga__decoder__set_report_metadata(
wuffs_tga__decoder* self,
uint32_t a_fourcc,
bool a_report);
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__tell_me_more(
wuffs_tga__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src);
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
wuffs_tga__decoder__workbuf_len(
const wuffs_tga__decoder* self);
#ifdef __cplusplus
} // extern "C"
#endif
// ---------------- Struct Definitions
// These structs' fields, and the sizeof them, are private implementation
// details that aren't guaranteed to be stable across Wuffs versions.
//
// See https://en.wikipedia.org/wiki/Opaque_pointer#C
#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
struct wuffs_tga__decoder__struct {
// Do not access the private_impl's or private_data's fields directly. There
// is no API/ABI compatibility or safety guarantee if you do so. Instead, use
// the wuffs_foo__bar__baz functions.
//
// It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
// can be stack allocated when WUFFS_IMPLEMENTATION is defined.
struct {
uint32_t magic;
uint32_t active_coroutine;
wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
wuffs_base__vtable null_vtable;
uint32_t f_width;
uint32_t f_height;
uint8_t f_call_sequence;
uint64_t f_frame_config_io_position;
wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_frame_config[1];
uint32_t p_decode_frame[1];
} private_impl;
struct {
struct {
uint8_t v_src[4];
} s_decode_frame[1];
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
using unique_ptr = std::unique_ptr<wuffs_tga__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
static inline unique_ptr
alloc() {
return unique_ptr(wuffs_tga__decoder__alloc(), &free);
}
static inline wuffs_base__image_decoder::unique_ptr
alloc_as__wuffs_base__image_decoder() {
return wuffs_base__image_decoder::unique_ptr(
wuffs_tga__decoder__alloc_as__wuffs_base__image_decoder(), &free);
}
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
// Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
// call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
// their first argument) rather than tweaking bar.private_impl.qux fields.
//
// In C, we can just leave wuffs_foo__bar as an incomplete type (unless
// WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
// order to provide convenience methods. These forward on "this", so that you
// can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
wuffs_tga__decoder__struct() = delete;
wuffs_tga__decoder__struct(const wuffs_tga__decoder__struct&) = delete;
wuffs_tga__decoder__struct& operator=(
const wuffs_tga__decoder__struct&) = delete;
#endif // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
#if !defined(WUFFS_IMPLEMENTATION)
// As above, the size of the struct is not part of the public API, and unless
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
// allocated, not stack allocated. Its size is not intended to be known at
// compile time, but it is unfortunately divulged as a side effect of
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
// instead of "sizeof T", invoking the operator. To make the two values
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t options) {
return wuffs_tga__decoder__initialize(
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__image_decoder*
upcast_as__wuffs_base__image_decoder() {
return (wuffs_base__image_decoder*)this;
}
inline wuffs_base__empty_struct
set_quirk_enabled(
uint32_t a_quirk,
bool a_enabled) {
return wuffs_tga__decoder__set_quirk_enabled(this, a_quirk, a_enabled);
}
inline wuffs_base__status
decode_image_config(
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
return wuffs_tga__decoder__decode_image_config(this, a_dst, a_src);
}
inline wuffs_base__status
decode_frame_config(
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
return wuffs_tga__decoder__decode_frame_config(this, a_dst, a_src);
}
inline wuffs_base__status
decode_frame(
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
return wuffs_tga__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
}
inline wuffs_base__rect_ie_u32
frame_dirty_rect() const {
return wuffs_tga__decoder__frame_dirty_rect(this);
}
inline uint32_t
num_animation_loops() const {
return wuffs_tga__decoder__num_animation_loops(this);
}
inline uint64_t
num_decoded_frame_configs() const {
return wuffs_tga__decoder__num_decoded_frame_configs(this);
}
inline uint64_t
num_decoded_frames() const {
return wuffs_tga__decoder__num_decoded_frames(this);
}
inline wuffs_base__status
restart_frame(
uint64_t a_index,
uint64_t a_io_position) {
return wuffs_tga__decoder__restart_frame(this, a_index, a_io_position);
}
inline wuffs_base__empty_struct
set_report_metadata(
uint32_t a_fourcc,
bool a_report) {
return wuffs_tga__decoder__set_report_metadata(this, a_fourcc, a_report);
}
inline wuffs_base__status
tell_me_more(
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src) {
return wuffs_tga__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
}
inline wuffs_base__range_ii_u64
workbuf_len() const {
return wuffs_tga__decoder__workbuf_len(this);
}
#endif // __cplusplus
}; // struct wuffs_tga__decoder__struct
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
// ---------------- Status Codes
extern const char wuffs_wbmp__error__bad_header[];
// ---------------- Public Consts
@@ -10266,6 +10578,7 @@ class DecodeImageCallbacks {
// - WUFFS_BASE__FOURCC__GIF
// - WUFFS_BASE__FOURCC__NIE
// - WUFFS_BASE__FOURCC__PNG
// - WUFFS_BASE__FOURCC__TGA
// - WUFFS_BASE__FOURCC__WBMP
virtual wuffs_base__image_decoder::unique_ptr //
SelectDecoder(uint32_t fourcc,
@@ -41632,6 +41945,591 @@ wuffs_png__decoder__filter_and_swizzle_tricky(
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG)
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA)
// ---------------- Status Codes Implementations
// ---------------- Private Consts
// ---------------- Private Initializer Prototypes
// ---------------- Private Function Prototypes
// ---------------- VTables
const wuffs_base__image_decoder__func_ptrs
wuffs_tga__decoder__func_ptrs_for__wuffs_base__image_decoder = {
(wuffs_base__status(*)(void*,
wuffs_base__pixel_buffer*,
wuffs_base__io_buffer*,
wuffs_base__pixel_blend,
wuffs_base__slice_u8,
wuffs_base__decode_frame_options*))(&wuffs_tga__decoder__decode_frame),
(wuffs_base__status(*)(void*,
wuffs_base__frame_config*,
wuffs_base__io_buffer*))(&wuffs_tga__decoder__decode_frame_config),
(wuffs_base__status(*)(void*,
wuffs_base__image_config*,
wuffs_base__io_buffer*))(&wuffs_tga__decoder__decode_image_config),
(wuffs_base__rect_ie_u32(*)(const void*))(&wuffs_tga__decoder__frame_dirty_rect),
(uint32_t(*)(const void*))(&wuffs_tga__decoder__num_animation_loops),
(uint64_t(*)(const void*))(&wuffs_tga__decoder__num_decoded_frame_configs),
(uint64_t(*)(const void*))(&wuffs_tga__decoder__num_decoded_frames),
(wuffs_base__status(*)(void*,
uint64_t,
uint64_t))(&wuffs_tga__decoder__restart_frame),
(wuffs_base__empty_struct(*)(void*,
uint32_t,
bool))(&wuffs_tga__decoder__set_quirk_enabled),
(wuffs_base__empty_struct(*)(void*,
uint32_t,
bool))(&wuffs_tga__decoder__set_report_metadata),
(wuffs_base__status(*)(void*,
wuffs_base__io_buffer*,
wuffs_base__more_information*,
wuffs_base__io_buffer*))(&wuffs_tga__decoder__tell_me_more),
(wuffs_base__range_ii_u64(*)(const void*))(&wuffs_tga__decoder__workbuf_len),
};
// ---------------- Initializer Implementations
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_tga__decoder__initialize(
wuffs_tga__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
if (sizeof(*self) != sizeof_star_self) {
return wuffs_base__make_status(wuffs_base__error__bad_sizeof_receiver);
}
if (((wuffs_version >> 32) != WUFFS_VERSION_MAJOR) ||
(((wuffs_version >> 16) & 0xFFFF) > WUFFS_VERSION_MINOR)) {
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
if (self->private_impl.magic != 0) {
return wuffs_base__make_status(wuffs_base__error__initialize_falsely_claimed_already_zeroed);
}
#if !defined(__clang__) && defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
} else {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
}
self->private_impl.magic = WUFFS_BASE__MAGIC;
self->private_impl.vtable_for__wuffs_base__image_decoder.vtable_name =
wuffs_base__image_decoder__vtable_name;
self->private_impl.vtable_for__wuffs_base__image_decoder.function_pointers =
(const void*)(&wuffs_tga__decoder__func_ptrs_for__wuffs_base__image_decoder);
return wuffs_base__make_status(NULL);
}
wuffs_tga__decoder*
wuffs_tga__decoder__alloc() {
wuffs_tga__decoder* x =
(wuffs_tga__decoder*)(calloc(sizeof(wuffs_tga__decoder), 1));
if (!x) {
return NULL;
}
if (wuffs_tga__decoder__initialize(
x, sizeof(wuffs_tga__decoder), WUFFS_VERSION, WUFFS_INITIALIZE__ALREADY_ZEROED).repr) {
free(x);
return NULL;
}
return x;
}
size_t
sizeof__wuffs_tga__decoder() {
return sizeof(wuffs_tga__decoder);
}
// ---------------- Function Implementations
// -------- func tga.decoder.set_quirk_enabled
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
wuffs_tga__decoder__set_quirk_enabled(
wuffs_tga__decoder* self,
uint32_t a_quirk,
bool a_enabled) {
return wuffs_base__make_empty_struct();
}
// -------- func tga.decoder.decode_image_config
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__decode_image_config(
wuffs_tga__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
return wuffs_base__make_status(
(self->private_impl.magic == WUFFS_BASE__DISABLED)
? wuffs_base__error__disabled_by_previous_error
: wuffs_base__error__initialize_not_called);
}
if (!a_src) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
return wuffs_base__make_status(wuffs_base__error__bad_argument);
}
if ((self->private_impl.active_coroutine != 0) &&
(self->private_impl.active_coroutine != 1)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
}
self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
if (a_src) {
io0_a_src = a_src->data.ptr;
io1_a_src = io0_a_src + a_src->meta.ri;
iop_a_src = io1_a_src;
io2_a_src = io0_a_src + a_src->meta.wi;
}
if (self->private_impl.f_call_sequence != 0) {
status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
goto exit;
}
self->private_impl.f_width = 1;
self->private_impl.f_height = 1;
self->private_impl.f_frame_config_io_position = wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)));
if (a_dst != NULL) {
wuffs_base__image_config__set(
a_dst,
2164295816,
0,
self->private_impl.f_width,
self->private_impl.f_height,
self->private_impl.f_frame_config_io_position,
false);
}
self->private_impl.f_call_sequence = 3;
goto ok;
ok:
goto exit;
exit:
if (a_src) {
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
}
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.decode_frame_config
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__decode_frame_config(
wuffs_tga__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
return wuffs_base__make_status(
(self->private_impl.magic == WUFFS_BASE__DISABLED)
? wuffs_base__error__disabled_by_previous_error
: wuffs_base__error__initialize_not_called);
}
if (!a_src) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
return wuffs_base__make_status(wuffs_base__error__bad_argument);
}
if ((self->private_impl.active_coroutine != 0) &&
(self->private_impl.active_coroutine != 2)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
}
self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
if (a_src) {
io0_a_src = a_src->data.ptr;
io1_a_src = io0_a_src + a_src->meta.ri;
iop_a_src = io1_a_src;
io2_a_src = io0_a_src + a_src->meta.wi;
}
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
if (self->private_impl.f_call_sequence < 3) {
if (a_src) {
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
}
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_tga__decoder__decode_image_config(self, NULL, a_src);
if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri;
}
if (status.repr) {
goto suspend;
}
} else if (self->private_impl.f_call_sequence == 3) {
if (self->private_impl.f_frame_config_io_position != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) {
status = wuffs_base__make_status(wuffs_base__error__bad_restart);
goto exit;
}
} else if (self->private_impl.f_call_sequence == 4) {
self->private_impl.f_call_sequence = 255;
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
goto ok;
} else {
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
goto ok;
}
if (a_dst != NULL) {
wuffs_base__frame_config__set(
a_dst,
wuffs_base__utility__make_rect_ie_u32(
0,
0,
self->private_impl.f_width,
self->private_impl.f_height),
((wuffs_base__flicks)(0)),
0,
self->private_impl.f_frame_config_io_position,
0,
true,
false,
0);
}
self->private_impl.f_call_sequence = 4;
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (a_src) {
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
}
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.decode_frame
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__decode_frame(
wuffs_tga__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
return wuffs_base__make_status(
(self->private_impl.magic == WUFFS_BASE__DISABLED)
? wuffs_base__error__disabled_by_previous_error
: wuffs_base__error__initialize_not_called);
}
if (!a_dst || !a_src) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
return wuffs_base__make_status(wuffs_base__error__bad_argument);
}
if ((self->private_impl.active_coroutine != 0) &&
(self->private_impl.active_coroutine != 3)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
}
self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
wuffs_base__pixel_format v_dst_pixfmt = {0};
uint32_t v_dst_bits_per_pixel = 0;
wuffs_base__table_u8 v_tab = {0};
wuffs_base__slice_u8 v_dst = {0};
uint8_t v_src[4] = {0};
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
if (coro_susp_point) {
memcpy(v_src, self->private_data.s_decode_frame[0].v_src, sizeof(v_src));
}
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
if (self->private_impl.f_call_sequence < 4) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_tga__decoder__decode_frame_config(self, NULL, a_src);
if (status.repr) {
goto suspend;
}
} else if (self->private_impl.f_call_sequence == 4) {
} else {
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
goto ok;
}
v_status = wuffs_base__pixel_swizzler__prepare(&self->private_impl.f_swizzler,
wuffs_base__pixel_buffer__pixel_format(a_dst),
wuffs_base__pixel_buffer__palette(a_dst),
wuffs_base__utility__make_pixel_format(2164295816),
wuffs_base__utility__empty_slice_u8(),
a_blend);
if ( ! wuffs_base__status__is_ok(&v_status)) {
status = v_status;
if (wuffs_base__status__is_error(&status)) {
goto exit;
} else if (wuffs_base__status__is_suspension(&status)) {
status = wuffs_base__make_status(wuffs_base__error__cannot_return_a_suspension);
goto exit;
}
goto ok;
}
v_dst_pixfmt = wuffs_base__pixel_buffer__pixel_format(a_dst);
v_dst_bits_per_pixel = wuffs_base__pixel_format__bits_per_pixel(&v_dst_pixfmt);
if ((v_dst_bits_per_pixel & 7) != 0) {
status = wuffs_base__make_status(wuffs_base__error__unsupported_option);
goto exit;
}
v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0);
v_dst = wuffs_base__table_u8__row_u32(v_tab, 0);
v_src[0] = 127;
v_src[1] = 0;
v_src[2] = 255;
v_src[3] = 255;
wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, v_dst, wuffs_base__pixel_buffer__palette(a_dst), wuffs_base__make_slice_u8(v_src, 4));
self->private_impl.f_call_sequence = 255;
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
memcpy(self->private_data.s_decode_frame[0].v_src, v_src, sizeof(v_src));
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.frame_dirty_rect
WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
wuffs_tga__decoder__frame_dirty_rect(
const wuffs_tga__decoder* self) {
if (!self) {
return wuffs_base__utility__empty_rect_ie_u32();
}
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
return wuffs_base__utility__empty_rect_ie_u32();
}
return wuffs_base__utility__make_rect_ie_u32(
0,
0,
self->private_impl.f_width,
self->private_impl.f_height);
}
// -------- func tga.decoder.num_animation_loops
WUFFS_BASE__MAYBE_STATIC uint32_t
wuffs_tga__decoder__num_animation_loops(
const wuffs_tga__decoder* self) {
if (!self) {
return 0;
}
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
return 0;
}
return 0;
}
// -------- func tga.decoder.num_decoded_frame_configs
WUFFS_BASE__MAYBE_STATIC uint64_t
wuffs_tga__decoder__num_decoded_frame_configs(
const wuffs_tga__decoder* self) {
if (!self) {
return 0;
}
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
return 0;
}
if (self->private_impl.f_call_sequence > 3) {
return 1;
}
return 0;
}
// -------- func tga.decoder.num_decoded_frames
WUFFS_BASE__MAYBE_STATIC uint64_t
wuffs_tga__decoder__num_decoded_frames(
const wuffs_tga__decoder* self) {
if (!self) {
return 0;
}
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
return 0;
}
if (self->private_impl.f_call_sequence > 4) {
return 1;
}
return 0;
}
// -------- func tga.decoder.restart_frame
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__restart_frame(
wuffs_tga__decoder* self,
uint64_t a_index,
uint64_t a_io_position) {
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
return wuffs_base__make_status(
(self->private_impl.magic == WUFFS_BASE__DISABLED)
? wuffs_base__error__disabled_by_previous_error
: wuffs_base__error__initialize_not_called);
}
if (self->private_impl.f_call_sequence < 3) {
return wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
}
if (a_index != 0) {
return wuffs_base__make_status(wuffs_base__error__bad_argument);
}
self->private_impl.f_call_sequence = 3;
self->private_impl.f_frame_config_io_position = a_io_position;
return wuffs_base__make_status(NULL);
}
// -------- func tga.decoder.set_report_metadata
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
wuffs_tga__decoder__set_report_metadata(
wuffs_tga__decoder* self,
uint32_t a_fourcc,
bool a_report) {
return wuffs_base__make_empty_struct();
}
// -------- func tga.decoder.tell_me_more
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
wuffs_tga__decoder__tell_me_more(
wuffs_tga__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src) {
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
return wuffs_base__make_status(
(self->private_impl.magic == WUFFS_BASE__DISABLED)
? wuffs_base__error__disabled_by_previous_error
: wuffs_base__error__initialize_not_called);
}
if (!a_dst || !a_src) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
return wuffs_base__make_status(wuffs_base__error__bad_argument);
}
if ((self->private_impl.active_coroutine != 0) &&
(self->private_impl.active_coroutine != 4)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
}
self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL);
status = wuffs_base__make_status(wuffs_base__error__no_more_information);
goto exit;
goto ok;
ok:
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.workbuf_len
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
wuffs_tga__decoder__workbuf_len(
const wuffs_tga__decoder* self) {
if (!self) {
return wuffs_base__utility__empty_range_ii_u64();
}
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
return wuffs_base__utility__empty_range_ii_u64();
}
return wuffs_base__utility__make_range_ii_u64(0, 0);
}
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA)
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__WBMP)
// ---------------- Status Codes Implementations
@@ -43105,6 +44003,11 @@ DecodeImageCallbacks::SelectDecoder(uint32_t fourcc,
}
#endif
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA)
case WUFFS_BASE__FOURCC__TGA:
return wuffs_tga__decoder::alloc_as__wuffs_base__image_decoder();
#endif
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__WBMP)
case WUFFS_BASE__FOURCC__WBMP:
return wuffs_wbmp__decoder::alloc_as__wuffs_base__image_decoder();
+206
View File
@@ -0,0 +1,206 @@
// Copyright 2022 The Wuffs Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0
pub struct decoder? implements base.image_decoder(
width : base.u32,
height : base.u32,
// Call sequence states:
// - 0x00: initial state.
// - 0x03: image config decoded.
// - 0x04: frame config decoded.
// - 0xFF: end-of-data, usually after (the non-animated) frame decoded.
//
// State transitions:
//
// - 0x00 -> 0x03: via DIC
// - 0x00 -> 0x04: via DFC with implicit DIC
// - 0x00 -> 0xFF: via DF with implicit DIC and DFC
//
// - 0x03 -> 0x04: via DFC
// - 0x03 -> 0xFF: via DF with implicit DFC
//
// - 0x04 -> 0xFF: via DFC
// - 0x04 -> 0xFF: via DF
//
// - ???? -> 0x03: via RF for ???? > 0x00
//
// Where:
// - DF is decode_frame
// - DFC is decode_frame_config, implicit means nullptr args.dst
// - DIC is decode_image_config, implicit means nullptr args.dst
// - RF is restart_frame
call_sequence : base.u8,
frame_config_io_position : base.u64,
swizzler : base.pixel_swizzler,
util : base.utility,
)
pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
}
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
if this.call_sequence <> 0 {
return base."#bad call sequence"
}
this.width = 1
this.height = 1
this.frame_config_io_position = args.src.position()
if args.dst <> nullptr {
args.dst.set!(
pixfmt: base.PIXEL_FORMAT__BGRA_NONPREMUL,
pixsub: 0,
width: this.width,
height: this.height,
first_frame_io_position: this.frame_config_io_position,
first_frame_is_opaque: false)
}
this.call_sequence = 3
}
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
if this.call_sequence < 3 {
this.decode_image_config?(dst: nullptr, src: args.src)
} else if this.call_sequence == 3 {
if this.frame_config_io_position <> args.src.position() {
return base."#bad restart"
}
} else if this.call_sequence == 4 {
this.call_sequence = 0xFF
return base."@end of data"
} else {
return base."@end of data"
}
if args.dst <> nullptr {
args.dst.set!(bounds: this.util.make_rect_ie_u32(
min_incl_x: 0,
min_incl_y: 0,
max_excl_x: this.width,
max_excl_y: this.height),
duration: 0,
index: 0,
io_position: this.frame_config_io_position,
disposal: 0,
opaque_within_bounds: true,
overwrite_instead_of_blend: false,
background_color: 0x0000_0000)
}
this.call_sequence = 4
}
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status
var dst_pixfmt : base.pixel_format
var dst_bits_per_pixel : base.u32[..= 256]
var tab : table base.u8
var dst : slice base.u8
var src : array[4] base.u8
if this.call_sequence < 4 {
this.decode_frame_config?(dst: nullptr, src: args.src)
} else if this.call_sequence == 4 {
// No-op.
} else {
return base."@end of data"
}
status = this.swizzler.prepare!(
dst_pixfmt: args.dst.pixel_format(),
dst_palette: args.dst.palette(),
src_pixfmt: this.util.make_pixel_format(repr: base.PIXEL_FORMAT__BGRA_NONPREMUL),
src_palette: this.util.empty_slice_u8(),
blend: args.blend)
if not status.is_ok() {
return status
}
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
// to chain the two calls: "args.dst.pixel_format().bits_per_pixel()".
dst_pixfmt = args.dst.pixel_format()
dst_bits_per_pixel = dst_pixfmt.bits_per_pixel()
if (dst_bits_per_pixel & 7) <> 0 {
return base."#unsupported option"
}
tab = args.dst.plane(p: 0)
dst = tab.row_u32(y: 0)
src[0] = 0x7F
src[1] = 0x00
src[2] = 0xFF
src[3] = 0xFF
this.swizzler.swizzle_interleaved_from_slice!(
dst: dst, dst_palette: args.dst.palette(), src: src[..])
this.call_sequence = 0xFF
}
pub func decoder.frame_dirty_rect() base.rect_ie_u32 {
return this.util.make_rect_ie_u32(
min_incl_x: 0,
min_incl_y: 0,
max_excl_x: this.width,
max_excl_y: this.height)
}
pub func decoder.num_animation_loops() base.u32 {
return 0
}
pub func decoder.num_decoded_frame_configs() base.u64 {
if this.call_sequence > 3 {
return 1
}
return 0
}
pub func decoder.num_decoded_frames() base.u64 {
if this.call_sequence > 4 {
return 1
}
return 0
}
pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.status {
if this.call_sequence < 3 {
return base."#bad call sequence"
}
if args.index <> 0 {
return base."#bad argument"
}
this.call_sequence = 3
this.frame_config_io_position = args.io_position
return ok
}
pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
// TODO: implement.
}
pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
return base."#no more information"
}
pub func decoder.workbuf_len() base.range_ii_u64 {
return this.util.make_range_ii_u64(min_incl: 0, max_incl: 0)
}
+10
View File
@@ -1 +1,11 @@
# Generated by script/print-nia-checksums.sh
1f87b217 test/3pdata/tgasuite/bad-color-map.tga
1f87b217 test/3pdata/tgasuite/cbw8.tga
1f87b217 test/3pdata/tgasuite/ccm8.tga
1f87b217 test/3pdata/tgasuite/ctc24.tga
1f87b217 test/3pdata/tgasuite/sixteen-bit-gray-colormap2.tga
1f87b217 test/3pdata/tgasuite/ubw8.tga
1f87b217 test/3pdata/tgasuite/ucm8.tga
1f87b217 test/3pdata/tgasuite/utc16.tga
1f87b217 test/3pdata/tgasuite/utc24.tga
1f87b217 test/3pdata/tgasuite/utc32.tga
+137
View File
@@ -0,0 +1,137 @@
// Copyright 2022 The Wuffs Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------
/*
This test program is typically run indirectly, by the "wuffs test" or "wuffs
bench" commands. These commands take an optional "-mimic" flag to check that
Wuffs' output mimics (i.e. exactly matches) other libraries' output, such as
giflib for GIF, libpng for PNG, etc.
To manually run this test:
for CC in clang gcc; do
$CC -std=c99 -Wall -Werror tga.c && ./a.out
rm -f a.out
done
Each edition should print "PASS", amongst other information, and exit(0).
Add the "wuffs mimic cflags" (everything after the colon below) to the C
compiler flags (after the .c file) to run the mimic tests.
To manually run the benchmarks, replace "-Wall -Werror" with "-O3" and replace
the first "./a.out" with "./a.out -bench". Combine these changes with the
"wuffs mimic cflags" to run the mimic benchmarks.
*/
// ¿ wuffs mimic cflags: -DWUFFS_MIMIC
// Wuffs ships as a "single file C library" or "header file library" as per
// https://github.com/nothings/stb/blob/master/docs/stb_howto.txt
//
// To use that single file as a "foo.c"-like implementation, instead of a
// "foo.h"-like header, #define WUFFS_IMPLEMENTATION before #include'ing or
// compiling it.
#define WUFFS_IMPLEMENTATION
// Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of
// release/c/etc.c choose which parts of Wuffs to build. That file contains the
// entire Wuffs standard library, implementing a variety of codecs and file
// formats. Without this macro definition, an optimizing compiler or linker may
// very well discard Wuffs code for unused codecs, but listing the Wuffs
// modules we use makes that process explicit. Preprocessing means that such
// code simply isn't compiled.
#define WUFFS_CONFIG__MODULES
#define WUFFS_CONFIG__MODULE__BASE
#define WUFFS_CONFIG__MODULE__TGA
// If building this program in an environment that doesn't easily accommodate
// relative includes, you can use the script/inline-c-relative-includes.go
// program to generate a stand-alone C file.
#include "../../../release/c/wuffs-unsupported-snapshot.c"
#include "../testlib/testlib.c"
#ifdef WUFFS_MIMIC
// No mimic library.
#endif
// ---------------- TGA Tests
const char* //
test_wuffs_tga_decode_interface() {
CHECK_FOCUS(__func__);
wuffs_tga__decoder dec;
CHECK_STATUS("initialize",
wuffs_tga__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
return do_test__wuffs_base__image_decoder(
wuffs_tga__decoder__upcast_as__wuffs_base__image_decoder(&dec),
"test/data/bricks-color.tga", 0, SIZE_MAX, 1, 1, 0xFFFF007F);
}
// ---------------- Mimic Tests
#ifdef WUFFS_MIMIC
// No mimic tests.
#endif // WUFFS_MIMIC
// ---------------- TGA Benches
// No TGA benches.
// ---------------- Mimic Benches
#ifdef WUFFS_MIMIC
// No mimic benches.
#endif // WUFFS_MIMIC
// ---------------- Manifest
proc g_tests[] = {
test_wuffs_tga_decode_interface,
#ifdef WUFFS_MIMIC
// No mimic tests.
#endif // WUFFS_MIMIC
NULL,
};
proc g_benches[] = {
// No TGA benches.
#ifdef WUFFS_MIMIC
// No mimic benches.
#endif // WUFFS_MIMIC
NULL,
};
int //
main(int argc, char** argv) {
g_proc_package_name = "std/tga";
return test_main(argc, argv, g_tests, g_benches);
}
+4
View File
@@ -26,6 +26,7 @@ e08a7cc8 test/data/artificial-png/exif.png
e08a7cc8 test/data/artificial-png/key-value-pairs.png
076cb375 test/data/bricks-color.bmp
076cb375 test/data/bricks-color.png
1f87b217 test/data/bricks-color.tga
f36c2e80 test/data/bricks-dither.bmp
f36c2e80 test/data/bricks-dither.gif
f36c2e80 test/data/bricks-dither.no-ancillary.png
@@ -34,10 +35,13 @@ c2bce675 test/data/bricks-gray.bmp
c2bce675 test/data/bricks-gray.gif
c2bce675 test/data/bricks-gray.no-ancillary.png
c2bce675 test/data/bricks-gray.png
1f87b217 test/data/bricks-gray.tga
7aebfe6c test/data/bricks-nodither.bmp
7aebfe6c test/data/bricks-nodither.gif
7aebfe6c test/data/bricks-nodither.png
1f87b217 test/data/bricks-nodither.tga
ae2e547d test/data/bricks-nodither.wbmp
1f87b217 test/data/cbor-rfc-7049-examples.cbor
b47730a2 test/data/checkerboard.gamma1dot0.png
b47730a2 test/data/checkerboard.gamma2dot2.png
aa3e6c7c test/data/crude-flag.nie