Show / Hide Table of Contents

Class SwsContext

Represents a context for scaling and converting image frames between different sizes and pixel formats. This class provides an interface for configuring the source and destination image properties and performing the conversion using the FFmpeg scaling library.

Inheritance
object
OptionQueryableBase
SwsContext
Implements
IOptionQueryable
ILoggingContext
IDisposable
IAVPointer<_SwsContext>
Inherited Members
OptionQueryableBase.ResetOptions()
OptionQueryableBase.GetOptions(bool)
OptionQueryableBase.FindOption(string, bool)
OptionQueryableBase.SetOption(string, string, bool)
OptionQueryableBase.SetOption(string, long, bool)
OptionQueryableBase.SetOption(string, bool, bool)
OptionQueryableBase.SetOption(string, double, bool)
OptionQueryableBase.SetOption(string, Rational, bool)
OptionQueryableBase.SetOption(string, ReadOnlySpan<byte>, bool)
OptionQueryableBase.SetOption(string, ReadOnlyMemory<byte>, bool)
OptionQueryableBase.SetOption(string, int, int, bool)
OptionQueryableBase.SetOption(string, (int Width, int Height), bool)
OptionQueryableBase.SetOption(string, PixelFormat, bool)
OptionQueryableBase.SetOption(string, SampleFormat, bool)
OptionQueryableBase.SetOption(string, IDictionary<string, string>, bool)
OptionQueryableBase.SetOption(string, ILookup<string, string>, bool)
OptionQueryableBase.SetOption(IDictionary<string, string>, bool)
OptionQueryableBase.SetOption(string, ref ILookup<string, string>, bool)
OptionQueryableBase.SetOption<T>(string, T, bool)
OptionQueryableBase.SetOption(string, object, bool)
OptionQueryableBase.SetOption(Option, string, bool)
OptionQueryableBase.SetOption(Option, bool, bool)
OptionQueryableBase.SetOption(Option, long, bool)
OptionQueryableBase.SetOption(Option, double, bool)
OptionQueryableBase.SetOption(Option, Rational, bool)
OptionQueryableBase.SetOption(Option, ReadOnlySpan<byte>, bool)
OptionQueryableBase.SetOption(Option, ReadOnlyMemory<byte>, bool)
OptionQueryableBase.SetOption(Option, int, int, bool)
OptionQueryableBase.SetOption(Option, (int Width, int Height), bool)
OptionQueryableBase.SetOption(Option, PixelFormat, bool)
OptionQueryableBase.SetOption(Option, SampleFormat, bool)
OptionQueryableBase.SetOption(Option, IDictionary<string, string>, bool)
OptionQueryableBase.SetOption(Option, ILookup<string, string>, bool)
OptionQueryableBase.SetOption<T>(Option, T, bool)
OptionQueryableBase.SetOption(Option, object, bool)
OptionQueryableBase.TryGetOption(string, out string, bool)
OptionQueryableBase.TryGetOption(string, out long, bool)
OptionQueryableBase.TryGetOption<T>(string, out T, bool)
OptionQueryableBase.TryGetOption(string, out ulong, bool)
OptionQueryableBase.TryGetOption(string, out int, bool)
OptionQueryableBase.TryGetOption(string, out bool, bool)
OptionQueryableBase.TryGetOption(string, out uint, bool)
OptionQueryableBase.TryGetOption(string, out double, bool)
OptionQueryableBase.TryGetOption(string, out Rational, bool)
OptionQueryableBase.TryGetOption(string, out PixelFormat, bool)
OptionQueryableBase.TryGetOption(string, out SampleFormat, bool)
OptionQueryableBase.TryGetOption(string, out IDictionary<string, string>, bool)
OptionQueryableBase.TryGetOption(string, out Dictionary<string, string>, bool)
OptionQueryableBase.TryGetOption(string, out AVDictionary, bool)
OptionQueryableBase.TryGetOption(string, out ILookup<string, string>, bool)
OptionQueryableBase.TryGetOption(string, out AVMultiDictionary, bool)
OptionQueryableBase.TryGetOption(string, out int, out int, bool)
OptionQueryableBase.TryGetOption(string, out (int Width, int Height), bool)
OptionQueryableBase.TryGetOption(string, Span<byte>, bool)
OptionQueryableBase.TryGetOption(string, out byte[], bool)
OptionQueryableBase.TryGetOption(string, out Memory<byte>, bool)
OptionQueryableBase.TryGetOption(string, out ReadOnlyMemory<byte>, bool)
OptionQueryableBase.TryGetOption(string, out object, bool)
OptionQueryableBase.TryGetOption(Option, out string, bool)
OptionQueryableBase.TryGetOption(Option, out long, bool)
OptionQueryableBase.TryGetOption<T>(Option, out T, bool)
OptionQueryableBase.TryGetOption(Option, out ulong, bool)
OptionQueryableBase.TryGetOption(Option, out int, bool)
OptionQueryableBase.TryGetOption(Option, out bool, bool)
OptionQueryableBase.TryGetOption(Option, out uint, bool)
OptionQueryableBase.TryGetOption(Option, out double, bool)
OptionQueryableBase.TryGetOption(Option, out Rational, bool)
OptionQueryableBase.TryGetOption(Option, out PixelFormat, bool)
OptionQueryableBase.TryGetOption(Option, out SampleFormat, bool)
OptionQueryableBase.TryGetOption(Option, out IDictionary<string, string>, bool)
OptionQueryableBase.TryGetOption(Option, out Dictionary<string, string>, bool)
OptionQueryableBase.TryGetOption(Option, out AVDictionary, bool)
OptionQueryableBase.TryGetOption(Option, out ILookup<string, string>, bool)
OptionQueryableBase.TryGetOption(Option, out AVMultiDictionary, bool)
OptionQueryableBase.TryGetOption(Option, out int, out int, bool)
OptionQueryableBase.TryGetOption(Option, out (int Width, int Height), bool)
OptionQueryableBase.TryGetOption(Option, out byte[], bool)
OptionQueryableBase.TryGetOption(Option, out Memory<byte>, bool)
OptionQueryableBase.TryGetOption(Option, out ReadOnlyMemory<byte>, bool)
OptionQueryableBase.TryGetOption(Option, Span<byte>, bool)
OptionQueryableBase.TryGetOption(Option, out object, bool)
OptionQueryableBase.SetOption(string, ChannelLayout, bool)
OptionQueryableBase.SetOption(Option, ChannelLayout, bool)
OptionQueryableBase.TryGetOption(string, out ChannelLayout, bool)
OptionQueryableBase.TryGetOption(Option, out ChannelLayout, bool)
object.GetType()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.Images
Assembly: FFmpeg.dll
Syntax
public sealed class SwsContext : OptionQueryableBase, IOptionQueryable, ILoggingContext, IDisposable, IAVPointer<_SwsContext>

