renamed gpucodec -> cudacodec
This commit is contained in:
9
modules/cudacodec/doc/cudacodec.rst
Normal file
9
modules/cudacodec/doc/cudacodec.rst
Normal file
@@ -0,0 +1,9 @@
|
||||
*************************************************
|
||||
gpucodec. GPU-accelerated Video Encoding/Decoding
|
||||
*************************************************
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
videodec
|
||||
videoenc
|
156
modules/cudacodec/doc/videodec.rst
Normal file
156
modules/cudacodec/doc/videodec.rst
Normal file
@@ -0,0 +1,156 @@
|
||||
Video Decoding
|
||||
==============
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
|
||||
|
||||
gpucodec::VideoReader
|
||||
---------------------
|
||||
Video reader interface.
|
||||
|
||||
.. ocv:class:: gpucodec::VideoReader
|
||||
|
||||
.. note::
|
||||
|
||||
* An example on how to use the videoReader class can be found at opencv_source_code/samples/gpu/video_reader.cpp
|
||||
|
||||
|
||||
gpucodec::VideoReader::nextFrame
|
||||
--------------------------------
|
||||
Grabs, decodes and returns the next video frame.
|
||||
|
||||
.. ocv:function:: bool gpucodec::VideoReader::nextFrame(OutputArray frame)
|
||||
|
||||
If no frames has been grabbed (there are no more frames in video file), the methods return ``false`` . The method throws :ocv:class:`Exception` if error occurs.
|
||||
|
||||
|
||||
|
||||
gpucodec::VideoReader::format
|
||||
-----------------------------
|
||||
Returns information about video file format.
|
||||
|
||||
.. ocv:function:: FormatInfo gpucodec::VideoReader::format() const
|
||||
|
||||
|
||||
|
||||
gpucodec::Codec
|
||||
---------------
|
||||
Video codecs supported by :ocv:class:`gpucodec::VideoReader` .
|
||||
|
||||
.. ocv:enum:: gpucodec::Codec
|
||||
|
||||
.. ocv:emember:: MPEG1 = 0
|
||||
.. ocv:emember:: MPEG2
|
||||
.. ocv:emember:: MPEG4
|
||||
.. ocv:emember:: VC1
|
||||
.. ocv:emember:: H264
|
||||
.. ocv:emember:: JPEG
|
||||
.. ocv:emember:: H264_SVC
|
||||
.. ocv:emember:: H264_MVC
|
||||
|
||||
.. ocv:emember:: Uncompressed_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V'))
|
||||
|
||||
Y,U,V (4:2:0)
|
||||
|
||||
.. ocv:emember:: Uncompressed_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2'))
|
||||
|
||||
Y,V,U (4:2:0)
|
||||
|
||||
.. ocv:emember:: Uncompressed_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2'))
|
||||
|
||||
Y,UV (4:2:0)
|
||||
|
||||
.. ocv:emember:: Uncompressed_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V'))
|
||||
|
||||
YUYV/YUY2 (4:2:2)
|
||||
|
||||
.. ocv:emember:: Uncompressed_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y'))
|
||||
|
||||
UYVY (4:2:2)
|
||||
|
||||
|
||||
|
||||
gpucodec::ChromaFormat
|
||||
----------------------
|
||||
Chroma formats supported by :ocv:class:`gpucodec::VideoReader` .
|
||||
|
||||
.. ocv:enum:: gpucodec::ChromaFormat
|
||||
|
||||
.. ocv:emember:: Monochrome = 0
|
||||
.. ocv:emember:: YUV420
|
||||
.. ocv:emember:: YUV422
|
||||
.. ocv:emember:: YUV444
|
||||
|
||||
|
||||
|
||||
gpucodec::FormatInfo
|
||||
--------------------
|
||||
.. ocv:struct:: gpucodec::FormatInfo
|
||||
|
||||
Struct providing information about video file format. ::
|
||||
|
||||
struct FormatInfo
|
||||
{
|
||||
Codec codec;
|
||||
ChromaFormat chromaFormat;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
|
||||
|
||||
gpucodec::createVideoReader
|
||||
---------------------------
|
||||
Creates video reader.
|
||||
|
||||
.. ocv:function:: Ptr<VideoReader> gpucodec::createVideoReader(const String& filename)
|
||||
.. ocv:function:: Ptr<VideoReader> gpucodec::createVideoReader(const Ptr<RawVideoSource>& source)
|
||||
|
||||
:param filename: Name of the input video file.
|
||||
|
||||
:param source: RAW video source implemented by user.
|
||||
|
||||
FFMPEG is used to read videos. User can implement own demultiplexing with :ocv:class:`gpucodec::RawVideoSource` .
|
||||
|
||||
|
||||
|
||||
gpucodec::RawVideoSource
|
||||
------------------------
|
||||
.. ocv:class:: gpucodec::RawVideoSource
|
||||
|
||||
Interface for video demultiplexing. ::
|
||||
|
||||
class RawVideoSource
|
||||
{
|
||||
public:
|
||||
virtual ~RawVideoSource() {}
|
||||
|
||||
virtual bool getNextPacket(unsigned char** data, int* size, bool* endOfFile) = 0;
|
||||
|
||||
virtual FormatInfo format() const = 0;
|
||||
};
|
||||
|
||||
User can implement own demultiplexing by implementing this interface.
|
||||
|
||||
|
||||
|
||||
gpucodec::RawVideoSource::getNextPacket
|
||||
---------------------------------------
|
||||
Returns next packet with RAW video frame.
|
||||
|
||||
.. ocv:function:: bool gpucodec::VideoSource::getNextPacket(unsigned char** data, int* size, bool* endOfFile) = 0
|
||||
|
||||
:param data: Pointer to frame data.
|
||||
|
||||
:param size: Size in bytes of current frame.
|
||||
|
||||
:param endOfStream: Indicates that it is end of stream.
|
||||
|
||||
|
||||
|
||||
gpucodec::RawVideoSource::format
|
||||
--------------------------------
|
||||
Returns information about video file format.
|
||||
|
||||
.. ocv:function:: virtual FormatInfo gpucodec::RawVideoSource::format() const = 0
|
192
modules/cudacodec/doc/videoenc.rst
Normal file
192
modules/cudacodec/doc/videoenc.rst
Normal file
@@ -0,0 +1,192 @@
|
||||
Video Encoding
|
||||
==============
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
|
||||
|
||||
gpucodec::VideoWriter
|
||||
---------------------
|
||||
Video writer interface.
|
||||
|
||||
.. ocv:class:: gpucodec::VideoWriter
|
||||
|
||||
The implementation uses H264 video codec.
|
||||
|
||||
.. note:: Currently only Windows platform is supported.
|
||||
|
||||
.. note::
|
||||
|
||||
* An example on how to use the videoWriter class can be found at opencv_source_code/samples/gpu/video_writer.cpp
|
||||
|
||||
|
||||
gpucodec::VideoWriter::write
|
||||
----------------------------
|
||||
Writes the next video frame.
|
||||
|
||||
.. ocv:function:: void gpucodec::VideoWriter::write(InputArray frame, bool lastFrame = false) = 0
|
||||
|
||||
:param frame: The written frame.
|
||||
|
||||
:param lastFrame: Indicates that it is end of stream. The parameter can be ignored.
|
||||
|
||||
The method write the specified image to video file. The image must have the same size and the same surface format as has been specified when opening the video writer.
|
||||
|
||||
|
||||
|
||||
gpucodec::createVideoWriter
|
||||
---------------------------
|
||||
Creates video writer.
|
||||
|
||||
.. ocv:function:: Ptr<gpucodec::VideoWriter> gpucodec::createVideoWriter(const String& fileName, Size frameSize, double fps, SurfaceFormat format = SF_BGR)
|
||||
.. ocv:function:: Ptr<gpucodec::VideoWriter> gpucodec::createVideoWriter(const String& fileName, Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR)
|
||||
.. ocv:function:: Ptr<gpucodec::VideoWriter> gpucodec::createVideoWriter(const Ptr<EncoderCallBack>& encoderCallback, Size frameSize, double fps, SurfaceFormat format = SF_BGR)
|
||||
.. ocv:function:: Ptr<gpucodec::VideoWriter> gpucodec::createVideoWriter(const Ptr<EncoderCallBack>& encoderCallback, Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR)
|
||||
|
||||
:param fileName: Name of the output video file. Only AVI file format is supported.
|
||||
|
||||
:param frameSize: Size of the input video frames.
|
||||
|
||||
:param fps: Framerate of the created video stream.
|
||||
|
||||
:param params: Encoder parameters. See :ocv:struct:`gpucodec::EncoderParams` .
|
||||
|
||||
:param format: Surface format of input frames ( ``SF_UYVY`` , ``SF_YUY2`` , ``SF_YV12`` , ``SF_NV12`` , ``SF_IYUV`` , ``SF_BGR`` or ``SF_GRAY``). BGR or gray frames will be converted to YV12 format before encoding, frames with other formats will be used as is.
|
||||
|
||||
:param encoderCallback: Callbacks for video encoder. See :ocv:class:`gpucodec::EncoderCallBack` . Use it if you want to work with raw video stream.
|
||||
|
||||
The constructors initialize video writer. FFMPEG is used to write videos. User can implement own multiplexing with :ocv:class:`gpucodec::EncoderCallBack` .
|
||||
|
||||
|
||||
|
||||
gpucodec::EncoderParams
|
||||
-----------------------
|
||||
.. ocv:struct:: gpucodec::EncoderParams
|
||||
|
||||
Different parameters for CUDA video encoder. ::
|
||||
|
||||
struct EncoderParams
|
||||
{
|
||||
int P_Interval; // NVVE_P_INTERVAL,
|
||||
int IDR_Period; // NVVE_IDR_PERIOD,
|
||||
int DynamicGOP; // NVVE_DYNAMIC_GOP,
|
||||
int RCType; // NVVE_RC_TYPE,
|
||||
int AvgBitrate; // NVVE_AVG_BITRATE,
|
||||
int PeakBitrate; // NVVE_PEAK_BITRATE,
|
||||
int QP_Level_Intra; // NVVE_QP_LEVEL_INTRA,
|
||||
int QP_Level_InterP; // NVVE_QP_LEVEL_INTER_P,
|
||||
int QP_Level_InterB; // NVVE_QP_LEVEL_INTER_B,
|
||||
int DeblockMode; // NVVE_DEBLOCK_MODE,
|
||||
int ProfileLevel; // NVVE_PROFILE_LEVEL,
|
||||
int ForceIntra; // NVVE_FORCE_INTRA,
|
||||
int ForceIDR; // NVVE_FORCE_IDR,
|
||||
int ClearStat; // NVVE_CLEAR_STAT,
|
||||
int DIMode; // NVVE_SET_DEINTERLACE,
|
||||
int Presets; // NVVE_PRESETS,
|
||||
int DisableCabac; // NVVE_DISABLE_CABAC,
|
||||
int NaluFramingType; // NVVE_CONFIGURE_NALU_FRAMING_TYPE
|
||||
int DisableSPSPPS; // NVVE_DISABLE_SPS_PPS
|
||||
|
||||
EncoderParams();
|
||||
explicit EncoderParams(const String& configFile);
|
||||
|
||||
void load(const String& configFile);
|
||||
void save(const String& configFile) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
gpucodec::EncoderParams::EncoderParams
|
||||
--------------------------------------
|
||||
Constructors.
|
||||
|
||||
.. ocv:function:: gpucodec::EncoderParams::EncoderParams()
|
||||
.. ocv:function:: gpucodec::EncoderParams::EncoderParams(const String& configFile)
|
||||
|
||||
:param configFile: Config file name.
|
||||
|
||||
Creates default parameters or reads parameters from config file.
|
||||
|
||||
|
||||
|
||||
gpucodec::EncoderParams::load
|
||||
-----------------------------
|
||||
Reads parameters from config file.
|
||||
|
||||
.. ocv:function:: void gpucodec::EncoderParams::load(const String& configFile)
|
||||
|
||||
:param configFile: Config file name.
|
||||
|
||||
|
||||
|
||||
gpucodec::EncoderParams::save
|
||||
-----------------------------
|
||||
Saves parameters to config file.
|
||||
|
||||
.. ocv:function:: void gpucodec::EncoderParams::save(const String& configFile) const
|
||||
|
||||
:param configFile: Config file name.
|
||||
|
||||
|
||||
|
||||
gpucodec::EncoderCallBack
|
||||
-------------------------
|
||||
.. ocv:class:: gpucodec::EncoderCallBack
|
||||
|
||||
Callbacks for CUDA video encoder. ::
|
||||
|
||||
class EncoderCallBack
|
||||
{
|
||||
public:
|
||||
enum PicType
|
||||
{
|
||||
IFRAME = 1,
|
||||
PFRAME = 2,
|
||||
BFRAME = 3
|
||||
};
|
||||
|
||||
virtual ~EncoderCallBack() {}
|
||||
|
||||
virtual unsigned char* acquireBitStream(int* bufferSize) = 0;
|
||||
virtual void releaseBitStream(unsigned char* data, int size) = 0;
|
||||
virtual void onBeginFrame(int frameNumber, PicType picType) = 0;
|
||||
virtual void onEndFrame(int frameNumber, PicType picType) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
gpucodec::EncoderCallBack::acquireBitStream
|
||||
-------------------------------------------
|
||||
Callback function to signal the start of bitstream that is to be encoded.
|
||||
|
||||
.. ocv:function:: virtual uchar* gpucodec::EncoderCallBack::acquireBitStream(int* bufferSize) = 0
|
||||
|
||||
Callback must allocate buffer for CUDA encoder and return pointer to it and it's size.
|
||||
|
||||
|
||||
|
||||
gpucodec::EncoderCallBack::releaseBitStream
|
||||
-------------------------------------------
|
||||
Callback function to signal that the encoded bitstream is ready to be written to file.
|
||||
|
||||
.. ocv:function:: virtual void gpucodec::EncoderCallBack::releaseBitStream(unsigned char* data, int size) = 0
|
||||
|
||||
|
||||
|
||||
gpucodec::EncoderCallBack::onBeginFrame
|
||||
---------------------------------------
|
||||
Callback function to signal that the encoding operation on the frame has started.
|
||||
|
||||
.. ocv:function:: virtual void gpucodec::EncoderCallBack::onBeginFrame(int frameNumber, PicType picType) = 0
|
||||
|
||||
:param picType: Specify frame type (I-Frame, P-Frame or B-Frame).
|
||||
|
||||
|
||||
|
||||
gpucodec::EncoderCallBack::onEndFrame
|
||||
-------------------------------------
|
||||
Callback function signals that the encoding operation on the frame has finished.
|
||||
|
||||
.. ocv:function:: virtual void gpucodec::EncoderCallBack::onEndFrame(int frameNumber, PicType picType) = 0
|
||||
|
||||
:param picType: Specify frame type (I-Frame, P-Frame or B-Frame).
|
Reference in New Issue
Block a user