OSDN Git Service

android-x86/external-bluetooth-sbc.git
9 years agoRelease 1.3 kitkat-x86 lollipop-x86 marshmallow-x86 nougat-x86 android-x86-6.0-r1 android-x86-6.0-r2 android-x86-6.0-r3
Marcel Holtmann [Thu, 30 Oct 2014 04:00:56 +0000 (05:00 +0100)]
Release 1.3

9 years agoAUTHORS: Mention Aurélien's contributions
Marcel Holtmann [Thu, 30 Oct 2014 03:57:37 +0000 (04:57 +0100)]
AUTHORS: Mention Aurélien's contributions

9 years agobuild: Update library revision number
Marcel Holtmann [Thu, 30 Oct 2014 03:55:38 +0000 (04:55 +0100)]
build: Update library revision number

9 years agosbc: use an uint16 to store frame length in internal frame structure
Aurélien Zanelli [Thu, 23 Oct 2014 14:32:21 +0000 (16:32 +0200)]
sbc: use an uint16 to store frame length in internal frame structure

Otherwise it could overflow in some cases.
For instance in DUAL_CHANNEL mode, with subbands set to SBC_SB_8, blocks
set to SBC_BLK_16 and bitpool set to 64 results in a frame length of 268.

9 years agosbc: fix frame length calculation for DUAL_CHANNEL mode
Aurélien Zanelli [Thu, 23 Oct 2014 14:32:20 +0000 (16:32 +0200)]
sbc: fix frame length calculation for DUAL_CHANNEL mode

According to A2DP specification, section 12.9, for DUAL_CHANNEL mode, we
shall use the same formula as for MONO mode.

10 years agoRelease 1.2
Marcel Holtmann [Thu, 23 Jan 2014 15:39:47 +0000 (07:39 -0800)]
Release 1.2

10 years agosbc: Add sbc_reinit_a2dp to sbc.sym
Luiz Augusto von Dentz [Thu, 23 Jan 2014 12:19:17 +0000 (14:19 +0200)]
sbc: Add sbc_reinit_a2dp to sbc.sym

10 years agosbc: Add sbc_reinit_a2dp
Luiz Augusto von Dentz [Thu, 23 Jan 2014 12:16:38 +0000 (14:16 +0200)]
sbc: Add sbc_reinit_a2dp

This adds sbc_reinit_a2dp that can be used to reconfigure a previous
initialized sbc_t with new A2DP configuration.

10 years agoTODO: Update entries in TODO list
Marcel Holtmann [Wed, 22 Jan 2014 23:07:01 +0000 (15:07 -0800)]
TODO: Update entries in TODO list

10 years agosbc: Use bool variable for priv->init
Marcel Holtmann [Wed, 22 Jan 2014 16:47:48 +0000 (08:47 -0800)]
sbc: Use bool variable for priv->init

10 years agosbc: Add Intel copyright to public header file
Marcel Holtmann [Wed, 22 Jan 2014 16:33:58 +0000 (08:33 -0800)]
sbc: Add Intel copyright to public header file

10 years agobuild: Update library version for new sbc_init_a2dp() function
Marcel Holtmann [Wed, 22 Jan 2014 16:30:57 +0000 (08:30 -0800)]
build: Update library version for new sbc_init_a2dp() function

10 years agobuild: Keep high precision support disabled by default
Marcel Holtmann [Wed, 22 Jan 2014 16:19:57 +0000 (08:19 -0800)]
build: Keep high precision support disabled by default

10 years agosbc: Add sbc_init_a2dp to sbc.sym
Luiz Augusto von Dentz [Mon, 20 Jan 2014 09:29:14 +0000 (11:29 +0200)]
sbc: Add sbc_init_a2dp to sbc.sym

10 years agosbc: Add sbc_init_a2dp
Luiz Augusto von Dentz [Mon, 20 Jan 2014 09:26:00 +0000 (11:26 +0200)]
sbc: Add sbc_init_a2dp

This adds sbc_init_a2dp that can be used to convert A2DP configuration to
the internal representation since they are not binary compatible.

10 years agobuild: Add configure option --disable-high-precision
Luiz Augusto von Dentz [Mon, 16 Sep 2013 08:11:15 +0000 (11:11 +0300)]
build: Add configure option --disable-high-precision

This enables high precision using 64 bits accumulators by default which
can be disabled with --disable-high-precision.

10 years agosbc: Fix declaration of sbc_init_msbc symbol
Marcel Holtmann [Sun, 25 Aug 2013 17:35:27 +0000 (10:35 -0700)]
sbc: Fix declaration of sbc_init_msbc symbol

10 years agoRelease 1.1
Marcel Holtmann [Tue, 30 Apr 2013 21:23:57 +0000 (14:23 -0700)]
Release 1.1

10 years agobuild: Update library version for new sbc_init_msbc() function
Marcel Holtmann [Tue, 30 Apr 2013 21:18:52 +0000 (14:18 -0700)]
build: Update library version for new sbc_init_msbc() function

11 years agoAUTHORS: Mention Frédéric's contributions
Marcel Holtmann [Mon, 15 Apr 2013 14:47:55 +0000 (07:47 -0700)]
AUTHORS: Mention Frédéric's contributions

11 years agoTODO: Add TODO list
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:18 +0000 (15:24 +0200)]
TODO: Add TODO list

