Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
afad1029
Commit
afad1029
authored
Jun 14, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2146 from cudawarped:update_codecs_nvcuvid
parents
74ea5dec
66aba496
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
17 deletions
+54
-17
cudacodec.hpp
modules/cudacodec/include/opencv2/cudacodec.hpp
+4
-0
perf_video.cpp
modules/cudacodec/perf/perf_video.cpp
+1
-1
cuvid_video_source.cpp
modules/cudacodec/src/cuvid_video_source.cpp
+1
-0
ffmpeg_video_source.cpp
modules/cudacodec/src/ffmpeg_video_source.cpp
+1
-0
video_decoder.cpp
modules/cudacodec/src/video_decoder.cpp
+47
-16
No files found.
modules/cudacodec/include/opencv2/cudacodec.hpp
View file @
afad1029
...
...
@@ -250,6 +250,9 @@ enum Codec
JPEG
,
H264_SVC
,
H264_MVC
,
HEVC
,
VP8
,
VP9
,
Uncompressed_YUV420
=
((
'I'
<<
24
)
|
(
'Y'
<<
16
)
|
(
'U'
<<
8
)
|
(
'V'
)),
//!< Y,U,V (4:2:0)
Uncompressed_YV12
=
((
'Y'
<<
24
)
|
(
'V'
<<
16
)
|
(
'1'
<<
8
)
|
(
'2'
)),
//!< Y,V,U (4:2:0)
...
...
@@ -274,6 +277,7 @@ struct FormatInfo
{
Codec
codec
;
ChromaFormat
chromaFormat
;
int
nBitDepthMinus8
;
int
width
;
int
height
;
};
...
...
modules/cudacodec/perf/perf_video.cpp
View file @
afad1029
...
...
@@ -51,7 +51,7 @@ DEF_PARAM_TEST_1(FileName, string);
//////////////////////////////////////////////////////
// VideoReader
#if defined(HAVE_NVCUVID)
&& defined(HAVE_VIDEO_INPUT)
#if defined(HAVE_NVCUVID)
PERF_TEST_P
(
FileName
,
VideoReader
,
Values
(
"gpu/video/768x576.avi"
,
"gpu/video/1920x1080.avi"
))
{
...
...
modules/cudacodec/src/cuvid_video_source.cpp
View file @
afad1029
...
...
@@ -70,6 +70,7 @@ cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource(const String& fname)
format_
.
codec
=
static_cast
<
Codec
>
(
vidfmt
.
codec
);
format_
.
chromaFormat
=
static_cast
<
ChromaFormat
>
(
vidfmt
.
chroma_format
);
format_
.
nBitDepthMinus8
=
vidfmt
.
bit_depth_luma_minus8
;
format_
.
width
=
vidfmt
.
coded_width
;
format_
.
height
=
vidfmt
.
coded_height
;
}
...
...
modules/cudacodec/src/ffmpeg_video_source.cpp
View file @
afad1029
...
...
@@ -111,6 +111,7 @@ cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname)
format_
.
codec
=
static_cast
<
Codec
>
(
codec
);
format_
.
chromaFormat
=
static_cast
<
ChromaFormat
>
(
chroma_format
);
format_
.
nBitDepthMinus8
=
-
1
;
format_
.
width
=
width
;
format_
.
height
=
height
;
}
...
...
modules/cudacodec/src/video_decoder.cpp
View file @
afad1029
...
...
@@ -57,22 +57,53 @@ void cv::cudacodec::detail::VideoDecoder::create(const FormatInfo& videoFormat)
cudaVideoCreate_PreferCUVID
;
// Validate video format. These are the currently supported formats via NVCUVID
CV_Assert
(
cudaVideoCodec_MPEG1
==
_codec
||
cudaVideoCodec_MPEG2
==
_codec
||
cudaVideoCodec_MPEG4
==
_codec
||
cudaVideoCodec_VC1
==
_codec
||
cudaVideoCodec_H264
==
_codec
||
cudaVideoCodec_JPEG
==
_codec
||
cudaVideoCodec_YUV420
==
_codec
||
cudaVideoCodec_YV12
==
_codec
||
cudaVideoCodec_NV12
==
_codec
||
cudaVideoCodec_YUYV
==
_codec
||
cudaVideoCodec_UYVY
==
_codec
);
CV_Assert
(
cudaVideoChromaFormat_Monochrome
==
_chromaFormat
||
cudaVideoChromaFormat_420
==
_chromaFormat
||
cudaVideoChromaFormat_422
==
_chromaFormat
||
cudaVideoChromaFormat_444
==
_chromaFormat
);
bool
codecSupported
=
cudaVideoCodec_MPEG1
==
_codec
||
cudaVideoCodec_MPEG2
==
_codec
||
cudaVideoCodec_MPEG4
==
_codec
||
cudaVideoCodec_VC1
==
_codec
||
cudaVideoCodec_H264
==
_codec
||
cudaVideoCodec_JPEG
==
_codec
||
cudaVideoCodec_H264_SVC
==
_codec
||
cudaVideoCodec_H264_MVC
==
_codec
||
cudaVideoCodec_YV12
==
_codec
||
cudaVideoCodec_NV12
==
_codec
||
cudaVideoCodec_YUYV
==
_codec
||
cudaVideoCodec_UYVY
==
_codec
;
#if defined (HAVE_CUDA)
#if (CUDART_VERSION >= 6500)
codecSupported
|=
cudaVideoCodec_HEVC
==
_codec
;
#endif
#if ((CUDART_VERSION == 7500) || (CUDART_VERSION >= 9000))
codecSupported
|=
cudaVideoCodec_VP8
==
_codec
||
cudaVideoCodec_VP9
==
_codec
||
cudaVideoCodec_YUV420
==
_codec
;
#endif
#endif
CV_Assert
(
codecSupported
);
CV_Assert
(
cudaVideoChromaFormat_Monochrome
==
_chromaFormat
||
cudaVideoChromaFormat_420
==
_chromaFormat
||
cudaVideoChromaFormat_422
==
_chromaFormat
||
cudaVideoChromaFormat_444
==
_chromaFormat
);
#if (CUDART_VERSION >= 9000)
// Check video format is supported by GPU's hardware video decoder
if
(
videoFormat
.
nBitDepthMinus8
!=
-
1
)
{
// info not available call to create CuvidVideoSource() failed
CUVIDDECODECAPS
decodeCaps
=
{};
decodeCaps
.
eCodecType
=
_codec
;
decodeCaps
.
eChromaFormat
=
_chromaFormat
;
decodeCaps
.
nBitDepthMinus8
=
videoFormat
.
nBitDepthMinus8
;
cuSafeCall
(
cuvidGetDecoderCaps
(
&
decodeCaps
));
if
(
!
decodeCaps
.
bIsSupported
)
CV_Error
(
Error
::
StsUnsupportedFormat
,
"Video source is not supported by hardware video decoder"
);
CV_Assert
(
videoFormat
.
width
>=
decodeCaps
.
nMinWidth
&&
videoFormat
.
height
>=
decodeCaps
.
nMinHeight
&&
videoFormat
.
width
<=
decodeCaps
.
nMaxWidth
&&
videoFormat
.
height
<=
decodeCaps
.
nMaxHeight
);
}
#endif
// Fill the decoder-create-info struct from the given video-format struct.
std
::
memset
(
&
createInfo_
,
0
,
sizeof
(
CUVIDDECODECREATEINFO
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment