Skip to content

Commit 3aa8841

Browse files
committed
(RWEBP) The enum reordering (VR=4, LD=5, RD=6 matching libvpx's actual binary) fixed the bmi[7] divergence — we now get 9/16 sub-block modes correct for MB0 (up from 7/16). The kf_bmode_prob table was also permuted in both dimensions to match the new enum.
The remaining divergence at bmi[9] suggests there may be another subtle difference — possibly in the kf_bmode_prob table entries for the specific context [1][0] that bmi[9] uses. The overall diff remains 100.2 because the cascading error from bmi[9] still propagates through all 805 MBs.
1 parent 44c1db8 commit 3aa8841

1 file changed

Lines changed: 27 additions & 27 deletions

File tree

  • libretro-common/formats/webp

libretro-common/formats/webp/rwebp.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -858,16 +858,16 @@ static const uint8_t vp8_uvmp[3] = {142,114,183};
858858
/* Key-frame B_PRED sub-block mode probabilities (RFC 6386 §12.1)
859859
* Indexed by [above_bmode][left_bmode][tree_node 0..8] */
860860
static const uint8_t kf_bmode_prob[10][10][9] = {
861-
{{231,120,48,89,115,113,120,152,112},{152,179,64,126,170,118,46,70,95},{175,69,143,80,85,82,72,155,103},{56,58,10,171,218,189,17,13,152},{114,26,17,163,44,195,21,10,173},{121,24,80,195,26,62,44,64,85},{144,71,10,38,171,213,144,34,26},{170,46,55,19,136,160,33,206,71},{63,20,8,114,114,208,12,9,226},{81,40,11,96,182,84,29,16,36}},
862-
{{134,183,89,137,98,101,106,165,148},{72,187,100,130,157,111,32,75,80},{66,102,167,99,74,62,40,234,128},{41,53,9,178,241,141,26,8,107},{74,43,26,146,73,166,49,23,157},{65,38,105,160,51,52,31,115,128},{104,79,12,27,217,255,87,17,7},{87,68,71,44,114,51,15,186,23},{47,41,14,110,182,183,21,17,194},{66,45,25,102,197,189,23,18,22}},
863-
{{88,88,147,150,42,46,45,196,205},{43,97,183,117,85,38,35,179,61},{39,53,200,87,26,21,43,232,171},{56,34,51,104,114,102,29,93,77},{39,28,85,171,58,165,90,98,64},{34,22,116,206,23,34,43,166,73},{107,54,32,26,51,1,81,43,31},{68,25,106,22,64,171,36,225,114},{34,19,21,102,132,188,16,76,124},{62,18,78,95,85,57,50,48,51}},
864-
{{193,101,35,159,215,111,89,46,111},{60,148,31,172,219,228,21,18,111},{112,113,77,85,179,255,38,120,114},{40,42,1,196,245,209,10,25,109},{88,43,29,140,166,213,37,43,154},{61,63,30,155,67,45,68,1,209},{100,80,8,43,154,1,51,26,71},{142,78,78,16,255,128,34,197,171},{41,40,5,102,211,183,4,1,221},{51,50,17,168,209,192,23,25,82}},
865-
{{138,31,36,171,27,166,38,44,229},{67,87,58,169,82,115,26,59,179},{63,59,90,180,59,166,93,73,154},{40,40,21,116,143,209,34,39,175},{47,15,16,183,34,223,49,45,183},{46,17,33,183,6,98,15,32,183},{57,46,22,24,128,1,54,17,37},{65,32,73,115,28,128,23,128,205},{40,3,9,115,51,192,18,6,223},{87,37,9,115,59,77,64,21,47}},
866-
{{104,55,44,218,9,54,53,130,226},{64,90,70,205,40,41,23,26,57},{54,57,112,184,5,41,38,166,213},{30,34,26,133,152,116,10,32,134},{75,32,12,51,192,255,160,43,51},{23,49,45,156,8,111,16,71,82},{42,158,42,48,22,234,13,1,1},{65,70,60,146,72,31,16,1,64},{57,18,10,102,102,213,34,20,43},{47,22,24,138,187,187,49,44,165}},
867-
{{182,24,21,242,2,2,7,40,219},{72,79,60,205,60,75,7,32,145},{62,68,86,130,73,119,27,149,192},{31,28,25,110,169,100,24,131,101},{58,45,4,75,114,193,102,44,42},{33,19,38,212,3,52,3,109,198},{22,27,3,47,244,255,78,7,3},{39,50,59,59,64,128,34,69,210},{44,7,5,85,101,214,14,9,187},{55,47,4,55,151,7,89,38,35}},
868-
{{164,50,31,137,154,133,25,35,218},{67,68,71,186,114,84,28,30,163},{90,67,64,90,153,132,25,119,188},{36,44,18,145,190,119,14,26,97},{63,43,20,116,100,152,48,93,127},{58,24,47,157,116,25,41,99,163},{75,55,11,14,8,30,22,51,130},{86,55,80,64,32,60,9,158,77},{37,20,14,111,138,163,11,11,214},{63,51,14,79,118,34,64,42,75}},
869-
{{141,28,36,162,27,128,43,116,227},{76,82,63,185,121,102,40,52,143},{63,58,96,152,115,128,58,102,152},{44,38,34,121,181,149,12,48,116},{79,28,16,128,167,239,41,38,109},{42,22,47,187,41,89,16,42,132},{54,45,15,27,188,213,53,22,16},{89,41,66,20,74,79,8,128,147},{53,18,15,93,181,196,21,20,153},{72,47,25,107,160,81,53,27,53}},
870-
{{124,68,51,98,125,189,82,82,200},{76,100,69,192,134,147,45,75,83},{57,59,107,115,109,131,43,139,143},{38,43,27,131,152,136,32,34,107},{80,45,17,134,81,175,99,50,100},{48,25,51,199,33,104,33,84,108},{60,53,16,24,158,220,44,24,44},{82,42,51,57,73,70,25,157,113},{51,24,14,115,133,209,18,16,209},{66,47,20,122,148,176,39,30,57}}
861+
{{231,120,48,89,115,113,120,152,112},{152,179,64,126,170,118,46,70,95},{175,69,143,80,85,82,72,155,103},{56,58,10,171,218,189,17,13,152},{144,71,10,38,171,213,144,34,26},{114,26,17,163,44,195,21,10,173},{121,24,80,195,26,62,44,64,85},{170,46,55,19,136,160,33,206,71},{63,20,8,114,114,208,12,9,226},{81,40,11,96,182,84,29,16,36}},
862+
{{134,183,89,137,98,101,106,165,148},{72,187,100,130,157,111,32,75,80},{66,102,167,99,74,62,40,234,128},{41,53,9,178,241,141,26,8,107},{104,79,12,27,217,255,87,17,7},{74,43,26,146,73,166,49,23,157},{65,38,105,160,51,52,31,115,128},{87,68,71,44,114,51,15,186,23},{47,41,14,110,182,183,21,17,194},{66,45,25,102,197,189,23,18,22}},
863+
{{88,88,147,150,42,46,45,196,205},{43,97,183,117,85,38,35,179,61},{39,53,200,87,26,21,43,232,171},{56,34,51,104,114,102,29,93,77},{107,54,32,26,51,1,81,43,31},{39,28,85,171,58,165,90,98,64},{34,22,116,206,23,34,43,166,73},{68,25,106,22,64,171,36,225,114},{34,19,21,102,132,188,16,76,124},{62,18,78,95,85,57,50,48,51}},
864+
{{193,101,35,159,215,111,89,46,111},{60,148,31,172,219,228,21,18,111},{112,113,77,85,179,255,38,120,114},{40,42,1,196,245,209,10,25,109},{100,80,8,43,154,1,51,26,71},{88,43,29,140,166,213,37,43,154},{61,63,30,155,67,45,68,1,209},{142,78,78,16,255,128,34,197,171},{41,40,5,102,211,183,4,1,221},{51,50,17,168,209,192,23,25,82}},
865+
{{182,24,21,242,2,2,7,40,219},{72,79,60,205,60,75,7,32,145},{62,68,86,130,73,119,27,149,192},{31,28,25,110,169,100,24,131,101},{22,27,3,47,244,255,78,7,3},{58,45,4,75,114,193,102,44,42},{33,19,38,212,3,52,3,109,198},{39,50,59,59,64,128,34,69,210},{44,7,5,85,101,214,14,9,187},{55,47,4,55,151,7,89,38,35}},
866+
{{138,31,36,171,27,166,38,44,229},{67,87,58,169,82,115,26,59,179},{63,59,90,180,59,166,93,73,154},{40,40,21,116,143,209,34,39,175},{57,46,22,24,128,1,54,17,37},{47,15,16,183,34,223,49,45,183},{46,17,33,183,6,98,15,32,183},{65,32,73,115,28,128,23,128,205},{40,3,9,115,51,192,18,6,223},{87,37,9,115,59,77,64,21,47}},
867+
{{104,55,44,218,9,54,53,130,226},{64,90,70,205,40,41,23,26,57},{54,57,112,184,5,41,38,166,213},{30,34,26,133,152,116,10,32,134},{42,158,42,48,22,234,13,1,1},{75,32,12,51,192,255,160,43,51},{23,49,45,156,8,111,16,71,82},{65,70,60,146,72,31,16,1,64},{57,18,10,102,102,213,34,20,43},{47,22,24,138,187,187,49,44,165}},
868+
{{164,50,31,137,154,133,25,35,218},{67,68,71,186,114,84,28,30,163},{90,67,64,90,153,132,25,119,188},{36,44,18,145,190,119,14,26,97},{75,55,11,14,8,30,22,51,130},{63,43,20,116,100,152,48,93,127},{58,24,47,157,116,25,41,99,163},{86,55,80,64,32,60,9,158,77},{37,20,14,111,138,163,11,11,214},{63,51,14,79,118,34,64,42,75}},
869+
{{141,28,36,162,27,128,43,116,227},{76,82,63,185,121,102,40,52,143},{63,58,96,152,115,128,58,102,152},{44,38,34,121,181,149,12,48,116},{54,45,15,27,188,213,53,22,16},{79,28,16,128,167,239,41,38,109},{42,22,47,187,41,89,16,42,132},{89,41,66,20,74,79,8,128,147},{53,18,15,93,181,196,21,20,153},{72,47,25,107,160,81,53,27,53}},
870+
{{124,68,51,98,125,189,82,82,200},{76,100,69,192,134,147,45,75,83},{57,59,107,115,109,131,43,139,143},{38,43,27,131,152,136,32,34,107},{60,53,16,24,158,220,44,24,44},{80,45,17,134,81,175,99,50,100},{48,25,51,199,33,104,33,84,108},{82,42,51,57,73,70,25,157,113},{51,24,14,115,133,209,18,16,209},{66,47,20,122,148,176,39,30,57}}
871871
};
872872

873873
/* Decode a B_PRED sub-block mode from the key-frame tree (RFC 6386 §12.1).
@@ -891,11 +891,11 @@ static int vp8_read_bmode(vp8b *br, int above, int left)
891891
if (!vp8b_get(br, p[3])) {
892892
/* Left subtree: HE, RD, VR */
893893
if (!vp8b_get(br, p[4])) return 3; /* B_HE_PRED */
894-
if (!vp8b_get(br, p[5])) return 5; /* B_RD_PRED */
895-
return 6; /* B_VR_PRED */
894+
if (!vp8b_get(br, p[5])) return 6; /* B_RD_PRED */
895+
return 4; /* B_VR_PRED */
896896
} else {
897897
/* Right subtree: LD, VL, HD, HU */
898-
if (!vp8b_get(br, p[6])) return 4; /* B_LD_PRED */
898+
if (!vp8b_get(br, p[6])) return 5; /* B_LD_PRED */
899899
if (!vp8b_get(br, p[7])) return 7; /* B_VL_PRED */
900900
if (!vp8b_get(br, p[8])) return 8; /* B_HD_PRED */
901901
return 9; /* B_HU_PRED */
@@ -935,7 +935,19 @@ static void vp8_pred4x4(uint8_t *d, int s, int m,
935935
memset(d+j*s,(uint8_t)v,4);
936936
}
937937
break;
938-
case 4: /* B_LD_PRED */
938+
case 4: /* B_VR_PRED (4) */
939+
d[3*s+0]=(uint8_t)((l[2]+2*l[1]+l[0]+2)>>2);
940+
d[2*s+0]=(uint8_t)((l[1]+2*l[0]+tl+2)>>2);
941+
d[1*s+0]=d[3*s+1]=(uint8_t)((l[0]+2*tl+a[0]+2)>>2);
942+
d[0*s+0]=d[2*s+1]=(uint8_t)((tl+a[0]+1)>>1);
943+
d[0*s+1]=d[2*s+2]=(uint8_t)((a[0]+a[1]+1)>>1);
944+
d[1*s+1]=d[3*s+2]=(uint8_t)((tl+2*a[0]+a[1]+2)>>2);
945+
d[0*s+2]=d[2*s+3]=(uint8_t)((a[1]+a[2]+1)>>1);
946+
d[1*s+2]=d[3*s+3]=(uint8_t)((a[0]+2*a[1]+a[2]+2)>>2);
947+
d[0*s+3]=(uint8_t)((a[2]+a[3]+1)>>1);
948+
d[1*s+3]=(uint8_t)((a[1]+2*a[2]+a[3]+2)>>2);
949+
break;
950+
case 5: /* B_LD_PRED (5) */
939951
d[0*s+0]=(uint8_t)((a[0]+2*a[1]+a[2]+2)>>2);
940952
d[0*s+1]=d[1*s+0]=(uint8_t)((a[1]+2*a[2]+a[3]+2)>>2);
941953
d[0*s+2]=d[1*s+1]=d[2*s+0]=(uint8_t)((a[2]+2*a[3]+a[4]+2)>>2);
@@ -944,7 +956,7 @@ static void vp8_pred4x4(uint8_t *d, int s, int m,
944956
d[2*s+3]=d[3*s+2]=(uint8_t)((a[5]+2*a[6]+a[7]+2)>>2);
945957
d[3*s+3]=(uint8_t)((a[6]+2*a[7]+a[7]+2)>>2);
946958
break;
947-
case 5: /* B_RD_PRED */
959+
case 6: /* B_RD_PRED (6) */
948960
d[3*s+0]=(uint8_t)((l[3]+2*l[2]+l[1]+2)>>2);
949961
d[2*s+0]=d[3*s+1]=(uint8_t)((l[2]+2*l[1]+l[0]+2)>>2);
950962
d[1*s+0]=d[2*s+1]=d[3*s+2]=(uint8_t)((l[1]+2*l[0]+tl+2)>>2);
@@ -953,18 +965,6 @@ static void vp8_pred4x4(uint8_t *d, int s, int m,
953965
d[0*s+2]=d[1*s+3]=(uint8_t)((a[0]+2*a[1]+a[2]+2)>>2);
954966
d[0*s+3]=(uint8_t)((a[1]+2*a[2]+a[3]+2)>>2);
955967
break;
956-
case 6: /* B_VR_PRED */
957-
d[3*s+0]=(uint8_t)((l[2]+2*l[1]+l[0]+2)>>2);
958-
d[2*s+0]=(uint8_t)((l[1]+2*l[0]+tl+2)>>2);
959-
d[1*s+0]=d[3*s+1]=(uint8_t)((l[0]+2*tl+a[0]+2)>>2);
960-
d[0*s+0]=d[2*s+1]=(uint8_t)((tl+a[0]+1)>>1);
961-
d[0*s+1]=d[2*s+2]=(uint8_t)((a[0]+a[1]+1)>>1);
962-
d[1*s+1]=d[3*s+2]=(uint8_t)((tl+2*a[0]+a[1]+2)>>2);
963-
d[0*s+2]=d[2*s+3]=(uint8_t)((a[1]+a[2]+1)>>1);
964-
d[1*s+2]=d[3*s+3]=(uint8_t)((a[0]+2*a[1]+a[2]+2)>>2);
965-
d[0*s+3]=(uint8_t)((a[2]+a[3]+1)>>1);
966-
d[1*s+3]=(uint8_t)((a[1]+2*a[2]+a[3]+2)>>2);
967-
break;
968968
case 7: /* B_VL_PRED */
969969
d[0*s+0]=(uint8_t)((a[0]+a[1]+1)>>1);
970970
d[1*s+0]=(uint8_t)((a[0]+2*a[1]+a[2]+2)>>2);

0 commit comments

Comments
 (0)