mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
std/vp8: swizzle to the dst pixel buffer
This commit, part of a series, is inspired by pull request PR #168 by Damian Kaczmarek (with AI assistance), with some modifications. Updates PR #168
This commit is contained in:
1 parent
214b63c275
commit
24fae427c1
7 files changed
+323
-255
No files matched your search
@@ -134,12 +134,11 @@ pub struct decoder? implements base.image_decoder(
|
||||
|
||||
yuv_cache : array[26] array[32] base.u8,
|
||||
|
||||
dst_x : base.u32,
|
||||
dst_y : base.u32,
|
||||
|
||||
swizzler : base.pixel_swizzler,
|
||||
util : base.utility,
|
||||
) + (
|
||||
swizzle_ycck_scratch_buffer_2k : array[2048] base.u8,
|
||||
|
||||
// 1056 is (4 planes, 8 bands, 3 contexts, 11 tokens) flattened.
|
||||
coeff_probs : array[1056] base.u8,
|
||||
|
||||
@@ -371,14 +370,6 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
return status
|
||||
}
|
||||
|
||||
status = this.decode_macroblocks!(workbuf: args.workbuf)
|
||||
if not status.is_ok() {
|
||||
return status
|
||||
}
|
||||
|
||||
this.dst_x = 0
|
||||
this.dst_y = 0
|
||||
|
||||
status = this.swizzler.prepare!(
|
||||
dst_pixfmt: args.dst.pixel_format(),
|
||||
dst_palette: args.dst.palette(),
|
||||
@@ -389,8 +380,7 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
return status
|
||||
}
|
||||
|
||||
// TODO: actually decode the pixels.
|
||||
status = this.make_a_placeholder_gradient!(dst: args.dst)
|
||||
status = this.decode_macroblocks!(dst: args.dst, workbuf: args.workbuf)
|
||||
if not status.is_ok() {
|
||||
return status
|
||||
}
|
||||
@@ -398,60 +388,6 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
this.call_sequence = 0x60
|
||||
}
|
||||
|
||||
pri func decoder.make_a_placeholder_gradient!(dst: ptr base.pixel_buffer) base.status {
|
||||
var dst_pixfmt : base.pixel_format
|
||||
var dst_bits_per_pixel : base.u32[..= 256]
|
||||
var dst_bytes_per_pixel : base.u32[..= 32]
|
||||
var dst_bytes_per_row : base.u64
|
||||
var tab : table base.u8
|
||||
var dst : slice base.u8
|
||||
var i : base.u64
|
||||
var bgrx : array[4] base.u8
|
||||
|
||||
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
|
||||
// to chain the two calls: "args.dst.pixel_format().bits_per_pixel()".
|
||||
dst_pixfmt = args.dst.pixel_format()
|
||||
dst_bits_per_pixel = dst_pixfmt.bits_per_pixel()
|
||||
if (dst_bits_per_pixel & 7) <> 0 {
|
||||
return base."#unsupported option"
|
||||
}
|
||||
dst_bytes_per_pixel = dst_bits_per_pixel / 8
|
||||
dst_bytes_per_row = (this.width * dst_bytes_per_pixel) as base.u64
|
||||
tab = args.dst.plane(p: 0)
|
||||
|
||||
bgrx[0] = 0x80
|
||||
|
||||
while this.dst_y < this.height {
|
||||
assert this.dst_y < 0x3FFF via "a < b: a < c; c <= b"(c: this.height)
|
||||
bgrx[1] = (this.dst_y & 0xFF) as base.u8
|
||||
|
||||
this.dst_x = 0
|
||||
while this.dst_x < this.width,
|
||||
inv this.dst_y < 0x3FFF,
|
||||
{
|
||||
assert this.dst_x < 0x3FFF via "a < b: a < c; c <= b"(c: this.width)
|
||||
bgrx[2] = (this.dst_x & 0xFF) as base.u8
|
||||
|
||||
dst = tab.row_u32(y: this.dst_y)
|
||||
if dst_bytes_per_row < dst.length() {
|
||||
dst = dst[.. dst_bytes_per_row]
|
||||
}
|
||||
i = (this.dst_x as base.u64) * (dst_bytes_per_pixel as base.u64)
|
||||
if i < dst.length() {
|
||||
this.swizzler.swizzle_interleaved_from_slice!(
|
||||
dst: dst[i ..],
|
||||
dst_palette: args.dst.palette(),
|
||||
src: bgrx[.. 4])
|
||||
}
|
||||
|
||||
this.dst_x += 1
|
||||
}
|
||||
this.dst_y += 1
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
pub func decoder.frame_dirty_rect() base.rect_ie_u32 {
|
||||
return this.util.make_rect_ie_u32(
|
||||
min_incl_x: 0,
|
||||
|
||||
Reference in new issue
Block a user