mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 19:47:17 +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.
36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) 2024, Gregory Bertilson <zaggy1024@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibMedia/CodecID.h>
|
|
#include <LibMedia/Export.h>
|
|
#include <LibMedia/VideoDecoder.h>
|
|
|
|
#include "FFmpegForward.h"
|
|
|
|
namespace Media::FFmpeg {
|
|
|
|
class MEDIA_API FFmpegVideoDecoder final : public VideoDecoder {
|
|
public:
|
|
static DecoderErrorOr<NonnullOwnPtr<FFmpegVideoDecoder>> try_create(CodecID, ReadonlyBytes codec_initialization_data);
|
|
FFmpegVideoDecoder(AVCodecContext* codec_context, AVPacket* packet, AVFrame* frame);
|
|
virtual ~FFmpegVideoDecoder() override;
|
|
|
|
virtual DecoderErrorOr<void> receive_coded_data(AK::Duration timestamp, AK::Duration duration, ReadonlyBytes coded_data) override;
|
|
virtual void signal_end_of_stream() override;
|
|
virtual DecoderErrorOr<NonnullOwnPtr<VideoFrame>> get_decoded_frame(CodingIndependentCodePoints const& container_cicp) override;
|
|
|
|
virtual void flush() override;
|
|
|
|
private:
|
|
AVCodecContext* m_codec_context;
|
|
AVPacket* m_packet;
|
|
AVFrame* m_frame;
|
|
};
|
|
|
|
}
|