From 4beeda2713b1e3830804c1d208d5db3d501bf3f6 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Thu, 24 Jun 2021 13:19:11 +0200 Subject: [PATCH] nvidia/cv/image: Store alignment for later use --- source/nvidia/cv/nvidia-cv-image.cpp | 9 +++++---- source/nvidia/cv/nvidia-cv-image.hpp | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/nvidia/cv/nvidia-cv-image.cpp b/source/nvidia/cv/nvidia-cv-image.cpp index 3b8dba70..8d6d0678 100644 --- a/source/nvidia/cv/nvidia-cv-image.cpp +++ b/source/nvidia/cv/nvidia-cv-image.cpp @@ -51,7 +51,7 @@ image::~image() _cv->NvCVImage_Dealloc(&_image); } -image::image() : _cv(::streamfx::nvidia::cv::cv::get()), _image() +image::image() : _cv(::streamfx::nvidia::cv::cv::get()), _image(), _alignment(1) { // Forcefully clear the image storage. memset(&_image, sizeof(_image), 0); @@ -64,8 +64,9 @@ image::image(uint32_t width, uint32_t height, pixel_format pix_fmt, component_ty auto gctx = ::streamfx::obs::gs::context(); auto cctx = ::streamfx::nvidia::cuda::obs::get()->get_context()->enter(); + _alignment = alignment; if (auto res = _cv->NvCVImage_Alloc(&_image, width, height, pix_fmt, cmp_type, static_cast(cmp_layout), - static_cast(location), alignment); + static_cast(location), _alignment); res != result::SUCCESS) { throw std::runtime_error(_cv->NvCV_GetErrorStringFromCode(res)); } @@ -83,13 +84,13 @@ void streamfx::nvidia::cv::image::reallocate(uint32_t width, uint32_t height, pi res != result::SUCCESS) { throw std::runtime_error(_cv->NvCV_GetErrorStringFromCode(res)); } + _alignment = alignment; } void streamfx::nvidia::cv::image::resize(uint32_t width, uint32_t height) { - // TODO: Is pixel_bytes correct? reallocate(width, height, _image.pxl_format, _image.comp_type, static_cast(_image.comp_layout), - static_cast(_image.mem_location), _image.pixel_bytes); + static_cast(_image.mem_location), _alignment); } streamfx::nvidia::cv::image_t* streamfx::nvidia::cv::image::get_image() diff --git a/source/nvidia/cv/nvidia-cv-image.hpp b/source/nvidia/cv/nvidia-cv-image.hpp index d301ba40..4c180bbd 100644 --- a/source/nvidia/cv/nvidia-cv-image.hpp +++ b/source/nvidia/cv/nvidia-cv-image.hpp @@ -32,6 +32,7 @@ namespace streamfx::nvidia::cv { protected: std::shared_ptr<::streamfx::nvidia::cv::cv> _cv; image_t _image; + size_t _alignment; public: virtual ~image();