MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / removeEmulationPreventionBytes

Function removeEmulationPreventionBytes

src/codec_data.ts:106–121  ·  view source on GitHub ↗
(data: Uint8Array)

Source from the content-addressed store, hash-verified

104};
105
106const removeEmulationPreventionBytes = (data: Uint8Array) => {
107 const result: number[] = [];
108 const len = data.length;
109
110 for (let i = 0; i < len; i++) {
111 // Look for the 0x000003 pattern
112 if (i + 2 < len && data[i] === 0x00 && data[i + 1] === 0x00 && data[i + 2] === 0x03) {
113 result.push(0x00, 0x00); // Push the first two bytes
114 i += 2; // Skip the 0x03 byte
115 } else {
116 result.push(data[i]);
117 }
118 }
119
120 return new Uint8Array(result);
121};
122
123/** Parses an AVC SPS (Sequence Parameter Set) to extract basic information. */
124export const parseAvcSps = (sps: Uint8Array): AvcSpsInfo | null => {

Callers 2

parseAvcSpsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected