Skip to content

Commit 28f3017

Browse files
committed
cleanup
Moved the preprocessor common structs to gpujpeg_preprocessor.h and keep in gpujpeg_preprocessor_common.cuh only utils. The naming may not be ideal but this is to avoid including the .cuh file with gpujpeg_common_internal.h for struct gpujpeg_postprocess definition since gpujpeg_preprocessor_common.cuh file includes gpujpeg_common_internal.h in turn (for subsampling utility fns). + small improvements if recent code (eg. indent)
1 parent 7de2626 commit 28f3017

File tree

5 files changed

+51
-44
lines changed

5 files changed

+51
-44
lines changed

src/gpujpeg_common_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <stdlib.h>
4242
#include "../libgpujpeg/gpujpeg_common.h"
4343
#include "../libgpujpeg/gpujpeg_type.h"
44-
#include "gpujpeg_preprocessor_common.cuh"
44+
#include "gpujpeg_preprocessor.h" // struct gpujpeg_preprocessor
4545
#include "gpujpeg_util.h"
4646

4747
// static_assert compat

src/gpujpeg_postprocessor.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
* to raw image. It also does color space transformations.
3434
*/
3535

36-
#define PREPROCESSOR_INTERNAL_API
37-
#include "gpujpeg_preprocessor_common.cuh"
36+
#include "gpujpeg_postprocessor.h"
3837

3938
#include "gpujpeg_colorspace.h"
40-
#include "gpujpeg_postprocessor.h"
39+
#include "gpujpeg_preprocessor.h" // common structs
40+
#include "gpujpeg_preprocessor_common.cuh" // utils
4141
#include "gpujpeg_util.h"
4242

4343
/**
@@ -500,7 +500,7 @@ gpujpeg_preprocessor_decoder_copy_planar_data(struct gpujpeg_coder * coder, cuda
500500
int
501501
gpujpeg_postprocessor_decode(struct gpujpeg_coder* coder, cudaStream_t stream)
502502
{
503-
if (coder->preprocessor.kernel == nullptr) {
503+
if ( coder->preprocessor.kernel == nullptr ) {
504504
return gpujpeg_preprocessor_decoder_copy_planar_data(coder, stream);
505505
}
506506

src/gpujpeg_preprocessor.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
* computational kernels. It also does color space transformations.
3434
*/
3535

36-
#define PREPROCESSOR_INTERNAL_API
37-
#include "gpujpeg_preprocessor_common.cuh"
36+
#include "gpujpeg_preprocessor.h"
3837

3938
#include "gpujpeg_colorspace.h"
40-
#include "gpujpeg_preprocessor.h"
39+
#include "gpujpeg_encoder_internal.h"
40+
#include "gpujpeg_preprocessor_common.cuh"
4141
#include "gpujpeg_util.h"
4242

4343
/**
@@ -359,7 +359,7 @@ gpujpeg_preprocessor_encoder_init(struct gpujpeg_coder* coder)
359359
coder->preprocessor.kernel = (void*)gpujpeg_preprocessor_select_encode_kernel<GPUJPEG_YCBCR_BT709>(coder);
360360
}
361361

362-
if ( coder->preprocessor.kernel == NULL ) {
362+
if ( coder->preprocessor.kernel == nullptr ) {
363363
return -1;
364364
}
365365

src/gpujpeg_preprocessor.h

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file
3-
* Copyright (c) 2011-2021, CESNET z.s.p.o
3+
* Copyright (c) 2011-2025, CESNET
44
* Copyright (c) 2011, Silicon Genome, LLC.
55
*
66
* All rights reserved.
@@ -31,12 +31,48 @@
3131
#ifndef GPUJPEG_PREPROCESSOR_H
3232
#define GPUJPEG_PREPROCESSOR_H
3333

34-
#include "gpujpeg_encoder_internal.h"
34+
#ifndef __cplusplus
35+
#include <stdbool.h>
36+
#endif
37+
38+
#include "../libgpujpeg/gpujpeg_type.h"
39+
3540

3641
#ifdef __cplusplus
3742
extern "C" {
3843
#endif
3944

45+
struct gpujpeg_coder;
46+
struct gpujpeg_encoder;
47+
48+
/**
49+
* Preprocessor/postprocessor data for component
50+
// */
51+
struct gpujpeg_preprocessor_data_component
52+
{
53+
uint8_t* d_data;
54+
int data_width;
55+
struct gpujpeg_component_sampling_factor sampling_factor;
56+
};
57+
58+
/**
59+
* Preprocessor/postprocessor data
60+
*/
61+
struct gpujpeg_preprocessor_data
62+
{
63+
struct gpujpeg_preprocessor_data_component comp[GPUJPEG_MAX_COMPONENT_COUNT];
64+
};
65+
66+
/**
67+
* Preprocessor/postprocessor state
68+
*/
69+
struct gpujpeg_preprocessor
70+
{
71+
void* kernel; // function poitner
72+
bool input_flipped; // [preprocess only] input is flipped
73+
struct gpujpeg_preprocessor_data data;
74+
};
75+
4076
/**
4177
* Init preprocessor encoder
4278
*

src/gpujpeg_preprocessor_common.cuh

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,15 @@
3030
#ifndef GPUJPEG_PREPROCESSOR_COMMON_CUH_DCC657E3_2EDF_47E2_90F4_F7CA26829E81
3131
#define GPUJPEG_PREPROCESSOR_COMMON_CUH_DCC657E3_2EDF_47E2_90F4_F7CA26829E81
3232

33+
#include <cassert>
34+
#include <cstdint>
35+
3336
#include "../libgpujpeg/gpujpeg_common.h"
3437
#include "../libgpujpeg/gpujpeg_type.h"
35-
36-
#ifndef __cplusplus
37-
#include <stdbool.h>
38-
#endif
38+
#include "gpujpeg_common_internal.h"
3939

4040
#define RGB_8BIT_THREADS 256
4141

42-
/**
43-
* Preprocessor data for component
44-
*/
45-
struct gpujpeg_preprocessor_data_component
46-
{
47-
uint8_t* d_data;
48-
int data_width;
49-
struct gpujpeg_component_sampling_factor sampling_factor;
50-
};
51-
52-
/**
53-
* Preprocessor data
54-
*/
55-
struct gpujpeg_preprocessor_data
56-
{
57-
struct gpujpeg_preprocessor_data_component comp[GPUJPEG_MAX_COMPONENT_COUNT];
58-
};
59-
60-
struct gpujpeg_preprocessor {
61-
void* kernel; // function poitner
62-
bool input_flipped; // [preprocess only] input is flipped
63-
struct gpujpeg_preprocessor_data data;
64-
};
65-
66-
#ifdef PREPROCESSOR_INTERNAL_API
67-
#include "gpujpeg_common_internal.h"
68-
#include <cassert>
69-
#include <cstdint>
7042
/** Value that means that sampling factor has dynamic value */
7143
#define GPUJPEG_DYNAMIC 16
7244

@@ -135,7 +107,6 @@ gpujpeg_preprocessor_make_sampling_factor_i(int comp_count, int numerator_h, int
135107
coder->component[1].sampling_factor.horizontal, coder->component[1].sampling_factor.vertical, \
136108
coder->component[2].sampling_factor.horizontal, coder->component[2].sampling_factor.vertical, \
137109
coder->component[3].sampling_factor.horizontal, coder->component[3].sampling_factor.vertical)
138-
#endif // defined PREPROCESSOR_INTERNAL_API
139110

140111
#endif // defined GPUJPEG_PREPROCESSOR_COMMON_CUH_DCC657E3_2EDF_47E2_90F4_F7CA26829E81
141112
/* vi: set expandtab sw=4: */

0 commit comments

Comments
 (0)