Skip to content

Commit 5a5d8ae

Browse files
committed
encoder: add convenience input sett. alternatives
Add function returning gpujpeg_encoder_input structure for convenience, mostly to make tools like clang-tidy happy that the struct is initialized when defined. It is much better than tempting user to use something like (`= { 0 }`) to suppress the warning. Also this can be used in C++ brace-or-equal or class initializer section.
1 parent 27503d7 commit 5a5d8ae

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

libgpujpeg/gpujpeg_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ struct gpujpeg_parameters
213213
*
214214
* @param param Parameters for JPEG coder
215215
* @return void
216+
* @sa gpujpeg_default_parameters
216217
*/
217218
GPUJPEG_API void
218219
gpujpeg_set_default_parameters(struct gpujpeg_parameters* param);

libgpujpeg/gpujpeg_encoder.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct gpujpeg_encoder_input
7272
* @param encoder_input Encoder input structure
7373
* @param image Input image data
7474
* @return void
75+
* @sa gpujpeg_encoder_input_image
7576
*/
7677
GPUJPEG_API void
7778
gpujpeg_encoder_input_set_image(struct gpujpeg_encoder_input* input, uint8_t* image);
@@ -82,6 +83,7 @@ gpujpeg_encoder_input_set_image(struct gpujpeg_encoder_input* input, uint8_t* im
8283
* @param encoder_input Encoder input structure
8384
* @param image GPU image data
8485
* @return void
86+
* @sa gpujpeg_encoder_input_gpu_image
8587
*/
8688
GPUJPEG_API void
8789
gpujpeg_encoder_input_set_gpu_image(struct gpujpeg_encoder_input* input, uint8_t* image);
@@ -92,10 +94,21 @@ gpujpeg_encoder_input_set_gpu_image(struct gpujpeg_encoder_input* input, uint8_t
9294
* @param encoder_input Encoder input structure
9395
* @param texture_id OpenGL texture id
9496
* @return void
97+
* @sa gpujpeg_encoder_input_set_texture
9598
*/
9699
GPUJPEG_API void
97100
gpujpeg_encoder_input_set_texture(struct gpujpeg_encoder_input* input, struct gpujpeg_opengl_texture* texture);
98101

102+
/// alternative to @ref gpujpeg_encoder_input_set_image returning the struct as a return value
103+
GPUJPEG_API struct gpujpeg_encoder_input
104+
gpujpeg_encoder_input_image(uint8_t* image);
105+
/// alternative to @ref gpujpeg_encoder_input_set_gpu_image returning the struct as a return value
106+
GPUJPEG_API struct gpujpeg_encoder_input
107+
gpujpeg_encoder_input_gpu_image(uint8_t* image);
108+
/// alternative to @ref gpujpeg_encoder_input_set_texture returning the struct as a return value
109+
GPUJPEG_API struct gpujpeg_encoder_input
110+
gpujpeg_encoder_input_texture(struct gpujpeg_opengl_texture* texture);
111+
99112
/**
100113
* Create JPEG encoder
101114
*

src/gpujpeg_encoder.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@ gpujpeg_encoder_input_set_texture(struct gpujpeg_encoder_input* input, struct gp
6969
input->texture = texture;
7070
}
7171

72+
struct gpujpeg_encoder_input
73+
gpujpeg_encoder_input_image(uint8_t* image)
74+
{
75+
struct gpujpeg_encoder_input ret;
76+
gpujpeg_encoder_input_set_image(&ret, image);
77+
return ret;
78+
}
79+
80+
struct gpujpeg_encoder_input
81+
gpujpeg_encoder_input_gpu_image(uint8_t* image)
82+
{
83+
struct gpujpeg_encoder_input ret;
84+
gpujpeg_encoder_input_set_gpu_image(&ret, image);
85+
return ret;
86+
}
87+
88+
struct gpujpeg_encoder_input
89+
gpujpeg_encoder_input_texture(struct gpujpeg_opengl_texture* texture)
90+
{
91+
struct gpujpeg_encoder_input ret;
92+
gpujpeg_encoder_input_set_texture(&ret, texture);
93+
return ret;
94+
}
95+
7296
/* Documented at declaration */
7397
struct gpujpeg_encoder*
7498
gpujpeg_encoder_create(cudaStream_t stream)

0 commit comments

Comments
 (0)