Decode Windows WebP images without an AVX requirement (by Codex)
This commit is contained in:
1 parent
a7aa1d3713
commit
678fce47f6
3 files changed
+29
No files matched your search
@@ -3,6 +3,7 @@
|
||||
#include "editor/mcp.hpp"
|
||||
#include "editor/session.hpp"
|
||||
#include <httplib.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#ifdef _WIN32
|
||||
@@ -108,6 +109,25 @@ int main() {
|
||||
const auto png = images::encode_png(image);
|
||||
write_atomic(root / "input.png", png);
|
||||
check(images::decode(png, ".png").pixels == image.pixels, "PNG lossless RGBA");
|
||||
// Authored synthetic pixels: a solid teal 17x19 VP8 image and the
|
||||
// same four RGBA pixels as above encoded as VP8L, including alpha.
|
||||
const std::string webp_lossy(
|
||||
"\x52\x49\x46\x46\x4a\x00\x00\x00\x57\x45\x42\x50\x56\x50\x38\x20"
|
||||
"\x3e\x00\x00\x00\x90\x03\x00\x9d\x01\x2a\x11\x00\x13\x00\x3e\x31"
|
||||
"\x18\x8a\x43\xa2\x21\xa1\x14\x04\x00\x20\x03\x04\xb2\x80\x3b\x00"
|
||||
"\x7e\x00\x7e\x00\x00\x49\x95\x7c\x00\x00\xfe\xe8\x38\xbf\xff\xf6"
|
||||
"\x96\x42\x15\xd7\xfc\x95\x7f\xff\xee\x9e\x90\x81\xa3\xfe\x4a\x00\x00\x00", 82);
|
||||
const std::string webp_lossless(
|
||||
"\x52\x49\x46\x46\x30\x00\x00\x00\x57\x45\x42\x50\x56\x50\x38\x4c"
|
||||
"\x23\x00\x00\x00\x2f\x01\x40\x00\x10\x1f\x20\x10\x48\xde\x1f\x3a"
|
||||
"\x8d\xf9\x17\x10\x14\xfc\x1f\x9d\x80\xa0\xe8\xba\xe5\x22\x66\x0f"
|
||||
"\xc2\x0d\x18\x22\xfa\x1f\x02\x00", 56);
|
||||
const auto webp = images::decode(webp_lossy, ".webp");
|
||||
check(webp.width == 17 && webp.height == 19 && webp.pixels.size() == 17 * 19 * 4 &&
|
||||
std::abs(int(webp.pixels[0]) - 40) <= 4 && std::abs(int(webp.pixels[1]) - 140) <= 4 &&
|
||||
std::abs(int(webp.pixels[2]) - 200) <= 4 && webp.pixels[3] == 255,
|
||||
"WebP lossy colour and dimensions");
|
||||
check(images::decode(webp_lossless, ".webp").pixels == image.pixels, "WebP lossless RGBA");
|
||||
check(images::transform(png, ".png", Json::object()).bytes == png, "identity preserves exact bytes");
|
||||
auto flip = images::decode(images::transform(png, ".png", {{"flip_x", true}}).bytes, ".png");
|
||||
check(flip.pixels[1] == 255 && flip.pixels[4] == 255, "horizontal mirror pixels");
|
||||
|
||||
Reference in new issue
Block a user