2020-10-27 04:07:36 +01:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
|
|
|
struct SwsContext;
|
|
|
|
|
|
|
|
namespace Tegra {
|
|
|
|
class GPU;
|
|
|
|
class Nvdec;
|
2021-10-07 17:14:05 +02:00
|
|
|
union VicConfig;
|
2020-10-27 04:07:36 +01:00
|
|
|
|
|
|
|
class Vic {
|
|
|
|
public:
|
|
|
|
enum class Method : u32 {
|
|
|
|
Execute = 0xc0,
|
|
|
|
SetControlParams = 0x1c1,
|
|
|
|
SetConfigStructOffset = 0x1c2,
|
|
|
|
SetOutputSurfaceLumaOffset = 0x1c8,
|
2021-08-04 05:43:11 +02:00
|
|
|
SetOutputSurfaceChromaOffset = 0x1c9,
|
|
|
|
SetOutputSurfaceChromaUnusedOffset = 0x1ca
|
2020-10-27 04:07:36 +01:00
|
|
|
};
|
|
|
|
|
2020-10-27 07:09:17 +01:00
|
|
|
explicit Vic(GPU& gpu, std::shared_ptr<Nvdec> nvdec_processor);
|
2021-10-07 17:14:05 +02:00
|
|
|
|
2020-10-27 04:07:36 +01:00
|
|
|
~Vic();
|
|
|
|
|
|
|
|
/// Write to the device state.
|
2020-11-23 21:01:40 +01:00
|
|
|
void ProcessMethod(Method method, u32 argument);
|
2020-10-27 04:07:36 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Execute();
|
|
|
|
|
2021-10-07 17:14:05 +02:00
|
|
|
void WriteRGBFrame(const AVFrame* frame, const VicConfig& config);
|
2020-10-27 04:07:36 +01:00
|
|
|
|
2021-10-07 17:14:05 +02:00
|
|
|
void WriteYUVFrame(const AVFrame* frame, const VicConfig& config);
|
2020-10-27 04:07:36 +01:00
|
|
|
|
|
|
|
GPU& gpu;
|
|
|
|
std::shared_ptr<Tegra::Nvdec> nvdec_processor;
|
|
|
|
|
2020-11-23 19:25:01 +01:00
|
|
|
/// Avoid reallocation of the following buffers every frame, as their
|
|
|
|
/// size does not change during a stream
|
|
|
|
using AVMallocPtr = std::unique_ptr<u8, decltype(&av_free)>;
|
|
|
|
AVMallocPtr converted_frame_buffer;
|
|
|
|
std::vector<u8> luma_buffer;
|
|
|
|
std::vector<u8> chroma_buffer;
|
|
|
|
|
2020-10-27 04:07:36 +01:00
|
|
|
GPUVAddr config_struct_address{};
|
|
|
|
GPUVAddr output_surface_luma_address{};
|
2021-08-04 05:43:11 +02:00
|
|
|
GPUVAddr output_surface_chroma_address{};
|
2020-10-27 04:07:36 +01:00
|
|
|
|
|
|
|
SwsContext* scaler_ctx{};
|
|
|
|
s32 scaler_width{};
|
|
|
|
s32 scaler_height{};
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Tegra
|