mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
resampler: Improve s16<-->s32 conversion, use s16 work format if input or output is s16
Problem: s16 to s32 conversion is performed as s16->float->s32 (via work format float) for resamplers TRIVIAL, COPY, PEAKS. Precision and efficiency suffers: e.g. 0x9fff results in 0x9ffe4001 (instead of 0x9fff0000) and there are two sample format conversions instead of one conversion. Solution: If input or output format is s16, then choose the work format to be s16 as well. If remapping is to be performed, we could stick to work format float32ne for precision reseans. This is debateable. Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
This commit is contained in:
parent
4b3de4422e
commit
3a3c4eb462
1 changed files with 3 additions and 1 deletions
|
|
@ -282,7 +282,9 @@ pa_resampler* pa_resampler_new(
|
|||
|
||||
if (r->map_required || a->format != b->format || method == PA_RESAMPLER_PEAKS) {
|
||||
|
||||
if (a->format == PA_SAMPLE_S32NE || a->format == PA_SAMPLE_S32RE ||
|
||||
if (a->format == PA_SAMPLE_S16NE || b->format == PA_SAMPLE_S16NE)
|
||||
r->work_format = PA_SAMPLE_S16NE;
|
||||
else if (a->format == PA_SAMPLE_S32NE || a->format == PA_SAMPLE_S32RE ||
|
||||
a->format == PA_SAMPLE_FLOAT32NE || a->format == PA_SAMPLE_FLOAT32RE ||
|
||||
a->format == PA_SAMPLE_S24NE || a->format == PA_SAMPLE_S24RE ||
|
||||
a->format == PA_SAMPLE_S24_32NE || a->format == PA_SAMPLE_S24_32RE ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue