OSDN Git Service

sbc: Fix input reordering for 15 blocks case
authorFrédéric Dalleau <frederic.dalleau@linux.intel.com>
Mon, 8 Apr 2013 13:24:11 +0000 (15:24 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 15 Apr 2013 08:03:40 +0000 (11:03 +0300)
commite9bc3e0083a2e8a23d8191b66b7e371af936040d
treed62cb29f4f22d62ac3205e20172025ca469020f5
parentc115634f9e4a586f8189b2eba499097c331a1cf6
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.
sbc/sbc_primitives.c