Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
77a2529e
Commit
77a2529e
authored
Sep 09, 2013
by
Roman Donchenko
Committed by
OpenCV Buildbot
Sep 09, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1408 from jet47:new-ptr-fixes
parents
74578f56
6ad72bfc
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
32 deletions
+38
-32
opengl_interop.rst
modules/core/doc/opengl_interop.rst
+4
-0
opengl.cpp
modules/core/src/opengl.cpp
+12
-12
video_reader.cpp
modules/gpucodec/src/video_reader.cpp
+19
-17
video_source.cpp
modules/gpucodec/src/video_source.cpp
+1
-1
video_writer.cpp
modules/gpucodec/src/video_writer.cpp
+2
-2
No files found.
modules/core/doc/opengl_interop.rst
View file @
77a2529e
...
@@ -122,6 +122,8 @@ Decrements the reference counter and destroys the buffer object if needed.
...
@@ -122,6 +122,8 @@ Decrements the reference counter and destroys the buffer object if needed.
.. ocv:function:: void ogl::Buffer::release()
.. ocv:function:: void ogl::Buffer::release()
The function will call `setAutoRelease(true)` .
ogl::Buffer::setAutoRelease
ogl::Buffer::setAutoRelease
...
@@ -323,6 +325,8 @@ Decrements the reference counter and destroys the texture object if needed.
...
@@ -323,6 +325,8 @@ Decrements the reference counter and destroys the texture object if needed.
.. ocv:function:: void ogl::Texture2D::release()
.. ocv:function:: void ogl::Texture2D::release()
The function will call `setAutoRelease(true)` .
ogl::Texture2D::setAutoRelease
ogl::Texture2D::setAutoRelease
...
...
modules/core/src/opengl.cpp
View file @
77a2529e
...
@@ -484,7 +484,7 @@ cv::ogl::Buffer::Buffer(int arows, int acols, int atype, unsigned int abufId, bo
...
@@ -484,7 +484,7 @@ cv::ogl::Buffer::Buffer(int arows, int acols, int atype, unsigned int abufId, bo
(
void
)
autoRelease
;
(
void
)
autoRelease
;
throw_no_ogl
();
throw_no_ogl
();
#else
#else
impl_
=
new
Impl
(
abufId
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
abufId
,
autoRelease
)
);
rows_
=
arows
;
rows_
=
arows
;
cols_
=
acols
;
cols_
=
acols
;
type_
=
atype
;
type_
=
atype
;
...
@@ -500,7 +500,7 @@ cv::ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRel
...
@@ -500,7 +500,7 @@ cv::ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRel
(
void
)
autoRelease
;
(
void
)
autoRelease
;
throw_no_ogl
();
throw_no_ogl
();
#else
#else
impl_
=
new
Impl
(
abufId
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
abufId
,
autoRelease
)
);
rows_
=
asize
.
height
;
rows_
=
asize
.
height
;
cols_
=
asize
.
width
;
cols_
=
asize
.
width
;
type_
=
atype
;
type_
=
atype
;
...
@@ -529,7 +529,7 @@ cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_
...
@@ -529,7 +529,7 @@ cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_
Mat
mat
=
arr
.
getMat
();
Mat
mat
=
arr
.
getMat
();
CV_Assert
(
mat
.
isContinuous
()
);
CV_Assert
(
mat
.
isContinuous
()
);
const
GLsizeiptr
asize
=
mat
.
rows
*
mat
.
cols
*
mat
.
elemSize
();
const
GLsizeiptr
asize
=
mat
.
rows
*
mat
.
cols
*
mat
.
elemSize
();
impl_
=
new
Impl
(
asize
,
mat
.
data
,
target
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
asize
,
mat
.
data
,
target
,
autoRelease
)
);
rows_
=
mat
.
rows
;
rows_
=
mat
.
rows
;
cols_
=
mat
.
cols
;
cols_
=
mat
.
cols
;
type_
=
mat
.
type
();
type_
=
mat
.
type
();
...
@@ -552,7 +552,7 @@ void cv::ogl::Buffer::create(int arows, int acols, int atype, Target target, boo
...
@@ -552,7 +552,7 @@ void cv::ogl::Buffer::create(int arows, int acols, int atype, Target target, boo
if
(
rows_
!=
arows
||
cols_
!=
acols
||
type_
!=
atype
)
if
(
rows_
!=
arows
||
cols_
!=
acols
||
type_
!=
atype
)
{
{
const
GLsizeiptr
asize
=
arows
*
acols
*
CV_ELEM_SIZE
(
atype
);
const
GLsizeiptr
asize
=
arows
*
acols
*
CV_ELEM_SIZE
(
atype
);
impl_
=
new
Impl
(
asize
,
0
,
target
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
asize
,
0
,
target
,
autoRelease
)
);
rows_
=
arows
;
rows_
=
arows
;
cols_
=
acols
;
cols_
=
acols
;
type_
=
atype
;
type_
=
atype
;
...
@@ -563,7 +563,7 @@ void cv::ogl::Buffer::create(int arows, int acols, int atype, Target target, boo
...
@@ -563,7 +563,7 @@ void cv::ogl::Buffer::create(int arows, int acols, int atype, Target target, boo
void
cv
::
ogl
::
Buffer
::
release
()
void
cv
::
ogl
::
Buffer
::
release
()
{
{
#ifdef HAVE_OPENGL
#ifdef HAVE_OPENGL
if
(
*
impl_
.
refcount
==
1
)
if
(
impl_
)
impl_
->
setAutoRelease
(
true
);
impl_
->
setAutoRelease
(
true
);
impl_
=
Impl
::
empty
();
impl_
=
Impl
::
empty
();
rows_
=
0
;
rows_
=
0
;
...
@@ -968,7 +968,7 @@ cv::ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, unsigned int
...
@@ -968,7 +968,7 @@ cv::ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, unsigned int
(
void
)
autoRelease
;
(
void
)
autoRelease
;
throw_no_ogl
();
throw_no_ogl
();
#else
#else
impl_
=
new
Impl
(
atexId
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
atexId
,
autoRelease
)
);
rows_
=
arows
;
rows_
=
arows
;
cols_
=
acols
;
cols_
=
acols
;
format_
=
aformat
;
format_
=
aformat
;
...
@@ -984,7 +984,7 @@ cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, unsigned int atexId, b
...
@@ -984,7 +984,7 @@ cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, unsigned int atexId, b
(
void
)
autoRelease
;
(
void
)
autoRelease
;
throw_no_ogl
();
throw_no_ogl
();
#else
#else
impl_
=
new
Impl
(
atexId
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
atexId
,
autoRelease
)
);
rows_
=
asize
.
height
;
rows_
=
asize
.
height
;
cols_
=
asize
.
width
;
cols_
=
asize
.
width
;
format_
=
aformat
;
format_
=
aformat
;
...
@@ -1024,7 +1024,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols
...
@@ -1024,7 +1024,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols
{
{
ogl
::
Buffer
buf
=
arr
.
getOGlBuffer
();
ogl
::
Buffer
buf
=
arr
.
getOGlBuffer
();
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
=
new
Impl
(
internalFormats
[
cn
],
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
0
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
internalFormats
[
cn
],
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
0
,
autoRelease
)
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
break
;
break
;
}
}
...
@@ -1037,7 +1037,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols
...
@@ -1037,7 +1037,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols
GpuMat
dmat
=
arr
.
getGpuMat
();
GpuMat
dmat
=
arr
.
getGpuMat
();
ogl
::
Buffer
buf
(
dmat
,
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
buf
(
dmat
,
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
=
new
Impl
(
internalFormats
[
cn
],
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
0
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
internalFormats
[
cn
],
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
0
,
autoRelease
)
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
#endif
#endif
...
@@ -1049,7 +1049,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols
...
@@ -1049,7 +1049,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols
Mat
mat
=
arr
.
getMat
();
Mat
mat
=
arr
.
getMat
();
CV_Assert
(
mat
.
isContinuous
()
);
CV_Assert
(
mat
.
isContinuous
()
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
=
new
Impl
(
internalFormats
[
cn
],
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
mat
.
data
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
internalFormats
[
cn
],
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
mat
.
data
,
autoRelease
)
);
break
;
break
;
}
}
}
}
...
@@ -1072,7 +1072,7 @@ void cv::ogl::Texture2D::create(int arows, int acols, Format aformat, bool autoR
...
@@ -1072,7 +1072,7 @@ void cv::ogl::Texture2D::create(int arows, int acols, Format aformat, bool autoR
if
(
rows_
!=
arows
||
cols_
!=
acols
||
format_
!=
aformat
)
if
(
rows_
!=
arows
||
cols_
!=
acols
||
format_
!=
aformat
)
{
{
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
=
new
Impl
(
aformat
,
acols
,
arows
,
aformat
,
gl
::
FLOAT
,
0
,
autoRelease
);
impl_
.
reset
(
new
Impl
(
aformat
,
acols
,
arows
,
aformat
,
gl
::
FLOAT
,
0
,
autoRelease
)
);
rows_
=
arows
;
rows_
=
arows
;
cols_
=
acols
;
cols_
=
acols
;
format_
=
aformat
;
format_
=
aformat
;
...
@@ -1083,7 +1083,7 @@ void cv::ogl::Texture2D::create(int arows, int acols, Format aformat, bool autoR
...
@@ -1083,7 +1083,7 @@ void cv::ogl::Texture2D::create(int arows, int acols, Format aformat, bool autoR
void
cv
::
ogl
::
Texture2D
::
release
()
void
cv
::
ogl
::
Texture2D
::
release
()
{
{
#ifdef HAVE_OPENGL
#ifdef HAVE_OPENGL
if
(
*
impl_
.
refcount
==
1
)
if
(
impl_
)
impl_
->
setAutoRelease
(
true
);
impl_
->
setAutoRelease
(
true
);
impl_
=
Impl
::
empty
();
impl_
=
Impl
::
empty
();
rows_
=
0
;
rows_
=
0
;
...
...
modules/gpucodec/src/video_reader.cpp
View file @
77a2529e
...
@@ -58,12 +58,14 @@ namespace cv { namespace gpu { namespace cudev
...
@@ -58,12 +58,14 @@ namespace cv { namespace gpu { namespace cudev
void
NV12_to_RGB
(
const
PtrStepb
decodedFrame
,
PtrStepSz
<
uint
>
interopFrame
,
cudaStream_t
stream
=
0
);
void
NV12_to_RGB
(
const
PtrStepb
decodedFrame
,
PtrStepSz
<
uint
>
interopFrame
,
cudaStream_t
stream
=
0
);
}}}
}}}
using
namespace
cv
::
gpucodec
::
detail
;
namespace
namespace
{
{
class
VideoReaderImpl
:
public
VideoReader
class
VideoReaderImpl
:
public
VideoReader
{
{
public
:
public
:
explicit
VideoReaderImpl
(
const
Ptr
<
detail
::
VideoSource
>&
source
);
explicit
VideoReaderImpl
(
const
Ptr
<
VideoSource
>&
source
);
~
VideoReaderImpl
();
~
VideoReaderImpl
();
bool
nextFrame
(
OutputArray
frame
);
bool
nextFrame
(
OutputArray
frame
);
...
@@ -71,11 +73,11 @@ namespace
...
@@ -71,11 +73,11 @@ namespace
FormatInfo
format
()
const
;
FormatInfo
format
()
const
;
private
:
private
:
Ptr
<
detail
::
VideoSource
>
videoSource_
;
Ptr
<
VideoSource
>
videoSource_
;
Ptr
<
detail
::
FrameQueue
>
frameQueue_
;
Ptr
<
FrameQueue
>
frameQueue_
;
Ptr
<
detail
::
VideoDecoder
>
videoDecoder_
;
Ptr
<
VideoDecoder
>
videoDecoder_
;
Ptr
<
detail
::
VideoParser
>
videoParser_
;
Ptr
<
VideoParser
>
videoParser_
;
CUvideoctxlock
lock_
;
CUvideoctxlock
lock_
;
...
@@ -87,7 +89,7 @@ namespace
...
@@ -87,7 +89,7 @@ namespace
return
videoSource_
->
format
();
return
videoSource_
->
format
();
}
}
VideoReaderImpl
::
VideoReaderImpl
(
const
Ptr
<
detail
::
VideoSource
>&
source
)
:
VideoReaderImpl
::
VideoReaderImpl
(
const
Ptr
<
VideoSource
>&
source
)
:
videoSource_
(
source
),
videoSource_
(
source
),
lock_
(
0
)
lock_
(
0
)
{
{
...
@@ -99,9 +101,9 @@ namespace
...
@@ -99,9 +101,9 @@ namespace
cuSafeCall
(
cuCtxGetCurrent
(
&
ctx
)
);
cuSafeCall
(
cuCtxGetCurrent
(
&
ctx
)
);
cuSafeCall
(
cuvidCtxLockCreate
(
&
lock_
,
ctx
)
);
cuSafeCall
(
cuvidCtxLockCreate
(
&
lock_
,
ctx
)
);
frameQueue_
=
new
detail
::
FrameQueue
;
frameQueue_
.
reset
(
new
FrameQueue
)
;
videoDecoder_
=
new
detail
::
VideoDecoder
(
videoSource_
->
format
(),
lock_
);
videoDecoder_
.
reset
(
new
VideoDecoder
(
videoSource_
->
format
(),
lock_
)
);
videoParser_
=
new
detail
::
VideoParser
(
videoDecoder_
,
frameQueue_
);
videoParser_
.
reset
(
new
VideoParser
(
videoDecoder_
,
frameQueue_
)
);
videoSource_
->
setVideoParser
(
videoParser_
);
videoSource_
->
setVideoParser
(
videoParser_
);
videoSource_
->
start
();
videoSource_
->
start
();
...
@@ -159,7 +161,7 @@ namespace
...
@@ -159,7 +161,7 @@ namespace
return
false
;
return
false
;
// Wait a bit
// Wait a bit
detail
::
Thread
::
sleep
(
1
);
Thread
::
sleep
(
1
);
}
}
bool
isProgressive
=
displayInfo
.
progressive_frame
!=
0
;
bool
isProgressive
=
displayInfo
.
progressive_frame
!=
0
;
...
@@ -212,25 +214,25 @@ Ptr<VideoReader> cv::gpucodec::createVideoReader(const String& filename)
...
@@ -212,25 +214,25 @@ Ptr<VideoReader> cv::gpucodec::createVideoReader(const String& filename)
{
{
CV_Assert
(
!
filename
.
empty
()
);
CV_Assert
(
!
filename
.
empty
()
);
Ptr
<
detail
::
VideoSource
>
videoSource
;
Ptr
<
VideoSource
>
videoSource
;
try
try
{
{
videoSource
=
new
detail
::
CuvidVideoSource
(
filename
);
videoSource
.
reset
(
new
CuvidVideoSource
(
filename
)
);
}
}
catch
(...)
catch
(...)
{
{
Ptr
<
RawVideoSource
>
source
(
new
detail
::
FFmpegVideoSource
(
filename
));
Ptr
<
RawVideoSource
>
source
(
new
FFmpegVideoSource
(
filename
));
videoSource
=
new
detail
::
RawVideoSourceWrapper
(
source
);
videoSource
.
reset
(
new
RawVideoSourceWrapper
(
source
)
);
}
}
return
new
VideoReaderImpl
(
videoSource
);
return
makePtr
<
VideoReaderImpl
>
(
videoSource
);
}
}
Ptr
<
VideoReader
>
cv
::
gpucodec
::
createVideoReader
(
const
Ptr
<
RawVideoSource
>&
source
)
Ptr
<
VideoReader
>
cv
::
gpucodec
::
createVideoReader
(
const
Ptr
<
RawVideoSource
>&
source
)
{
{
Ptr
<
detail
::
VideoSource
>
videoSource
(
new
detail
::
RawVideoSourceWrapper
(
source
));
Ptr
<
VideoSource
>
videoSource
(
new
RawVideoSourceWrapper
(
source
));
return
new
VideoReaderImpl
(
videoSource
);
return
makePtr
<
VideoReaderImpl
>
(
videoSource
);
}
}
#endif // HAVE_NVCUVID
#endif // HAVE_NVCUVID
modules/gpucodec/src/video_source.cpp
View file @
77a2529e
...
@@ -69,7 +69,7 @@ void cv::gpucodec::detail::RawVideoSourceWrapper::start()
...
@@ -69,7 +69,7 @@ void cv::gpucodec::detail::RawVideoSourceWrapper::start()
{
{
stop_
=
false
;
stop_
=
false
;
hasError_
=
false
;
hasError_
=
false
;
thread_
=
new
Thread
(
readLoop
,
this
);
thread_
.
reset
(
new
Thread
(
readLoop
,
this
)
);
}
}
void
cv
::
gpucodec
::
detail
::
RawVideoSourceWrapper
::
stop
()
void
cv
::
gpucodec
::
detail
::
RawVideoSourceWrapper
::
stop
()
...
...
modules/gpucodec/src/video_writer.cpp
View file @
77a2529e
...
@@ -908,12 +908,12 @@ Ptr<VideoWriter> cv::gpucodec::createVideoWriter(const String& fileName, Size fr
...
@@ -908,12 +908,12 @@ Ptr<VideoWriter> cv::gpucodec::createVideoWriter(const String& fileName, Size fr
Ptr
<
VideoWriter
>
cv
::
gpucodec
::
createVideoWriter
(
const
Ptr
<
EncoderCallBack
>&
encoderCallback
,
Size
frameSize
,
double
fps
,
SurfaceFormat
format
)
Ptr
<
VideoWriter
>
cv
::
gpucodec
::
createVideoWriter
(
const
Ptr
<
EncoderCallBack
>&
encoderCallback
,
Size
frameSize
,
double
fps
,
SurfaceFormat
format
)
{
{
return
new
VideoWriterImpl
(
encoderCallback
,
frameSize
,
fps
,
format
);
return
makePtr
<
VideoWriterImpl
>
(
encoderCallback
,
frameSize
,
fps
,
format
);
}
}
Ptr
<
VideoWriter
>
cv
::
gpucodec
::
createVideoWriter
(
const
Ptr
<
EncoderCallBack
>&
encoderCallback
,
Size
frameSize
,
double
fps
,
const
EncoderParams
&
params
,
SurfaceFormat
format
)
Ptr
<
VideoWriter
>
cv
::
gpucodec
::
createVideoWriter
(
const
Ptr
<
EncoderCallBack
>&
encoderCallback
,
Size
frameSize
,
double
fps
,
const
EncoderParams
&
params
,
SurfaceFormat
format
)
{
{
return
new
VideoWriterImpl
(
encoderCallback
,
frameSize
,
fps
,
params
,
format
);
return
makePtr
<
VideoWriterImpl
>
(
encoderCallback
,
frameSize
,
fps
,
params
,
format
);
}
}
#endif // !defined HAVE_CUDA || !defined WIN32
#endif // !defined HAVE_CUDA || !defined WIN32
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