AVHWFramesContext
public final class AVHWFramesContext
This struct describes a set or pool of hardware
frames (i.e. those with
data not located in normal system memory). All the frames in the pool are
assumed to be allocated in the same way and interchangeable.
This struct is reference-counted with the AVBuffer
mechanism and tied to a
given AVHWDeviceContext
instance. The init(deviceContext:)
constructor
yields a reference, whose data field points to the actual AVHWFramesContext
struct.
-
Create an
AVHWFramesContext
tied to a given device context.Declaration
Swift
public init(deviceContext: AVHWDeviceContext)
Parameters
deviceContext
a
AVHWDeviceContext
instance. -
A reference to the parent
AVHWDeviceContext
.Declaration
Swift
public var deviceContext: AVHWDeviceContext { get }
-
The pixel format identifying the underlying HW surface type. Must be a hwaccel format, i.e. the corresponding descriptor must have the
AV_PIX_FMT_FLAG_HWACCEL
flag set.Must be set by the user before calling
initialize()
.Declaration
Swift
public var pixelFormat: AVPixelFormat { get set }
-
The pixel format identifying the actual data layout of the hardware frames.
Must be set by the caller before calling
initialize()
.Note
When the underlying API does not provide the exact data layout, but only the colorspace/bit depth, this field should be set to the fully planar version of that format (e.g. for 8-bit 420 YUV it should beAVPixelFormat.YUV420P
, notAVPixelFormat.NV12
or anything else).Declaration
Swift
public var swPixelFormat: AVPixelFormat { get set }
-
The width of the frames in this pool.
Must be set by the user before calling
initialize()
.Declaration
Swift
public var width: Int { get set }
-
The height of the frames in this pool.
Must be set by the user before calling
initialize()
.Declaration
Swift
public var height: Int { get set }
-
Initial size of the frame pool. If a device type does not support dynamically resizing the pool, then this is also the maximum pool size.
May be set by the caller before calling
initialize()
. Must be set if pool isnil
and the device type does not support dynamic pools.Declaration
Swift
public var initialPoolSize: Int { get set }
-
Finalize the context before use. This function must be called after the context is filled with all the required information and before it is attached to any frames.
Throws
AVErrorDeclaration
Swift
public func initialize() throws
-
Allocate a new frame attached to the given
AVHWFramesContext
.Throws
AVErrorDeclaration
Swift
public func allocBuffer(frame: AVFrame) throws
Parameters
frame
an empty (freshly allocated or unreffed) frame to be filled with newly allocated buffers.
-
Get a list of possible source or target formats usable in
AVFrame.transferData(from:)
.Declaration
Swift
public func getPixelFormats(_ direction: AVHWFrameTransferDirection) -> [AVPixelFormat]?
Parameters
direction
the direction of the transfer
Return Value
supported pixel formats