add webp test

This commit is contained in:
alexey.lysiuk 2023-08-23 16:18:06 +03:00
parent 73ad049e10
commit d91e8373c6

59
test/libwebp.cpp Normal file
View file

@ -0,0 +1,59 @@
#include <webp/decode.h>
// https://chromium.googlesource.com/webm/libwebp-test-data
// https://chromium-review.googlesource.com/c/webm/libwebp-test-data/+/3384439
static uint8_t alpha_filter_1[] =
{
0x52, 0x49, 0x46, 0x46, 0x6a, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38, 0x58,
0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x41, 0x4c,
0x50, 0x48, 0x23, 0x00, 0x00, 0x00, 0x05, 0x17, 0x20, 0x20, 0x49, 0x43, 0xe0, 0xf0, 0x8a, 0x88,
0x58, 0x20, 0x93, 0xb6, 0xd1, 0x30, 0x4f, 0x61, 0xfe, 0x35, 0xed, 0x9d, 0x81, 0x88, 0xfe, 0x13,
0x4c, 0xd2, 0x54, 0xdb, 0x31, 0x45, 0xa6, 0xdb, 0x01, 0x00, 0x56, 0x50, 0x38, 0x20, 0x20, 0x00,
0x00, 0x00, 0x70, 0x01, 0x00, 0x9d, 0x01, 0x2a, 0x10, 0x00, 0x10, 0x00, 0x0f, 0xc0, 0xfe, 0x25,
0xa0, 0x02, 0x74, 0x01, 0x40, 0x00, 0x00, 0xfe, 0xda, 0x26, 0x95, 0x7a, 0xbc, 0xb9, 0x16, 0xc0,
0x00, 0x00
};
static uint8_t one_color_no_palette[] =
{
0x52, 0x49, 0x46, 0x46, 0x14, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38, 0x4c,
0x08, 0x00, 0x00, 0x00, 0x2f, 0x63, 0xc0, 0x18, 0x10, 0x88, 0x88, 0x08
};
static uint8_t small_1x13[] =
{
0x52, 0x49, 0x46, 0x46, 0x62, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38, 0x20,
0x44, 0x00, 0x00, 0x00, 0x30, 0x03, 0x00, 0x9d, 0x01, 0x2a, 0x01, 0x00, 0x0d, 0x00, 0x00, 0x47,
0x08, 0x85, 0x85, 0x88, 0x85, 0x84, 0x88, 0x02, 0x02, 0x02, 0x75, 0xaa, 0x03, 0xf8, 0x03, 0xfa,
0x02, 0x0d, 0x4c, 0x85, 0x06, 0xfb, 0x80, 0xfe, 0xff, 0xfe, 0x5e, 0xd1, 0xea, 0x83, 0x7c, 0xf1,
0x31, 0x39, 0xff, 0xe6, 0x06, 0x6d, 0xd8, 0xa3, 0xbf, 0xfe, 0x60, 0x6f, 0xff, 0xcc, 0x0c, 0xdb,
0xb1, 0x48, 0x5d, 0xff, 0xcc, 0x0f, 0x70, 0x00, 0x49, 0x43, 0x4d, 0x54, 0x0a, 0x00, 0x00, 0x00,
0x74, 0x65, 0x73, 0x74, 0x31, 0x78, 0x31, 0x33, 0x00, 0x00
};
int main()
{
AEDI_EXPECT(WebPGetDecoderVersion() != 0);
{
int width, height;
AEDI_EXPECT(WebPGetInfo(alpha_filter_1, sizeof alpha_filter_1, &width, &height));
AEDI_EXPECT(width == 16);
AEDI_EXPECT(height == 16);
}
{
int width, height;
AEDI_EXPECT(WebPGetInfo(one_color_no_palette, sizeof one_color_no_palette, &width, &height));
AEDI_EXPECT(width == 100);
AEDI_EXPECT(height == 100);
}
{
int width, height;
AEDI_EXPECT(WebPGetInfo(small_1x13, sizeof small_1x13, &width, &height));
AEDI_EXPECT(width == 1);
AEDI_EXPECT(height == 13);
}
return 0;
}