Skip to content

Commit

Permalink
Add support for av1 and update fourcc mapping to deal with all combin…
Browse files Browse the repository at this point in the history
…ations of expected codecs.
  • Loading branch information
cudawarped committed Aug 5, 2022
1 parent 9d0a451 commit 9e591fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
16 changes: 14 additions & 2 deletions modules/cudacodec/src/ffmpeg_video_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ Codec FourccToCodec(int codec)
switch (codec)
{
case CV_FOURCC_MACRO('m', 'p', 'e', 'g'): // fallthru
case CV_FOURCC_MACRO('m', 'p', 'g', '1'): // fallthru
case CV_FOURCC_MACRO('M', 'P', 'G', '1'): return MPEG1;
case CV_FOURCC_MACRO('m', 'p', 'g', '2'): // fallthru
case CV_FOURCC_MACRO('M', 'P', 'G', '2'): return MPEG2;
case CV_FOURCC_MACRO('X', 'V', 'I', 'D'): // fallthru
case CV_FOURCC_MACRO('m', 'p', '4', 'v'): // fallthru
Expand All @@ -85,8 +87,18 @@ Codec FourccToCodec(int codec)
case CV_FOURCC_MACRO('h', '2', '6', '5'): // fallthru
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('v', 'p', '8', '0'): // fallthru
case CV_FOURCC_MACRO('V', 'P', '8', '0'): // fallthru
case CV_FOURCC_MACRO('v', 'p', '0', '8'): // fallthru
case CV_FOURCC_MACRO('V', 'P', '0', '8'): return VP8;
case CV_FOURCC_MACRO('v', 'p', '9', '0'): // fallthru
case CV_FOURCC_MACRO('V', 'P', '9', '0'): // fallthru
case CV_FOURCC_MACRO('V', 'P', '0', '9'): // fallthru
case CV_FOURCC_MACRO('v', 'p', '0', '9'): return VP9;
case CV_FOURCC_MACRO('a', 'v', '1', '0'): // fallthru
case CV_FOURCC_MACRO('A', 'V', '1', '0'): // fallthru
case CV_FOURCC_MACRO('a', 'v', '0', '1'): // fallthru
case CV_FOURCC_MACRO('A', 'V', '0', '1'): return AV1;
default:
break;
}
Expand Down
13 changes: 10 additions & 3 deletions modules/cudacodec/test/test_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ CUDA_TEST_P(Video, Reader)
if (GET_PARAM(1) == "cv/video/768x576.avi" && !videoio_registry::hasBackend(CAP_FFMPEG))
throw SkipTestException("FFmpeg backend not found");

#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 = {
{cudacodec::ColorFormat::GRAY,1},
{cudacodec::ColorFormat::BGR,3},
Expand All @@ -196,7 +201,7 @@ CUDA_TEST_P(Video, Reader)
cv::Ptr<cv::cudacodec::VideoReader> reader = cv::cudacodec::createVideoReader(inputFile);
cv::cudacodec::FormatInfo fmt = reader->format();
cv::cuda::GpuMat frame;
for (int i = 0; i < 100; i++)
for (int i = 0; i < 10; i++)
{
// request a different colour format for each frame
const std::pair< cudacodec::ColorFormat, int>& formatToChannels = formatsToChannels[i % formatsToChannels.size()];
Expand Down Expand Up @@ -426,8 +431,10 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckSet, testing::Combine(
ALL_DEVICES,
testing::Values("highgui/video/big_buck_bunny.mp4")));

#define VIDEO_SRC_R "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"
#define VIDEO_SRC_R "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"
INSTANTIATE_TEST_CASE_P(CUDA_Codec, Video, testing::Combine(
ALL_DEVICES,
testing::Values(VIDEO_SRC_R)));
Expand Down

0 comments on commit 9e591fb

Please sign in to comment.