AVImage

public final class AVImage

Undocumented

  • Undocumented

    Declaration

    Swift

    public let data: UnsafeMutableBufferPointer<UnsafeMutablePointer<UInt8>?>
  • Undocumented

    Declaration

    Swift

    public let size: Int
  • Undocumented

    Declaration

    Swift

    public let linesizes: UnsafeMutableBufferPointer<Int32>
  • Undocumented

    Declaration

    Swift

    public let width: Int
  • Undocumented

    Declaration

    Swift

    public let height: Int
  • Undocumented

    Declaration

    Swift

    public let pixelFormat: AVPixelFormat
  • Allocate an image with size and pixel format.

    Declaration

    Swift

    public init(width: Int, height: Int, pixelFormat: AVPixelFormat, align: Int = 1)

    Parameters

    width

    image width

    height

    image height

    pixelFormat

    image pixel format

    align

    the value to use for buffer size alignment, e.g. 1(no alignment), 16, 32, 64

  • Create an image from the given frame.

    Declaration

    Swift

    public init(frame: AVFrame)
  • Copy image from the given pixel buffer.

    Declaration

    Swift

    public func copy(
        from buffer: UnsafeMutablePointer<UnsafePointer<UInt8>?>,
        linesizes: UnsafePointer<Int32>
    )
  • Copy image from the given frame.

    Declaration

    Swift

    public func copy(from frame: AVFrame)
  • Reformat image using the given SwsContext.

    Throws

    AVError

    Declaration

    Swift

    @discardableResult
    public func reformat(using context: SwsContext, to image: AVImage) throws -> Int

    Return Value

    the height of the output slice

  • Compute the size of an image line with format and width for the plane.

    Throws

    AVError

    Declaration

    Swift

    public static func getLinesize(pixelFormat: AVPixelFormat, width: Int, plane: Int) throws -> Int

    Return Value

    the computed size in bytes

  • Fill plane linesizes for an image with pixel format and width.

    Throws

    AVError

    Declaration

    Swift

    public static func fillLinesizes(
        _ linesizes: UnsafeMutablePointer<Int32>,
        pixelFormat: AVPixelFormat,
        width: Int
    ) throws
  • Fill plane data pointers for an image with pixel format and height.

    Throws

    AVError

    Declaration

    Swift

    @discardableResult
    public static func fillPointers(
        _ data: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>,
        pixelFormat: AVPixelFormat,
        height: Int,
        buffer: UnsafeMutablePointer<UInt8>?,
        linesizes: UnsafePointer<Int32>?
    ) throws -> Int

    Parameters

    data

    pointers array to be filled with the pointer for each image plane

    pixelFormat

    the pixel format of the image

    height

    the height of the image

    buffer

    the pointer to a buffer which will contain the image

    linesizes

    the array containing the linesize for each plane, should be filled by fillLinesizes(_:pixelFormat:width:)

    Return Value

    the size in bytes required for the image buffer

  • Return the size in bytes of the amount of data required to store an image with the given parameters.

    Throws

    AVError

    Declaration

    Swift

    public static func getBufferSize(
        pixelFormat: AVPixelFormat,
        width: Int,
        height: Int,
        align: Int
    ) throws -> Int

    Parameters

    pixelFormat

    the pixel format of the image

    width

    the width of the image in pixels

    height

    the height of the image in pixels

    align

    the assumed linesize alignment

    Return Value

    the buffer size in bytes

  • Copy image data from an frame into a buffer.

    Throws

    AVError

    Declaration

    Swift

    @discardableResult
    public static func copyImageData(
        from frame: AVFrame,
        to buffer: UnsafeMutablePointer<UInt8>,
        size: Int,
        align: Int = 1
    ) throws -> Int

    Parameters

    frame

    the source frame

    buffer

    a buffer into which picture data will be copied

    size

    the size in bytes of dst

    align

    the assumed linesize alignment for dst

    Return Value

    the number of bytes written to dst

  • Create a pixel buffer and copy image data from an frame into the buffer.

    Throws

    AVError

    Declaration

    Swift

    public static func makePixelBuffer(
        from frame: AVFrame,
        align: Int = 1
    ) throws -> UnsafeMutableBufferPointer<UInt8>

    Parameters

    frame

    the source frame

    align

    the assumed linesize alignment for dst

    Return Value

    a buffer into which picture data will be copied