From 45b79440648aa85f278f9ceb2bbb44855465f3f0 Mon Sep 17 00:00:00 2001 From: Aryan Salmanpour Date: Thu, 25 Jul 2024 14:04:20 -0400 Subject: [PATCH] Samples - updates & fixes (#47) * Samples - updates & fixes * use std::cerr --- samples/jpegDecode/jpegdecode.cpp | 10 +++++++++- samples/jpegDecodeBatched/jpegdecodebatched.cpp | 11 ++++++++++- .../jpegdecodemultithreads.cpp | 14 ++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/samples/jpegDecode/jpegdecode.cpp b/samples/jpegDecode/jpegdecode.cpp index fc289f8a57..7382d3006c 100644 --- a/samples/jpegDecode/jpegdecode.cpp +++ b/samples/jpegDecode/jpegdecode.cpp @@ -91,7 +91,15 @@ 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_411) { + if (widths[0] < 64 || heights[0] < 64) { + std::cerr << "The image resolution is not supported by VCN Hardware" << std::endl; + if (is_dir) { + std::cout << std::endl; + continue; + } else + return EXIT_FAILURE; + } + if (subsampling == ROCJPEG_CSS_411 || subsampling == ROCJPEG_CSS_UNKNOWN) { std::cerr << "The chroma sub-sampling is not supported by VCN Hardware" << std::endl; if (is_dir) { std::cout << std::endl; diff --git a/samples/jpegDecodeBatched/jpegdecodebatched.cpp b/samples/jpegDecodeBatched/jpegdecodebatched.cpp index 139b300767..d2c192da6b 100644 --- a/samples/jpegDecodeBatched/jpegdecodebatched.cpp +++ b/samples/jpegDecodeBatched/jpegdecodebatched.cpp @@ -104,7 +104,16 @@ int main(int argc, char **argv) { CHECK_ROCJPEG(rocJpegGetImageInfo(rocjpeg_handle, rocjpeg_stream_handles[index], &num_components, &subsamplings[index], widths[index].data(), heights[index].data())); rocjpeg_utils.GetChromaSubsamplingStr(subsamplings[index], chroma_sub_sampling); - if (subsamplings[index] == ROCJPEG_CSS_411) { + if (widths[index][0] < 64 || heights[index][0] < 64) { + std::cerr << "The image resolution is not supported by VCN Hardware" << std::endl; + if (is_dir) { + std::cout << std::endl; + continue; + } else + return EXIT_FAILURE; + } + + if (subsamplings[index] == ROCJPEG_CSS_411 || subsamplings[index] == ROCJPEG_CSS_UNKNOWN) { std::cerr << "The chroma sub-sampling is not supported by VCN Hardware" << std::endl; if (is_dir) { std::cout << std::endl; diff --git a/samples/jpegDecodeMultiThreads/jpegdecodemultithreads.cpp b/samples/jpegDecodeMultiThreads/jpegdecodemultithreads.cpp index 010c3d73c7..4f19aab7fe 100644 --- a/samples/jpegDecodeMultiThreads/jpegdecodemultithreads.cpp +++ b/samples/jpegDecodeMultiThreads/jpegdecodemultithreads.cpp @@ -71,15 +71,21 @@ void ThreadFunction(std::vector& jpegFiles, RocJpegHandle rocjpeg_h CHECK_ROCJPEG(rocJpegStreamParse(reinterpret_cast(file_data.data()), file_size, rocjpeg_stream)); CHECK_ROCJPEG(rocJpegGetImageInfo(rocjpeg_handle, rocjpeg_stream, &num_components, &subsampling, widths, heights)); - if (subsampling == ROCJPEG_CSS_411) { - std::cout << "The chroma sub-sampling is not supported by VCN Hardware" << std::endl; + if (widths[0] < 64 || heights[0] < 64) { + std::cerr << "The image resolution is not supported by VCN Hardware" << std::endl; + std::cout << "Skipping decoding file " << base_file_name << std::endl; + return; + } + + if (subsampling == ROCJPEG_CSS_411 || subsampling == ROCJPEG_CSS_UNKNOWN) { + std::cerr << "The chroma sub-sampling is not supported by VCN Hardware" << std::endl; std::cout << "Skipping decoding file " << base_file_name << std::endl; return; } if (rocjpeg_util.GetChannelPitchAndSizes(decode_params, subsampling, widths, heights, num_channels, *output_image, channel_sizes)) { - std::cerr << "ERROR: Failed to get the channel pitch and sizes" << std::endl; - return; + std::cerr << "ERROR: Failed to get the channel pitch and sizes" << std::endl; + return; } // allocate memory for each channel