mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:07:34 +00:00
LibVideo: Convert subsampled frames in a vectorization-friendly way
This change reduces the time spent converting frames for display in a 1080p video from ~19ms per frame to ~12ms per frame.
This commit is contained in:
parent
f2c0cee522
commit
7a58577fee
4 changed files with 114 additions and 59 deletions
|
@ -23,20 +23,20 @@ public:
|
|||
virtual DecoderErrorOr<void> output_to_bitmap(Gfx::Bitmap& bitmap) = 0;
|
||||
virtual DecoderErrorOr<NonnullRefPtr<Gfx::Bitmap>> to_bitmap()
|
||||
{
|
||||
auto bitmap = DECODER_TRY_ALLOC(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, m_size));
|
||||
auto bitmap = DECODER_TRY_ALLOC(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { width(), height() }));
|
||||
TRY(output_to_bitmap(bitmap));
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
inline Gfx::IntSize size() { return m_size; }
|
||||
inline size_t width() { return size().width(); }
|
||||
inline size_t height() { return size().height(); }
|
||||
inline Gfx::Size<u32> size() const { return m_size; }
|
||||
inline u32 width() const { return size().width(); }
|
||||
inline u32 height() const { return size().height(); }
|
||||
|
||||
inline u8 bit_depth() { return m_bit_depth; }
|
||||
inline u8 bit_depth() const { return m_bit_depth; }
|
||||
inline CodingIndependentCodePoints& cicp() { return m_cicp; }
|
||||
|
||||
protected:
|
||||
VideoFrame(Gfx::IntSize size,
|
||||
VideoFrame(Gfx::Size<u32> size,
|
||||
u8 bit_depth, CodingIndependentCodePoints cicp)
|
||||
: m_size(size)
|
||||
, m_bit_depth(bit_depth)
|
||||
|
@ -44,7 +44,7 @@ protected:
|
|||
{
|
||||
}
|
||||
|
||||
Gfx::IntSize m_size;
|
||||
Gfx::Size<u32> m_size;
|
||||
u8 m_bit_depth;
|
||||
CodingIndependentCodePoints m_cicp;
|
||||
};
|
||||
|
@ -53,13 +53,13 @@ class SubsampledYUVFrame : public VideoFrame {
|
|||
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<SubsampledYUVFrame>> try_create(
|
||||
Gfx::IntSize size,
|
||||
Gfx::Size<u32> size,
|
||||
u8 bit_depth, CodingIndependentCodePoints cicp,
|
||||
bool subsampling_horizontal, bool subsampling_vertical,
|
||||
Span<u16> plane_y, Span<u16> plane_u, Span<u16> plane_v);
|
||||
|
||||
SubsampledYUVFrame(
|
||||
Gfx::IntSize size,
|
||||
Gfx::Size<u32> size,
|
||||
u8 bit_depth, CodingIndependentCodePoints cicp,
|
||||
bool subsampling_horizontal, bool subsampling_vertical,
|
||||
FixedArray<u16>& plane_y, FixedArray<u16>& plane_u, FixedArray<u16>& plane_v)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue