Files
ladybird/Userland/Libraries/LibMedia/FFmpeg/FFmpegVideoDecoder.h
Zaggy1024 c128a19903 LibMedia: Add a function to flush persistent data from video decoders
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.
2024-06-24 12:41:32 -06:00

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;
};
}