Rename wuffs_base__image_buffer method args

This commit is contained in:
Nigel Tao committed 2018-05-17 20:52:36 +10:00
1 parent 3521861cc9
commit 33ca57b553
14 files changed
+368 -368

No files matched your search

+28 -28
View File
@@ -985,34 +985,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1020,36 +1020,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1058,22 +1058,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+4 -4
View File
@@ -74,10 +74,10 @@ const baseHeader = "" +
"l.num_loops = num_loops;\n return;\n }\n }\n *c = ((wuffs_base__image_config){});\n}\n\nstatic inline void wuffs_base__image_config__invalidate(\n wuffs_base__image_config* c) {\n if (c) {\n *c = ((wuffs_base__image_config){});\n }\n}\n\nstatic inline bool wuffs_base__image_config__is_valid(\n wuffs_base__image_config* c) {\n return c && c->private_impl.pixfmt;\n}\n\nstatic inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(\n 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 uint32_t wuffs_base__image_config__width(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__height(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__num_loops(\n" + "l.num_loops = num_loops;\n return;\n }\n }\n *c = ((wuffs_base__image_config){});\n}\n\nstatic inline void wuffs_base__image_config__invalidate(\n wuffs_base__image_config* c) {\n if (c) {\n *c = ((wuffs_base__image_config){});\n }\n}\n\nstatic inline bool wuffs_base__image_config__is_valid(\n wuffs_base__image_config* c) {\n return c && c->private_impl.pixfmt;\n}\n\nstatic inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(\n 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 uint32_t wuffs_base__image_config__width(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__height(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__num_loops(\n" +
" wuffs_base__image_config* c) {\n return c ? c->private_impl.num_loops : 0;\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 wuffs_base__image_config__pixbuf_size(\n wuffs_base__image_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" + " wuffs_base__image_config* c) {\n return c ? c->private_impl.num_loops : 0;\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 wuffs_base__image_config__pixbuf_size(\n wuffs_base__image_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" +
"" + "" +
"// --------\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 uint32_t loop_count; // 0-based count of the current loop.\n wuffs_base__pixel_buffer pixbuf;\n // TODO: color spaces.\n wuffs_base__rect_ie_u32 dirty_rect;\n wuffs_base__flicks duration;\n uint8_t palette[1024];\n } private_impl;\n} wuffs_base__image_buffer;\n\nstatic inline void wuffs_base__image_buffer__set_from_pixbuf(\n wuffs_base__image_buffer* f,\n wuffs_base__image_config config,\n wuffs_base__pixel_buffer pixbuf) {\n if (!f) {\n return;\n }\n *f = ((wuffs_base__image_buffer){});\n f->private_impl.config = config;\n f->private_impl.pixbuf = pixbuf;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void wuffs_base__image_buffer__set_from_slice(\n wuffs_base__image_buffer* f,\n wuffs_base__image_config config,\n wuffs_base__slice_u8 pixbuf_memory) {\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 uint32_t loop_count; // 0-based count of the current loop.\n wuffs_base__pixel_buffer pixbuf;\n // TODO: color spaces.\n wuffs_base__rect_ie_u32 dirty_rect;\n wuffs_base__flicks duration;\n uint8_t palette[1024];\n } private_impl;\n} wuffs_base__image_buffer;\n\nstatic inline void wuffs_base__image_buffer__set_from_pixbuf(\n wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__pixel_buffer pixbuf) {\n if (!b) {\n return;\n }\n *b = ((wuffs_base__image_buffer){});\n b->private_impl.config = config;\n b->private_impl.pixbuf = pixbuf;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void wuffs_base__image_buffer__set_from_slice(\n wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__slice_u8 pixbuf_memory) {\n " +
" if (!f) {\n return;\n }\n *f = ((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;\n }\n f->private_impl.config = config;\n wuffs_base__table_u8* tab = &f->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}\n\nstatic inline void wuffs_base__image_buffer__update(\n wuffs_base__image_buffer* f,\n wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n uint8_t* palette_ptr,\n size_t palette_len) {\n if (!f) {\n return;\n }\n f->private_impl.dirty_rect = dirty_rect;\n f->private_impl.duration = duration;\n if (palette_ptr) {\n memmove(f->private_impl.palette, palette_ptr,\n palette_len <= 1024 ? palette_len : 1024);\n }\n}\n\n// wuffs_base__im" + " if (!b) {\n return;\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;\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}\n\nstatic inline void wuffs_base__image_buffer__update(\n wuffs_base__image_buffer* b,\n wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n uint8_t* palette_ptr,\n size_t palette_len) {\n if (!b) {\n return;\n }\n b->private_impl.dirty_rect = dirty_rect;\n b->private_impl.duration = duration;\n if (palette_ptr) {\n memmove(b->private_impl.palette, palette_ptr,\n palette_len <= 1024 ? palette_len : 1024);\n }\n}\n\n// wuffs_base__im" +
"age_buffer__loop returns whether the image decoder should loop\n// back to the beginning of the animation, assuming that we've reached the end\n// of the encoded stream. If so, it increments f's count of the animation loops\n// played so far.\nstatic inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {\n if (!f) {\n return false;\n }\n uint32_t n = f->private_impl.config.private_impl.num_loops;\n if (n == 0) {\n return true;\n }\n if (f->private_impl.loop_count < n - 1) {\n f->private_impl.loop_count++;\n return true;\n }\n return false;\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 wuffs_base__image_buffer__dirty_rect(\n wuffs_base__image_buffer* f) {\n return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});\n}\n\n// wuffs_base__image_buffer__duration returns the amount of time to display\n// this frame. Zero means to display forever - a sti" + "age_buffer__loop returns whether the image decoder should loop\n// back to the beginning of the animation, assuming that we've reached the end\n// of the encoded stream. If so, it increments b's count of the animation loops\n// played so far.\nstatic inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {\n if (!b) {\n return false;\n }\n uint32_t n = b->private_impl.config.private_impl.num_loops;\n if (n == 0) {\n return true;\n }\n if (b->private_impl.loop_count < n - 1) {\n b->private_impl.loop_count++;\n return true;\n }\n return false;\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 wuffs_base__image_buffer__dirty_rect(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});\n}\n\n// wuffs_base__image_buffer__duration returns the amount of time to display\n// this frame. Zero means to display forever - a sti" +
"ll (non-animated) image.\nstatic inline wuffs_base__flicks wuffs_base__image_buffer__duration(\n wuffs_base__image_buffer* f) {\n return f ? f->private_impl.duration : 0;\n}\n\n// wuffs_base__image_buffer__palette returns the palette that the pixel data\n// can index. The backing array is inside f and has length 1024.\nstatic inline uint8_t* wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* f) {\n return f ? f->private_impl.palette : NULL;\n}\n\n#endif // WUFFS_BASE_HEADER_H\n" + "ll (non-animated) image.\nstatic inline wuffs_base__flicks wuffs_base__image_buffer__duration(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.duration : 0;\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 uint8_t* wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.palette : NULL;\n}\n\n#endif // WUFFS_BASE_HEADER_H\n" +
"" ""
const baseImpl = "" + const baseImpl = "" +
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H
+28 -28
View File
@@ -988,34 +988,34 @@ typedef struct {
} wuffs_base__image_buffer; } wuffs_base__image_buffer;
static inline void wuffs_base__image_buffer__set_from_pixbuf( static inline void wuffs_base__image_buffer__set_from_pixbuf(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__pixel_buffer pixbuf) { wuffs_base__pixel_buffer pixbuf) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
f->private_impl.config = config; b->private_impl.config = config;
f->private_impl.pixbuf = pixbuf; b->private_impl.pixbuf = pixbuf;
} }
// TODO: Should this function return bool? An error type? // TODO: Should this function return bool? An error type?
static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__set_from_slice(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__image_config config, wuffs_base__image_config config,
wuffs_base__slice_u8 pixbuf_memory) { wuffs_base__slice_u8 pixbuf_memory) {
if (!f) { if (!b) {
return; return;
} }
*f = ((wuffs_base__image_buffer){}); *b = ((wuffs_base__image_buffer){});
// TODO: don't assume 1 byte per pixel. Don't assume packed. // TODO: don't assume 1 byte per pixel. Don't assume packed.
uint64_t wh = ((uint64_t)config.private_impl.width) * uint64_t wh = ((uint64_t)config.private_impl.width) *
((uint64_t)config.private_impl.height); ((uint64_t)config.private_impl.height);
if (wh > pixbuf_memory.len) { if (wh > pixbuf_memory.len) {
return; return;
} }
f->private_impl.config = config; b->private_impl.config = config;
wuffs_base__table_u8* tab = &f->private_impl.pixbuf.planes[0]; wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
tab->ptr = pixbuf_memory.ptr; tab->ptr = pixbuf_memory.ptr;
tab->width = config.private_impl.width; tab->width = config.private_impl.width;
tab->height = config.private_impl.height; tab->height = config.private_impl.height;
@@ -1023,36 +1023,36 @@ static inline void wuffs_base__image_buffer__set_from_slice(
} }
static inline void wuffs_base__image_buffer__update( static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* f, wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration, wuffs_base__flicks duration,
uint8_t* palette_ptr, uint8_t* palette_ptr,
size_t palette_len) { size_t palette_len) {
if (!f) { if (!b) {
return; return;
} }
f->private_impl.dirty_rect = dirty_rect; b->private_impl.dirty_rect = dirty_rect;
f->private_impl.duration = duration; b->private_impl.duration = duration;
if (palette_ptr) { if (palette_ptr) {
memmove(f->private_impl.palette, palette_ptr, memmove(b->private_impl.palette, palette_ptr,
palette_len <= 1024 ? palette_len : 1024); palette_len <= 1024 ? palette_len : 1024);
} }
} }
// wuffs_base__image_buffer__loop returns whether the image decoder should loop // wuffs_base__image_buffer__loop returns whether the image decoder should loop
// back to the beginning of the animation, assuming that we've reached the end // back to the beginning of the animation, assuming that we've reached the end
// of the encoded stream. If so, it increments f's count of the animation loops // of the encoded stream. If so, it increments b's count of the animation loops
// played so far. // played so far.
static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) { static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
if (!f) { if (!b) {
return false; return false;
} }
uint32_t n = f->private_impl.config.private_impl.num_loops; uint32_t n = b->private_impl.config.private_impl.num_loops;
if (n == 0) { if (n == 0) {
return true; return true;
} }
if (f->private_impl.loop_count < n - 1) { if (b->private_impl.loop_count < n - 1) {
f->private_impl.loop_count++; b->private_impl.loop_count++;
return true; return true;
} }
return false; return false;
@@ -1061,22 +1061,22 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {
// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of
// this frame's pixels differs from the previous frame. // this frame's pixels differs from the previous frame.
static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});
} }
// wuffs_base__image_buffer__duration returns the amount of time to display // wuffs_base__image_buffer__duration returns the amount of time to display
// this frame. Zero means to display forever - a still (non-animated) image. // this frame. Zero means to display forever - a still (non-animated) image.
static inline wuffs_base__flicks wuffs_base__image_buffer__duration( static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.duration : 0; return b ? b->private_impl.duration : 0;
} }
// wuffs_base__image_buffer__palette returns the palette that the pixel data // wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside f and has length 1024. // can index. The backing array is inside b and has length 1024.
static inline uint8_t* wuffs_base__image_buffer__palette( static inline uint8_t* wuffs_base__image_buffer__palette(
wuffs_base__image_buffer* f) { wuffs_base__image_buffer* b) {
return f ? f->private_impl.palette : NULL; return b ? b->private_impl.palette : NULL;
} }
#endif // WUFFS_BASE_HEADER_H #endif // WUFFS_BASE_HEADER_H