Skip to content

Commit

Permalink
encoder: add convenience input sett. alternatives
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MartinPulec committed Jan 7, 2025
1 parent 27503d7 commit 5a5d8ae
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions libgpujpeg/gpujpeg_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ struct gpujpeg_parameters
*
* @param param Parameters for JPEG coder
* @return void
* @sa gpujpeg_default_parameters
*/
GPUJPEG_API void
gpujpeg_set_default_parameters(struct gpujpeg_parameters* param);
Expand Down
13 changes: 13 additions & 0 deletions libgpujpeg/gpujpeg_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct gpujpeg_encoder_input
* @param encoder_input Encoder input structure
* @param image Input image data
* @return void
* @sa gpujpeg_encoder_input_image
*/
GPUJPEG_API void
gpujpeg_encoder_input_set_image(struct gpujpeg_encoder_input* input, uint8_t* image);
Expand All @@ -82,6 +83,7 @@ gpujpeg_encoder_input_set_image(struct gpujpeg_encoder_input* input, uint8_t* im
* @param encoder_input Encoder input structure
* @param image GPU image data
* @return void
* @sa gpujpeg_encoder_input_gpu_image
*/
GPUJPEG_API void
gpujpeg_encoder_input_set_gpu_image(struct gpujpeg_encoder_input* input, uint8_t* image);
Expand All @@ -92,10 +94,21 @@ gpujpeg_encoder_input_set_gpu_image(struct gpujpeg_encoder_input* input, uint8_t
* @param encoder_input Encoder input structure
* @param texture_id OpenGL texture id
* @return void
* @sa gpujpeg_encoder_input_set_texture
*/
GPUJPEG_API void
gpujpeg_encoder_input_set_texture(struct gpujpeg_encoder_input* input, struct gpujpeg_opengl_texture* texture);

/// alternative to @ref gpujpeg_encoder_input_set_image returning the struct as a return value
GPUJPEG_API struct gpujpeg_encoder_input
gpujpeg_encoder_input_image(uint8_t* image);
/// alternative to @ref gpujpeg_encoder_input_set_gpu_image returning the struct as a return value
GPUJPEG_API struct gpujpeg_encoder_input
gpujpeg_encoder_input_gpu_image(uint8_t* image);
/// alternative to @ref gpujpeg_encoder_input_set_texture returning the struct as a return value
GPUJPEG_API struct gpujpeg_encoder_input
gpujpeg_encoder_input_texture(struct gpujpeg_opengl_texture* texture);

/**
* Create JPEG encoder
*
Expand Down
24 changes: 24 additions & 0 deletions src/gpujpeg_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,30 @@ gpujpeg_encoder_input_set_texture(struct gpujpeg_encoder_input* input, struct gp
input->texture = texture;
}

struct gpujpeg_encoder_input
gpujpeg_encoder_input_image(uint8_t* image)
{
struct gpujpeg_encoder_input ret;
gpujpeg_encoder_input_set_image(&ret, image);
return ret;
}

struct gpujpeg_encoder_input
gpujpeg_encoder_input_gpu_image(uint8_t* image)
{
struct gpujpeg_encoder_input ret;
gpujpeg_encoder_input_set_gpu_image(&ret, image);
return ret;
}

struct gpujpeg_encoder_input
gpujpeg_encoder_input_texture(struct gpujpeg_opengl_texture* texture)
{
struct gpujpeg_encoder_input ret;
gpujpeg_encoder_input_set_texture(&ret, texture);
return ret;
}

/* Documented at declaration */
struct gpujpeg_encoder*
gpujpeg_encoder_create(cudaStream_t stream)
Expand Down

0 comments on commit 5a5d8ae

Please sign in to comment.