Constructors

View Source

SwsContext(int, int, PixelFormat, int, int, PixelFormat, SwsAlgorithm)

Initializes a new SwsContext with a fixed source and destination image configuration.

Declaration
public SwsContext(int srcW, int srcH, PixelFormat srcFormat, int dstW, int dstH, PixelFormat dstFormat, SwsAlgorithm algorithm)
Parameters
Type Name Description
int srcW

The width of the source image, in pixels.

int srcH

The height of the source image, in pixels.

PixelFormat srcFormat

The pixel format of the source image.

int dstW

The width of the destination image, in pixels.

int dstH

The height of the destination image, in pixels.

PixelFormat dstFormat

The pixel format of the destination image.

SwsAlgorithm algorithm

The scaling algorithm and associated parameters to use.

Remarks

Use this constructor when converting between image buffers or image planes where the source and destination dimensions and pixel formats are known in advance. The source and destination properties of the created context are fixed for its lifetime and cannot be changed after construction.

If you intend to convert between AVFrame instances using Convert(AVFrame, AVFrame), prefer creating the context with Allocate() instead. An allocated context automatically configures itself to match the source and destination frames when scaling.

Properties

View Source

Algorithm

Gets the scaling algorithm used by this context.

Declaration
public SwsAlgorithm Algorithm { get; }
Property Value
Type Description
SwsAlgorithm
Remarks

