Commit 5a85f1b6 authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

renamed gpucodec namespace -> cudacodec

parent 8282f6eb
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include "opencv2/core/gpu.hpp" #include "opencv2/core/gpu.hpp"
namespace cv { namespace gpucodec { namespace cv { namespace cudacodec {
////////////////////////////////// Video Encoding ////////////////////////////////// ////////////////////////////////// Video Encoding //////////////////////////////////
...@@ -201,6 +201,6 @@ public: ...@@ -201,6 +201,6 @@ public:
CV_EXPORTS Ptr<VideoReader> createVideoReader(const String& filename); CV_EXPORTS Ptr<VideoReader> createVideoReader(const String& filename);
CV_EXPORTS Ptr<VideoReader> createVideoReader(const Ptr<RawVideoSource>& source); CV_EXPORTS Ptr<VideoReader> createVideoReader(const Ptr<RawVideoSource>& source);
}} // namespace cv { namespace gpucodec { }} // namespace cv { namespace cudacodec {
#endif /* __OPENCV_GPUCODEC_HPP__ */ #endif /* __OPENCV_GPUCODEC_HPP__ */
...@@ -75,7 +75,7 @@ PERF_TEST_P(FileName, VideoReader, Values("gpu/video/768x576.avi", "gpu/video/19 ...@@ -75,7 +75,7 @@ PERF_TEST_P(FileName, VideoReader, Values("gpu/video/768x576.avi", "gpu/video/19
if (PERF_RUN_GPU()) if (PERF_RUN_GPU())
{ {
cv::Ptr<cv::gpucodec::VideoReader> d_reader = cv::gpucodec::createVideoReader(inputFile); cv::Ptr<cv::cudacodec::VideoReader> d_reader = cv::cudacodec::createVideoReader(inputFile);
cv::cuda::GpuMat frame; cv::cuda::GpuMat frame;
...@@ -119,7 +119,7 @@ PERF_TEST_P(FileName, VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/19 ...@@ -119,7 +119,7 @@ PERF_TEST_P(FileName, VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/19
if (PERF_RUN_GPU()) if (PERF_RUN_GPU())
{ {
cv::Ptr<cv::gpucodec::VideoWriter> d_writer; cv::Ptr<cv::cudacodec::VideoWriter> d_writer;
cv::cuda::GpuMat d_frame; cv::cuda::GpuMat d_frame;
...@@ -131,7 +131,7 @@ PERF_TEST_P(FileName, VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/19 ...@@ -131,7 +131,7 @@ PERF_TEST_P(FileName, VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/19
d_frame.upload(frame); d_frame.upload(frame);
if (d_writer.empty()) if (d_writer.empty())
d_writer = cv::gpucodec::createVideoWriter(outputFile, frame.size(), FPS); d_writer = cv::cudacodec::createVideoWriter(outputFile, frame.size(), FPS);
startTimer(); next(); startTimer(); next();
d_writer->write(d_frame); d_writer->write(d_frame);
......
...@@ -46,10 +46,10 @@ ...@@ -46,10 +46,10 @@
#ifdef HAVE_NVCUVID #ifdef HAVE_NVCUVID
using namespace cv; using namespace cv;
using namespace cv::gpucodec; using namespace cv::cudacodec;
using namespace cv::gpucodec::detail; using namespace cv::cudacodec::detail;
cv::gpucodec::detail::CuvidVideoSource::CuvidVideoSource(const String& fname) cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource(const String& fname)
{ {
CUVIDSOURCEPARAMS params; CUVIDSOURCEPARAMS params;
std::memset(&params, 0, sizeof(CUVIDSOURCEPARAMS)); std::memset(&params, 0, sizeof(CUVIDSOURCEPARAMS));
...@@ -74,37 +74,37 @@ cv::gpucodec::detail::CuvidVideoSource::CuvidVideoSource(const String& fname) ...@@ -74,37 +74,37 @@ cv::gpucodec::detail::CuvidVideoSource::CuvidVideoSource(const String& fname)
format_.height = vidfmt.coded_height; format_.height = vidfmt.coded_height;
} }
cv::gpucodec::detail::CuvidVideoSource::~CuvidVideoSource() cv::cudacodec::detail::CuvidVideoSource::~CuvidVideoSource()
{ {
cuvidDestroyVideoSource(videoSource_); cuvidDestroyVideoSource(videoSource_);
} }
FormatInfo cv::gpucodec::detail::CuvidVideoSource::format() const FormatInfo cv::cudacodec::detail::CuvidVideoSource::format() const
{ {
return format_; return format_;
} }
void cv::gpucodec::detail::CuvidVideoSource::start() void cv::cudacodec::detail::CuvidVideoSource::start()
{ {
cuSafeCall( cuvidSetVideoSourceState(videoSource_, cudaVideoState_Started) ); cuSafeCall( cuvidSetVideoSourceState(videoSource_, cudaVideoState_Started) );
} }
void cv::gpucodec::detail::CuvidVideoSource::stop() void cv::cudacodec::detail::CuvidVideoSource::stop()
{ {
cuSafeCall( cuvidSetVideoSourceState(videoSource_, cudaVideoState_Stopped) ); cuSafeCall( cuvidSetVideoSourceState(videoSource_, cudaVideoState_Stopped) );
} }
bool cv::gpucodec::detail::CuvidVideoSource::isStarted() const bool cv::cudacodec::detail::CuvidVideoSource::isStarted() const
{ {
return (cuvidGetVideoSourceState(videoSource_) == cudaVideoState_Started); return (cuvidGetVideoSourceState(videoSource_) == cudaVideoState_Started);
} }
bool cv::gpucodec::detail::CuvidVideoSource::hasError() const bool cv::cudacodec::detail::CuvidVideoSource::hasError() const
{ {
return (cuvidGetVideoSourceState(videoSource_) == cudaVideoState_Error); return (cuvidGetVideoSourceState(videoSource_) == cudaVideoState_Error);
} }
int CUDAAPI cv::gpucodec::detail::CuvidVideoSource::HandleVideoData(void* userData, CUVIDSOURCEDATAPACKET* packet) int CUDAAPI cv::cudacodec::detail::CuvidVideoSource::HandleVideoData(void* userData, CUVIDSOURCEDATAPACKET* packet)
{ {
CuvidVideoSource* thiz = static_cast<CuvidVideoSource*>(userData); CuvidVideoSource* thiz = static_cast<CuvidVideoSource*>(userData);
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include "opencv2/gpucodec.hpp" #include "opencv2/gpucodec.hpp"
#include "video_source.hpp" #include "video_source.hpp"
namespace cv { namespace gpucodec { namespace detail namespace cv { namespace cudacodec { namespace detail
{ {
class CuvidVideoSource : public VideoSource class CuvidVideoSource : public VideoSource
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
#ifdef HAVE_NVCUVID #ifdef HAVE_NVCUVID
using namespace cv; using namespace cv;
using namespace cv::gpucodec; using namespace cv::cudacodec;
using namespace cv::gpucodec::detail; using namespace cv::cudacodec::detail;
namespace namespace
{ {
...@@ -95,7 +95,7 @@ namespace ...@@ -95,7 +95,7 @@ namespace
} }
} }
cv::gpucodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname) : cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname) :
stream_(0) stream_(0)
{ {
CV_Assert( init_MediaStream_FFMPEG() ); CV_Assert( init_MediaStream_FFMPEG() );
...@@ -115,18 +115,18 @@ cv::gpucodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname) ...@@ -115,18 +115,18 @@ cv::gpucodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname)
format_.height = height; format_.height = height;
} }
cv::gpucodec::detail::FFmpegVideoSource::~FFmpegVideoSource() cv::cudacodec::detail::FFmpegVideoSource::~FFmpegVideoSource()
{ {
if (stream_) if (stream_)
release_InputMediaStream_FFMPEG_p(stream_); release_InputMediaStream_FFMPEG_p(stream_);
} }
FormatInfo cv::gpucodec::detail::FFmpegVideoSource::format() const FormatInfo cv::cudacodec::detail::FFmpegVideoSource::format() const
{ {
return format_; return format_;
} }
bool cv::gpucodec::detail::FFmpegVideoSource::getNextPacket(unsigned char** data, int* size, bool* bEndOfFile) bool cv::cudacodec::detail::FFmpegVideoSource::getNextPacket(unsigned char** data, int* size, bool* bEndOfFile)
{ {
int endOfFile; int endOfFile;
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
struct InputMediaStream_FFMPEG; struct InputMediaStream_FFMPEG;
namespace cv { namespace gpucodec { namespace detail { namespace cv { namespace cudacodec { namespace detail {
class FFmpegVideoSource : public RawVideoSource class FFmpegVideoSource : public RawVideoSource
{ {
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#ifdef HAVE_NVCUVID #ifdef HAVE_NVCUVID
cv::gpucodec::detail::FrameQueue::FrameQueue() : cv::cudacodec::detail::FrameQueue::FrameQueue() :
endOfDecode_(0), endOfDecode_(0),
framesInQueue_(0), framesInQueue_(0),
readPosition_(0) readPosition_(0)
...@@ -54,7 +54,7 @@ cv::gpucodec::detail::FrameQueue::FrameQueue() : ...@@ -54,7 +54,7 @@ cv::gpucodec::detail::FrameQueue::FrameQueue() :
std::memset((void*) isFrameInUse_, 0, sizeof(isFrameInUse_)); std::memset((void*) isFrameInUse_, 0, sizeof(isFrameInUse_));
} }
bool cv::gpucodec::detail::FrameQueue::waitUntilFrameAvailable(int pictureIndex) bool cv::cudacodec::detail::FrameQueue::waitUntilFrameAvailable(int pictureIndex)
{ {
while (isInUse(pictureIndex)) while (isInUse(pictureIndex))
{ {
...@@ -68,7 +68,7 @@ bool cv::gpucodec::detail::FrameQueue::waitUntilFrameAvailable(int pictureIndex) ...@@ -68,7 +68,7 @@ bool cv::gpucodec::detail::FrameQueue::waitUntilFrameAvailable(int pictureIndex)
return true; return true;
} }
void cv::gpucodec::detail::FrameQueue::enqueue(const CUVIDPARSERDISPINFO* picParams) void cv::cudacodec::detail::FrameQueue::enqueue(const CUVIDPARSERDISPINFO* picParams)
{ {
// Mark the frame as 'in-use' so we don't re-use it for decoding until it is no longer needed // Mark the frame as 'in-use' so we don't re-use it for decoding until it is no longer needed
// for display // for display
...@@ -99,7 +99,7 @@ void cv::gpucodec::detail::FrameQueue::enqueue(const CUVIDPARSERDISPINFO* picPar ...@@ -99,7 +99,7 @@ void cv::gpucodec::detail::FrameQueue::enqueue(const CUVIDPARSERDISPINFO* picPar
} while (!isEndOfDecode()); } while (!isEndOfDecode());
} }
bool cv::gpucodec::detail::FrameQueue::dequeue(CUVIDPARSERDISPINFO& displayInfo) bool cv::cudacodec::detail::FrameQueue::dequeue(CUVIDPARSERDISPINFO& displayInfo)
{ {
AutoLock autoLock(mtx_); AutoLock autoLock(mtx_);
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include <nvcuvid.h> #include <nvcuvid.h>
namespace cv { namespace gpucodec { namespace detail namespace cv { namespace cudacodec { namespace detail
{ {
class FrameQueue class FrameQueue
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#ifdef HAVE_NVCUVID #ifdef HAVE_NVCUVID
using namespace cv::gpucodec::detail; using namespace cv::cudacodec::detail;
#ifdef WIN32 #ifdef WIN32
...@@ -67,7 +67,7 @@ namespace ...@@ -67,7 +67,7 @@ namespace
} }
} }
class cv::gpucodec::detail::Thread::Impl class cv::cudacodec::detail::Thread::Impl
{ {
public: public:
Impl(Thread::Func func, void* userData) Impl(Thread::Func func, void* userData)
...@@ -120,7 +120,7 @@ namespace ...@@ -120,7 +120,7 @@ namespace
} }
} }
class cv::gpucodec::detail::Thread::Impl class cv::cudacodec::detail::Thread::Impl
{ {
public: public:
Impl(Thread::Func func, void* userData) Impl(Thread::Func func, void* userData)
...@@ -148,17 +148,17 @@ private: ...@@ -148,17 +148,17 @@ private:
#endif #endif
cv::gpucodec::detail::Thread::Thread(Func func, void* userData) : cv::cudacodec::detail::Thread::Thread(Func func, void* userData) :
impl_(new Impl(func, userData)) impl_(new Impl(func, userData))
{ {
} }
void cv::gpucodec::detail::Thread::wait() void cv::cudacodec::detail::Thread::wait()
{ {
impl_->wait(); impl_->wait();
} }
void cv::gpucodec::detail::Thread::sleep(int ms) void cv::cudacodec::detail::Thread::sleep(int ms)
{ {
#ifdef WIN32 #ifdef WIN32
::Sleep(ms); ::Sleep(ms);
...@@ -167,7 +167,7 @@ void cv::gpucodec::detail::Thread::sleep(int ms) ...@@ -167,7 +167,7 @@ void cv::gpucodec::detail::Thread::sleep(int ms)
#endif #endif
} }
template <> void cv::Ptr<cv::gpucodec::detail::Thread::Impl>::delete_obj() template <> void cv::Ptr<cv::cudacodec::detail::Thread::Impl>::delete_obj()
{ {
if (obj) delete obj; if (obj) delete obj;
} }
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
namespace cv { namespace gpucodec { namespace detail { namespace cv { namespace cudacodec { namespace detail {
class Thread class Thread
{ {
...@@ -68,7 +68,7 @@ private: ...@@ -68,7 +68,7 @@ private:
}}} }}}
namespace cv { namespace cv {
template <> void Ptr<cv::gpucodec::detail::Thread::Impl>::delete_obj(); template <> void Ptr<cv::cudacodec::detail::Thread::Impl>::delete_obj();
} }
#endif // __THREAD_WRAPPERS_HPP__ #endif // __THREAD_WRAPPERS_HPP__
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#ifdef HAVE_NVCUVID #ifdef HAVE_NVCUVID
void cv::gpucodec::detail::VideoDecoder::create(const FormatInfo& videoFormat) void cv::cudacodec::detail::VideoDecoder::create(const FormatInfo& videoFormat)
{ {
release(); release();
...@@ -104,7 +104,7 @@ void cv::gpucodec::detail::VideoDecoder::create(const FormatInfo& videoFormat) ...@@ -104,7 +104,7 @@ void cv::gpucodec::detail::VideoDecoder::create(const FormatInfo& videoFormat)
cuSafeCall( cuvidCreateDecoder(&decoder_, &createInfo_) ); cuSafeCall( cuvidCreateDecoder(&decoder_, &createInfo_) );
} }
void cv::gpucodec::detail::VideoDecoder::release() void cv::cudacodec::detail::VideoDecoder::release()
{ {
if (decoder_) if (decoder_)
{ {
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include "opencv2/core/private.gpu.hpp" #include "opencv2/core/private.gpu.hpp"
#include "opencv2/gpucodec.hpp" #include "opencv2/gpucodec.hpp"
namespace cv { namespace gpucodec { namespace detail namespace cv { namespace cudacodec { namespace detail
{ {
class VideoDecoder class VideoDecoder
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#ifdef HAVE_NVCUVID #ifdef HAVE_NVCUVID
cv::gpucodec::detail::VideoParser::VideoParser(VideoDecoder* videoDecoder, FrameQueue* frameQueue) : cv::cudacodec::detail::VideoParser::VideoParser(VideoDecoder* videoDecoder, FrameQueue* frameQueue) :
videoDecoder_(videoDecoder), frameQueue_(frameQueue), unparsedPackets_(0), hasError_(false) videoDecoder_(videoDecoder), frameQueue_(frameQueue), unparsedPackets_(0), hasError_(false)
{ {
CUVIDPARSERPARAMS params; CUVIDPARSERPARAMS params;
...@@ -62,7 +62,7 @@ cv::gpucodec::detail::VideoParser::VideoParser(VideoDecoder* videoDecoder, Frame ...@@ -62,7 +62,7 @@ cv::gpucodec::detail::VideoParser::VideoParser(VideoDecoder* videoDecoder, Frame
cuSafeCall( cuvidCreateVideoParser(&parser_, &params) ); cuSafeCall( cuvidCreateVideoParser(&parser_, &params) );
} }
bool cv::gpucodec::detail::VideoParser::parseVideoData(const unsigned char* data, size_t size, bool endOfStream) bool cv::cudacodec::detail::VideoParser::parseVideoData(const unsigned char* data, size_t size, bool endOfStream)
{ {
CUVIDSOURCEDATAPACKET packet; CUVIDSOURCEDATAPACKET packet;
std::memset(&packet, 0, sizeof(CUVIDSOURCEDATAPACKET)); std::memset(&packet, 0, sizeof(CUVIDSOURCEDATAPACKET));
...@@ -96,7 +96,7 @@ bool cv::gpucodec::detail::VideoParser::parseVideoData(const unsigned char* data ...@@ -96,7 +96,7 @@ bool cv::gpucodec::detail::VideoParser::parseVideoData(const unsigned char* data
return !frameQueue_->isEndOfDecode(); return !frameQueue_->isEndOfDecode();
} }
int CUDAAPI cv::gpucodec::detail::VideoParser::HandleVideoSequence(void* userData, CUVIDEOFORMAT* format) int CUDAAPI cv::cudacodec::detail::VideoParser::HandleVideoSequence(void* userData, CUVIDEOFORMAT* format)
{ {
VideoParser* thiz = static_cast<VideoParser*>(userData); VideoParser* thiz = static_cast<VideoParser*>(userData);
...@@ -128,7 +128,7 @@ int CUDAAPI cv::gpucodec::detail::VideoParser::HandleVideoSequence(void* userDat ...@@ -128,7 +128,7 @@ int CUDAAPI cv::gpucodec::detail::VideoParser::HandleVideoSequence(void* userDat
return true; return true;
} }
int CUDAAPI cv::gpucodec::detail::VideoParser::HandlePictureDecode(void* userData, CUVIDPICPARAMS* picParams) int CUDAAPI cv::cudacodec::detail::VideoParser::HandlePictureDecode(void* userData, CUVIDPICPARAMS* picParams)
{ {
VideoParser* thiz = static_cast<VideoParser*>(userData); VideoParser* thiz = static_cast<VideoParser*>(userData);
...@@ -148,7 +148,7 @@ int CUDAAPI cv::gpucodec::detail::VideoParser::HandlePictureDecode(void* userDat ...@@ -148,7 +148,7 @@ int CUDAAPI cv::gpucodec::detail::VideoParser::HandlePictureDecode(void* userDat
return true; return true;
} }
int CUDAAPI cv::gpucodec::detail::VideoParser::HandlePictureDisplay(void* userData, CUVIDPARSERDISPINFO* picParams) int CUDAAPI cv::cudacodec::detail::VideoParser::HandlePictureDisplay(void* userData, CUVIDPARSERDISPINFO* picParams)
{ {
VideoParser* thiz = static_cast<VideoParser*>(userData); VideoParser* thiz = static_cast<VideoParser*>(userData);
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#include "frame_queue.hpp" #include "frame_queue.hpp"
#include "video_decoder.hpp" #include "video_decoder.hpp"
namespace cv { namespace gpucodec { namespace detail namespace cv { namespace cudacodec { namespace detail
{ {
class VideoParser class VideoParser
......
...@@ -44,12 +44,12 @@ ...@@ -44,12 +44,12 @@
using namespace cv; using namespace cv;
using namespace cv::cuda; using namespace cv::cuda;
using namespace cv::gpucodec; using namespace cv::cudacodec;
#ifndef HAVE_NVCUVID #ifndef HAVE_NVCUVID
Ptr<VideoReader> cv::gpucodec::createVideoReader(const String&) { throw_no_cuda(); return Ptr<VideoReader>(); } Ptr<VideoReader> cv::cudacodec::createVideoReader(const String&) { throw_no_cuda(); return Ptr<VideoReader>(); }
Ptr<VideoReader> cv::gpucodec::createVideoReader(const Ptr<RawVideoSource>&) { throw_no_cuda(); return Ptr<VideoReader>(); } Ptr<VideoReader> cv::cudacodec::createVideoReader(const Ptr<RawVideoSource>&) { throw_no_cuda(); return Ptr<VideoReader>(); }
#else // HAVE_NVCUVID #else // HAVE_NVCUVID
...@@ -208,7 +208,7 @@ namespace ...@@ -208,7 +208,7 @@ namespace
} }
} }
Ptr<VideoReader> cv::gpucodec::createVideoReader(const String& filename) Ptr<VideoReader> cv::cudacodec::createVideoReader(const String& filename)
{ {
CV_Assert( !filename.empty() ); CV_Assert( !filename.empty() );
...@@ -227,7 +227,7 @@ Ptr<VideoReader> cv::gpucodec::createVideoReader(const String& filename) ...@@ -227,7 +227,7 @@ Ptr<VideoReader> cv::gpucodec::createVideoReader(const String& filename)
return new VideoReaderImpl(videoSource); return new VideoReaderImpl(videoSource);
} }
Ptr<VideoReader> cv::gpucodec::createVideoReader(const Ptr<RawVideoSource>& source) Ptr<VideoReader> cv::cudacodec::createVideoReader(const Ptr<RawVideoSource>& source)
{ {
Ptr<detail::VideoSource> videoSource(new detail::RawVideoSourceWrapper(source)); Ptr<detail::VideoSource> videoSource(new detail::RawVideoSourceWrapper(source));
return new VideoReaderImpl(videoSource); return new VideoReaderImpl(videoSource);
......
...@@ -46,50 +46,50 @@ ...@@ -46,50 +46,50 @@
#ifdef HAVE_NVCUVID #ifdef HAVE_NVCUVID
using namespace cv; using namespace cv;
using namespace cv::gpucodec; using namespace cv::cudacodec;
using namespace cv::gpucodec::detail; using namespace cv::cudacodec::detail;
bool cv::gpucodec::detail::VideoSource::parseVideoData(const unsigned char* data, size_t size, bool endOfStream) bool cv::cudacodec::detail::VideoSource::parseVideoData(const unsigned char* data, size_t size, bool endOfStream)
{ {
return videoParser_->parseVideoData(data, size, endOfStream); return videoParser_->parseVideoData(data, size, endOfStream);
} }
cv::gpucodec::detail::RawVideoSourceWrapper::RawVideoSourceWrapper(const Ptr<RawVideoSource>& source) : cv::cudacodec::detail::RawVideoSourceWrapper::RawVideoSourceWrapper(const Ptr<RawVideoSource>& source) :
source_(source) source_(source)
{ {
CV_Assert( !source_.empty() ); CV_Assert( !source_.empty() );
} }
cv::gpucodec::FormatInfo cv::gpucodec::detail::RawVideoSourceWrapper::format() const cv::cudacodec::FormatInfo cv::cudacodec::detail::RawVideoSourceWrapper::format() const
{ {
return source_->format(); return source_->format();
} }
void cv::gpucodec::detail::RawVideoSourceWrapper::start() void cv::cudacodec::detail::RawVideoSourceWrapper::start()
{ {
stop_ = false; stop_ = false;
hasError_ = false; hasError_ = false;
thread_ = new Thread(readLoop, this); thread_ = new Thread(readLoop, this);
} }
void cv::gpucodec::detail::RawVideoSourceWrapper::stop() void cv::cudacodec::detail::RawVideoSourceWrapper::stop()
{ {
stop_ = true; stop_ = true;
thread_->wait(); thread_->wait();
thread_.release(); thread_.release();
} }
bool cv::gpucodec::detail::RawVideoSourceWrapper::isStarted() const bool cv::cudacodec::detail::RawVideoSourceWrapper::isStarted() const
{ {
return !stop_; return !stop_;
} }
bool cv::gpucodec::detail::RawVideoSourceWrapper::hasError() const bool cv::cudacodec::detail::RawVideoSourceWrapper::hasError() const
{ {
return hasError_; return hasError_;
} }
void cv::gpucodec::detail::RawVideoSourceWrapper::readLoop(void* userData) void cv::cudacodec::detail::RawVideoSourceWrapper::readLoop(void* userData)
{ {
RawVideoSourceWrapper* thiz = static_cast<RawVideoSourceWrapper*>(userData); RawVideoSourceWrapper* thiz = static_cast<RawVideoSourceWrapper*>(userData);
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
#include "opencv2/gpucodec.hpp" #include "opencv2/gpucodec.hpp"
#include "thread.hpp" #include "thread.hpp"
namespace cv { namespace gpucodec { namespace detail namespace cv { namespace cudacodec { namespace detail
{ {
class VideoParser; class VideoParser;
......
...@@ -45,20 +45,20 @@ ...@@ -45,20 +45,20 @@
using namespace cv; using namespace cv;
using namespace cv::cuda; using namespace cv::cuda;
using namespace cv::gpucodec; using namespace cv::cudacodec;
#if !defined(HAVE_NVCUVID) || !defined(WIN32) #if !defined(HAVE_NVCUVID) || !defined(WIN32)
cv::gpucodec::EncoderParams::EncoderParams() { throw_no_cuda(); } cv::cudacodec::EncoderParams::EncoderParams() { throw_no_cuda(); }
cv::gpucodec::EncoderParams::EncoderParams(const String&) { throw_no_cuda(); } cv::cudacodec::EncoderParams::EncoderParams(const String&) { throw_no_cuda(); }
void cv::gpucodec::EncoderParams::load(const String&) { throw_no_cuda(); } void cv::cudacodec::EncoderParams::load(const String&) { throw_no_cuda(); }
void cv::gpucodec::EncoderParams::save(const String&) const { throw_no_cuda(); } void cv::cudacodec::EncoderParams::save(const String&) const { throw_no_cuda(); }
Ptr<VideoWriter> cv::gpucodec::createVideoWriter(const String&, Size, double, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); } Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const String&, Size, double, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); }
Ptr<VideoWriter> cv::gpucodec::createVideoWriter(const String&, Size, double, const EncoderParams&, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); } Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const String&, Size, double, const EncoderParams&, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); }
Ptr<VideoWriter> cv::gpucodec::createVideoWriter(const Ptr<EncoderCallBack>&, Size, double, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); } Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const Ptr<EncoderCallBack>&, Size, double, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); }
Ptr<VideoWriter> cv::gpucodec::createVideoWriter(const Ptr<EncoderCallBack>&, Size, double, const EncoderParams&, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); } Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const Ptr<EncoderCallBack>&, Size, double, const EncoderParams&, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); }
#else // !defined HAVE_CUDA || !defined WIN32 #else // !defined HAVE_CUDA || !defined WIN32
...@@ -811,7 +811,7 @@ namespace ...@@ -811,7 +811,7 @@ namespace
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// EncoderParams // EncoderParams
cv::gpucodec::EncoderParams::EncoderParams() cv::cudacodec::EncoderParams::EncoderParams()
{ {
P_Interval = 3; P_Interval = 3;
IDR_Period = 15; IDR_Period = 15;
...@@ -834,12 +834,12 @@ cv::gpucodec::EncoderParams::EncoderParams() ...@@ -834,12 +834,12 @@ cv::gpucodec::EncoderParams::EncoderParams()
DisableSPSPPS = 0; DisableSPSPPS = 0;
} }
cv::gpucodec::EncoderParams::EncoderParams(const String& configFile) cv::cudacodec::EncoderParams::EncoderParams(const String& configFile)
{ {
load(configFile); load(configFile);
} }
void cv::gpucodec::EncoderParams::load(const String& configFile) void cv::cudacodec::EncoderParams::load(const String& configFile)
{ {
FileStorage fs(configFile, FileStorage::READ); FileStorage fs(configFile, FileStorage::READ);
CV_Assert( fs.isOpened() ); CV_Assert( fs.isOpened() );
...@@ -865,7 +865,7 @@ void cv::gpucodec::EncoderParams::load(const String& configFile) ...@@ -865,7 +865,7 @@ void cv::gpucodec::EncoderParams::load(const String& configFile)
read(fs["DisableSPSPPS" ], DisableSPSPPS, 0); read(fs["DisableSPSPPS" ], DisableSPSPPS, 0);
} }
void cv::gpucodec::EncoderParams::save(const String& configFile) const void cv::cudacodec::EncoderParams::save(const String& configFile) const
{ {
FileStorage fs(configFile, FileStorage::WRITE); FileStorage fs(configFile, FileStorage::WRITE);
CV_Assert( fs.isOpened() ); CV_Assert( fs.isOpened() );
...@@ -894,24 +894,24 @@ void cv::gpucodec::EncoderParams::save(const String& configFile) const ...@@ -894,24 +894,24 @@ void cv::gpucodec::EncoderParams::save(const String& configFile) const
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// createVideoWriter // createVideoWriter
Ptr<VideoWriter> cv::gpucodec::createVideoWriter(const String& fileName, Size frameSize, double fps, SurfaceFormat format) Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const String& fileName, Size frameSize, double fps, SurfaceFormat format)
{ {
Ptr<EncoderCallBack> encoderCallback(new EncoderCallBackFFMPEG(fileName, frameSize, fps)); Ptr<EncoderCallBack> encoderCallback(new EncoderCallBackFFMPEG(fileName, frameSize, fps));
return createVideoWriter(encoderCallback, frameSize, fps, format); return createVideoWriter(encoderCallback, frameSize, fps, format);
} }
Ptr<VideoWriter> cv::gpucodec::createVideoWriter(const String& fileName, Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format) Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const String& fileName, Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format)
{ {
Ptr<EncoderCallBack> encoderCallback(new EncoderCallBackFFMPEG(fileName, frameSize, fps)); Ptr<EncoderCallBack> encoderCallback(new EncoderCallBackFFMPEG(fileName, frameSize, fps));
return createVideoWriter(encoderCallback, frameSize, fps, params, format); return createVideoWriter(encoderCallback, frameSize, fps, params, format);
} }
Ptr<VideoWriter> cv::gpucodec::createVideoWriter(const Ptr<EncoderCallBack>& encoderCallback, Size frameSize, double fps, SurfaceFormat format) Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const Ptr<EncoderCallBack>& encoderCallback, Size frameSize, double fps, SurfaceFormat format)
{ {
return new VideoWriterImpl(encoderCallback, frameSize, fps, format); return new 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::cudacodec::createVideoWriter(const Ptr<EncoderCallBack>& encoderCallback, Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format)
{ {
return new VideoWriterImpl(encoderCallback, frameSize, fps, params, format); return new VideoWriterImpl(encoderCallback, frameSize, fps, params, format);
} }
......
...@@ -57,7 +57,7 @@ GPU_TEST_P(Video, Reader) ...@@ -57,7 +57,7 @@ GPU_TEST_P(Video, Reader)
const std::string inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "video/" + GET_PARAM(1); const std::string inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "video/" + GET_PARAM(1);
cv::Ptr<cv::gpucodec::VideoReader> reader = cv::gpucodec::createVideoReader(inputFile); cv::Ptr<cv::cudacodec::VideoReader> reader = cv::cudacodec::createVideoReader(inputFile);
cv::cuda::GpuMat frame; cv::cuda::GpuMat frame;
...@@ -85,7 +85,7 @@ GPU_TEST_P(Video, Writer) ...@@ -85,7 +85,7 @@ GPU_TEST_P(Video, Writer)
cv::VideoCapture reader(inputFile); cv::VideoCapture reader(inputFile);
ASSERT_TRUE(reader.isOpened()); ASSERT_TRUE(reader.isOpened());
cv::Ptr<cv::gpucodec::VideoWriter> d_writer; cv::Ptr<cv::cudacodec::VideoWriter> d_writer;
cv::Mat frame; cv::Mat frame;
cv::cuda::GpuMat d_frame; cv::cuda::GpuMat d_frame;
...@@ -98,7 +98,7 @@ GPU_TEST_P(Video, Writer) ...@@ -98,7 +98,7 @@ GPU_TEST_P(Video, Writer)
d_frame.upload(frame); d_frame.upload(frame);
if (d_writer.empty()) if (d_writer.empty())
d_writer = cv::gpucodec::createVideoWriter(outputFile, frame.size(), FPS); d_writer = cv::cudacodec::createVideoWriter(outputFile, frame.size(), FPS);
d_writer->write(d_frame); d_writer->write(d_frame);
} }
......
...@@ -222,7 +222,7 @@ namespace ...@@ -222,7 +222,7 @@ namespace
private: private:
String fileName_; String fileName_;
Ptr<gpucodec::VideoReader> reader_; Ptr<cudacodec::VideoReader> reader_;
GpuMat frame_; GpuMat frame_;
}; };
...@@ -251,7 +251,7 @@ namespace ...@@ -251,7 +251,7 @@ namespace
void VideoFrameSource_GPU::reset() void VideoFrameSource_GPU::reset()
{ {
reader_ = gpucodec::createVideoReader(fileName_); reader_ = cudacodec::createVideoReader(fileName_);
} }
} }
......
...@@ -30,7 +30,7 @@ int main(int argc, const char* argv[]) ...@@ -30,7 +30,7 @@ int main(int argc, const char* argv[])
cv::VideoCapture reader(fname); cv::VideoCapture reader(fname);
cv::cuda::GpuMat d_frame; cv::cuda::GpuMat d_frame;
cv::Ptr<cv::gpucodec::VideoReader> d_reader = cv::gpucodec::createVideoReader(fname); cv::Ptr<cv::cudacodec::VideoReader> d_reader = cv::cudacodec::createVideoReader(fname);
cv::TickMeter tm; cv::TickMeter tm;
std::vector<double> cpu_times; std::vector<double> cpu_times;
......
...@@ -33,7 +33,7 @@ int main(int argc, const char* argv[]) ...@@ -33,7 +33,7 @@ int main(int argc, const char* argv[])
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice()); cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cv::VideoWriter writer; cv::VideoWriter writer;
cv::Ptr<cv::gpucodec::VideoWriter> d_writer; cv::Ptr<cv::cudacodec::VideoWriter> d_writer;
cv::Mat frame; cv::Mat frame;
cv::gpu::GpuMat d_frame; cv::gpu::GpuMat d_frame;
...@@ -68,7 +68,7 @@ int main(int argc, const char* argv[]) ...@@ -68,7 +68,7 @@ int main(int argc, const char* argv[])
{ {
std::cout << "Open GPU Writer" << std::endl; std::cout << "Open GPU Writer" << std::endl;
d_writer = cv::gpucodec::createVideoWriter("output_gpu.avi", frame.size(), FPS); d_writer = cv::cudacodec::createVideoWriter("output_gpu.avi", frame.size(), FPS);
} }
d_frame.upload(frame); d_frame.upload(frame);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment