@@ -331,30 +331,30 @@ class RocJpegUtils {
331
331
switch (subsampling) {
332
332
case ROCJPEG_CSS_444:
333
333
num_channels = 3 ;
334
- output_image.pitch [2 ] = output_image.pitch [1 ] = output_image.pitch [0 ] = is_roi_valid ? roi_width : widths[0 ];
335
- channel_sizes[2 ] = channel_sizes[1 ] = channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
334
+ output_image.pitch [2 ] = output_image.pitch [1 ] = output_image.pitch [0 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ;
335
+ channel_sizes[2 ] = channel_sizes[1 ] = channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
336
336
break ;
337
337
case ROCJPEG_CSS_440:
338
338
num_channels = 3 ;
339
- output_image.pitch [2 ] = output_image.pitch [1 ] = output_image.pitch [0 ] = is_roi_valid ? roi_width : widths[0 ];
340
- channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
341
- channel_sizes[2 ] = channel_sizes[1 ] = align ( output_image.pitch [0 ] * ((is_roi_valid ? roi_height : heights[0 ]) >> 1 ), mem_alignment );
339
+ output_image.pitch [2 ] = output_image.pitch [1 ] = output_image.pitch [0 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ;
340
+ channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
341
+ channel_sizes[2 ] = channel_sizes[1 ] = output_image.pitch [0 ] * ((is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment)) >> 1 );
342
342
break ;
343
343
case ROCJPEG_CSS_422:
344
344
num_channels = 1 ;
345
- output_image.pitch [0 ] = (is_roi_valid ? roi_width : widths[0 ]) * 2 ;
346
- channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
345
+ output_image.pitch [0 ] = (is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ) * 2 ;
346
+ channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
347
347
break ;
348
348
case ROCJPEG_CSS_420:
349
349
num_channels = 2 ;
350
- output_image.pitch [1 ] = output_image.pitch [0 ] = is_roi_valid ? roi_width : widths[0 ];
351
- channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
352
- channel_sizes[1 ] = align ( output_image.pitch [1 ] * ((is_roi_valid ? roi_height : heights[0 ]) >> 1 ), mem_alignment );
350
+ output_image.pitch [1 ] = output_image.pitch [0 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ;
351
+ channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
352
+ channel_sizes[1 ] = output_image.pitch [1 ] * ((is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment)) >> 1 );
353
353
break ;
354
354
case ROCJPEG_CSS_400:
355
355
num_channels = 1 ;
356
- output_image.pitch [0 ] = is_roi_valid ? roi_width : widths[0 ];
357
- channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
356
+ output_image.pitch [0 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ;
357
+ channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
358
358
break ;
359
359
default :
360
360
std::cout << " Unknown chroma subsampling!" << std::endl;
@@ -364,32 +364,32 @@ class RocJpegUtils {
364
364
case ROCJPEG_OUTPUT_YUV_PLANAR:
365
365
if (subsampling == ROCJPEG_CSS_400) {
366
366
num_channels = 1 ;
367
- output_image.pitch [0 ] = is_roi_valid ? roi_width : widths[0 ];
368
- channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
367
+ output_image.pitch [0 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ;
368
+ channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
369
369
} else {
370
370
num_channels = 3 ;
371
- output_image.pitch [0 ] = is_roi_valid ? roi_width : widths[0 ];
372
- output_image.pitch [1 ] = is_roi_valid ? roi_width : widths[1 ];
373
- output_image.pitch [2 ] = is_roi_valid ? roi_width : widths[2 ];
374
- channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
375
- channel_sizes[1 ] = align ( output_image.pitch [1 ] * (is_roi_valid ? roi_height : heights[1 ]) , mem_alignment);
376
- channel_sizes[2 ] = align ( output_image.pitch [2 ] * (is_roi_valid ? roi_height : heights[2 ]) , mem_alignment);
371
+ output_image.pitch [0 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ;
372
+ output_image.pitch [1 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[1 ], mem_alignment) ;
373
+ output_image.pitch [2 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[2 ], mem_alignment) ;
374
+ channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
375
+ channel_sizes[1 ] = output_image.pitch [1 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[1 ], mem_alignment) );
376
+ channel_sizes[2 ] = output_image.pitch [2 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[2 ], mem_alignment) );
377
377
}
378
378
break ;
379
379
case ROCJPEG_OUTPUT_Y:
380
380
num_channels = 1 ;
381
- output_image.pitch [0 ] = is_roi_valid ? roi_width : widths[0 ];
382
- channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
381
+ output_image.pitch [0 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ;
382
+ channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
383
383
break ;
384
384
case ROCJPEG_OUTPUT_RGB:
385
385
num_channels = 1 ;
386
- output_image.pitch [0 ] = (is_roi_valid ? roi_width : widths[0 ]) * 3 ;
387
- channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
386
+ output_image.pitch [0 ] = (is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ) * 3 ;
387
+ channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
388
388
break ;
389
389
case ROCJPEG_OUTPUT_RGB_PLANAR:
390
390
num_channels = 3 ;
391
- output_image.pitch [2 ] = output_image.pitch [1 ] = output_image.pitch [0 ] = is_roi_valid ? roi_width : widths[0 ];
392
- channel_sizes[2 ] = channel_sizes[1 ] = channel_sizes[0 ] = align ( output_image.pitch [0 ] * (is_roi_valid ? roi_height : heights[0 ]) , mem_alignment);
391
+ output_image.pitch [2 ] = output_image.pitch [1 ] = output_image.pitch [0 ] = is_roi_valid ? align ( roi_width, mem_alignment) : align ( widths[0 ], mem_alignment) ;
392
+ channel_sizes[2 ] = channel_sizes[1 ] = channel_sizes[0 ] = output_image.pitch [0 ] * (is_roi_valid ? align ( roi_height, mem_alignment) : align ( heights[0 ], mem_alignment) );
393
393
break ;
394
394
default :
395
395
std::cout << " Unknown output format!" << std::endl;
@@ -567,9 +567,9 @@ class RocJpegUtils {
567
567
return ;
568
568
}
569
569
570
- uint32_t channel0_size = output_image->pitch [0 ] * heights[0 ];
571
- uint32_t channel1_size = output_image->pitch [1 ] * heights[1 ];
572
- uint32_t channel2_size = output_image->pitch [2 ] * heights[2 ];
570
+ uint32_t channel0_size = output_image->pitch [0 ] * align ( heights[0 ], mem_alignment) ;
571
+ uint32_t channel1_size = output_image->pitch [1 ] * align ( heights[1 ], mem_alignment) ;
572
+ uint32_t channel2_size = output_image->pitch [2 ] * align ( heights[2 ], mem_alignment) ;
573
573
574
574
uint32_t output_image_size = channel0_size + channel1_size + channel2_size;
575
575
@@ -628,7 +628,7 @@ class RocJpegUtils {
628
628
}
629
629
630
630
private:
631
- static const int mem_alignment = 4 * 1024 * 1024 ;
631
+ static const int mem_alignment = 16 ;
632
632
/* *
633
633
* @brief Shows the help message and exits.
634
634
*
0 commit comments