Add support for YUV440 (#28)

* Add support for YUV440

* Add YUV440 to RGB kernels

* code clean up

[ROCm/rocjpeg commit: d0b812bc26]
This commit is contained in:
Aryan Salmanpour
2024-05-30 22:00:07 -04:00
committed by GitHub
parent 4f5187a2ae
commit 048d2d8fca
11 changed files with 546 additions and 18 deletions
@@ -91,7 +91,7 @@ int main(int argc, char **argv) {
std::cout << "Input file name: " << base_file_name << std::endl;
std::cout << "Input image resolution: " << widths[0] << "x" << heights[0] << std::endl;
std::cout << "Chroma subsampling: " + chroma_sub_sampling << std::endl;
if (subsampling == ROCJPEG_CSS_440 || subsampling == ROCJPEG_CSS_411) {
if (subsampling == ROCJPEG_CSS_411) {
std::cerr << "The chroma sub-sampling is not supported by VCN Hardware" << std::endl;
if (is_dir) {
std::cout << std::endl;
@@ -71,7 +71,7 @@ void ThreadFunction(std::vector<std::string>& jpegFiles, RocJpegHandle rocjpeg_h
CHECK_ROCJPEG(rocJpegStreamParse(reinterpret_cast<uint8_t *>(file_data.data()), file_size, rocjpeg_stream));
CHECK_ROCJPEG(rocJpegGetImageInfo(rocjpeg_handle, rocjpeg_stream, &num_components, &subsampling, widths, heights));
if (subsampling == ROCJPEG_CSS_440 || subsampling == ROCJPEG_CSS_411) {
if (subsampling == ROCJPEG_CSS_411) {
std::cout << "The chroma sub-sampling is not supported by VCN Hardware" << std::endl;
std::cout << "Skipping decoding file " << base_file_name << std::endl;
return;
@@ -276,6 +276,12 @@ public:
output_image.pitch[2] = output_image.pitch[1] = output_image.pitch[0] = widths[0];
channel_sizes[2] = channel_sizes[1] = channel_sizes[0] = output_image.pitch[0] * heights[0];
break;
case ROCJPEG_CSS_440:
num_channels = 3;
output_image.pitch[2] = output_image.pitch[1] = output_image.pitch[0] = widths[0];
channel_sizes[0] = output_image.pitch[0] * heights[0];
channel_sizes[2] = channel_sizes[1] = output_image.pitch[0] * (heights[0] >> 1);
break;
case ROCJPEG_CSS_422:
num_channels = 1;
output_image.pitch[0] = widths[0] * 2;
@@ -407,6 +413,11 @@ public:
widths[2] = widths[1] = widths[0] = img_width;
heights[2] = heights[1] = heights[0] = img_height;
break;
case ROCJPEG_CSS_440:
widths[2] = widths[1] = widths[0] = img_width;
heights[0] = img_height;
heights[2] = heights[1] = img_height >> 1;
break;
case ROCJPEG_CSS_422:
widths[0] = img_width * 2;
heights[0] = img_height;
@@ -431,6 +442,11 @@ public:
widths[2] = widths[1] = widths[0] = img_width;
heights[2] = heights[1] = heights[0] = img_height;
break;
case ROCJPEG_CSS_440:
widths[2] = widths[1] = widths[0] = img_width;
heights[0] = img_height;
heights[2] = heights[1] = img_height >> 1;
break;
case ROCJPEG_CSS_422:
widths[0] = img_width;
widths[2] = widths[1] = widths[0] >> 1;