mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Add a virtual method to query frame durations without decoding pixel data. This is needed by the ImageDecoder service to extract timing metadata upfront for streaming animation decode. Implement the method for GIF, PNG, WebP, AVIF, and JPEGXL decoders. For WebP, extract durations from the demuxer during header decode so they are available before any frames are decoded.
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2023, Nico Weber <thakis@chromium.org>
|
|
* Copyright (c) 2024, doctortheemh <doctortheemh@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGfx/ImageFormats/ImageDecoder.h>
|
|
|
|
namespace Gfx {
|
|
|
|
class AVIFLoadingContext;
|
|
|
|
class AVIFImageDecoderPlugin final : public ImageDecoderPlugin {
|
|
public:
|
|
static bool sniff(ReadonlyBytes);
|
|
static ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> create(ReadonlyBytes);
|
|
|
|
virtual ~AVIFImageDecoderPlugin() override;
|
|
|
|
virtual IntSize size() override;
|
|
|
|
virtual bool is_animated() override;
|
|
virtual size_t loop_count() override;
|
|
virtual size_t frame_count() override;
|
|
virtual size_t first_animated_frame_index() override;
|
|
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index, Optional<IntSize> ideal_size = {}) override;
|
|
virtual int frame_duration(size_t index) override;
|
|
virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() override;
|
|
|
|
private:
|
|
AVIFImageDecoderPlugin(ReadonlyBytes, OwnPtr<AVIFLoadingContext>);
|
|
|
|
OwnPtr<AVIFLoadingContext> m_context;
|
|
};
|
|
|
|
}
|