Skip to content

Commit c35b498

Browse files
committed
decoder: handle width_padding
added by the commit a12554c (2024-09-24) for encoder
1 parent 9bb28ad commit c35b498

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/gpujpeg_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file
3-
* Copyright (c) 2011-2024, CESNET
3+
* Copyright (c) 2011-2025, CESNET
44
* Copyright (c) 2011, Silicon Genome, LLC.
55
*
66
* All rights reserved.
@@ -1131,7 +1131,7 @@ gpujpeg_image_calculate_size(struct gpujpeg_image_parameters* param)
11311131
{
11321132
int bpp = gpujpeg_pixel_format_get_unit_size(param->pixel_format);
11331133
if (bpp != 0) {
1134-
return (size_t) param->width * param->height * bpp;
1134+
return ((size_t) param->width + param->width_padding) * param->height * bpp;
11351135
}
11361136
const int comp_count = gpujpeg_pixel_format_get_comp_count(param->pixel_format);
11371137
switch ( param->pixel_format ) {

src/gpujpeg_decoder.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ gpujpeg_decoder_init(struct gpujpeg_decoder* decoder, const struct gpujpeg_param
194194
// Check if (re)inialization is needed
195195
int change = 0;
196196
change |= coder->param_image.width != param_image->width;
197+
change |= coder->param_image.width_padding != param_image->width_padding;
197198
change |= coder->param_image.height != param_image->height;
198199
change |= coder->param.comp_count != param->comp_count;
199200
change |= coder->param.restart_interval != param->restart_interval;

src/gpujpeg_postprocessor.cu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ gpujpeg_preprocessor_decoder_copy_planar_data(struct gpujpeg_coder * coder, cuda
457457
size_t data_raw_offset = 0;
458458
bool needs_stride = false; // true if width is not divisible by MCU width
459459
for ( int i = 0; i < coder->param.comp_count; ++i ) {
460-
needs_stride = needs_stride || coder->component[i].width != coder->component[i].data_width;
460+
int component_width = coder->component[i].width + coder->param_image.width_padding;
461+
needs_stride = needs_stride || component_width != coder->component[i].data_width;
461462
}
462463
if (!needs_stride) {
463464
for ( int i = 0; i < coder->param.comp_count; ++i ) {
@@ -490,7 +491,7 @@ gpujpeg_postprocessor_decode(struct gpujpeg_coder* coder, cudaStream_t stream)
490491
gpujpeg_preprocessor_decode_kernel kernel = (gpujpeg_preprocessor_decode_kernel)coder->preprocessor;
491492
assert(kernel != NULL);
492493

493-
int image_width = coder->param_image.width;
494+
int image_width = coder->param_image.width + coder->param_image.width_padding;
494495
int image_height = coder->param_image.height;
495496

496497
// When saving 4:2:2 data of odd width, the data should have even width, so round it

0 commit comments

Comments
 (0)