mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
wuffs gen -version=0.2.0-alpha.8
This commit is contained in:
1 parent
9514b12c7f
commit
e3e94476ab
1 file changed
+649
-278
+649
-278
@@ -65,14 +65,14 @@ extern "C" {
|
|||||||
// work-in-progress version, not a release version, and has no backwards or
|
// work-in-progress version, not a release version, and has no backwards or
|
||||||
// forwards compatibility guarantees.
|
// forwards compatibility guarantees.
|
||||||
//
|
//
|
||||||
// WUFFS_VERSION was overridden by "wuffs gen -version" on 2018-07-15 UTC,
|
// WUFFS_VERSION was overridden by "wuffs gen -version" on 2018-07-21 UTC,
|
||||||
// based on revision dcda30b96a9239910d7f50e937518d81cf75dc1c.
|
// based on revision 9514b12c7f0a36a4bbab178d0d5fcb1b87a34011.
|
||||||
#define WUFFS_VERSION ((uint64_t)0x0000000000020000)
|
#define WUFFS_VERSION ((uint64_t)0x0000000000020000)
|
||||||
#define WUFFS_VERSION_MAJOR ((uint64_t)0x00000000)
|
#define WUFFS_VERSION_MAJOR ((uint64_t)0x00000000)
|
||||||
#define WUFFS_VERSION_MINOR ((uint64_t)0x0002)
|
#define WUFFS_VERSION_MINOR ((uint64_t)0x0002)
|
||||||
#define WUFFS_VERSION_PATCH ((uint64_t)0x0000)
|
#define WUFFS_VERSION_PATCH ((uint64_t)0x0000)
|
||||||
#define WUFFS_VERSION_EXTENSION "alpha.7"
|
#define WUFFS_VERSION_EXTENSION "alpha.8"
|
||||||
#define WUFFS_VERSION_STRING "0.2.0-alpha.7"
|
#define WUFFS_VERSION_STRING "0.2.0-alpha.8"
|
||||||
|
|
||||||
// Define WUFFS_CONFIG__STATIC_FUNCTIONS to make all of Wuffs' functions have
|
// Define WUFFS_CONFIG__STATIC_FUNCTIONS to make all of Wuffs' functions have
|
||||||
// static storage. The motivation is discussed in the "ALLOW STATIC
|
// static storage. The motivation is discussed in the "ALLOW STATIC
|
||||||
@@ -1093,6 +1093,28 @@ wuffs_base__io_buffer__struct::writer() {
|
|||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---------------- Images
|
// ---------------- Images
|
||||||
|
|
||||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||||
@@ -1270,10 +1292,6 @@ wuffs_base__pixel_format__num_planes(wuffs_base__pixel_format f) {
|
|||||||
return f ? (((f >> 20) & 0x03) + 1) : 0;
|
return f ? (((f >> 20) & 0x03) + 1) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
wuffs_base__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX];
|
|
||||||
} wuffs_base__pixel_buffer;
|
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
|
||||||
// wuffs_base__pixel_subsampling encodes the mapping of pixel space coordinates
|
// wuffs_base__pixel_subsampling encodes the mapping of pixel space coordinates
|
||||||
@@ -1364,6 +1382,165 @@ typedef struct {
|
|||||||
wuffs_base__pixel_subsampling pixsub;
|
wuffs_base__pixel_subsampling pixsub;
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
|
} private_impl;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
inline void initialize(wuffs_base__pixel_format pixfmt,
|
||||||
|
wuffs_base__pixel_subsampling pixsub,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t height);
|
||||||
|
inline void invalidate();
|
||||||
|
inline bool is_valid();
|
||||||
|
inline wuffs_base__pixel_format pixel_format();
|
||||||
|
inline wuffs_base__pixel_subsampling pixel_subsampling();
|
||||||
|
inline wuffs_base__rect_ie_u32 bounds();
|
||||||
|
inline uint32_t width();
|
||||||
|
inline uint32_t height();
|
||||||
|
inline size_t pixbuf_size();
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
} wuffs_base__pixel_config;
|
||||||
|
|
||||||
|
// TODO: Should this function return bool? An error type?
|
||||||
|
static inline void //
|
||||||
|
wuffs_base__pixel_config__initialize(wuffs_base__pixel_config* c,
|
||||||
|
wuffs_base__pixel_format pixfmt,
|
||||||
|
wuffs_base__pixel_subsampling pixsub,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t height) {
|
||||||
|
if (!c) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pixfmt) {
|
||||||
|
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||||
|
// TODO: handle things other than 1 byte per pixel.
|
||||||
|
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||||
|
c->private_impl.pixfmt = pixfmt;
|
||||||
|
c->private_impl.pixsub = pixsub;
|
||||||
|
c->private_impl.width = width;
|
||||||
|
c->private_impl.height = height;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*c = ((wuffs_base__pixel_config){});
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void //
|
||||||
|
wuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {
|
||||||
|
if (c) {
|
||||||
|
*c = ((wuffs_base__pixel_config){});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool //
|
||||||
|
wuffs_base__pixel_config__is_valid(wuffs_base__pixel_config* c) {
|
||||||
|
return c && c->private_impl.pixfmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline wuffs_base__pixel_format //
|
||||||
|
wuffs_base__pixel_config__pixel_format(wuffs_base__pixel_config* c) {
|
||||||
|
return c ? c->private_impl.pixfmt : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline wuffs_base__pixel_subsampling //
|
||||||
|
wuffs_base__pixel_config__pixel_subsampling(wuffs_base__pixel_config* c) {
|
||||||
|
return c ? c->private_impl.pixsub : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline wuffs_base__rect_ie_u32 //
|
||||||
|
wuffs_base__pixel_config__bounds(wuffs_base__pixel_config* c) {
|
||||||
|
return c ? ((wuffs_base__rect_ie_u32){
|
||||||
|
.min_incl_x = 0,
|
||||||
|
.min_incl_y = 0,
|
||||||
|
.max_excl_x = c->private_impl.width,
|
||||||
|
.max_excl_y = c->private_impl.height,
|
||||||
|
})
|
||||||
|
: ((wuffs_base__rect_ie_u32){});
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t //
|
||||||
|
wuffs_base__pixel_config__width(wuffs_base__pixel_config* c) {
|
||||||
|
return c ? c->private_impl.width : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t //
|
||||||
|
wuffs_base__pixel_config__height(wuffs_base__pixel_config* c) {
|
||||||
|
return c ? c->private_impl.height : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||||
|
// decoding into a color model different from the format's intrinsic one? For
|
||||||
|
// example, decoding a JPEG image straight to RGBA instead of to YCbCr?
|
||||||
|
static inline size_t //
|
||||||
|
wuffs_base__pixel_config__pixbuf_size(wuffs_base__pixel_config* c) {
|
||||||
|
if (c) {
|
||||||
|
uint64_t wh =
|
||||||
|
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||||
|
// TODO: handle things other than 1 byte per pixel.
|
||||||
|
return (size_t)wh;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
inline void //
|
||||||
|
wuffs_base__pixel_config::initialize(wuffs_base__pixel_format pixfmt,
|
||||||
|
wuffs_base__pixel_subsampling pixsub,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t height) {
|
||||||
|
wuffs_base__pixel_config__initialize(this, pixfmt, pixsub, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void //
|
||||||
|
wuffs_base__pixel_config::invalidate() {
|
||||||
|
wuffs_base__pixel_config__invalidate(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool //
|
||||||
|
wuffs_base__pixel_config::is_valid() {
|
||||||
|
return wuffs_base__pixel_config__is_valid(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wuffs_base__pixel_format //
|
||||||
|
wuffs_base__pixel_config::pixel_format() {
|
||||||
|
return wuffs_base__pixel_config__pixel_format(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wuffs_base__pixel_subsampling //
|
||||||
|
wuffs_base__pixel_config::pixel_subsampling() {
|
||||||
|
return wuffs_base__pixel_config__pixel_subsampling(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wuffs_base__rect_ie_u32 //
|
||||||
|
wuffs_base__pixel_config::bounds() {
|
||||||
|
return wuffs_base__pixel_config__bounds(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint32_t //
|
||||||
|
wuffs_base__pixel_config::width() {
|
||||||
|
return wuffs_base__pixel_config__width(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint32_t //
|
||||||
|
wuffs_base__pixel_config::height() {
|
||||||
|
return wuffs_base__pixel_config__height(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t //
|
||||||
|
wuffs_base__pixel_config::pixbuf_size() {
|
||||||
|
return wuffs_base__pixel_config__pixbuf_size(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
// --------
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||||
|
// compatibility or safety guarantee if you do so.
|
||||||
|
struct {
|
||||||
|
wuffs_base__pixel_config pixcfg;
|
||||||
uint32_t num_loops;
|
uint32_t num_loops;
|
||||||
bool first_frame_is_opaque;
|
bool first_frame_is_opaque;
|
||||||
} private_impl;
|
} private_impl;
|
||||||
@@ -1377,6 +1554,7 @@ typedef struct {
|
|||||||
bool first_frame_is_opaque);
|
bool first_frame_is_opaque);
|
||||||
inline void invalidate();
|
inline void invalidate();
|
||||||
inline bool is_valid();
|
inline bool is_valid();
|
||||||
|
inline wuffs_base__pixel_config* pixel_config();
|
||||||
inline wuffs_base__pixel_format pixel_format();
|
inline wuffs_base__pixel_format pixel_format();
|
||||||
inline wuffs_base__pixel_subsampling pixel_subsampling();
|
inline wuffs_base__pixel_subsampling pixel_subsampling();
|
||||||
inline wuffs_base__rect_ie_u32 bounds();
|
inline wuffs_base__rect_ie_u32 bounds();
|
||||||
@@ -1384,7 +1562,6 @@ typedef struct {
|
|||||||
inline uint32_t height();
|
inline uint32_t height();
|
||||||
inline uint32_t num_loops();
|
inline uint32_t num_loops();
|
||||||
inline uint32_t first_frame_is_opaque();
|
inline uint32_t first_frame_is_opaque();
|
||||||
inline size_t pixbuf_size();
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
} wuffs_base__image_config;
|
} wuffs_base__image_config;
|
||||||
@@ -1401,18 +1578,14 @@ wuffs_base__image_config__initialize(wuffs_base__image_config* c,
|
|||||||
if (!c) {
|
if (!c) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pixfmt) {
|
if (wuffs_base__pixel_format__is_valid(pixfmt)) {
|
||||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
c->private_impl.pixcfg.private_impl.pixfmt = pixfmt;
|
||||||
// TODO: handle things other than 1 byte per pixel.
|
c->private_impl.pixcfg.private_impl.pixsub = pixsub;
|
||||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
c->private_impl.pixcfg.private_impl.width = width;
|
||||||
c->private_impl.pixfmt = pixfmt;
|
c->private_impl.pixcfg.private_impl.height = height;
|
||||||
c->private_impl.pixsub = pixsub;
|
c->private_impl.num_loops = num_loops;
|
||||||
c->private_impl.width = width;
|
c->private_impl.first_frame_is_opaque = first_frame_is_opaque;
|
||||||
c->private_impl.height = height;
|
return;
|
||||||
c->private_impl.num_loops = num_loops;
|
|
||||||
c->private_impl.first_frame_is_opaque = first_frame_is_opaque;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*c = ((wuffs_base__image_config){});
|
*c = ((wuffs_base__image_config){});
|
||||||
}
|
}
|
||||||
@@ -1426,17 +1599,22 @@ wuffs_base__image_config__invalidate(wuffs_base__image_config* c) {
|
|||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__image_config__is_valid(wuffs_base__image_config* c) {
|
wuffs_base__image_config__is_valid(wuffs_base__image_config* c) {
|
||||||
return c && c->private_impl.pixfmt;
|
return c && wuffs_base__pixel_config__is_valid(&(c->private_impl.pixcfg));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline wuffs_base__pixel_config* //
|
||||||
|
wuffs_base__image_config__pixel_config(wuffs_base__image_config* c) {
|
||||||
|
return c ? &c->private_impl.pixcfg : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline wuffs_base__pixel_format //
|
static inline wuffs_base__pixel_format //
|
||||||
wuffs_base__image_config__pixel_format(wuffs_base__image_config* c) {
|
wuffs_base__image_config__pixel_format(wuffs_base__image_config* c) {
|
||||||
return c ? c->private_impl.pixfmt : 0;
|
return c ? c->private_impl.pixcfg.private_impl.pixfmt : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline wuffs_base__pixel_subsampling //
|
static inline wuffs_base__pixel_subsampling //
|
||||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||||
return c ? c->private_impl.pixsub : 0;
|
return c ? c->private_impl.pixcfg.private_impl.pixsub : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline wuffs_base__rect_ie_u32 //
|
static inline wuffs_base__rect_ie_u32 //
|
||||||
@@ -1444,20 +1622,20 @@ wuffs_base__image_config__bounds(wuffs_base__image_config* c) {
|
|||||||
return c ? ((wuffs_base__rect_ie_u32){
|
return c ? ((wuffs_base__rect_ie_u32){
|
||||||
.min_incl_x = 0,
|
.min_incl_x = 0,
|
||||||
.min_incl_y = 0,
|
.min_incl_y = 0,
|
||||||
.max_excl_x = c->private_impl.width,
|
.max_excl_x = c->private_impl.pixcfg.private_impl.width,
|
||||||
.max_excl_y = c->private_impl.height,
|
.max_excl_y = c->private_impl.pixcfg.private_impl.height,
|
||||||
})
|
})
|
||||||
: ((wuffs_base__rect_ie_u32){});
|
: ((wuffs_base__rect_ie_u32){});
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t //
|
static inline uint32_t //
|
||||||
wuffs_base__image_config__width(wuffs_base__image_config* c) {
|
wuffs_base__image_config__width(wuffs_base__image_config* c) {
|
||||||
return c ? c->private_impl.width : 0;
|
return c ? c->private_impl.pixcfg.private_impl.width : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t //
|
static inline uint32_t //
|
||||||
wuffs_base__image_config__height(wuffs_base__image_config* c) {
|
wuffs_base__image_config__height(wuffs_base__image_config* c) {
|
||||||
return c ? c->private_impl.height : 0;
|
return c ? c->private_impl.pixcfg.private_impl.height : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t //
|
static inline uint32_t //
|
||||||
@@ -1470,20 +1648,6 @@ wuffs_base__image_config__first_frame_is_opaque(wuffs_base__image_config* c) {
|
|||||||
return c ? c->private_impl.first_frame_is_opaque : false;
|
return c ? c->private_impl.first_frame_is_opaque : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
|
||||||
// decoding into a color model different from the format's intrinsic one? For
|
|
||||||
// example, decoding a JPEG image straight to RGBA instead of to YCbCr?
|
|
||||||
static inline size_t //
|
|
||||||
wuffs_base__image_config__pixbuf_size(wuffs_base__image_config* c) {
|
|
||||||
if (c) {
|
|
||||||
uint64_t wh =
|
|
||||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
|
||||||
// TODO: handle things other than 1 byte per pixel.
|
|
||||||
return (size_t)wh;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
inline void //
|
inline void //
|
||||||
@@ -1507,6 +1671,11 @@ wuffs_base__image_config::is_valid() {
|
|||||||
return wuffs_base__image_config__is_valid(this);
|
return wuffs_base__image_config__is_valid(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline wuffs_base__pixel_config* //
|
||||||
|
wuffs_base__image_config::pixel_config() {
|
||||||
|
return wuffs_base__image_config__pixel_config(this);
|
||||||
|
}
|
||||||
|
|
||||||
inline wuffs_base__pixel_format //
|
inline wuffs_base__pixel_format //
|
||||||
wuffs_base__image_config::pixel_format() {
|
wuffs_base__image_config::pixel_format() {
|
||||||
return wuffs_base__image_config__pixel_format(this);
|
return wuffs_base__image_config__pixel_format(this);
|
||||||
@@ -1542,11 +1711,6 @@ wuffs_base__image_config::first_frame_is_opaque() {
|
|||||||
return wuffs_base__image_config__first_frame_is_opaque(this);
|
return wuffs_base__image_config__first_frame_is_opaque(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline size_t //
|
|
||||||
wuffs_base__image_config::pixbuf_size() {
|
|
||||||
return wuffs_base__image_config__pixbuf_size(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
@@ -1573,260 +1737,284 @@ typedef struct {
|
|||||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||||
// compatibility or safety guarantee if you do so.
|
// compatibility or safety guarantee if you do so.
|
||||||
struct {
|
struct {
|
||||||
wuffs_base__image_config config;
|
wuffs_base__rect_ie_u32 bounds;
|
||||||
wuffs_base__pixel_buffer pixbuf;
|
|
||||||
// TODO: color spaces.
|
|
||||||
wuffs_base__rect_ie_u32 dirty_rect;
|
|
||||||
wuffs_base__flicks duration;
|
wuffs_base__flicks duration;
|
||||||
bool blend;
|
bool blend;
|
||||||
wuffs_base__animation_disposal disposal;
|
wuffs_base__animation_disposal disposal;
|
||||||
bool palette_changed;
|
bool palette_changed;
|
||||||
uint8_t palette[1024];
|
|
||||||
} private_impl;
|
} private_impl;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
inline wuffs_base__status set_from_pixbuf(wuffs_base__image_config config,
|
inline void update(wuffs_base__rect_ie_u32 bounds,
|
||||||
wuffs_base__pixel_buffer pixbuf);
|
|
||||||
inline wuffs_base__status set_from_slice(wuffs_base__image_config config,
|
|
||||||
wuffs_base__slice_u8 pixbuf_memory);
|
|
||||||
inline void update(wuffs_base__rect_ie_u32 dirty_rect,
|
|
||||||
wuffs_base__flicks duration,
|
wuffs_base__flicks duration,
|
||||||
bool blend,
|
bool blend,
|
||||||
wuffs_base__animation_disposal disposal,
|
wuffs_base__animation_disposal disposal,
|
||||||
wuffs_base__slice_u8 palette);
|
bool palette_changed);
|
||||||
inline wuffs_base__image_config* image_config();
|
|
||||||
inline wuffs_base__rect_ie_u32 bounds();
|
inline wuffs_base__rect_ie_u32 bounds();
|
||||||
inline uint32_t width();
|
inline uint32_t width();
|
||||||
inline uint32_t height();
|
inline uint32_t height();
|
||||||
inline wuffs_base__rect_ie_u32 dirty_rect();
|
|
||||||
inline wuffs_base__flicks duration();
|
inline wuffs_base__flicks duration();
|
||||||
inline bool blend();
|
inline bool blend();
|
||||||
inline wuffs_base__animation_disposal disposal();
|
inline wuffs_base__animation_disposal disposal();
|
||||||
inline bool palette_changed();
|
inline bool palette_changed();
|
||||||
inline wuffs_base__slice_u8 palette();
|
|
||||||
inline wuffs_base__table_u8 plane(uint32_t p);
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
} wuffs_base__image_buffer;
|
} wuffs_base__frame_config;
|
||||||
|
|
||||||
static inline wuffs_base__status //
|
|
||||||
wuffs_base__image_buffer__set_from_pixbuf(wuffs_base__image_buffer* b,
|
|
||||||
wuffs_base__image_config config,
|
|
||||||
wuffs_base__pixel_buffer pixbuf) {
|
|
||||||
if (!b) {
|
|
||||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
|
||||||
}
|
|
||||||
*b = ((wuffs_base__image_buffer){});
|
|
||||||
b->private_impl.config = config;
|
|
||||||
b->private_impl.pixbuf = pixbuf;
|
|
||||||
return WUFFS_BASE__STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline wuffs_base__status //
|
|
||||||
wuffs_base__image_buffer__set_from_slice(wuffs_base__image_buffer* b,
|
|
||||||
wuffs_base__image_config config,
|
|
||||||
wuffs_base__slice_u8 pixbuf_memory) {
|
|
||||||
if (!b) {
|
|
||||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
|
||||||
}
|
|
||||||
*b = ((wuffs_base__image_buffer){});
|
|
||||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
|
||||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
|
||||||
((uint64_t)config.private_impl.height);
|
|
||||||
if (wh > pixbuf_memory.len) {
|
|
||||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
|
||||||
}
|
|
||||||
b->private_impl.config = config;
|
|
||||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
|
||||||
tab->ptr = pixbuf_memory.ptr;
|
|
||||||
tab->width = config.private_impl.width;
|
|
||||||
tab->height = config.private_impl.height;
|
|
||||||
tab->stride = config.private_impl.width;
|
|
||||||
return WUFFS_BASE__STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The palette argument is ignored unless its length is exactly 1024.
|
|
||||||
static inline void //
|
static inline void //
|
||||||
wuffs_base__image_buffer__update(wuffs_base__image_buffer* b,
|
wuffs_base__frame_config__update(wuffs_base__frame_config* c,
|
||||||
wuffs_base__rect_ie_u32 dirty_rect,
|
wuffs_base__rect_ie_u32 bounds,
|
||||||
wuffs_base__flicks duration,
|
wuffs_base__flicks duration,
|
||||||
bool blend,
|
bool blend,
|
||||||
wuffs_base__animation_disposal disposal,
|
wuffs_base__animation_disposal disposal,
|
||||||
wuffs_base__slice_u8 palette) {
|
bool palette_changed) {
|
||||||
if (!b) {
|
if (!c) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clip the dirty_rect to the image bounds.
|
c->private_impl.bounds = bounds;
|
||||||
dirty_rect.max_excl_x = wuffs_base__u32__min(
|
c->private_impl.duration = duration;
|
||||||
dirty_rect.max_excl_x, b->private_impl.config.private_impl.width);
|
c->private_impl.blend = blend;
|
||||||
dirty_rect.max_excl_y = wuffs_base__u32__min(
|
c->private_impl.disposal = disposal;
|
||||||
dirty_rect.max_excl_y, b->private_impl.config.private_impl.height);
|
c->private_impl.palette_changed = palette_changed;
|
||||||
b->private_impl.dirty_rect = dirty_rect;
|
|
||||||
|
|
||||||
b->private_impl.duration = duration;
|
|
||||||
b->private_impl.blend = blend;
|
|
||||||
b->private_impl.disposal = disposal;
|
|
||||||
b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);
|
|
||||||
if (b->private_impl.palette_changed) {
|
|
||||||
memmove(b->private_impl.palette, palette.ptr, 1024);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// wuffs_base__image_config returns the overall configuration for this frame.
|
|
||||||
static inline wuffs_base__image_config* //
|
|
||||||
wuffs_base__image_buffer__image_config(wuffs_base__image_buffer* b) {
|
|
||||||
return b ? &b->private_impl.config : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline wuffs_base__rect_ie_u32 //
|
static inline wuffs_base__rect_ie_u32 //
|
||||||
wuffs_base__image_buffer__bounds(wuffs_base__image_buffer* b) {
|
wuffs_base__frame_config__bounds(wuffs_base__frame_config* c) {
|
||||||
return b ? wuffs_base__image_config__bounds(&b->private_impl.config)
|
return c ? c->private_impl.bounds : ((wuffs_base__rect_ie_u32){});
|
||||||
: ((wuffs_base__rect_ie_u32){});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t //
|
static inline uint32_t //
|
||||||
wuffs_base__image_buffer__width(wuffs_base__image_buffer* b) {
|
wuffs_base__frame_config__width(wuffs_base__frame_config* c) {
|
||||||
return b ? wuffs_base__image_config__width(&b->private_impl.config) : 0;
|
return c ? wuffs_base__rect_ie_u32__width(&c->private_impl.bounds) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t //
|
static inline uint32_t //
|
||||||
wuffs_base__image_buffer__height(wuffs_base__image_buffer* b) {
|
wuffs_base__frame_config__height(wuffs_base__frame_config* c) {
|
||||||
return b ? wuffs_base__image_config__height(&b->private_impl.config) : 0;
|
return c ? wuffs_base__rect_ie_u32__height(&c->private_impl.bounds) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
|
// wuffs_base__frame_config__duration returns the amount of time to display
|
||||||
// this frame's pixels differs from the previous frame.
|
|
||||||
static inline wuffs_base__rect_ie_u32 //
|
|
||||||
wuffs_base__image_buffer__dirty_rect(wuffs_base__image_buffer* b) {
|
|
||||||
return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){});
|
|
||||||
}
|
|
||||||
|
|
||||||
// wuffs_base__image_buffer__duration returns the amount of time to display
|
|
||||||
// this frame. Zero means to display forever - a still (non-animated) image.
|
// this frame. Zero means to display forever - a still (non-animated) image.
|
||||||
static inline wuffs_base__flicks //
|
static inline wuffs_base__flicks //
|
||||||
wuffs_base__image_buffer__duration(wuffs_base__image_buffer* b) {
|
wuffs_base__frame_config__duration(wuffs_base__frame_config* c) {
|
||||||
return b ? b->private_impl.duration : 0;
|
return c ? c->private_impl.duration : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wuffs_base__image_buffer__blend returns, for a transparent image, whether to
|
// wuffs_base__frame_config__blend returns, for a transparent image, whether to
|
||||||
// blend this frame with the existing canvas.
|
// blend this frame with the existing canvas.
|
||||||
//
|
//
|
||||||
// In Porter-Duff compositing operator terminology, false means "src" and true
|
// In Porter-Duff compositing operator terminology, false means "src" and true
|
||||||
// means "src over dst".
|
// means "src over dst".
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__image_buffer__blend(wuffs_base__image_buffer* b) {
|
wuffs_base__frame_config__blend(wuffs_base__frame_config* c) {
|
||||||
return b && b->private_impl.blend;
|
return c && c->private_impl.blend;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wuffs_base__image_buffer__disposal returns, for an animated image, how to
|
// wuffs_base__frame_config__disposal returns, for an animated image, how to
|
||||||
// dispose of this frame after displaying it.
|
// dispose of this frame after displaying it.
|
||||||
static inline wuffs_base__animation_disposal //
|
static inline wuffs_base__animation_disposal //
|
||||||
wuffs_base__image_buffer__disposal(wuffs_base__image_buffer* b) {
|
wuffs_base__frame_config__disposal(wuffs_base__frame_config* c) {
|
||||||
return b ? b->private_impl.disposal : 0;
|
return c ? c->private_impl.disposal : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wuffs_base__image_buffer__palette_changed returns whether this frame's
|
// wuffs_base__frame_config__palette_changed returns whether this frame's
|
||||||
// palette differs from the previous frame. It is conservative and may return
|
// palette differs from the previous frame. It is conservative and may return
|
||||||
// false positives (but never false negatives).
|
// false positives (but never false negatives).
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__image_buffer__palette_changed(wuffs_base__image_buffer* b) {
|
wuffs_base__frame_config__palette_changed(wuffs_base__frame_config* c) {
|
||||||
return b && b->private_impl.palette_changed;
|
return c && c->private_impl.palette_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wuffs_base__image_buffer__palette returns the palette that the pixel data
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
inline void //
|
||||||
|
wuffs_base__frame_config::update(wuffs_base__rect_ie_u32 bounds,
|
||||||
|
wuffs_base__flicks duration,
|
||||||
|
bool blend,
|
||||||
|
wuffs_base__animation_disposal disposal,
|
||||||
|
bool palette_changed) {
|
||||||
|
wuffs_base__frame_config__update(this, bounds, duration, blend, disposal,
|
||||||
|
palette_changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wuffs_base__rect_ie_u32 //
|
||||||
|
wuffs_base__frame_config::bounds() {
|
||||||
|
return wuffs_base__frame_config__bounds(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint32_t //
|
||||||
|
wuffs_base__frame_config::width() {
|
||||||
|
return wuffs_base__frame_config__width(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint32_t //
|
||||||
|
wuffs_base__frame_config::height() {
|
||||||
|
return wuffs_base__frame_config__height(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wuffs_base__flicks //
|
||||||
|
wuffs_base__frame_config::duration() {
|
||||||
|
return wuffs_base__frame_config__duration(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool //
|
||||||
|
wuffs_base__frame_config::blend() {
|
||||||
|
return wuffs_base__frame_config__blend(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wuffs_base__animation_disposal //
|
||||||
|
wuffs_base__frame_config::disposal() {
|
||||||
|
return wuffs_base__frame_config__disposal(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool //
|
||||||
|
wuffs_base__frame_config::palette_changed() {
|
||||||
|
return wuffs_base__frame_config__palette_changed(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
// --------
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||||
|
// compatibility or safety guarantee if you do so.
|
||||||
|
struct {
|
||||||
|
wuffs_base__pixel_config pixcfg;
|
||||||
|
wuffs_base__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX];
|
||||||
|
uint8_t palette[1024];
|
||||||
|
// TODO: color spaces.
|
||||||
|
} private_impl;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
inline wuffs_base__status set_from_slice(wuffs_base__pixel_config* pixcfg,
|
||||||
|
wuffs_base__slice_u8 pixbuf_memory);
|
||||||
|
inline void set_palette(wuffs_base__slice_u8 palette);
|
||||||
|
inline wuffs_base__pixel_config* pixel_config();
|
||||||
|
inline wuffs_base__rect_ie_u32 bounds();
|
||||||
|
inline uint32_t width();
|
||||||
|
inline uint32_t height();
|
||||||
|
inline wuffs_base__table_u8 plane(uint32_t p);
|
||||||
|
inline wuffs_base__slice_u8 palette();
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
} wuffs_base__pixel_buffer;
|
||||||
|
|
||||||
|
static inline wuffs_base__status //
|
||||||
|
wuffs_base__pixel_buffer__set_from_slice(wuffs_base__pixel_buffer* b,
|
||||||
|
wuffs_base__pixel_config* pixcfg,
|
||||||
|
wuffs_base__slice_u8 pixbuf_memory) {
|
||||||
|
if (!b) {
|
||||||
|
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||||
|
}
|
||||||
|
*b = ((wuffs_base__pixel_buffer){});
|
||||||
|
if (!pixcfg) {
|
||||||
|
return WUFFS_BASE__ERROR_BAD_ARGUMENT;
|
||||||
|
}
|
||||||
|
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||||
|
uint64_t wh = ((uint64_t)pixcfg->private_impl.width) *
|
||||||
|
((uint64_t)pixcfg->private_impl.height);
|
||||||
|
if (wh > pixbuf_memory.len) {
|
||||||
|
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||||
|
}
|
||||||
|
b->private_impl.pixcfg = *pixcfg;
|
||||||
|
wuffs_base__table_u8* tab = &b->private_impl.planes[0];
|
||||||
|
tab->ptr = pixbuf_memory.ptr;
|
||||||
|
tab->width = pixcfg->private_impl.width;
|
||||||
|
tab->height = pixcfg->private_impl.height;
|
||||||
|
tab->stride = pixcfg->private_impl.width;
|
||||||
|
return WUFFS_BASE__STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The palette argument is ignored unless its length is exactly 1024.
|
||||||
|
static inline void //
|
||||||
|
wuffs_base__pixel_buffer__set_palette(wuffs_base__pixel_buffer* b,
|
||||||
|
wuffs_base__slice_u8 palette) {
|
||||||
|
if (b && palette.ptr && (palette.len == 1024)) {
|
||||||
|
memmove(b->private_impl.palette, palette.ptr, 1024);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wuffs_base__pixel_config returns the overall configuration for this frame.
|
||||||
|
static inline wuffs_base__pixel_config* //
|
||||||
|
wuffs_base__pixel_buffer__pixel_config(wuffs_base__pixel_buffer* b) {
|
||||||
|
return b ? &b->private_impl.pixcfg : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline wuffs_base__rect_ie_u32 //
|
||||||
|
wuffs_base__pixel_buffer__bounds(wuffs_base__pixel_buffer* b) {
|
||||||
|
return b ? wuffs_base__pixel_config__bounds(&b->private_impl.pixcfg)
|
||||||
|
: ((wuffs_base__rect_ie_u32){});
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t //
|
||||||
|
wuffs_base__pixel_buffer__width(wuffs_base__pixel_buffer* b) {
|
||||||
|
return b ? wuffs_base__pixel_config__width(&b->private_impl.pixcfg) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t //
|
||||||
|
wuffs_base__pixel_buffer__height(wuffs_base__pixel_buffer* b) {
|
||||||
|
return b ? wuffs_base__pixel_config__height(&b->private_impl.pixcfg) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline wuffs_base__table_u8 //
|
||||||
|
wuffs_base__pixel_buffer__plane(wuffs_base__pixel_buffer* b, uint32_t p) {
|
||||||
|
return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))
|
||||||
|
? b->private_impl.planes[p]
|
||||||
|
: ((wuffs_base__table_u8){});
|
||||||
|
}
|
||||||
|
|
||||||
|
// wuffs_base__pixel_buffer__palette returns the palette that the pixel data
|
||||||
// can index. The backing array is inside b and has length 1024.
|
// can index. The backing array is inside b and has length 1024.
|
||||||
static inline wuffs_base__slice_u8 //
|
static inline wuffs_base__slice_u8 //
|
||||||
wuffs_base__image_buffer__palette(wuffs_base__image_buffer* b) {
|
wuffs_base__pixel_buffer__palette(wuffs_base__pixel_buffer* b) {
|
||||||
return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,
|
return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,
|
||||||
.len = 1024})
|
.len = 1024})
|
||||||
: ((wuffs_base__slice_u8){});
|
: ((wuffs_base__slice_u8){});
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline wuffs_base__table_u8 //
|
|
||||||
wuffs_base__image_buffer__plane(wuffs_base__image_buffer* b, uint32_t p) {
|
|
||||||
return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))
|
|
||||||
? b->private_impl.pixbuf.planes[p]
|
|
||||||
: ((wuffs_base__table_u8){});
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
inline wuffs_base__status //
|
inline wuffs_base__status //
|
||||||
wuffs_base__image_buffer::set_from_pixbuf(wuffs_base__image_config config,
|
wuffs_base__pixel_buffer::set_from_slice(wuffs_base__pixel_config* pixcfg,
|
||||||
wuffs_base__pixel_buffer pixbuf) {
|
|
||||||
return wuffs_base__image_buffer__set_from_pixbuf(this, config, pixbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline wuffs_base__status //
|
|
||||||
wuffs_base__image_buffer::set_from_slice(wuffs_base__image_config config,
|
|
||||||
wuffs_base__slice_u8 pixbuf_memory) {
|
wuffs_base__slice_u8 pixbuf_memory) {
|
||||||
return wuffs_base__image_buffer__set_from_slice(this, config, pixbuf_memory);
|
return wuffs_base__pixel_buffer__set_from_slice(this, pixcfg, pixbuf_memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void //
|
inline void //
|
||||||
wuffs_base__image_buffer::update(wuffs_base__rect_ie_u32 dirty_rect,
|
wuffs_base__pixel_buffer::set_palette(wuffs_base__slice_u8 palette) {
|
||||||
wuffs_base__flicks duration,
|
wuffs_base__pixel_buffer__set_palette(this, palette);
|
||||||
bool blend,
|
|
||||||
wuffs_base__animation_disposal disposal,
|
|
||||||
wuffs_base__slice_u8 palette) {
|
|
||||||
wuffs_base__image_buffer__update(this, dirty_rect, duration, blend, disposal,
|
|
||||||
palette);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline wuffs_base__image_config* //
|
inline wuffs_base__pixel_config* //
|
||||||
wuffs_base__image_buffer::image_config() {
|
wuffs_base__pixel_buffer::pixel_config() {
|
||||||
return wuffs_base__image_buffer__image_config(this);
|
return wuffs_base__pixel_buffer__pixel_config(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline wuffs_base__rect_ie_u32 //
|
inline wuffs_base__rect_ie_u32 //
|
||||||
wuffs_base__image_buffer::bounds() {
|
wuffs_base__pixel_buffer::bounds() {
|
||||||
return wuffs_base__image_buffer__bounds(this);
|
return wuffs_base__pixel_buffer__bounds(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32_t //
|
inline uint32_t //
|
||||||
wuffs_base__image_buffer::width() {
|
wuffs_base__pixel_buffer::width() {
|
||||||
return wuffs_base__image_buffer__width(this);
|
return wuffs_base__pixel_buffer__width(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32_t //
|
inline uint32_t //
|
||||||
wuffs_base__image_buffer::height() {
|
wuffs_base__pixel_buffer::height() {
|
||||||
return wuffs_base__image_buffer__height(this);
|
return wuffs_base__pixel_buffer__height(this);
|
||||||
}
|
|
||||||
|
|
||||||
inline wuffs_base__rect_ie_u32 //
|
|
||||||
wuffs_base__image_buffer::dirty_rect() {
|
|
||||||
return wuffs_base__image_buffer__dirty_rect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline wuffs_base__flicks //
|
|
||||||
wuffs_base__image_buffer::duration() {
|
|
||||||
return wuffs_base__image_buffer__duration(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool //
|
|
||||||
wuffs_base__image_buffer::blend() {
|
|
||||||
return wuffs_base__image_buffer__blend(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline wuffs_base__animation_disposal //
|
|
||||||
wuffs_base__image_buffer::disposal() {
|
|
||||||
return wuffs_base__image_buffer__disposal(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool //
|
|
||||||
wuffs_base__image_buffer::palette_changed() {
|
|
||||||
return wuffs_base__image_buffer__palette_changed(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline wuffs_base__slice_u8 //
|
|
||||||
wuffs_base__image_buffer::palette() {
|
|
||||||
return wuffs_base__image_buffer__palette(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline wuffs_base__table_u8 //
|
inline wuffs_base__table_u8 //
|
||||||
wuffs_base__image_buffer::plane(uint32_t p) {
|
wuffs_base__pixel_buffer::plane(uint32_t p) {
|
||||||
return wuffs_base__image_buffer__plane(this, p);
|
return wuffs_base__pixel_buffer__plane(this, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wuffs_base__slice_u8 //
|
||||||
|
wuffs_base__pixel_buffer::palette() {
|
||||||
|
return wuffs_base__pixel_buffer__palette(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
@@ -2340,6 +2528,7 @@ typedef struct {
|
|||||||
bool f_has_full_global_palette;
|
bool f_has_full_global_palette;
|
||||||
bool f_has_full_palette;
|
bool f_has_full_palette;
|
||||||
bool f_use_local_palette;
|
bool f_use_local_palette;
|
||||||
|
uint8_t f_which_palette;
|
||||||
uint8_t f_interlace;
|
uint8_t f_interlace;
|
||||||
bool f_seen_num_loops;
|
bool f_seen_num_loops;
|
||||||
uint32_t f_num_loops;
|
uint32_t f_num_loops;
|
||||||
@@ -2367,6 +2556,13 @@ typedef struct {
|
|||||||
uint32_t v_num_loops;
|
uint32_t v_num_loops;
|
||||||
bool v_ffio;
|
bool v_ffio;
|
||||||
} c_decode_image_config[1];
|
} c_decode_image_config[1];
|
||||||
|
struct {
|
||||||
|
uint32_t coro_susp_point;
|
||||||
|
} c_decode_frame_config[1];
|
||||||
|
struct {
|
||||||
|
uint32_t coro_susp_point;
|
||||||
|
uint8_t v_lw;
|
||||||
|
} c_skip_frame[1];
|
||||||
struct {
|
struct {
|
||||||
uint32_t coro_susp_point;
|
uint32_t coro_susp_point;
|
||||||
} c_decode_frame[1];
|
} c_decode_frame[1];
|
||||||
@@ -2433,9 +2629,13 @@ typedef struct {
|
|||||||
wuffs_base__io_reader a_src);
|
wuffs_base__io_reader a_src);
|
||||||
inline uint64_t frame_count();
|
inline uint64_t frame_count();
|
||||||
inline wuffs_base__range_ii_u64 work_buffer_size();
|
inline wuffs_base__range_ii_u64 work_buffer_size();
|
||||||
inline wuffs_base__status decode_frame(wuffs_base__image_buffer* a_dst,
|
inline wuffs_base__status decode_frame_config(wuffs_base__frame_config* a_dst,
|
||||||
|
wuffs_base__io_reader a_src);
|
||||||
|
inline wuffs_base__status decode_frame(wuffs_base__pixel_buffer* a_dst,
|
||||||
wuffs_base__io_reader a_src,
|
wuffs_base__io_reader a_src,
|
||||||
wuffs_base__slice_u8 a_work_buffer);
|
wuffs_base__slice_u8 a_work_buffer,
|
||||||
|
uint32_t a_pixbuf_origin_x,
|
||||||
|
uint32_t a_pixbuf_origin_y);
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
} wuffs_gif__decoder;
|
} wuffs_gif__decoder;
|
||||||
@@ -2464,11 +2664,18 @@ wuffs_gif__decoder__frame_count(wuffs_gif__decoder* self);
|
|||||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64 //
|
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64 //
|
||||||
wuffs_gif__decoder__work_buffer_size(wuffs_gif__decoder* self);
|
wuffs_gif__decoder__work_buffer_size(wuffs_gif__decoder* self);
|
||||||
|
|
||||||
|
WUFFS_BASE__MAYBE_STATIC wuffs_base__status //
|
||||||
|
wuffs_gif__decoder__decode_frame_config(wuffs_gif__decoder* self,
|
||||||
|
wuffs_base__frame_config* a_dst,
|
||||||
|
wuffs_base__io_reader a_src);
|
||||||
|
|
||||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status //
|
WUFFS_BASE__MAYBE_STATIC wuffs_base__status //
|
||||||
wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_dst,
|
wuffs_base__pixel_buffer* a_dst,
|
||||||
wuffs_base__io_reader a_src,
|
wuffs_base__io_reader a_src,
|
||||||
wuffs_base__slice_u8 a_work_buffer);
|
wuffs_base__slice_u8 a_work_buffer,
|
||||||
|
uint32_t a_pixbuf_origin_x,
|
||||||
|
uint32_t a_pixbuf_origin_y);
|
||||||
|
|
||||||
// ---------------- C++ Convenience Methods
|
// ---------------- C++ Convenience Methods
|
||||||
|
|
||||||
@@ -2498,10 +2705,19 @@ wuffs_gif__decoder::work_buffer_size() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline wuffs_base__status //
|
inline wuffs_base__status //
|
||||||
wuffs_gif__decoder::decode_frame(wuffs_base__image_buffer* a_dst,
|
wuffs_gif__decoder::decode_frame_config(wuffs_base__frame_config* a_dst,
|
||||||
|
wuffs_base__io_reader a_src) {
|
||||||
|
return wuffs_gif__decoder__decode_frame_config(this, a_dst, a_src);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wuffs_base__status //
|
||||||
|
wuffs_gif__decoder::decode_frame(wuffs_base__pixel_buffer* a_dst,
|
||||||
wuffs_base__io_reader a_src,
|
wuffs_base__io_reader a_src,
|
||||||
wuffs_base__slice_u8 a_work_buffer) {
|
wuffs_base__slice_u8 a_work_buffer,
|
||||||
return wuffs_gif__decoder__decode_frame(this, a_dst, a_src, a_work_buffer);
|
uint32_t a_pixbuf_origin_x,
|
||||||
|
uint32_t a_pixbuf_origin_y) {
|
||||||
|
return wuffs_gif__decoder__decode_frame(this, a_dst, a_src, a_work_buffer,
|
||||||
|
a_pixbuf_origin_x, a_pixbuf_origin_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
@@ -6437,6 +6653,10 @@ static const uint8_t wuffs_gif__netscape2dot0[11] = {
|
|||||||
|
|
||||||
// ---------------- Private Function Prototypes
|
// ---------------- Private Function Prototypes
|
||||||
|
|
||||||
|
static wuffs_base__status //
|
||||||
|
wuffs_gif__decoder__skip_frame(wuffs_gif__decoder* self,
|
||||||
|
wuffs_base__io_reader a_src);
|
||||||
|
|
||||||
static wuffs_base__status //
|
static wuffs_base__status //
|
||||||
wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
||||||
wuffs_base__io_reader a_src);
|
wuffs_base__io_reader a_src);
|
||||||
@@ -6471,12 +6691,12 @@ wuffs_gif__decoder__decode_id_part0(wuffs_gif__decoder* self,
|
|||||||
|
|
||||||
static wuffs_base__status //
|
static wuffs_base__status //
|
||||||
wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_dst,
|
wuffs_base__pixel_buffer* a_dst,
|
||||||
wuffs_base__io_reader a_src);
|
wuffs_base__io_reader a_src);
|
||||||
|
|
||||||
static wuffs_base__status //
|
static wuffs_base__status //
|
||||||
wuffs_gif__decoder__copy_to_image_buffer(wuffs_gif__decoder* self,
|
wuffs_gif__decoder__copy_to_image_buffer(wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_ib);
|
wuffs_base__pixel_buffer* a_pb);
|
||||||
|
|
||||||
// ---------------- Initializer Implementations
|
// ---------------- Initializer Implementations
|
||||||
|
|
||||||
@@ -6632,13 +6852,199 @@ wuffs_gif__decoder__work_buffer_size(wuffs_gif__decoder* self) {
|
|||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------- func gif.decoder.decode_frame_config
|
||||||
|
|
||||||
|
WUFFS_BASE__MAYBE_STATIC wuffs_base__status //
|
||||||
|
wuffs_gif__decoder__decode_frame_config(wuffs_gif__decoder* self,
|
||||||
|
wuffs_base__frame_config* a_dst,
|
||||||
|
wuffs_base__io_reader a_src) {
|
||||||
|
if (!self) {
|
||||||
|
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||||
|
}
|
||||||
|
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||||
|
self->private_impl.status =
|
||||||
|
WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED;
|
||||||
|
}
|
||||||
|
if (self->private_impl.status < 0) {
|
||||||
|
return self->private_impl.status;
|
||||||
|
}
|
||||||
|
wuffs_base__status status = WUFFS_BASE__STATUS_OK;
|
||||||
|
|
||||||
|
uint32_t coro_susp_point =
|
||||||
|
self->private_impl.c_decode_frame_config[0].coro_susp_point;
|
||||||
|
if (coro_susp_point) {
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
switch (coro_susp_point) {
|
||||||
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
|
|
||||||
|
if (!self->private_impl.f_end_of_data) {
|
||||||
|
if (self->private_impl.f_call_sequence == 0) {
|
||||||
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||||
|
status = wuffs_gif__decoder__decode_image_config(self, NULL, a_src);
|
||||||
|
if (status) {
|
||||||
|
goto suspend;
|
||||||
|
}
|
||||||
|
} else if (self->private_impl.f_call_sequence == 1) {
|
||||||
|
} else if (self->private_impl.f_call_sequence == 2) {
|
||||||
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||||
|
status = wuffs_gif__decoder__skip_frame(self, a_src);
|
||||||
|
if (status) {
|
||||||
|
goto suspend;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||||
|
status = wuffs_gif__decoder__decode_up_to_id_part1(self, a_src);
|
||||||
|
if (status) {
|
||||||
|
goto suspend;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (self->private_impl.f_end_of_data) {
|
||||||
|
while (true) {
|
||||||
|
status = WUFFS_BASE__SUSPENSION_END_OF_DATA;
|
||||||
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (self->private_impl.f_use_local_palette ||
|
||||||
|
self->private_impl.f_gc_has_transparent_index) {
|
||||||
|
self->private_impl.f_which_palette = 1;
|
||||||
|
} else if (!self->private_impl.f_previous_use_global_palette) {
|
||||||
|
self->private_impl.f_which_palette = 0;
|
||||||
|
} else {
|
||||||
|
self->private_impl.f_which_palette = 2;
|
||||||
|
}
|
||||||
|
self->private_impl.f_previous_use_global_palette =
|
||||||
|
!(self->private_impl.f_use_local_palette ||
|
||||||
|
self->private_impl.f_gc_has_transparent_index);
|
||||||
|
if (a_dst != NULL) {
|
||||||
|
wuffs_base__frame_config__update(
|
||||||
|
a_dst,
|
||||||
|
wuffs_base__utility__make_rect_ie_u32(
|
||||||
|
&self->private_impl.f_util, self->private_impl.f_frame_rect_x0,
|
||||||
|
self->private_impl.f_frame_rect_y0,
|
||||||
|
self->private_impl.f_frame_rect_x1,
|
||||||
|
self->private_impl.f_frame_rect_y1),
|
||||||
|
self->private_impl.f_gc_duration, true,
|
||||||
|
self->private_impl.f_gc_disposal,
|
||||||
|
(self->private_impl.f_which_palette != 2));
|
||||||
|
}
|
||||||
|
self->private_impl.f_call_sequence = 2;
|
||||||
|
|
||||||
|
goto ok;
|
||||||
|
ok:
|
||||||
|
self->private_impl.c_decode_frame_config[0].coro_susp_point = 0;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto suspend;
|
||||||
|
suspend:
|
||||||
|
self->private_impl.c_decode_frame_config[0].coro_susp_point = coro_susp_point;
|
||||||
|
|
||||||
|
goto exit;
|
||||||
|
exit:
|
||||||
|
self->private_impl.status = status;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- func gif.decoder.skip_frame
|
||||||
|
|
||||||
|
static wuffs_base__status //
|
||||||
|
wuffs_gif__decoder__skip_frame(wuffs_gif__decoder* self,
|
||||||
|
wuffs_base__io_reader a_src) {
|
||||||
|
wuffs_base__status status = WUFFS_BASE__STATUS_OK;
|
||||||
|
|
||||||
|
uint8_t v_lw;
|
||||||
|
|
||||||
|
uint8_t* ioptr_src = NULL;
|
||||||
|
uint8_t* iobounds0orig_src = NULL;
|
||||||
|
uint8_t* iobounds1_src = NULL;
|
||||||
|
WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(iobounds0orig_src);
|
||||||
|
WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(iobounds1_src);
|
||||||
|
if (a_src.private_impl.buf) {
|
||||||
|
ioptr_src = a_src.private_impl.buf->ptr + a_src.private_impl.buf->ri;
|
||||||
|
if (!a_src.private_impl.bounds[0]) {
|
||||||
|
a_src.private_impl.bounds[0] = ioptr_src;
|
||||||
|
a_src.private_impl.bounds[1] =
|
||||||
|
a_src.private_impl.buf->ptr + a_src.private_impl.buf->wi;
|
||||||
|
}
|
||||||
|
iobounds0orig_src = a_src.private_impl.bounds[0];
|
||||||
|
iobounds1_src = a_src.private_impl.bounds[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t coro_susp_point = self->private_impl.c_skip_frame[0].coro_susp_point;
|
||||||
|
if (coro_susp_point) {
|
||||||
|
v_lw = self->private_impl.c_skip_frame[0].v_lw;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
switch (coro_susp_point) {
|
||||||
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
|
|
||||||
|
{
|
||||||
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||||
|
if (WUFFS_BASE__UNLIKELY(ioptr_src == iobounds1_src)) {
|
||||||
|
goto short_read_src;
|
||||||
|
}
|
||||||
|
uint8_t t_0 = *ioptr_src++;
|
||||||
|
v_lw = t_0;
|
||||||
|
}
|
||||||
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||||
|
if (a_src.private_impl.buf) {
|
||||||
|
a_src.private_impl.buf->ri = ioptr_src - a_src.private_impl.buf->ptr;
|
||||||
|
}
|
||||||
|
status = wuffs_gif__decoder__skip_blocks(self, a_src);
|
||||||
|
if (a_src.private_impl.buf) {
|
||||||
|
ioptr_src = a_src.private_impl.buf->ptr + a_src.private_impl.buf->ri;
|
||||||
|
}
|
||||||
|
if (status) {
|
||||||
|
goto suspend;
|
||||||
|
}
|
||||||
|
self->private_impl.f_seen_graphic_control = false;
|
||||||
|
self->private_impl.f_gc_has_transparent_index = false;
|
||||||
|
self->private_impl.f_gc_transparent_index = 0;
|
||||||
|
self->private_impl.f_gc_disposal = 0;
|
||||||
|
self->private_impl.f_gc_duration = 0;
|
||||||
|
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_frame_count_value,
|
||||||
|
1);
|
||||||
|
self->private_impl.f_call_sequence = 3;
|
||||||
|
|
||||||
|
goto ok;
|
||||||
|
ok:
|
||||||
|
self->private_impl.c_skip_frame[0].coro_susp_point = 0;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto suspend;
|
||||||
|
suspend:
|
||||||
|
self->private_impl.c_skip_frame[0].coro_susp_point = coro_susp_point;
|
||||||
|
self->private_impl.c_skip_frame[0].v_lw = v_lw;
|
||||||
|
|
||||||
|
goto exit;
|
||||||
|
exit:
|
||||||
|
if (a_src.private_impl.buf) {
|
||||||
|
a_src.private_impl.buf->ri = ioptr_src - a_src.private_impl.buf->ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
|
||||||
|
short_read_src:
|
||||||
|
if (wuffs_base__io_reader__is_eof(a_src)) {
|
||||||
|
status = WUFFS_BASE__ERROR_UNEXPECTED_EOF;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
status = WUFFS_BASE__SUSPENSION_SHORT_READ;
|
||||||
|
goto suspend;
|
||||||
|
}
|
||||||
|
|
||||||
// -------- func gif.decoder.decode_frame
|
// -------- func gif.decoder.decode_frame
|
||||||
|
|
||||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status //
|
WUFFS_BASE__MAYBE_STATIC wuffs_base__status //
|
||||||
wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_dst,
|
wuffs_base__pixel_buffer* a_dst,
|
||||||
wuffs_base__io_reader a_src,
|
wuffs_base__io_reader a_src,
|
||||||
wuffs_base__slice_u8 a_work_buffer) {
|
wuffs_base__slice_u8 a_work_buffer,
|
||||||
|
uint32_t a_pixbuf_origin_x,
|
||||||
|
uint32_t a_pixbuf_origin_y) {
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||||
}
|
}
|
||||||
@@ -6663,37 +7069,26 @@ wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
|||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
|
|
||||||
if (self->private_impl.f_call_sequence == 0) {
|
if (self->private_impl.f_call_sequence != 2) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||||
status = wuffs_gif__decoder__decode_image_config(self, NULL, a_src);
|
status = wuffs_gif__decoder__decode_frame_config(self, NULL, a_src);
|
||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!self->private_impl.f_end_of_data) {
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||||
if (self->private_impl.f_call_sequence == 1) {
|
|
||||||
self->private_impl.f_call_sequence = 2;
|
|
||||||
} else {
|
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
|
||||||
status = wuffs_gif__decoder__decode_up_to_id_part1(self, a_src);
|
|
||||||
if (status) {
|
|
||||||
goto suspend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self->private_impl.f_end_of_data) {
|
|
||||||
while (true) {
|
|
||||||
status = WUFFS_BASE__SUSPENSION_END_OF_DATA;
|
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
|
||||||
status = wuffs_gif__decoder__decode_id_part1(self, a_dst, a_src);
|
status = wuffs_gif__decoder__decode_id_part1(self, a_dst, a_src);
|
||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
|
self->private_impl.f_seen_graphic_control = false;
|
||||||
|
self->private_impl.f_gc_has_transparent_index = false;
|
||||||
|
self->private_impl.f_gc_transparent_index = 0;
|
||||||
|
self->private_impl.f_gc_disposal = 0;
|
||||||
|
self->private_impl.f_gc_duration = 0;
|
||||||
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_frame_count_value,
|
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_frame_count_value,
|
||||||
1);
|
1);
|
||||||
|
self->private_impl.f_call_sequence = 3;
|
||||||
|
|
||||||
goto ok;
|
goto ok;
|
||||||
ok:
|
ok:
|
||||||
@@ -7927,7 +8322,7 @@ short_read_src:
|
|||||||
|
|
||||||
static wuffs_base__status //
|
static wuffs_base__status //
|
||||||
wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_dst,
|
wuffs_base__pixel_buffer* a_dst,
|
||||||
wuffs_base__io_reader a_src) {
|
wuffs_base__io_reader a_src) {
|
||||||
wuffs_base__status status = WUFFS_BASE__STATUS_OK;
|
wuffs_base__status status = WUFFS_BASE__STATUS_OK;
|
||||||
|
|
||||||
@@ -7941,7 +8336,6 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
|||||||
WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(ioptr_w);
|
WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(ioptr_w);
|
||||||
WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(iobounds1_w);
|
WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(iobounds1_w);
|
||||||
wuffs_base__status v_z;
|
wuffs_base__status v_z;
|
||||||
wuffs_base__slice_u8 v_palette;
|
|
||||||
|
|
||||||
uint8_t* ioptr_src = NULL;
|
uint8_t* ioptr_src = NULL;
|
||||||
uint8_t* iobounds0orig_src = NULL;
|
uint8_t* iobounds0orig_src = NULL;
|
||||||
@@ -7966,10 +8360,8 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
|||||||
v_block_size = self->private_impl.c_decode_id_part1[0].v_block_size;
|
v_block_size = self->private_impl.c_decode_id_part1[0].v_block_size;
|
||||||
v_w = ((wuffs_base__io_writer){});
|
v_w = ((wuffs_base__io_writer){});
|
||||||
v_z = self->private_impl.c_decode_id_part1[0].v_z;
|
v_z = self->private_impl.c_decode_id_part1[0].v_z;
|
||||||
v_palette = ((wuffs_base__slice_u8){});
|
|
||||||
} else {
|
} else {
|
||||||
v_w = ((wuffs_base__io_writer){});
|
v_w = ((wuffs_base__io_writer){});
|
||||||
v_palette = ((wuffs_base__slice_u8){});
|
|
||||||
}
|
}
|
||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
@@ -7995,6 +8387,11 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
|||||||
(4 * ((uint32_t)(self->private_impl.f_gc_transparent_index))) + 3)] =
|
(4 * ((uint32_t)(self->private_impl.f_gc_transparent_index))) + 3)] =
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
|
wuffs_base__pixel_buffer__set_palette(
|
||||||
|
a_dst,
|
||||||
|
((wuffs_base__slice_u8){.ptr = self->private_impl.f_palettes[(
|
||||||
|
self->private_impl.f_which_palette & 1)],
|
||||||
|
.len = 1024}));
|
||||||
if (self->private_impl.f_previous_lzw_decode_ended_abruptly) {
|
if (self->private_impl.f_previous_lzw_decode_ended_abruptly) {
|
||||||
(memset(&self->private_impl.f_lzw, 0, sizeof((wuffs_lzw__decoder){})),
|
(memset(&self->private_impl.f_lzw, 0, sizeof((wuffs_lzw__decoder){})),
|
||||||
wuffs_lzw__decoder__check_wuffs_version(&self->private_impl.f_lzw,
|
wuffs_lzw__decoder__check_wuffs_version(&self->private_impl.f_lzw,
|
||||||
@@ -8106,32 +8503,6 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
|||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v_palette = ((wuffs_base__slice_u8){});
|
|
||||||
if (self->private_impl.f_use_local_palette ||
|
|
||||||
self->private_impl.f_gc_has_transparent_index) {
|
|
||||||
v_palette = ((wuffs_base__slice_u8){
|
|
||||||
.ptr = self->private_impl.f_palettes[1], .len = 1024});
|
|
||||||
} else if (!self->private_impl.f_previous_use_global_palette) {
|
|
||||||
v_palette = ((wuffs_base__slice_u8){
|
|
||||||
.ptr = self->private_impl.f_palettes[0], .len = 1024});
|
|
||||||
}
|
|
||||||
wuffs_base__image_buffer__update(
|
|
||||||
a_dst,
|
|
||||||
wuffs_base__utility__make_rect_ie_u32(
|
|
||||||
&self->private_impl.f_util, self->private_impl.f_frame_rect_x0,
|
|
||||||
self->private_impl.f_frame_rect_y0,
|
|
||||||
self->private_impl.f_frame_rect_x1,
|
|
||||||
self->private_impl.f_frame_rect_y1),
|
|
||||||
self->private_impl.f_gc_duration, true,
|
|
||||||
self->private_impl.f_gc_disposal, v_palette);
|
|
||||||
self->private_impl.f_previous_use_global_palette =
|
|
||||||
!(self->private_impl.f_use_local_palette ||
|
|
||||||
self->private_impl.f_gc_has_transparent_index);
|
|
||||||
self->private_impl.f_seen_graphic_control = false;
|
|
||||||
self->private_impl.f_gc_has_transparent_index = false;
|
|
||||||
self->private_impl.f_gc_transparent_index = 0;
|
|
||||||
self->private_impl.f_gc_disposal = 0;
|
|
||||||
self->private_impl.f_gc_duration = 0;
|
|
||||||
|
|
||||||
goto ok;
|
goto ok;
|
||||||
ok:
|
ok:
|
||||||
@@ -8167,7 +8538,7 @@ short_read_src:
|
|||||||
|
|
||||||
static wuffs_base__status //
|
static wuffs_base__status //
|
||||||
wuffs_gif__decoder__copy_to_image_buffer(wuffs_gif__decoder* self,
|
wuffs_gif__decoder__copy_to_image_buffer(wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_ib) {
|
wuffs_base__pixel_buffer* a_pb) {
|
||||||
wuffs_base__status status = WUFFS_BASE__STATUS_OK;
|
wuffs_base__status status = WUFFS_BASE__STATUS_OK;
|
||||||
|
|
||||||
wuffs_base__slice_u8 v_dst;
|
wuffs_base__slice_u8 v_dst;
|
||||||
@@ -8180,7 +8551,7 @@ wuffs_gif__decoder__copy_to_image_buffer(wuffs_gif__decoder* self,
|
|||||||
v_src = ((wuffs_base__slice_u8){});
|
v_src = ((wuffs_base__slice_u8){});
|
||||||
v_n = 0;
|
v_n = 0;
|
||||||
v_new_ri = 0;
|
v_new_ri = 0;
|
||||||
v_tab = wuffs_base__image_buffer__plane(a_ib, 0);
|
v_tab = wuffs_base__pixel_buffer__plane(a_pb, 0);
|
||||||
label_0_continue:;
|
label_0_continue:;
|
||||||
while (self->private_impl.f_uncompressed_wi >
|
while (self->private_impl.f_uncompressed_wi >
|
||||||
self->private_impl.f_uncompressed_ri) {
|
self->private_impl.f_uncompressed_ri) {
|
||||||
|
|||||||
Reference in new issue
Block a user