mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
std/vp8: calculate the predicted values
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
3a74d542ab
commit
bb3c85e2ef
8 files changed
+2276
-11
No files matched your search
+293
-2
@@ -65,7 +65,296 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the
|
||||
|
||||
// ---------------- VP8 Tests
|
||||
|
||||
// No VP8 tests.
|
||||
void //
|
||||
initialize_decoder_test_state(wuffs_vp8__decoder* dec) {
|
||||
// Initialize the top and left luma (Y) pixels to the digits of pi.
|
||||
|
||||
dec->private_impl.f_yuv_cache[0x00][0x07] = 0x31;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x08] = 0x41;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x09] = 0x59;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x0A] = 0x26;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x0B] = 0x53;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x0C] = 0x58;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x0D] = 0x97;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x0E] = 0x93;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x0F] = 0x23;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x10] = 0x84;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x11] = 0x62;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x12] = 0x64;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x13] = 0x33;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x14] = 0x83;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x15] = 0x27;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x16] = 0x95;
|
||||
dec->private_impl.f_yuv_cache[0x00][0x17] = 0x02;
|
||||
|
||||
dec->private_impl.f_yuv_cache[0x01][0x07] = 0x88;
|
||||
dec->private_impl.f_yuv_cache[0x02][0x07] = 0x41;
|
||||
dec->private_impl.f_yuv_cache[0x03][0x07] = 0x97;
|
||||
dec->private_impl.f_yuv_cache[0x04][0x07] = 0x16;
|
||||
dec->private_impl.f_yuv_cache[0x05][0x07] = 0x93;
|
||||
dec->private_impl.f_yuv_cache[0x06][0x07] = 0x99;
|
||||
dec->private_impl.f_yuv_cache[0x07][0x07] = 0x37;
|
||||
dec->private_impl.f_yuv_cache[0x08][0x07] = 0x51;
|
||||
dec->private_impl.f_yuv_cache[0x09][0x07] = 0x05;
|
||||
dec->private_impl.f_yuv_cache[0x0A][0x07] = 0x82;
|
||||
dec->private_impl.f_yuv_cache[0x0B][0x07] = 0x09;
|
||||
dec->private_impl.f_yuv_cache[0x0C][0x07] = 0x74;
|
||||
dec->private_impl.f_yuv_cache[0x0D][0x07] = 0x94;
|
||||
dec->private_impl.f_yuv_cache[0x0E][0x07] = 0x45;
|
||||
dec->private_impl.f_yuv_cache[0x0F][0x07] = 0x92;
|
||||
dec->private_impl.f_yuv_cache[0x10][0x07] = 0x30;
|
||||
|
||||
// Initialize the top and left chroma-blue (U) pixels to the digits of e.
|
||||
|
||||
dec->private_impl.f_yuv_cache[0x11][0x07] = 0x27;
|
||||
dec->private_impl.f_yuv_cache[0x11][0x08] = 0x18;
|
||||
dec->private_impl.f_yuv_cache[0x11][0x09] = 0x28;
|
||||
dec->private_impl.f_yuv_cache[0x11][0x0A] = 0x18;
|
||||
dec->private_impl.f_yuv_cache[0x11][0x0B] = 0x28;
|
||||
dec->private_impl.f_yuv_cache[0x11][0x0C] = 0x45;
|
||||
dec->private_impl.f_yuv_cache[0x11][0x0D] = 0x90;
|
||||
dec->private_impl.f_yuv_cache[0x11][0x0E] = 0x45;
|
||||
dec->private_impl.f_yuv_cache[0x11][0x0F] = 0x23;
|
||||
|
||||
dec->private_impl.f_yuv_cache[0x12][0x07] = 0x53;
|
||||
dec->private_impl.f_yuv_cache[0x13][0x07] = 0x60;
|
||||
dec->private_impl.f_yuv_cache[0x14][0x07] = 0x28;
|
||||
dec->private_impl.f_yuv_cache[0x15][0x07] = 0x74;
|
||||
dec->private_impl.f_yuv_cache[0x16][0x07] = 0x71;
|
||||
dec->private_impl.f_yuv_cache[0x17][0x07] = 0x35;
|
||||
dec->private_impl.f_yuv_cache[0x18][0x07] = 0x26;
|
||||
dec->private_impl.f_yuv_cache[0x19][0x07] = 0x62;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_vp8_decode_predict_uv8() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
const uint64_t test_cases[13][8] = {
|
||||
{0x4444444444444444, 0x4444444444444444, 0x4444444444444444,
|
||||
0x4444444444444444, 0x4444444444444444, 0x4444444444444444,
|
||||
0x4444444444444444, 0x4444444444444444},
|
||||
{0x4454445471BC714F, 0x516151617EC97E5C, 0x1929192946914624,
|
||||
0x6575657592DD9270, 0x627262728FDA8F6D, 0x26362636539E5331,
|
||||
0x17271727448F4422, 0x5363536380CB805E},
|
||||
{0x1828182845904523, 0x1828182845904523, 0x1828182845904523,
|
||||
0x1828182845904523, 0x1828182845904523, 0x1828182845904523,
|
||||
0x1828182845904523, 0x1828182845904523},
|
||||
{0x5353535353535353, 0x6060606060606060, 0x2828282828282828,
|
||||
0x7474747474747474, 0x7171717171717171, 0x3535353535353535,
|
||||
0x2626262626262626, 0x6262626262626262},
|
||||
|
||||
{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
|
||||
{0x5050505050505050, 0x5050505050505050, 0x5050505050505050,
|
||||
0x5050505050505050, 0x5050505050505050, 0x5050505050505050,
|
||||
0x5050505050505050, 0x5050505050505050},
|
||||
{0x3838383838383838, 0x3838383838383838, 0x3838383838383838,
|
||||
0x3838383838383838, 0x3838383838383838, 0x3838383838383838,
|
||||
0x3838383838383838, 0x3838383838383838},
|
||||
{0x8080808080808080, 0x8080808080808080, 0x8080808080808080,
|
||||
0x8080808080808080, 0x8080808080808080, 0x8080808080808080,
|
||||
0x8080808080808080, 0x8080808080808080},
|
||||
};
|
||||
|
||||
wuffs_vp8__decoder dec = {0};
|
||||
for (int mode = 0; mode < 13; mode++) {
|
||||
uint64_t w0 = test_cases[mode][0];
|
||||
uint64_t w1 = test_cases[mode][1];
|
||||
uint64_t w2 = test_cases[mode][2];
|
||||
uint64_t w3 = test_cases[mode][3];
|
||||
uint64_t w4 = test_cases[mode][4];
|
||||
uint64_t w5 = test_cases[mode][5];
|
||||
uint64_t w6 = test_cases[mode][6];
|
||||
uint64_t w7 = test_cases[mode][7];
|
||||
|
||||
if (w0 == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
initialize_decoder_test_state(&dec);
|
||||
|
||||
wuffs_vp8__decoder__predict_uv8(&dec, 0, mode);
|
||||
|
||||
uint64_t h0 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x12][8]);
|
||||
uint64_t h1 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x13][8]);
|
||||
uint64_t h2 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x14][8]);
|
||||
uint64_t h3 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x15][8]);
|
||||
uint64_t h4 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x16][8]);
|
||||
uint64_t h5 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x17][8]);
|
||||
uint64_t h6 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x18][8]);
|
||||
uint64_t h7 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x19][8]);
|
||||
|
||||
if ((h0 != w0) || (h1 != w1) || (h2 != w2) || (h3 != w3) || //
|
||||
(h4 != w4) || (h5 != w5) || (h6 != w6) || (h7 != w7)) {
|
||||
RETURN_FAIL(
|
||||
"mode=%d:" //
|
||||
"\nhave %016" PRIX64 " %016" PRIX64 " %016" PRIX64 " %016" PRIX64 //
|
||||
" %016" PRIX64 " %016" PRIX64 " %016" PRIX64 " %016" PRIX64 //
|
||||
"\nwant %016" PRIX64 " %016" PRIX64 " %016" PRIX64 " %016" PRIX64 //
|
||||
" %016" PRIX64 " %016" PRIX64 " %016" PRIX64 " %016" PRIX64, //
|
||||
mode, h0, h1, h2, h3, h4, h5, h6, h7, w0, w1, w2, w3, w4, w5, w6, w7);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_vp8_decode_predict_y16() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
const uint64_t test_cases[13][9] = {
|
||||
|
||||
{0x5A5A5A5A5A5A5A5A, 0x5A5A5A5A5A5A5A5A, 0x5A5A5A5A5A5A5A5A,
|
||||
0x5A5A5A5A5A5A5A5A, 0x5A5A5A5A5A5A5A5A, 0x5A5A5A5A5A5A5A5A,
|
||||
0x5A5A5A5A5A5A5A5A, 0x5A5A5A5A5A5A5A5A, 0x5A5A5A5A5A5A5A5A},
|
||||
{0x98B07DAAAFEEEA7A, 0x5169366368A7A333, 0xA7BF8CB9BEFDF989,
|
||||
0x263E0B383D7C7808, 0xA3BB88B5BAF9F585, 0xA9C18EBBC0FFFB8B,
|
||||
0x475F2C595E9D9929, 0x6179467378B7B343, 0x152D00272C6B6700},
|
||||
{0x4159265358979323, 0x4159265358979323, 0x4159265358979323,
|
||||
0x4159265358979323, 0x4159265358979323, 0x4159265358979323,
|
||||
0x4159265358979323, 0x4159265358979323, 0x4159265358979323},
|
||||
{0x8888888888888888, 0x4141414141414141, 0x9797979797979797,
|
||||
0x1616161616161616, 0x9393939393939393, 0x9999999999999999,
|
||||
0x3737373737373737, 0x5151515151515151, 0x0505050505050505},
|
||||
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
|
||||
{0x5D5D5D5D5D5D5D5D, 0x5D5D5D5D5D5D5D5D, 0x5D5D5D5D5D5D5D5D,
|
||||
0x5D5D5D5D5D5D5D5D, 0x5D5D5D5D5D5D5D5D, 0x5D5D5D5D5D5D5D5D,
|
||||
0x5D5D5D5D5D5D5D5D, 0x5D5D5D5D5D5D5D5D, 0x5D5D5D5D5D5D5D5D},
|
||||
{0x5757575757575757, 0x5757575757575757, 0x5757575757575757,
|
||||
0x5757575757575757, 0x5757575757575757, 0x5757575757575757,
|
||||
0x5757575757575757, 0x5757575757575757, 0x5757575757575757},
|
||||
{0x8080808080808080, 0x8080808080808080, 0x8080808080808080,
|
||||
0x8080808080808080, 0x8080808080808080, 0x8080808080808080,
|
||||
0x8080808080808080, 0x8080808080808080, 0x8080808080808080},
|
||||
};
|
||||
|
||||
wuffs_vp8__decoder dec = {0};
|
||||
for (int mode = 0; mode < 13; mode++) {
|
||||
uint64_t w0 = test_cases[mode][0];
|
||||
uint64_t w1 = test_cases[mode][1];
|
||||
uint64_t w2 = test_cases[mode][2];
|
||||
uint64_t w3 = test_cases[mode][3];
|
||||
uint64_t w4 = test_cases[mode][4];
|
||||
uint64_t w5 = test_cases[mode][5];
|
||||
uint64_t w6 = test_cases[mode][6];
|
||||
uint64_t w7 = test_cases[mode][7];
|
||||
uint64_t w8 = test_cases[mode][8];
|
||||
|
||||
if (w0 == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
initialize_decoder_test_state(&dec);
|
||||
|
||||
wuffs_vp8__decoder__predict_y16(&dec, mode);
|
||||
|
||||
uint64_t h0 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x01][8]);
|
||||
uint64_t h1 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x02][8]);
|
||||
uint64_t h2 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x03][8]);
|
||||
uint64_t h3 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x04][8]);
|
||||
uint64_t h4 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x05][8]);
|
||||
uint64_t h5 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x06][8]);
|
||||
uint64_t h6 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x07][8]);
|
||||
uint64_t h7 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x08][8]);
|
||||
uint64_t h8 = wuffs_base__peek_u64be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[0x09][8]);
|
||||
|
||||
if ((h0 != w0) || (h1 != w1) || (h2 != w2) || (h3 != w3) || //
|
||||
(h4 != w4) || (h5 != w5) || (h6 != w6) || (h7 != w7) || (h8 != w8)) {
|
||||
RETURN_FAIL(
|
||||
"mode=%d:" //
|
||||
"\nhave %016" PRIX64 " %016" PRIX64 " %016" PRIX64 " %016" PRIX64 //
|
||||
" %016" PRIX64 " %016" PRIX64 " %016" PRIX64 " %016" PRIX64 //
|
||||
" %016" PRIX64 //
|
||||
"\nwant %016" PRIX64 " %016" PRIX64 " %016" PRIX64 " %016" PRIX64 //
|
||||
" %016" PRIX64 " %016" PRIX64 " %016" PRIX64 " %016" PRIX64 //
|
||||
" %016" PRIX64, //
|
||||
mode, h0, h1, h2, h3, h4, h5, h6, h7, h8, //
|
||||
w0, w1, w2, w3, w4, w5, w6, w7, w8);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_vp8_decode_predict_y4() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
const uint32_t test_cases[10][4] = {
|
||||
{0x51515151, 0x51515151, 0x51515151, 0x51515151},
|
||||
{0x98B07DAA, 0x51693663, 0xA7BF8CB9, 0x263E0B38},
|
||||
{0x43463E49, 0x43463E49, 0x43463E49, 0x43463E49},
|
||||
{0x61616161, 0x68686868, 0x61616161, 0x36363636},
|
||||
{0x4B43463E, 0x614B4346, 0x68614B43, 0x6168614B},
|
||||
{0x394D403D, 0x4B43463E, 0x61394D40, 0x684B4346},
|
||||
{0x463E4967, 0x3E496786, 0x49678678, 0x6786783F},
|
||||
{0x4D403D56, 0x463E4967, 0x403D5686, 0x3E496778},
|
||||
{0x5D4B4346, 0x65615D4B, 0x6C686561, 0x57616C68},
|
||||
{0x65686C61, 0x6C615736, 0x57361616, 0x16161616},
|
||||
};
|
||||
|
||||
wuffs_vp8__decoder dec = {0};
|
||||
for (int mode = 0; mode < 10; mode++) {
|
||||
uint32_t w0 = test_cases[mode][0];
|
||||
uint32_t w1 = test_cases[mode][1];
|
||||
uint32_t w2 = test_cases[mode][2];
|
||||
uint32_t w3 = test_cases[mode][3];
|
||||
|
||||
initialize_decoder_test_state(&dec);
|
||||
|
||||
dec.private_impl.f_mb_subblock_modes[0] = mode;
|
||||
wuffs_vp8__decoder__predict_y4(&dec, 0);
|
||||
|
||||
uint32_t h0 = wuffs_base__peek_u32be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[1][8]);
|
||||
uint32_t h1 = wuffs_base__peek_u32be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[2][8]);
|
||||
uint32_t h2 = wuffs_base__peek_u32be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[3][8]);
|
||||
uint32_t h3 = wuffs_base__peek_u32be__no_bounds_check(
|
||||
&dec.private_impl.f_yuv_cache[4][8]);
|
||||
|
||||
if ((h0 != w0) || (h1 != w1) || (h2 != w2) || (h3 != w3)) {
|
||||
RETURN_FAIL(
|
||||
"mode=%d:" //
|
||||
"\nhave %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 //
|
||||
"\nwant %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32, //
|
||||
mode, h0, h1, h2, h3, w0, w1, w2, w3);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ---------------- Mimic Tests
|
||||
|
||||
@@ -91,7 +380,9 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the
|
||||
|
||||
proc g_tests[] = {
|
||||
|
||||
// No VP8 tests.
|
||||
test_wuffs_vp8_decode_predict_uv8,
|
||||
test_wuffs_vp8_decode_predict_y16,
|
||||
test_wuffs_vp8_decode_predict_y4,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
|
||||
Reference in new issue
Block a user