mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
std/vp8: add comments about reconstruction etc
This commit is contained in:
1 parent
46ac36bd7b
commit
3fce6225c9
8 files changed
+139
-12
No files matched your search
@@ -8,6 +8,66 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
// --------
|
||||
|
||||
// Reconstructing YUV samples involves adding predictions (based on previous
|
||||
// YUV samples, in macroblocks one column left or one column above) to
|
||||
// residuals (decoded from the bitstream, dequantized and IDCT'ed).
|
||||
//
|
||||
// There are 16×16 = 256 luma and 2×8×8 = 128 chroma samples per macroblock.
|
||||
// The decoder.yuv_cache field is a bit larger than that, being an array[26]
|
||||
// array[32] base.u8. Here's the layout.
|
||||
//
|
||||
// 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
// . . . . . . . a b b b b b b b b b b b b b b b b c c c c . . . . 00
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 01
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 02
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 03
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y c c c c . . . . 04
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 05
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 06
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 07
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y c c c c . . . . 08
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 09
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 0A
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 0B
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y c c c c . . . . 0C
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 0D
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 0E
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 0F
|
||||
// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 10
|
||||
// . . . . . . . e f f f f f f f f . . . . . . . g h h h h h h h h 11
|
||||
// . . . . . . . i U U U U U U U U . . . . . . . j V V V V V V V V 12
|
||||
// . . . . . . . i U U U U U U U U . . . . . . . j V V V V V V V V 13
|
||||
// . . . . . . . i U U U U U U U U . . . . . . . j V V V V V V V V 14
|
||||
// . . . . . . . i U U U U U U U U . . . . . . . j V V V V V V V V 15
|
||||
// . . . . . . . i U U U U U U U U . . . . . . . j V V V V V V V V 16
|
||||
// . . . . . . . i U U U U U U U U . . . . . . . j V V V V V V V V 17
|
||||
// . . . . . . . i U U U U U U U U . . . . . . . j V V V V V V V V 18
|
||||
// . . . . . . . i U U U U U U U U . . . . . . . j V V V V V V V V 19
|
||||
//
|
||||
// Y, U and V are this macroblock's luma and chroma values.
|
||||
//
|
||||
// The Y predictions (per 4×4 subblock) depend on the row above's Y values
|
||||
// (either abc or dYc) and the column left's Y values (ad or bY).
|
||||
//
|
||||
// The U predictions (per 8×8 block) depend on the row above's U values (ef)
|
||||
// and the column left's U values (i).
|
||||
//
|
||||
// The V predictions (per 8×8 block) depend on the row above's V values (gh)
|
||||
// and the column left's V values (j).
|
||||
//
|
||||
// For top-row (mby == 0) macroblocks, abcefgh is initialized to 0x7F. For
|
||||
// other macroblocks, these are copied from the bottom-most row of the
|
||||
// macroblock above (before filtering, for I-Frames), from the workbuf.
|
||||
//
|
||||
// The c values are then duplicated from row 0x00 to rows 0x04, 0x08 and 0x0C.
|
||||
//
|
||||
// For left-column (mbx == 0) macroblocks, adeigj are initialized to 0x81 (but
|
||||
// aeg is 0x7F if mby is also 0). For other macroblocks, these are copied from
|
||||
// the right-most column of the macroblock to the left (before filtering, for
|
||||
// I-Frames), from the yuv_cache to itself, shifted by 8 or 16 columns.
|
||||
|
||||
pri func decoder.reconstruct!(
|
||||
workbuf: slice base.u8,
|
||||
mbx: base.u32[..= 0x3FF],
|
||||
@@ -120,7 +180,10 @@ pri func decoder.prepare_yuv_cache!(
|
||||
var offset : base.u64[..= 0x17FE_FFF8]
|
||||
var o : base.u64
|
||||
|
||||
// For abcdefghij comments, see the layout at the top of this file.
|
||||
|
||||
if args.mbx <= 0 {
|
||||
// Initialize adeigj to 0x81.
|
||||
j = 0x00
|
||||
while j < 0x11 {
|
||||
this.yuv_cache[j][0x07] = 0x81
|
||||
@@ -133,6 +196,7 @@ pri func decoder.prepare_yuv_cache!(
|
||||
}
|
||||
|
||||
} else {
|
||||
// Copy from the previous (left) macroblock, in yuv_cache, to adeigj.
|
||||
j = 0x00
|
||||
while j < 0x11 {
|
||||
this.yuv_cache[j][0x07] = this.yuv_cache[j][0x17]
|
||||
@@ -146,6 +210,7 @@ pri func decoder.prepare_yuv_cache!(
|
||||
}
|
||||
|
||||
if args.mby <= 0 {
|
||||
// Initialize abcefgh to 0x7F.
|
||||
i = 0x00
|
||||
while i < 0x20 {
|
||||
this.yuv_cache[0x00][i] = 0x7F
|
||||
@@ -158,6 +223,8 @@ pri func decoder.prepare_yuv_cache!(
|
||||
}
|
||||
|
||||
} else {
|
||||
// Copy from the previous (above) macroblock, in args.workbuf, to bcfh.
|
||||
|
||||
offset = 0 +
|
||||
(((((args.mby * 16) - 1) * this.workbuf_yuv_y_stride) + (args.mbx * 16)) as base.u64)
|
||||
i = 0x00
|
||||
@@ -220,6 +287,7 @@ pri func decoder.prepare_yuv_cache!(
|
||||
}
|
||||
}
|
||||
|
||||
// Duplicate the c values.
|
||||
j = 0x04
|
||||
while j < 0x10 {
|
||||
this.yuv_cache[j][0x18] = this.yuv_cache[0][0x18]
|
||||
|
||||
Reference in new issue
Block a user