2022-04-23 04:59:50 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-10-26 23:07:36 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
2022-12-18 18:09:59 -05:00
|
|
|
|
2020-10-26 23:07:36 -04:00
|
|
|
#include "common/common_types.h"
|
2022-12-18 18:09:59 -05:00
|
|
|
#include "common/scratch_buffer.h"
|
2020-10-26 23:07:36 -04:00
|
|
|
|
|
|
|
struct SwsContext;
|
|
|
|
|
|
|
|
namespace Tegra {
|
2022-01-30 04:31:13 -05:00
|
|
|
|
|
|
|
namespace Host1x {
|
|
|
|
|
2022-01-30 16:26:01 -05:00
|
|
|
class Host1x;
|
2020-10-26 23:07:36 -04:00
|
|
|
class Nvdec;
|
2021-10-07 11:14:05 -04:00
|
|
|
union VicConfig;
|
2020-10-26 23:07:36 -04:00
|
|
|
|
|
|
|
class Vic {
|
|
|
|
public:
|
|
|
|
enum class Method : u32 {
|
|
|
|
Execute = 0xc0,
|
|
|
|
SetControlParams = 0x1c1,
|
|
|
|
SetConfigStructOffset = 0x1c2,
|
|
|
|
SetOutputSurfaceLumaOffset = 0x1c8,
|
2021-08-03 23:43:11 -04:00
|
|
|
SetOutputSurfaceChromaOffset = 0x1c9,
|
|
|
|
SetOutputSurfaceChromaUnusedOffset = 0x1ca
|
2020-10-26 23:07:36 -04:00
|
|
|
};
|
|
|
|
|
2022-01-30 16:26:01 -05:00
|
|
|
explicit Vic(Host1x& host1x, std::shared_ptr<Nvdec> nvdec_processor);
|
2021-10-07 11:14:05 -04:00
|
|
|
|
2020-10-26 23:07:36 -04:00
|
|
|
~Vic();
|
|
|
|
|
|
|
|
/// Write to the device state.
|
2020-11-23 15:01:40 -05:00
|
|
|
void ProcessMethod(Method method, u32 argument);
|
2020-10-26 23:07:36 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Execute();
|
|
|
|
|
2021-10-07 11:14:05 -04:00
|
|
|
void WriteRGBFrame(const AVFrame* frame, const VicConfig& config);
|
2020-10-26 23:07:36 -04:00
|
|
|
|
2021-10-07 11:14:05 -04:00
|
|
|
void WriteYUVFrame(const AVFrame* frame, const VicConfig& config);
|
2020-10-26 23:07:36 -04:00
|
|
|
|
2022-01-30 16:26:01 -05:00
|
|
|
Host1x& host1x;
|
2022-01-30 04:31:13 -05:00
|
|
|
std::shared_ptr<Tegra::Host1x::Nvdec> nvdec_processor;
|
2020-10-26 23:07:36 -04:00
|
|
|
|
2020-11-23 13:25:01 -05: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;
|
2022-12-18 18:09:59 -05:00
|
|
|
Common::ScratchBuffer<u8> luma_buffer;
|
|
|
|
Common::ScratchBuffer<u8> chroma_buffer;
|
2020-11-23 13:25:01 -05:00
|
|
|
|
2020-10-26 23:07:36 -04:00
|
|
|
GPUVAddr config_struct_address{};
|
|
|
|
GPUVAddr output_surface_luma_address{};
|
2021-08-03 23:43:11 -04:00
|
|
|
GPUVAddr output_surface_chroma_address{};
|
2020-10-26 23:07:36 -04:00
|
|
|
|
|
|
|
SwsContext* scaler_ctx{};
|
|
|
|
s32 scaler_width{};
|
|
|
|
s32 scaler_height{};
|
|
|
|
};
|
|
|
|
|
2022-01-30 04:31:13 -05:00
|
|
|
} // namespace Host1x
|
|
|
|
|
2020-10-26 23:07:36 -04:00
|
|
|
} // namespace Tegra
|