VideoContext
VideoContext
#include <icy/av/videocontext.h>Subclassed by:
VideoDecoder,VideoEncoder
Base video context from which all video encoders and decoders derive.
Public Attributes
| Return | Name | Description |
|---|---|---|
PacketSignal | emitter | |
VideoCodec | iparams | input parameters |
VideoCodec | oparams | output parameters |
AVStream * | stream | encoder or decoder stream |
AVCodecContext * | ctx | encoder or decoder context |
const AVCodec * | codec | encoder or decoder codec |
AVFrame * | frame | encoder or decoder frame |
std::unique_ptr< VideoConverter > | conv | video conversion context |
int64_t | time | stream time in codec time base |
int64_t | pts | last packet pts value |
double | seconds | video time in seconds |
std::string | error | error message |
emitter
PacketSignal emitteriparams
VideoCodec iparamsinput parameters
oparams
VideoCodec oparamsoutput parameters
stream
AVStream * streamencoder or decoder stream
ctx
AVCodecContext * ctxencoder or decoder context
codec
const AVCodec * codecencoder or decoder codec
frame
AVFrame * frameencoder or decoder frame
conv
std::unique_ptr< VideoConverter > convvideo conversion context
time
int64_t timestream time in codec time base
pts
int64_t ptslast packet pts value
seconds
double secondsvideo time in seconds
error
std::string errorerror message
Public Methods
| Return | Name | Description |
|---|---|---|
VideoContext | ||
VideoContext | Deleted constructor. | |
VideoContext | Deleted constructor. | |
void | create virtual | Initialise the AVCodecContext with codec-specific defaults. Overridden by VideoEncoder and VideoDecoder. |
void | open virtual | Open the codec and create the pixel format conversion context if required. Throws std::runtime_error if the codec context has not been created. |
void | close virtual | Close the codec context, free the frame, and reset timestamps. |
bool | decode virtual | Decode a compressed video packet and emit the resulting frame. |
bool | encode virtual | Encode a buffer of interleaved video data. |
bool | encode virtual | Encode a planar video frame. |
bool | encode virtual | Encode a single AVFrame. |
void | flush virtual | Flush any frames buffered inside the codec and emit remaining output. |
AVFrame * | convert virtual | Convert the video frame and return the result. |
bool | recreateConverter virtual | Recreate the VideoConverter if the input or output parameters have changed. Called automatically by open() and convert(). |
VideoContext
VideoContext()VideoContext
VideoContext(const VideoContext &) = deleteDeleted constructor.
VideoContext
VideoContext(VideoContext &&) = deleteDeleted constructor.
create
virtual
virtual void create()Initialise the AVCodecContext with codec-specific defaults. Overridden by VideoEncoder and VideoDecoder.
open
virtual
virtual void open()Open the codec and create the pixel format conversion context if required. Throws std::runtime_error if the codec context has not been created.
close
virtual
virtual void close()Close the codec context, free the frame, and reset timestamps.
decode
virtual
virtual bool decode(AVPacket & ipacket)Decode a compressed video packet and emit the resulting frame.
Parameters
ipacketThe compressed video packet to decode.
Returns
True if an output frame was decoded and emitted, false otherwise.
encode
virtual
virtual bool encode(uint8_t * data, int size, int64_t pts)Encode a buffer of interleaved video data.
Parameters
dataPointer to the interleaved frame buffer.sizeSize of the buffer in bytes.ptsPresentation timestamp in stream time base units.
Returns
True if an encoded packet was produced and emitted.
encode
virtual
virtual bool encode(uint8_t * data, int linesize, int64_t pts)Encode a planar video frame.
Parameters
dataArray of per-plane data pointers (up to 4 planes).linesizeArray of per-plane byte strides.ptsPresentation timestamp in stream time base units.
Returns
True if an encoded packet was produced and emitted.
encode
virtual
virtual bool encode(AVFrame * iframe)Encode a single AVFrame.
Parameters
iframeThe source video frame; must have all fields set correctly.
Returns
True if an encoded packet was produced and emitted.
flush
virtual
virtual void flush()Flush any frames buffered inside the codec and emit remaining output.
convert
virtual
virtual AVFrame * convert(AVFrame * iframe)Convert the video frame and return the result.
The input frame will only be converted if it doesn't match the output format. If the frame is not converted the input frame will be returned. If the input frame format does not match the [VideoConverter](icy-av-VideoConverter.html#videoconverter) context then the [VideoConverter](icy-av-VideoConverter.html#videoconverter) will be recreated with the input frame params.
recreateConverter
virtual
virtual bool recreateConverter()Recreate the VideoConverter if the input or output parameters have changed. Called automatically by open() and convert().
Returns
True if the converter was (re)created, false if it is already up to date.
