mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02: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.
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2026, Gregory Bertilson <gregory@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/FixedArray.h>
|
|
#include <AK/NonnullOwnPtr.h>
|
|
#include <LibGfx/Size.h>
|
|
#include <LibMedia/Color/CodingIndependentCodePoints.h>
|
|
#include <LibMedia/Subsampling.h>
|
|
|
|
class SkYUVAPixmaps;
|
|
|
|
namespace Gfx {
|
|
|
|
namespace Details {
|
|
|
|
struct YUVDataImpl;
|
|
|
|
}
|
|
|
|
// Holds planar YUV data with metadata needed for GPU conversion.
|
|
// Uses FixedArray for deterministic buffer sizing.
|
|
// Not ref-counted - owned directly by ImmutableBitmap via NonnullOwnPtr.
|
|
class YUVData final {
|
|
public:
|
|
static ErrorOr<NonnullOwnPtr<YUVData>> create(IntSize size, u8 bit_depth, Media::Subsampling, Media::CodingIndependentCodePoints);
|
|
|
|
~YUVData();
|
|
|
|
IntSize size() const;
|
|
u8 bit_depth() const;
|
|
Media::Subsampling subsampling() const;
|
|
Media::CodingIndependentCodePoints const& cicp() const;
|
|
|
|
// Writable access for decoder to fill buffers after creation
|
|
Bytes y_data();
|
|
Bytes u_data();
|
|
Bytes v_data();
|
|
|
|
SkYUVAPixmaps const& skia_yuva_pixmaps() const;
|
|
|
|
private:
|
|
explicit YUVData(NonnullOwnPtr<Details::YUVDataImpl>);
|
|
|
|
NonnullOwnPtr<Details::YUVDataImpl> m_impl;
|
|
};
|
|
|
|
}
|