Program Listing for File OpHQResize.h

Return to documentation for file (cvcuda/include/cvcuda/OpHQResize.h)

/*
 * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef CVCUDA_HQ_RESIZE_H
#define CVCUDA_HQ_RESIZE_H

#include "Operator.h"
#include "Types.h"
#include "Workspace.h"
#include "detail/Export.h"

#include <cuda_runtime.h>
#include <nvcv/ImageBatch.h>
#include <nvcv/Rect.h>
#include <nvcv/Status.h>
#include <nvcv/Tensor.h>

#ifdef __cplusplus
extern "C"
{
#endif

#define NVCV_HQ_RESIZE_MAX_RESIZED_NDIM (3)

typedef struct
{
    int32_t extent[NVCV_HQ_RESIZE_MAX_RESIZED_NDIM];
    int32_t ndim;
    int32_t numChannels;
} HQResizeTensorShapeI;

typedef struct
{
    HQResizeTensorShapeI *shape;
    int32_t               size;        // the number of valid elements in the `shape` array
    int32_t               ndim;        // the number of spatial extents in each `shapes` element
    int32_t               numChannels; // the number of innermost channels, -1 if they differ between samples
} HQResizeTensorShapesI;

typedef struct
{
    float lo[NVCV_HQ_RESIZE_MAX_RESIZED_NDIM];
    float hi[NVCV_HQ_RESIZE_MAX_RESIZED_NDIM];
} HQResizeRoiF;

typedef struct
{
    int32_t       size; // the number of valid elements in the `roi` array
    int32_t       ndim; // the number of valid extents in each `roi` element
    HQResizeRoiF *roi;
} HQResizeRoisF;

CVCUDA_PUBLIC NVCVStatus cvcudaHQResizeCreate(NVCVOperatorHandle *handle);

CVCUDA_PUBLIC NVCVStatus cvcudaHQResizeTensorGetWorkspaceRequirements(NVCVOperatorHandle handle, int batchSize,
                                                                      const HQResizeTensorShapeI  inputShape,
                                                                      const HQResizeTensorShapeI  outputShape,
                                                                      const NVCVInterpolationType minInterpolation,
                                                                      const NVCVInterpolationType magInterpolation,
                                                                      bool antialias, const HQResizeRoiF *roi,
                                                                      NVCVWorkspaceRequirements *reqOut);

CVCUDA_PUBLIC NVCVStatus cvcudaHQResizeTensorBatchGetWorkspaceRequirements(NVCVOperatorHandle handle, int batchSize,
                                                                           const HQResizeTensorShapesI inputShapes,
                                                                           const HQResizeTensorShapesI outputShapes,
                                                                           const NVCVInterpolationType minInterpolation,
                                                                           const NVCVInterpolationType magInterpolation,
                                                                           bool antialias, const HQResizeRoisF roi,
                                                                           NVCVWorkspaceRequirements *reqOut);

CVCUDA_PUBLIC NVCVStatus cvcudaHQResizeGetMaxWorkspaceRequirements(NVCVOperatorHandle handle, int maxBatchSize,
                                                                   const HQResizeTensorShapeI maxShape,
                                                                   NVCVWorkspaceRequirements *reqOut);

CVCUDA_PUBLIC NVCVStatus cvcudaHQResizeSubmit(NVCVOperatorHandle handle, cudaStream_t stream,
                                              const NVCVWorkspace *workspace, NVCVTensorHandle in, NVCVTensorHandle out,
                                              const NVCVInterpolationType minInterpolation,
                                              const NVCVInterpolationType magInterpolation, bool antialias,
                                              const HQResizeRoiF *roi);

CVCUDA_PUBLIC NVCVStatus cvcudaHQResizeImageBatchSubmit(NVCVOperatorHandle handle, cudaStream_t stream,
                                                        const NVCVWorkspace *workspace, NVCVImageBatchHandle in,
                                                        NVCVImageBatchHandle        out,
                                                        const NVCVInterpolationType minInterpolation,
                                                        const NVCVInterpolationType magInterpolation, bool antialias,
                                                        const HQResizeRoisF roi);

CVCUDA_PUBLIC NVCVStatus cvcudaHQResizeTensorBatchSubmit(NVCVOperatorHandle handle, cudaStream_t stream,
                                                         const NVCVWorkspace *workspace, NVCVTensorBatchHandle in,
                                                         NVCVTensorBatchHandle       out,
                                                         const NVCVInterpolationType minInterpolation,
                                                         const NVCVInterpolationType magInterpolation, bool antialias,
                                                         const HQResizeRoisF roi);

#ifdef __cplusplus
}
#endif

#endif /* CVCUDA_HQ_RESIZE_H */