@@ -58,6 +58,10 @@ PARAM_TEST_CASE(Scaling, cv::cuda::DeviceInfo, std::string, Size2f, Rect2f, Rect
5858{
5959};
6060
61+ struct DisplayResolution : testing::TestWithParam<cv::cuda::DeviceInfo>
62+ {
63+ };
64+
6165PARAM_TEST_CASE (Video, cv::cuda::DeviceInfo, std::string)
6266{
6367};
@@ -223,6 +227,37 @@ CUDA_TEST_P(Scaling, Reader)
223227 ASSERT_LT (mae, 2.35 );
224228}
225229
230+ CUDA_TEST_P (DisplayResolution, Reader)
231+ {
232+ cv::cuda::setDevice (GetParam ().deviceID ());
233+ std::string inputFile = std::string (cvtest::TS::ptr ()->get_data_path ()) + " ../cv/video/1920x1080.avi" ;
234+ const Rect displayArea (0 , 0 , 1920 , 1080 );
235+ GpuMat frame;
236+
237+ {
238+ // verify the output frame is the diplay size (1920x1080) and not the coded size (1920x1088)
239+ cv::Ptr<cv::cudacodec::VideoReader> reader = cv::cudacodec::createVideoReader (inputFile);
240+ reader->set (cudacodec::ColorFormat::GRAY);
241+ ASSERT_TRUE (reader->nextFrame (frame));
242+ const cudacodec::FormatInfo format = reader->format ();
243+ ASSERT_TRUE (format.displayArea == displayArea);
244+ ASSERT_TRUE (frame.size () == displayArea.size () && frame.size () == format.targetSz );
245+ }
246+
247+ {
248+ // extra check to verify display frame has not been post-processed and is just a cropped version of the coded sized frame
249+ cudacodec::VideoReaderInitParams params;
250+ params.srcRoi = Rect (0 , 0 , 1920 , 1088 );
251+ cv::Ptr<cv::cudacodec::VideoReader> readerCodedSz = cv::cudacodec::createVideoReader (inputFile, {}, params);
252+ readerCodedSz->set (cudacodec::ColorFormat::GRAY);
253+ GpuMat frameCodedSz;
254+ ASSERT_TRUE (readerCodedSz->nextFrame (frameCodedSz));
255+ const cudacodec::FormatInfo formatCodedSz = readerCodedSz->format ();
256+ const double err = cv::cuda::norm (frame, frameCodedSz (displayArea), NORM_INF);
257+ ASSERT_TRUE (err == 0 );
258+ }
259+ }
260+
226261CUDA_TEST_P (Video, Reader)
227262{
228263 cv::cuda::setDevice (GET_PARAM (0 ).deviceID ());
@@ -664,6 +699,8 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckSet, testing::Combine(
664699INSTANTIATE_TEST_CASE_P(CUDA_Codec, Scaling, testing::Combine(
665700 ALL_DEVICES, testing::Values(VIDEO_SRC_SCALING), testing::Values(TARGET_SZ), testing::Values(SRC_ROI), testing::Values(TARGET_ROI)));
666701
702+ INSTANTIATE_TEST_CASE_P (CUDA_Codec, DisplayResolution, ALL_DEVICES);
703+
667704#define VIDEO_SRC_R " highgui/video/big_buck_bunny.mp4" , " cv/video/768x576.avi" , " cv/video/1920x1080.avi" , " highgui/video/big_buck_bunny.avi" , \
668705 " highgui/video/big_buck_bunny.h264" , " highgui/video/big_buck_bunny.h265" , " highgui/video/big_buck_bunny.mpg" , \
669706 " highgui/video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4" , " highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4" , \
0 commit comments