diff options
Diffstat (limited to 'src/video_core/host1x/ffmpeg/ffmpeg.h')
-rw-r--r-- | src/video_core/host1x/ffmpeg/ffmpeg.h | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/src/video_core/host1x/ffmpeg/ffmpeg.h b/src/video_core/host1x/ffmpeg/ffmpeg.h index 1de0bbd83..a74fcba80 100644 --- a/src/video_core/host1x/ffmpeg/ffmpeg.h +++ b/src/video_core/host1x/ffmpeg/ffmpeg.h @@ -20,17 +20,20 @@ extern "C" { #endif #include <libavcodec/avcodec.h> -#include <libavfilter/avfilter.h> -#include <libavfilter/buffersink.h> -#include <libavfilter/buffersrc.h> -#include <libavutil/avutil.h> #include <libavutil/opt.h> +#ifndef ANDROID +#include <libavcodec/codec_internal.h> +#endif #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif } +namespace Tegra { +class MemoryManager; +} + namespace FFmpeg { class Packet; @@ -90,6 +93,10 @@ public: return m_frame->data[plane]; } + const u8* GetPlane(int plane) const { + return m_frame->data[plane]; + } + u8** GetPlanes() const { return m_frame->data; } @@ -98,6 +105,14 @@ public: m_frame->format = format; } + bool IsInterlaced() const { + return m_frame->interlaced_frame != 0; + } + + bool IsHardwareDecoded() const { + return m_frame->hw_frames_ctx != nullptr; + } + AVFrame* GetFrame() const { return m_frame; } @@ -160,33 +175,22 @@ public: void InitializeHardwareDecoder(const HardwareContext& context, AVPixelFormat hw_pix_fmt); bool OpenContext(const Decoder& decoder); bool SendPacket(const Packet& packet); - std::unique_ptr<Frame> ReceiveFrame(bool* out_is_interlaced); + std::shared_ptr<Frame> ReceiveFrame(); AVCodecContext* GetCodecContext() const { return m_codec_context; } -private: - AVCodecContext* m_codec_context{}; -}; - -// Wraps an AVFilterGraph. -class DeinterlaceFilter { -public: - YUZU_NON_COPYABLE(DeinterlaceFilter); - YUZU_NON_MOVEABLE(DeinterlaceFilter); - - explicit DeinterlaceFilter(const Frame& frame); - ~DeinterlaceFilter(); - - bool AddSourceFrame(const Frame& frame); - std::unique_ptr<Frame> DrainSinkFrame(); + bool UsingDecodeOrder() const { + return m_decode_order; + } private: - AVFilterGraph* m_filter_graph{}; - AVFilterContext* m_source_context{}; - AVFilterContext* m_sink_context{}; - bool m_initialized{}; + const Decoder& m_decoder; + AVCodecContext* m_codec_context{}; + s32 m_got_frame{}; + std::shared_ptr<Frame> m_temp_frame{}; + bool m_decode_order{}; }; class DecodeApi { @@ -200,14 +204,17 @@ public: bool Initialize(Tegra::Host1x::NvdecCommon::VideoCodec codec); void Reset(); - bool SendPacket(std::span<const u8> packet_data, size_t configuration_size); - void ReceiveFrames(std::queue<std::unique_ptr<Frame>>& frame_queue); + bool UsingDecodeOrder() const { + return m_decoder_context->UsingDecodeOrder(); + } + + bool SendPacket(std::span<const u8> packet_data); + std::shared_ptr<Frame> ReceiveFrame(); private: std::optional<FFmpeg::Decoder> m_decoder; std::optional<FFmpeg::DecoderContext> m_decoder_context; std::optional<FFmpeg::HardwareContext> m_hardware_context; - std::optional<FFmpeg::DeinterlaceFilter> m_deinterlace_filter; }; } // namespace FFmpeg |