Add support for rocJpegDecodeBatched API - part 1 of 2 (#31)

* Add initial support for batch decoding

* Add support for reading and parsing the images in batches and allocating the output buffers

* Add initial support for the rocJpegDecodeBatched API

* use recursive_mutex to allow DecodeBatched and Decode functions called concurrently

* code cleanup

* Add a CTEST for jpegdecodebatched

* modify the help message

* code clean up

[ROCm/rocjpeg commit: c660aeab43]
This commit is contained in:
Aryan Salmanpour
2024-06-13 14:04:53 -04:00
committed by GitHub
parent 514a174c43
commit 08f7236c94
13 changed files with 429 additions and 18 deletions
+27
View File
@@ -208,6 +208,33 @@ RocJpegStatus ROCJPEGAPI rocJpegDecode(RocJpegHandle handle, RocJpegStreamHandle
return rocjpeg_status;
}
/**
* @brief Decodes a batch of JPEG images using the rocJPEG library.
*
* Decodes a batch of JPEG images using the specified handle, stream handles, decode parameters, and destination images.
*
* @param handle The handle to the RocJpeg decoder.
* @param jpeg_stream_handles An array of stream handles for the JPEG images to be decoded.
* @param decode_params The decode parameters for the decoding process.
* @param destinations An array of RocJpegImage structures to store the decoded images.
* @return The status of the decoding process. Returns ROCJPEG_STATUS_SUCCESS if successful, or an error code otherwise.
*/
RocJpegStatus ROCJPEGAPI rocJpegDecodeBatched(RocJpegHandle handle, RocJpegStreamHandle *jpeg_stream_handles, int batch_size, const RocJpegDecodeParams *decode_params, RocJpegImage *destinations) {
if (handle == nullptr || jpeg_stream_handles == nullptr|| decode_params == nullptr || destinations == nullptr) {
return ROCJPEG_STATUS_INVALID_PARAMETER;
}
RocJpegStatus rocjpeg_status = ROCJPEG_STATUS_SUCCESS;
auto rocjpeg_handle = static_cast<RocJpegDecoderHandle*>(handle);
try {
rocjpeg_status = rocjpeg_handle->rocjpeg_decoder->DecodeBatched(jpeg_stream_handles, batch_size, decode_params, destinations);
} catch (const std::exception& e) {
rocjpeg_handle->CaptureError(e.what());
ERR(e.what());
return ROCJPEG_STATUS_RUNTIME_ERROR;
}
return rocjpeg_status;
}
/**
* @brief Returns the error name corresponding to the given RocJpegStatus.
*