mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-21 19:30:27 +00:00
This saves us from having our own color conversion code, which was taking up a fair amount of time in VideoDataProvider. With this change, we should be able to play high resolution videos without interruptions on machines where the CPU can keep up with decoding. In order to make this change, ImmutableBitmap is now able to be constructed with YUV data instead of an RBG bitmap. It holds onto a YUVData instance that stores the buffers of image data, since Skia itself doesn't take ownership of them. In order to support greater than 8 bits of color depth, we normalize the 10- or 12-bit color values into a 16-bit range.
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2022-2026, Gregory Bertilson <gregory@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <AK/Time.h>
|
|
#include <LibGfx/Forward.h>
|
|
#include <LibGfx/Size.h>
|
|
#include <LibMedia/Color/CodingIndependentCodePoints.h>
|
|
#include <LibMedia/Export.h>
|
|
|
|
namespace Media {
|
|
|
|
class MEDIA_API VideoFrame final {
|
|
|
|
public:
|
|
VideoFrame(AK::Duration timestamp, AK::Duration duration,
|
|
Gfx::Size<u32> size,
|
|
u8 bit_depth, CodingIndependentCodePoints cicp,
|
|
NonnullRefPtr<Gfx::ImmutableBitmap> bitmap);
|
|
~VideoFrame();
|
|
|
|
AK::Duration timestamp() const { return m_timestamp; }
|
|
AK::Duration duration() const { return m_duration; }
|
|
|
|
Gfx::Size<u32> size() const { return m_size; }
|
|
u32 width() const { return size().width(); }
|
|
u32 height() const { return size().height(); }
|
|
|
|
u8 bit_depth() const { return m_bit_depth; }
|
|
CodingIndependentCodePoints& cicp() { return m_cicp; }
|
|
|
|
NonnullRefPtr<Gfx::ImmutableBitmap> immutable_bitmap() const;
|
|
|
|
private:
|
|
AK::Duration m_timestamp;
|
|
AK::Duration m_duration;
|
|
Gfx::Size<u32> m_size;
|
|
u8 m_bit_depth;
|
|
CodingIndependentCodePoints m_cicp;
|
|
NonnullRefPtr<Gfx::ImmutableBitmap> m_bitmap;
|
|
};
|
|
|
|
}
|