/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocjpeg/checkouts/develop/projects/rocjpeg/api/rocjpeg/rocjpeg.h Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocjpeg/checkouts/develop/projects/rocjpeg/api/rocjpeg/rocjpeg.h Source File#

6 min read time

Applies to Linux

rocJPEG: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocjpeg/checkouts/develop/projects/rocjpeg/api/rocjpeg/rocjpeg.h Source File
rocjpeg.h
Go to the documentation of this file.
1 /* Copyright (c) 2024 - 2026 Advanced Micro Devices, Inc. All rights reserved.
2 
3 Permission is hereby granted, free of charge, to any person obtaining a copy
4 of this software and associated documentation files (the "Software"), to deal
5 in the Software without restriction, including without limitation the rights
6 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 copies of the Software, and to permit persons to whom the Software is
8 furnished to do so, subject to the following conditions:
9 
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
12 
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 THE SOFTWARE.
20 */
21 
22 #ifndef ROC_JPEG_H
23 #define ROC_JPEG_H
24 
25 #define ROCJPEGAPI
26 
27 #pragma once
28 #include "hip/hip_runtime.h"
29 
37 #if defined(__cplusplus)
38 extern "C" {
39 #endif // __cplusplus
45 #define ROCJPEG_MAX_COMPONENT 4
46 
51 typedef enum {
67 
84 typedef enum {
85  ROCJPEG_CSS_444 = 0,
86  ROCJPEG_CSS_440 = 1,
87  ROCJPEG_CSS_422 = 2,
88  ROCJPEG_CSS_420 = 3,
89  ROCJPEG_CSS_411 = 4,
90  ROCJPEG_CSS_400 = 5,
91  ROCJPEG_CSS_UNKNOWN = -1
93 
102 typedef struct {
103  uint8_t* channel[ROCJPEG_MAX_COMPONENT];
104  uint32_t pitch[ROCJPEG_MAX_COMPONENT];
105 } RocJpegImage;
106 
121 typedef enum {
132  ROCJPEG_OUTPUT_Y = 2,
134  ROCJPEG_OUTPUT_RGB = 3,
136  ROCJPEG_OUTPUT_RGB_PLANAR = 4,
139 
150 typedef struct {
152  struct {
153  int16_t left;
154  int16_t top;
155  int16_t right;
156  int16_t bottom;
157  } crop_rectangle;
158  struct {
159  uint32_t width;
160  uint32_t height;
161  } target_dimension;
164 
172 typedef enum {
176 
183 typedef void* RocJpegStreamHandle;
184 
199 RocJpegStatus ROCJPEGAPI rocJpegStreamCreate(RocJpegStreamHandle *jpeg_stream_handle);
200 
213 RocJpegStatus ROCJPEGAPI rocJpegStreamParse(const unsigned char *data, size_t length, RocJpegStreamHandle jpeg_stream_handle);
214 
228 
235 typedef void *RocJpegHandle;
236 
250 RocJpegStatus ROCJPEGAPI rocJpegCreate(RocJpegBackend backend, int device_id, RocJpegHandle *handle);
251 
265 
286 RocJpegStatus ROCJPEGAPI rocJpegGetImageInfo(RocJpegHandle handle, RocJpegStreamHandle jpeg_stream_handle, uint8_t *num_components, RocJpegChromaSubsampling *subsampling, uint32_t *widths, uint32_t *heights);
287 
303 RocJpegStatus ROCJPEGAPI rocJpegDecode(RocJpegHandle handle, RocJpegStreamHandle jpeg_stream_handle, const RocJpegDecodeParams *decode_params, RocJpegImage *destination);
304 
318 RocJpegStatus ROCJPEGAPI rocJpegDecodeBatched(RocJpegHandle handle, RocJpegStreamHandle *jpeg_stream_handles, int batch_size, const RocJpegDecodeParams *decode_params, RocJpegImage *destinations);
319 
329 extern const char* ROCJPEGAPI rocJpegGetErrorName(RocJpegStatus rocjpeg_status);
330 
349 RocJpegStatus ROCJPEGAPI rocJpegDecodeAsync(RocJpegHandle handle, RocJpegStreamHandle jpeg_stream_handle, const RocJpegDecodeParams *decode_params, RocJpegImage *destination);
350 
367 
388 RocJpegStatus ROCJPEGAPI rocJpegDecodeBatchedAsync(RocJpegHandle handle, RocJpegStreamHandle *jpeg_stream_handles, int batch_size, const RocJpegDecodeParams *decode_params, RocJpegImage *destinations);
389 
407 RocJpegStatus ROCJPEGAPI rocJpegDecodeBatchedSync(RocJpegHandle handle, RocJpegImage *destinations, int batch_size);
408 
409 #if defined(__cplusplus)
410  }
411 #endif
412 
413 #endif // ROC_JPEG_H
RocJpegStatus ROCJPEGAPI rocJpegDecodeAsync(RocJpegHandle handle, RocJpegStreamHandle jpeg_stream_handle, const RocJpegDecodeParams *decode_params, RocJpegImage *destination)
Submits a JPEG decode operation without waiting for the output.
const char *ROCJPEGAPI rocJpegGetErrorName(RocJpegStatus rocjpeg_status)
Retrieves the name of the error associated with the given RocJpegStatus.
RocJpegStatus ROCJPEGAPI rocJpegDecodeBatched(RocJpegHandle handle, RocJpegStreamHandle *jpeg_stream_handles, int batch_size, const RocJpegDecodeParams *decode_params, RocJpegImage *destinations)
Decodes a batch of JPEG images using the rocJPEG library.
RocJpegStatus ROCJPEGAPI rocJpegCreate(RocJpegBackend backend, int device_id, RocJpegHandle *handle)
Creates a RocJpegHandle for JPEG decoding.
RocJpegStatus ROCJPEGAPI rocJpegStreamParse(const unsigned char *data, size_t length, RocJpegStreamHandle jpeg_stream_handle)
Parses a JPEG stream.
RocJpegStatus ROCJPEGAPI rocJpegDecodeSync(RocJpegHandle handle, RocJpegImage *destination)
Synchronizes a pending asynchronous JPEG decode and retrieves the decoded output.
RocJpegStatus ROCJPEGAPI rocJpegStreamCreate(RocJpegStreamHandle *jpeg_stream_handle)
Creates a RocJpegStreamHandle for JPEG stream processing.
RocJpegOutputFormat
Enum representing the output format options for the RocJpegImage.
Definition: rocjpeg.h:121
RocJpegBackend
The backend options for the rocJpeg library.
Definition: rocjpeg.h:172
RocJpegChromaSubsampling
Enum representing the chroma subsampling options for JPEG encoding/decoding.
Definition: rocjpeg.h:84
RocJpegStatus ROCJPEGAPI rocJpegDecode(RocJpegHandle handle, RocJpegStreamHandle jpeg_stream_handle, const RocJpegDecodeParams *decode_params, RocJpegImage *destination)
Decodes a JPEG image using the rocJPEG library.
RocJpegStatus ROCJPEGAPI rocJpegStreamDestroy(RocJpegStreamHandle jpeg_stream_handle)
Destroys a RocJpegStreamHandle object and releases associated resources.
RocJpegStatus
Enumeration representing the status codes for the rocJPEG library.
Definition: rocjpeg.h:51
RocJpegStatus ROCJPEGAPI rocJpegDestroy(RocJpegHandle handle)
Destroys a RocJpegHandle object.
RocJpegStatus ROCJPEGAPI rocJpegGetImageInfo(RocJpegHandle handle, RocJpegStreamHandle jpeg_stream_handle, uint8_t *num_components, RocJpegChromaSubsampling *subsampling, uint32_t *widths, uint32_t *heights)
Retrieves information about the JPEG image.
RocJpegStatus ROCJPEGAPI rocJpegDecodeBatchedAsync(RocJpegHandle handle, RocJpegStreamHandle *jpeg_stream_handles, int batch_size, const RocJpegDecodeParams *decode_params, RocJpegImage *destinations)
Submits a batch of JPEG decode operations without waiting for the output.
RocJpegStatus ROCJPEGAPI rocJpegDecodeBatchedSync(RocJpegHandle handle, RocJpegImage *destinations, int batch_size)
Synchronizes a pending asynchronous batched JPEG decode and retrieves the decoded output.
@ ROCJPEG_OUTPUT_Y
Definition: rocjpeg.h:132
@ ROCJPEG_OUTPUT_FORMAT_MAX
Definition: rocjpeg.h:137
@ ROCJPEG_OUTPUT_NATIVE
Definition: rocjpeg.h:127
@ ROCJPEG_OUTPUT_YUV_PLANAR
Definition: rocjpeg.h:130
@ ROCJPEG_OUTPUT_RGB
Definition: rocjpeg.h:134
@ ROCJPEG_BACKEND_HYBRID
Definition: rocjpeg.h:174
@ ROCJPEG_BACKEND_HARDWARE
Definition: rocjpeg.h:173
@ ROCJPEG_STATUS_MAX_VALUE
Definition: rocjpeg.h:65
@ ROCJPEG_STATUS_IMPLEMENTATION_NOT_SUPPORTED
Definition: rocjpeg.h:61
@ ROCJPEG_STATUS_HW_JPEG_DECODER_NOT_SUPPORTED
Definition: rocjpeg.h:62
@ ROCJPEG_STATUS_NOT_IMPLEMENTED
Definition: rocjpeg.h:64
@ ROCJPEG_STATUS_OUTOF_MEMORY
Definition: rocjpeg.h:57
@ ROCJPEG_STATUS_BAD_JPEG
Definition: rocjpeg.h:55
@ ROCJPEG_STATUS_SUCCESS
Definition: rocjpeg.h:52
@ ROCJPEG_STATUS_JPEG_NOT_SUPPORTED
Definition: rocjpeg.h:56
@ ROCJPEG_STATUS_ARCH_MISMATCH
Definition: rocjpeg.h:59
@ ROCJPEG_STATUS_INVALID_PARAMETER
Definition: rocjpeg.h:54
@ ROCJPEG_STATUS_EXECUTION_FAILED
Definition: rocjpeg.h:58
@ ROCJPEG_STATUS_RUNTIME_ERROR
Definition: rocjpeg.h:63
@ ROCJPEG_STATUS_NOT_INITIALIZED
Definition: rocjpeg.h:53
@ ROCJPEG_STATUS_INTERNAL_ERROR
Definition: rocjpeg.h:60
void * RocJpegHandle
A handle representing a RocJpeg instance.
Definition: rocjpeg.h:235
void * RocJpegStreamHandle
A handle representing a RocJpegStream instance.
Definition: rocjpeg.h:183
Structure containing parameters for JPEG decoding.
Definition: rocjpeg.h:150
int16_t left
Definition: rocjpeg.h:153
RocJpegOutputFormat output_format
Definition: rocjpeg.h:151
uint32_t width
Definition: rocjpeg.h:159
int16_t top
Definition: rocjpeg.h:154
int16_t bottom
Definition: rocjpeg.h:156
uint32_t height
Definition: rocjpeg.h:160
int16_t right
Definition: rocjpeg.h:155
Structure representing a JPEG image.
Definition: rocjpeg.h:102