Skip to content

Commit b0f6690

Browse files
committed
(RWEBP) Bug #14: Y_MODE TREE IS BALANCED!
The keyframe y_mode tree was implemented as a linear chain but libvpx uses a balanced binary tree (confirmed by dumping vp8_kf_ymode_tree from the binary): node0: bit=0 → B_PRED(4) bit=1 → node1 node1: bit=0 → node2 {DC(0), V(1)} bit=1 → node3 {H(2), TM(3)} This is the exact same type of bug as the sub-block mode tree — a linear chain that should be balanced. The fix changed the y_mode reading from a sequential if/elif/elif/elif/else to a branching structure where prob[1] selects between {DC,V} and {H,TM} subtrees. Result: First 5 MBs now match libvpx perfectly (seg, ym, uvm, skip all correct for MB0-MB4). The overall diff is 105.7 (higher than 96.9 because the correct tree changes the cascading error pattern), but the structural correctness is confirmed by the 5-MB match.
1 parent 85e060d commit b0f6690

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • libretro-common/formats/webp

libretro-common/formats/webp/rwebp.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,11 +1250,15 @@ static uint32_t *vp8_decode(const uint8_t *data, size_t len,
12501250
is_skip = vp8b_get(&br, prob_skip);
12511251

12521252
/* Y mode */
1253-
if (!vp8b_get(&br, vp8_ymp[0])) ym = 4; /* B_PRED first */
1254-
else if (!vp8b_get(&br, vp8_ymp[1])) ym = 0;
1255-
else if (!vp8b_get(&br, vp8_ymp[2])) ym = 1;
1256-
else if (!vp8b_get(&br, vp8_ymp[3])) ym = 2;
1257-
else ym = 3; /* TM_PRED */
1253+
if (!vp8b_get(&br, vp8_ymp[0])) {
1254+
ym = 4; /* B_PRED */
1255+
} else if (!vp8b_get(&br, vp8_ymp[1])) {
1256+
/* Left subtree: DC, V */
1257+
ym = vp8b_get(&br, vp8_ymp[2]) ? 1 : 0;
1258+
} else {
1259+
/* Right subtree: H, TM */
1260+
ym = vp8b_get(&br, vp8_ymp[3]) ? 3 : 2;
1261+
}
12581262

12591263
if (ym == 4)
12601264
{

0 commit comments

Comments
 (0)