v0.7.1.0 Release

v0.7.1.0 Release
This commit is contained in:
jdsouza90 committed 2022-09-20 10:00:17 -07:00
1 parent 7f69da2ee4
commit 3058988f6f
39 files changed
+2128 -395

No files matched your search

+14 -8
View File
@@ -1,8 +1,14 @@
Changelog (v0.6.5.2)
- AI Green Screen filter
- Quality mode is updated for higher quality
- Added CUDA graph optimization which may improve overall latency under a GPU-intensive workload.
- Super Resolution filter
- 4K input support for 4/3x(~1.33x), 1.5x and 2x super resolution
- Migrated to TensorRT 8.0.1.6
- Migrated to CUDA 11.3u1
Changelog (v0.7.1.0)
--------------------
- NvCVImage_Transfer() now sets alpha to 255 or 1.0f when doing RGB -> RGBA
- NvCVImage_CompositeRect() has a premultiplied alpha mode added
- AI Green Screen filter
- Introduced NVVFX_MAX_INPUT_WIDTH, NVVFX_MAX_INPUT_HEIGHT parameter selectors and getters to set the maximum input resolution
for NVVFX_FX_GREEN_SCREEN pipeline to avoid lazy memory allocations
- Introduced the following parameter selectors and APIs for NVVFX_FX_GREEN_SCREEN to improve the quality of the model
- NVVFX_MAX_NUMBER_STREAMS parameter selector to set the maximum number of streams
- NVVFX_STATE, NVVFX_STATE_COUNT parameter selectors
- NvVFX_AllocateState, NvVFX_DeallocateState, NvVFX_ResetState, NvVFX_SetStateObjectHandleArray APIs
- BatchEffectApp does not support NVVFX_FX_GREEN_SCREEN anymore. Use BatchAigsEffectApp as the sample app for batch input
- Migrated to TensorRT 8.4.2.2
- Migrated to CUDA 11.6u1
+72 -4
View File
@@ -21,9 +21,77 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(SDK_INCLUDES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/nvvfx/include)
# Add target for NVVideoEffects
add_library(NVVideoEffects INTERFACE)
target_include_directories(NVVideoEffects INTERFACE ${SDK_INCLUDES_PATH})
if(MSVC)
set(SDK_INCLUDES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/nvvfx/include)
# Add target for NVVideoEffects
add_library(NVVideoEffects INTERFACE)
target_include_directories(NVVideoEffects INTERFACE ${SDK_INCLUDES_PATH})
else()
# Add target for NVVideoEffects
add_library(NVVideoEffects INTERFACE)
# found in different locations depending on type of package
find_path(VideoFX_INCLUDES
NAMES nvVideoEffects.h
PATHS
/usr/local/VideoFX/include
/usr/include/x86_64-linux-gnu
/usr/include
REQUIRED
)
target_include_directories(NVVideoEffects INTERFACE ${VideoFX_INCLUDES})
set(SDK_INCLUDES_PATH ${VideoFX_INCLUDES})
find_library(VideoFX_LIB
NAMES libVideoFX.so
PATHS
/usr/local/VideoFX/lib
/usr/lib/x86_64-linux-gnu
/usr/lib64
/usr/lib
REQUIRED
NO_DEFAULT_PATH)
target_link_libraries(NVVideoEffects INTERFACE "${VideoFX_LIB}")
message(STATUS "VideoFX_LIB: ${VideoFX_LIB}")
message(STATUS "SDK_INCLUDES_PATH: ${SDK_INCLUDES_PATH}")
# Add target for NVCVImage
add_library(NVCVImage INTERFACE)
# found in different locations depending on type of package
find_path(NVCVImage_INCLUDES
NAMES nvCVImage.h
PATHS
/usr/local/VideoFX/include
/usr/include/x86_64-linux-gnu
/usr/include
REQUIRED
)
target_include_directories(NVCVImage INTERFACE ${NVCVImage_INCLUDES})
find_library(NVCVImage_LIB
NAMES libNVCVImage.so
PATHS
/usr/local/VideoFX/lib
/usr/lib/x86_64-linux-gnu
/usr/lib64
/usr/lib
REQUIRED
NO_DEFAULT_PATH)
target_link_libraries(NVCVImage INTERFACE "${NVCVImage_LIB}")
message(STATUS "NVCVImage_LIB: ${NVCVImage_LIB}")
message(STATUS "NVCVImage_INCLUDES_PATH: ${NVCVImage_INCLUDES}")
endif()
add_subdirectory(samples)
+17 -18
View File
@@ -1,40 +1,39 @@
# README
## NVIDIA MAXINE VideoEffects SDK: API Source Code and Sample Applications
NVIDIA MAXINE VideoEffects SDK is an SDK for enhancing and applying filters to videos at real-time. The SDK is powered by NVIDIA graphics processing units (GPUs) with Tensor Cores, and as a result, the algorithm throughput is greatly accelerated, and latency is reduced.
NVIDIA MAXINE Video Effects SDK enables AI-based visual effects that run with standard webcam input and can easily be integrated into video conference and content creation pipelines. The underlying deep learning models are optimized with NVIDIA AI using NVIDIA® TensorRT™ for high-performance inference, making it possible for developers to apply multiple effects in real-time applications.
The SDK has the following AI features:
- **AI Green Screen**, which segments and masks the background areas in a video or image.
- **Background Blur**, which uses the segmentation mask from the AI Green Screen filter or other sources, and produces a blur effect over the background of a video or iamge.
- **Encoder Artifact Reduction**, which reduces the blocky and noisy artifacts from an encoded video while preserving the details of the original video.
- **Super Resolution**, which upscales a video while also reducing the blocky and noisy artifacts. It can enhance the details and sharpen the output while simultaneously preserving the content. This is suitable for upscaling lossy content.
- **Upscale**, which is a very fast and light-weight method for upscaling an input video. It also provides a sharpening parameter to sharpen the resulting output. This feature can be optionally pipelined with the encoder artifact reduction feature to enhance the scale while reducing the video artifacts.
- **Webcam Denoising**, which removes noise from a webcam video while preserving the texture details.
- **Virtual Background**,which segments and masks the background areas in a video or image to enable AI-powered background removal, replacement, or blur.
- **Artifact Reduction**, which reduces compression artifacts from an encoded video while preserving the details of the original video.
- **Super Resolution**, which generates a detail-enhanced video with up to 4X high-quality scaling, while also reducing blocky/noisy artifacts and preserving textures and content. It is suitable for upscaling lossy content.
- **Upscaler**, which is a very fast and light-weight method to deliver up to 4X high-quality scaled video with an adjustable sharpening parameter. This feature can be optionally pipelined with the Artifact Reduction feature to enhance the scale while reducing the video artifacts.
- **Video Noise Removal**, which removes low-light camera noise from a webcam video while preserving the texture details.
<p align="center">
<img src="https://github.com/NVIDIA/MAXINE-VFX-SDK/blob/master/resources/SR.gif" alt="NVIDIA Super Resolution" width="640" height="320"/>
</p>
<p align="center">
<img src="https://github.com/NVIDIA/MAXINE-VFX-SDK/blob/master/resources/Denoise.gif" alt="NVIDIA Webcam Denoising" width="640" height="320"/>
<img src="https://github.com/NVIDIA/MAXINE-VFX-SDK/blob/master/resources/Denoise.gif" alt="NVIDIA Video Noise Removal" width="640" height="320"/>
</p>
The SDK provides several sample applications that demonstrate the features listed above in real time by using offline videos.
- **AI Green Screen App**, which is a sample app that demonstrates the background segmentation feature.
- **VideoEffects App**, which is a sample app that can invoke each of Encoder Artifact Reduction, Super Resolution or Upscale features individually.
- **UpscalePipeline App**, which is a sample app that pipelines the Encoder Artifact Reduction feature with the Upscale feature.
- **DenoiseEffect App**, which is a sample app that demonstrates the webcam denoising feature.
- **AI Green Screen App**, which is a sample app that demonstrates the Virtual background feature.
- **VideoEffects App**, which is a sample app that can invoke each of Artifact Reduction, Super Resolution or Upscaler features individually.
- **UpscalePipeline App**, which is a sample app that pipelines the Artifact Reduction feature with the Upscaler feature.
- **DenoiseEffect App**, which is a sample app that demonstrates the Video Noise Removal feature.
The input and output resolutions supported by the features of the SDK are listed below.
- The Encoder Artifact Reduction feature supports between 90p to 1080p as input resolutions.
- The Artifact Reduction feature supports between 90p to 1080p as input resolutions.
- The Super Resolution feature supports between 90p to 2160p as input resolutions.
- Super Resolution supports the following scaling factors: 4/3x (~1.33x), 1.5x, 2x, 3x and 4x.
- 2160p input is only supported for the following scaling factors: 4/3x (~1.33x), 1.5x and 2x
- The maximum output resolution for the Super Resolution feature is 4320p.
- The Upscale feature supports any input resolution, and the following scaling factors: 4/3x (~1.33x), 1.5x, 2x, 3x and 4x.
- The Webcam Denoising feature supports between 80p to 1080p as input resolutions.
- The AI Green Screen and Background Blur features require that an input image/video be at least 288 pixels high.
- The Upscaler feature supports any input resolution, and the following scaling factors: 4/3x (~1.33x), 1.5x, 2x, 3x and 4x.
- The Video Noise Removal feature supports between 80p to 1080p as input resolutions.
- The Virtual Background and Background Blur features require that an input image/video be at least 288 pixels high.
NVIDIA MAXINE VideoEffects SDK is distributed in the following parts:
@@ -44,12 +43,12 @@ NVIDIA MAXINE VideoEffects SDK is distributed in the following parts:
Please refer to the [SDK System guide](https://docs.nvidia.com/deeplearning/maxine/vfx-sdk-system-guide/) for configuring and integrating the SDK, compiling and running the sample applications. Please visit the [NVIDIA MAXINE Video Effects SDK](https://developer.nvidia.com/maxine-getting-started) webpage for more information about the SDK.
## System requirements
The SDK is supported on NVIDIA GPUs that are based on the NVIDIA® Turing™ or Ampere™ architecture and have Tensor Cores.
The SDK is supported on NVIDIA GPUs that are based on the NVIDIA® Turing™, Ampere™ or Ada™ architecture and have Tensor Cores.
* Windows OS supported: 64-bit Windows 10 or later
* Microsoft Visual Studio: 2017 (MSVC15.0) or later
* CMake: v3.12 or later
* NVIDIA Graphics Driver for Windows: 465.89 or later
* NVIDIA Graphics Driver for Windows: 511.65 or later
## NVIDIA MAXINE Branding Guidelines
If you integrate an NVIDIA MAXINE SDK within your product, please follow the required branding guidelines that are available [here](https://www.nvidia.com/maxine-sdk-guidelines/)
+25 -2
View File
@@ -323,6 +323,12 @@ NvCV_Status NvCV_API NvCVImage_Realloc(NvCVImage *im, unsigned width, unsigned h
void NvCV_API NvCVImage_Dealloc(NvCVImage *im);
//! Deallocate the image buffer from the image asynchronously on the specified stream. The image is not deallocated.
//! param[in,out] im the image whose buffer is to be deallocated.
//! param[int] stream the CUDA stream on which the image buffer is to be deallocated..
void NvCV_API NvCVImage_DeallocAsync(NvCVImage *im, struct CUstream_st *stream);
//! Allocate a new image, with storage (C-style constructor).
//! \param[in] width the desired width of the image, in pixels.
//! \param[in] height the desired height of the image, in pixels.
@@ -378,7 +384,7 @@ void NvCV_API NvCVImage_ComponentOffsets(NvCVImage_PixelFormat format, int *rOff
//! | RGB --> RGB | X | X | X | X |
//! | RGB --> RGBA | X | X | X | X |
//! | RGBA --> Y | X | X | | |
//! | RGBA --> A | | X | | |
//! | RGBA --> A | X | | | |
//! | RGBA --> RGB | X | X | X | X |
//! | RGBA --> RGBA | X | X | X | X |
//! | RGB --> YUV420 | X | | X | |
@@ -559,7 +565,7 @@ NvCV_Status NvCV_API NvCVImage_Composite(const NvCVImage *fg, const NvCVImage *b
//! \param[in] mat the matte image, indicating where the src should come through.
//! This determines the size of the rectangle to be composited.
//! If this is multi-channel, the alpha channel is used as the matte.
//! \param[in] mode the composition mode. Only 0 (straight alpha over) is implemented at this time.
//! \param[in] mode the composition mode: 0 (straight alpha over) or 1 (premultiplied alpha over).
//! \param[out] dst the destination image. This can be the same as fg or bg.
//! \param[in] dstOrg the upper-left corner of the dst image to be updated (NULL implies (0,0)).
//! \param[in] stream the CUDA stream on which the composition is to be performed.
@@ -631,6 +637,23 @@ NvCV_Status NvCV_API NvCVImage_GetYUVPointers(NvCVImage *im,
int *yPixBytes, int *cPixBytes, int *yRowBytes, int *cRowBytes);
//! Sharpen an image.
//! The src and dst should be the same type - conversions are not performed.
//! This function is only implemented for NVCV_CHUNKY NVCV_U8 pixels, of format NVCV_RGB or NVCV_BGR.
//! \param[in] sharpness the sharpness strength, calibrated so that 1 and 2 yields Adobe's Sharpen and Sharpen More.
//! \param[in] src the source image to be sharpened.
//! \param[out] dst the resultant image (may be the same as the src).
//! \param[in] stream the CUDA stream on which to perform the computations.
//! \param[in] tmp a temporary working image. This can be NULL, but may result in lower performance.
//! It is best if it resides on the same processor (CPU or GPU) as the destination.
//! @return NVCV_SUCCESS if the operation completed successfully.
//! NVCV_ERR_MISMATCH if the source and destination formats are different.
//! NVCV_ERR_PIXELFORMAT if the function has not been implemented for the chosen pixel type.
NvCV_Status NvCV_API NvCVImage_Sharpen(float sharpness, const NvCVImage *src, NvCVImage *dst,
struct CUstream_st *stream, NvCVImage *tmp);
#ifdef __cplusplus
} // extern "C"
+7
View File
@@ -77,7 +77,14 @@ typedef enum NvCV_Status {
NVCV_ERR_TRT_ENGINE = -30, ///< There was a problem deserializing the inference runtime engine.
NVCV_ERR_NPP = -31, //!< An error has occurred in the NPP library.
NVCV_ERR_CONFIG = -32, //!< No suitable model exists for the specified parameter configuration.
NVCV_ERR_TOOSMALL = -33, //!< A supplied parameter or buffer is not large enough.
NVCV_ERR_TOOBIG = -34, //!< A supplied parameter is too big.
NVCV_ERR_WRONGSIZE = -35, //!< A supplied parameter is not the expected size.
NVCV_ERR_OBJECTNOTFOUND = -36, //!< The specified object was not found.
NVCV_ERR_SINGULAR = -37, //!< A mathematical singularity has been encountered.
NVCV_ERR_NOTHINGRENDERED = -38, //!< Nothing was rendered in the specified region.
NVCV_ERR_OPENGL = -98, //!< An OpenGL error has occurred.
NVCV_ERR_DIRECT3D = -99, //!< A Direct3D error has occurred.
NVCV_ERR_CUDA_BASE = -100, //!< CUDA errors are offset from this value.
+37 -5
View File
@@ -55,6 +55,12 @@ typedef const char* NvVFX_ParameterSelector;
struct NvVFX_Object;
typedef struct NvVFX_Object NvVFX_Object, *NvVFX_Handle;
///!
///! Effect may use this handle to manage state objects.
///!
struct NvVFX_StateObjectHandleBase;
typedef struct NvVFX_StateObjectHandleBase* NvVFX_StateObjectHandle;
//! Get the SDK version
//! \param[in,out] version Pointer to an unsigned int set to
//! (major << 24) | (minor << 16) | (build << 8) | 0
@@ -88,6 +94,7 @@ NvCV_Status NvVFX_API NvVFX_SetF32(NvVFX_Handle effect, NvVFX_ParameterSelector
NvCV_Status NvVFX_API NvVFX_SetF64(NvVFX_Handle effect, NvVFX_ParameterSelector paramName, double val);
NvCV_Status NvVFX_API NvVFX_SetU64(NvVFX_Handle effect, NvVFX_ParameterSelector paramName, unsigned long long val);
NvCV_Status NvVFX_API NvVFX_SetObject(NvVFX_Handle effect, NvVFX_ParameterSelector paramName, void *ptr);
NvCV_Status NvVFX_API NvVFX_SetStateObjectHandleArray(NvVFX_Handle effect, NvVFX_ParameterSelector paramName, NvVFX_StateObjectHandle* handle);
NvCV_Status NvVFX_API NvVFX_SetCudaStream(NvVFX_Handle effect, NvVFX_ParameterSelector paramName, CUstream stream);
//! Set the selected image descriptor.
@@ -167,28 +174,50 @@ NvCV_Status NvVFX_API NvVFX_GetString(NvVFX_Handle effect, NvVFX_ParameterSelect
//! \param[in] async run the effect asynchronously if nonzero; otherwise run synchronously.
//! \todo Should async instead be a pointer to a place to store a token that can be useful
//! for synchronizing two streams alter?
//! \return NVFVX_SUCCESS if the operation was successful.
//! \return NVCV_SUCCESS if the operation was successful.
//! \return NVCV_ERR_EFFECT if an invalid effect handle was supplied.
NvCV_Status NvVFX_API NvVFX_Run(NvVFX_Handle effect, int async);
//! Load the model based on the set params.
//! \param[in] effect the effect object handle.
//! \return NVFVX_SUCCESS if the operation was successful.
//! \return NVCV_SUCCESS if the operation was successful.
//! \return NVCV_ERR_EFFECT if an invalid effect handle was supplied.
NvCV_Status NvVFX_API NvVFX_Load(NvVFX_Handle effect);
//! Wrapper for cudaStreamCreate(), if it is desired to avoid linking with the cuda lib.
//! \param[out] stream A place to store the newly allocated stream.
//! \return NVFVX_SUCCESS if the operation was successful,
//! \return NVCV_SUCCESS if the operation was successful,
//! NVCV_ERR_CUDA_VALUE if not.
NvCV_Status NvVFX_API NvVFX_CudaStreamCreate(CUstream *stream);
//! Wrapper for cudaStreamDestroy(), if it is desired to avoid linking with the cuda lib.
//! \param[in] stream The stream to destroy.
//! \return NVFVX_SUCCESS if the operation was successful,
//! \return NVCV_SUCCESS if the operation was successful,
//! NVCV_ERR_CUDA_VALUE if not.
NvCV_Status NvVFX_API NvVFX_CudaStreamDestroy(CUstream stream);
//! Allocate the state object handle for a feature.
//! \param[in] effect the effect object handle.
//! \param[in] handle handle to the state object
//! \return NVCV_SUCCESS if the operation was successful.
//! \return NVCV_ERR_EFFECT if an invalid effect handle was supplied.
//! \note This may depend on prior settings of parameters.
NvCV_Status NvVFX_API NvVFX_AllocateState(NvVFX_Handle effect, NvVFX_StateObjectHandle* handle);
//! Deallocate the state object handle for stateful feature.
//! \param[in] effect the effect object handle.
//! \param[in] handle handle to the state object
//! \return NVCV_SUCCESS if the operation was successful.
//! \return NVCV_ERR_EFFECT if an invalid effect handle was supplied.
NvCV_Status NvVFX_API NvVFX_DeallocateState(NvVFX_Handle effect, NvVFX_StateObjectHandle handle);
//! Reset the state object handle for stateful feature.
//! \param[in] effect the effect object handle.
//! \param[in] handle handle to the state object
//! \return NVCV_SUCCESS if the operation was successful.
//! \return NVCV_ERR_EFFECT if an invalid effect handle was supplied.
NvCV_Status NvVFX_API NvVFX_ResetState(NvVFX_Handle effect, NvVFX_StateObjectHandle handle);
// Filter selectors
#define NVVFX_FX_TRANSFER "Transfer"
@@ -209,6 +238,9 @@ NvCV_Status NvVFX_API NvVFX_CudaStreamDestroy(CUstream stream);
#define NVVFX_CUDA_STREAM "CudaStream" //!< The CUDA stream to use
#define NVVFX_CUDA_GRAPH "CudaGraph" //!< Enable CUDA graph to use
#define NVVFX_INFO "Info" //!< Get info about the effects
#define NVVFX_MAX_INPUT_WIDTH "MaxInputWidth" //!< Maximum width of the input supported
#define NVVFX_MAX_INPUT_HEIGHT "MaxInputHeight" //!< Maximum height of the input supported
#define NVVFX_MAX_NUMBER_STREAMS "MaxNumberStreams" //!< Maximum number of concurrent input streams
#define NVVFX_SCALE "Scale" //!< Scale factor
#define NVVFX_STRENGTH "Strength" //!< Strength for different filters
#define NVVFX_STRENGTH_LEVELS "StrengthLevels" //!< Number of strength levels
@@ -219,7 +251,7 @@ NvCV_Status NvVFX_API NvVFX_CudaStreamDestroy(CUstream stream);
#define NVVFX_MODEL_BATCH "ModelBatch" //!< The preferred batching model to use (default 1)
#define NVVFX_STATE "State" //!< State variable
#define NVVFX_STATE_SIZE "StateSize" //!< Number of bytes needed to store state
#define NVVFX_STATE_COUNT "NumStateObjects" //!< Number of active state object handles
#ifdef __cplusplus
+28
View File
@@ -169,6 +169,13 @@ NvCV_Status NvVFX_API NvVFX_SetObject(NvVFX_Handle obj, NvVFX_ParameterSelector
return funcPtr(obj, paramName, ptr);
}
NvCV_Status NvVFX_API NvVFX_SetStateObjectHandleArray(NvVFX_Handle obj, NvVFX_ParameterSelector paramName, NvVFX_StateObjectHandle* handle) {
static const auto funcPtr = (decltype(NvVFX_SetStateObjectHandleArray)*)nvGetProcAddress(getNvVfxLib(), "NvVFX_SetStateObjectHandleArray");
if (nullptr == funcPtr) return NVCV_ERR_LIBRARY;
return funcPtr(obj, paramName, handle);
}
NvCV_Status NvVFX_API NvVFX_SetString(NvVFX_Handle obj, NvVFX_ParameterSelector paramName, const char* str) {
static const auto funcPtr = (decltype(NvVFX_SetString)*)nvGetProcAddress(getNvVfxLib(), "NvVFX_SetString");
@@ -276,4 +283,25 @@ NvCV_Status NvVFX_API NvVFX_CudaStreamDestroy(CUstream stream) {
return funcPtr(stream);
}
NvCV_Status NvVFX_API NvVFX_AllocateState(NvVFX_Handle obj, NvVFX_StateObjectHandle* handle) {
static const auto funcPtr = (decltype(NvVFX_AllocateState)*)nvGetProcAddress(getNvVfxLib(), "NvVFX_AllocateState");
if (nullptr == funcPtr) return NVCV_ERR_LIBRARY;
return funcPtr(obj, handle);
}
NvCV_Status NvVFX_API NvVFX_DeallocateState(NvVFX_Handle obj, NvVFX_StateObjectHandle handle) {
static const auto funcPtr = (decltype(NvVFX_DeallocateState)*)nvGetProcAddress(getNvVfxLib(), "NvVFX_DeallocateState");
if (nullptr == funcPtr) return NVCV_ERR_LIBRARY;
return funcPtr(obj, handle);
}
NvCV_Status NvVFX_API NvVFX_ResetState(NvVFX_Handle obj, NvVFX_StateObjectHandle handle) {
static const auto funcPtr = (decltype(NvVFX_ResetState)*)nvGetProcAddress(getNvVfxLib(), "NvVFX_ResetState");
if (nullptr == funcPtr) return NVCV_ERR_LIBRARY;
return funcPtr(obj, handle);
}
#endif // enabling for this file
+15 -1
View File
@@ -132,10 +132,16 @@ NvCV_Status NvCV_API NvCVImage_Realloc(NvCVImage* im, unsigned width, unsigned h
void NvCV_API NvCVImage_Dealloc(NvCVImage* im) {
static const auto funcPtr = (decltype(NvCVImage_Dealloc)*)nvGetProcAddress(getNvCVImageLib(), "NvCVImage_Dealloc");
if (nullptr != funcPtr) funcPtr(im);
}
void NvCV_API NvCVImage_DeallocAsync(NvCVImage* im, CUstream_st* stream) {
static const auto funcPtr = (decltype(NvCVImage_DeallocAsync)*)nvGetProcAddress(getNvCVImageLib(), "NvCVImage_DeallocAsync");
if (nullptr != funcPtr) funcPtr(im, stream);
}
NvCV_Status NvCV_API NvCVImage_Create(unsigned width, unsigned height, NvCVImage_PixelFormat format,
NvCVImage_ComponentType type, unsigned isPlanar, unsigned onGPU,
unsigned alignment, NvCVImage** out) {
@@ -266,6 +272,14 @@ NvCV_Status NvCV_API NvCVImage_FlipY(const NvCVImage *src, NvCVImage *dst) {
return funcPtr(src, dst);
}
NvCV_Status NvCV_API NvCVImage_Sharpen(float sharpness, const NvCVImage *src, NvCVImage *dst,
struct CUstream_st *stream, NvCVImage *tmp) {
static const auto funcPtr = (decltype(NvCVImage_Sharpen)*)nvGetProcAddress(getNvCVImageLib(), "NvCVImage_Sharpen");
if (nullptr == funcPtr) return NVCV_ERR_LIBRARY;
return funcPtr(sharpness, src, dst, stream, tmp);
}
#ifdef _WIN32
__declspec(dllexport) const char* __cdecl
#else
+101 -8
View File
@@ -28,6 +28,7 @@
#include <chrono>
#include <string>
#include <iostream>
#include <vector>
#include "nvCVOpenCV.h"
#include "nvVideoEffects.h"
@@ -154,6 +155,7 @@ static void Usage() {
" 4 (show input - compNone),\n"
" 5 (composite over a specified background image - compBG),\n"
" 6 (blur the background of the image - compBlur) }\n"
" --blur_strength=[0-1] strength of the background blur, when applicable\n"
" --cuda_graph Enable cuda graph.\n"
);
}
@@ -330,14 +332,13 @@ struct FXApp {
_framePeriod = 0.f;
_lastTime = std::chrono::high_resolution_clock::time_point::min();
_blurStrength = 0.5f;
_maxInputWidth = 3840u;
_maxInputHeight = 2160u;
_maxNumberStreams = 1u;
_batchOfStates = nullptr;
}
~FXApp() {
NvVFX_DestroyEffect(_eff);
NvVFX_DestroyEffect(_bgblurEff);
if (_stream) {
NvVFX_CudaStreamDestroy(_stream);
}
destroyEffect();
}
void setShow(bool show) { _show = show; }
@@ -375,6 +376,11 @@ struct FXApp {
NvCVImage _dstNvVFXImage;
NvCVImage _blurNvVFXImage;
float _blurStrength;
unsigned int _maxInputWidth;
unsigned int _maxInputHeight;
unsigned int _maxNumberStreams;
std::vector<NvVFX_StateObjectHandle> _stateArray;
NvVFX_StateObjectHandle* _batchOfStates;
};
const char *FXApp::errorStringFromCode(Err code) {
@@ -530,12 +536,41 @@ NvCV_Status FXApp::createAigsEffect() {
return vfxErr;
}
// Set maximum width, height and number of streams and then call Load() again
vfxErr = NvVFX_SetU32(_eff, NVVFX_MAX_INPUT_WIDTH, _maxInputWidth);
if (vfxErr != NVCV_SUCCESS) {
std::cerr << "Error setting the mode \n";
return vfxErr;
}
vfxErr = NvVFX_SetU32(_eff, NVVFX_MAX_INPUT_HEIGHT, _maxInputHeight);
if (vfxErr != NVCV_SUCCESS) {
std::cerr << "Error setting the mode \n";
return vfxErr;
}
vfxErr = NvVFX_SetU32(_eff, NVVFX_MAX_NUMBER_STREAMS, _maxNumberStreams);
if (vfxErr != NVCV_SUCCESS) {
std::cerr << "Error setting the mode \n";
return vfxErr;
}
vfxErr = NvVFX_Load(_eff);
if (vfxErr != NVCV_SUCCESS) {
std::cerr << "Error loading the model \n";
return vfxErr;
}
for (unsigned int i = 0; i < _maxNumberStreams; i++) {
NvVFX_StateObjectHandle state;
vfxErr = NvVFX_AllocateState(_eff, &state);
if (NVCV_SUCCESS != vfxErr) {
std::cerr << "Error allocate state variable for effect \"" << NVVFX_FX_GREEN_SCREEN << "\"\n";
return vfxErr;
}
_stateArray.push_back(state);
}
// ------------------ create Background blur effect ------------------ //
vfxErr = NvVFX_CreateEffect(NVVFX_FX_BGBLUR, &_bgblurEff);
if (NVCV_SUCCESS != vfxErr) {
@@ -559,8 +594,26 @@ NvCV_Status FXApp::createAigsEffect() {
}
void FXApp::destroyEffect() {
// If DeallocateState fails, all memory allocated in the SDK returns to the heap when the effect handle is destroyed.
for (unsigned int i = 0; i < _stateArray.size(); i++) {
NvVFX_DeallocateState(_eff, _stateArray[i]);
}
_stateArray.clear();
if (_batchOfStates != nullptr) {
free(_batchOfStates);
_batchOfStates = nullptr;
}
NvVFX_DestroyEffect(_eff);
_eff = nullptr;
NvVFX_DestroyEffect(_bgblurEff);
_bgblurEff = nullptr;
if (_stream) {
NvVFX_CudaStreamDestroy(_stream);
}
}
static void overlay(const cv::Mat &image, const cv::Mat &mask, float alpha, cv::Mat &result) {
@@ -573,6 +626,17 @@ FXApp::Err FXApp::processImage(const char *inFile, const char *outFile) {
NvCV_Status vfxErr;
bool ok;
cv::Mat result;
NvCVImage fxSrcChunkyGPU, fxDstChunkyGPU;
// Allocate space for batchOfStates to hold state variable addresses
// Assume that MODEL_BATCH Size is enough for this scenario
unsigned int modelBatch = 1;
BAIL_IF_ERR(vfxErr = NvVFX_GetU32(_eff, NVVFX_MODEL_BATCH, &modelBatch));
_batchOfStates = (NvVFX_StateObjectHandle*) malloc(sizeof(NvVFX_StateObjectHandle) * modelBatch);
if (_batchOfStates == nullptr) {
vfxErr = NVCV_ERR_MEMORY;
goto bail;
}
if (!_eff) return errEffect;
_srcImg = cv::imread(inFile);
@@ -584,12 +648,26 @@ FXApp::Err FXApp::processImage(const char *inFile, const char *outFile) {
(void)NVWrapperForCVMat(&_srcImg, &_srcVFX);
(void)NVWrapperForCVMat(&_dstImg, &_dstVFX);
NvCVImage fxSrcChunkyGPU(_srcImg.cols, _srcImg.rows, NVCV_BGR, NVCV_U8, NVCV_CHUNKY, NVCV_GPU, 1);
NvCVImage fxDstChunkyGPU(_srcImg.cols, _srcImg.rows, NVCV_A, NVCV_U8, NVCV_CHUNKY, NVCV_GPU, 1);
if (!fxSrcChunkyGPU.pixels)
{
BAIL_IF_ERR(vfxErr =
NvCVImage_Alloc(&fxSrcChunkyGPU, _srcImg.cols, _srcImg.rows, NVCV_BGR, NVCV_U8, NVCV_CHUNKY, NVCV_GPU, 1));
}
if (!fxDstChunkyGPU.pixels) {
BAIL_IF_ERR(vfxErr =
NvCVImage_Alloc(&fxDstChunkyGPU, _srcImg.cols, _srcImg.rows, NVCV_A, NVCV_U8, NVCV_CHUNKY, NVCV_GPU, 1));
}
BAIL_IF_ERR(vfxErr = NvVFX_SetImage(_eff, NVVFX_INPUT_IMAGE, &fxSrcChunkyGPU));
BAIL_IF_ERR(vfxErr = NvVFX_SetImage(_eff, NVVFX_OUTPUT_IMAGE, &fxDstChunkyGPU));
BAIL_IF_ERR(vfxErr = NvCVImage_Transfer(&_srcVFX, &fxSrcChunkyGPU, 1.0f, _stream, NULL));
// Assign states from stateArray in batchOfStates
// There is only one stream in this app
_batchOfStates[0] = _stateArray[0];
BAIL_IF_ERR(vfxErr = NvVFX_SetStateObjectHandleArray(_eff, NVVFX_STATE, _batchOfStates));
BAIL_IF_ERR(vfxErr = NvVFX_Run(_eff, 0));
BAIL_IF_ERR(vfxErr = NvCVImage_Transfer(&fxDstChunkyGPU, &_dstVFX, 1.0f, _stream, NULL));
@@ -627,6 +705,7 @@ FXApp::Err FXApp::processMovie(const char *inFile, const char *outFile) {
cv::VideoWriter writer;
unsigned frameNum;
VideoInfo info;
unsigned int modelBatch = 1;
if (inFile && !inFile[0]) inFile = nullptr; // Set file paths to NULL if zero length
if (outFile && !outFile[0]) outFile = nullptr;
@@ -698,6 +777,15 @@ FXApp::Err FXApp::processMovie(const char *inFile, const char *outFile) {
}
}
// Allocate space for batchOfStates to hold state variable addresses
// Assume that MODEL_BATCH Size is enough for this scenario
BAIL_IF_ERR(vfxErr = NvVFX_GetU32(_eff, NVVFX_MODEL_BATCH, &modelBatch));
_batchOfStates = (NvVFX_StateObjectHandle*) malloc(sizeof(NvVFX_StateObjectHandle) * modelBatch);
if (_batchOfStates == nullptr) {
vfxErr = NVCV_ERR_MEMORY;
goto bail;
}
// allocate src for GPU
if (!_srcNvVFXImage.pixels)
BAIL_IF_ERR(vfxErr =
@@ -726,6 +814,11 @@ FXApp::Err FXApp::processMovie(const char *inFile, const char *outFile) {
BAIL_IF_ERR(vfxErr = NvVFX_SetImage(_eff, NVVFX_OUTPUT_IMAGE, &_dstNvVFXImage));
BAIL_IF_ERR(vfxErr = NvCVImage_Transfer(&_srcVFX, &_srcNvVFXImage, 1.0f, _stream, NULL));
// Assign states from stateArray in batchOfStates
// There is only one stream in this app
_batchOfStates[0] = _stateArray[0];
BAIL_IF_ERR(vfxErr = NvVFX_SetStateObjectHandleArray(_eff, NVVFX_STATE, _batchOfStates));
auto startTime = std::chrono::high_resolution_clock::now();
BAIL_IF_ERR(vfxErr = NvVFX_Run(_eff, 0));
auto endTime = std::chrono::high_resolution_clock::now();
Binary file not shown.
+25 -13
View File
@@ -15,17 +15,29 @@ target_include_directories(AigsEffectApp PUBLIC
${SDK_INCLUDES_PATH}
)
target_link_libraries(AigsEffectApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
if(MSVC)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(PATH_STR "PATH=%PATH%" ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--show --in_file=\"${CMAKE_CURRENT_SOURCE_DIR}/../input/input_003054.jpg\" ")
set_target_properties(AigsEffectApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
target_link_libraries(AigsEffectApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(PATH_STR "PATH=%PATH%" ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--show --in_file=\"${CMAKE_CURRENT_SOURCE_DIR}/../input/input_003054.jpg\" ")
set_target_properties(AigsEffectApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
else()
target_link_libraries(AigsEffectApp PUBLIC
NVVideoEffects
NVCVImage
OpenCV
TensorRT
CUDA
)
endif()
@@ -0,0 +1,370 @@
/*###############################################################################
#
# Copyright (c) 2022 NVIDIA Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
###############################################################################*/
#include <string>
#include <vector>
#include <cuda_runtime_api.h>
#include "BatchUtilities.h"
#include "nvCVOpenCV.h"
#include "nvVideoEffects.h"
#include "opencv2/opencv.hpp"
#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif // _MSC_VER
#define BAIL_IF_ERR(err) do { if (0 != (err)) { goto bail; } } while(0)
#define BAIL_IF_NULL(x, err, code) do { if ((void*)(x) == NULL) { err = code; goto bail; } } while(0)
#define BAIL_IF_FALSE(x, err, code) do { if (!(x)) { err = code; goto bail; } } while(0)
#define BAIL(err, code) do { err = code; goto bail; } while(0)
#ifdef _WIN32
#define DEFAULT_CODEC "avc1"
#else // !_WIN32
#define DEFAULT_CODEC "H264"
#endif // _WIN32
bool FLAG_verbose = false;
int FLAG_mode = 0;
std::string FLAG_outFile,
FLAG_modelDir,
FLAG_codec = DEFAULT_CODEC;
std::vector<const char*> FLAG_inFiles;
// Set this when using OTA Updates
// This path is used by nvVideoEffectsProxy.cpp to load the SDK dll
// when using OTA Updates
char *g_nvVFXSDKPath = NULL;
static bool GetFlagArgVal(const char *flag, const char *arg, const char **val) {
if (*arg != '-')
return false;
while (*++arg == '-')
continue;
const char *s = strchr(arg, '=');
if (s == NULL) {
if (strcmp(flag, arg) != 0)
return false;
*val = NULL;
return true;
}
size_t n = s - arg;
if ((strlen(flag) != n) || (strncmp(flag, arg, n) != 0))
return false;
*val = s + 1;
return true;
}
static bool GetFlagArgVal(const char *flag, const char *arg, std::string *val) {
const char *valStr;
if (!GetFlagArgVal(flag, arg, &valStr))
return false;
val->assign(valStr ? valStr : "");
return true;
}
static bool GetFlagArgVal(const char *flag, const char *arg, bool *val) {
const char *valStr;
bool success = GetFlagArgVal(flag, arg, &valStr);
if (success) {
*val = (valStr == NULL ||
strcasecmp(valStr, "true") == 0 ||
strcasecmp(valStr, "on") == 0 ||
strcasecmp(valStr, "yes") == 0 ||
strcasecmp(valStr, "1") == 0
);
}
return success;
}
static bool GetFlagArgVal(const char *flag, const char *arg, long *val) {
const char *valStr;
bool success = GetFlagArgVal(flag, arg, &valStr);
if (success)
*val = strtol(valStr, NULL, 10);
return success;
}
static bool GetFlagArgVal(const char *flag, const char *arg, int *val) {
long longVal;
bool success = GetFlagArgVal(flag, arg, &longVal);
if (success)
*val = (int)longVal;
return success;
}
static int StringToFourcc(const std::string &str) {
union chint {
int i;
char c[4];
};
chint x = {0};
for (int n = (str.size() < 4) ? (int)str.size() : 4; n--;) x.c[n] = str[n];
return x.i;
}
static void Usage() {
printf(
"BatchAigsEffectApp [flags ...] inFile1 [ inFileN ...]\n"
" where flags is:\n"
" --out_file=<path> output video files to be written (a pattern with one %%u or %%d), default \"BatchOut_%%02u.mp4\"\n"
" --model_dir=<path> the path to the directory that contains the models\n"
" --mode=<value> which model to pick for processing (default: 0)\n"
" --verbose verbose output\n"
" --codec=<fourcc> the fourcc code for the desired codec (default " DEFAULT_CODEC ")\n"
" and inFile1 ... are identically sized video files\n"
);
}
static int ParseMyArgs(int argc, char **argv) {
int errs = 0;
for (--argc, ++argv; argc--; ++argv) {
bool help;
const char *arg = *argv;
if (arg[0] == '-') {
if (arg[1] == '-') { // double-dash
if (GetFlagArgVal("verbose", arg, &FLAG_verbose) ||
GetFlagArgVal("mode", arg, &FLAG_mode) ||
GetFlagArgVal("model_dir", arg, &FLAG_modelDir) ||
GetFlagArgVal("out_file", arg, &FLAG_outFile) ||
GetFlagArgVal("codec", arg, &FLAG_codec)
) {
continue;
} else if (GetFlagArgVal("help", arg, &help)) { // --help
Usage();
errs = 1;
}
}
else { // single dash
for (++arg; *arg; ++arg) {
if (*arg == 'v') {
FLAG_verbose = true;
} else {
printf("Unknown flag ignored: \"-%c\"\n", *arg);
}
}
continue;
}
}
else { // no dash
FLAG_inFiles.push_back(arg);
}
}
return errs;
}
class App {
public:
NvVFX_Handle _eff;
NvCVImage _src, _stg, _dst;
CUstream _stream;
unsigned _batchSize;
App() : _eff(nullptr), _stream(0), _batchSize(0) {}
~App() {
NvVFX_DestroyEffect(_eff); if (_stream) NvVFX_CudaStreamDestroy(_stream);
}
NvCV_Status init(const char* effectName, unsigned batchSize, unsigned int mode, const NvCVImage *srcImg) {
NvCV_Status err = NVCV_ERR_UNIMPLEMENTED;
_batchSize = batchSize;
BAIL_IF_ERR(err = NvVFX_CreateEffect(effectName, &_eff));
BAIL_IF_ERR(err = AllocateBatchBuffer(&_src, _batchSize, srcImg->width, srcImg->height, NVCV_BGR, NVCV_U8, NVCV_CHUNKY, NVCV_GPU, 1));
BAIL_IF_ERR(err = AllocateBatchBuffer(&_dst, _batchSize, srcImg->width, srcImg->height, NVCV_A, NVCV_U8, NVCV_CHUNKY, NVCV_GPU, 1));
BAIL_IF_ERR(err = NvVFX_SetString(_eff, NVVFX_MODEL_DIRECTORY, FLAG_modelDir.c_str()));
{ // Set parameters.
NvCVImage nth;
BAIL_IF_ERR(err = NvVFX_SetImage(_eff, NVVFX_INPUT_IMAGE, NthImage(0, srcImg->height, &_src, &nth))); // Set the first of the batched images in ...
BAIL_IF_ERR(err = NvVFX_SetImage(_eff, NVVFX_OUTPUT_IMAGE, NthImage(0, _dst.height / _batchSize, &_dst, &nth))); // ... and out
BAIL_IF_ERR(err = NvVFX_CudaStreamCreate(&_stream));
BAIL_IF_ERR(err = NvVFX_SetCudaStream(_eff, NVVFX_CUDA_STREAM, _stream));
BAIL_IF_ERR(err = NvVFX_SetU32(_eff, NVVFX_MODE, mode));
}
bail:
return err;
}
};
NvCV_Status BatchProcess(const char* effectName, unsigned int mode,
const std::vector<const char*>& srcVideos, const char *outfilePattern, std::string codec) {
NvCV_Status err = NVCV_SUCCESS;
App app;
cv::Mat ocv1, ocv2;
NvCVImage nvx1, nvx2;
unsigned srcWidth, srcHeight, dstHeight;
std::vector<NvVFX_StateObjectHandle> arrayOfStates;
NvVFX_StateObjectHandle* batchOfStates = nullptr;
unsigned int numOfVideoStreams = static_cast<unsigned int>(srcVideos.size());
// If valid states are passed for inference, then -
// 1. Effect can only process a batch which is equal to maximum number of video streams
// 2. Multiple frames from the same video stream should not be present in the same batch
unsigned batchSize = numOfVideoStreams;
std::vector<cv::VideoCapture> srcCaptures(numOfVideoStreams);
std::vector<cv::VideoWriter> dstWriters(numOfVideoStreams);
for (unsigned int i = 0; i < numOfVideoStreams; i++) {
srcCaptures[i].open(srcVideos[i]);
if (srcCaptures[i].isOpened()==false) BAIL(err, NVCV_ERR_READ);
int width, height;
double fps;
width = (int)srcCaptures[i].get(cv::CAP_PROP_FRAME_WIDTH);
height = (int)srcCaptures[i].get(cv::CAP_PROP_FRAME_HEIGHT);
fps = srcCaptures[i].get(cv::CAP_PROP_FPS);
const int fourcc = StringToFourcc(codec);
char fileName[1024];
snprintf(fileName, sizeof(fileName), outfilePattern, i);
dstWriters[i].open(fileName, fourcc, fps, cv::Size2i(width,height), false);
if (dstWriters[i].isOpened() == false) BAIL(err, NVCV_ERR_WRITE);
}
// Read in the first image, to determine the resolution for init()
BAIL_IF_FALSE(srcVideos.size() > 0, err, NVCV_ERR_MISSINGINPUT);
srcCaptures[0] >> ocv1;
srcCaptures[0].set(cv::CAP_PROP_POS_FRAMES, 0); //resetting to first frame
if (!ocv1.data) {
printf("Cannot read video file \"%s\"\n", srcVideos[0]);
BAIL(err, NVCV_ERR_READ);
}
NVWrapperForCVMat(&ocv1, &nvx1);
srcWidth = nvx1.width;
srcHeight = nvx1.height;
BAIL_IF_ERR(err = app.init(effectName, batchSize, mode, &nvx1)); // Init effect and buffers
BAIL_IF_ERR(err = NvVFX_SetU32(app._eff, NVVFX_MAX_NUMBER_STREAMS, numOfVideoStreams));
BAIL_IF_ERR(err = NvVFX_SetU32(app._eff, NVVFX_MODEL_BATCH, numOfVideoStreams>1?8:1));
BAIL_IF_ERR(err = NvVFX_Load(app._eff));
// Creating state objects, one per stream.
for (unsigned int i = 0; i < numOfVideoStreams; i++) {
NvVFX_StateObjectHandle state;
BAIL_IF_ERR(err = NvVFX_AllocateState(app._eff, &state));
arrayOfStates.push_back(state);
}
//Creating batch array to hold states
batchOfStates = (NvVFX_StateObjectHandle*)malloc(sizeof(NvVFX_StateObjectHandle) * batchSize);
if (batchOfStates == nullptr) {
err = NVCV_ERR_MEMORY;
goto bail;
}
dstHeight = app._dst.height / batchSize;
BAIL_IF_ERR(err = NvCVImage_Alloc(&nvx2, app._dst.width, dstHeight, NVCV_A, NVCV_U8, NVCV_CHUNKY, NVCV_CPU, 0));
CVWrapperForNvCVImage(&nvx2, &ocv2);
for(int j=0;;j++)
{
for (unsigned int i = 0; i < batchSize; i++) {
int capIdx = i%numOfVideoStreams; // interlacing frames from different video stream, but can in any order
srcCaptures[capIdx] >> ocv1;
if (ocv1.empty()) goto bail;
batchOfStates[i] = arrayOfStates[capIdx];
NVWrapperForCVMat(&ocv1, &nvx1);
if (!(nvx1.width == srcWidth && nvx1.height == srcHeight)) {
printf("Input video file \"%s\" %ux%u does not match %ux%u\n"
"Batching requires all video frames to be of the same size\n", srcVideos[i], nvx1.width, nvx1.height, srcWidth, srcHeight);
BAIL(err, NVCV_ERR_MISMATCH);
}
BAIL_IF_ERR(err = TransferToNthImage(i, &nvx1, &app._src, 1.f, app._stream, NULL));
ocv1.release();
}
// Run batch
BAIL_IF_ERR(err = NvVFX_SetU32(app._eff, NVVFX_BATCH_SIZE, (unsigned)batchSize)); // The batchSize can change every Run
BAIL_IF_ERR(err = NvVFX_SetStateObjectHandleArray(app._eff, NVVFX_STATE, batchOfStates)); // The batch of states can change every Run
BAIL_IF_ERR(err = NvVFX_Run(app._eff, 0));
for (unsigned int i = 0; i < batchSize; ++i) {
int writerIdx = i % numOfVideoStreams;
BAIL_IF_ERR(err = TransferFromNthImage(i, &app._dst, &nvx2, 1.0f, app._stream, NULL));
dstWriters[writerIdx] << ocv2;
}
// NvCVImage_Dealloc() is called in the destructors
}
bail:
// If DeallocateState fails, all memory allocated in the SDK returns to the heap when the effect handle is destroyed.
for (unsigned int i = 0; i < arrayOfStates.size(); i++) {
NvVFX_DeallocateState(app._eff, arrayOfStates[i]);
}
arrayOfStates.clear();
if (batchOfStates) {
free(batchOfStates);
batchOfStates = nullptr;
}
for (auto& cap : srcCaptures) {
if (cap.isOpened()) cap.release();
}
for (auto& writer : dstWriters) {
if (writer.isOpened()) writer.release();
}
return err;
}
int main(int argc, char** argv) {
int nErrs;
NvCV_Status vfxErr;
nErrs = ParseMyArgs(argc, argv);
if (nErrs)
return nErrs;
// If the outFile is missing a stream index
// insert one, assuming a period followed by a three-character extension
if (FLAG_outFile.empty())
FLAG_outFile = "BatchOut_%02u.mp4";
else if (std::string::npos == FLAG_outFile.find_first_of('%'))
FLAG_outFile.insert(FLAG_outFile.size() - 4, "_%02u");
#ifdef NVVFX_FX_GREEN_SCREEN
vfxErr = BatchProcess(NVVFX_FX_GREEN_SCREEN, FLAG_mode, FLAG_inFiles, FLAG_outFile.c_str(), FLAG_codec);
#elif defined(NVVFX_FX_GREEN_SCREEN_I)
vfxErr = BatchProcess(NVVFX_FX_GREEN_SCREEN_I, FLAG_mode, FLAG_inFiles, FLAG_outFile.c_str(), FLAG_codec);
#endif
if (NVCV_SUCCESS != vfxErr) {
Usage();
printf("Error: %s\n", NvCV_GetErrorStringFromCode(vfxErr));
nErrs = (int)vfxErr;
}
return nErrs;
}
Binary file not shown.
@@ -217,16 +217,16 @@ NvCV_Status BatchProcess(const char* effectName, const std::vector<const char*>&
App app;
cv::Mat ocv1, ocv2;
NvCVImage nvx1, nvx2;
unsigned srcWidth, srcHeight, dstHeight, i;
unsigned srcWidth, srcHeight, dstHeight;
void** arrayOfStates = nullptr;
void** batchOfStates = nullptr;
unsigned int stateSizeInBytes;
int numOfVideoStreams = srcVideos.size();
unsigned int numOfVideoStreams = static_cast<unsigned int>(srcVideos.size());
std::vector<cv::VideoCapture> srcCaptures(numOfVideoStreams);
std::vector<cv::VideoWriter> dstWriters(numOfVideoStreams);
for (int i = 0; i < numOfVideoStreams; i++) {
for (unsigned int i = 0; i < numOfVideoStreams; i++) {
srcCaptures[i].open(srcVideos[i]);
if (srcCaptures[i].isOpened()==false) BAIL(err, NVCV_ERR_READ);
@@ -260,7 +260,7 @@ NvCV_Status BatchProcess(const char* effectName, const std::vector<const char*>&
// Creating state objects, one per stream.
BAIL_IF_ERR(err = NvVFX_GetU32(app._eff, NVVFX_STATE_SIZE, &stateSizeInBytes));
arrayOfStates = (void**)calloc(numOfVideoStreams, sizeof(void*)); // allocating void* array of numOfVideoStreams elements
for (int i = 0; i < numOfVideoStreams; i++) {
for (unsigned int i = 0; i < numOfVideoStreams; i++) {
cudaMalloc(&arrayOfStates[i], stateSizeInBytes);
cudaMemsetAsync(arrayOfStates[i], 0, stateSizeInBytes,app._stream);
}
@@ -273,7 +273,7 @@ NvCV_Status BatchProcess(const char* effectName, const std::vector<const char*>&
CVWrapperForNvCVImage(&nvx2, &ocv2);
for(int j=0;;j++)
{
for (int i = 0; i < batchSize; i++) {
for (unsigned int i = 0; i < batchSize; i++) {
int capIdx = i%numOfVideoStreams; // interlacing frames from different video stream, but can in any order
srcCaptures[capIdx] >> ocv1;
if (ocv1.empty()) goto bail;
@@ -295,7 +295,7 @@ NvCV_Status BatchProcess(const char* effectName, const std::vector<const char*>&
BAIL_IF_ERR(err = NvVFX_Run(app._eff, 0));
for (i = 0; i < batchSize; ++i) {
for (unsigned int i = 0; i < batchSize; ++i) {
int writerIdx = i % numOfVideoStreams;
BAIL_IF_ERR(err = TransferFromNthImage(i, &app._dst, &nvx2, 255.f, app._stream, &app._stg));
dstWriters[writerIdx] << ocv2;
@@ -304,7 +304,7 @@ NvCV_Status BatchProcess(const char* effectName, const std::vector<const char*>&
}
bail:
if (arrayOfStates) {
for (unsigned i = 0; i < numOfVideoStreams; i++) {
for (unsigned int i = 0; i < numOfVideoStreams; i++) {
if (arrayOfStates[i]) cudaFree(arrayOfStates[i]);
}
free(arrayOfStates);
Binary file not shown.
+2 -8
View File
@@ -244,16 +244,9 @@ public:
else if (!strcmp(effectName, NVVFX_FX_SR_UPSCALE)) {
BAIL_IF_ERR(err = AllocateBatchBuffer(&_src, _batchSize, src->width, src->height, NVCV_RGBA, NVCV_U8, NVCV_CHUNKY, NVCV_CUDA, 32)); // n*32, n>=0
BAIL_IF_ERR(err = AllocateBatchBuffer(&_dst, _batchSize, dw, dh, NVCV_RGBA, NVCV_U8, NVCV_CHUNKY, NVCV_CUDA, 32));
BAIL_IF_ERR(err = NvVFX_SetF32(_eff, NVVFX_STRENGTH, FLAG_strength));
}
#endif // NVVFX_FX_SR_UPSCALE
#ifdef NVVFX_FX_GREEN_SCREEN
else if (!strcmp(effectName, NVVFX_FX_GREEN_SCREEN)) {
BAIL_IF_ERR(err = AllocateBatchBuffer(&_src, _batchSize, src->width, src->height, NVCV_BGR, NVCV_U8, NVCV_CHUNKY, NVCV_CUDA, 1));
BAIL_IF_ERR(err = AllocateBatchBuffer(&_dst, _batchSize, src->width, src->height, NVCV_Y, NVCV_U8, NVCV_CHUNKY, NVCV_CUDA, 1));
BAIL_IF_ERR(err = NvVFX_SetString(_eff, NVVFX_MODEL_DIRECTORY, FLAG_modelDir.c_str()));
BAIL_IF_ERR(err = NvVFX_SetU32(_eff, NVVFX_MODE, FLAG_mode));
}
#endif // NVVFX_FX_GREEN_SCREEN
#ifdef NVVFX_FX_ARTIFACT_REDUCTION
else if (!strcmp(effectName, NVVFX_FX_ARTIFACT_REDUCTION)) {
BAIL_IF_ERR(err = AllocateBatchBuffer(&_src, _batchSize, src->width, src->height, NVCV_BGR, NVCV_F32, NVCV_PLANAR, NVCV_CUDA, 1));
@@ -268,6 +261,7 @@ public:
BAIL_IF_ERR(err = AllocateBatchBuffer(&_dst, _batchSize, dw, dh, NVCV_BGR, NVCV_F32, NVCV_PLANAR, NVCV_CUDA, 1));
BAIL_IF_ERR(err = NvVFX_SetString(_eff, NVVFX_MODEL_DIRECTORY, FLAG_modelDir.c_str()));
BAIL_IF_ERR(err = NvVFX_SetU32(_eff, NVVFX_MODE, FLAG_mode));
BAIL_IF_ERR(err = NvVFX_SetF32(_eff, NVVFX_STRENGTH, FLAG_strength));
}
#endif // NVVFX_FX_SUPER_RES
else {
Binary file not shown.
+96 -28
View File
@@ -17,20 +17,32 @@ target_include_directories(BatchEffectApp PUBLIC
${SDK_INCLUDES_PATH}
)
target_link_libraries(BatchEffectApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
if(MSVC)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(PATH_STR "PATH=%PATH%" ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--show --in_file=\"${CMAKE_CURRENT_SOURCE_DIR}/../input/input_003054.jpg\" ")
set_target_properties(BatchEffectApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
target_link_libraries(BatchEffectApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(PATH_STR "PATH=%PATH%" ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--show --in_file=\"${CMAKE_CURRENT_SOURCE_DIR}/../input/input_003054.jpg\" ")
set_target_properties(BatchEffectApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
else()
target_link_libraries(BatchEffectApp PUBLIC
NVVideoEffects
NVCVImage
OpenCV
TensorRT
CUDA
)
endif()
#Batch denoise effect
set(SOURCE_FILES
@@ -51,19 +63,75 @@ target_include_directories(BatchDenoiseEffectApp PUBLIC
${SDK_INCLUDES_PATH}
)
target_link_libraries(BatchDenoiseEffectApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
target_include_directories(BatchDenoiseEffectApp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/include)
if(MSVC)
target_link_libraries(BatchDenoiseEffectApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
target_include_directories(BatchDenoiseEffectApp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/include)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(PATH_STR "PATH=%PATH%" ${OPENCV_PATH_STR})
set(CMD_ARG_STR "video1.mp4 video2.mp4 ")
set_target_properties(BatchDenoiseEffectApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(PATH_STR "PATH=%PATH%" ${OPENCV_PATH_STR})
set(CMD_ARG_STR "video1.mp4 video2.mp4 ")
set_target_properties(BatchDenoiseEffectApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
else()
target_link_libraries(BatchDenoiseEffectApp PUBLIC
NVVideoEffects
NVCVImage
OpenCV
TensorRT
CUDA
)
endif()
#Batch aigs effect
set(SOURCE_FILES
BatchAigsEffectApp.cpp
BatchUtilities.cpp
../../nvvfx/src/nvVideoEffectsProxy.cpp
../../nvvfx/src/nvCVImageProxy.cpp)
# Set Visual Studio source filters
source_group("Source Files" FILES ${SOURCE_FILES})
add_executable(BatchAigsEffectApp ${SOURCE_FILES})
target_include_directories(BatchAigsEffectApp PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../utils
)
target_include_directories(BatchAigsEffectApp PUBLIC
${SDK_INCLUDES_PATH}
)
if(MSVC)
target_link_libraries(BatchAigsEffectApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
target_include_directories(BatchAigsEffectApp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/include)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(PATH_STR "PATH=%PATH%" ${OPENCV_PATH_STR})
set(CMD_ARG_STR "video1.mp4 video2.mp4 ")
set_target_properties(BatchAigsEffectApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
else()
target_link_libraries(BatchAigsEffectApp PUBLIC
NVVideoEffects
NVCVImage
OpenCV
TensorRT
CUDA
)
endif()
+4 -2
View File
@@ -1,7 +1,9 @@
SETLOCAL
SET PATH=%PATH%;..\external\opencv\bin;
SET IMAGE_LIST=..\input\LeFret_000900.jpg ..\input\LeFret_001400.jpg ..\input\LeFret_003400.jpg ..\input\LeFret_012300.jpg
BatchEffectApp.exe --effect=GreenScreen --out_file=GreenScreen_%%04u.png %IMAGE_LIST%
BatchEffectApp.exe --effect=ArtifactReduction --out_file=ArtifactReduction_%%04u.png %IMAGE_LIST%
BatchEffectApp.exe --effect=SuperRes --out_file=SuperRes_%%04u.png --scale=1.5 %IMAGE_LIST%
BatchEffectApp.exe --effect=Upscale --out_file=Upscale_%%04u.png --scale=1.5 %IMAGE_LIST%
BatchEffectApp.exe --effect=Upscale --out_file=Upscale_%%04u.png --scale=1.5 %IMAGE_LIST%
SET VIDEO_LIST=..\input\input_0_100_frames.mp4 ..\input\input_100_200_frames.mp4
BatchAigsEffectApp.exe --out_file=GreenScreen_%04u.mp4 %VIDEO_LIST%
+25 -16
View File
@@ -7,20 +7,29 @@ add_executable(DenoiseEffectApp ${SOURCE_FILES})
target_include_directories(DenoiseEffectApp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../utils)
target_include_directories(DenoiseEffectApp PUBLIC ${SDK_INCLUDES_PATH})
if(MSVC)
target_link_libraries(DenoiseEffectApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
target_include_directories(DenoiseEffectApp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/include)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(VFXSDK_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) # Also the location for CUDA/NVTRT/libcrypto
set(PATH_STR "PATH=%PATH%" ${VFXSDK_PATH_STR} ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--model_dir=\"${CMAKE_CURRENT_SOURCE_DIR}/../../bin/models\" --show --webcam")
set_target_properties(DenoiseEffectApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
else()
target_link_libraries(DenoiseEffectApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
target_include_directories(DenoiseEffectApp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/include)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(VFXSDK_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) # Also the location for CUDA/NVTRT/libcrypto
set(PATH_STR "PATH=%PATH%" ${VFXSDK_PATH_STR} ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--show --webcam")
set_target_properties(DenoiseEffectApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
target_link_libraries(DenoiseEffectApp PUBLIC
NVVideoEffects
NVCVImage
OpenCV
TensorRT
CUDA
)
endif()
Binary file not shown.
+24 -14
View File
@@ -12,19 +12,29 @@ target_include_directories(UpscalePipelineApp PUBLIC
${SDK_INCLUDES_PATH}
)
target_link_libraries(UpscalePipelineApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
if(MSVC)
target_link_libraries(UpscalePipelineApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(VFXSDK_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) # Also the location for CUDA/NVTRT/libcrypto
set(PATH_STR "PATH=%PATH%" ${VFXSDK_PATH_STR} ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--show --resolution=1440 --in_file=\"${CMAKE_CURRENT_SOURCE_DIR}/../input/input1.jpg\"")
set_target_properties(UpscalePipelineApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(VFXSDK_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) # Also the location for CUDA/NVTRT/libcrypto
set(PATH_STR "PATH=%PATH%" ${VFXSDK_PATH_STR} ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--model_dir=\"${CMAKE_CURRENT_SOURCE_DIR}/../../bin/models\" --show --resolution=1440 --in_file=\"${CMAKE_CURRENT_SOURCE_DIR}/../input/input1.jpg\"")
set_target_properties(UpscalePipelineApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
else()
target_link_libraries(UpscalePipelineApp PUBLIC
NVVideoEffects
NVCVImage
OpenCV
TensorRT
CUDA
)
endif()
Binary file not shown.
+24 -14
View File
@@ -7,19 +7,29 @@ add_executable(VideoEffectsApp ${SOURCE_FILES})
target_include_directories(VideoEffectsApp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../utils)
target_include_directories(VideoEffectsApp PUBLIC ${SDK_INCLUDES_PATH})
target_link_libraries(VideoEffectsApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
if(MSVC)
target_link_libraries(VideoEffectsApp PUBLIC
opencv346
NVVideoEffects
${CMAKE_CURRENT_SOURCE_DIR}/../external/cuda/lib/x64/cudart.lib
)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(VFXSDK_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) # Also the location for CUDA/NVTRT/libcrypto
set(PATH_STR "PATH=%PATH%" ${VFXSDK_PATH_STR} ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--show --effect=SuperRes --resolution=1080 --in_file=\"${CMAKE_CURRENT_SOURCE_DIR}/../input/input1.jpg\"")
set_target_properties(VideoEffectsApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
set(OPENCV_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../external/opencv/bin)
set(VFXSDK_PATH_STR ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) # Also the location for CUDA/NVTRT/libcrypto
set(PATH_STR "PATH=%PATH%" ${VFXSDK_PATH_STR} ${OPENCV_PATH_STR})
set(CMD_ARG_STR "--model_dir=\"${CMAKE_CURRENT_SOURCE_DIR}/../../bin/models\" --show --effect=SuperRes --resolution=1080 --in_file=\"${CMAKE_CURRENT_SOURCE_DIR}/../input/input1.jpg\"")
set_target_properties(VideoEffectsApp PROPERTIES
FOLDER SampleApps
VS_DEBUGGER_ENVIRONMENT "${PATH_STR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "${CMD_ARG_STR}"
)
else()
target_link_libraries(VideoEffectsApp PUBLIC
NVVideoEffects
NVCVImage
OpenCV
TensorRT
CUDA
)
endif()
+2 -1
View File
@@ -57,7 +57,7 @@ bool FLAG_debug = false,
FLAG_progress = false,
FLAG_webcam = false;
float FLAG_strength = 0.f;
int FLAG_mode = 0;
int FLAG_mode = 0;
int FLAG_resolution = 0;
std::string FLAG_codec = DEFAULT_CODEC,
FLAG_camRes = "1280x720",
@@ -519,6 +519,7 @@ NvCV_Status FXApp::allocBuffers(unsigned width, unsigned height) {
printf("--resolution has not been specified\n");
return NVCV_ERR_PARAMETER;
}
BAIL_IF_ERR(vfxErr = NvVFX_SetF32(_eff, NVVFX_STRENGTH, FLAG_strength));
int dstWidth = _srcImg.cols * FLAG_resolution / _srcImg.rows;
_dstImg.create(FLAG_resolution, dstWidth, _srcImg.type()); // dst CPU
BAIL_IF_NULL(_dstImg.data, vfxErr, NVCV_ERR_MEMORY);
Binary file not shown.
+181 -1
View File
@@ -86,7 +86,27 @@
* \endcode
*
* where ::cudaChannelFormatKind is one of ::cudaChannelFormatKindSigned,
* ::cudaChannelFormatKindUnsigned, cudaChannelFormatKindFloat or ::cudaChannelFormatKindNV12.
* ::cudaChannelFormatKindUnsigned, cudaChannelFormatKindFloat,
* ::cudaChannelFormatKindSignedNormalized8X1, ::cudaChannelFormatKindSignedNormalized8X2,
* ::cudaChannelFormatKindSignedNormalized8X4,
* ::cudaChannelFormatKindUnsignedNormalized8X1, ::cudaChannelFormatKindUnsignedNormalized8X2,
* ::cudaChannelFormatKindUnsignedNormalized8X4,
* ::cudaChannelFormatKindSignedNormalized16X1, ::cudaChannelFormatKindSignedNormalized16X2,
* ::cudaChannelFormatKindSignedNormalized16X4,
* ::cudaChannelFormatKindUnsignedNormalized16X1, ::cudaChannelFormatKindUnsignedNormalized16X2,
* ::cudaChannelFormatKindUnsignedNormalized16X4
* or ::cudaChannelFormatKindNV12.
*
* The format is specified by the template specialization.
*
* The template function specializes for the following scalar types:
* char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, and float.
* The template function specializes for the following vector types:
* char{1|2|4}, uchar{1|2|4}, short{1|2|4}, ushort{1|2|4}, int{1|2|4}, uint{1|2|4}, long{1|2|4}, ulong{1|2|4}, float{1|2|4}.
* The template function specializes for following cudaChannelFormatKind enum values:
* ::cudaChannelFormatKind{Uns|S}ignedNormalized{8|16}X{1|2|4}, and ::cudaChannelFormatKindNV12.
*
* Invoking the function on a type without a specialization defaults to creating a channel format of kind ::cudaChannelFormatKindNone
*
* \return
* Channel descriptor with format \p f
@@ -407,6 +427,166 @@ static __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDescNV12(void)
return cudaCreateChannelDesc(e, e, e, 0, cudaChannelFormatKindNV12);
}
template<cudaChannelFormatKind> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc(void)
{
return cudaCreateChannelDesc(0, 0, 0, 0, cudaChannelFormatKindNone);
}
/* Signed 8-bit normalized integer formats */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized8X1>(void)
{
return cudaCreateChannelDesc(8, 0, 0, 0, cudaChannelFormatKindSignedNormalized8X1);
}
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized8X2>(void)
{
return cudaCreateChannelDesc(8, 8, 0, 0, cudaChannelFormatKindSignedNormalized8X2);
}
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized8X4>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindSignedNormalized8X4);
}
/* Unsigned 8-bit normalized integer formats */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized8X1>(void)
{
return cudaCreateChannelDesc(8, 0, 0, 0, cudaChannelFormatKindUnsignedNormalized8X1);
}
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized8X2>(void)
{
return cudaCreateChannelDesc(8, 8, 0, 0, cudaChannelFormatKindUnsignedNormalized8X2);
}
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized8X4>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedNormalized8X4);
}
/* Signed 16-bit normalized integer formats */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized16X1>(void)
{
return cudaCreateChannelDesc(16, 0, 0, 0, cudaChannelFormatKindSignedNormalized16X1);
}
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized16X2>(void)
{
return cudaCreateChannelDesc(16, 16, 0, 0, cudaChannelFormatKindSignedNormalized16X2);
}
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized16X4>(void)
{
return cudaCreateChannelDesc(16, 16, 16, 16, cudaChannelFormatKindSignedNormalized16X4);
}
/* Unsigned 16-bit normalized integer formats */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized16X1>(void)
{
return cudaCreateChannelDesc(16, 0, 0, 0, cudaChannelFormatKindUnsignedNormalized16X1);
}
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized16X2>(void)
{
return cudaCreateChannelDesc(16, 16, 0, 0, cudaChannelFormatKindUnsignedNormalized16X2);
}
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized16X4>(void)
{
return cudaCreateChannelDesc(16, 16, 16, 16, cudaChannelFormatKindUnsignedNormalized16X4);
}
/* NV12 format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindNV12>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 0, cudaChannelFormatKindNV12);
}
/* BC1 format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed1>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed1);
}
/* BC1sRGB format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed1SRGB>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed1SRGB);
}
/* BC2 format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed2>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed2);
}
/* BC2sRGB format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed2SRGB>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed2SRGB);
}
/* BC3 format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed3>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed3);
}
/* BC3sRGB format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed3SRGB>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed3SRGB);
}
/* BC4 unsigned format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed4>(void)
{
return cudaCreateChannelDesc(8, 0, 0, 0, cudaChannelFormatKindUnsignedBlockCompressed4);
}
/* BC4 signed format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedBlockCompressed4>(void)
{
return cudaCreateChannelDesc(8, 0, 0, 0, cudaChannelFormatKindSignedBlockCompressed4);
}
/* BC5 unsigned format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed5>(void)
{
return cudaCreateChannelDesc(8, 8, 0, 0, cudaChannelFormatKindUnsignedBlockCompressed5);
}
/* BC5 signed format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedBlockCompressed5>(void)
{
return cudaCreateChannelDesc(8, 8, 0, 0, cudaChannelFormatKindSignedBlockCompressed5);
}
/* BC6H unsigned format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed6H>(void)
{
return cudaCreateChannelDesc(16, 16, 16, 0, cudaChannelFormatKindUnsignedBlockCompressed6H);
}
/* BC6H signed format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedBlockCompressed6H>(void)
{
return cudaCreateChannelDesc(16, 16, 16, 0, cudaChannelFormatKindSignedBlockCompressed6H);
}
/* BC7 format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed7>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed7);
}
/* BC7sRGB format */
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed7SRGB>(void)
{
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed7SRGB);
}
#endif /* __cplusplus */
/** @} */
+13 -20
View File
@@ -1,5 +1,5 @@
/*
* Copyright 1993-2020 NVIDIA Corporation. All rights reserved.
* Copyright 1993-2022 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO LICENSEE:
*
@@ -105,21 +105,14 @@
#if defined(__ICC)
#if (__ICC != 1500 && __ICC != 1600 && __ICC != 1700 && __ICC != 1800 && !(__ICC >= 1900 && __ICC <= 1999)) || !defined(__GNUC__) || !defined(__LP64__)
#if (__ICC != 1500 && __ICC != 1600 && __ICC != 1700 && __ICC != 1800 && !(__ICC >= 1900 && __ICC <= 2021)) || !defined(__GNUC__) || !defined(__LP64__)
#error -- unsupported ICC configuration! Only ICC 15.0, ICC 16.0, ICC 17.0, ICC 18.0 and ICC 19.x on Linux x86_64 are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
#error -- unsupported ICC configuration! Only ICC 15.0, ICC 16.0, ICC 17.0, ICC 18.0, ICC 19.x and 20.x on Linux x86_64 are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
#endif /* (__ICC != 1500 && __ICC != 1600 && __ICC != 1700 && __ICC != 1800 && __ICC != 1900) || !__GNUC__ || !__LP64__ */
#endif /* __ICC */
#if defined(__PGIC__)
#if ((__PGIC__ != 18) && (__PGIC__ != 19) && (__PGIC__ != 20) && (__PGIC__ != 21) && !(__PGIC__ == 99 && __PGIC_MINOR__ == 99))
#error -- unsupported pgc++ configuration! Only pgc++ 18, 19, 20 and 21 are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
#endif
#endif /* __PGIC__ */
#if defined(__powerpc__)
#if defined(__ibmxl_vrm__) && !(__ibmxl_vrm__ >= 0x0d010000 && __ibmxl_vrm__ < 0x0d020000) && \
@@ -134,19 +127,19 @@
#if defined(__GNUC__)
#if __GNUC__ > 10
#if __GNUC__ > 11
#error -- unsupported GNU version! gcc versions later than 10 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
#error -- unsupported GNU version! gcc versions later than 11 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
#endif /* __GNUC__ > 10 */
#endif /* __GNUC__ > 11 */
#if defined(__clang__) && !defined(__ibmxl_vrm__) && !defined(__ICC) && !defined(__HORIZON__) && !defined(__APPLE__)
#if (__clang_major__ >= 12) || (__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 3))
#error -- unsupported clang version! clang version must be less than 12 and greater than 3.2 . The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
#if (__clang_major__ >= 14) || (__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 3))
#error -- unsupported clang version! clang version must be less than 14 and greater than 3.2 . The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
#endif /* (__clang_major__ >= 12) || (__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 3)) */
#endif /* (__clang_major__ >= 14) || (__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 3)) */
#endif /* defined(__clang__) && !defined(__ibmxl_vrm__) && !defined(__ICC) && !defined(__HORIZON__) && !defined(__APPLE__) */
@@ -155,15 +148,15 @@
#if defined(_WIN32)
#if _MSC_VER < 1910 || _MSC_VER >= 1930
#if _MSC_VER < 1910 || _MSC_VER >= 1940
#error -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2019 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
#error -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
#elif _MSC_VER >= 1910 && _MSC_VER < 1910
#pragma message("support for this version of Microsoft Visual Studio has been deprecated! Only the versions between 2017 and 2019 (inclusive) are supported!")
#pragma message("support for this version of Microsoft Visual Studio has been deprecated! Only the versions between 2017 and 2022 (inclusive) are supported!")
#endif /* (_MSC_VER < 1910 || _MSC_VER >= 1930) || (_MSC_VER >= 1910 && _MSC_VER < 1910) */
#endif /* (_MSC_VER < 1910 || _MSC_VER >= 1940) || (_MSC_VER >= 1910 && _MSC_VER < 1910) */
#endif /* _WIN32 */
#endif /* !__NV_NO_HOST_COMPILER_CHECK */
+21 -1
View File
@@ -106,6 +106,22 @@ inline __device__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultipro
#endif /* !defined(__CUDACC_RTC__) */
#if defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
# define __DEPRECATED__(msg)
#elif defined(_WIN32)
# define __DEPRECATED__(msg) __declspec(deprecated(msg))
#elif (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5 && !defined(__clang__))))
# define __DEPRECATED__(msg) __attribute__((deprecated))
#else
# define __DEPRECATED__(msg) __attribute__((deprecated(msg)))
#endif
#if defined(__CUDA_ARCH__) && !defined(__CDPRT_SUPPRESS_SYNC_DEPRECATION_WARNING)
# define __CDPRT_DEPRECATED(func_name) __DEPRECATED__("Use of "#func_name" from device code is deprecated and will not be supported in a future release. Disable this warning with -D__CDPRT_SUPPRESS_SYNC_DEPRECATION_WARNING.")
#else
# define __CDPRT_DEPRECATED(func_name)
#endif
#if defined(__cplusplus) && defined(__CUDACC__) /* Visible to nvcc front-end only */
#if !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350) // Visible to SM>=3.5 and "__host__ __device__" only
@@ -118,7 +134,8 @@ extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetAttribut
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetLimit(size_t *pValue, enum cudaLimit limit);
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetCacheConfig(enum cudaFuncCache *pCacheConfig);
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetSharedMemConfig(enum cudaSharedMemConfig *pConfig);
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceSynchronize(void);
extern __device__ __cudart_builtin__ __CDPRT_DEPRECATED(cudaDeviceSynchronize) cudaError_t CUDARTAPI cudaDeviceSynchronize(void);
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaDeviceSynchronizeDeprecationAvoidance(void);
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetLastError(void);
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaPeekAtLastError(void);
extern __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorString(cudaError_t error);
@@ -242,4 +259,7 @@ template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_
#endif // !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350)
#endif /* defined(__cplusplus) && defined(__CUDACC__) */
#undef __DEPRECATED__
#undef __CDPRT_DEPRECATED
#endif /* !__CUDA_DEVICE_RUNTIME_API_H__ */
File diff suppressed because it is too large. Load diff
+2
View File
@@ -55,7 +55,9 @@
#define __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_TYPES_H__
#endif
#ifndef __DOXYGEN_ONLY__
#include "crt/host_defines.h"
#endif
/*******************************************************************************
* *
+254 -22
View File
@@ -55,9 +55,13 @@
#define __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DRIVER_TYPES_H__
#endif
#ifndef __DOXYGEN_ONLY__
#include "crt/host_defines.h"
#endif
#include "vector_types.h"
/**
* \defgroup CUDART_TYPES Data types used by CUDA Runtime
* \ingroup CUDART
@@ -145,6 +149,9 @@
#define cudaArrayColorAttachment 0x20 /**< Must be set in cudaExternalMemoryGetMappedMipmappedArray if the mipmapped array is used as a color target in a graphics API */
#define cudaArraySparse 0x40 /**< Must be set in cudaMallocArray, cudaMalloc3DArray or cudaMallocMipmappedArray in order to create a sparse CUDA array or CUDA mipmapped array */
#define cudaArrayDeferredMapping 0x80 /**< Must be set in cudaMallocArray, cudaMalloc3DArray or cudaMallocMipmappedArray in order to create a deferred mapping CUDA array or CUDA mipmapped array */
#define cudaIpcMemLazyEnablePeerAccess 0x01 /**< Automatically enable peer access between remote devices as needed */
#define cudaMemAttachGlobal 0x01 /**< Memory can be accessed by any stream on any device*/
@@ -540,7 +547,8 @@ enum __device_builtin__ cudaError
/**
* This indicates that the device ordinal supplied by the user does not
* correspond to a valid CUDA device.
* correspond to a valid CUDA device or that the action requested is
* invalid for the specified device.
*/
cudaErrorInvalidDevice = 101,
@@ -691,6 +699,11 @@ enum __device_builtin__ cudaError
*/
cudaErrorJitCompilationDisabled = 223,
/**
* This indicates that the provided execution affinity is not supported by the device.
*/
cudaErrorUnsupportedExecAffinity = 224,
/**
* This indicates that the device kernel source is invalid.
*/
@@ -939,6 +952,32 @@ enum __device_builtin__ cudaError
*/
cudaErrorCompatNotSupportedOnDevice = 804,
/**
* This error indicates that the MPS client failed to connect to the MPS control daemon or the MPS server.
*/
cudaErrorMpsConnectionFailed = 805,
/**
* This error indicates that the remote procedural call between the MPS server and the MPS client failed.
*/
cudaErrorMpsRpcFailure = 806,
/**
* This error indicates that the MPS server is not ready to accept new MPS client requests.
* This error can be returned when the MPS server is in the process of recovering from a fatal failure.
*/
cudaErrorMpsServerNotReady = 807,
/**
* This error indicates that the hardware resources required to create MPS client have been exhausted.
*/
cudaErrorMpsMaxClientsReached = 808,
/**
* This error indicates the the hardware resources required to device connections have been exhausted.
*/
cudaErrorMpsMaxConnectionsReached = 809,
/**
* The operation is not permitted when the stream is capturing.
*/
@@ -1004,6 +1043,24 @@ enum __device_builtin__ cudaError
*/
cudaErrorGraphExecUpdateFailure = 910,
/**
* This indicates that an async error has occurred in a device outside of CUDA.
* If CUDA was waiting for an external device's signal before consuming shared data,
* the external device signaled an error indicating that the data is not valid for
* consumption. This leaves the process in an inconsistent state and any further CUDA
* work will return the same error. To continue using CUDA, the process must be
* terminated and relaunched.
*/
cudaErrorExternalDevice = 911,
/**
* This indicates that an unknown internal error has occurred.
*/
@@ -1023,11 +1080,37 @@ enum __device_builtin__ cudaError
*/
enum __device_builtin__ cudaChannelFormatKind
{
cudaChannelFormatKindSigned = 0, /**< Signed channel format */
cudaChannelFormatKindUnsigned = 1, /**< Unsigned channel format */
cudaChannelFormatKindFloat = 2, /**< Float channel format */
cudaChannelFormatKindNone = 3, /**< No channel format */
cudaChannelFormatKindNV12 = 4 /**< Unsigned 8-bit integers, planar 4:2:0 YUV format */
cudaChannelFormatKindSigned = 0, /**< Signed channel format */
cudaChannelFormatKindUnsigned = 1, /**< Unsigned channel format */
cudaChannelFormatKindFloat = 2, /**< Float channel format */
cudaChannelFormatKindNone = 3, /**< No channel format */
cudaChannelFormatKindNV12 = 4, /**< Unsigned 8-bit integers, planar 4:2:0 YUV format */
cudaChannelFormatKindUnsignedNormalized8X1 = 5, /**< 1 channel unsigned 8-bit normalized integer */
cudaChannelFormatKindUnsignedNormalized8X2 = 6, /**< 2 channel unsigned 8-bit normalized integer */
cudaChannelFormatKindUnsignedNormalized8X4 = 7, /**< 4 channel unsigned 8-bit normalized integer */
cudaChannelFormatKindUnsignedNormalized16X1 = 8, /**< 1 channel unsigned 16-bit normalized integer */
cudaChannelFormatKindUnsignedNormalized16X2 = 9, /**< 2 channel unsigned 16-bit normalized integer */
cudaChannelFormatKindUnsignedNormalized16X4 = 10, /**< 4 channel unsigned 16-bit normalized integer */
cudaChannelFormatKindSignedNormalized8X1 = 11, /**< 1 channel signed 8-bit normalized integer */
cudaChannelFormatKindSignedNormalized8X2 = 12, /**< 2 channel signed 8-bit normalized integer */
cudaChannelFormatKindSignedNormalized8X4 = 13, /**< 4 channel signed 8-bit normalized integer */
cudaChannelFormatKindSignedNormalized16X1 = 14, /**< 1 channel signed 16-bit normalized integer */
cudaChannelFormatKindSignedNormalized16X2 = 15, /**< 2 channel signed 16-bit normalized integer */
cudaChannelFormatKindSignedNormalized16X4 = 16, /**< 4 channel signed 16-bit normalized integer */
cudaChannelFormatKindUnsignedBlockCompressed1 = 17, /**< 4 channel unsigned normalized block-compressed (BC1 compression) format */
cudaChannelFormatKindUnsignedBlockCompressed1SRGB = 18, /**< 4 channel unsigned normalized block-compressed (BC1 compression) format with sRGB encoding*/
cudaChannelFormatKindUnsignedBlockCompressed2 = 19, /**< 4 channel unsigned normalized block-compressed (BC2 compression) format */
cudaChannelFormatKindUnsignedBlockCompressed2SRGB = 20, /**< 4 channel unsigned normalized block-compressed (BC2 compression) format with sRGB encoding */
cudaChannelFormatKindUnsignedBlockCompressed3 = 21, /**< 4 channel unsigned normalized block-compressed (BC3 compression) format */
cudaChannelFormatKindUnsignedBlockCompressed3SRGB = 22, /**< 4 channel unsigned normalized block-compressed (BC3 compression) format with sRGB encoding */
cudaChannelFormatKindUnsignedBlockCompressed4 = 23, /**< 1 channel unsigned normalized block-compressed (BC4 compression) format */
cudaChannelFormatKindSignedBlockCompressed4 = 24, /**< 1 channel signed normalized block-compressed (BC4 compression) format */
cudaChannelFormatKindUnsignedBlockCompressed5 = 25, /**< 2 channel unsigned normalized block-compressed (BC5 compression) format */
cudaChannelFormatKindSignedBlockCompressed5 = 26, /**< 2 channel signed normalized block-compressed (BC5 compression) format */
cudaChannelFormatKindUnsignedBlockCompressed6H = 27, /**< 3 channel unsigned half-float block-compressed (BC6H compression) format */
cudaChannelFormatKindSignedBlockCompressed6H = 28, /**< 3 channel signed half-float block-compressed (BC6H compression) format */
cudaChannelFormatKindUnsignedBlockCompressed7 = 29, /**< 4 channel unsigned normalized block-compressed (BC7 compression) format */
cudaChannelFormatKindUnsignedBlockCompressed7SRGB = 30 /**< 4 channel unsigned normalized block-compressed (BC7 compression) format with sRGB encoding */
};
/**
@@ -1086,6 +1169,17 @@ struct __device_builtin__ cudaArraySparseProperties {
unsigned int reserved[4];
};
/**
* CUDA array and CUDA mipmapped array memory requirements
*/
struct __device_builtin__ cudaArrayMemoryRequirements {
size_t size; /**< Total size of the array. */
size_t alignment; /**< Alignment necessary for mapping the array. */
unsigned int reserved[4];
};
/**
* CUDA memory types
*/
@@ -1566,6 +1660,55 @@ struct __device_builtin__ cudaFuncAttributes
* See ::cudaFuncSetAttribute
*/
int preferredShmemCarveout;
};
/**
@@ -1575,6 +1718,14 @@ enum __device_builtin__ cudaFuncAttribute
{
cudaFuncAttributeMaxDynamicSharedMemorySize = 8, /**< Maximum dynamic shared memory size */
cudaFuncAttributePreferredSharedMemoryCarveout = 9, /**< Preferred shared memory-L1 cache split */
cudaFuncAttributeMax
};
@@ -1609,6 +1760,17 @@ enum __device_builtin__ cudaSharedCarveout {
cudaSharedmemCarveoutMaxL1 = 0 /**< Prefer maximum available L1 cache, minimum shared memory */
};
/**
* CUDA device compute modes
*/
@@ -1799,7 +1961,7 @@ enum __device_builtin__ cudaDeviceAttr
cudaDevAttrReserved93 = 93,
cudaDevAttrReserved94 = 94,
cudaDevAttrCooperativeLaunch = 95, /**< Device supports launching cooperative kernels via ::cudaLaunchCooperativeKernel*/
cudaDevAttrCooperativeMultiDeviceLaunch = 96, /**< Device can participate in cooperative kernels launched via ::cudaLaunchCooperativeKernelMultiDevice */
cudaDevAttrCooperativeMultiDeviceLaunch = 96, /**< Deprecated, cudaLaunchCooperativeKernelMultiDevice is deprecated. */
cudaDevAttrMaxSharedMemoryPerBlockOptin = 97, /**< The maximum optin shared memory per block. This value may vary by chip. See ::cudaFuncSetAttribute */
cudaDevAttrCanFlushRemoteWrites = 98, /**< Device supports flushing of outstanding remote writes. */
cudaDevAttrHostRegisterSupported = 99, /**< Device supports host memory registration via ::cudaHostRegister. */
@@ -1811,12 +1973,20 @@ enum __device_builtin__ cudaDeviceAttr
cudaDevAttrReservedSharedMemoryPerBlock = 111, /**< Shared memory reserved by CUDA driver per block in bytes */
cudaDevAttrSparseCudaArraySupported = 112, /**< Device supports sparse CUDA arrays and sparse CUDA mipmapped arrays */
cudaDevAttrHostRegisterReadOnlySupported = 113, /**< Device supports using the ::cudaHostRegister flag cudaHostRegisterReadOnly to register memory that must be mapped as read-only to the GPU */
cudaDevAttrMaxTimelineSemaphoreInteropSupported = 114, /**< External timeline semaphore interop is supported on the device */
cudaDevAttrTimelineSemaphoreInteropSupported = 114, /**< External timeline semaphore interop is supported on the device */
cudaDevAttrMaxTimelineSemaphoreInteropSupported = 114, /**< Deprecated, External timeline semaphore interop is supported on the device */
cudaDevAttrMemoryPoolsSupported = 115, /**< Device supports using the ::cudaMallocAsync and ::cudaMemPool family of APIs */
cudaDevAttrGPUDirectRDMASupported = 116, /**< Device supports GPUDirect RDMA APIs, like nvidia_p2p_get_pages (see https://docs.nvidia.com/cuda/gpudirect-rdma for more information) */
cudaDevAttrGPUDirectRDMAFlushWritesOptions = 117, /**< The returned attribute shall be interpreted as a bitmask, where the individual bits are listed in the ::cudaFlushGPUDirectRDMAWritesOptions enum */
cudaDevAttrGPUDirectRDMAWritesOrdering = 118, /**< GPUDirect RDMA writes to the device do not need to be flushed for consumers within the scope indicated by the returned attribute. See ::cudaGPUDirectRDMAWritesOrdering for the numerical values returned here. */
cudaDevAttrMemoryPoolSupportedHandleTypes = 119 /**< Handle types supported with mempool based IPC */
cudaDevAttrMemoryPoolSupportedHandleTypes = 119, /**< Handle types supported with mempool based IPC */
cudaDevAttrDeferredMappingCudaArraySupported = 121, /**< Device supports deferred mapping CUDA arrays and CUDA mipmapped arrays */
cudaDevAttrMax
};
/**
@@ -1968,6 +2138,53 @@ struct __device_builtin__ cudaMemPoolPtrExportData {
unsigned char reserved[64];
};
/**
* Memory allocation node parameters
*/
struct __device_builtin__ cudaMemAllocNodeParams {
/**
* in: location where the allocation should reside (specified in ::location).
* ::handleTypes must be ::cudaMemHandleTypeNone. IPC is not supported.
*/
struct cudaMemPoolProps poolProps; /**< in: array of memory access descriptors. Used to describe peer GPU access */
const struct cudaMemAccessDesc *accessDescs; /**< in: number of memory access descriptors. Must not exceed the number of GPUs. */
size_t accessDescCount; /**< in: Number of `accessDescs`s */
size_t bytesize; /**< in: size in bytes of the requested allocation */
void *dptr; /**< out: address of the allocation returned by CUDA */
};
/**
* Graph memory attributes
*/
enum __device_builtin__ cudaGraphMemAttributeType {
/**
* (value type = cuuint64_t)
* Amount of memory, in bytes, currently associated with graphs.
*/
cudaGraphMemAttrUsedMemCurrent = 0x0,
/**
* (value type = cuuint64_t)
* High watermark of memory, in bytes, associated with graphs since the
* last time it was reset. High watermark can only be reset to zero.
*/
cudaGraphMemAttrUsedMemHigh = 0x1,
/**
* (value type = cuuint64_t)
* Amount of memory, in bytes, currently allocated for use by
* the CUDA graphs asynchronous allocator.
*/
cudaGraphMemAttrReservedMemCurrent = 0x2,
/**
* (value type = cuuint64_t)
* High watermark of memory, in bytes, currently allocated for use by
* the CUDA graphs asynchronous allocator.
*/
cudaGraphMemAttrReservedMemHigh = 0x3
};
/**
* CUDA device P2P attributes
*/
@@ -2161,6 +2378,11 @@ struct __device_builtin__ cudaDeviceProp
0, /* size_t reservedSharedMemPerBlock */ \
} /**< Empty device properties */
/**
* CUDA IPC Handle Size
*/
@@ -2459,7 +2681,6 @@ struct __device_builtin__ cudaExternalSemaphoreHandleDesc {
unsigned int flags;
};
#if defined(__CUDA_API_VERSION_INTERNAL)
/**
* External semaphore signal parameters(deprecated)
*/
@@ -2553,7 +2774,6 @@ struct __device_builtin__ cudaExternalSemaphoreWaitParams_v1 {
*/
unsigned int flags;
};
#endif
/**
* External semaphore signal parameters, compatible with driver type
@@ -2784,6 +3004,10 @@ enum __device_builtin__ cudaGraphNodeType {
cudaGraphNodeTypeEmpty = 0x05, /**< Empty (no-op) node */
cudaGraphNodeTypeWaitEvent = 0x06, /**< External event wait node */
cudaGraphNodeTypeEventRecord = 0x07, /**< External event record node */
cudaGraphNodeTypeExtSemaphoreSignal = 0x08, /**< External semaphore signal node */
cudaGraphNodeTypeExtSemaphoreWait = 0x09, /**< External semaphore wait node */
cudaGraphNodeTypeMemAlloc = 0x0a, /**< Memory allocation node */
cudaGraphNodeTypeMemFree = 0x0b, /**< Memory free node */
cudaGraphNodeTypeCount
};
@@ -2803,7 +3027,8 @@ enum __device_builtin__ cudaGraphExecUpdateResult {
cudaGraphExecUpdateErrorFunctionChanged = 0x4, /**< The update failed because the function of a kernel node changed (CUDA driver < 11.2) */
cudaGraphExecUpdateErrorParametersChanged = 0x5, /**< The update failed because the parameters changed in a way that is not supported */
cudaGraphExecUpdateErrorNotSupported = 0x6, /**< The update failed because something about the node is not supported */
cudaGraphExecUpdateErrorUnsupportedFunctionChange = 0x7 /**< The update failed because the function of a kernel node changed in an unsupported way */
cudaGraphExecUpdateErrorUnsupportedFunctionChange = 0x7, /**< The update failed because the function of a kernel node changed in an unsupported way */
cudaGraphExecUpdateErrorAttributesChanged = 0x8 /**< The update failed because the node attributes changed in a way that is not supported */
};
/**
@@ -2820,16 +3045,23 @@ enum __device_builtin__ cudaGetDriverEntryPointFlags {
* CUDA Graph debug write options
*/
enum __device_builtin__ cudaGraphDebugDotFlags {
cudaGraphDebugDotFlagsVerbose = 1<<0, /** Output all debug data as if every debug flag is enabled */
cudaGraphDebugDotFlagsKernelNodeParams = 1<<2, /** Adds cudaKernelNodeParams to output */
cudaGraphDebugDotFlagsMemcpyNodeParams = 1<<3, /** Adds cudaMemcpy3DParms to output */
cudaGraphDebugDotFlagsMemsetNodeParams = 1<<4, /** Adds cudaMemsetParams to output */
cudaGraphDebugDotFlagsHostNodeParams = 1<<5, /** Adds cudaHostNodeParams to output */
cudaGraphDebugDotFlagsEventNodeParams = 1<<6, /** Adds cudaEvent_t handle from record and wait nodes to output */
cudaGraphDebugDotFlagsExtSemasSignalNodeParams = 1<<7, /** Adds cudaExternalSemaphoreSignalNodeParams values to output */
cudaGraphDebugDotFlagsExtSemasWaitNodeParams = 1<<8, /** Adds cudaExternalSemaphoreWaitNodeParams to output */
cudaGraphDebugDotFlagsKernelNodeAttributes = 1<<9, /** Adds cudaKernelNodeAttrID values to output */
cudaGraphDebugDotFlagsHandles = 1<<10 /** Adds node handles and every kernel function handle to output */
cudaGraphDebugDotFlagsVerbose = 1<<0, /**< Output all debug data as if every debug flag is enabled */
cudaGraphDebugDotFlagsKernelNodeParams = 1<<2, /**< Adds cudaKernelNodeParams to output */
cudaGraphDebugDotFlagsMemcpyNodeParams = 1<<3, /**< Adds cudaMemcpy3DParms to output */
cudaGraphDebugDotFlagsMemsetNodeParams = 1<<4, /**< Adds cudaMemsetParams to output */
cudaGraphDebugDotFlagsHostNodeParams = 1<<5, /**< Adds cudaHostNodeParams to output */
cudaGraphDebugDotFlagsEventNodeParams = 1<<6, /**< Adds cudaEvent_t handle from record and wait nodes to output */
cudaGraphDebugDotFlagsExtSemasSignalNodeParams = 1<<7, /**< Adds cudaExternalSemaphoreSignalNodeParams values to output */
cudaGraphDebugDotFlagsExtSemasWaitNodeParams = 1<<8, /**< Adds cudaExternalSemaphoreWaitNodeParams to output */
cudaGraphDebugDotFlagsKernelNodeAttributes = 1<<9, /**< Adds cudaKernelNodeAttrID values to output */
cudaGraphDebugDotFlagsHandles = 1<<10 /**< Adds node handles and every kernel function handle to output */
};
/**
* Flags for instantiating a graph
*/
enum __device_builtin__ cudaGraphInstantiateFlags {
cudaGraphInstantiateFlagAutoFreeOnLaunch = 1 /**< Automatically free memory allocated in a graph before relaunching. */
};
/** @} */
+4
View File
@@ -212,6 +212,10 @@ struct __device_builtin__ cudaTextureDesc
* Disable any trilinear filtering optimizations.
*/
int disableTrilinearOptimization;
/**
* Enable seamless cube map filtering.
*/
int seamlessCubemap;
};
/**
+2
View File
@@ -61,7 +61,9 @@
* *
*******************************************************************************/
#ifndef __DOXYGEN_ONLY__
#include "crt/host_defines.h"
#endif
/*******************************************************************************
* *
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -58,13 +58,13 @@ inline void CVWrapperForNvCVImage(const NvCVImage *nvcvIm, cv::Mat *cvIm) {
// Wrap a cv::Mat in an NvCVImage.
inline void NVWrapperForCVMat(const cv::Mat *cvIm, NvCVImage *nvcvIm) {
static const NvCVImage_PixelFormat nvFormat[] = { NVCV_FORMAT_UNKNOWN, NVCV_Y, NVCV_YA, NVCV_BGR, NVCV_BGRA };
static const NvCVImage_ComponentType nvType[] = {NVCV_U8, NVCV_TYPE_UNKNOWN, NVCV_U16, NVCV_S16,
NVCV_S32, NVCV_F32, NVCV_F64, NVCV_TYPE_UNKNOWN};
static const NvCVImage_ComponentType nvType[] = { NVCV_U8, NVCV_TYPE_UNKNOWN, NVCV_U16, NVCV_S16, NVCV_S32, NVCV_F32,
NVCV_F64, NVCV_TYPE_UNKNOWN };
nvcvIm->pixels = cvIm->data;
nvcvIm->width = cvIm->cols;
nvcvIm->height = cvIm->rows;
nvcvIm->pitch = (int)cvIm->step[0];
nvcvIm->pixelFormat = nvFormat[cvIm->channels() <= 4 ? cvIm->channels() : 0];
nvcvIm->pixelFormat = nvFormat[cvIm->channels() <= 4 ? cvIm->channels() : 0];
nvcvIm->componentType = nvType[cvIm->depth() & 7];
nvcvIm->bufferBytes = 0;
nvcvIm->deletePtr = nullptr;
+8 -8
View File
@@ -23,13 +23,13 @@
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_MAJOR 0
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_MINOR 6
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_RELEASE 5
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_BUILD 2
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_MINOR 7
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_RELEASE 1
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_BUILD 0
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION 0,6,5,2
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_MAJOR_MINOR 0,6
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_STRING "0.6.5.2"
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_STRING_SHORT "0.6.5"
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_STRING_MAJOR_MINOR "0.6"
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION 0,7,1,0
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_MAJOR_MINOR 0,7
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_STRING "0.7.1.0"
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_STRING_SHORT "0.7.1"
#define NVIDIA_VIDEOEFFECTS_SDK_VERSION_STRING_MAJOR_MINOR "0.7"