You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Slow toFloatChannelData performance with Dolby Atmos audio #8
changed the title [-]Slow `toFloatChannelData` performance with Enhanced AC-3 audio[/-][+]Slow `toFloatChannelData` performance with Dolby Atmos audio[/+]on Jun 5, 2024
Perhaps it's worth adding that the Atmos mp4 has 12 channels:
(lldb) po format
<AVAudioFormat 0x60000212c5f0: 12 ch, 48000 Hz, Float32, deinterleaved>
Where as a typical mp3 has 2:
(lldb) po format
<AVAudioFormat 0x600002132300: 2 ch, 44100 Hz, Float32, deinterleaved>
I might have a go at optimising to only render using first two channels.
Potentially could use UnsafeBufferPointer to directly access the memory of pcmFloatChannelData, which could potentially be faster than the nested loops:
// Create the result array with preallocated capacity
varresult=[[Float]](repeating:[],count:channelCount)forchannelin0..<channelCount{result[channel]=Array(UnsafeBufferPointer(start:pcmFloatChannelData[channel],count:frameLength*stride))}
Activity
markst commentedon Jun 5, 2024
Happy to supply mp4 but will need approval. I may be able to find an example unlicensed.
I have also tried using
ffmpegto strip the video track with the following:markst commentedon Jun 5, 2024
ffmpeg format output:
[-]Slow `toFloatChannelData` performance with Enhanced AC-3 audio[/-][+]Slow `toFloatChannelData` performance with Dolby Atmos audio[/+]markst commentedon Jun 18, 2024
Perhaps it's worth adding that the Atmos mp4 has 12 channels:
Where as a typical mp3 has 2:
I might have a go at optimising to only render using first two channels.
Potentially could use
UnsafeBufferPointerto directly access the memory ofpcmFloatChannelData, which could potentially be faster than the nested loops:// Create the result array with preallocated capacity var result = [[Float]](repeating: [], count: channelCount) for channel in 0..<channelCount { result[channel] = Array(UnsafeBufferPointer(start: pcmFloatChannelData[channel], count: frameLength * stride)) }