11 years agosbc: Update sbcinfo for msbc
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:17 +0000 (15:24 +0200)]
sbc: Update sbcinfo for msbc

11 years agosbc: Update sbcenc for msbc
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:16 +0000 (15:24 +0200)]
sbc: Update sbcenc for msbc

11 years agosbc: Update sbcdec for msbc
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:15 +0000 (15:24 +0200)]
sbc: Update sbcdec for msbc

11 years agosbc: Add support for mSBC frame header
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:14 +0000 (15:24 +0200)]
sbc: Add support for mSBC frame header

Traditionnal SBC frame header describe encoding parameters for each
frame: nr of blocks, subbands, allocation method, and bitpool. In mSBC,
only one combination of parameter is defined. That combination cannot be
expressed using a traditionnal SBC header. Because of this, a specific
header is defined with 0xAD followed by two reserved zero bytes.

11 years agosbc: Declare and implement sbc_init_msbc
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:13 +0000 (15:24 +0200)]
sbc: Declare and implement sbc_init_msbc

11 years agosbc: Add a private boolean flag to enable 15 block encoding
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:12 +0000 (15:24 +0200)]
sbc: Add a private boolean flag to enable 15 block encoding

This patch introduce a new private member which purpose is to encode 15
blocks. It is private to the library and can't be set from standard API.
sbc_init_msbc() function will be defined to set this flag.

11 years agosbc: Fix input reordering for 15 blocks case
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:11 +0000 (15:24 +0200)]
sbc: Fix input reordering for 15 blocks case

SBC analysis handles 8 samples at a time. The optimisation requires 8
samples forming an "odd" block, followed by 8 samples, forming an "even"
block. Until now SBC was used for encoding 4, 8, 12, or 16 blocks in a
frame. Reordering took a frame and for each 16 samples (ie 2 blocks) it
produced one "odd" block and one "even" block.
A mSBC frame encodes 15 blocks of 8 samples. 14 blocks are processed as
before, two at a time. If 8 samples are remaining, it will form the
first half of two blocks (a bit of an "odd" block, and a bit of an
"even" block). When processing the next frame, we detect eight samples
were missing at previous iteration and the two block can be finished.

This reordering is possible because only one sample is moved (x[-7]) AND
the first coefficient in the coef table is 0. Thus x[0] doesn't need to
be set and 0 can be used in calculation instead. Note that x[-7] is not
used in analysis for this block.
see: analysis_consts_fixed8_simd_odd.

To detect that two blocks are not completed, the number of processed
samples can be used. This value is stored in position. position starts
at SBC_X_BUFFER_SIZE-72 and is decremented by 16 as long as two blocks
can be formed. If only 8 samples are remaining in input, then position
is decremented by 8 *arbitrarly*, thus indicating that some samples are
pending. During next frame reordering, position will be decremented by 8
again, back to a 16 multiple.

This logic works for SBC_X_BUFFER_SIZE-72 multiple of 16 and bigger than
8*2*15+72=312 and less than 8*3*15+72=432. The current value of 328
matches this constraint and X buffer is shifted every two frames (30
blocks) in mSBC. This way, we don't need to care about x[-7] when
shifting, we also know that it won't be before X.

11 years agosbc: Use plain C primitive if doing msbc on neon
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:10 +0000 (15:24 +0200)]
sbc: Use plain C primitive if doing msbc on neon

neon has it's own optimized input reordering. Until this code gets optimized,
the neon assembly code will not work with the mSBC input reordering.
However, the plain C version of mSBC can be used in this case.
This patch makes use of plain C code if the block increment is 1 which is
typical for mSBC.

11 years agosbc: Add plain C primitive for 1b 8s analysis
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:09 +0000 (15:24 +0200)]
sbc: Add plain C primitive for 1b 8s analysis

11 years agosbc: Add iwmmxt primitive for 1b 8s encoding
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:08 +0000 (15:24 +0200)]
sbc: Add iwmmxt primitive for 1b 8s encoding

11 years agosbc: Add armv6 primitive for 1b 8s analysis
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:07 +0000 (15:24 +0200)]
sbc: Add armv6 primitive for 1b 8s analysis

11 years agosbc: Add mmx primitive for 1b 8s analysis
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:06 +0000 (15:24 +0200)]
sbc: Add mmx primitive for 1b 8s analysis

11 years agosbc: Rename sbc_analyze_4b_xx to sbc_analyze_xx
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:05 +0000 (15:24 +0200)]
sbc: Rename sbc_analyze_4b_xx to sbc_analyze_xx

11 years agosbc: Break 4 blocks processing to variable steps
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:04 +0000 (15:24 +0200)]
sbc: Break 4 blocks processing to variable steps

Until now SBC processed 4 blocks at a time. If we want to process 15
blocks, then we need to break this processing in one block steps. 4
blocks is still default increment.

11 years agosbc: Add encoder_state to analysis functions
Frédéric Dalleau [Mon, 8 Apr 2013 13:24:03 +0000 (15:24 +0200)]
sbc: Add encoder_state to analysis functions

Until now, SIMD analysis used to process 4 blocks of 8 samples at a
time. This was implemented using two constant tables: odd and even. This
mean we can only process 4, 8, 12, or 16 blocks par SBC packets.
mSBC requires 15 blocks, so to be able to analyse 1 block, it will be
necessary to know if we are processing an odd or even block. This will
be done with a new member to encoder_state.

11 years agobuild: Do not use deprecated AM_CONFIG_HEADER
Lucas De Marchi [Thu, 14 Feb 2013 14:27:01 +0000 (12:27 -0200)]
build: Do not use deprecated AM_CONFIG_HEADER

The long-obsoleted AM_CONFIG_HEADER macro was removed in automake 1.13.
Use AC_CONFIG_HEADERS instead.

11 years agoRelease 1.0
Marcel Holtmann [Mon, 30 Jul 2012 20:41:33 +0000 (13:41 -0700)]
Release 1.0

11 years agosbc: Remove unnecessary whitespace from empty line
Johan Hedberg [Wed, 18 Jul 2012 07:31:57 +0000 (10:31 +0300)]
sbc: Remove unnecessary whitespace from empty line

11 years agobuild: Set initial public library version
Marcel Holtmann [Tue, 17 Jul 2012 04:19:35 +0000 (06:19 +0200)]
build: Set initial public library version

11 years agosbc: Set symbols for version 1.0
Marcel Holtmann [Tue, 17 Jul 2012 04:19:15 +0000 (06:19 +0200)]
sbc: Set symbols for version 1.0

11 years agobuild: Add symbol table for library
Marcel Holtmann [Tue, 17 Jul 2012 04:10:12 +0000 (06:10 +0200)]
build: Add symbol table for library

11 years agosbc: Use SBC_EXPORT instead of LIB_EXPORT
Marcel Holtmann [Tue, 17 Jul 2012 03:50:45 +0000 (00:50 -0300)]
sbc: Use SBC_EXPORT instead of LIB_EXPORT

11 years agosbc: Fix spelling mistake
Marcel Holtmann [Tue, 17 Jul 2012 03:48:23 +0000 (00:48 -0300)]
sbc: Fix spelling mistake

11 years agobuild: Add library version information
Marcel Holtmann [Tue, 17 Jul 2012 03:41:22 +0000 (00:41 -0300)]
build: Add library version information

11 years agoREADME: Add basic information
Marcel Holtmann [Sun, 15 Jul 2012 21:31:09 +0000 (18:31 -0300)]
README: Add basic information

11 years agoAUTHORS: Add missing original contributor
Marcel Holtmann [Sun, 15 Jul 2012 21:28:46 +0000 (18:28 -0300)]
AUTHORS: Add missing original contributor

11 years agosbc: Export public functions as API
Marcel Holtmann [Sun, 15 Jul 2012 21:23:43 +0000 (18:23 -0300)]
sbc: Export public functions as API

11 years agobuild: Add private SBC library header
Marcel Holtmann [Sun, 15 Jul 2012 21:20:32 +0000 (18:20 -0300)]
build: Add private SBC library header

11 years agobuild: Switch to -fvisibility=hidden by default
Marcel Holtmann [Sun, 15 Jul 2012 21:16:22 +0000 (18:16 -0300)]
build: Switch to -fvisibility=hidden by default

11 years agobuild: Add pkg-config information
Marcel Holtmann [Sun, 15 Jul 2012 21:12:45 +0000 (18:12 -0300)]
build: Add pkg-config information

11 years agobuild: Private library is not needed when tools are disabled
Marcel Holtmann [Sun, 15 Jul 2012 18:19:12 +0000 (15:19 -0300)]
build: Private library is not needed when tools are disabled

11 years agobuild: Rename option for SBC tester
Marcel Holtmann [Sun, 15 Jul 2012 18:16:10 +0000 (15:16 -0300)]
build: Rename option for SBC tester

11 years agobuild: Add option to disable SBC tools
Marcel Holtmann [Sun, 15 Jul 2012 18:14:42 +0000 (15:14 -0300)]
build: Add option to disable SBC tools

11 years agobuild: Install SBC header includes
Marcel Holtmann [Sun, 15 Jul 2012 17:32:50 +0000 (14:32 -0300)]
build: Install SBC header includes

11 years agoAUTHORS: Update list of contributors
Marcel Holtmann [Sun, 15 Jul 2012 17:17:53 +0000 (14:17 -0300)]
AUTHORS: Update list of contributors

11 years agobuild: Add support for building SBC tester
Marcel Holtmann [Sun, 15 Jul 2012 17:07:31 +0000 (14:07 -0300)]
build: Add support for building SBC tester

11 years agobuild: Use -Wshadow compiler option
Marcel Holtmann [Sun, 15 Jul 2012 17:05:34 +0000 (14:05 -0300)]
build: Use -Wshadow compiler option

11 years agobuild: Add support for building SBC tools
Marcel Holtmann [Sun, 15 Jul 2012 17:05:05 +0000 (14:05 -0300)]
build: Add support for building SBC tools

11 years agobuild: Add support for building SBC library
Marcel Holtmann [Sun, 15 Jul 2012 17:03:34 +0000 (14:03 -0300)]
build: Add support for building SBC library

11 years agosrc: Move SBC tester utility
Marcel Holtmann [Mon, 30 Jul 2012 03:01:29 +0000 (20:01 -0700)]
src: Move SBC tester utility

11 years agosrc: Move subband encoder, decoder and info tools
Marcel Holtmann [Mon, 30 Jul 2012 03:00:29 +0000 (20:00 -0700)]
src: Move subband encoder, decoder and info tools

11 years agosbc: Fix spelling errors
Rafael Fonseca [Tue, 3 Apr 2012 13:16:22 +0000 (10:16 -0300)]
sbc: Fix spelling errors

