Skip to content

Commit ee3aec8

Browse files
committed
encoder: enforce hdr type via opt API
deprecate gpujpeg_encoder_set_jpeg_header() in favor of the opt API As a consequence, gpujpegtool accepts `-O enc_hdr=Adobe` (specifying the header type explicitly was not possible until now).
1 parent 96a08fa commit ee3aec8

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
22
# change version also in configure.ac
3-
project(gpujpeg VERSION 0.27.5 LANGUAGES C CUDA)
3+
project(gpujpeg VERSION 0.27.6 LANGUAGES C CUDA)
44

55
# options
66
set(BUILD_OPENGL OFF CACHE STRING "Build with OpenGL support, options are: AUTO ON OFF")

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2025-07-08 - 0.27.6
2+
----------
3+
4+
- deprecate gpujpeg_encoder_set_jpeg_header() in favor of opt API
5+
- as the consequence, gpujpegtool is able to pass that opt (`-O enc_hdr=Adobe`)
6+
17
2025-06-10 - 0.27.5
28
----------
39

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AC_PREREQ([2.65])
22
# change version also in CMakeLists.txt
3-
AC_INIT([libgpujpeg],[0.27.5],[https://github.com/CESNET/GPUJPEG/issues],[libgpujpeg],[https://github.com/CESNET/GPUJPEG])
3+
AC_INIT([libgpujpeg],[0.27.6],[https://github.com/CESNET/GPUJPEG/issues],[libgpujpeg],[https://github.com/CESNET/GPUJPEG])
44
AC_CONFIG_MACRO_DIR([m4])
55
AC_CONFIG_SRCDIR([src/main.c])
66
AC_CONFIG_AUX_DIR([.])

libgpujpeg/gpujpeg_encoder.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, const struct gpujpeg_par
188188
GPUJPEG_DEPRECATED GPUJPEG_API int
189189
gpujpeg_encoder_get_stats(struct gpujpeg_encoder *encoder, struct gpujpeg_duration_stats *stats);
190190

191+
/// do not use, use gpujpeg_encoder_set_option() with @ref GPUJPEG_ENC_OPT_HDR and @ref enc_hdr_types instead
191192
enum gpujpeg_header_type {
192193
GPUJPEG_HEADER_DEFAULT = 0, ///< for 1 or 3 channel @ref GPUJPEG_YCBCR_JPEG @ref GPUJPEG_HEADER_JFIF, for @ref
193194
///< GPUJPEG_RGB @ref GPUJPEG_HEADER_ADOBE, @ref GPUJPEG_HEADER_SPIFF otherwise
@@ -201,8 +202,10 @@ enum gpujpeg_header_type {
201202
*
202203
* Header type should be capable of describing the resulting JPEG, eg. JFIF only for BT.601
203204
* full-scale YCbCr images. If not, resulting JPEG image may be incompatible with decoders.
205+
*
206+
* @deprecated use gpujpeg_encoder_set_option() with @ref GPUJPEG_ENC_OPT_HDR
204207
*/
205-
GPUJPEG_API void
208+
GPUJPEG_DEPRECATED GPUJPEG_API void
206209
gpujpeg_encoder_set_jpeg_header(struct gpujpeg_encoder *encoder, enum gpujpeg_header_type header_type);
207210

208211
/**
@@ -220,6 +223,14 @@ gpujpeg_encoder_suggest_restart_interval(const struct gpujpeg_image_parameters*
220223
#define GPUJPEG_ENC_OUT_VAL_PAGEABLE "enc_out_val_pageable" ///< default
221224
#define GPUJPEG_ENC_OUT_VAL_PINNED "enc_out_val_pinned"
222225

226+
#define GPUJPEG_ENC_OPT_HDR "enc_hdr"
227+
/// @defgroup enc_hdr_types
228+
/// @{
229+
#define GPUJPEG_ENC_HDR_VAL_JFIF "JFIF"
230+
#define GPUJPEG_ENC_HDR_VAL_ADOBE "Adobe"
231+
#define GPUJPEG_ENC_HDR_VAL_SPIFF "SPIFF"
232+
/// @}
233+
223234
/**
224235
* sets encoder option
225236
* @retval GPUJPEG_NOERR option was sucessfully set

src/gpujpeg_encoder.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#include <assert.h>
3232
#include <math.h>
3333
#include <string.h>
34+
35+
#ifdef _WIN32
36+
#include <windows.h>
37+
#define strcasecmp _stricmp
38+
#endif
39+
3440
#include "../libgpujpeg/gpujpeg_common.h"
3541
#include "../libgpujpeg/gpujpeg_encoder.h"
3642
#include "gpujpeg_common_internal.h"
@@ -669,6 +675,19 @@ gpujpeg_encoder_set_option(struct gpujpeg_encoder* encoder, const char *opt, con
669675
encoder->writer->buffer_pinned = strcmp(val, GPUJPEG_VAL_TRUE) == 0;
670676
return GPUJPEG_NOERR;
671677
}
678+
if ( strcmp(opt, GPUJPEG_ENC_OPT_HDR) == 0 ) {
679+
if (strcasecmp(val, GPUJPEG_ENC_HDR_VAL_JFIF) == 0) {
680+
encoder->header_type = GPUJPEG_HEADER_JFIF;
681+
} else if (strcasecmp(val, GPUJPEG_ENC_HDR_VAL_ADOBE) == 0) {
682+
encoder->header_type = GPUJPEG_HEADER_ADOBE;
683+
} else if (strcasecmp(val, GPUJPEG_ENC_HDR_VAL_SPIFF) == 0) {
684+
encoder->header_type = GPUJPEG_HEADER_SPIFF;
685+
} else {
686+
ERROR_MSG("Unknown encoder header type: %s\n", val);
687+
return GPUJPEG_ERROR;
688+
}
689+
return GPUJPEG_NOERR;
690+
}
672691
ERROR_MSG("Invalid encoder option: %s!\n", opt);
673692
return GPUJPEG_ERROR;
674693
}

0 commit comments

Comments
 (0)