summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioResamplerSinc.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Return number of frames output from resample methodAndy Hung2015-04-081-6/+8
| | | | Change-Id: Ic297e2ed59839f1788c83e099ef1a9e4af29591f
* Remove redundant semicolon from namespace closingGlenn Kasten2015-03-031-1/+1
| | | | Change-Id: I163f9d3d216c283ae1160ce4802e5247cf44fba7
* Line length 100Glenn Kasten2015-02-271-1/+2
| | | | Change-Id: Ic0ae92c300df221387bdd9669e4b7b995d83d28a
* Extract resampler coefficient tables to separate filesGlenn Kasten2015-02-271-258/+2
| | | | Change-Id: I2e186bd3172cecc08c436e6bf7546b913249e6c8
* am c53b98f3: am 6cd6792a: Merge "Allow building on clang without ↵Ian Rogers2014-09-261-1/+4
|\ | | | | | | | | | | | | __builtin_assume_aligned" * commit 'c53b98f3773299ca26acbe5c4a56450a76c2ecf9': Allow building on clang without __builtin_assume_aligned
| * Allow building on clang without __builtin_assume_alignedBernhard Rosenkraenzer2014-09-191-1/+4
| | | | | | | | | | | | | | | | | | Clang versions up to and including 3.5 don't have __builtin_assume_aligned. Define it to a reasonable approximation when building with those. Change-Id: I223ccfda6e6ae55ce29dda5e4cacc1b162728b2c Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
* | Add floating point volume handling to AudioMixerAndy Hung2014-07-081-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use floating point volume in AudioMixer mixing when floating point input is used with the new mixer engine. AudioResampler is updated to take floating point volume to match. Both legacy integer and floating point mixer engines work. For now, integer volume is used when the new mixer engine runs in integer input mode, for backward compatibility with the legacy mixer. The new mixer engine will generally run in floating point input mode. When the legacy path is removed, the integer volumes will be removed. Change-Id: I79e80c292ae7c8b8bdd0aa371a1b2c3a1b618290
* | Replace int bitDepth with audio_format_t in ResamplerAndy Hung2014-07-071-2/+2
| | | | | | | | | | | | | | | | Remove mBitDepth from class (not used). Replace with audio_format_t in factory method to distinguish between float and pcm 16-bit. Change-Id: I166860796c68285077ef4458d8758d19b82523f9
* | am 7e5c6351: am 4513aa2c: Merge "AArch64: rewrite audioflinger\'s sinc ↵Glenn Kasten2014-04-241-151/+165
|\ \ | |/ | | | | | | | | | | resample by intrinsics." * commit '7e5c635114a7762ad44581300021667a0da97389': AArch64: rewrite audioflinger's sinc resample by intrinsics.
| * AArch64: rewrite audioflinger's sinc resample by intrinsics.Zhongwei Yao2014-04-101-151/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Pass conformance test on armv7 and aarch64, performance test is done on armv7. Compared with original armv7 assembly version, this version has similar result. Here is performance data on pandaboard android4.4 (input: random wave file, unit: Mspl/s, toolchain:gcc 4.8): | | origin(assembly) | current(intrinsics) | C version | |----------------+------------------+---------------------+-----------| | single channel | 6.17 | 7.14 | 3.43 | | double channel | 5.24 | 5.63 | 3.50 | Change-Id: If5670218e1586e9dfd2b8d9c66a6880f3e4808ca
| * Fix build warningsGlenn Kasten2012-12-171-3/+3
| | | | | | | | Change-Id: I9e3cfa0c6b3467fe763ce55f759d179f02c5deea
| * fix a typo in SINC resampler that prevented tracks to be mixedMathias Agopian2012-11-191-2/+2
| | | | | | | | | | | | we were always erasing the current mix instead of mixing into it. Change-Id: Ib229245f9e5a0d384f1727640a59e9f0469211a2
| * more optimizations...Mathias Agopian2012-11-101-13/+18
| | | | | | | | | | | | | | | | | | | | | | calculate the offsets from the phase differently, this happens to reduce the register pressure in the main loop, which in turns allows the compiler to generate much better code (doesn't need to spill a lot of stuff on the stack). this gives another 15% performance increase Change-Id: I2ce3479dd48b9e6941adb80e6d443d6e14d64d96
| * refactor code to improve neon codeMathias Agopian2012-11-101-33/+42
| | | | | | | | | | | | | | | | | | we want to make sure we don't transfer data from the neon unit to the arm register file, as this can be quite slow. instead we do all the calculation on the neon side and write the result directly to main memory. Change-Id: Ibb56664d3ab03098ae2798b75e2b6927ac900187
| * NEON optimized SINC resamplerMathias Agopian2012-11-081-10/+165
| | | | | | | | | | | | | | this currently gives us a 60% to 80% boost depending on the quality level selected. Change-Id: I7db385007e811ed7bffe5fd3403b44e300894f5b
| * minor cleanupsMathias Agopian2012-11-081-41/+39
| | | | | | | | Change-Id: Ia12ee4fb59e90221761bec85e6450db29197591f
| * change how we store the FIR coefficientsMathias Agopian2012-11-051-38/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The coefficient table is now transposed and shows much better its polyphase nature: we now have a FIR per line, each line corresponding to a phase. This doesn't change at all the results produced by the filter, but allows us to make slightly better use of the data cache and improves performance a bit (although not as much as I thought it would). The main benefit is that it is the first step before we can make much larger optimizations (like using NEON). Change-Id: Iebf7695825dcbd41f25861efcaefbaa3365ecb43
| * improve SINC resampler performanceMathias Agopian2012-11-051-39/+25
| | | | | | | | | | | | | | | | The improvement is about 60% by just tweaking a few things to help the compiler generate better code. It turns out that inlining too much stuff manually was hurting us. Change-Id: I8068f0f75051f95ac600e50ce552572dd1e8c304
| * new coefficients for the vhq resamplerMathias Agopian2012-11-011-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | previous coefficients were provided by a 3rd party and didn't have a way to re-generate them. we're now using the 'fir' utility. the performance of the filter is virtually identical, except for the down-sampling case which seems slightly better now: It looks like both the previous and new coefficients are generating some sort of clipping for full-scale signals in the down-sampling case (although the new ones seem better), the reason for that is unknown (see bug: 7453062) Also updated the HQ coefficients for the down-samplers, previous ones were a little bit too conservative -- the new ones push the cut-off frequency up by about 1 KHz. Change-Id: I54a827b5c707c7cc41268ed01283758dce1d7647
| * fix SINC resampler on non ARM architecturesMathias Agopian2012-10-301-15/+5
| | | | | | | | | | | | | | make sure the C version of the code generates the same output than the ARM assemply version. Change-Id: Ide218785c35d02598b2d7278e646b1b178148698
| * fix another issue with generating FIR coefficientsMathias Agopian2012-10-301-18/+18
| | | | | | | | | | | | | | | | the impulse response of a low-pass is 2*f*sinc(2*pi*f*k), we were missing the 2*f scale factor. This explains why we were seeing clipping and had to manually scale the filter down. Change-Id: I86d0bb82ecdd99681c8ba5a8112a8257bf6f0186
| * fir a typo that caused up-sampling coefficiens to be wrongMathias Agopian2012-10-291-17/+17
| | | | | | | | | | | | | | | | | | | | up-sample coefficient were generated with a cut-off frequency of 24KHz intead of ~20KHz, which caused more aliasing in the audible band. also increased the attenuation to 1.3 dB on both up and down sampling coefficient to avoid clipping. Change-Id: Ie8aeecf1429190541b656810c6716b6aae5ece2e
| * improve SINC resampler coefficientsMathias Agopian2012-10-261-22/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - we increase the interpolation precision from 4 to 7 bits this doesn't increase CPU power required, it only increases the size of the filter table but significantly reduces the noise introduced by the quantization of the impulse response. - the parameters of the filter are set such that aliasing is rejected at 80 dB below 20 KHz. Because we don't use a lot of coefficient (to save compute power), there are quite a bit of attenuation in the pass-band: starting at 9KHz for the down-sampler (48 to 44.1), and starting at 13 KHz for the up-sampler (44.1 to 48) -- the transition band is about 15 KHz. Change-Id: I855548d2aab8a0fb0d2a2da3a364b6842d7d3838
| * Fix a typo that caused the high quality resampler to produce garbageMathias Agopian2012-10-211-1/+1
| | | | | | | | | | | | | | | | | | the problem is that if libaudio_resampler is present, it is those coefficients that will always be selected, but the correct meta-data. Bug: 7385994 Change-Id: Ieebeb37b4dfb62a1a051bc29fae2ce056dbc6621
| * Integrate improved coefficient sinc resampler: VHQGlenn Kasten2012-10-041-82/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Very high quality is enabled only for 44.1 -> 48 or 48 -> 44.1, and uses low quality for all other use cases. Track estimated CPU load and throttles the quality based on load; as currently configured it should allow up to 2 instances of very high quality. Medium quality and high quality are currently disabled unless explicitly requested. Details: Only load .so the first time it is needed. Cleanup code style: formatting, indentation, whitespace. Restore medium quality resampler, but it is not used (see next line). Fix memory leak for sinc resampler. Check sample rate in resampler constructor. Add logs for debugging. Rename DEFAULT to DEFAULT_QUALITY for consistency with other quality levels. Renumber VERY_HIGH_QUALITY from 255 to 4. Use enum src_quality consistently. Improve parsing of property af.resampler.quality. Fix reentrancy bug - allow an instance of high quality and an instance of very high quality to both be active concurrently. Bug: 7229644 Change-Id: I0ce6b913b05038889f50462a38830b61a602a9f7
| * audioflinger: use resample coefficients from audio-resampler library.SathishKumar Mani2012-09-261-9/+87
| | | | | | | | | | | | | | | | | | | | | | -Add a separate quality VERY_HIGH_QUALITY in resampler -Use resample coefficients audio-resampler library for quality VERY_HIGH_QUALITY. -This improves the quality of resampled output. Bug: 7024293 Change-Id: Ia44142413bed5f5963d7eab7846eec877a2415e4 Signed-off-by: Iliyan Malchev <malchev@google.com>
* | Fix resampler to allow output of single frameAndy Hung2014-02-191-1/+1
| | | | | | | | | | | | Bug: 13073201 Change-Id: If7818a3389a191a37277bbd8e96a59ef8ce68509 Signed-off-by: Andy Hung <hunga@google.com>
* | Fix build warningsGlenn Kasten2012-12-171-3/+3
| | | | | | | | Change-Id: I9e3cfa0c6b3467fe763ce55f759d179f02c5deea
* | fix a typo in SINC resampler that prevented tracks to be mixedMathias Agopian2012-11-191-2/+2
| | | | | | | | | | | | we were always erasing the current mix instead of mixing into it. Change-Id: Ib229245f9e5a0d384f1727640a59e9f0469211a2
* | more optimizations...Mathias Agopian2012-11-101-13/+18
| | | | | | | | | | | | | | | | | | | | | | calculate the offsets from the phase differently, this happens to reduce the register pressure in the main loop, which in turns allows the compiler to generate much better code (doesn't need to spill a lot of stuff on the stack). this gives another 15% performance increase Change-Id: I2ce3479dd48b9e6941adb80e6d443d6e14d64d96
* | refactor code to improve neon codeMathias Agopian2012-11-101-33/+42
| | | | | | | | | | | | | | | | | | we want to make sure we don't transfer data from the neon unit to the arm register file, as this can be quite slow. instead we do all the calculation on the neon side and write the result directly to main memory. Change-Id: Ibb56664d3ab03098ae2798b75e2b6927ac900187
* | NEON optimized SINC resamplerMathias Agopian2012-11-081-10/+165
| | | | | | | | | | | | | | this currently gives us a 60% to 80% boost depending on the quality level selected. Change-Id: I7db385007e811ed7bffe5fd3403b44e300894f5b
* | minor cleanupsMathias Agopian2012-11-081-41/+39
| | | | | | | | Change-Id: Ia12ee4fb59e90221761bec85e6450db29197591f
* | change how we store the FIR coefficientsMathias Agopian2012-11-051-38/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The coefficient table is now transposed and shows much better its polyphase nature: we now have a FIR per line, each line corresponding to a phase. This doesn't change at all the results produced by the filter, but allows us to make slightly better use of the data cache and improves performance a bit (although not as much as I thought it would). The main benefit is that it is the first step before we can make much larger optimizations (like using NEON). Change-Id: Iebf7695825dcbd41f25861efcaefbaa3365ecb43
* | improve SINC resampler performanceMathias Agopian2012-11-051-39/+25
| | | | | | | | | | | | | | | | The improvement is about 60% by just tweaking a few things to help the compiler generate better code. It turns out that inlining too much stuff manually was hurting us. Change-Id: I8068f0f75051f95ac600e50ce552572dd1e8c304
* | new coefficients for the vhq resamplerMathias Agopian2012-11-011-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | previous coefficients were provided by a 3rd party and didn't have a way to re-generate them. we're now using the 'fir' utility. the performance of the filter is virtually identical, except for the down-sampling case which seems slightly better now: It looks like both the previous and new coefficients are generating some sort of clipping for full-scale signals in the down-sampling case (although the new ones seem better), the reason for that is unknown (see bug: 7453062) Also updated the HQ coefficients for the down-samplers, previous ones were a little bit too conservative -- the new ones push the cut-off frequency up by about 1 KHz. Change-Id: I54a827b5c707c7cc41268ed01283758dce1d7647
* | fix SINC resampler on non ARM architecturesMathias Agopian2012-10-301-15/+5
| | | | | | | | | | | | | | make sure the C version of the code generates the same output than the ARM assemply version. Change-Id: Ide218785c35d02598b2d7278e646b1b178148698
* | fix another issue with generating FIR coefficientsMathias Agopian2012-10-301-18/+18
| | | | | | | | | | | | | | | | the impulse response of a low-pass is 2*f*sinc(2*pi*f*k), we were missing the 2*f scale factor. This explains why we were seeing clipping and had to manually scale the filter down. Change-Id: I86d0bb82ecdd99681c8ba5a8112a8257bf6f0186
* | fir a typo that caused up-sampling coefficiens to be wrongMathias Agopian2012-10-291-17/+17
| | | | | | | | | | | | | | | | | | | | up-sample coefficient were generated with a cut-off frequency of 24KHz intead of ~20KHz, which caused more aliasing in the audible band. also increased the attenuation to 1.3 dB on both up and down sampling coefficient to avoid clipping. Change-Id: Ie8aeecf1429190541b656810c6716b6aae5ece2e
* | improve SINC resampler coefficientsMathias Agopian2012-10-261-22/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - we increase the interpolation precision from 4 to 7 bits this doesn't increase CPU power required, it only increases the size of the filter table but significantly reduces the noise introduced by the quantization of the impulse response. - the parameters of the filter are set such that aliasing is rejected at 80 dB below 20 KHz. Because we don't use a lot of coefficient (to save compute power), there are quite a bit of attenuation in the pass-band: starting at 9KHz for the down-sampler (48 to 44.1), and starting at 13 KHz for the up-sampler (44.1 to 48) -- the transition band is about 15 KHz. Change-Id: I855548d2aab8a0fb0d2a2da3a364b6842d7d3838
* | Fix a typo that caused the high quality resampler to produce garbageMathias Agopian2012-10-211-1/+1
| | | | | | | | | | | | | | | | | | the problem is that if libaudio_resampler is present, it is those coefficients that will always be selected, but the correct meta-data. Bug: 7385994 Change-Id: Ieebeb37b4dfb62a1a051bc29fae2ce056dbc6621
* | Integrate improved coefficient sinc resampler: VHQGlenn Kasten2012-10-041-82/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Very high quality is enabled only for 44.1 -> 48 or 48 -> 44.1, and uses low quality for all other use cases. Track estimated CPU load and throttles the quality based on load; as currently configured it should allow up to 2 instances of very high quality. Medium quality and high quality are currently disabled unless explicitly requested. Details: Only load .so the first time it is needed. Cleanup code style: formatting, indentation, whitespace. Restore medium quality resampler, but it is not used (see next line). Fix memory leak for sinc resampler. Check sample rate in resampler constructor. Add logs for debugging. Rename DEFAULT to DEFAULT_QUALITY for consistency with other quality levels. Renumber VERY_HIGH_QUALITY from 255 to 4. Use enum src_quality consistently. Improve parsing of property af.resampler.quality. Fix reentrancy bug - allow an instance of high quality and an instance of very high quality to both be active concurrently. Bug: 7229644 Change-Id: I0ce6b913b05038889f50462a38830b61a602a9f7
* | audioflinger: use resample coefficients from audio-resampler library.SathishKumar Mani2012-09-261-9/+87
|/ | | | | | | | | | | -Add a separate quality VERY_HIGH_QUALITY in resampler -Use resample coefficients audio-resampler library for quality VERY_HIGH_QUALITY. -This improves the quality of resampled output. Bug: 7024293 Change-Id: Ia44142413bed5f5963d7eab7846eec877a2415e4 Signed-off-by: Iliyan Malchev <malchev@google.com>
* Whitespace and indentationGlenn Kasten2012-03-131-2/+2
| | | | | | | | | | | | | | Fix indentation to be multiple of 4. Make it easier to search: sp< not sp < to "switch (...)" instead of "switch(...)" (also "if" and "while") Remove redundant blank line at start or EOF. Remove whitespace at end of line. Remove extra blank lines where they don't add value. Use git diff -b or -w to verify. Change-Id: I966b7ba852faa5474be6907fb212f5e267c2874e
* Upintegrate Audio Flinger changes from ICS_AAHJohn Grossman2012-02-161-2/+2
| | | | | | | | Bring in changes to audio flinger made to support timed audio tracks and HW master volume control. Change-Id: Ide52d48809bdbed13acf35fd59b24637e35064ae Signed-off-by: John Grossman <johngro@google.com>
* Remove aliasingGlenn Kasten2012-02-091-12/+11
| | | | | | | | | Code was aliasing mBuffer as buffer, but continuing to use both buffer and mBuffer after that point. This was at best misleading, and at worst could confuse the compiler into generating bad code. There was no performance advantage to the alias, in fact removing it saves 16 bytes. Change-Id: I55023ddba465d9be82f66745b088d18af658ac60
* By convention const goes before the type specifierGlenn Kasten2012-01-061-7/+7
| | | | Change-Id: I70203abd6a6f54e5bd9f1412800cc01212157e58
* move native services under services/Mathias Agopian2010-07-141-0/+358
moved surfaceflinger, audioflinger, cameraservice all native services should now reside in this location. Change-Id: Iee42b83dd2a94c3bf5107ab0895fe2dfcd5337a8