Repository navigation
starboard: Add setting to skip audio resampling on unchanged sample rate - #13467
Conversation
|
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
There was a problem hiding this comment.
Code Review
This pull request introduces an experimental feature flag, kMediaSkipAudioResamplingOnUnchangedSampleRate, which allows AudioRendererPcm to skip routing decoded audio through the resampler when the sample rate remains unchanged, even if the audio sample type is not float32. This avoids unnecessary resampling overhead. The changes include reading the new experimental flag, updating the resampling logic in AudioRendererPcm::OnFirstOutput, and adding a new unit test SunnyDayWithInt16SamplesWithoutResampling to verify the behavior. There are no review comments to address, and I have no additional feedback to provide.
dd1f0ab to
0a79949
Compare
AudioRendererPcm feeds its AudioTimeStretcher float32 samples. When the decoder produces another sample type, e.g. the int16 output of the Android MediaCodec audio decoder, OnFirstOutput() creates a full AudioResamplerImpl even if the sample rate doesn't change, so every buffer goes through a 32-tap sinc convolution at a ratio of 1.0 just to be converted to float32. Add the H5vcc setting Media.SkipAudioResamplingOnUnchangedSampleRate. When it is set, IdentityAudioResampler is used whenever the sample rate is unchanged and the samples are converted by the existing code in ProcessAudioData() before they are enqueued to the time stretcher, as is already the case for float32 decoders. The setting is off by default so the change can be experimented with in production. Measured on a local Android TV device (Android 10, 4x Cortex-A53) playing a 1080p24 VP9 + AAC 44.1 kHz stereo YouTube video through the MediaCodec audio decoder (int16 output), averaged over two 95 s windows: player_worker thread: 6.9% -> 2.9% of one core Cobalt process total: 65.8% -> 62.0% of one core Bug: 511356295 TAG=agy CONV=75cbba55-91ae-4914-a546-0ce1106643ed
0a79949 to
ecfdae3
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces an experimental feature, kMediaSkipAudioResamplingOnUnchangedSampleRate, which allows AudioRendererPcm to skip routing decoded audio through the resampler when the sample rate is unchanged, even if a sample type conversion to float32 is needed. The changes implement this optimization in AudioRendererPcm and add a new unit test, SunnyDayWithInt16SamplesWithoutResampling, to verify the behavior. I have no feedback to provide as there are no review comments and the implementation is clean.
…g on unchanged sample rate Refer to original PR: #13467 AudioRendererPcm feeds its AudioTimeStretcher float32 samples. When the decoder produces another sample type, e.g. the int16 output of the Android MediaCodec audio decoder, OnFirstOutput() creates a full AudioResamplerImpl even if the sample rate doesn't change, so every buffer goes through a 32-tap sinc convolution at a ratio of 1.0 just to be converted to float32. Add the H5vcc setting Media.SkipAudioResamplingOnUnchangedSampleRate. When it is set, IdentityAudioResampler is used whenever the sample rate is unchanged and the samples are converted by the existing code in ProcessAudioData() before they are enqueued to the time stretcher, as is already the case for float32 decoders. The setting is off by default so the change can be experimented with in production. Measured on a local Android TV device (Android 10, 4x Cortex-A53) playing a 1080p24 VP9 + AAC 44.1 kHz stereo YouTube video through the MediaCodec audio decoder (int16 output), averaged over two 95 s windows: player_worker thread: 6.9% -> 2.9% of one core Cobalt process total: 65.8% -> 62.0% of one core Bug: 511356295 (cherry picked from commit 0183d36)
…g on unchanged sample rate Refer to original PR: #13467 AudioRendererPcm feeds its AudioTimeStretcher float32 samples. When the decoder produces another sample type, e.g. the int16 output of the Android MediaCodec audio decoder, OnFirstOutput() creates a full AudioResamplerImpl even if the sample rate doesn't change, so every buffer goes through a 32-tap sinc convolution at a ratio of 1.0 just to be converted to float32. Add the H5vcc setting Media.SkipAudioResamplingOnUnchangedSampleRate. When it is set, IdentityAudioResampler is used whenever the sample rate is unchanged and the samples are converted by the existing code in ProcessAudioData() before they are enqueued to the time stretcher, as is already the case for float32 decoders. The setting is off by default so the change can be experimented with in production. Measured on a local Android TV device (Android 10, 4x Cortex-A53) playing a 1080p24 VP9 + AAC 44.1 kHz stereo YouTube video through the MediaCodec audio decoder (int16 output), averaged over two 95 s windows: player_worker thread: 6.9% -> 2.9% of one core Cobalt process total: 65.8% -> 62.0% of one core Bug: 511356295 (cherry picked from commit 0183d36)
…g on unchanged sample rate Refer to original PR: #13467 AudioRendererPcm feeds its AudioTimeStretcher float32 samples. When the decoder produces another sample type, e.g. the int16 output of the Android MediaCodec audio decoder, OnFirstOutput() creates a full AudioResamplerImpl even if the sample rate doesn't change, so every buffer goes through a 32-tap sinc convolution at a ratio of 1.0 just to be converted to float32. Add the H5vcc setting Media.SkipAudioResamplingOnUnchangedSampleRate. When it is set, IdentityAudioResampler is used whenever the sample rate is unchanged and the samples are converted by the existing code in ProcessAudioData() before they are enqueued to the time stretcher, as is already the case for float32 decoders. The setting is off by default so the change can be experimented with in production. Measured on a local Android TV device (Android 10, 4x Cortex-A53) playing a 1080p24 VP9 + AAC 44.1 kHz stereo YouTube video through the MediaCodec audio decoder (int16 output), averaged over two 95 s windows: player_worker thread: 6.9% -> 2.9% of one core Cobalt process total: 65.8% -> 62.0% of one core Bug: 511356295 (cherry picked from commit 0183d36)
…g on unchanged sample rate Refer to original PR: #13467 AudioRendererPcm feeds its AudioTimeStretcher float32 samples. When the decoder produces another sample type, e.g. the int16 output of the Android MediaCodec audio decoder, OnFirstOutput() creates a full AudioResamplerImpl even if the sample rate doesn't change, so every buffer goes through a 32-tap sinc convolution at a ratio of 1.0 just to be converted to float32. Add the H5vcc setting Media.SkipAudioResamplingOnUnchangedSampleRate. When it is set, IdentityAudioResampler is used whenever the sample rate is unchanged and the samples are converted by the existing code in ProcessAudioData() before they are enqueued to the time stretcher, as is already the case for float32 decoders. The setting is off by default so the change can be experimented with in production. Measured on a local Android TV device (Android 10, 4x Cortex-A53) playing a 1080p24 VP9 + AAC 44.1 kHz stereo YouTube video through the MediaCodec audio decoder (int16 output), averaged over two 95 s windows: player_worker thread: 6.9% -> 2.9% of one core Cobalt process total: 65.8% -> 62.0% of one core Bug: 511356295 (cherry picked from commit 0183d36)
AudioRendererPcm feeds its AudioTimeStretcher float32 samples. When the decoder produces another sample type, e.g. the int16 output of the Android MediaCodec audio decoder, OnFirstOutput() creates a full AudioResamplerImpl even if the sample rate doesn't change, so every buffer goes through a 32-tap sinc convolution at a ratio of 1.0 just to be converted to float32.
Add the H5vcc setting Media.SkipAudioResamplingOnUnchangedSampleRate. When it is set, IdentityAudioResampler is used whenever the sample rate is unchanged and the samples are converted by the existing code in ProcessAudioData() before they are enqueued to the time stretcher, as is already the case for float32 decoders. The setting is off by default so the change can be experimented with in production.
Measured on a local Android TV device (Android 10, 4x Cortex-A53) playing a 1080p24 VP9 + AAC 44.1 kHz stereo YouTube video through the MediaCodec audio decoder (int16 output), averaged over two 95 s windows:
player_worker thread: 6.9% -> 2.9% of one core
Cobalt process total: 65.8% -> 62.0% of one core
Bug: 511356295