For contexts created with Allocate(), the algorithm is currently fixed to the default algorithm selected during context initialization.

View Source

DestinationFormat

Gets the pixel format of the destination image.

Declaration
public PixelFormat DestinationFormat { get; }
Property Value
Type Description
PixelFormat
View Source

DestinationHeight

Gets the height of the destination image in pixels.

Declaration
public int DestinationHeight { get; }
Property Value
Type Description
int
View Source

DestinationWidth

Gets the width of the destination image in pixels.

Declaration
public int DestinationWidth { get; }
Property Value
Type Description
int
View Source

Pointer

Provides a pointer to the underlying FFmpeg scaling context.

Declaration
protected override void* Pointer { get; }
Property Value
Type Description
void*
Overrides
OptionQueryableBase.Pointer
View Source

SourceFormat

Gets the pixel format of the source image.

Declaration
public PixelFormat SourceFormat { get; }
Property Value
Type Description
PixelFormat
View Source

SourceHeight

Gets the height of the source image in pixels.

Declaration
public int SourceHeight { get; }
Property Value
Type Description
int
View Source

SourceWidth

Gets the width of the source image in pixels.

Declaration
public int SourceWidth { get; }
Property Value
Type Description
int

Methods

View Source

Allocate()

Allocates an unconfigured SwsContext.

Declaration
public static SwsContext Allocate()
Returns
Type Description
SwsContext

A new, unconfigured SwsContext suitable for frame-to-frame scaling.

Remarks

This is the preferred way to create a context when using Convert(AVFrame, AVFrame). The context is automatically configured from the source and destination frames each time it is used, updating the source and destination properties as needed.

Unlike SwsContext(int, int, PixelFormat, int, int, PixelFormat, SwsAlgorithm), the image dimensions and pixel formats are not fixed when the context is created.

The scaling algorithm cannot currently be specified when using this creation method.

View Source

CheckContext(SwsContext?, CodecContext, CodecContext)

Ensures that a scaling context matches the specified source and destination codec contexts.

Declaration
public static SwsContext CheckContext(SwsContext? context, CodecContext src, CodecContext dst)
Parameters
Type Name Description
SwsContext context

The existing scaling context, or null.

CodecContext src

The source codec context.

CodecContext dst

The destination codec context.

Returns
Type Description
SwsContext

A compatible SwsContext. If the supplied context is not compatible, it is disposed and replaced with a newly created instance.

Remarks

This helper is intended for applications that repeatedly convert frames whose dimensions or pixel formats may change during playback or encoding.

View Source

CheckContext(SwsContext?, CodecContext, AVFrame)

Ensures that a scaling context matches the specified source codec context and destination frame.

Declaration
public static SwsContext CheckContext(SwsContext? context, CodecContext src, AVFrame dst)
Parameters
Type Name Description
SwsContext context

The existing scaling context, or null.

CodecContext src

The source codec context.

AVFrame dst

The destination codec context.

Returns
Type Description
SwsContext

A compatible SwsContext. If the supplied context is not compatible, it is disposed and replaced with a newly created instance.

Remarks

This helper is intended for applications that repeatedly convert frames whose dimensions or pixel formats may change during playback or encoding.

View Source

CheckContext(SwsContext?, AVFrame, CodecContext)

Ensures that a scaling context matches the specified source and destination codec contexts.

Declaration
public static SwsContext CheckContext(SwsContext? context, AVFrame src, CodecContext dst)
Parameters
Type Name Description
SwsContext context

