Skip to content

Commit 6ae2a1a

Browse files
committed
updated opt names and values
- add generic GPUJPEG_VAL_TRUE and _FALSE (for the dec opt) - for GPUJPEG_ENC_OPT_OUT accept GPUJPEG_ENC_OUT_VAL_PAGEABLE and GPUJPEG_ENC_OUT_VAL_PINNED refer to GH-97
1 parent e8f9e41 commit 6ae2a1a

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

libgpujpeg/gpujpeg_decoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ gpujpeg_decoder_get_image_info(uint8_t *image, size_t image_size, struct gpujpeg
269269

270270
/// use RLE when writing TGA with gpujpeg_image_save_to_file (default is true), 0 or 1 please note that the option is
271271
/// global so it affects all decoder instances
272-
#define GPUJPEG_DECODER_OPT_TGA_RLE "dec_tga_rle"
272+
#define GPUJPEG_DEC_OPT_TGA_RLE_BOOL "dec_opt_tga_rle" ///< GPUJPEG_VAL_TRUE or GPUJPEG_VAL_FALSE
273273
/**
274274
* sets decoder option
275275
* @retval GPUJPEG_NOERR option was sucessfully set

libgpujpeg/gpujpeg_encoder.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,12 @@ GPUJPEG_API int
214214
gpujpeg_encoder_suggest_restart_interval(const struct gpujpeg_image_parameters* param_image,
215215
gpujpeg_sampling_factor_t subsampling, bool interleaved, int verbose);
216216

217-
/// buffer returned from gpujpeg_encoder_encode() should be in pinned memory
218-
#define GPUJPEG_ENCODER_OPT_OUT_PINNED "enc_out_pinned"
217+
#define GPUJPEG_ENCODER_OPT_OUT_PINNED "enc_out_pinned" ///< deprecated - use GPUJPEG_ENC_OPT_OUT
218+
/// location of buffer returned from gpujpeg_encoder_encode()
219+
#define GPUJPEG_ENC_OPT_OUT "enc_opt_out"
220+
#define GPUJPEG_ENC_OUT_VAL_PAGEABLE "enc_out_val_pageable" ///< default
221+
#define GPUJPEG_ENC_OUT_VAL_PINNED "enc_out_val_pinned"
222+
219223
/**
220224
* sets encoder option
221225
* @retval GPUJPEG_NOERR option was sucessfully set

libgpujpeg/gpujpeg_type.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file
3-
* Copyright (c) 2011-2024, CESNET
3+
* Copyright (c) 2011-2025, CESNET
44
* Copyright (c) 2011, Silicon Genome, LLC.
55
*
66
* All rights reserved.
@@ -76,6 +76,9 @@ extern "C" {
7676
#define GPUJPEG_ERR_RESTART_CHANGE (-2)
7777
/// @}
7878

79+
#define GPUJPEG_VAL_TRUE "1"
80+
#define GPUJPEG_VAL_FALSE "0"
81+
7982
/**
8083
* Color spaces for JPEG codec
8184
*/

src/gpujpeg_decoder.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,12 @@ gpujpeg_decoder_set_option(struct gpujpeg_decoder* decoder, const char *opt, con
485485
if ( decoder == NULL || opt == NULL || val == NULL ) {
486486
return GPUJPEG_ERROR;
487487
}
488-
if ( strcmp(opt, GPUJPEG_DECODER_OPT_TGA_RLE) == 0 ) {
489-
if ( (val[0] != '0' && val[0] != '1') || val[1] != '\0' ) {
490-
ERROR_MSG("Unexpeceted value %s for " GPUJPEG_DECODER_OPT_TGA_RLE "\n", val);
488+
if ( strcmp(opt, GPUJPEG_DEC_OPT_TGA_RLE_BOOL) == 0 ) {
489+
if ( strcmp(val, GPUJPEG_VAL_TRUE) != 0 && strcmp(val, GPUJPEG_VAL_FALSE) != 0 ) {
490+
ERROR_MSG("Unexpeceted value %s for " GPUJPEG_DEC_OPT_TGA_RLE_BOOL "\n", val);
491491
return GPUJPEG_ERROR;
492492
}
493-
image_delegate_stbi_tga_set_rle(val[0] == '1');
493+
image_delegate_stbi_tga_set_rle(strcmp(val, GPUJPEG_VAL_TRUE) == 0);
494494
return GPUJPEG_NOERR;
495495
}
496496
ERROR_MSG("Invalid decoder option: %s!\n", opt);

src/gpujpeg_encoder.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,21 @@ gpujpeg_encoder_set_option(struct gpujpeg_encoder* encoder, const char *opt, con
652652
if ( encoder == NULL || opt == NULL || val == NULL ) {
653653
return GPUJPEG_ERROR;
654654
}
655+
if ( strcmp(opt, GPUJPEG_ENC_OPT_OUT) == 0 ) {
656+
if ( strcmp(val, GPUJPEG_ENC_OUT_VAL_PAGEABLE) != 0 && strcmp(val, GPUJPEG_ENC_OUT_VAL_PINNED) != 0 ) {
657+
ERROR_MSG("Unexpeceted value %s for " GPUJPEG_ENC_OPT_OUT "\n", val);
658+
return GPUJPEG_ERROR;
659+
}
660+
encoder->writer->buffer_pinned = strcmp(val, GPUJPEG_ENC_OUT_VAL_PINNED) == 0;
661+
return GPUJPEG_NOERR;
662+
}
655663
if ( strcmp(opt, GPUJPEG_ENCODER_OPT_OUT_PINNED) == 0 ) {
656-
if ( (val[0] != '0' && val[0] != '1') || val[1] != '\0' ) {
664+
WARN_MSG("deprecated, use GPUJPEG_ENC_OUT_VAL_PAGEABLE (" GPUJPEG_ENC_OUT_VAL_PAGEABLE ") instead!\n");
665+
if ( strcmp(val, GPUJPEG_VAL_TRUE) != 0 && strcmp(val, GPUJPEG_VAL_FALSE) != 0 ) {
657666
ERROR_MSG("Unexpeceted value %s for " GPUJPEG_ENCODER_OPT_OUT_PINNED "\n", val);
658667
return GPUJPEG_ERROR;
659668
}
660-
encoder->writer->buffer_pinned = val[0] == '1';
669+
encoder->writer->buffer_pinned = strcmp(val, GPUJPEG_VAL_TRUE) == 0;
661670
return GPUJPEG_NOERR;
662671
}
663672
ERROR_MSG("Invalid encoder option: %s!\n", opt);

0 commit comments

Comments
 (0)