public static void ToPlanar(AudioFrame inOutFrame) { AudioResampler resampler = GetPlanarResampler(inOutFrame.format); if (resampler == null) { return; } var samples = inOutFrame.SampleCount; int bytes = resampler.GetOutBytes(samples); packedCache.Resize(bytes); var data = packedCache.data; Buffer.MemoryCopy((void *)inOutFrame.datas[0], (void *)data, bytes, bytes); int lineBytes = resampler.Destination.GetLineBytes(samples); inOutFrame.format = resampler.Destination; inOutFrame.Resize(samples); fixed(IntPtr *input = inOutFrame.datas) { resampler.Resample((IntPtr)(&data), samples, (IntPtr)input, samples); } inOutFrame.sampleCount = samples; }
public static void ToPacked(AudioFrame inOutFrame) { AudioResampler resampler = GetPackedResampler(inOutFrame.format); if (resampler == null) { return; } var samples = inOutFrame.SampleCount; int bytes = resampler.GetOutBytes(samples); packedCache.Resize(bytes); var data = packedCache.data; fixed(IntPtr *input = inOutFrame.datas) { resampler.Resample((IntPtr)input, samples, (IntPtr)(&data), samples); } inOutFrame.format = resampler.Destination; inOutFrame.Update(samples, packedCache.data); }