Repository navigation
Audio: channel mixer matrix builder for QAudioFormat - #1600
Merged
Merged
Conversation
CommonFramework/AudioPipeline/ChannelMixer.h/.cpp:
build_channel_mixer_matrix() builds the N x M float weight matrix
(consumed by Kernels::AudioChannelMixer::mix_channels) from the
channel configs of two QAudioFormats, using the conventional
industry-standard coefficients (ITU-R BS.1116-1 style):
- same position passes through at gain 1
- mono <-> stereo duplicate / 0.5 average
- C -> L/R at 0.7, L/R -> C (upmix) at 0.35 each
- back/side surrounds -> front at 0.7 when the destination has
no surround on that side; BL <-> SL cross-fill at 0.7
- LFE passes through only, tops never mix
- returns an empty vector when either format's channel layout is
ChannelConfigUnknown; unnamed channels contribute zero
Kernels/AudioPipeline: add MixerMatrixTest infra and register 15
matrix cases (1<->2, 3.0, 5.1<->2.0/3.0/2.1/7.1, unknown layouts).
Kernels must not depend on Qt or CommonFramework, so the MixerMatrixTest infra moves below build_channel_mixer_matrix in CommonFramework/AudioPipeline/ChannelMixer.cpp, registered via add_tests_ChannelMixerMatrix() from ComputerPrograms/UnitTestRunner.cpp (the same pattern as BlackBorderDetector). Reverts the Kernels/AudioPipeline changes and drops the Qt5 stub (Qt6+ required). Also drops ffmpeg mentions from the comments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
build_channel_mixer_matrix(QAudioFormat in, QAudioFormat out)in CommonFramework/AudioPipeline/ChannelMixer.h/.cpp. It builds the N x M float weight matrix consumed byKernels::AudioChannelMixer::mix_channels(column-major: indexi + in_channels * o), so an input format's channels are converted to an output format's channels with conventional 'industry standard' coefficients (ITU-R BS.1116-1 style, matching FFmpeg's automatic rematrix):Failure semantics (per design): an empty vector is returned when either format's channel layout is
ChannelConfigUnknownor has a non-positive channel count. Channels present in the frame but unnamed by the config contribute zero (FFmpeg does not guess per-channel identities). No renormalization is applied (FFmpeg uses these fixed coefficients; a full-scale multichannel source can exceed full-scale in a narrow downmix).Qt 5 has no per-channel position info, so the builder returns empty there (Qt 6 API only), matching the existing
PA_AUDIO_USE_CHANNEL_CONFIGconvention.Tests: new
MixerMatrixTestinfra (Kernels/AudioPipeline/Kernels_ChannelMixer_Matrix_TestInfra.h/.cpp) with 15 registered cases (mono<->stereo, 3.0<->2.0, 5.1<->2.0/3.0/2.1/7.1/5.1, unknown layouts). Full command-line suite: 5446 passed, 0 failed.