mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 08:38:14 +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
+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
|
||||
|
||||
Reference in new issue
Block a user