Program Listing for File Image.h

Return to documentation for file (nvcv_types/include/nvcv/Image.h)

/*
 * SPDX-FileCopyrightText: Copyright (c) 2022-2023 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 NVCV_IMAGE_H
#define NVCV_IMAGE_H

#include "Export.h"
#include "Fwd.h"
#include "ImageData.h"
#include "Status.h"
#include "alloc/Allocator.h"
#include "alloc/Requirements.h"
#include "detail/CudaFwd.h"

#include <nvcv/ImageFormat.h>

#ifdef __cplusplus
extern "C"
{
#endif

typedef enum
{
    NVCV_TYPE_IMAGE,
    NVCV_TYPE_IMAGE_WRAPDATA
} NVCVTypeImage;

typedef struct NVCVImage *NVCVImageHandle;

typedef void (*NVCVImageDataCleanupFunc)(void *ctx, const NVCVImageData *data);

typedef struct NVCVImageRequirementsRec
{
    int32_t         width, height; /*< Image dimensions. */
    NVCVImageFormat format;        /*< Image format. */

    int32_t planeRowStride[NVCV_MAX_PLANE_COUNT];

    int32_t          alignBytes; /*< Alignment/block size in bytes */
    NVCVRequirements mem;        /*< Image resource requirements. */
} NVCVImageRequirements;

NVCV_PUBLIC NVCVStatus nvcvImageCalcRequirements(int32_t width, int32_t height, NVCVImageFormat format,
                                                 int32_t baseAddrAlignment, int32_t rowAddrAlignment,
                                                 NVCVImageRequirements *reqs);

NVCV_PUBLIC NVCVStatus nvcvImageConstruct(const NVCVImageRequirements *reqs, NVCVAllocatorHandle alloc,
                                          NVCVImageHandle *handle);

NVCV_PUBLIC NVCVStatus nvcvImageWrapDataConstruct(const NVCVImageData *data, NVCVImageDataCleanupFunc cleanup,
                                                  void *ctxCleanup, NVCVImageHandle *handle);

NVCV_PUBLIC NVCVStatus nvcvImageDecRef(NVCVImageHandle handle, int *newRefCount);

NVCV_PUBLIC NVCVStatus nvcvImageIncRef(NVCVImageHandle handle, int *newRefCount);

NVCV_PUBLIC NVCVStatus nvcvImageRefCount(NVCVImageHandle handle, int *newRefCount);

NVCV_PUBLIC NVCVStatus nvcvImageSetUserPointer(NVCVImageHandle handle, void *userPtr);

NVCV_PUBLIC NVCVStatus nvcvImageGetUserPointer(NVCVImageHandle handle, void **outUserPtr);

NVCV_PUBLIC NVCVStatus nvcvImageGetType(NVCVImageHandle handle, NVCVTypeImage *type);

NVCV_PUBLIC NVCVStatus nvcvImageGetSize(NVCVImageHandle handle, int32_t *width, int32_t *height);

NVCV_PUBLIC NVCVStatus nvcvImageGetFormat(NVCVImageHandle handle, NVCVImageFormat *fmt);

NVCV_PUBLIC NVCVStatus nvcvImageGetAllocator(NVCVImageHandle handle, NVCVAllocatorHandle *alloc);

NVCV_PUBLIC NVCVStatus nvcvImageExportData(NVCVImageHandle handle, NVCVImageData *data);

#ifdef __cplusplus
}
#endif

#endif // NVCV_IMAGE_H