-
Notifications
You must be signed in to change notification settings - Fork 8
Encoded Data
ReferenceType edited this page Mar 12, 2025
·
6 revisions
The EncodedData struct represents H.264 encoded data after encoding operation. Provides access to the data and its associated metadata.
The EncodedData struct encapsulates the encoded H.264 data along with metadata such as frame type, layer number, and temporal/spatial/quality identifiers. It is designed to efficiently manage and access encoded data, providing methods for copying and retrieving the data.
- Holds H.264 encoded data and metadata.
- Provides methods to retrieve data as a managed byte array.
- Supports copying data to streams and byte arrays.
| Property | Type | Description |
|---|---|---|
| DataPointer | IntPtr | Pointer to the unmanaged encoded data. |
| Length | int | Length of the encoded data in bytes. |
| FrameType | FrameType | Type of the encoded frame (e.g., I-frame, P-frame). |
| LayerNum | int | Layer number of the encoded data. |
| TemporalId | byte | Temporal identifier. |
| SpatialId | byte | Spatial identifier. |
| QualityId | byte | Quality identifier. |
| LayerType | byte | Layer type. |
| SubSeqId | int | Sub-sequence identifier. |
| Method | Return Type | Description |
|---|---|---|
| GetBytes() | byte[] | Creates a new managed byte array from the unmanaged data. |
| WriteTo(Stream s) | void | Copies the unmanaged data to a stream. |
| CopyTo(byte[] buffer, int startIndex) | int | Copies the unmanaged data to a byte array starting at the specified index. |
| Method | Return Type | Description |
|---|---|---|
| GetAllBytes(this EncodedData[] datas) | byte[] | Copies an array of EncodedData to a new managed byte array. |
| CopyAllTo(this EncodedData[] datas, byte[] toBuffer, int startIndex) | int | Copies an array of EncodedData to a provided buffer in contiguous order. |
| GetTotalSize(this EncodedData[] datas) | int | Gets the total size of all bytes in the collection. |
byte[] buffer = new byte[encodedData.Length + 10];
int bytesWritten = encodedData.CopyTo(buffer, 5); // Copy starting at index 5using (var stream = new MemoryStream())
{
encodedData.WriteTo(stream);
// ... use the stream ...
}EncodedData[] encodedDataArray = new EncodedData[] { /* ... */ };
// Get all bytes as a single array
byte[] allBytes = encodedDataArray.GetAllBytes();
// Copy all bytes to a buffer
byte[] buffer = new byte[encodedDataArray.GetTotalSize() + 10];
int bytesWritten = encodedDataArray.CopyAllTo(buffer, 5);
// Get total size
int totalSize = encodedDataArray.GetTotalSize();}