vic.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <memory>
  5. #include <vector>
  6. #include "common/common_types.h"
  7. struct SwsContext;
  8. namespace Tegra {
  9. namespace Host1x {
  10. class Host1x;
  11. class Nvdec;
  12. union VicConfig;
  13. class Vic {
  14. public:
  15. enum class Method : u32 {
  16. Execute = 0xc0,
  17. SetControlParams = 0x1c1,
  18. SetConfigStructOffset = 0x1c2,
  19. SetOutputSurfaceLumaOffset = 0x1c8,
  20. SetOutputSurfaceChromaOffset = 0x1c9,
  21. SetOutputSurfaceChromaUnusedOffset = 0x1ca
  22. };
  23. explicit Vic(Host1x& host1x, std::shared_ptr<Nvdec> nvdec_processor);
  24. ~Vic();
  25. /// Write to the device state.
  26. void ProcessMethod(Method method, u32 argument);
  27. private:
  28. void Execute();
  29. void WriteRGBFrame(const AVFrame* frame, const VicConfig& config);
  30. void WriteYUVFrame(const AVFrame* frame, const VicConfig& config);
  31. Host1x& host1x;
  32. std::shared_ptr<Tegra::Host1x::Nvdec> nvdec_processor;
  33. /// Avoid reallocation of the following buffers every frame, as their
  34. /// size does not change during a stream
  35. using AVMallocPtr = std::unique_ptr<u8, decltype(&av_free)>;
  36. AVMallocPtr converted_frame_buffer;
  37. std::vector<u8> luma_buffer;
  38. std::vector<u8> chroma_buffer;
  39. GPUVAddr config_struct_address{};
  40. GPUVAddr output_surface_luma_address{};
  41. GPUVAddr output_surface_chroma_address{};
  42. SwsContext* scaler_ctx{};
  43. s32 scaler_width{};
  44. s32 scaler_height{};
  45. };
  46. } // namespace Host1x
  47. } // namespace Tegra