mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibGfx/AVIF: Always reduce decoding output to a bit depth of 8
Gfx::Bitmap only supports a bit depth of 8, therefore we refused to load AVIF images which didn't have this bit depth. However, we can tell the libavif decoder to reduce the output depth by setting avifRGBImage.depth to 8. This allows us to support any input depth. Makes images load on https://www.ikea.com/ which uses Cloudflare Images to re-encode their images to 16-bit AVIF.
This commit is contained in:
parent
5f5975c81d
commit
ffae0d8b2d
Notes:
github-actions[bot]
2025-06-18 12:28:46 +00:00
Author: https://github.com/Lubrsi
Commit: ffae0d8b2d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5105
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/tcl3
2 changed files with 10 additions and 4 deletions
|
@ -83,9 +83,6 @@ static ErrorOr<void> decode_avif_header(AVIFLoadingContext& context)
|
|||
if (result != AVIF_RESULT_OK)
|
||||
return Error::from_string_literal("Failed to decode AVIF");
|
||||
|
||||
if (context.decoder->image->depth != 8)
|
||||
return Error::from_string_literal("Unsupported bitdepth");
|
||||
|
||||
// Image header now decoded, save some results for fast access in other parts of the plugin.
|
||||
context.size = IntSize { context.decoder->image->width, context.decoder->image->height };
|
||||
context.has_alpha = context.decoder->alphaPresent == 1;
|
||||
|
@ -114,6 +111,7 @@ static ErrorOr<void> decode_avif_image(AVIFLoadingContext& context)
|
|||
rgb.pixels = bitmap->scanline_u8(0);
|
||||
rgb.rowBytes = bitmap->pitch();
|
||||
rgb.format = avifRGBFormat::AVIF_RGB_FORMAT_BGRA;
|
||||
rgb.depth = 8;
|
||||
|
||||
avifResult result = avifImageYUVToRGB(context.decoder->image, &rgb);
|
||||
if (result != AVIF_RESULT_OK)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue