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

Function fromAudioSampleFormat

src/misc.ts:312–325  ·  view source on GitHub ↗
(sampleFormat: AudioSampleFormat)

Source from the content-addressed store, hash-verified

310};
311
312export const fromAudioSampleFormat = (sampleFormat: AudioSampleFormat): AVSampleFormat => {
313 switch (sampleFormat) {
314 case 'u8': return AV_SAMPLE_FMT_U8;
315 case 's16': return AV_SAMPLE_FMT_S16;
316 case 's32': return AV_SAMPLE_FMT_S32;
317 case 'f32': return AV_SAMPLE_FMT_FLT;
318 case 'u8-planar': return AV_SAMPLE_FMT_U8P;
319 case 's16-planar': return AV_SAMPLE_FMT_S16P;
320 case 's32-planar': return AV_SAMPLE_FMT_S32P;
321 case 'f32-planar': return AV_SAMPLE_FMT_FLTP;
322
323 default: return AV_SAMPLE_FMT_NONE;
324 }
325};
326
327export const toUint8Array = (source: AllowSharedBufferSource): Uint8Array => {
328 if (source.constructor === Uint8Array) { // We want a true Uint8Array, not something that extends it like Buffer

Callers 1

encodeInternalMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected