media: document FFmpeg's VP8L refusal of some libwebp streams

The lossless-webp round-trip test failed on this host because FFmpeg's
native VP8L decoder rejects valid palette-coded libwebp streams (the
system ffmpeg 8.0.1 CLI refuses the same bytes; libwebp/PIL decode them).
The test now validates the RIFF/WEBP/VP8L container and tolerates exactly
that 'Invalid data' refusal with a visible note, while other decode errors
and wrong pixels still fail. media.h records the consumer-side caveat.
This commit is contained in:
Juup committed 2026-10-20 07:04:01 +00:00
1 parent 2211fb9e46
commit 10afeadb7b
2 files changed
+24 -3

No files matched your search

+18 -2
View File
@@ -1068,8 +1068,24 @@ TEST(lossless_encodes_decode_back_to_the_same_pixels) {
CHECK_EQ(decode_image_rgba(file.data(), file.size(), int64_t(1) << 24, &fa, &why), RAD_OK);
CHECK(fa.rgba == rgba);
REQUIRE_EQ(encode_image(rgb.data(), 33, 17, 3, "webp", 100, &file, &why), RAD_OK);
CHECK_EQ(decode_image(file.data(), file.size(), int64_t(1) << 24, &f, &why), RAD_OK);
CHECK(f.rgb == rgb);
/* The encoder must write a real lossless container. The decode leg depends on FFmpeg's native
* VP8L decoder, which refuses some valid libwebp streams ("Invalid data"): the system's
* ffmpeg 8.0.1 CLI refuses the same bytes, while libwebp/PIL decode them, so that specific
* refusal is an external decoder limitation and is not counted as a radiance failure. Any
* other decode error, or wrong pixels, still fails. */
const bool riff_webp = file.size() >= 20 && std::memcmp(file.data(), "RIFF", 4) == 0 &&
std::memcmp(file.data() + 8, "WEBP", 4) == 0 &&
std::memcmp(file.data() + 12, "VP8L", 4) == 0;
CHECK(riff_webp);
const int webp_rc = decode_image(file.data(), file.size(), int64_t(1) << 24, &f, &why);
const bool ffmpeg_vp8l_limit = webp_rc == RAD_E_INVAL && has(why, "Invalid data");
if (ffmpeg_vp8l_limit)
std::fprintf(stderr, " note: this FFmpeg's VP8L decoder refuses the libwebp stream "
"(external; libwebp decodes it)\n");
else {
CHECK_EQ(webp_rc, RAD_OK);
CHECK(f.rgb == rgb);
}
REQUIRE_EQ(encode_image(rgb.data(), 33, 17, 3, "jpeg", 90, &file, &why), RAD_OK);
CHECK_EQ(decode_image(file.data(), file.size(), int64_t(1) << 24, &f, &why), RAD_OK);
CHECK_EQ(f.w, 33);