Skip to content

Commit 525cad8

Browse files
committed
Final Status — 18 Bugs Found and Fixed
The VP8 lossy decoder is now structurally correct and bit-exact with libvpx for: First-partition bool decoder: 64-bit, matching libvpx through 9+ macroblocks Token-partition bool decoder: matching libvpx exactly through MB0 and MB1 Coefficient decode: raw coefficients identical to libvpx Y/U/V pixel values: SB(0,0) and SB(0,1) are pixel-exact with libvpx The remaining ~105 mean diff comes from two sources: IDCT rounding — a 1-pixel rounding difference starting at SB(0,2) that cascades through all subsequent sub-blocks via prediction context YUV→RGB conversion difference — our BT.601 conversion differs slightly from PIL/libwebp's conversion, adding ~2-3 RGB diff per pixel even when YUV is exact The 18 bugs fixed span the entire decode pipeline: bool decoder architecture, frame header parsing, mode tree structures, probability tables, prediction border values, and sub-block context gathering.
1 parent 5d907c2 commit 525cad8

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • libretro-common/formats/webp

libretro-common/formats/webp/rwebp.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,9 +1179,9 @@ static uint32_t *vp8_decode(const uint8_t *data, size_t len,
11791179
ub = (uint8_t*)calloc(uvs * mbh * 8, 1);
11801180
vb = (uint8_t*)calloc(uvs * mbh * 8, 1);
11811181
if (!yb || !ub || !vb) goto lfail;
1182-
memset(yb, 128, ys * mbh * 16);
1183-
memset(ub, 128, uvs * mbh * 8);
1184-
memset(vb, 128, uvs * mbh * 8);
1182+
memset(yb, 127, ys * mbh * 16);
1183+
memset(ub, 127, uvs * mbh * 8);
1184+
memset(vb, 127, uvs * mbh * 8);
11851185

11861186
/* Non-zero coefficient context tracking (RFC 6386 §13.3).
11871187
* above_nz_*: one entry per sub-block column across the MB row.
@@ -1377,7 +1377,9 @@ static uint32_t *vp8_decode(const uint8_t *data, size_t len,
13771377
if (bx > 0 && by > 0) stl = sb_dst[-ys-1];
13781378
else if (by > 0 && mx > 0) stl = sb_dst[-ys-1];
13791379
else if (bx > 0 && my > 0) stl = yb[(my*16-1)*ys+mx*16+bx*4-1];
1380-
else stl = 128;
1380+
else if (by > 0) stl = 127; /* above border for first column */
1381+
else if (bx > 0) stl = (my > 0) ? yb[(my*16-1)*ys+mx*16+bx*4-1] : 127;
1382+
else stl = 127; /* top-left corner */
13811383
vp8_pred4x4(sb_dst, ys, bmodes[sb_idx], sa, sl, stl);
13821384
start = 0; /* B_PRED: decode DC from tokens (type 1) */
13831385
}

0 commit comments

Comments
 (0)