Skip to content

Commit c8ef940

Browse files
committed
adjust_pixel_format: assertion + macro val improve
Use the macro values referenced from GPUJPEG_PIXFMT_NONE rather than substracting 1 from previous macro (readibility, otherwise values the same).
1 parent 9e69e4d commit c8ef940

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

libgpujpeg/gpujpeg_decoder.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file
3-
* Copyright (c) 2011-2025, CESNET
3+
* Copyright (c) 2011-2026, CESNET
44
* Copyright (c) 2011, Silicon Genome, LLC.
55
*
66
* All rights reserved.
@@ -232,13 +232,12 @@ gpujpeg_decoder_destroy(struct gpujpeg_decoder* decoder);
232232
*/
233233
/// decoder default pixfmt - usually @ref GPUJPEG_444_U8_P012;
234234
/// @ref GPUJPEG_U8 for grayscale and @ref GPUJPEG_444_U8_P0123 if alpha present
235-
///
236235
#define GPUJPEG_PIXFMT_AUTODETECT ((enum gpujpeg_pixel_format)(GPUJPEG_PIXFMT_NONE - 1))
237236
/// as @ref GPUJPEG_PIXFMT_AUTODETECT, but alpha stripped if present
238-
#define GPUJPEG_PIXFMT_NO_ALPHA ((enum gpujpeg_pixel_format)(GPUJPEG_PIXFMT_AUTODETECT - 1))
237+
#define GPUJPEG_PIXFMT_NO_ALPHA ((enum gpujpeg_pixel_format)(GPUJPEG_PIXFMT_NONE - 2))
239238
/// pixel format that may be stored in a PAM or Y4M file - a planar pixel
240239
/// format that is either 444, 422 or 420 for YUV, P012(3) otherwise
241-
#define GPUJPEG_PIXFMT_STD ((enum gpujpeg_pixel_format)(GPUJPEG_PIXFMT_NO_ALPHA - 1))
240+
#define GPUJPEG_PIXFMT_STD ((enum gpujpeg_pixel_format)(GPUJPEG_PIXFMT_NONE - 3))
242241
/// @}
243242
/// Decode RGB for 3 or 4 channels, GPUJPEG_YCBCR for grayscale.
244243
/// decoder only, valid only if passed to gpujpeg_decoder_set_output_format()

src/gpujpeg_reader.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file
3-
* Copyright (c) 2011-2025, CESNET
3+
* Copyright (c) 2011-2026, CESNET
44
* Copyright (c) 2011, Silicon Genome, LLC.
55
*
66
* All rights reserved.
@@ -1492,6 +1492,7 @@ static _Bool sampling_factor_compare(int count, struct gpujpeg_component_samplin
14921492

14931493
static enum gpujpeg_pixel_format
14941494
adjust_pixel_format(struct gpujpeg_parameters * param, struct gpujpeg_image_parameters * param_image) {
1495+
assert(param_image->pixel_format == GPUJPEG_PIXFMT_AUTODETECT || param_image->pixel_format == GPUJPEG_PIXFMT_STD);
14951496
if ( param->comp_count == 1 ) {
14961497
return GPUJPEG_U8;
14971498
}

0 commit comments

Comments
 (0)