Fix spelling errors found using the codespell tool
(https://github.com/lucasdemarchi/codespell).

11 years agosbc: fix "always_inline function might not be inlinable" warning
Siarhei Siamashka [Fri, 24 Feb 2012 12:13:16 +0000 (14:13 +0200)]
sbc: fix "always_inline function might not be inlinable" warning

"__attribute__((always_inline))" does not replace "inline" and they
still need to be used together. This fixes "always_inline function
might not be inlinable [-Wattributes]" warning in gcc 4.7

11 years agosbc: Reduce for-loop induced indentation in sbc_unpack_frame
Johan Hedberg [Wed, 19 Oct 2011 08:09:13 +0000 (11:09 +0300)]
sbc: Reduce for-loop induced indentation in sbc_unpack_frame

11 years agosbc: overflow bugfix and audio decoding quality improvement
Siarhei Siamashka [Mon, 17 Oct 2011 01:24:38 +0000 (04:24 +0300)]
sbc: overflow bugfix and audio decoding quality improvement

The "(((audio_sample << 1) | 1) << frame->scale_factor[ch][sb])"
part of expression
    "frame->sb_sample[blk][ch][sb] =
        (((audio_sample << 1) | 1) << frame->scale_factor[ch][sb]) /
        levels[ch][sb] - (1 << frame->scale_factor[ch][sb])"
in "sbc_unpack_frame" function can sometimes overflow 32-bit signed int.
This problem can be reproduced by first using bitpool 128 and encoding
some random noise data, and then feeding it to sbc decoder. The obvious
thing to do would be to change "audio_sample" variable type to uint32_t.

However the problem is a little bit more complicated. According
to the section "12.6.2 Scale Factors" of A2DP spec:
    scalefactor[ch][sb] = pow(2.0, (scale_factor[ch][sb] + 1))

And according to "12.6.4 Reconstruction of the Subband Samples":
    sb_sample[blk][ch][sb] = scalefactor[ch][sb] *
        ((audio_sample[blk][ch][sb]*2.0+1.0) / levels[ch][sb]-1.0);

Hence the current code for calculating "sb_sample[blk][ch][sb]" is
not quite correct, because it loses one least significant bit of
sample data and passes twice smaller sample values to the synthesis
filter (the filter also deviates from the spec to compensate this).
This all has quite a noticeable impact on audio quality. Moreover,
it makes sense to keep a few extra bits of precision here in order
to minimize rounding errors. So the proposed patch introduces a new
SBCDEC_FIXED_EXTRA_BITS constant and uses uint64_t data type
for intermediate calculations in order to safeguard against
overflows. This patch intentionally addresses only the quality
issue, but performance can be also improved later (like replacing
division with multiplication by reciprocal).

Test for the difference of sbc encoding/decoding roundtrip vs.
the original audio file for joint stereo, bitpool 128, 8 subbands
and http://media.xiph.org/sintel/sintel-master-st.flac sample
demonstrates some quality improvement:

=== before ===
    --- comparing original / sbc_encoder.exe + sbcdec ---
    stddev:    4.64 PSNR: 82.97 bytes:170495708/170496000
=== after ===
    --- comparing original / sbc_encoder.exe + sbcdec ---
    stddev:    1.95 PSNR: 90.50 bytes:170495708/170496000

11 years agosbc: Use __asm__ keyword
Maarten Bosmans [Tue, 6 Sep 2011 07:40:44 +0000 (10:40 +0300)]
sbc: Use __asm__ keyword

There are two reasons for this change:

First: consistency. __asm__ was already used elsewhere in the files, so
using that throughout is cleaner.

Second: both asm and __asm__ are GCC-specific extensions, not defined in
the C standard. When compiling with --std=gnu99 both are recognized, but
when using --std=c99 only __asm__ is recognized to make it perfectly
clear that you're not using some standard C99 construct, but a
GCC-extension.

11 years agosbc: Fix empty parameter list in usage() declaration
Szymon Janc [Wed, 18 May 2011 06:42:47 +0000 (08:42 +0200)]
sbc: Fix empty parameter list in usage() declaration

11 years agosbc: Remove unused variable
Johan Hedberg [Sat, 14 May 2011 22:56:11 +0000 (01:56 +0300)]
sbc: Remove unused variable

11 years agosbc: better compatibility with ARM thumb/thumb2
Siarhei Siamashka [Mon, 28 Mar 2011 22:57:39 +0000 (01:57 +0300)]
sbc: better compatibility with ARM thumb/thumb2

ARM assembly optimizations fail to compile in thumb mode, but are fine
for thumb2. Update ifdefs in the code to make use of ARM assembly only
when it is safe and also make sure that no optimizations are missed
when compiling for thumb2.

The problem was reported by Paul Menzel:
https://tango.0pointer.de/pipermail/pulseaudio-discuss/2011-February/009022.html

11 years agosbc: detect when bitpool has changed
Luiz Augusto von Dentz [Wed, 22 Dec 2010 09:35:48 +0000 (11:35 +0200)]
sbc: detect when bitpool has changed

A2DP spec allow bitpool changes midstream which is why sbc configuration
has a range of values for bitpool that the encoder can use and decoder
must support.

Bitpool changes do not affect the state of encoder/decoder so they don't
need to be reinitialize when this happens, so the impact is fairly small,
what it does change is the frame length so encoders may change the
bitpool to use the link more efficiently.

11 years agosbc: Add iwmmxt optimization for sbc for pxa series cpu
Keith Mok [Thu, 18 Nov 2010 13:33:16 +0000 (21:33 +0800)]
sbc: Add iwmmxt optimization for sbc for pxa series cpu

Add iwmmxt optimization for sbc for pxa series cpu.

Benchmarked on ARM PXA platform:
===  Before (4 bands) ====
$ time  ./sbcenc_orig  -s 4     long.au  > /dev/null
real    0m 2.44s
user    0m 2.39s
sys     0m 0.05s
===  After (4 bands) ====
$ time  ./sbcenc  -s 4     long.au  > /dev/null
real    0m 1.59s
user    0m 1.49s
sys     0m 0.10s

===  Before (8 bands) ====
$ time  ./sbcenc_orig   -s 8     long.au  > /dev/null
real    0m 4.05s
user    0m 3.98s
sys     0m 0.07s
===  After (8 bands) ====
$ time  ./sbcenc  -s 8     long.au  > /dev/null
real    0m 1.48s
user    0m 1.41s
sys     0m 0.06s

===  Before (a2dp usage) ====
$ time  ./sbcenc_orig   -b53 -s8 -j    long.au  > /dev/null
real    0m 4.51s
user    0m 4.41s
sys     0m 0.10s
===  After (a2dp usage) ====
$ time  ./sbcenc   -b53 -s8 -j    long.au  > /dev/null
real    0m 2.05s
user    0m 1.99s
sys     0m 0.06s

11 years agosbc: added "cc" to the clobber list of mmx inline assembly
Siarhei Siamashka [Thu, 11 Nov 2010 09:29:42 +0000 (11:29 +0200)]
sbc: added "cc" to the clobber list of mmx inline assembly

In the case of scale factors calculation optimizations, the inline
assembly code has instructions which update flags register, but
"cc" was not mentioned in the clobber list. When optimizing code,
gcc theoretically is allowed to do a comparison before the inline
assembly block, and a conditional branch after it which would lead
to a problem if the flags register gets clobbered. While this is
apparently not happening in practice with the current versions of
gcc, the clobber list needs to be corrected.

Regarding the other inline assembly blocks. While most likely it
is actually unnecessary based on quick review, "cc" is also added
there to the clobber list because it should have no impact on
performance in practice. It's kind of cargo cult, but relieves
us from the need to track the potential updates of flags register
in all these places.

11 years agosbc: ARMv6 optimized version of analysis filter for SBC encoder
Siarhei Siamashka [Fri, 2 Jul 2010 12:25:42 +0000 (15:25 +0300)]
sbc: ARMv6 optimized version of analysis filter for SBC encoder

The optimized filter gets enabled when the code is compiled
with -mcpu=/-march options set to target the processors which
support ARMv6 instructions. This code is also disabled when
NEON is used (which is a lot better alternative). For additional
safety ARM EABI is required and thumb mode should not be used.

Benchmarks from ARM11:

== 8 subbands ==

$ time ./sbcenc -b53 -s8 -j test.au > /dev/null

real    0m 35.65s
user    0m 34.17s
sys     0m 1.28s

$ time ./sbcenc.armv6 -b53 -s8 -j test.au > /dev/null

real    0m 17.29s
user    0m 15.47s
sys     0m 0.67s

== 4 subbands ==

$ time ./sbcenc -b53 -s4 -j test.au > /dev/null

real    0m 25.28s
user    0m 23.76s
sys     0m 1.32s

$ time ./sbcenc.armv6 -b53 -s4 -j test.au > /dev/null

real    0m 18.64s
user    0m 15.78s
sys     0m 2.22s

11 years agosbc: faster 'sbc_calculate_bits' function
Siarhei Siamashka [Fri, 2 Jul 2010 12:25:41 +0000 (15:25 +0300)]
sbc: faster 'sbc_calculate_bits' function

By using SBC_ALWAYS_INLINE trick, the implementation of 'sbc_calculate_bits'
function is split into two branches, each having 'subband' variable value
known at compile time. It helps the compiler to generate more optimal code
by saving at least one extra register, and also provides more obvious
opportunities for loops unrolling.

Benchmarked on ARM Cortex-A8:

== Before: ==

$ time ./sbcenc -b53 -s8 -j test.au > /dev/null

real    0m3.989s
user    0m3.602s
sys     0m0.391s

samples  %        image name               symbol name
26057    32.6128  sbcenc                   sbc_pack_frame
20003    25.0357  sbcenc                   sbc_analyze_4b_8s_neon
14220    17.7977  sbcenc                   sbc_calculate_bits
8498     10.6361  no-vmlinux               /no-vmlinux
5300      6.6335  sbcenc                   sbc_calc_scalefactors_j_neon
3235      4.0489  sbcenc                   sbc_enc_process_input_8s_be_neon
2172      2.7185  sbcenc                   sbc_encode

== After: ==

$ time ./sbcenc -b53 -s8 -j test.au > /dev/null

real    0m3.652s
user    0m3.195s
sys     0m0.445s

samples  %        image name               symbol name
26207    36.0095  sbcenc                   sbc_pack_frame
19820    27.2335  sbcenc                   sbc_analyze_4b_8s_neon
8629     11.8566  no-vmlinux               /no-vmlinux
6988      9.6018  sbcenc                   sbc_calculate_bits
5094      6.9994  sbcenc                   sbc_calc_scalefactors_j_neon
3351      4.6044  sbcenc                   sbc_enc_process_input_8s_be_neon
2182      2.9982  sbcenc                   sbc_encode

11 years agosbc: slightly faster 'sbc_calc_scalefactors_neon'
Siarhei Siamashka [Fri, 2 Jul 2010 12:25:40 +0000 (15:25 +0300)]
sbc: slightly faster 'sbc_calc_scalefactors_neon'

Previous variant was basically derived from C and MMX implementations.
Now new variant makes use of 'vmax' instruction, which is available in
NEON and can do this job faster. The same method for calculating scale
factors is also used in 'sbc_calc_scalefactors_j_neon'.

Benchmarked without joint stereo on ARM Cortex-A8:

== Before: ==

$ time ./sbcenc -b53 -s8 test.au > /dev/null

real    0m3.851s
user    0m3.375s
sys     0m0.469s

samples  %        image name               symbol name
26260    34.2672  sbcenc                   sbc_pack_frame
20013    26.1154  sbcenc                   sbc_analyze_4b_8s_neon
13796    18.0027  sbcenc                   sbc_calculate_bits
8388     10.9457  no-vmlinux               /no-vmlinux
3229      4.2136  sbcenc                   sbc_enc_process_input_8s_be_neon
2408      3.1422  sbcenc                   sbc_calc_scalefactors_neon
2093      2.7312  sbcenc                   sbc_encode

== After: ==

$ time ./sbcenc -b53 -s8 test.au > /dev/null

real    0m3.796s
user    0m3.344s
sys     0m0.438s

samples  %        image name               symbol name
26582    34.8726  sbcenc                   sbc_pack_frame
20032    26.2797  sbcenc                   sbc_analyze_4b_8s_neon
13808    18.1146  sbcenc                   sbc_calculate_bits
8374     10.9858  no-vmlinux               /no-vmlinux
3187      4.1810  sbcenc                   sbc_enc_process_input_8s_be_neon
2027      2.6592  sbcenc                   sbc_encode
1766      2.3168  sbcenc                   sbc_calc_scalefactors_neon

11 years agosbc: ARM NEON optimizations for input permutation in SBC encoder
Siarhei Siamashka [Fri, 2 Jul 2010 12:25:39 +0000 (15:25 +0300)]
sbc: ARM NEON optimizations for input permutation in SBC encoder

Using SIMD optimizations for 'sbc_enc_process_input_*' functions provides
a modest, but consistent speedup in all SBC encoding cases.

Benchmarked on ARM Cortex-A8:

== Before: ==

$ time ./sbcenc -b53 -s8 -j test.au > /dev/null

real    0m4.389s
user    0m3.969s
sys     0m0.422s

samples  %        image name               symbol name
26234    29.9625  sbcenc                   sbc_pack_frame
20057    22.9076  sbcenc                   sbc_analyze_4b_8s_neon
14306    16.3393  sbcenc                   sbc_calculate_bits
9866     11.2682  sbcenc                   sbc_enc_process_input_8s_be
8506      9.7149  no-vmlinux               /no-vmlinux
5219      5.9608  sbcenc                   sbc_calc_scalefactors_j_neon
2280      2.6040  sbcenc                   sbc_encode
661       0.7549  libc-2.10.1.so           memcpy

== After: ==

$ time ./sbcenc -b53 -s8 -j test.au > /dev/null

real    0m3.989s
user    0m3.602s
sys     0m0.391s

samples  %        image name               symbol name
26057    32.6128  sbcenc                   sbc_pack_frame
20003    25.0357  sbcenc                   sbc_analyze_4b_8s_neon
14220    17.7977  sbcenc                   sbc_calculate_bits
8498     10.6361  no-vmlinux               /no-vmlinux
5300      6.6335  sbcenc                   sbc_calc_scalefactors_j_neon
3235      4.0489  sbcenc                   sbc_enc_process_input_8s_be_neon
2172      2.7185  sbcenc                   sbc_encode

11 years agosbc: ARM NEON optimized joint stereo processing in SBC encoder
Siarhei Siamashka [Fri, 2 Jul 2010 12:25:38 +0000 (15:25 +0300)]
sbc: ARM NEON optimized joint stereo processing in SBC encoder

Improves SBC encoding performance when joint stereo is used, which
is a typical A2DP configuration.

Benchmarked on ARM Cortex-A8:

== Before: ==

$ time ./sbcenc -b53 -s8 -j test.au > /dev/null

real    0m5.239s
user    0m4.805s
sys     0m0.430s

samples  %        image name               symbol name
26083    25.0856  sbcenc                   sbc_pack_frame
21548    20.7240  sbcenc                   sbc_calc_scalefactors_j
19910    19.1486  sbcenc                   sbc_analyze_4b_8s_neon
14377    13.8272  sbcenc                   sbc_calculate_bits
9990      9.6080  sbcenc                   sbc_enc_process_input_8s_be
8667      8.3356  no-vmlinux               /no-vmlinux
2263      2.1765  sbcenc                   sbc_encode
696       0.6694  libc-2.10.1.so           memcpy

== After: ==

$ time ./sbcenc -b53 -s8 -j test.au > /dev/null

real    0m4.389s
user    0m3.969s
sys     0m0.422s

samples  %        image name               symbol name
26234    29.9625  sbcenc                   sbc_pack_frame
20057    22.9076  sbcenc                   sbc_analyze_4b_8s_neon
14306    16.3393  sbcenc                   sbc_calculate_bits
9866     11.2682  sbcenc                   sbc_enc_process_input_8s_be
8506      9.7149  no-vmlinux               /no-vmlinux
5219      5.9608  sbcenc                   sbc_calc_scalefactors_j_neon
2280      2.6040  sbcenc                   sbc_encode
661       0.7549  libc-2.10.1.so           memcpy

11 years agosbc: Fix signedness of libsbc parameters
Johan Hedberg [Wed, 30 Jun 2010 08:55:11 +0000 (11:55 +0300)]
sbc: Fix signedness of libsbc parameters

The written parameter of sbc_encode can be negative so it should be
ssize_t instead of size_t.

11 years agosbc: ARM NEON optimization for scale factors calculation
Siarhei Siamashka [Tue, 29 Jun 2010 13:48:47 +0000 (16:48 +0300)]
sbc: ARM NEON optimization for scale factors calculation

Improves SBC encoding performance when joint stereo is not used.
Benchmarked on ARM Cortex-A8:

== Before: ==

$ time ./sbcenc -b53 -s8 test.au > /dev/null

real    0m4.756s
user    0m4.313s
sys     0m0.438s

samples  %        image name               symbol name
2569     27.6296  sbcenc                   sbc_pack_frame
1934     20.8002  sbcenc                   sbc_analyze_4b_8s_neon
1386     14.9064  sbcenc                   sbc_calculate_bits
1221     13.1319  sbcenc                   sbc_calc_scalefactors
996      10.7120  sbcenc                   sbc_enc_process_input_8s_be
878       9.4429  no-vmlinux               /no-vmlinux
204       2.1940  sbcenc                   sbc_encode
56        0.6023  libc-2.10.1.so           memcpy

== After: ==

$ time ./sbcenc -b53 -s8 test.au > /dev/null

real    0m4.220s
user    0m3.797s
sys     0m0.422s

samples  %        image name               symbol name
2563     31.3249  sbcenc                   sbc_pack_frame
1892     23.1239  sbcenc                   sbc_analyze_4b_8s_neon
1368     16.7196  sbcenc                   sbc_calculate_bits
961      11.7453  sbcenc                   sbc_enc_process_input_8s_be
836      10.2176  no-vmlinux               /no-vmlinux
262       3.2022  sbcenc                   sbc_calc_scalefactors_neon
199       2.4322  sbcenc                   sbc_encode
49        0.5989  libc-2.10.1.so           memcpy

11 years agosbc: MMX optimization for scale factors calculation
Siarhei Siamashka [Tue, 29 Jun 2010 13:48:46 +0000 (16:48 +0300)]
sbc: MMX optimization for scale factors calculation

Improves SBC encoding performance when joint stereo is not used.
Benchmarked on Pentium-M:

== Before: ==

$ time ./sbcenc -b53 -s8 test.au > /dev/null

real    0m1.439s
user    0m1.336s
sys     0m0.104s

samples  %        image name               symbol name
8642     33.7473  sbcenc                   sbc_pack_frame
5873     22.9342  sbcenc                   sbc_analyze_4b_8s_mmx
4435     17.3188  sbcenc                   sbc_calc_scalefactors
4285     16.7331  sbcenc                   sbc_calculate_bits
1942      7.5836  sbcenc                   sbc_enc_process_input_8s_be
322       1.2574  sbcenc                   sbc_encode

== After: ==

$ time ./sbcenc -b53 -s8 test.au > /dev/null

real    0m1.319s
user    0m1.220s
sys     0m0.084s

samples  %        image name               symbol name
8706     37.9959  sbcenc                   sbc_pack_frame
5740     25.0513  sbcenc                   sbc_analyze_4b_8s_mmx
4307     18.7972  sbcenc                   sbc_calculate_bits
1937      8.4537  sbcenc                   sbc_enc_process_input_8s_be
1801      7.8602  sbcenc                   sbc_calc_scalefactors_mmx
307       1.3399  sbcenc                   sbc_encode

11 years agosbc: new 'sbc_calc_scalefactors_j' function added to sbc primitives
Siarhei Siamashka [Tue, 29 Jun 2010 13:48:45 +0000 (16:48 +0300)]
sbc: new 'sbc_calc_scalefactors_j' function added to sbc primitives

The code for scale factors calculation with joint stereo support has
been moved to a separate function. It can get platform-specific
SIMD optimizations later for best possible performance.

But even this change in C code improves performance because of the
use of __builtin_clz() instead of loops similar to what was done
to sbc_calc_scalefactors earlier. Also technically it does loop
unrolling by processing two channels at once, which might be either
good or bad for performance (if the registers pressure is increased
and more data is spilled to memory). But the benchmark from 32-bit
x86 system (pentium-m) shows that it got clearly faster:

$ time ./sbcenc.old -b53 -s8 -j test.au > /dev/null

real    0m1.868s
user    0m1.808s
sys     0m0.048s

$ time ./sbcenc.new -b53 -s8 -j test.au > /dev/null

real    0m1.742s
user    0m1.668s
sys     0m0.064s

11 years agosbc: Fix redundant null check on calling free()
Gustavo F. Padovan [Sat, 5 Jun 2010 10:14:28 +0000 (07:14 -0300)]
sbc: Fix redundant null check on calling free()

Issues found by smatch static check: http://smatch.sourceforge.net/

11 years agosbc: Update Nokia copyrights
Johan Hedberg [Thu, 7 Jan 2010 09:02:51 +0000 (11:02 +0200)]
sbc: Update Nokia copyrights

11 years agosbc: Update copyright information
Marcel Holtmann [Sat, 2 Jan 2010 01:08:17 +0000 (17:08 -0800)]
sbc: Update copyright information

11 years agosbc: added saturated clipping of decoder output to 16-bit
Siarhei Siamashka [Fri, 17 Apr 2009 15:27:38 +0000 (18:27 +0300)]
sbc: added saturated clipping of decoder output to 16-bit

This prevents overflows and audible artefacts for the audio files which
originally had loudness maximized. Music from audio CD disks is an
example of such files, see http://en.wikipedia.org/wiki/Loudness_war

11 years agosbc: Do some coding style cleanups
Marcel Holtmann [Thu, 16 Apr 2009 23:55:42 +0000 (01:55 +0200)]
sbc: Do some coding style cleanups

11 years agosbc: fix up sbc.h prototypes to use const/size_t wherever applicable
Lennart Poettering [Mon, 23 Mar 2009 15:44:11 +0000 (16:44 +0100)]
sbc: fix up sbc.h prototypes to use const/size_t wherever applicable

11 years agosbc: Remove unused variable.
Luiz Augusto von Dentz [Wed, 1 Apr 2009 13:47:39 +0000 (10:47 -0300)]
sbc: Remove unused variable.

11 years agosbc: ensure 16-byte buffer position alignment for 4 subbands encoding
Siarhei Siamashka [Mon, 16 Mar 2009 00:27:26 +0000 (02:27 +0200)]
sbc: ensure 16-byte buffer position alignment for 4 subbands encoding

Buffer position in X array was not always 16-bytes aligned.
Strict 16-byte alignment is strictly required for powerpc altivec
simd optimizations because altivec does not have support for
unaligned vector loads at all.

11 years agosbc: Fix misuse of 'frame.joint' when estimating the frame length.
Luiz Augusto von Dentz [Fri, 20 Mar 2009 21:40:43 +0000 (18:40 -0300)]
sbc: Fix misuse of 'frame.joint' when estimating the frame length.

'frame.joint' is not the flag for joint stereo mode, it is a set of bits which
show for which subbands channels joining was actually used.

11 years agosbc: Fix a couple of other places that should use size_t and ssize_t
Johan Hedberg [Thu, 12 Mar 2009 19:33:14 +0000 (16:33 -0300)]
sbc: Fix a couple of other places that should use size_t and ssize_t

11 years agosbc: don't dereference sbc pointer if NULL
Marc-André Lureau [Tue, 17 Feb 2009 20:46:41 +0000 (22:46 +0200)]
sbc: don't dereference sbc pointer if NULL

11 years agosbc: provide implementation info as a readable string
Marc-André Lureau [Mon, 16 Feb 2009 13:59:51 +0000 (15:59 +0200)]
sbc: provide implementation info as a readable string

This is mainly useful for logging and debugging.

11 years agosbc: make check_mmx_support() a proper C function
Lennart Poettering [Mon, 2 Feb 2009 00:57:14 +0000 (01:57 +0100)]
sbc: make check_mmx_support() a proper C function

Signed-off-by: Lennart Poettering <lennart@poettering.net>
11 years agosbc: Fix SBC to compile cleanly with -Wsign-compare
Marcel Holtmann [Thu, 29 Jan 2009 23:02:58 +0000 (00:02 +0100)]
sbc: Fix SBC to compile cleanly with -Wsign-compare

11 years agosbc: Fix for SBC encoding with block sizes other than 16
Siarhei Siamashka [Thu, 29 Jan 2009 16:15:31 +0000 (18:15 +0200)]
sbc: Fix for SBC encoding with block sizes other than 16

Thanks to Christian Hoene for finding and reporting the
problem. This regression was intruduced in commit
19af3c49e61aa046375497108e05a3a0605da158

11 years agosbc: Add -Wno-sign-compare for the library and fix the other warnings
Marcel Holtmann [Thu, 29 Jan 2009 16:32:58 +0000 (17:32 +0100)]
sbc: Add -Wno-sign-compare for the library and fix the other warnings

11 years agosbc: SBC encoder scale factors calculation optimized with __builtin_clz
Siarhei Siamashka [Thu, 29 Jan 2009 00:17:36 +0000 (02:17 +0200)]
sbc: SBC encoder scale factors calculation optimized with __builtin_clz

Count leading zeros operation is often implemented using a special
instruction for it on various architectures (at least this is true
for ARM and x86). Using __builtin_clz gcc intrinsic allows to
eliminate innermost loop in scale factors calculation and improve
performance. Also scale factors calculation can be optimized even
more using SIMD instructions.

11 years agosbc: Performance optimizations for input data processing in SBC encoder
Siarhei Siamashka [Tue, 27 Jan 2009 16:57:35 +0000 (18:57 +0200)]
sbc: Performance optimizations for input data processing in SBC encoder

Channels deinterleaving, endian conversion and samples reordering
is done in one pass, avoiding the use of intermediate buffer. Also
this code is implemented as a new "performance primitive", which
allows further platform specific optimizations (ARMv6 and ARM NEON
should gain quite a lot from assembly optimizations here).