mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Redo {frame,image,pixel}_config and pixel_buffer
This commit is contained in:
1 parent
4e70498189
commit
1c75f7b748
12 files changed
+945
-560
No files matched your search
@@ -195,10 +195,6 @@ wuffs_base__pixel_format__num_planes(wuffs_base__pixel_format f) {
|
||||
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
|
||||
@@ -289,6 +285,165 @@ typedef struct {
|
||||
wuffs_base__pixel_subsampling pixsub;
|
||||
uint32_t width;
|
||||
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;
|
||||
bool first_frame_is_opaque;
|
||||
} private_impl;
|
||||
@@ -302,6 +457,7 @@ typedef struct {
|
||||
bool first_frame_is_opaque);
|
||||
inline void invalidate();
|
||||
inline bool is_valid();
|
||||
inline wuffs_base__pixel_config* pixel_config();
|
||||
inline wuffs_base__pixel_format pixel_format();
|
||||
inline wuffs_base__pixel_subsampling pixel_subsampling();
|
||||
inline wuffs_base__rect_ie_u32 bounds();
|
||||
@@ -309,7 +465,6 @@ typedef struct {
|
||||
inline uint32_t height();
|
||||
inline uint32_t num_loops();
|
||||
inline uint32_t first_frame_is_opaque();
|
||||
inline size_t pixbuf_size();
|
||||
#endif // __cplusplus
|
||||
|
||||
} wuffs_base__image_config;
|
||||
@@ -326,18 +481,14 @@ wuffs_base__image_config__initialize(wuffs_base__image_config* c,
|
||||
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;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
c->private_impl.first_frame_is_opaque = first_frame_is_opaque;
|
||||
return;
|
||||
}
|
||||
if (wuffs_base__pixel_format__is_valid(pixfmt)) {
|
||||
c->private_impl.pixcfg.private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixcfg.private_impl.pixsub = pixsub;
|
||||
c->private_impl.pixcfg.private_impl.width = width;
|
||||
c->private_impl.pixcfg.private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
c->private_impl.first_frame_is_opaque = first_frame_is_opaque;
|
||||
return;
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
@@ -351,17 +502,22 @@ wuffs_base__image_config__invalidate(wuffs_base__image_config* c) {
|
||||
|
||||
static inline bool //
|
||||
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 //
|
||||
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 //
|
||||
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 //
|
||||
@@ -369,20 +525,20 @@ wuffs_base__image_config__bounds(wuffs_base__image_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,
|
||||
.max_excl_x = c->private_impl.pixcfg.private_impl.width,
|
||||
.max_excl_y = c->private_impl.pixcfg.private_impl.height,
|
||||
})
|
||||
: ((wuffs_base__rect_ie_u32){});
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
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 //
|
||||
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 //
|
||||
@@ -395,20 +551,6 @@ wuffs_base__image_config__first_frame_is_opaque(wuffs_base__image_config* c) {
|
||||
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
|
||||
|
||||
inline void //
|
||||
@@ -432,6 +574,11 @@ wuffs_base__image_config::is_valid() {
|
||||
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 //
|
||||
wuffs_base__image_config::pixel_format() {
|
||||
return wuffs_base__image_config__pixel_format(this);
|
||||
@@ -467,11 +614,6 @@ wuffs_base__image_config::first_frame_is_opaque() {
|
||||
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
|
||||
|
||||
// --------
|
||||
@@ -498,260 +640,284 @@ 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__image_config config;
|
||||
wuffs_base__pixel_buffer pixbuf;
|
||||
// TODO: color spaces.
|
||||
wuffs_base__rect_ie_u32 dirty_rect;
|
||||
wuffs_base__rect_ie_u32 bounds;
|
||||
wuffs_base__flicks duration;
|
||||
bool blend;
|
||||
wuffs_base__animation_disposal disposal;
|
||||
bool palette_changed;
|
||||
uint8_t palette[1024];
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline wuffs_base__status set_from_pixbuf(wuffs_base__image_config config,
|
||||
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,
|
||||
inline void update(wuffs_base__rect_ie_u32 bounds,
|
||||
wuffs_base__flicks duration,
|
||||
bool blend,
|
||||
wuffs_base__animation_disposal disposal,
|
||||
wuffs_base__slice_u8 palette);
|
||||
inline wuffs_base__image_config* image_config();
|
||||
bool palette_changed);
|
||||
inline wuffs_base__rect_ie_u32 bounds();
|
||||
inline uint32_t width();
|
||||
inline uint32_t height();
|
||||
inline wuffs_base__rect_ie_u32 dirty_rect();
|
||||
inline wuffs_base__flicks duration();
|
||||
inline bool blend();
|
||||
inline wuffs_base__animation_disposal disposal();
|
||||
inline bool palette_changed();
|
||||
inline wuffs_base__slice_u8 palette();
|
||||
inline wuffs_base__table_u8 plane(uint32_t p);
|
||||
#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 //
|
||||
wuffs_base__image_buffer__update(wuffs_base__image_buffer* b,
|
||||
wuffs_base__rect_ie_u32 dirty_rect,
|
||||
wuffs_base__frame_config__update(wuffs_base__frame_config* c,
|
||||
wuffs_base__rect_ie_u32 bounds,
|
||||
wuffs_base__flicks duration,
|
||||
bool blend,
|
||||
wuffs_base__animation_disposal disposal,
|
||||
wuffs_base__slice_u8 palette) {
|
||||
if (!b) {
|
||||
bool palette_changed) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clip the dirty_rect to the image bounds.
|
||||
dirty_rect.max_excl_x = wuffs_base__u32__min(
|
||||
dirty_rect.max_excl_x, b->private_impl.config.private_impl.width);
|
||||
dirty_rect.max_excl_y = wuffs_base__u32__min(
|
||||
dirty_rect.max_excl_y, b->private_impl.config.private_impl.height);
|
||||
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;
|
||||
c->private_impl.bounds = bounds;
|
||||
c->private_impl.duration = duration;
|
||||
c->private_impl.blend = blend;
|
||||
c->private_impl.disposal = disposal;
|
||||
c->private_impl.palette_changed = palette_changed;
|
||||
}
|
||||
|
||||
static inline wuffs_base__rect_ie_u32 //
|
||||
wuffs_base__image_buffer__bounds(wuffs_base__image_buffer* b) {
|
||||
return b ? wuffs_base__image_config__bounds(&b->private_impl.config)
|
||||
: ((wuffs_base__rect_ie_u32){});
|
||||
wuffs_base__frame_config__bounds(wuffs_base__frame_config* c) {
|
||||
return c ? c->private_impl.bounds : ((wuffs_base__rect_ie_u32){});
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__image_buffer__width(wuffs_base__image_buffer* b) {
|
||||
return b ? wuffs_base__image_config__width(&b->private_impl.config) : 0;
|
||||
wuffs_base__frame_config__width(wuffs_base__frame_config* c) {
|
||||
return c ? wuffs_base__rect_ie_u32__width(&c->private_impl.bounds) : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__image_buffer__height(wuffs_base__image_buffer* b) {
|
||||
return b ? wuffs_base__image_config__height(&b->private_impl.config) : 0;
|
||||
wuffs_base__frame_config__height(wuffs_base__frame_config* c) {
|
||||
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
|
||||
// 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
|
||||
// wuffs_base__frame_config__duration returns the amount of time to display
|
||||
// this frame. Zero means to display forever - a still (non-animated) image.
|
||||
static inline wuffs_base__flicks //
|
||||
wuffs_base__image_buffer__duration(wuffs_base__image_buffer* b) {
|
||||
return b ? b->private_impl.duration : 0;
|
||||
wuffs_base__frame_config__duration(wuffs_base__frame_config* c) {
|
||||
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.
|
||||
//
|
||||
// In Porter-Duff compositing operator terminology, false means "src" and true
|
||||
// means "src over dst".
|
||||
static inline bool //
|
||||
wuffs_base__image_buffer__blend(wuffs_base__image_buffer* b) {
|
||||
return b && b->private_impl.blend;
|
||||
wuffs_base__frame_config__blend(wuffs_base__frame_config* c) {
|
||||
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.
|
||||
static inline wuffs_base__animation_disposal //
|
||||
wuffs_base__image_buffer__disposal(wuffs_base__image_buffer* b) {
|
||||
return b ? b->private_impl.disposal : 0;
|
||||
wuffs_base__frame_config__disposal(wuffs_base__frame_config* c) {
|
||||
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
|
||||
// false positives (but never false negatives).
|
||||
static inline bool //
|
||||
wuffs_base__image_buffer__palette_changed(wuffs_base__image_buffer* b) {
|
||||
return b && b->private_impl.palette_changed;
|
||||
wuffs_base__frame_config__palette_changed(wuffs_base__frame_config* c) {
|
||||
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.
|
||||
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,
|
||||
.len = 1024})
|
||||
: ((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
|
||||
|
||||
inline wuffs_base__status //
|
||||
wuffs_base__image_buffer::set_from_pixbuf(wuffs_base__image_config config,
|
||||
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__pixel_buffer::set_from_slice(wuffs_base__pixel_config* pixcfg,
|
||||
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 //
|
||||
wuffs_base__image_buffer::update(wuffs_base__rect_ie_u32 dirty_rect,
|
||||
wuffs_base__flicks duration,
|
||||
bool blend,
|
||||
wuffs_base__animation_disposal disposal,
|
||||
wuffs_base__slice_u8 palette) {
|
||||
wuffs_base__image_buffer__update(this, dirty_rect, duration, blend, disposal,
|
||||
palette);
|
||||
wuffs_base__pixel_buffer::set_palette(wuffs_base__slice_u8 palette) {
|
||||
wuffs_base__pixel_buffer__set_palette(this, palette);
|
||||
}
|
||||
|
||||
inline wuffs_base__image_config* //
|
||||
wuffs_base__image_buffer::image_config() {
|
||||
return wuffs_base__image_buffer__image_config(this);
|
||||
inline wuffs_base__pixel_config* //
|
||||
wuffs_base__pixel_buffer::pixel_config() {
|
||||
return wuffs_base__pixel_buffer__pixel_config(this);
|
||||
}
|
||||
|
||||
inline wuffs_base__rect_ie_u32 //
|
||||
wuffs_base__image_buffer::bounds() {
|
||||
return wuffs_base__image_buffer__bounds(this);
|
||||
wuffs_base__pixel_buffer::bounds() {
|
||||
return wuffs_base__pixel_buffer__bounds(this);
|
||||
}
|
||||
|
||||
inline uint32_t //
|
||||
wuffs_base__image_buffer::width() {
|
||||
return wuffs_base__image_buffer__width(this);
|
||||
wuffs_base__pixel_buffer::width() {
|
||||
return wuffs_base__pixel_buffer__width(this);
|
||||
}
|
||||
|
||||
inline uint32_t //
|
||||
wuffs_base__image_buffer::height() {
|
||||
return wuffs_base__image_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);
|
||||
wuffs_base__pixel_buffer::height() {
|
||||
return wuffs_base__pixel_buffer__height(this);
|
||||
}
|
||||
|
||||
inline wuffs_base__table_u8 //
|
||||
wuffs_base__image_buffer::plane(uint32_t p) {
|
||||
return wuffs_base__image_buffer__plane(this, p);
|
||||
wuffs_base__pixel_buffer::plane(uint32_t 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
|
||||
|
||||
@@ -124,32 +124,39 @@ const baseImagePublicH = "" +
|
||||
"DRM library's WL_DRM_FORMAT_RGB565.\n//\n// Different software libraries name their pixel formats (and especially their\n// channel order) either according to memory layout or as bits of a native\n// integer type like uint32_t. The two conventions differ because of a system's\n// endianness. As mentioned earlier, Wuffs pixel formats are always in memory\n// order. More detail of other software libraries' naming conventions is in the\n// Pixel Format Guide at https://afrantzis.github.io/pixel-format-guide/\n//\n// Do not manipulate these bits directly; they are private implementation\n// details. Use methods such as wuffs_base__pixel_format__num_planes instead.\ntypedef uint32_t wuffs_base__pixel_format;\n\n// Common 8-bit-depth pixel formats. This list is not exhaustive; not all valid\n// wuffs_base__pixel_format values are present.\n\n#define WUFFS_BASE__PIXEL_FORMAT__INVALID ((wuffs_base__pixel_format)0x00000000)\n\n#define WUFFS_BASE__PIXEL_FORMAT__A ((wuffs_base__pixel_format)0x02000008)\n\n#define WUFFS_BASE__PIXEL_FORMAT__" +
|
||||
"Y ((wuffs_base__pixel_format)0x10000008)\n#define WUFFS_BASE__PIXEL_FORMAT__YA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x12000008)\n#define WUFFS_BASE__PIXEL_FORMAT__YA_PREMUL \\\n ((wuffs_base__pixel_format)0x13000008)\n\n#define WUFFS_BASE__PIXEL_FORMAT__BGR ((wuffs_base__pixel_format)0x20000888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRX ((wuffs_base__pixel_format)0x21008888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRX_INDEXED \\\n ((wuffs_base__pixel_format)0x21088888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x22008888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_INDEXED \\\n ((wuffs_base__pixel_format)0x22088888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL \\\n ((wuffs_base__pixel_format)0x23008888)\n\n#define WUFFS_BASE__PIXEL_FORMAT__RGB ((wuffs_base__pixel_format)0x30000888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBX ((wuffs_base__pixel_format)0x31008888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBX_INDEXED \\\n ((wuffs_base__pixel_format)0x31088888)\n#define WUFFS_BASE__PIXEL_FORMAT_" +
|
||||
"_RGBA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x32008888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL_INDEXED \\\n ((wuffs_base__pixel_format)0x32088888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL \\\n ((wuffs_base__pixel_format)0x33008888)\n\n#define WUFFS_BASE__PIXEL_FORMAT__YUV ((wuffs_base__pixel_format)0x40200888)\n#define WUFFS_BASE__PIXEL_FORMAT__YUVK ((wuffs_base__pixel_format)0x41308888)\n#define WUFFS_BASE__PIXEL_FORMAT__YUVA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x42308888)\n\n#define WUFFS_BASE__PIXEL_FORMAT__CMY ((wuffs_base__pixel_format)0x50200888)\n#define WUFFS_BASE__PIXEL_FORMAT__CMYK ((wuffs_base__pixel_format)0x51308888)\n\nstatic inline bool //\nwuffs_base__pixel_format__is_valid(wuffs_base__pixel_format f) {\n return f != 0;\n}\n\nstatic inline bool //\nwuffs_base__pixel_format__is_indexed(wuffs_base__pixel_format f) {\n return ((f >> 16) & 0x0F) != 0;\n}\n\n#define WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX 4\n\nstatic inline uint32_t //\nwuffs_base__pixel_format__num_planes(wuffs_base__pixel_fo" +
|
||||
"rmat f) {\n return f ? (((f >> 20) & 0x03) + 1) : 0;\n}\n\ntypedef struct {\n wuffs_base__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX];\n} wuffs_base__pixel_buffer;\n\n" +
|
||||
"rmat f) {\n return f ? (((f >> 20) & 0x03) + 1) : 0;\n}\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// wuffs_base__pixel_subsampling encodes the mapping of pixel space coordinates\n// (x, y) to pixel buffer indices (i, j). That mapping can differ for each\n// plane p. For a depth of 8 bits (1 byte), the p'th plane's sample starts at\n// (planes[p].ptr + (j * planes[p].stride) + i).\n//\n// For packed pixel formats, the mapping is trivial: i = x and j = y. For\n// planar pixel formats, the mapping can differ due to chroma subsampling. For\n// example, consider a three plane YUV pixel format with 4:2:2 subsampling. For\n// the luma (Y) channel, there is one sample for every pixel, but for the\n// chroma (U, V) channels, there is one sample for every two pixels: pairs of\n// horizontally adjacent pixels form one macropixel, i = x / 2 and j == y. In\n// general, for a given p:\n// - i = (x + bias_x) >> shift_x.\n// - j = (y + bias_y) >> shift_y.\n// where biases and shifts are in the range 0..3 and 0..2 respectively.\n//\n// In general, the biases will be zero after decoding an image. However, making\n// a sub-im" +
|
||||
"age may change the bias, since the (x, y) coordinates are relative\n// to the sub-image's top-left origin, but the backing pixel buffers were\n// created relative to the original image's origin.\n//\n// For each plane p, each of those four numbers (biases and shifts) are encoded\n// in two bits, which combine to form an 8 bit unsigned integer:\n//\n// e_p = (bias_x << 6) | (shift_x << 4) | (bias_y << 2) | (shift_y << 0)\n//\n// Those e_p values (e_0 for the first plane, e_1 for the second plane, etc)\n// combine to form a wuffs_base__pixel_subsampling value:\n//\n// pixsub = (e_3 << 24) | (e_2 << 16) | (e_1 << 8) | (e_0 << 0)\n//\n// Do not manipulate these bits directly; they are private implementation\n// details. Use methods such as wuffs_base__pixel_subsampling__bias_x instead.\ntypedef uint32_t wuffs_base__pixel_subsampling;\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__NONE ((wuffs_base__pixel_subsampling)0)\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__444 \\\n ((wuffs_base__pixel_subsampling)0x000000)\n#define WUFFS_BASE__PIXEL_" +
|
||||
"SUBSAMPLING__440 \\\n ((wuffs_base__pixel_subsampling)0x010100)\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__422 \\\n ((wuffs_base__pixel_subsampling)0x101000)\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__420 \\\n ((wuffs_base__pixel_subsampling)0x111100)\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__411 \\\n ((wuffs_base__pixel_subsampling)0x202000)\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__410 \\\n ((wuffs_base__pixel_subsampling)0x212100)\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__bias_x(wuffs_base__pixel_subsampling s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 6;\n return (s >> shift) & 0x03;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__shift_x(wuffs_base__pixel_subsampling s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 4;\n return (s >> shift) & 0x03;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__bias_y(wuffs_base__pixel_subsampling s,\n ui" +
|
||||
"nt32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 2;\n return (s >> shift) & 0x03;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__shift_y(wuffs_base__pixel_subsampling s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 0;\n return (s >> shift) & 0x03;\n}\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__pixel_format pixfmt;\n wuffs_base__pixel_subsampling pixsub;\n uint32_t width;\n uint32_t height;\n uint32_t num_loops;\n bool first_frame_is_opaque;\n } private_impl;\n\n#ifdef __cplusplus\n inline void initialize(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint32_t num_loops,\n bool first_frame_is_opaque);\n inline void invalidate();\n inline bool is_valid();\n inline wuffs_base__pixel_format pixel_format();\n inline wuffs_base__pixel_subsampling pixel_subsampling();\n inline wuffs_base__rect_ie_u32 bounds();\n inline uint32_t width();\n inline uint32_t height();\n inline uint32_t num_loops();\n inline uint32_t first_frame_is_opaque();\n " +
|
||||
"inline size_t pixbuf_size();\n#endif // __cplusplus\n\n} wuffs_base__image_config;\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__image_config__initialize(wuffs_base__image_config* c,\n wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint32_t num_loops,\n bool first_frame_is_opaque) {\n if (!c) {\n return;\n }\n if (pixfmt) {\n uint64_t wh = ((uint64_t)width) * ((uint64_t)height);\n // TODO: handle things other than 1 byte per pixel.\n if (wh <= ((uint64_t)SIZE_MAX)) {\n c->private_impl.pixfmt = pixfmt;\n c->private_impl.pixsub = pixsub;\n c->private_impl.width = width;\n c->private_impl.height = height;\n c->private_impl.num_loops = num_loops;\n c->private_impl.fi" +
|
||||
"rst_frame_is_opaque = first_frame_is_opaque;\n return;\n }\n }\n *c = ((wuffs_base__image_config){});\n}\n\nstatic inline void //\nwuffs_base__image_config__invalidate(wuffs_base__image_config* c) {\n if (c) {\n *c = ((wuffs_base__image_config){});\n }\n}\n\nstatic inline bool //\nwuffs_base__image_config__is_valid(wuffs_base__image_config* c) {\n return c && c->private_impl.pixfmt;\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__image_config__pixel_format(wuffs_base__image_config* c) {\n return c ? c->private_impl.pixfmt : 0;\n}\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {\n return c ? c->private_impl.pixsub : 0;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__image_config__bounds(wuffs_base__image_config* c) {\n return c ? ((wuffs_base__rect_ie_u32){\n .min_incl_x = 0,\n .min_incl_y = 0,\n .max_excl_x = c->private_impl.width,\n .max_excl_y = c->privat" +
|
||||
"e_impl.height,\n })\n : ((wuffs_base__rect_ie_u32){});\n}\n\nstatic inline uint32_t //\nwuffs_base__image_config__width(wuffs_base__image_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__image_config__height(wuffs_base__image_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__image_config__num_loops(wuffs_base__image_config* c) {\n return c ? c->private_impl.num_loops : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__image_config__first_frame_is_opaque(wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_is_opaque : false;\n}\n\n// TODO: this is the right API for planar (not packed) pixbufs? Should it allow\n// decoding into a color model different from the format's intrinsic one? For\n// example, decoding a JPEG image straight to RGBA instead of to YCbCr?\nstatic inline size_t //\nwuffs_base__image_config__pixbuf_size(wuffs_base__image_config* c) {\n if (c) {\n uint64_t wh =\n ((uint6" +
|
||||
"4_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n // TODO: handle things other than 1 byte per pixel.\n return (size_t)wh;\n }\n return 0;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__image_config::initialize(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint32_t num_loops,\n bool first_frame_is_opaque) {\n wuffs_base__image_config__initialize(this, pixfmt, pixsub, width, height,\n num_loops, first_frame_is_opaque);\n}\n\ninline void //\nwuffs_base__image_config::invalidate() {\n wuffs_base__image_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__image_config::is_valid() {\n return wuffs_base__image_config__is_valid(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__image_config::pixel_format() {\n " +
|
||||
"return wuffs_base__image_config__pixel_format(this);\n}\n\ninline wuffs_base__pixel_subsampling //\nwuffs_base__image_config::pixel_subsampling() {\n return wuffs_base__image_config__pixel_subsampling(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__image_config::bounds() {\n return wuffs_base__image_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__image_config::width() {\n return wuffs_base__image_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__image_config::height() {\n return wuffs_base__image_config__height(this);\n}\n\ninline uint32_t //\nwuffs_base__image_config::num_loops() {\n return wuffs_base__image_config__num_loops(this);\n}\n\ninline uint32_t //\nwuffs_base__image_config::first_frame_is_opaque() {\n return wuffs_base__image_config__first_frame_is_opaque(this);\n}\n\ninline size_t //\nwuffs_base__image_config::pixbuf_size() {\n return wuffs_base__image_config__pixbuf_size(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__pixel_format pixfmt;\n wuffs_base__pixel_subsampling pixsub;\n uint32_t width;\n uint32_t height;\n } private_impl;\n\n#ifdef __cplusplus\n inline void initialize(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height);\n inline void invalidate();\n inline bool is_valid();\n inline wuffs_base__pixel_format pixel_format();\n inline wuffs_base__pixel_subsampling pixel_subsampling();\n inline wuffs_base__rect_ie_u32 bounds();\n inline uint32_t width();\n inline uint32_t height();\n inline size_t pixbuf_size();\n#endif // __cplusplus\n\n} wuffs_base__pixel_config;\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__pixel_config__initialize(wuffs_base__pixel_config* c," +
|
||||
"\n wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n if (!c) {\n return;\n }\n if (pixfmt) {\n uint64_t wh = ((uint64_t)width) * ((uint64_t)height);\n // TODO: handle things other than 1 byte per pixel.\n if (wh <= ((uint64_t)SIZE_MAX)) {\n c->private_impl.pixfmt = pixfmt;\n c->private_impl.pixsub = pixsub;\n c->private_impl.width = width;\n c->private_impl.height = height;\n return;\n }\n }\n *c = ((wuffs_base__pixel_config){});\n}\n\nstatic inline void //\nwuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {\n if (c) {\n *c = ((wuffs_base__pixel_config){});\n }\n}\n\nstatic inline bool //\nwuffs_base__pixel_config__is_valid(wuffs_base__pixel_config* c) {\n return c && c->private_impl.pixfmt;\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__pixel_config__pixe" +
|
||||
"l_format(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixfmt : 0;\n}\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config__pixel_subsampling(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixsub : 0;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config__bounds(wuffs_base__pixel_config* c) {\n return c ? ((wuffs_base__rect_ie_u32){\n .min_incl_x = 0,\n .min_incl_y = 0,\n .max_excl_x = c->private_impl.width,\n .max_excl_y = c->private_impl.height,\n })\n : ((wuffs_base__rect_ie_u32){});\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__width(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__height(wuffs_base__pixel_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\n// TODO: this is the right API for planar (not packed) pixbufs? Should it allow\n// decoding into a color model differe" +
|
||||
"nt from the format's intrinsic one? For\n// example, decoding a JPEG image straight to RGBA instead of to YCbCr?\nstatic inline size_t //\nwuffs_base__pixel_config__pixbuf_size(wuffs_base__pixel_config* c) {\n if (c) {\n uint64_t wh =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n // TODO: handle things other than 1 byte per pixel.\n return (size_t)wh;\n }\n return 0;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__pixel_config::initialize(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n wuffs_base__pixel_config__initialize(this, pixfmt, pixsub, width, height);\n}\n\ninline void //\nwuffs_base__pixel_config::invalidate() {\n wuffs_base__pixel_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__pixel_config::is_valid() {\n return wuffs_base__pixel_config__is_valid(this);\n}\n\ninline wuffs_base__pixel_f" +
|
||||
"ormat //\nwuffs_base__pixel_config::pixel_format() {\n return wuffs_base__pixel_config__pixel_format(this);\n}\n\ninline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config::pixel_subsampling() {\n return wuffs_base__pixel_config__pixel_subsampling(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config::bounds() {\n return wuffs_base__pixel_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::width() {\n return wuffs_base__pixel_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::height() {\n return wuffs_base__pixel_config__height(this);\n}\n\ninline size_t //\nwuffs_base__pixel_config::pixbuf_size() {\n return wuffs_base__pixel_config__pixbuf_size(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__pixel_config pixcfg;\n uint32_t num_loops;\n bool first_frame_is_opaque;\n } private_impl;\n\n#ifdef __cplusplus\n inline void initialize(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint32_t num_loops,\n bool first_frame_is_opaque);\n inline void invalidate();\n inline bool is_valid();\n inline wuffs_base__pixel_config* pixel_config();\n inline wuffs_base__pixel_format pixel_format();\n inline wuffs_base__pixel_subsampling pixel_subsampling();\n inline wuffs_base__rect_ie_u32 bounds();\n inline uint32_t width();\n inline uint32_t height();\n inline uint32_t num_loops();\n inline uint32_t first_frame_is_opaque();\n#endif // __cplusplus\n\n} wuffs_ba" +
|
||||
"se__image_config;\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__image_config__initialize(wuffs_base__image_config* c,\n wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint32_t num_loops,\n bool first_frame_is_opaque) {\n if (!c) {\n return;\n }\n if (wuffs_base__pixel_format__is_valid(pixfmt)) {\n c->private_impl.pixcfg.private_impl.pixfmt = pixfmt;\n c->private_impl.pixcfg.private_impl.pixsub = pixsub;\n c->private_impl.pixcfg.private_impl.width = width;\n c->private_impl.pixcfg.private_impl.height = height;\n c->private_impl.num_loops = num_loops;\n c->private_impl.first_frame_is_opaque = first_frame_is_opaque;\n return;\n }\n *c = ((wuffs_base__image_config){});\n}\n\nstatic i" +
|
||||
"nline void //\nwuffs_base__image_config__invalidate(wuffs_base__image_config* c) {\n if (c) {\n *c = ((wuffs_base__image_config){});\n }\n}\n\nstatic inline bool //\nwuffs_base__image_config__is_valid(wuffs_base__image_config* c) {\n return c && wuffs_base__pixel_config__is_valid(&(c->private_impl.pixcfg));\n}\n\nstatic inline wuffs_base__pixel_config* //\nwuffs_base__image_config__pixel_config(wuffs_base__image_config* c) {\n return c ? &c->private_impl.pixcfg : NULL;\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__image_config__pixel_format(wuffs_base__image_config* c) {\n return c ? c->private_impl.pixcfg.private_impl.pixfmt : 0;\n}\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {\n return c ? c->private_impl.pixcfg.private_impl.pixsub : 0;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__image_config__bounds(wuffs_base__image_config* c) {\n return c ? ((wuffs_base__rect_ie_u32){\n .min_incl_x = 0,\n " +
|
||||
" .min_incl_y = 0,\n .max_excl_x = c->private_impl.pixcfg.private_impl.width,\n .max_excl_y = c->private_impl.pixcfg.private_impl.height,\n })\n : ((wuffs_base__rect_ie_u32){});\n}\n\nstatic inline uint32_t //\nwuffs_base__image_config__width(wuffs_base__image_config* c) {\n return c ? c->private_impl.pixcfg.private_impl.width : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__image_config__height(wuffs_base__image_config* c) {\n return c ? c->private_impl.pixcfg.private_impl.height : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__image_config__num_loops(wuffs_base__image_config* c) {\n return c ? c->private_impl.num_loops : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__image_config__first_frame_is_opaque(wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_is_opaque : false;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__image_config::initialize(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsa" +
|
||||
"mpling pixsub,\n uint32_t width,\n uint32_t height,\n uint32_t num_loops,\n bool first_frame_is_opaque) {\n wuffs_base__image_config__initialize(this, pixfmt, pixsub, width, height,\n num_loops, first_frame_is_opaque);\n}\n\ninline void //\nwuffs_base__image_config::invalidate() {\n wuffs_base__image_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__image_config::is_valid() {\n return wuffs_base__image_config__is_valid(this);\n}\n\ninline wuffs_base__pixel_config* //\nwuffs_base__image_config::pixel_config() {\n return wuffs_base__image_config__pixel_config(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__image_config::pixel_format() {\n return wuffs_base__image_config__pixel_format(this);\n}\n\ninline wuffs_base__pixel_subsampling //\nwuffs_base__image_config::pixel_subsampling() {\n return wuffs_base__image_config__pixel_subsa" +
|
||||
"mpling(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__image_config::bounds() {\n return wuffs_base__image_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__image_config::width() {\n return wuffs_base__image_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__image_config::height() {\n return wuffs_base__image_config__height(this);\n}\n\ninline uint32_t //\nwuffs_base__image_config::num_loops() {\n return wuffs_base__image_config__num_loops(this);\n}\n\ninline uint32_t //\nwuffs_base__image_config::first_frame_is_opaque() {\n return wuffs_base__image_config__first_frame_is_opaque(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// wuffs_base__animation_disposal encodes, for an animated image, how to\n// dispose of a frame after displaying it:\n// - None means to draw the next frame on top of this one.\n// - Restore Background means to clear the frame's dirty rectangle to \"the\n// background color\" (in practice, this means transparent black) before\n// drawing the next frame.\n// - Restore Previous means to undo the current frame, so that the next frame\n// is drawn on top of the previous one.\ntypedef uint8_t wuffs_base__animation_disposal;\n\n#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)\n#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \\\n ((wuffs_base__animation_disposal)1)\n#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \\\n ((wuffs_base__animation_disposal)2)\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__image_config config;\n wuffs_base__pixel_buffer pixbuf;\n // TODO: color spaces.\n wuffs_base__rect_ie_u32 dirty_rect;\n wuffs_base__flicks duration;\n bool blend;\n wuffs_base__animation_disposal disposal;\n bool palette_changed;\n uint8_t palette[1024];\n } private_impl;\n\n#ifdef __cplusplus\n inline wuffs_base__status set_from_pixbuf(wuffs_base__image_config config,\n wuffs_base__pixel_buffer pixbuf);\n inline wuffs_base__status set_from_slice(wuffs_base__image_config config,\n wuffs_base__slice_u8 pixbuf_memory);\n inline void update(wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n bool blend,\n wuffs_base__animation_disposal disposal,\n " +
|
||||
" wuffs_base__slice_u8 palette);\n inline wuffs_base__image_config* image_config();\n inline wuffs_base__rect_ie_u32 bounds();\n inline uint32_t width();\n inline uint32_t height();\n inline wuffs_base__rect_ie_u32 dirty_rect();\n inline wuffs_base__flicks duration();\n inline bool blend();\n inline wuffs_base__animation_disposal disposal();\n inline bool palette_changed();\n inline wuffs_base__slice_u8 palette();\n inline wuffs_base__table_u8 plane(uint32_t p);\n#endif // __cplusplus\n\n} wuffs_base__image_buffer;\n\nstatic inline wuffs_base__status //\nwuffs_base__image_buffer__set_from_pixbuf(wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__pixel_buffer pixbuf) {\n if (!b) {\n return WUFFS_BASE__ERROR_BAD_RECEIVER;\n }\n *b = ((wuffs_base__image_buffer){});\n b->private_impl.config = config;\n b->private_impl.pixbuf = pixbuf;\n return WUFFS_BASE__STATUS_OK;\n}\n\nstatic inline wuffs_base__status //\nw" +
|
||||
"uffs_base__image_buffer__set_from_slice(wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__slice_u8 pixbuf_memory) {\n if (!b) {\n return WUFFS_BASE__ERROR_BAD_RECEIVER;\n }\n *b = ((wuffs_base__image_buffer){});\n // TODO: don't assume 1 byte per pixel. Don't assume packed.\n uint64_t wh = ((uint64_t)config.private_impl.width) *\n ((uint64_t)config.private_impl.height);\n if (wh > pixbuf_memory.len) {\n return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;\n }\n b->private_impl.config = config;\n wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];\n tab->ptr = pixbuf_memory.ptr;\n tab->width = config.private_impl.width;\n tab->height = config.private_impl.height;\n tab->stride = config.private_impl.width;\n return WUFFS_BASE__STATUS_OK;\n}\n\n// The palette argument is ignored unless its length is exactly 1024.\nstatic inline void //\nwuffs_base__image_buffer__update(wuffs_base_" +
|
||||
"_image_buffer* b,\n wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n bool blend,\n wuffs_base__animation_disposal disposal,\n wuffs_base__slice_u8 palette) {\n if (!b) {\n return;\n }\n\n // Clip the dirty_rect to the image bounds.\n dirty_rect.max_excl_x = wuffs_base__u32__min(\n dirty_rect.max_excl_x, b->private_impl.config.private_impl.width);\n dirty_rect.max_excl_y = wuffs_base__u32__min(\n dirty_rect.max_excl_y, b->private_impl.config.private_impl.height);\n b->private_impl.dirty_rect = dirty_rect;\n\n b->private_impl.duration = duration;\n b->private_impl.blend = blend;\n b->private_impl.disposal = disposal;\n b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);\n if (b->private_impl.palette_changed) {\n memmove(b->private_impl.palette, palette.ptr, 1024);\n }\n}\n\n// wuffs_base__image_config returns the" +
|
||||
" overall configuration for this frame.\nstatic inline wuffs_base__image_config* //\nwuffs_base__image_buffer__image_config(wuffs_base__image_buffer* b) {\n return b ? &b->private_impl.config : NULL;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__image_buffer__bounds(wuffs_base__image_buffer* b) {\n return b ? wuffs_base__image_config__bounds(&b->private_impl.config)\n : ((wuffs_base__rect_ie_u32){});\n}\n\nstatic inline uint32_t //\nwuffs_base__image_buffer__width(wuffs_base__image_buffer* b) {\n return b ? wuffs_base__image_config__width(&b->private_impl.config) : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__image_buffer__height(wuffs_base__image_buffer* b) {\n return b ? wuffs_base__image_config__height(&b->private_impl.config) : 0;\n}\n\n// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of\n// this frame's pixels differs from the previous frame.\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__image_buffer__dirty_rect(wuffs_base__image_buffer* b) {\n return b ? b-" +
|
||||
">private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){});\n}\n\n// wuffs_base__image_buffer__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstatic inline wuffs_base__flicks //\nwuffs_base__image_buffer__duration(wuffs_base__image_buffer* b) {\n return b ? b->private_impl.duration : 0;\n}\n\n// wuffs_base__image_buffer__blend returns, for a transparent image, whether to\n// blend this frame with the existing canvas.\n//\n// In Porter-Duff compositing operator terminology, false means \"src\" and true\n// means \"src over dst\".\nstatic inline bool //\nwuffs_base__image_buffer__blend(wuffs_base__image_buffer* b) {\n return b && b->private_impl.blend;\n}\n\n// wuffs_base__image_buffer__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal //\nwuffs_base__image_buffer__disposal(wuffs_base__image_buffer* b) {\n return b ? b->private_impl.disposal : 0;\n}\n\n// wuffs_base__ima" +
|
||||
"ge_buffer__palette_changed returns whether this frame's\n// palette differs from the previous frame. It is conservative and may return\n// false positives (but never false negatives).\nstatic inline bool //\nwuffs_base__image_buffer__palette_changed(wuffs_base__image_buffer* b) {\n return b && b->private_impl.palette_changed;\n}\n\n// wuffs_base__image_buffer__palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__image_buffer__palette(wuffs_base__image_buffer* b) {\n return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,\n .len = 1024})\n : ((wuffs_base__slice_u8){});\n}\n\nstatic inline wuffs_base__table_u8 //\nwuffs_base__image_buffer__plane(wuffs_base__image_buffer* b, uint32_t p) {\n return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))\n ? b->private_impl.pixbuf.planes[p]\n : ((wuffs_base__table_u8){});\n}\n\n#ifdef __cplusp" +
|
||||
"lus\n\ninline wuffs_base__status //\nwuffs_base__image_buffer::set_from_pixbuf(wuffs_base__image_config config,\n wuffs_base__pixel_buffer pixbuf) {\n return wuffs_base__image_buffer__set_from_pixbuf(this, config, pixbuf);\n}\n\ninline wuffs_base__status //\nwuffs_base__image_buffer::set_from_slice(wuffs_base__image_config config,\n wuffs_base__slice_u8 pixbuf_memory) {\n return wuffs_base__image_buffer__set_from_slice(this, config, pixbuf_memory);\n}\n\ninline void //\nwuffs_base__image_buffer::update(wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n bool blend,\n wuffs_base__animation_disposal disposal,\n wuffs_base__slice_u8 palette) {\n wuffs_base__image_buffer__update(this, dirty_rect, duration, blend, disposal,\n palette);\n}\n\ninline wuffs_base__image_config* /" +
|
||||
"/\nwuffs_base__image_buffer::image_config() {\n return wuffs_base__image_buffer__image_config(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__image_buffer::bounds() {\n return wuffs_base__image_buffer__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__image_buffer::width() {\n return wuffs_base__image_buffer__width(this);\n}\n\ninline uint32_t //\nwuffs_base__image_buffer::height() {\n return wuffs_base__image_buffer__height(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__image_buffer::dirty_rect() {\n return wuffs_base__image_buffer__dirty_rect(this);\n}\n\ninline wuffs_base__flicks //\nwuffs_base__image_buffer::duration() {\n return wuffs_base__image_buffer__duration(this);\n}\n\ninline bool //\nwuffs_base__image_buffer::blend() {\n return wuffs_base__image_buffer__blend(this);\n}\n\ninline wuffs_base__animation_disposal //\nwuffs_base__image_buffer::disposal() {\n return wuffs_base__image_buffer__disposal(this);\n}\n\ninline bool //\nwuffs_base__image_buffer::palette_changed() {\n return wuffs_base__image" +
|
||||
"_buffer__palette_changed(this);\n}\n\ninline wuffs_base__slice_u8 //\nwuffs_base__image_buffer::palette() {\n return wuffs_base__image_buffer__palette(this);\n}\n\ninline wuffs_base__table_u8 //\nwuffs_base__image_buffer::plane(uint32_t p) {\n return wuffs_base__image_buffer__plane(this, p);\n}\n\n#endif // __cplusplus\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n" +
|
||||
"// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__rect_ie_u32 bounds;\n wuffs_base__flicks duration;\n bool blend;\n wuffs_base__animation_disposal disposal;\n bool palette_changed;\n } private_impl;\n\n#ifdef __cplusplus\n inline void update(wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n bool blend,\n wuffs_base__animation_disposal disposal,\n bool palette_changed);\n inline wuffs_base__rect_ie_u32 bounds();\n inline uint32_t width();\n inline uint32_t height();\n inline wuffs_base__flicks duration();\n inline bool blend();\n inline wuffs_base__animation_disposal disposal();\n inline bool palette_changed();\n#endif // __cplusplus\n\n} wuffs_base__frame_config;\n\nstatic inline void //\nwuffs_base__frame_config__update(wuffs_base__frame_config* c,\n wu" +
|
||||
"ffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n bool blend,\n wuffs_base__animation_disposal disposal,\n bool palette_changed) {\n if (!c) {\n return;\n }\n\n c->private_impl.bounds = bounds;\n c->private_impl.duration = duration;\n c->private_impl.blend = blend;\n c->private_impl.disposal = disposal;\n c->private_impl.palette_changed = palette_changed;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config__bounds(wuffs_base__frame_config* c) {\n return c ? c->private_impl.bounds : ((wuffs_base__rect_ie_u32){});\n}\n\nstatic inline uint32_t //\nwuffs_base__frame_config__width(wuffs_base__frame_config* c) {\n return c ? wuffs_base__rect_ie_u32__width(&c->private_impl.bounds) : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__frame_config__height(wuffs_base__frame_config* c) {\n return c ? wuffs_base__rect_ie_u32__height(&c->private_impl.bounds) : 0;\n}\n\n// wuffs_ba" +
|
||||
"se__frame_config__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstatic inline wuffs_base__flicks //\nwuffs_base__frame_config__duration(wuffs_base__frame_config* c) {\n return c ? c->private_impl.duration : 0;\n}\n\n// wuffs_base__frame_config__blend returns, for a transparent image, whether to\n// blend this frame with the existing canvas.\n//\n// In Porter-Duff compositing operator terminology, false means \"src\" and true\n// means \"src over dst\".\nstatic inline bool //\nwuffs_base__frame_config__blend(wuffs_base__frame_config* c) {\n return c && c->private_impl.blend;\n}\n\n// wuffs_base__frame_config__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal //\nwuffs_base__frame_config__disposal(wuffs_base__frame_config* c) {\n return c ? c->private_impl.disposal : 0;\n}\n\n// wuffs_base__frame_config__palette_changed returns whether this frame's\n// palette diffe" +
|
||||
"rs from the previous frame. It is conservative and may return\n// false positives (but never false negatives).\nstatic inline bool //\nwuffs_base__frame_config__palette_changed(wuffs_base__frame_config* c) {\n return c && c->private_impl.palette_changed;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__frame_config::update(wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n bool blend,\n wuffs_base__animation_disposal disposal,\n bool palette_changed) {\n wuffs_base__frame_config__update(this, bounds, duration, blend, disposal,\n palette_changed);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config::bounds() {\n return wuffs_base__frame_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::width() {\n return wuffs_base__frame_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::height() {\n return " +
|
||||
"wuffs_base__frame_config__height(this);\n}\n\ninline wuffs_base__flicks //\nwuffs_base__frame_config::duration() {\n return wuffs_base__frame_config__duration(this);\n}\n\ninline bool //\nwuffs_base__frame_config::blend() {\n return wuffs_base__frame_config__blend(this);\n}\n\ninline wuffs_base__animation_disposal //\nwuffs_base__frame_config::disposal() {\n return wuffs_base__frame_config__disposal(this);\n}\n\ninline bool //\nwuffs_base__frame_config::palette_changed() {\n return wuffs_base__frame_config__palette_changed(this);\n}\n\n#endif // __cplusplus\n\n" +
|
||||
"" +
|
||||
"// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__pixel_config pixcfg;\n wuffs_base__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX];\n uint8_t palette[1024];\n // TODO: color spaces.\n } private_impl;\n\n#ifdef __cplusplus\n inline wuffs_base__status set_from_slice(wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory);\n inline void set_palette(wuffs_base__slice_u8 palette);\n inline wuffs_base__pixel_config* pixel_config();\n inline wuffs_base__rect_ie_u32 bounds();\n inline uint32_t width();\n inline uint32_t height();\n inline wuffs_base__table_u8 plane(uint32_t p);\n inline wuffs_base__slice_u8 palette();\n#endif // __cplusplus\n\n} wuffs_base__pixel_buffer;\n\nstatic inline wuffs_base__status //\nwuffs_base__pixel_buffer__set_from_slice(wuffs_base__pixel_buffer* b,\n " +
|
||||
" wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory) {\n if (!b) {\n return WUFFS_BASE__ERROR_BAD_RECEIVER;\n }\n *b = ((wuffs_base__pixel_buffer){});\n if (!pixcfg) {\n return WUFFS_BASE__ERROR_BAD_ARGUMENT;\n }\n // TODO: don't assume 1 byte per pixel. Don't assume packed.\n uint64_t wh = ((uint64_t)pixcfg->private_impl.width) *\n ((uint64_t)pixcfg->private_impl.height);\n if (wh > pixbuf_memory.len) {\n return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;\n }\n b->private_impl.pixcfg = *pixcfg;\n wuffs_base__table_u8* tab = &b->private_impl.planes[0];\n tab->ptr = pixbuf_memory.ptr;\n tab->width = pixcfg->private_impl.width;\n tab->height = pixcfg->private_impl.height;\n tab->stride = pixcfg->private_impl.width;\n return WUFFS_BASE__STATUS_OK;\n}\n\n// The palette argument is ignored unless its length is exactly 1024.\nstatic inline void //\nwuffs_base__pixel_buffer__set_palette(wuffs_base__pixel_buffer* b,\n " +
|
||||
" wuffs_base__slice_u8 palette) {\n if (b && palette.ptr && (palette.len == 1024)) {\n memmove(b->private_impl.palette, palette.ptr, 1024);\n }\n}\n\n// wuffs_base__pixel_config returns the overall configuration for this frame.\nstatic inline wuffs_base__pixel_config* //\nwuffs_base__pixel_buffer__pixel_config(wuffs_base__pixel_buffer* b) {\n return b ? &b->private_impl.pixcfg : NULL;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_buffer__bounds(wuffs_base__pixel_buffer* b) {\n return b ? wuffs_base__pixel_config__bounds(&b->private_impl.pixcfg)\n : ((wuffs_base__rect_ie_u32){});\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_buffer__width(wuffs_base__pixel_buffer* b) {\n return b ? wuffs_base__pixel_config__width(&b->private_impl.pixcfg) : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_buffer__height(wuffs_base__pixel_buffer* b) {\n return b ? wuffs_base__pixel_config__height(&b->private_impl.pixcfg) : 0;\n}\n\nstatic inline wuffs_base__table_u8 //\nwuffs_base__pixel_" +
|
||||
"buffer__plane(wuffs_base__pixel_buffer* b, uint32_t p) {\n return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))\n ? b->private_impl.planes[p]\n : ((wuffs_base__table_u8){});\n}\n\n// wuffs_base__pixel_buffer__palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__pixel_buffer__palette(wuffs_base__pixel_buffer* b) {\n return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,\n .len = 1024})\n : ((wuffs_base__slice_u8){});\n}\n\n#ifdef __cplusplus\n\ninline wuffs_base__status //\nwuffs_base__pixel_buffer::set_from_slice(wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory) {\n return wuffs_base__pixel_buffer__set_from_slice(this, pixcfg, pixbuf_memory);\n}\n\ninline void //\nwuffs_base__pixel_buffer::set_palette(wuffs_base__slice_u8 palette) {\n wuffs_base__pixel_buffer__set_pa" +
|
||||
"lette(this, palette);\n}\n\ninline wuffs_base__pixel_config* //\nwuffs_base__pixel_buffer::pixel_config() {\n return wuffs_base__pixel_buffer__pixel_config(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_buffer::bounds() {\n return wuffs_base__pixel_buffer__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_buffer::width() {\n return wuffs_base__pixel_buffer__width(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_buffer::height() {\n return wuffs_base__pixel_buffer__height(this);\n}\n\ninline wuffs_base__table_u8 //\nwuffs_base__pixel_buffer::plane(uint32_t p) {\n return wuffs_base__pixel_buffer__plane(this, p);\n}\n\ninline wuffs_base__slice_u8 //\nwuffs_base__pixel_buffer::palette() {\n return wuffs_base__pixel_buffer__palette(this);\n}\n\n#endif // __cplusplus\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n" +
|
||||
""
|
||||
|
||||
type template_args_short_read struct {
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@
|
||||
- Renamed `u32`, `io_reader`, etc to `base.u32`, `base.io_reader`, etc.
|
||||
- Renamed `unread_u8?` to `undo_byte!`; added `can_undo_byte`.
|
||||
- Redesigned iterate blocks.
|
||||
- Added a `base.image_config` type.
|
||||
- Added `{frame,image,pixel}_config` and `pixel_buffer` types.
|
||||
- Added a `reset` method.
|
||||
- Added `peek_uxx`, `skip_fast` and `write_fast_uxx` methods.
|
||||
- Tweaked how marks and limits work.
|
||||
- Supported animated (not just single frame) GIFs.
|
||||
- Supported animated (not just single frame) and interlaced GIFs.
|
||||
- Marked the `std/gif` LZW decoder as private.
|
||||
- Marked some internal status codes as private.
|
||||
- Changed the string messages for built-in status codes.
|
||||
|
||||
@@ -89,8 +89,7 @@ size_t print_len = 0;
|
||||
|
||||
bool first_play = true;
|
||||
uint32_t num_loops_remaining = 0;
|
||||
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
||||
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||
wuffs_base__pixel_buffer pb = ((wuffs_base__pixel_buffer){});
|
||||
|
||||
wuffs_base__flicks cumulative_delay_micros = 0;
|
||||
|
||||
@@ -132,10 +131,9 @@ static inline uint32_t load_u32le(uint8_t* p) {
|
||||
((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);
|
||||
}
|
||||
|
||||
void restore_background(wuffs_base__image_buffer* ib) {
|
||||
size_t width = wuffs_base__image_buffer__width(ib);
|
||||
|
||||
wuffs_base__rect_ie_u32 bounds = wuffs_base__image_buffer__dirty_rect(ib);
|
||||
void restore_background(wuffs_base__pixel_buffer* pb,
|
||||
wuffs_base__rect_ie_u32 bounds) {
|
||||
size_t width = wuffs_base__pixel_buffer__width(pb);
|
||||
size_t y;
|
||||
for (y = bounds.min_incl_y; y < bounds.max_excl_y; y++) {
|
||||
size_t x;
|
||||
@@ -146,11 +144,12 @@ void restore_background(wuffs_base__image_buffer* ib) {
|
||||
}
|
||||
}
|
||||
|
||||
void compose(wuffs_base__image_buffer* ib) {
|
||||
uint8_t* palette = wuffs_base__image_buffer__palette(ib).ptr;
|
||||
size_t width = wuffs_base__image_buffer__width(ib);
|
||||
|
||||
wuffs_base__rect_ie_u32 bounds = wuffs_base__image_buffer__dirty_rect(ib);
|
||||
void compose(wuffs_base__pixel_buffer* pb, wuffs_base__rect_ie_u32 bounds) {
|
||||
wuffs_base__slice_u8 palette = wuffs_base__pixel_buffer__palette(pb);
|
||||
if (palette.len != 1024) {
|
||||
return;
|
||||
}
|
||||
size_t width = wuffs_base__pixel_buffer__width(pb);
|
||||
size_t y;
|
||||
for (y = bounds.min_incl_y; y < bounds.max_excl_y; y++) {
|
||||
size_t x;
|
||||
@@ -158,7 +157,7 @@ void compose(wuffs_base__image_buffer* ib) {
|
||||
uint8_t* s = image_buffer + (y * width) + bounds.min_incl_x;
|
||||
for (x = bounds.min_incl_x; x < bounds.max_excl_x; x++) {
|
||||
uint32_t index = *s++;
|
||||
wuffs_base__color_u32argb c = load_u32le(palette + 4 * index);
|
||||
wuffs_base__color_u32argb c = load_u32le(palette.ptr + 4 * index);
|
||||
if (c) {
|
||||
*d = c;
|
||||
}
|
||||
@@ -167,9 +166,9 @@ void compose(wuffs_base__image_buffer* ib) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t print_ascii_art(wuffs_base__image_buffer* ib) {
|
||||
uint32_t width = wuffs_base__image_buffer__width(ib);
|
||||
uint32_t height = wuffs_base__image_buffer__height(ib);
|
||||
size_t print_ascii_art(wuffs_base__pixel_buffer* pb) {
|
||||
uint32_t width = wuffs_base__pixel_buffer__width(pb);
|
||||
uint32_t height = wuffs_base__pixel_buffer__height(pb);
|
||||
|
||||
wuffs_base__color_u32argb* d = dst_buffer;
|
||||
uint8_t* p = print_buffer;
|
||||
@@ -193,9 +192,9 @@ size_t print_ascii_art(wuffs_base__image_buffer* ib) {
|
||||
return p - print_buffer;
|
||||
}
|
||||
|
||||
size_t print_color_art(wuffs_base__image_buffer* ib) {
|
||||
uint32_t width = wuffs_base__image_buffer__width(ib);
|
||||
uint32_t height = wuffs_base__image_buffer__height(ib);
|
||||
size_t print_color_art(wuffs_base__pixel_buffer* pb) {
|
||||
uint32_t width = wuffs_base__pixel_buffer__width(pb);
|
||||
uint32_t height = wuffs_base__pixel_buffer__height(pb);
|
||||
|
||||
wuffs_base__color_u32argb* d = dst_buffer;
|
||||
uint8_t* p = print_buffer;
|
||||
@@ -221,8 +220,8 @@ size_t print_color_art(wuffs_base__image_buffer* ib) {
|
||||
|
||||
// ----
|
||||
|
||||
const char* allocate(wuffs_base__image_config* ic) {
|
||||
image_len = wuffs_base__image_config__pixbuf_size(ic);
|
||||
const char* allocate(wuffs_base__pixel_config* pc) {
|
||||
image_len = wuffs_base__pixel_config__pixbuf_size(pc);
|
||||
if (image_len > (SIZE_MAX / sizeof(wuffs_base__color_u32argb))) {
|
||||
return "could not allocate dst buffer";
|
||||
}
|
||||
@@ -249,8 +248,8 @@ const char* allocate(wuffs_base__image_config* ic) {
|
||||
return "could not allocate image buffer";
|
||||
}
|
||||
|
||||
uint32_t width = wuffs_base__image_config__width(ic);
|
||||
uint32_t height = wuffs_base__image_config__height(ic);
|
||||
uint32_t width = wuffs_base__pixel_config__width(pc);
|
||||
uint32_t height = wuffs_base__pixel_config__height(pc);
|
||||
uint64_t plen = 1 + ((uint64_t)(width) + 1) * (uint64_t)(height);
|
||||
uint64_t bytes_per_print_pixel = color_flag ? BYTES_PER_COLOR_PIXEL : 1;
|
||||
if (plen <= ((uint64_t)SIZE_MAX) / bytes_per_print_pixel) {
|
||||
@@ -280,6 +279,7 @@ const char* play() {
|
||||
|
||||
if (first_play) {
|
||||
first_play = false;
|
||||
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||
wuffs_base__status s =
|
||||
wuffs_gif__decoder__decode_image_config(&dec, &ic, src_reader);
|
||||
if (s) {
|
||||
@@ -293,12 +293,12 @@ const char* play() {
|
||||
if ((width > MAX_DIMENSION) || (height > MAX_DIMENSION)) {
|
||||
return "image dimensions are too large";
|
||||
}
|
||||
const char* msg = allocate(&ic);
|
||||
const char* msg = allocate(wuffs_base__image_config__pixel_config(&ic));
|
||||
if (msg) {
|
||||
return msg;
|
||||
}
|
||||
s = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic,
|
||||
s = wuffs_base__pixel_buffer__set_from_slice(
|
||||
&pb, wuffs_base__image_config__pixel_config(&ic),
|
||||
((wuffs_base__slice_u8){.ptr = image_buffer, .len = image_len}));
|
||||
if (s) {
|
||||
return wuffs_gif__status__string(s);
|
||||
@@ -313,8 +313,9 @@ const char* play() {
|
||||
// upcoming frame is WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS.
|
||||
memcpy(prev_dst_buffer, dst_buffer, dst_len);
|
||||
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
wuffs_base__status s = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &ib, src_reader, ((wuffs_base__slice_u8){}));
|
||||
&dec, &fc, &pb, src_reader, ((wuffs_base__slice_u8){}));
|
||||
if (s) {
|
||||
if (s == WUFFS_BASE__SUSPENSION_END_OF_DATA) {
|
||||
break;
|
||||
@@ -322,13 +323,13 @@ const char* play() {
|
||||
return wuffs_gif__status__string(s);
|
||||
}
|
||||
|
||||
compose(&ib);
|
||||
compose(&pb, wuffs_base__frame_config__bounds(&fc));
|
||||
|
||||
size_t n = color_flag ? print_color_art(&ib) : print_ascii_art(&ib);
|
||||
size_t n = color_flag ? print_color_art(&pb) : print_ascii_art(&pb);
|
||||
|
||||
switch (wuffs_base__image_buffer__disposal(&ib)) {
|
||||
switch (wuffs_base__frame_config__disposal(&fc)) {
|
||||
case WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND: {
|
||||
restore_background(&ib);
|
||||
restore_background(&pb, wuffs_base__frame_config__bounds(&fc));
|
||||
break;
|
||||
}
|
||||
case WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS: {
|
||||
@@ -361,7 +362,7 @@ const char* play() {
|
||||
ignore_return_value(write(stdout_fd, print_buffer, n));
|
||||
|
||||
cumulative_delay_micros +=
|
||||
(1000 * wuffs_base__image_buffer__duration(&ib)) /
|
||||
(1000 * wuffs_base__frame_config__duration(&fc)) /
|
||||
WUFFS_BASE__FLICKS_PER_MILLISECOND;
|
||||
|
||||
// TODO: should a zero duration mean to show this frame forever?
|
||||
|
||||
@@ -57,7 +57,6 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
||||
wuffs_gif__decoder dec = ((wuffs_gif__decoder){});
|
||||
wuffs_gif__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
||||
|
||||
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
||||
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||
s = wuffs_gif__decoder__decode_image_config(&dec, &ic, src_reader);
|
||||
if (s) {
|
||||
@@ -69,7 +68,8 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
size_t pixbuf_size = wuffs_base__image_config__pixbuf_size(&ic);
|
||||
size_t pixbuf_size = wuffs_base__pixel_config__pixbuf_size(
|
||||
wuffs_base__image_config__pixel_config(&ic));
|
||||
// Don't try to allocate more than 64 MiB.
|
||||
if (pixbuf_size > 64 * 1024 * 1024) {
|
||||
ret = "image too large";
|
||||
@@ -80,8 +80,10 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
||||
ret = "out of memory";
|
||||
goto exit;
|
||||
}
|
||||
s = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic, ((wuffs_base__slice_u8){.ptr = pixbuf, .len = pixbuf_size}));
|
||||
wuffs_base__pixel_buffer pb = ((wuffs_base__pixel_buffer){});
|
||||
s = wuffs_base__pixel_buffer__set_from_slice(
|
||||
&pb, wuffs_base__image_config__pixel_config(&ic),
|
||||
((wuffs_base__slice_u8){.ptr = pixbuf, .len = pixbuf_size}));
|
||||
if (s) {
|
||||
ret = wuffs_gif__status__string(s);
|
||||
goto exit;
|
||||
@@ -89,7 +91,8 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
||||
|
||||
bool seen_ok = false;
|
||||
while (true) {
|
||||
s = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader,
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
s = wuffs_gif__decoder__decode_frame(&dec, &fc, &pb, src_reader,
|
||||
((wuffs_base__slice_u8){}));
|
||||
if (s) {
|
||||
if ((s == WUFFS_BASE__SUSPENSION_END_OF_DATA) && seen_ok) {
|
||||
|
||||
+21
-14
@@ -88,11 +88,14 @@ var Types = []string{
|
||||
"rect_ie_u32",
|
||||
"rect_ii_u32",
|
||||
|
||||
"image_buffer",
|
||||
"image_config",
|
||||
"io_reader",
|
||||
"io_writer",
|
||||
"status",
|
||||
|
||||
"frame_config",
|
||||
"image_config",
|
||||
"pixel_buffer",
|
||||
"pixel_config",
|
||||
}
|
||||
|
||||
var Funcs = []string{
|
||||
@@ -125,18 +128,6 @@ var Funcs = []string{
|
||||
"utility.make_rect_ii_u32(min_incl_x u32, min_incl_y u32, max_incl_x u32, max_incl_y u32)(ret rect_ii_u32)",
|
||||
"utility.make_rect_ie_u32(min_incl_x u32, min_incl_y u32, max_excl_x u32, max_excl_y u32)(ret rect_ie_u32)",
|
||||
|
||||
// ---- image_buffer
|
||||
|
||||
"image_buffer.plane(p u32[..3])(ret table u8)",
|
||||
// Duration's upper bound is the maximum possible i64 value.
|
||||
"image_buffer.update!(dirty_rect rect_ie_u32, duration u64[..0x7FFFFFFFFFFFFFFF], " +
|
||||
"blend bool, disposal u8, palette slice u8)()",
|
||||
|
||||
// ---- image_config
|
||||
|
||||
"image_config.initialize!(pixfmt u32, pixsub u32, width u32, height u32, " +
|
||||
"num_loops u32, first_frame_is_opaque bool)()",
|
||||
|
||||
// ---- io_reader
|
||||
|
||||
"io_reader.can_undo_byte()(ret bool)",
|
||||
@@ -256,6 +247,22 @@ var Funcs = []string{
|
||||
"status.is_error()(ret bool)",
|
||||
"status.is_ok()(ret bool)",
|
||||
"status.is_suspension()(ret bool)",
|
||||
|
||||
// ---- frame_config
|
||||
|
||||
// Duration's upper bound is the maximum possible i64 value.
|
||||
"frame_config.update!(bounds rect_ie_u32, duration u64[..0x7FFFFFFFFFFFFFFF], " +
|
||||
"blend bool, disposal u8, palette_changed bool)()",
|
||||
|
||||
// ---- image_config
|
||||
|
||||
"image_config.initialize!(pixfmt u32, pixsub u32, width u32, height u32, " +
|
||||
"num_loops u32, first_frame_is_opaque bool)()",
|
||||
|
||||
// ---- pixel_buffer
|
||||
|
||||
"pixel_buffer.plane(p u32[..3])(ret table u8)",
|
||||
"pixel_buffer.set_palette!(palette slice u8)()",
|
||||
}
|
||||
|
||||
// The "T1" and "T2" types here are placeholders for generic "slice T" or
|
||||
|
||||
+14
-8
@@ -58,11 +58,14 @@ var (
|
||||
typeExprRectIEU32 = a.NewTypeExpr(0, t.IDBase, t.IDRectIEU32, nil, nil, nil)
|
||||
typeExprRectIIU32 = a.NewTypeExpr(0, t.IDBase, t.IDRectIIU32, nil, nil, nil)
|
||||
|
||||
typeExprImageBuffer = a.NewTypeExpr(0, t.IDBase, t.IDImageBuffer, nil, nil, nil)
|
||||
typeExprIOReader = a.NewTypeExpr(0, t.IDBase, t.IDIOReader, nil, nil, nil)
|
||||
typeExprIOWriter = a.NewTypeExpr(0, t.IDBase, t.IDIOWriter, nil, nil, nil)
|
||||
typeExprStatus = a.NewTypeExpr(0, t.IDBase, t.IDStatus, nil, nil, nil)
|
||||
|
||||
typeExprFrameConfig = a.NewTypeExpr(0, t.IDBase, t.IDFrameConfig, nil, nil, nil)
|
||||
typeExprImageConfig = a.NewTypeExpr(0, t.IDBase, t.IDImageConfig, nil, nil, nil)
|
||||
typeExprIOReader = a.NewTypeExpr(0, t.IDBase, t.IDIOReader, nil, nil, nil)
|
||||
typeExprIOWriter = a.NewTypeExpr(0, t.IDBase, t.IDIOWriter, nil, nil, nil)
|
||||
typeExprStatus = a.NewTypeExpr(0, t.IDBase, t.IDStatus, nil, nil, nil)
|
||||
typeExprPixelBuffer = a.NewTypeExpr(0, t.IDBase, t.IDPixelBuffer, nil, nil, nil)
|
||||
typeExprPixelConfig = a.NewTypeExpr(0, t.IDBase, t.IDPixelConfig, nil, nil, nil)
|
||||
|
||||
typeExprSliceU8 = a.NewTypeExpr(t.IDSlice, 0, 0, nil, nil, typeExprU8)
|
||||
typeExprTableU8 = a.NewTypeExpr(t.IDTable, 0, 0, nil, nil, typeExprU8)
|
||||
@@ -93,11 +96,14 @@ var builtInTypeMap = typeMap{
|
||||
t.IDRectIEU32: typeExprRectIEU32,
|
||||
t.IDRectIIU32: typeExprRectIIU32,
|
||||
|
||||
t.IDImageBuffer: typeExprImageBuffer,
|
||||
t.IDIOReader: typeExprIOReader,
|
||||
t.IDIOWriter: typeExprIOWriter,
|
||||
t.IDStatus: typeExprStatus,
|
||||
|
||||
t.IDFrameConfig: typeExprFrameConfig,
|
||||
t.IDImageConfig: typeExprImageConfig,
|
||||
t.IDIOReader: typeExprIOReader,
|
||||
t.IDIOWriter: typeExprIOWriter,
|
||||
t.IDStatus: typeExprStatus,
|
||||
t.IDPixelBuffer: typeExprPixelBuffer,
|
||||
t.IDPixelConfig: typeExprPixelConfig,
|
||||
}
|
||||
|
||||
func (c *Checker) parseBuiltInFuncs(ss []string, generic bool) (map[t.QQID]*a.Func, error) {
|
||||
|
||||
+15
-9
@@ -412,11 +412,14 @@ const (
|
||||
IDRectIEU32 = ID(0x10C)
|
||||
IDRectIIU32 = ID(0x10D)
|
||||
|
||||
IDImageBuffer = ID(0x110)
|
||||
IDImageConfig = ID(0x111)
|
||||
IDIOReader = ID(0x112)
|
||||
IDIOWriter = ID(0x113)
|
||||
IDStatus = ID(0x114)
|
||||
IDIOReader = ID(0x110)
|
||||
IDIOWriter = ID(0x111)
|
||||
IDStatus = ID(0x112)
|
||||
|
||||
IDFrameConfig = ID(0x114)
|
||||
IDImageConfig = ID(0x115)
|
||||
IDPixelBuffer = ID(0x116)
|
||||
IDPixelConfig = ID(0x117)
|
||||
|
||||
IDT1 = ID(0x118)
|
||||
IDT2 = ID(0x119)
|
||||
@@ -679,11 +682,14 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
IDRectIEU32: "rect_ie_u32",
|
||||
IDRectIIU32: "rect_ii_u32",
|
||||
|
||||
IDImageBuffer: "image_buffer",
|
||||
IDIOReader: "io_reader",
|
||||
IDIOWriter: "io_writer",
|
||||
IDStatus: "status",
|
||||
|
||||
IDFrameConfig: "frame_config",
|
||||
IDImageConfig: "image_config",
|
||||
IDIOReader: "io_reader",
|
||||
IDIOWriter: "io_writer",
|
||||
IDStatus: "status",
|
||||
IDPixelBuffer: "pixel_buffer",
|
||||
IDPixelConfig: "pixel_config",
|
||||
|
||||
// Some of the next few IDs are never returned by the tokenizer, as it
|
||||
// rejects non-ASCII input. The string representations "¶", "ℤ" etc. are
|
||||
|
||||
+404
-228
@@ -1291,10 +1291,6 @@ wuffs_base__pixel_format__num_planes(wuffs_base__pixel_format f) {
|
||||
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
|
||||
@@ -1385,6 +1381,165 @@ typedef struct {
|
||||
wuffs_base__pixel_subsampling pixsub;
|
||||
uint32_t width;
|
||||
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;
|
||||
bool first_frame_is_opaque;
|
||||
} private_impl;
|
||||
@@ -1398,6 +1553,7 @@ typedef struct {
|
||||
bool first_frame_is_opaque);
|
||||
inline void invalidate();
|
||||
inline bool is_valid();
|
||||
inline wuffs_base__pixel_config* pixel_config();
|
||||
inline wuffs_base__pixel_format pixel_format();
|
||||
inline wuffs_base__pixel_subsampling pixel_subsampling();
|
||||
inline wuffs_base__rect_ie_u32 bounds();
|
||||
@@ -1405,7 +1561,6 @@ typedef struct {
|
||||
inline uint32_t height();
|
||||
inline uint32_t num_loops();
|
||||
inline uint32_t first_frame_is_opaque();
|
||||
inline size_t pixbuf_size();
|
||||
#endif // __cplusplus
|
||||
|
||||
} wuffs_base__image_config;
|
||||
@@ -1422,18 +1577,14 @@ wuffs_base__image_config__initialize(wuffs_base__image_config* c,
|
||||
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;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
c->private_impl.first_frame_is_opaque = first_frame_is_opaque;
|
||||
return;
|
||||
}
|
||||
if (wuffs_base__pixel_format__is_valid(pixfmt)) {
|
||||
c->private_impl.pixcfg.private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixcfg.private_impl.pixsub = pixsub;
|
||||
c->private_impl.pixcfg.private_impl.width = width;
|
||||
c->private_impl.pixcfg.private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
c->private_impl.first_frame_is_opaque = first_frame_is_opaque;
|
||||
return;
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
@@ -1447,17 +1598,22 @@ wuffs_base__image_config__invalidate(wuffs_base__image_config* c) {
|
||||
|
||||
static inline bool //
|
||||
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 //
|
||||
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 //
|
||||
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 //
|
||||
@@ -1465,20 +1621,20 @@ wuffs_base__image_config__bounds(wuffs_base__image_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,
|
||||
.max_excl_x = c->private_impl.pixcfg.private_impl.width,
|
||||
.max_excl_y = c->private_impl.pixcfg.private_impl.height,
|
||||
})
|
||||
: ((wuffs_base__rect_ie_u32){});
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
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 //
|
||||
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 //
|
||||
@@ -1491,20 +1647,6 @@ wuffs_base__image_config__first_frame_is_opaque(wuffs_base__image_config* c) {
|
||||
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
|
||||
|
||||
inline void //
|
||||
@@ -1528,6 +1670,11 @@ wuffs_base__image_config::is_valid() {
|
||||
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 //
|
||||
wuffs_base__image_config::pixel_format() {
|
||||
return wuffs_base__image_config__pixel_format(this);
|
||||
@@ -1563,11 +1710,6 @@ wuffs_base__image_config::first_frame_is_opaque() {
|
||||
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
|
||||
|
||||
// --------
|
||||
@@ -1594,260 +1736,284 @@ 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__image_config config;
|
||||
wuffs_base__pixel_buffer pixbuf;
|
||||
// TODO: color spaces.
|
||||
wuffs_base__rect_ie_u32 dirty_rect;
|
||||
wuffs_base__rect_ie_u32 bounds;
|
||||
wuffs_base__flicks duration;
|
||||
bool blend;
|
||||
wuffs_base__animation_disposal disposal;
|
||||
bool palette_changed;
|
||||
uint8_t palette[1024];
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline wuffs_base__status set_from_pixbuf(wuffs_base__image_config config,
|
||||
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,
|
||||
inline void update(wuffs_base__rect_ie_u32 bounds,
|
||||
wuffs_base__flicks duration,
|
||||
bool blend,
|
||||
wuffs_base__animation_disposal disposal,
|
||||
wuffs_base__slice_u8 palette);
|
||||
inline wuffs_base__image_config* image_config();
|
||||
bool palette_changed);
|
||||
inline wuffs_base__rect_ie_u32 bounds();
|
||||
inline uint32_t width();
|
||||
inline uint32_t height();
|
||||
inline wuffs_base__rect_ie_u32 dirty_rect();
|
||||
inline wuffs_base__flicks duration();
|
||||
inline bool blend();
|
||||
inline wuffs_base__animation_disposal disposal();
|
||||
inline bool palette_changed();
|
||||
inline wuffs_base__slice_u8 palette();
|
||||
inline wuffs_base__table_u8 plane(uint32_t p);
|
||||
#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 //
|
||||
wuffs_base__image_buffer__update(wuffs_base__image_buffer* b,
|
||||
wuffs_base__rect_ie_u32 dirty_rect,
|
||||
wuffs_base__frame_config__update(wuffs_base__frame_config* c,
|
||||
wuffs_base__rect_ie_u32 bounds,
|
||||
wuffs_base__flicks duration,
|
||||
bool blend,
|
||||
wuffs_base__animation_disposal disposal,
|
||||
wuffs_base__slice_u8 palette) {
|
||||
if (!b) {
|
||||
bool palette_changed) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clip the dirty_rect to the image bounds.
|
||||
dirty_rect.max_excl_x = wuffs_base__u32__min(
|
||||
dirty_rect.max_excl_x, b->private_impl.config.private_impl.width);
|
||||
dirty_rect.max_excl_y = wuffs_base__u32__min(
|
||||
dirty_rect.max_excl_y, b->private_impl.config.private_impl.height);
|
||||
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;
|
||||
c->private_impl.bounds = bounds;
|
||||
c->private_impl.duration = duration;
|
||||
c->private_impl.blend = blend;
|
||||
c->private_impl.disposal = disposal;
|
||||
c->private_impl.palette_changed = palette_changed;
|
||||
}
|
||||
|
||||
static inline wuffs_base__rect_ie_u32 //
|
||||
wuffs_base__image_buffer__bounds(wuffs_base__image_buffer* b) {
|
||||
return b ? wuffs_base__image_config__bounds(&b->private_impl.config)
|
||||
: ((wuffs_base__rect_ie_u32){});
|
||||
wuffs_base__frame_config__bounds(wuffs_base__frame_config* c) {
|
||||
return c ? c->private_impl.bounds : ((wuffs_base__rect_ie_u32){});
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__image_buffer__width(wuffs_base__image_buffer* b) {
|
||||
return b ? wuffs_base__image_config__width(&b->private_impl.config) : 0;
|
||||
wuffs_base__frame_config__width(wuffs_base__frame_config* c) {
|
||||
return c ? wuffs_base__rect_ie_u32__width(&c->private_impl.bounds) : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__image_buffer__height(wuffs_base__image_buffer* b) {
|
||||
return b ? wuffs_base__image_config__height(&b->private_impl.config) : 0;
|
||||
wuffs_base__frame_config__height(wuffs_base__frame_config* c) {
|
||||
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
|
||||
// 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
|
||||
// wuffs_base__frame_config__duration returns the amount of time to display
|
||||
// this frame. Zero means to display forever - a still (non-animated) image.
|
||||
static inline wuffs_base__flicks //
|
||||
wuffs_base__image_buffer__duration(wuffs_base__image_buffer* b) {
|
||||
return b ? b->private_impl.duration : 0;
|
||||
wuffs_base__frame_config__duration(wuffs_base__frame_config* c) {
|
||||
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.
|
||||
//
|
||||
// In Porter-Duff compositing operator terminology, false means "src" and true
|
||||
// means "src over dst".
|
||||
static inline bool //
|
||||
wuffs_base__image_buffer__blend(wuffs_base__image_buffer* b) {
|
||||
return b && b->private_impl.blend;
|
||||
wuffs_base__frame_config__blend(wuffs_base__frame_config* c) {
|
||||
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.
|
||||
static inline wuffs_base__animation_disposal //
|
||||
wuffs_base__image_buffer__disposal(wuffs_base__image_buffer* b) {
|
||||
return b ? b->private_impl.disposal : 0;
|
||||
wuffs_base__frame_config__disposal(wuffs_base__frame_config* c) {
|
||||
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
|
||||
// false positives (but never false negatives).
|
||||
static inline bool //
|
||||
wuffs_base__image_buffer__palette_changed(wuffs_base__image_buffer* b) {
|
||||
return b && b->private_impl.palette_changed;
|
||||
wuffs_base__frame_config__palette_changed(wuffs_base__frame_config* c) {
|
||||
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.
|
||||
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,
|
||||
.len = 1024})
|
||||
: ((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
|
||||
|
||||
inline wuffs_base__status //
|
||||
wuffs_base__image_buffer::set_from_pixbuf(wuffs_base__image_config config,
|
||||
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__pixel_buffer::set_from_slice(wuffs_base__pixel_config* pixcfg,
|
||||
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 //
|
||||
wuffs_base__image_buffer::update(wuffs_base__rect_ie_u32 dirty_rect,
|
||||
wuffs_base__flicks duration,
|
||||
bool blend,
|
||||
wuffs_base__animation_disposal disposal,
|
||||
wuffs_base__slice_u8 palette) {
|
||||
wuffs_base__image_buffer__update(this, dirty_rect, duration, blend, disposal,
|
||||
palette);
|
||||
wuffs_base__pixel_buffer::set_palette(wuffs_base__slice_u8 palette) {
|
||||
wuffs_base__pixel_buffer__set_palette(this, palette);
|
||||
}
|
||||
|
||||
inline wuffs_base__image_config* //
|
||||
wuffs_base__image_buffer::image_config() {
|
||||
return wuffs_base__image_buffer__image_config(this);
|
||||
inline wuffs_base__pixel_config* //
|
||||
wuffs_base__pixel_buffer::pixel_config() {
|
||||
return wuffs_base__pixel_buffer__pixel_config(this);
|
||||
}
|
||||
|
||||
inline wuffs_base__rect_ie_u32 //
|
||||
wuffs_base__image_buffer::bounds() {
|
||||
return wuffs_base__image_buffer__bounds(this);
|
||||
wuffs_base__pixel_buffer::bounds() {
|
||||
return wuffs_base__pixel_buffer__bounds(this);
|
||||
}
|
||||
|
||||
inline uint32_t //
|
||||
wuffs_base__image_buffer::width() {
|
||||
return wuffs_base__image_buffer__width(this);
|
||||
wuffs_base__pixel_buffer::width() {
|
||||
return wuffs_base__pixel_buffer__width(this);
|
||||
}
|
||||
|
||||
inline uint32_t //
|
||||
wuffs_base__image_buffer::height() {
|
||||
return wuffs_base__image_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);
|
||||
wuffs_base__pixel_buffer::height() {
|
||||
return wuffs_base__pixel_buffer__height(this);
|
||||
}
|
||||
|
||||
inline wuffs_base__table_u8 //
|
||||
wuffs_base__image_buffer::plane(uint32_t p) {
|
||||
return wuffs_base__image_buffer__plane(this, p);
|
||||
wuffs_base__pixel_buffer::plane(uint32_t 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
|
||||
@@ -2454,7 +2620,8 @@ typedef struct {
|
||||
wuffs_base__io_reader a_src);
|
||||
inline uint64_t frame_count();
|
||||
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(wuffs_base__frame_config* a_dst0,
|
||||
wuffs_base__pixel_buffer* a_dst1,
|
||||
wuffs_base__io_reader a_src,
|
||||
wuffs_base__slice_u8 a_work_buffer);
|
||||
#endif // __cplusplus
|
||||
@@ -2487,7 +2654,8 @@ wuffs_gif__decoder__work_buffer_size(wuffs_gif__decoder* self);
|
||||
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status //
|
||||
wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
||||
wuffs_base__image_buffer* a_dst,
|
||||
wuffs_base__frame_config* a_dst0,
|
||||
wuffs_base__pixel_buffer* a_dst1,
|
||||
wuffs_base__io_reader a_src,
|
||||
wuffs_base__slice_u8 a_work_buffer);
|
||||
|
||||
@@ -2519,10 +2687,12 @@ wuffs_gif__decoder::work_buffer_size() {
|
||||
}
|
||||
|
||||
inline wuffs_base__status //
|
||||
wuffs_gif__decoder::decode_frame(wuffs_base__image_buffer* a_dst,
|
||||
wuffs_gif__decoder::decode_frame(wuffs_base__frame_config* a_dst0,
|
||||
wuffs_base__pixel_buffer* a_dst1,
|
||||
wuffs_base__io_reader a_src,
|
||||
wuffs_base__slice_u8 a_work_buffer) {
|
||||
return wuffs_gif__decoder__decode_frame(this, a_dst, a_src, a_work_buffer);
|
||||
return wuffs_gif__decoder__decode_frame(this, a_dst0, a_dst1, a_src,
|
||||
a_work_buffer);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
@@ -6492,12 +6662,13 @@ wuffs_gif__decoder__decode_id_part0(wuffs_gif__decoder* self,
|
||||
|
||||
static wuffs_base__status //
|
||||
wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||
wuffs_base__image_buffer* a_dst,
|
||||
wuffs_base__frame_config* a_dst0,
|
||||
wuffs_base__pixel_buffer* a_dst1,
|
||||
wuffs_base__io_reader a_src);
|
||||
|
||||
static wuffs_base__status //
|
||||
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
|
||||
|
||||
@@ -6657,7 +6828,8 @@ wuffs_gif__decoder__work_buffer_size(wuffs_gif__decoder* self) {
|
||||
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status //
|
||||
wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
||||
wuffs_base__image_buffer* a_dst,
|
||||
wuffs_base__frame_config* a_dst0,
|
||||
wuffs_base__pixel_buffer* a_dst1,
|
||||
wuffs_base__io_reader a_src,
|
||||
wuffs_base__slice_u8 a_work_buffer) {
|
||||
if (!self) {
|
||||
@@ -6670,7 +6842,7 @@ wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
||||
if (self->private_impl.status < 0) {
|
||||
return self->private_impl.status;
|
||||
}
|
||||
if (!a_dst) {
|
||||
if (!a_dst0 || !a_dst1) {
|
||||
self->private_impl.status = WUFFS_BASE__ERROR_BAD_ARGUMENT;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT;
|
||||
}
|
||||
@@ -6709,7 +6881,7 @@ wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
||||
}
|
||||
}
|
||||
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_dst0, a_dst1, a_src);
|
||||
if (status) {
|
||||
goto suspend;
|
||||
}
|
||||
@@ -7948,7 +8120,8 @@ short_read_src:
|
||||
|
||||
static wuffs_base__status //
|
||||
wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||
wuffs_base__image_buffer* a_dst,
|
||||
wuffs_base__frame_config* a_dst0,
|
||||
wuffs_base__pixel_buffer* a_dst1,
|
||||
wuffs_base__io_reader a_src) {
|
||||
wuffs_base__status status = WUFFS_BASE__STATUS_OK;
|
||||
|
||||
@@ -8100,7 +8273,7 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||
}
|
||||
if ((v_z == 0) || (v_z == WUFFS_BASE__SUSPENSION_SHORT_WRITE)) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
status = wuffs_gif__decoder__copy_to_image_buffer(self, a_dst);
|
||||
status = wuffs_gif__decoder__copy_to_image_buffer(self, a_dst1);
|
||||
if (status) {
|
||||
goto suspend;
|
||||
}
|
||||
@@ -8122,7 +8295,7 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||
if (self->private_impl.f_uncompressed_ri !=
|
||||
self->private_impl.f_uncompressed_wi) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
status = wuffs_gif__decoder__copy_to_image_buffer(self, a_dst);
|
||||
status = wuffs_gif__decoder__copy_to_image_buffer(self, a_dst1);
|
||||
if (status) {
|
||||
goto suspend;
|
||||
}
|
||||
@@ -8136,15 +8309,18 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||
v_palette = ((wuffs_base__slice_u8){
|
||||
.ptr = self->private_impl.f_palettes[0], .len = 1024});
|
||||
}
|
||||
wuffs_base__image_buffer__update(
|
||||
a_dst,
|
||||
wuffs_base__frame_config__update(
|
||||
a_dst0,
|
||||
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_gc_disposal, (((uint64_t)(v_palette.len)) != 0));
|
||||
if (((uint64_t)(v_palette.len)) != 0) {
|
||||
wuffs_base__pixel_buffer__set_palette(a_dst1, 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);
|
||||
@@ -8188,7 +8364,7 @@ short_read_src:
|
||||
|
||||
static wuffs_base__status //
|
||||
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__slice_u8 v_dst;
|
||||
@@ -8201,7 +8377,7 @@ wuffs_gif__decoder__copy_to_image_buffer(wuffs_gif__decoder* self,
|
||||
v_src = ((wuffs_base__slice_u8){});
|
||||
v_n = 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:;
|
||||
while (self->private_impl.f_uncompressed_wi >
|
||||
self->private_impl.f_uncompressed_ri) {
|
||||
|
||||
+16
-11
@@ -145,7 +145,8 @@ pub func decoder.work_buffer_size()(ret base.range_ii_u64) {
|
||||
return this.util.make_range_ii_u64(min_incl:0, max_incl:0)
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame?(dst ptr base.image_buffer, src base.io_reader, work_buffer slice base.u8)() {
|
||||
// TODO: take pixbuf_origin_x and pixbuf_origin_y args.
|
||||
pub func decoder.decode_frame?(dst0 ptr base.frame_config, dst1 ptr base.pixel_buffer, src base.io_reader, work_buffer slice base.u8)() {
|
||||
if this.call_sequence == 0 {
|
||||
this.decode_image_config?(dst:nullptr, src:in.src)
|
||||
}
|
||||
@@ -167,7 +168,7 @@ pub func decoder.decode_frame?(dst ptr base.image_buffer, src base.io_reader, wo
|
||||
}
|
||||
}
|
||||
|
||||
this.decode_id_part1?(dst:in.dst, src:in.src)
|
||||
this.decode_id_part1?(dst0:in.dst0, dst1:in.dst1, src:in.src)
|
||||
this.frame_count_value ~sat+= 1
|
||||
}
|
||||
|
||||
@@ -454,7 +455,7 @@ pri func decoder.decode_id_part0?(src base.io_reader)() {
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.decode_id_part1?(dst ptr base.image_buffer, src base.io_reader)() {
|
||||
pri func decoder.decode_id_part1?(dst0 ptr base.frame_config, dst1 ptr base.pixel_buffer, src base.io_reader)() {
|
||||
if this.gc_has_transparent_index {
|
||||
if not this.use_local_palette {
|
||||
this.palettes[1][:].copy_from_slice(s:this.palettes[0][:])
|
||||
@@ -518,7 +519,7 @@ pri func decoder.decode_id_part1?(dst ptr base.image_buffer, src base.io_reader)
|
||||
}
|
||||
|
||||
if z.is_ok() or (z == suspension "short write") {
|
||||
this.copy_to_image_buffer?(ib:in.dst)
|
||||
this.copy_to_image_buffer?(pb:in.dst1)
|
||||
|
||||
if z == suspension "short write" {
|
||||
continue:inner
|
||||
@@ -535,7 +536,7 @@ pri func decoder.decode_id_part1?(dst ptr base.image_buffer, src base.io_reader)
|
||||
}
|
||||
|
||||
if this.uncompressed_ri != this.uncompressed_wi {
|
||||
this.copy_to_image_buffer?(ib:in.dst)
|
||||
this.copy_to_image_buffer?(pb:in.dst1)
|
||||
}
|
||||
|
||||
// TODO: check for "not enough pixel data".
|
||||
@@ -550,12 +551,16 @@ pri func decoder.decode_id_part1?(dst ptr base.image_buffer, src base.io_reader)
|
||||
// Both this frame and the previous one used the global palette. No
|
||||
// palette update is necessary.
|
||||
}
|
||||
in.dst.update!(dirty_rect:this.util.make_rect_ie_u32(
|
||||
in.dst0.update!(bounds:this.util.make_rect_ie_u32(
|
||||
min_incl_x:this.frame_rect_x0,
|
||||
min_incl_y:this.frame_rect_y0,
|
||||
max_excl_x:this.frame_rect_x1,
|
||||
max_excl_y:this.frame_rect_y1),
|
||||
duration:this.gc_duration, blend:true, disposal:this.gc_disposal, palette:palette)
|
||||
duration:this.gc_duration, blend:true, disposal:this.gc_disposal,
|
||||
palette_changed:palette.length() != 0)
|
||||
if palette.length() != 0 {
|
||||
in.dst1.set_palette!(palette:palette)
|
||||
}
|
||||
|
||||
this.previous_use_global_palette = not (this.use_local_palette or this.gc_has_transparent_index)
|
||||
|
||||
@@ -568,7 +573,7 @@ pri func decoder.decode_id_part1?(dst ptr base.image_buffer, src base.io_reader)
|
||||
this.gc_duration = 0
|
||||
}
|
||||
|
||||
pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() {
|
||||
pri func decoder.copy_to_image_buffer?(pb ptr base.pixel_buffer)() {
|
||||
// TODO: don't assume a packed pixel format.
|
||||
var dst slice base.u8
|
||||
var src slice base.u8
|
||||
@@ -576,7 +581,7 @@ pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() {
|
||||
// TODO: we shouldn't need this temporary variable.
|
||||
var new_ri base.u32
|
||||
|
||||
var tab table base.u8 = in.ib.plane(p:0)
|
||||
var tab table base.u8 = in.pb.plane(p:0)
|
||||
|
||||
while this.uncompressed_wi > this.uncompressed_ri {
|
||||
assert this.uncompressed_ri < this.uncompressed_wi via "a < b: b > a"()
|
||||
@@ -587,7 +592,7 @@ pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() {
|
||||
}
|
||||
|
||||
// First, copy from src to that part of the frame rect that is inside
|
||||
// in.ib's bounds.
|
||||
// in.pb's bounds.
|
||||
|
||||
dst = tab.row(y:this.dst_y)
|
||||
if (this.dst_x as base.u64) < dst.length() {
|
||||
@@ -622,7 +627,7 @@ pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() {
|
||||
}
|
||||
|
||||
// Second, skip over src for that part of the frame rect that is
|
||||
// outside in.ib's bounds. This second step should be infrequent.
|
||||
// outside in.pb's bounds. This second step should be infrequent.
|
||||
|
||||
// Set n to the number of pixels (i.e. the number of bytes) to skip.
|
||||
n = this.frame_rect_x1 - this.dst_x
|
||||
|
||||
+26
-19
@@ -217,16 +217,17 @@ const char* wuffs_gif_decode(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__io_buffer* src) {
|
||||
wuffs_gif__decoder dec = ((wuffs_gif__decoder){});
|
||||
wuffs_gif__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
||||
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
||||
wuffs_base__pixel_buffer pb = ((wuffs_base__pixel_buffer){});
|
||||
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(src);
|
||||
wuffs_base__status s =
|
||||
wuffs_gif__decoder__decode_image_config(&dec, &ic, src_reader);
|
||||
if (s) {
|
||||
return wuffs_gif__status__string(s);
|
||||
}
|
||||
s = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic,
|
||||
s = wuffs_base__pixel_buffer__set_from_slice(
|
||||
&pb, wuffs_base__image_config__pixel_config(&ic),
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = global_pixel_buffer,
|
||||
.len = WUFFS_TESTLIB_ARRAY_SIZE(global_pixel_buffer),
|
||||
@@ -236,7 +237,7 @@ const char* wuffs_gif_decode(wuffs_base__io_buffer* dst,
|
||||
}
|
||||
|
||||
while (true) {
|
||||
s = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader,
|
||||
s = wuffs_gif__decoder__decode_frame(&dec, &fc, &pb, src_reader,
|
||||
((wuffs_base__slice_u8){}));
|
||||
if (s == WUFFS_BASE__SUSPENSION_END_OF_DATA) {
|
||||
break;
|
||||
@@ -244,7 +245,8 @@ const char* wuffs_gif_decode(wuffs_base__io_buffer* dst,
|
||||
if (s) {
|
||||
return wuffs_gif__status__string(s);
|
||||
}
|
||||
const char* msg = copy_to_io_buffer_from_image_buffer(dst, &ib);
|
||||
const char* msg = copy_to_io_buffer_from_pixel_buffer(
|
||||
dst, &pb, wuffs_base__frame_config__bounds(&fc));
|
||||
if (msg) {
|
||||
return msg;
|
||||
}
|
||||
@@ -268,7 +270,7 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
||||
wuffs_gif__decoder dec = ((wuffs_gif__decoder){});
|
||||
wuffs_gif__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
||||
|
||||
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
||||
wuffs_base__pixel_buffer pb = ((wuffs_base__pixel_buffer){});
|
||||
{
|
||||
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||
@@ -307,8 +309,8 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
||||
FAIL("first_frame_is_opaque: got false, want true");
|
||||
return false;
|
||||
}
|
||||
status = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic,
|
||||
status = wuffs_base__pixel_buffer__set_from_slice(
|
||||
&pb, wuffs_base__image_config__pixel_config(&ic),
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = global_pixel_buffer,
|
||||
.len = WUFFS_TESTLIB_ARRAY_SIZE(global_pixel_buffer),
|
||||
@@ -328,11 +330,13 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
||||
}
|
||||
size_t old_ri = src.ri;
|
||||
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
wuffs_base__status status = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &ib, src_reader, ((wuffs_base__slice_u8){}));
|
||||
&dec, &fc, &pb, src_reader, ((wuffs_base__slice_u8){}));
|
||||
|
||||
if (status == WUFFS_BASE__STATUS_OK) {
|
||||
const char* msg = copy_to_io_buffer_from_image_buffer(&got, &ib);
|
||||
const char* msg = copy_to_io_buffer_from_pixel_buffer(
|
||||
&got, &pb, wuffs_base__frame_config__bounds(&fc));
|
||||
if (msg) {
|
||||
FAIL("%s", msg);
|
||||
return false;
|
||||
@@ -368,7 +372,7 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
||||
}
|
||||
}
|
||||
|
||||
wuffs_base__slice_u8 pal_got_slice = wuffs_base__image_buffer__palette(&ib);
|
||||
wuffs_base__slice_u8 pal_got_slice = wuffs_base__pixel_buffer__palette(&pb);
|
||||
wuffs_base__io_buffer pal_got = {.ptr = pal_got_slice.ptr,
|
||||
.len = pal_got_slice.len,
|
||||
.wi = pal_got_slice.len};
|
||||
@@ -396,8 +400,9 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
||||
return false;
|
||||
}
|
||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
wuffs_base__status status = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &ib, src_reader, ((wuffs_base__slice_u8){}));
|
||||
&dec, &fc, &pb, src_reader, ((wuffs_base__slice_u8){}));
|
||||
if (status != WUFFS_BASE__SUSPENSION_END_OF_DATA) {
|
||||
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
||||
wuffs_gif__status__string(status),
|
||||
@@ -462,7 +467,7 @@ bool do_test_wuffs_gif_decode_animated(
|
||||
wuffs_gif__decoder dec = ((wuffs_gif__decoder){});
|
||||
wuffs_gif__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
||||
|
||||
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
||||
wuffs_base__pixel_buffer pb = ((wuffs_base__pixel_buffer){});
|
||||
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||
|
||||
@@ -479,8 +484,8 @@ bool do_test_wuffs_gif_decode_animated(
|
||||
wuffs_base__image_config__num_loops(&ic), want_num_loops);
|
||||
return false;
|
||||
}
|
||||
status = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic,
|
||||
status = wuffs_base__pixel_buffer__set_from_slice(
|
||||
&pb, wuffs_base__image_config__pixel_config(&ic),
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = global_pixel_buffer,
|
||||
.len = WUFFS_TESTLIB_ARRAY_SIZE(global_pixel_buffer),
|
||||
@@ -492,7 +497,8 @@ bool do_test_wuffs_gif_decode_animated(
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < want_num_frames; i++) {
|
||||
status = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader,
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
status = wuffs_gif__decoder__decode_frame(&dec, &fc, &pb, src_reader,
|
||||
((wuffs_base__slice_u8){}));
|
||||
if (status != WUFFS_BASE__STATUS_OK) {
|
||||
FAIL("decode_frame #%" PRIu32 ": got %" PRIi32 " (%s)", i, status,
|
||||
@@ -501,10 +507,10 @@ bool do_test_wuffs_gif_decode_animated(
|
||||
}
|
||||
|
||||
if (want_dirty_rects) {
|
||||
wuffs_base__rect_ie_u32 got = wuffs_base__image_buffer__dirty_rect(&ib);
|
||||
wuffs_base__rect_ie_u32 got = wuffs_base__frame_config__bounds(&fc);
|
||||
wuffs_base__rect_ie_u32 want = want_dirty_rects[i];
|
||||
if (!wuffs_base__rect_ie_u32__equals(&got, want)) {
|
||||
FAIL("decode_frame #%" PRIu32 ": dirty_rect: got (%" PRIu32 ", %" PRIu32
|
||||
FAIL("decode_frame #%" PRIu32 ": bounds: got (%" PRIu32 ", %" PRIu32
|
||||
")-(%" PRIu32 ", %" PRIu32 "), want (%" PRIu32 ", %" PRIu32
|
||||
")-(%" PRIu32 ", %" PRIu32 ")",
|
||||
i, got.min_incl_x, got.min_incl_y, got.max_excl_x, got.max_excl_y,
|
||||
@@ -516,7 +522,8 @@ bool do_test_wuffs_gif_decode_animated(
|
||||
}
|
||||
|
||||
// There should be no more frames.
|
||||
status = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader,
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
status = wuffs_gif__decoder__decode_frame(&dec, &fc, &pb, src_reader,
|
||||
((wuffs_base__slice_u8){}));
|
||||
if (status != WUFFS_BASE__SUSPENSION_END_OF_DATA) {
|
||||
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
||||
|
||||
@@ -331,13 +331,14 @@ void set_writer_limit(wuffs_base__io_writer* o, uint64_t limit) {
|
||||
}
|
||||
}
|
||||
|
||||
const char* copy_to_io_buffer_from_image_buffer(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__image_buffer* src) {
|
||||
// TODO: we shouldn't need to pass the rect. Instead, pass a subset pixbuf.
|
||||
const char* copy_to_io_buffer_from_pixel_buffer(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__pixel_buffer* src,
|
||||
wuffs_base__rect_ie_u32 r) {
|
||||
// TODO: don't assume 1 plane or WUFFS_BASE__PIXEL_SUBSAMPLING__NONE.
|
||||
uint32_t p;
|
||||
for (p = 0; p < 1; p++) {
|
||||
wuffs_base__table_u8 tab = wuffs_base__image_buffer__plane(src, p);
|
||||
wuffs_base__rect_ie_u32 r = wuffs_base__image_buffer__dirty_rect(src);
|
||||
wuffs_base__table_u8 tab = wuffs_base__pixel_buffer__plane(src, p);
|
||||
uint32_t y;
|
||||
for (y = r.min_incl_y; y < r.max_excl_y; y++) {
|
||||
wuffs_base__slice_u8 row = wuffs_base__table_u8__row(tab, y);
|
||||
@@ -346,7 +347,7 @@ const char* copy_to_io_buffer_from_image_buffer(wuffs_base__io_buffer* dst,
|
||||
}
|
||||
uint32_t n = r.max_excl_x - r.min_incl_x;
|
||||
if (n > (dst->len - dst->wi)) {
|
||||
return "copy_to_io_buffer_from_image_buffer: dst buffer is too small";
|
||||
return "copy_to_io_buffer_from_pixel_buffer: dst buffer is too small";
|
||||
}
|
||||
memmove(dst->ptr + dst->wi, row.ptr + r.min_incl_x, n);
|
||||
dst->wi += n;
|
||||
|
||||
Reference in new issue
Block a user