CUVIDEOFORMAT VideoSource::format() const { CUVIDEOFORMAT oFormat; CUresult oResult = cuvidGetSourceVideoFormat(hVideoSource_, &oFormat, 0); assert(CUDA_SUCCESS == oResult); return oFormat; }
cv::gpu::detail::CuvidVideoSource::CuvidVideoSource(const std::string& fname) { CUVIDSOURCEPARAMS params; std::memset(¶ms, 0, sizeof(CUVIDSOURCEPARAMS)); // Fill parameter struct params.pUserData = this; // will be passed to data handlers params.pfnVideoDataHandler = HandleVideoData; // our local video-handler callback params.pfnAudioDataHandler = 0; // now create the actual source CUresult res = cuvidCreateVideoSource(&videoSource_, fname.c_str(), ¶ms); if (res == CUDA_ERROR_INVALID_SOURCE) throw std::runtime_error("Unsupported video source"); cuSafeCall( res ); CUVIDEOFORMAT vidfmt; cuSafeCall( cuvidGetSourceVideoFormat(videoSource_, &vidfmt, 0) ); format_.codec = static_cast<VideoReader_GPU::Codec>(vidfmt.codec); format_.chromaFormat = static_cast<VideoReader_GPU::ChromaFormat>(vidfmt.chroma_format); format_.width = vidfmt.coded_width; format_.height = vidfmt.coded_height; }