3535 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636 */
3737
38- #include < assert.h >
38+ #include < cassert >
3939#include < svt-jpegxs/SvtJpegxs.h>
4040#include < svt-jpegxs/SvtJpegxsDec.h>
4141#include < svt-jpegxs/SvtJpegxsImageBufferTools.h>
@@ -74,7 +74,7 @@ struct state_decompress_jpegxs {
7474 svt_jpeg_xs_image_config_t image_config{};
7575 svt_jpeg_xs_frame_pool_t *frame_pool{};
7676
77- bool configured = 0 ;
77+ bool configured = false ;
7878
7979 const jpegxs_to_uv_conversion *convert_from_planar{};
8080
@@ -86,16 +86,16 @@ struct state_decompress_jpegxs {
8686
8787}
8888
89- static const struct jpegxs_to_uv_conversion jpegxs_to_uv_conversions[] = {
90- { COLOUR_FORMAT_PLANAR_YUV422 , UYVY , yuv422pXX_to_uyvy },
91- { COLOUR_FORMAT_PLANAR_YUV422 , YUYV , yuv422p_to_yuyv },
92- { COLOUR_FORMAT_PLANAR_YUV420 , I420 , yuv420_to_i420 },
93- { COLOUR_FORMAT_PLANAR_YUV420 , UYVY , yuv420p_to_uyvy },
94- { COLOUR_FORMAT_PLANAR_YUV444_OR_RGB , RGB , rgbpXX_to_rgb },
95- { COLOUR_FORMAT_PLANAR_YUV422 , v210, yuv422p10le_to_v210},
96- { COLOUR_FORMAT_PLANAR_YUV444_OR_RGB , R10k, rgbpXXle_to_r10k },
97- { COLOUR_FORMAT_PLANAR_YUV444_OR_RGB , R12L , rgbpXXle_to_r12l },
98- { COLOUR_FORMAT_PLANAR_YUV444_OR_RGB , RG48 , rgbpXXle_to_rg48 },
89+ static const jpegxs_to_uv_conversion jpegxs_to_uv_conversions[] = {
90+ { . src = COLOUR_FORMAT_PLANAR_YUV422 , . dst = UYVY , . convert = yuv422pXX_to_uyvy },
91+ { . src = COLOUR_FORMAT_PLANAR_YUV422 , . dst = YUYV , . convert = yuv422p_to_yuyv },
92+ { . src = COLOUR_FORMAT_PLANAR_YUV420 , . dst = I420 , . convert = yuv420_to_i420 },
93+ { . src = COLOUR_FORMAT_PLANAR_YUV420 , . dst = UYVY , . convert = yuv420p_to_uyvy },
94+ { . src = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB , . dst = RGB , . convert = rgbpXX_to_rgb },
95+ { . src = COLOUR_FORMAT_PLANAR_YUV422 , . dst = v210, . convert = yuv422p10le_to_v210},
96+ { . src = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB , . dst = R10k, . convert = rgbpXXle_to_r10k },
97+ { . src = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB , . dst = R12L , . convert = rgbpXXle_to_r12l },
98+ { . src = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB , . dst = RG48 , . convert = rgbpXXle_to_rg48 },
9999};
100100
101101static enum subsampling get_jxs_subsampling_to_ug (ColourFormat_t jxs_ss);
@@ -124,21 +124,19 @@ get_jpegxs_to_uv_conversion(codec_t codec, enum subsampling ug_ss)
124124 return nullptr ;
125125}
126126
127- static void
128- jpegxs_to_uv_convert (struct state_decompress_jpegxs *s,
129- const svt_jpeg_xs_image_buffer_t *src, int width,
130- int height, uint8_t *dst)
127+ static void jpegxs_to_uv_convert (const state_decompress_jpegxs *s,
128+ const svt_jpeg_xs_image_buffer_t *src, int width, int height, uint8_t *dst)
131129{
132- const struct jpegxs_to_uv_conversion *conv = s->convert_from_planar ;
130+ const jpegxs_to_uv_conversion *conv = s->convert_from_planar ;
133131 const int in_bpp = s->image_config .bit_depth > 8 ? 2 : 1 ;
134- struct from_planar_data d = {};
132+ from_planar_data d = {};
135133 d.width = width;
136134 d.height = height;
137135 d.out_data = dst;
138136 d.out_pitch = s->pitch ;
139- d.in_data [0 ] = ( const unsigned char *) src->data_yuv [0 ];
140- d.in_data [1 ] = ( const unsigned char *) src->data_yuv [1 ];
141- d.in_data [2 ] = ( const unsigned char *) src->data_yuv [2 ];
137+ d.in_data [0 ] = static_cast < const unsigned char *>( src->data_yuv [0 ]) ;
138+ d.in_data [1 ] = static_cast < const unsigned char *>( src->data_yuv [1 ]) ;
139+ d.in_data [2 ] = static_cast < const unsigned char *>( src->data_yuv [2 ]) ;
142140 d.in_linesize [0 ] = src->stride [0 ] * in_bpp;
143141 d.in_linesize [1 ] = src->stride [1 ] * in_bpp;
144142 d.in_linesize [2 ] = src->stride [2 ] * in_bpp;
@@ -154,13 +152,13 @@ jpegxs_to_uv_convert(struct state_decompress_jpegxs *s,
154152 decode_planar_parallel (conv->convert , d, num_threads);
155153}
156154
157- static void *jpegxs_decompress_init (void ) {
158- struct state_decompress_jpegxs *s = new state_decompress_jpegxs ();
155+ static void *jpegxs_decompress_init () {
156+ auto *s = new state_decompress_jpegxs ();
159157
160158 return s;
161159}
162160
163- static bool configure_with (struct state_decompress_jpegxs *s, unsigned char *bitstream_buffer, size_t codestream_size)
161+ static bool configure_with (state_decompress_jpegxs *s, unsigned char *bitstream_buffer, size_t codestream_size)
164162{
165163 assert (s->out_codec != VC_NONE );
166164
@@ -193,14 +191,15 @@ static bool configure_with(struct state_decompress_jpegxs *s, unsigned char *bit
193191static int jpegxs_decompress_reconfigure (void *state, struct video_desc desc,
194192 int rshift, int gshift, int bshift, int pitch, codec_t out_codec)
195193{
196- struct state_decompress_jpegxs * s = ( struct state_decompress_jpegxs *) state;
194+ auto s = static_cast < struct state_decompress_jpegxs *>( state) ;
197195
198- if (s->out_codec == out_codec &&
196+ if (s->out_codec == out_codec &&
199197 s->pitch == pitch &&
200198 s->rshift == rshift &&
201199 s->gshift == gshift &&
202200 s->bshift == bshift &&
203- video_desc_eq_excl_param (s->desc , desc, PARAM_INTERLACING )) {
201+ video_desc_eq_excl_param (s->desc , desc, PARAM_INTERLACING ))
202+ {
204203 return true ;
205204 }
206205
@@ -226,7 +225,7 @@ static int jpegxs_decompress_reconfigure(void *state, struct video_desc desc,
226225 return true ;
227226}
228227
229- static decompress_status jpegxs_probe_internal_codec (struct state_decompress_jpegxs *s, struct pixfmt_desc *internal_prop, unsigned char *buffer, size_t buffer_size)
228+ static decompress_status jpegxs_probe_internal_codec (state_decompress_jpegxs *s, pixfmt_desc *internal_prop, unsigned char *buffer, size_t buffer_size)
230229{
231230 uint32_t size;
232231 SvtJxsErrorType_t err = svt_jpeg_xs_decoder_get_single_frame_size (buffer, buffer_size, &s->image_config , &size, 0 );
@@ -259,11 +258,9 @@ static decompress_status jpegxs_probe_internal_codec(struct state_decompress_jpe
259258}
260259
261260static decompress_status jpegxs_decompress (void *state, unsigned char *dst, unsigned char *buffer,
262- unsigned int src_len, int frame_seq, struct video_frame_callbacks *callbacks, struct pixfmt_desc *internal_prop)
261+ unsigned int src_len, int /* frame_seq*/ , video_frame_callbacks * /* callbacks*/ , struct pixfmt_desc *internal_prop)
263262{
264- UNUSED (frame_seq);
265- UNUSED (callbacks);
266- auto *s = (struct state_decompress_jpegxs *) state;
263+ auto *s = static_cast <struct state_decompress_jpegxs *>(state);
267264
268265 if (s->out_codec == VIDEO_CODEC_NONE ) {
269266 return jpegxs_probe_internal_codec (s, internal_prop, buffer, src_len);
@@ -311,10 +308,8 @@ static decompress_status jpegxs_decompress(void *state, unsigned char *dst, unsi
311308 return DECODER_GOT_FRAME ;
312309}
313310
314- static int jpegxs_decompress_get_property (void *state, int property, void *val, size_t *len)
311+ static int jpegxs_decompress_get_property (void */* state*/ , int property, void *val, size_t *len)
315312{
316- struct state_decompress *s = (struct state_decompress *) state;
317- UNUSED (s);
318313 int ret = false ;
319314
320315 switch (property) {
@@ -333,7 +328,8 @@ static int jpegxs_decompress_get_property(void *state, int property, void *val,
333328}
334329
335330static void jpegxs_decompress_done (void *state) {
336- delete (struct state_decompress_jpegxs *) state;
331+ auto s = static_cast <state_decompress_jpegxs *>(state);
332+ delete s;
337333}
338334
339335static enum subsampling
@@ -380,7 +376,7 @@ static int jpegxs_decompress_get_priority(codec_t compression, struct pixfmt_des
380376 return VDEC_PRIO_PREFERRED ;
381377}
382378
383- static const struct video_decompress_info jpegxs_info = {
379+ static constexpr video_decompress_info jpegxs_info = {
384380 jpegxs_decompress_init,
385381 jpegxs_decompress_reconfigure,
386382 jpegxs_decompress,
0 commit comments