nvjpeg2kEncode()

Compresses the input image in JPEG2000 format and stores it within encode_state. All GPU tasks will be submitted to the provided stream. The function is asynchronous with respect to the host.

Signature:

nvjpeg2kStatus_t nvjpeg2kEncode(nvjpeg2kEncoder_t enc_handle,
        nvjpeg2kEncodeState_t encode_state,
        const nvjpeg2kEncodeParams_t encode_params,
        const nvjpeg2kImage_t *input_image,
        cudaStream_t stream);

Parameters:

Parameter

Input/Output

Memory

Description

nvjpeg2kEncoder_t enc_handle

Input

Host

Encoder handle

nvjpeg2kEncodeState_t encode_state

Input

Host

Encode State, contains intermediate buffers used for encode

const nvjpeg2kEncodeParams_t encode_params

Input

Host

Stores parameters that control the encode process

const nvjpeg2kImage_t *input_image

Input

Host/Device

Input Image. The struct should be on host memory. The image component pointers should point to device memory. See Image Data

cudaStream_t stream

Input

Host

CUDA stream - used for all device operations

Returns:

nvjpeg2kStatus_t - An error code as specified in API Return Status Codes

nvjpeg2kEncodeRetrieveBitstream()

Retrieves the compressed stream from the encoder state that was previously used by the encoder function.

  • If the compressed_data parameter is NULL, the encoder will return the compressed jpeg2000 bitstream size in the length parameter.

  • If compressed_data is not NULL, the length parameter should contain the data buffer size.

  • If the length is less than compressed stream size, an error will be returned. Otherwise the compressed stream will be stored in the data buffer and the actual compressed buffer size will be stored in the length parameter.

  • Asynchronous behavior

    • When the compressed_data parameter is NULL, the API can be assumed to be synchronous with the host

    • When the compressed_data parameter is not NULL, the application should call cudaStreamSynchronize() to make sure the bitstream copy is successful.

Signature:

nvjpeg2kStatus_t nvjpeg2kEncodeRetrieveBitstream(
        nvjpeg2kEncoder_t enc_handle,
        nvjpeg2kEncodeState_t encode_state,
        unsigned char *compressed_data,
        size_t *length,
        cudaStream_t stream);

Parameters:

Parameter

Input/Output

Memory

Description

nvjpeg2kEncoder_t enc_handle

Input

Host

Encoder handle

nvjpeg2kEncodeState_t encode_state

Input

Host

Encode State, contains intermediate buffers used for encode

unsigned char *data

Output

Host

Pointer to the buffer in the host memory where the compressed stream will be stored. Can be NULL (see description).

size_t *length,

Input/Output

Host

Pointer to the input buffer size. The library will update the actual compressed stream size in this parameter.

cudaStream_t stream

Input

Host

CUDA stream - used for all device operations.

Returns:

nvjpeg2kStatus_t - An error code as specified in API Return Status Codes