The existing scaling context, or null.

AVFrame src

The source codec context.

CodecContext dst

The destination codec context.

Returns
Type Description
SwsContext

A compatible SwsContext. If the supplied context is not compatible, it is disposed and replaced with a newly created instance.

Remarks

This helper is intended for applications that repeatedly convert frames whose dimensions or pixel formats may change during playback or encoding.

View Source

CheckContext(SwsContext?, AVFrame, AVFrame)

Ensures that a scaling context matches the specified source and destination frames.

Declaration
public static SwsContext CheckContext(SwsContext? context, AVFrame src, AVFrame dst)
Parameters
Type Name Description
SwsContext context

The existing scaling context, or null.

AVFrame src

The source codec context.

AVFrame dst

The destination codec context.

Returns
Type Description
SwsContext

A compatible SwsContext. If the supplied context is not compatible, it is disposed and replaced with a newly created instance.

Remarks

This helper is intended for applications that repeatedly convert frames whose dimensions or pixel formats may change during playback or encoding.

View Source

Convert(Image, Image)

Converts the source Image to the destination Image.

Declaration
public AVResult32 Convert(Image src, Image dst)
Parameters
Type Name Description
Image src

The source image to be converted.

Image dst

The destination image where the converted data will be stored.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(nint, ImageInfo, nint, ImageInfo)
View Source

Convert(Image, Image, SwsAlgorithm)

Converts the source Image to the destination Image using the specified scaling algorithm.

Declaration
public static AVResult32 Convert(Image src, Image dst, SwsAlgorithm algorithm)
Parameters
Type Name Description
Image src

The source image to be converted.

Image dst

The destination image where the converted data will be stored.

SwsAlgorithm algorithm

The scaling algorithm to use for the conversion.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(nint, ImageInfo, nint, ImageInfo, SwsAlgorithm)
View Source

Convert(Image, AVFrame)

Converts the source Image to the destination AVFrame using the current scaling context.

Declaration
public AVResult32 Convert(Image src, AVFrame dst)
Parameters
Type Name Description
Image src

The source image to be converted.

AVFrame dst

The destination frame where the converted data will be stored.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, Image)
View Source

Convert(Image, AVFrame, SwsAlgorithm)

Converts the source Image to the destination AVFrame using the specified scaling algorithm.

Declaration
public static AVResult32 Convert(Image src, AVFrame dst, SwsAlgorithm algorithm)
Parameters
Type Name Description
Image src

The source image to be converted.

AVFrame dst

The destination frame where the converted data will be stored.

SwsAlgorithm algorithm

The scaling algorithm to use for the conversion.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(Image, AVFrame, SwsAlgorithm)
View Source

Convert(AVFrame, Image)

Converts the source AVFrame to the destination Image using the current scaling context.

Declaration
public AVResult32 Convert(AVFrame src, Image dst)
Parameters
Type Name Description
AVFrame src

The source frame to be converted.

Image dst

The destination image where the converted data will be stored.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, AVFrame)
View Source

Convert(AVFrame, Image, SwsAlgorithm)

Converts the source AVFrame to the destination Image using the specified scaling algorithm.

Declaration
public static AVResult32 Convert(AVFrame src, Image dst, SwsAlgorithm algorithm)
Parameters
Type Name Description
AVFrame src

The source frame to be converted.

Image dst

The destination image where the converted data will be stored.

SwsAlgorithm algorithm

The scaling algorithm to use for the conversion.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, Image, SwsAlgorithm)
View Source

Convert(AVFrame, AVFrame)

Converts the source AVFrame to the destination AVFrame using the current scaling context.

Declaration
public AVResult32 Convert(AVFrame src, AVFrame dst)
Parameters
Type Name Description
AVFrame src

The source frame to be converted.

AVFrame dst

The destination frame where the converted data will be stored.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, Image)
View Source

Convert(AVFrame, AVFrame, SwsAlgorithm)

Converts the source AVFrame to the destination AVFrame using the current scaling context.

Declaration
public static AVResult32 Convert(AVFrame src, AVFrame dst, SwsAlgorithm algorithm)
Parameters
Type Name Description
AVFrame src

The source frame to be converted.

AVFrame dst

The destination frame where the converted data will be stored.

SwsAlgorithm algorithm

The algorithm used for scaling

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, Image)
View Source

Convert(AVFrame, nint, ImageInfo, SwsAlgorithm)

Converts the source AVFrame to the destination buffer, described by ImageInfo, using the specified scaling algorithm.

Declaration
public static AVResult32 Convert(AVFrame src, nint dst, ImageInfo dstInfo, SwsAlgorithm algorithm)
Parameters
Type Name Description
AVFrame src

The source frame to be converted.

nint dst

Pointer to the destination buffer.

ImageInfo dstInfo

Information describing the destination image.

SwsAlgorithm algorithm

The scaling algorithm to use for the conversion.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, nint, ImageInfo, SwsAlgorithm)
View Source

Convert(AVFrame, nint, int)

Converts the source AVFrame to a destination buffer at a specified memory location.

Declaration
public AVResult32 Convert(AVFrame src, nint dst, int dstAlign = 1)
Parameters
Type Name Description
AVFrame src

The source frame to be converted.

nint dst

The destination buffer as a memory pointer.

int dstAlign

Optional memory alignment for the destination buffer, default is 1.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, Span<byte>, int)
View Source

Convert(AVFrame, ReadOnlySpan<nint>, ReadOnlySpan<int>)

Converts pixel data from the specified source AVFrame into the destination image planes using the current scaling context.

Declaration
public AVResult32 Convert(AVFrame frame, ReadOnlySpan<nint> dstPlanes, ReadOnlySpan<int> dstStride)
Parameters
Type Name Description
AVFrame frame

The source frame. Its pixel format must match SourceFormat.

ReadOnlySpan<nint> dstPlanes

The destination image planes as an array of pointers. The array must contain at least as many elements as required by DestinationFormat.

ReadOnlySpan<int> dstStride

The line size, in bytes, for each destination plane.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(ReadOnlySpan<nint>, ReadOnlySpan<int>, AVFrame)
Convert(Span<byte>, AVFrame, int)
View Source

Convert(AVFrame, Span<byte>, int)

Converts the source AVFrame to a destination buffer represented as a Span<T>.

Declaration
public AVResult32 Convert(AVFrame src, Span<byte> dst, int dstAlign = 1)
Parameters
Type Name Description
AVFrame src

The source frame to be converted.

Span<byte> dst

The destination buffer as a Span<T>.

int dstAlign

Optional memory alignment for the destination buffer, default is 1.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, nint, int)
View Source

Convert(nint, ImageInfo, AVFrame, SwsAlgorithm)

Converts the source buffer, described by ImageInfo, to the destination AVFrame using the specified scaling algorithm.

Declaration
public static AVResult32 Convert(nint src, ImageInfo srcInfo, AVFrame dst, SwsAlgorithm algorithm)
Parameters
Type Name Description
nint src

Pointer to the source buffer.

ImageInfo srcInfo

Information describing the source image.

AVFrame dst

The destination frame where the converted data will be stored.

SwsAlgorithm algorithm

The scaling algorithm to use for the conversion.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(nint, ImageInfo, AVFrame, SwsAlgorithm)
View Source

Convert(nint, ImageInfo, nint, ImageInfo)

Converts the source buffer, described by ImageInfo, to the destination buffer, also described by ImageInfo.

Declaration
public AVResult32 Convert(nint src, ImageInfo srcInfo, nint dst, ImageInfo dstInfo)
Parameters
Type Name Description
nint src

Pointer to the source buffer.

ImageInfo srcInfo

The information describing the source image.

nint dst

Pointer to the destination buffer.

ImageInfo dstInfo

The information describing the destination image.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(nint, nint, int, int)
View Source

Convert(nint, ImageInfo, nint, ImageInfo, SwsAlgorithm)

Converts the source buffer, described by ImageInfo, to the destination buffer, also described by ImageInfo, using the specified scaling algorithm.

Declaration
public static AVResult32 Convert(nint src, ImageInfo srcInfo, nint dst, ImageInfo dstInfo, SwsAlgorithm algorithm)
Parameters
Type Name Description
nint src

Pointer to the source buffer.

ImageInfo srcInfo

Information describing the source image.

nint dst

Pointer to the destination buffer.

ImageInfo dstInfo

Information describing the destination image.

SwsAlgorithm algorithm

The scaling algorithm to use for the conversion.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(nint, ImageInfo, nint, ImageInfo)
View Source

Convert(nint, AVFrame, int)

Converts a source buffer from a specified memory location to the destination AVFrame.

Declaration
public AVResult32 Convert(nint src, AVFrame dst, int srcAlign = 1)
Parameters
Type Name Description
nint src

The source buffer as a memory pointer.

AVFrame dst

The destination frame where the converted data will be stored.

int srcAlign

Optional memory alignment for the source buffer, default is 1.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, nint, int)
View Source

Convert(nint, nint, int, int)

Converts the source buffer to the destination buffer, both specified by pointers, with optional alignments for source and destination.

Declaration
public AVResult32 Convert(nint src, nint dst, int srcAlign = 1, int dstAlign = 1)
Parameters
Type Name Description
nint src

Pointer to the source buffer.

nint dst

Pointer to the destination buffer.

int srcAlign

Optional memory alignment for the source buffer, default is 1.

int dstAlign

Optional memory alignment for the destination buffer, default is 1.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(nint, ImageInfo, nint, ImageInfo)
View Source

Convert(ReadOnlySpan<nint>, ReadOnlySpan<int>, AVFrame)

Converts pixel data from the specified source image planes into the destination AVFrame using the current scaling context.

Declaration
public AVResult32 Convert(ReadOnlySpan<nint> srcPlanes, ReadOnlySpan<int> srcStride, AVFrame frame)
Parameters
Type Name Description
ReadOnlySpan<nint> srcPlanes

The source image planes as an array of pointers. The array must contain at least as many elements as required by SourceFormat.

ReadOnlySpan<int> srcStride

The line size, in bytes, for each source plane.

AVFrame frame

The destination frame. Its pixel format must match DestinationFormat.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(AVFrame, ReadOnlySpan<nint>, ReadOnlySpan<int>)
View Source

Convert(ReadOnlySpan<nint>, ReadOnlySpan<int>, ReadOnlySpan<nint>, ReadOnlySpan<int>)

Converts the source and destination planes using the current scaling context.

Declaration
public AVResult32 Convert(ReadOnlySpan<nint> srcPlanes, ReadOnlySpan<int> srcStride, ReadOnlySpan<nint> dstPlanes, ReadOnlySpan<int> dstStride)
Parameters
Type Name Description
ReadOnlySpan<nint> srcPlanes

The source planes as an array of pointers.

ReadOnlySpan<int> srcStride

The line size of each source plane.

ReadOnlySpan<nint> dstPlanes

The destination planes as an array of pointers.

ReadOnlySpan<int> dstStride

The line size of each destination plane.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(Span<byte>, AVFrame, int)
View Source

Convert(Span<byte>, AVFrame, int)

Converts the source buffer, represented as a Span<T>, to the destination AVFrame.

Declaration
public AVResult32 Convert(Span<byte> src, AVFrame dst, int srcAlign = 1)
Parameters
Type Name Description
Span<byte> src

The source buffer as a Span<T>.

AVFrame dst

The destination frame where the converted data will be stored.

int srcAlign

Optional memory alignment for the source buffer, default is 1.

Returns
Type Description
AVResult32

An AVResult32 value indicating success or failure of the conversion operation.

See Also
Convert(nint, AVFrame, int)
View Source

Dispose()

Releases the unmanaged resources associated with this scaling context.

Declaration
public void Dispose()
Remarks

After calling this method, the context can no longer be used for image conversion.

View Source

~SwsContext()

Ensures the unmanaged data gets released.

Declaration
protected ~SwsContext()
View Source

GetBufferSize(int, int, PixelFormat, int)

Calculates the buffer size required for an image with the specified width, height, and pixel format.

Declaration
public static int GetBufferSize(int width, int height, PixelFormat fmt, int align = 1)
Parameters
Type Name Description
int width

The width of the image in pixels.

int height

The height of the image in pixels.

PixelFormat fmt

The pixel format of the image.

int align

Optional memory alignment, default is 1.

Returns
Type Description
int

The size of the buffer required to store the image.

View Source

GetDestinationBufferSize(int)

Calculates the buffer size required for the destination image based on its dimensions, format, and alignment.

Declaration
public int GetDestinationBufferSize(int align = 1)
Parameters
Type Name Description
int align

Optional memory alignment, default is 1.

Returns
Type Description
int

The size of the buffer required to store the destination image.

See Also
GetSourceBufferSize(int)
View Source

GetDestinationLineSize(int, int)

Gets the size of a single line (row) in the destination image for a given plane, considering the specified alignment.

Declaration
public int GetDestinationLineSize(int plane, int align = 1)
Parameters
Type Name Description
int plane

The plane index of the image.

int align

Optional memory alignment, default is 1.

Returns
Type Description
int

The size of the line in bytes.

See Also
GetSourceLineSize(int, int)
View Source

GetLineSize(int, PixelFormat, int, int)

Gets the size of a single line (row) in an image with the specified width, pixel format, and plane, considering the given alignment.

Declaration
public static int GetLineSize(int width, PixelFormat fmt, int plane, int align = 1)
Parameters
Type Name Description
int width

The width of the image in pixels.

PixelFormat fmt

The pixel format of the image.

int plane

The plane index of the image.

int align

Optional memory alignment, default is 1.

Returns
Type Description
int

The size of the line in bytes.

View Source

GetSourceBufferSize(int)

Calculates the buffer size required for the source image based on its dimensions, format, and alignment.

Declaration
public int GetSourceBufferSize(int align = 1)
Parameters
Type Name Description
int align

Optional memory alignment, default is 1.

Returns
Type Description
int

The size of the buffer required to store the source image.

See Also
GetDestinationBufferSize(int)
View Source

GetSourceLineSize(int, int)

Gets the size of a single line (row) in the source image for a given plane, considering the specified alignment.

Declaration
public int GetSourceLineSize(int plane, int align = 1)
Parameters
Type Name Description
int plane

The plane index of the image (e.g., 0 for Y plane in YUV format).

int align

Optional memory alignment, default is 1.

Returns
Type Description
int

The size of the line in bytes.

See Also
GetDestinationLineSize(int, int)

Implements

IOptionQueryable
ILoggingContext
IDisposable
IAVPointer<T>

Extension Methods

LoggingContextExtensions.Debug(ILoggingContext, string)
LoggingContextExtensions.Error(ILoggingContext, string)
LoggingContextExtensions.Fatal(ILoggingContext, string)
LoggingContextExtensions.Info(ILoggingContext, string)
LoggingContextExtensions.Log(ILoggingContext, LogLevel, string)
LoggingContextExtensions.Panic(ILoggingContext, string)
LoggingContextExtensions.Trace(ILoggingContext, string)
LoggingContextExtensions.Verbose(ILoggingContext, string)
LoggingContextExtensions.Warning(ILoggingContext, string)
  • View Source
In this article
Back to top Generated by DocFX