未验证 提交 9c10a6d8 编写于 作者: A Alexander Smorkalov 提交者: GitHub

Merge pull request #3488 from cudawarped:fix_cudacodec_codec_resolution

`cudacodec::VideoReader` FORCC update with main #23540
...@@ -66,8 +66,10 @@ static std::string fourccToString(int fourcc) ...@@ -66,8 +66,10 @@ static std::string fourccToString(int fourcc)
(i32_c.c[3] >= ' ' && i32_c.c[3] < 128) ? i32_c.c[3] : '?'); (i32_c.c[3] >= ' ' && i32_c.c[3] < 128) ? i32_c.c[3] : '?');
} }
// handle old FFmpeg backend - remove when windows shared library is updated
#ifdef _WIN32
static static
Codec FourccToCodec(int codec) Codec FourccToCodecWin32Old(int codec)
{ {
switch (codec) switch (codec)
{ {
...@@ -100,9 +102,34 @@ Codec FourccToCodec(int codec) ...@@ -100,9 +102,34 @@ Codec FourccToCodec(int codec)
case CV_FOURCC_MACRO('a', 'v', '0', '1'): // fallthru case CV_FOURCC_MACRO('a', 'v', '0', '1'): // fallthru
case CV_FOURCC_MACRO('A', 'V', '0', '1'): return AV1; case CV_FOURCC_MACRO('A', 'V', '0', '1'): return AV1;
default: default:
break; return NumCodecs;
} }
}
#endif
static
Codec FourccToCodec(int codec)
{
#ifdef _WIN32 // handle old FFmpeg backend - remove when windows shared library is updated
Codec win32OldCodec = FourccToCodecWin32Old(codec);
if(win32OldCodec != NumCodecs)
return win32OldCodec;
#endif
switch (codec)
{
case CV_FOURCC_MACRO('m', 'p', 'g', '1'): return MPEG1;
case CV_FOURCC_MACRO('m', 'p', 'g', '2'): return MPEG2;
case CV_FOURCC_MACRO('F', 'M', 'P', '4'): return MPEG4;
case CV_FOURCC_MACRO('W', 'V', 'C', '1'): return VC1;
case CV_FOURCC_MACRO('h', '2', '6', '4'): return H264;
case CV_FOURCC_MACRO('h', 'e', 'v', 'c'): return HEVC;
case CV_FOURCC_MACRO('M', 'J', 'P', 'G'): return JPEG;
case CV_FOURCC_MACRO('V', 'P', '8', '0'): return VP8;
case CV_FOURCC_MACRO('V', 'P', '9', '0'): return VP9;
case CV_FOURCC_MACRO('A', 'V', '0', '1'): return AV1;
default:
break;
}
std::string msg = cv::format("Unknown codec FOURCC: 0x%08X (%s)", codec, fourccToString(codec).c_str()); std::string msg = cv::format("Unknown codec FOURCC: 0x%08X (%s)", codec, fourccToString(codec).c_str());
CV_LOG_WARNING(NULL, msg); CV_LOG_WARNING(NULL, msg);
CV_Error(Error::StsUnsupportedFormat, msg); CV_Error(Error::StsUnsupportedFormat, msg);
...@@ -163,7 +190,6 @@ cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname, ...@@ -163,7 +190,6 @@ cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname,
int codec = (int)cap.get(CAP_PROP_FOURCC); int codec = (int)cap.get(CAP_PROP_FOURCC);
int pixelFormat = (int)cap.get(CAP_PROP_CODEC_PIXEL_FORMAT); int pixelFormat = (int)cap.get(CAP_PROP_CODEC_PIXEL_FORMAT);
format_.codec = FourccToCodec(codec); format_.codec = FourccToCodec(codec);
format_.height = cap.get(CAP_PROP_FRAME_HEIGHT); format_.height = cap.get(CAP_PROP_FRAME_HEIGHT);
format_.width = cap.get(CAP_PROP_FRAME_WIDTH); format_.width = cap.get(CAP_PROP_FRAME_WIDTH);
......
...@@ -281,15 +281,11 @@ CUDA_TEST_P(DisplayResolution, Reader) ...@@ -281,15 +281,11 @@ CUDA_TEST_P(DisplayResolution, Reader)
CUDA_TEST_P(Video, Reader) CUDA_TEST_P(Video, Reader)
{ {
cv::cuda::setDevice(GET_PARAM(0).deviceID()); cv::cuda::setDevice(GET_PARAM(0).deviceID());
const std::string relativeFilePath = GET_PARAM(1);
// CUDA demuxer has to fall back to ffmpeg to process "cv/video/768x576.avi" // CUDA demuxer has to fall back to ffmpeg to process "cv/video/768x576.avi"
if (GET_PARAM(1) == "cv/video/768x576.avi" && !videoio_registry::hasBackend(CAP_FFMPEG)) if (relativeFilePath == "cv/video/768x576.avi" && !videoio_registry::hasBackend(CAP_FFMPEG))
throw SkipTestException("FFmpeg backend not found"); throw SkipTestException("FFmpeg backend not found - SKIP");
#ifdef _WIN32 // handle old FFmpeg backend
if (GET_PARAM(1) == "/cv/tracking/faceocc2/data/faceocc2.webm")
throw SkipTestException("Feature not yet supported by Windows FFmpeg shared library!");
#endif
const std::vector<std::pair< cudacodec::ColorFormat, int>> formatsToChannels = { const std::vector<std::pair< cudacodec::ColorFormat, int>> formatsToChannels = {
{cudacodec::ColorFormat::GRAY,1}, {cudacodec::ColorFormat::GRAY,1},
...@@ -298,7 +294,7 @@ CUDA_TEST_P(Video, Reader) ...@@ -298,7 +294,7 @@ CUDA_TEST_P(Video, Reader)
{cudacodec::ColorFormat::NV_NV12,1} {cudacodec::ColorFormat::NV_NV12,1}
}; };
std::string inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "../" + GET_PARAM(1); std::string inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "../" + relativeFilePath;
cv::Ptr<cv::cudacodec::VideoReader> reader = cv::cudacodec::createVideoReader(inputFile); cv::Ptr<cv::cudacodec::VideoReader> reader = cv::cudacodec::createVideoReader(inputFile);
ASSERT_FALSE(reader->set(cudacodec::ColorFormat::RGB)); ASSERT_FALSE(reader->set(cudacodec::ColorFormat::RGB));
cv::cudacodec::FormatInfo fmt = reader->format(); cv::cudacodec::FormatInfo fmt = reader->format();
...@@ -818,13 +814,20 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, Scaling, testing::Combine( ...@@ -818,13 +814,20 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, Scaling, testing::Combine(
INSTANTIATE_TEST_CASE_P(CUDA_Codec, DisplayResolution, ALL_DEVICES); INSTANTIATE_TEST_CASE_P(CUDA_Codec, DisplayResolution, ALL_DEVICES);
#define VIDEO_SRC_R "highgui/video/big_buck_bunny.mp4", "cv/video/768x576.avi", "cv/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \ #ifdef _WIN32 // handle old FFmpeg backend - remove when windows shared library is updated
#define VIDEO_SRC_R testing::Values("highgui/video/big_buck_bunny.mp4", "cv/video/768x576.avi", "cv/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg", \ "highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg", \
"highgui/video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4", "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4", \ "highgui/video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4")
"cv/tracking/faceocc2/data/faceocc2.webm" //, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4", \
INSTANTIATE_TEST_CASE_P(CUDA_Codec, Video, testing::Combine( "cv/tracking/faceocc2/data/faceocc2.webm")
ALL_DEVICES, #else
testing::Values(VIDEO_SRC_R))); #define VIDEO_SRC_R testing::Values("highgui/video/big_buck_bunny.mp4", "cv/video/768x576.avi", "cv/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg", \
"highgui/video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4")
//, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4", \
"cv/tracking/faceocc2/data/faceocc2.webm", "highgui/video/sample_322x242_15frames.yuv420p.mpeg2video.mp4", "highgui/video/sample_322x242_15frames.yuv420p.mjpeg.mp4")
#endif
INSTANTIATE_TEST_CASE_P(CUDA_Codec, Video, testing::Combine(ALL_DEVICES,VIDEO_SRC_R));
const color_conversion_params_t color_conversion_params[] = const color_conversion_params_t color_conversion_params[] =
{ {
...@@ -859,9 +862,11 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckExtraData, testing::Combine( ...@@ -859,9 +862,11 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckExtraData, testing::Combine(
ALL_DEVICES, ALL_DEVICES,
testing::ValuesIn(check_extra_data_params))); testing::ValuesIn(check_extra_data_params)));
#define VIDEO_SRC_KEY "highgui/video/big_buck_bunny.mp4", "cv/video/768x576.avi", "cv/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg"
INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckKeyFrame, testing::Combine( INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckKeyFrame, testing::Combine(
ALL_DEVICES, ALL_DEVICES,
testing::Values(VIDEO_SRC_R))); testing::Values(VIDEO_SRC_KEY)));
INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckParams, ALL_DEVICES); INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckParams, ALL_DEVICES);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册