Struct AVBuffer_ref
Represents a reference to an AVBuffer, providing a set of operations for handling buffer memory and metadata in a safe manner, while leveraging the underlying AVBufferRef structure.
Inherited Members
Namespace: FFmpeg.Collections
Assembly: FFmpeg.dll
Syntax
public readonly struct AVBuffer_ref : IBuffer, IEquatable<AVBuffer_ref>, IReference<AVBuffer>, IAVPointer<_AVBufferRef>
Properties
View SourceData
Gets the pointer to the buffer's data.
Declaration
public nint Data { get; }
Property Value
| Type | Description |
|---|---|
| nint |
IsNull
Gets a value indicating whether the buffer is uninitialized (null).
Declaration
public bool IsNull { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsReadOnly
Gets a value indicating whether the buffer is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| bool |
this[int]
Provides indexed access to the buffer's byte data.
Declaration
public byte this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index into the buffer. |
Property Value
| Type | Description |
|---|---|
| byte | The byte value at the specified index. |
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when the buffer is uninitialized. |
| ArgumentOutOfRangeException | Thrown when the index is out of bounds. |
Length
Gets the size of the buffer's data in bytes.
Declaration
public int Length { get; }
Property Value
| Type | Description |
|---|---|
| int |
LongLength
Gets the size of the buffer's data in long format.
Declaration
public long LongLength { get; }
Property Value
| Type | Description |
|---|---|
| long |
ReferenceCount
Gets the reference count of the buffer.
Declaration
public int ReferenceCount { get; }
Property Value
| Type | Description |
|---|---|
| int | Number of references held to the buffer, or -1 if the buffer is null. |
Methods
View SourceAsSpan()
Returns the buffer's data as a span of bytes.
Declaration
public Span<byte> AsSpan()
Returns
| Type | Description |
|---|---|
| Span<byte> | A Span<T> representing the buffer's data. |
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when the buffer is uninitialized. |
Clone()
Clones the current buffer reference into a new AVBuffer instance.
Declaration
public AVBuffer Clone()
Returns
| Type | Description |
|---|---|
| AVBuffer | A cloned instance of the buffer. |
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when the buffer is uninitialized. |
Copy()
Copies the buffer data to a new AVBuffer instance.
Declaration
public AVBuffer Copy()
Returns
| Type | Description |
|---|---|
| AVBuffer | A new AVBuffer containing the copied data. |
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when the buffer is uninitialized. |
| OutOfMemoryException | Thrown when memory allocation fails. |
Equals(AVBuffer_ref)
Declaration
public bool Equals(AVBuffer_ref other)
Parameters
| Type | Name | Description |
|---|---|---|
| AVBuffer_ref | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object?)
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
View SourceGetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
View SourceGetReferencedObject()
Retrieves the AVBuffer object currently referenced by this AVBuffer_ref.
Declaration
public AVBuffer? GetReferencedObject()
Returns
| Type | Description |
|---|---|
| AVBuffer | The AVBuffer if the buffer reference is valid; otherwise, |
Remarks
This method provides a safe way to access the buffer being referenced without exposing the underlying unmanaged pointer.
If the reference is null (i.e., IsNull is true), it returns null.
MakeWriteable()
Makes the buffer writable by ensuring a unique copy is made if necessary.
Declaration
public void MakeWriteable()
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when the buffer is uninitialized. |
| OutOfMemoryException | Thrown when memory allocation fails during write preparation. |
ReplaceWith(IBuffer)
Replaces the current buffer with another buffer.
Declaration
public void ReplaceWith(IBuffer src)
Parameters
| Type | Name | Description |
|---|---|---|
| IBuffer | src | The source buffer to replace with. |
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | Thrown when memory allocation fails during the replacement. |
Resize(int)
Resizes the buffer to the specified size.
Declaration
public void Resize(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| int | size | The new size for the buffer. |
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | Thrown when memory allocation fails during resizing. |
SetReferencedObject(AVBuffer?)
Sets the reference to a new AVBuffer object or unlinks the current reference.
Declaration
public void SetReferencedObject(AVBuffer? buffer)
Parameters
| Type | Name | Description |
|---|---|---|
| AVBuffer | buffer | The new AVBuffer object to reference, or |
Remarks
This method updates the underlying FFmpeg.AutoGen._AVBufferRef pointer to reference a new buffer object.
If buffer is null, the current reference is unlinked using ffmpeg.av_buffer_unref.
If a new object is provided, the reference is updated with ffmpeg.av_buffer_ref, and an OutOfMemoryException is thrown if the allocation fails.
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | Thrown if the system cannot allocate enough memory to create a new buffer reference when setting a non-null object. |
TryMakeWriteable()
Attempts to make the buffer writable. Returns true if successful.
Declaration
public bool TryMakeWriteable()
Returns
| Type | Description |
|---|---|
| bool |
TryReplaceWith(IBuffer)
Attempts to replace the current buffer with another buffer. Returns true if successful.
Declaration
public bool TryReplaceWith(IBuffer src)
Parameters
| Type | Name | Description |
|---|---|---|
| IBuffer | src |
Returns
| Type | Description |
|---|---|
| bool |
TryResize(int)
Attempts to resize the buffer to the specified size. Returns true if successful.
Declaration
public bool TryResize(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| int | size |
Returns
| Type | Description |
|---|---|
| bool |
Operators
View Sourceoperator ==(AVBuffer_ref, AVBuffer_ref)
Determines if two AVBuffer_ref instances are equal.
Declaration
public static bool operator ==(AVBuffer_ref left, AVBuffer_ref right)
Parameters
| Type | Name | Description |
|---|---|---|
| AVBuffer_ref | left | |
| AVBuffer_ref | right |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(AVBuffer_ref, AVBuffer_ref)
Determines if two AVBuffer_ref instances are not equal.
Declaration
public static bool operator !=(AVBuffer_ref left, AVBuffer_ref right)
Parameters
| Type | Name | Description |
|---|---|---|
| AVBuffer_ref | left | |
| AVBuffer_ref | right |
Returns
| Type | Description |
|---|---|
| bool |