HWEncoder Class Reference
Representation of a GPU video encoder and its configuration. More...
#include <HWEncoder.hh>
Public Member Functions | |
HWEncoder (FlagSet< HWEncoderType > _allowedHwEncoders, const std::string &_hwAccelDevice, std::optional< bool > _useHwSurface) | |
Set up the HW encoder configurator. | |
virtual | ~HWEncoder () |
void | ConfigHWAccel (AVCodecContext *_encoderContext) |
Configure hardware acceleration. Should be called after the codec context parameters have been set, but before calling avcodec_open2(). | |
AVCodec * | FindEncoder (AVCodecID _codecId) |
HWEncoderType | GetEncoderType () const |
Returns the type of encoder that is currently being used. The value will be NONE until ConfigHWAccel() successfully finishes. | |
AVFrame * | GetFrameForEncoder (AVFrame *_inFrame) |
Get a pointer to the frame that contains the encoder input. This mainly serves for uploading the frame to GPU buffer if requested. | |
Detailed Description
Representation of a GPU video encoder and its configuration.
- Note
- This class is intentionally hidden as it provides highly customized behavior tailored just for the use with VideoEncoder.
Constructor & Destructor Documentation
◆ HWEncoder()
HWEncoder | ( | FlagSet< HWEncoderType > | _allowedHwEncoders, |
const std::string & | _hwAccelDevice, | ||
std::optional< bool > | _useHwSurface | ||
) |
Set up the HW encoder configurator.
- Parameters
-
[in] _allowedHwEncoders HW encoders to try. [in] _hwAccelDevice Optional name of the device that should be used. It doesn't affect unrelated HW encoders, but if the name is a match for an encoder, it will limit its search to only this device. However, if another encoder is tried earlier and succeeds, it will return with its default device. [in] _useHwSurface. If set, specifies whether the HW encoder should explicitly upload frames to the GPU, or whether that is left for the internals of the codec. If the value is unset, a HW-specific default is used that was experimentally found to be faster.
◆ ~HWEncoder()
|
virtual |
Member Function Documentation
◆ ConfigHWAccel()
void ConfigHWAccel | ( | AVCodecContext * | _encoderContext | ) |
Configure hardware acceleration. Should be called after the codec context parameters have been set, but before calling avcodec_open2().
- Parameters
-
[in] _encoderContext Context of the encoder for which hardware acceleration should be set up.
- Note
- If the configuration fails, the codec will be left configured for software encoding and an error will be written to gzerr describing what failed.
◆ FindEncoder()
AVCodec * FindEncoder | ( | AVCodecID | _codecId | ) |
Find a suitable encoder, preferring HW encoders.
- Parameters
-
[in] _codecId ID of the codec we seek the encoder for.
- Returns
- Name of the encoder to be used.
- Note
- The class expects that the returned encoder will be passed to ConfigHWAccel, and no other.
◆ GetEncoderType()
HWEncoderType GetEncoderType | ( | ) | const |
Returns the type of encoder that is currently being used. The value will be NONE until ConfigHWAccel() successfully finishes.
◆ GetFrameForEncoder()
AVFrame * GetFrameForEncoder | ( | AVFrame * | _inFrame | ) |
Get a pointer to the frame that contains the encoder input. This mainly serves for uploading the frame to GPU buffer if requested.
- Parameters
-
[in] _inFrame The input frame to be encoded (in CPU buffer).
- Returns
- Pointer to either this->avOutFrame or this->avOutHwFrame.
- Note
- If GPU buffers are used, this function uploads the frame from the CPU buffer to the GPU before returning.
The documentation for this class was generated from the following file: