summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/extras/dec/gif.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /third_party/jpeg-xl/lib/extras/dec/gif.cc
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/jpeg-xl/lib/extras/dec/gif.cc')
-rw-r--r--third_party/jpeg-xl/lib/extras/dec/gif.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/third_party/jpeg-xl/lib/extras/dec/gif.cc b/third_party/jpeg-xl/lib/extras/dec/gif.cc
index 3d963941c0..3f89d460b8 100644
--- a/third_party/jpeg-xl/lib/extras/dec/gif.cc
+++ b/third_party/jpeg-xl/lib/extras/dec/gif.cc
@@ -50,8 +50,10 @@ void ensure_have_alpha(PackedFrame* frame) {
/*endianness=*/JXL_NATIVE_ENDIAN,
/*align=*/0,
};
- frame->extra_channels.emplace_back(frame->color.xsize, frame->color.ysize,
- alpha_format);
+ JXL_ASSIGN_OR_DIE(PackedImage image,
+ PackedImage::Create(frame->color.xsize, frame->color.ysize,
+ alpha_format));
+ frame->extra_channels.emplace_back(std::move(image));
// We need to set opaque-by-default.
std::fill_n(static_cast<uint8_t*>(frame->extra_channels[0].pixels()),
frame->color.xsize * frame->color.ysize, 255u);
@@ -136,7 +138,7 @@ Status DecodeImageGIF(Span<const uint8_t> bytes, const ColorHints& color_hints,
}
if (gif->ImageCount > 1) {
- ppf->info.have_animation = true;
+ ppf->info.have_animation = JXL_TRUE;
// Delays in GIF are specified in 100ths of a second.
ppf->info.animation.tps_numerator = 100;
ppf->info.animation.tps_denominator = 1;
@@ -186,7 +188,9 @@ Status DecodeImageGIF(Span<const uint8_t> bytes, const ColorHints& color_hints,
}
const PackedRgba background_rgba{background_color.Red, background_color.Green,
background_color.Blue, 0};
- PackedFrame canvas(gif->SWidth, gif->SHeight, canvas_format);
+ JXL_ASSIGN_OR_RETURN(
+ PackedFrame canvas,
+ PackedFrame::Create(gif->SWidth, gif->SHeight, canvas_format));
std::fill_n(static_cast<PackedRgba*>(canvas.color.pixels()),
canvas.color.xsize * canvas.color.ysize, background_rgba);
Rect canvas_rect{0, 0, canvas.color.xsize, canvas.color.ysize};
@@ -230,8 +234,14 @@ Status DecodeImageGIF(Span<const uint8_t> bytes, const ColorHints& color_hints,
}
// Allocates the frame buffer.
- ppf->frames.emplace_back(total_rect.xsize(), total_rect.ysize(),
- packed_frame_format);
+ {
+ JXL_ASSIGN_OR_RETURN(
+ PackedFrame frame,
+ PackedFrame::Create(total_rect.xsize(), total_rect.ysize(),
+ packed_frame_format));
+ ppf->frames.emplace_back(std::move(frame));
+ }
+
PackedFrame* frame = &ppf->frames.back();
// We cannot tell right from the start whether there will be a
@@ -301,8 +311,10 @@ Status DecodeImageGIF(Span<const uint8_t> bytes, const ColorHints& color_hints,
}
// Update the canvas by creating a copy first.
- PackedImage new_canvas_image(canvas.color.xsize, canvas.color.ysize,
- canvas.color.format);
+ JXL_ASSIGN_OR_RETURN(
+ PackedImage new_canvas_image,
+ PackedImage::Create(canvas.color.xsize, canvas.color.ysize,
+ canvas.color.format));
memcpy(new_canvas_image.pixels(), canvas.color.pixels(),
new_canvas_image.pixels_size);
for (size_t y = 0, byte_index = 0; y < image_rect.ysize(); ++y) {