mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-14 19:55:50 +00:00
Any data that sticks around in a decoder, especially frames that haven't been retrieved, may cause issues for playback. This is especially the case with H.264, since its arbitrary frame ordering to allow reference frames to precede B-frames causes it to hold onto frames, and causes the playback manager to get back a frame at a completely wrong timestamp after seeking.
36 lines
936 B
C++
36 lines
936 B
C++
/*
|
|
* Copyright (c) 2024, Gregory Bertilson <zaggy1024@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibMedia/CodecID.h>
|
|
#include <LibMedia/VideoDecoder.h>
|
|
|
|
#include "FFmpegForward.h"
|
|
|
|
namespace Media::FFmpeg {
|
|
|
|
class FFmpegVideoDecoder final : public VideoDecoder {
|
|
public:
|
|
static DecoderErrorOr<NonnullOwnPtr<FFmpegVideoDecoder>> try_create(CodecID, ReadonlyBytes codec_initialization_data);
|
|
FFmpegVideoDecoder(AVCodecContext* codec_context, AVPacket* packet, AVFrame* frame);
|
|
~FFmpegVideoDecoder();
|
|
|
|
DecoderErrorOr<void> receive_sample(Duration timestamp, ReadonlyBytes sample) override;
|
|
DecoderErrorOr<NonnullOwnPtr<VideoFrame>> get_decoded_frame() override;
|
|
|
|
void flush() override;
|
|
|
|
private:
|
|
DecoderErrorOr<void> decode_single_sample(Duration timestamp, u8* data, int size);
|
|
|
|
AVCodecContext* m_codec_context;
|
|
AVPacket* m_packet;
|
|
AVFrame* m_frame;
|
|
};
|
|
|
|
}
|