RESOLVED FIXED229251
[WebAudio/WebM] Incorrect number of frames returned if decoding frame rate doesn't match original
https://bugs.webkit.org/show_bug.cgi?id=229251
Summary [WebAudio/WebM] Incorrect number of frames returned if decoding frame rate do...
Jean-Yves Avenard [:jya]
Reported 2021-08-18 14:56:04 PDT
When calling decodeAudioData with a context where a sampling rate set is different to the original content, the number of frames returned may be incorrect STR: 1- Open https://jyavenard.github.io/htmltests/tests/webaudio/decodeAudioData.html 2- Select opus.webm as the file to use 3- Set the sampling rate to 44100 4- Press play The numbers showing are 88254 frames 2.001224489795918 which indicates that we've returned 88254 frames and that the length of the blob decoded is over 2s This file is originally encoded at 48kHz and is exactly 2s long. When forcing the content to be decoded at 44.1kHz we should be getting 88200 frames and a 2s duration. Something is wrong in the resampling and the trimming.
Attachments
Patch (8.95 KB, patch)
2021-09-08 03:40 PDT, Jean-Yves Avenard [:jya]
no flags
Patch (9.74 KB, patch)
2021-09-08 19:34 PDT, Jean-Yves Avenard [:jya]
no flags
Radar WebKit Bug Importer
Comment 1 2021-08-18 14:56:31 PDT
Jean-Yves Avenard [:jya]
Comment 2 2021-09-08 03:40:10 PDT
Eric Carlson
Comment 3 2021-09-08 15:19:30 PDT
Comment on attachment 437617 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=437617&action=review > Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.cpp:339 > + uint32_t leadingTrim = m_webmData->m_track->codecDelay().value_or(MediaTime()).toDouble() * outFormat.mSampleRate; `MediaTime::zeroTime()` should be cheaper than `MediaTime()` > Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.cpp:341 > + uint32_t trailingTrim = (m_webmData->m_track->codecDelay().value_or(MediaTime()) + m_webmData->m_track->discardPadding().value_or(MediaTime())).toDouble() * outFormat.mSampleRate - leadingTrim + 0.5; Ditto
Jean-Yves Avenard [:jya]
Comment 4 2021-09-08 19:34:27 PDT
EWS
Comment 5 2021-09-09 00:02:29 PDT
Committed r282196 (241483@main): <https://commits.webkit.org/241483@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 437698 [details].
Note You need to log in before you can comment on or make changes to this bug.