Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy B. Terriberry <tterribe@xiph.org>2011-09-17 23:44:19 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2011-09-28 04:28:31 +0400
commit748c960cf7ab61a92adc323fe5bbae03af9949f4 (patch)
treef35748461ac7a2906a76e3195c9af129960c989d /silk/code_signs.c
parent9826ed99c36504ad466feeadacf5e2ced1518c4a (diff)
Add support for coding signs with 0 pulses.
The SILK bitstream allowed coding 0 pulses in a shell block, but a non-zero number of LSb's, meaning some excitation coefficients could be non-zero, but would not have a corresponding sign. To fix this without breaking already-encoded bitstreams, this patch adds a set of sign PDFs for the 0 pulses case. This is occasionally more efficient than the normal encoding if there are a large number of coefficients with positive signs, since these cost more than 1 bit when using the > 0 pulse PDFs. It only saves 0.33 bits per second (on average: it does better at high rates), but that's probably enough to justify the two redundant ways of coding things (and it's too late now to remove the second one entirely, anyway). This patch does not include the encoder modifications required to check if this coding method is more efficient and switch to it.
Diffstat (limited to 'silk/code_signs.c')
-rw-r--r--silk/code_signs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/silk/code_signs.c b/silk/code_signs.c
index 65187e61..02a3aeb3 100644
--- a/silk/code_signs.c
+++ b/silk/code_signs.c
@@ -54,13 +54,13 @@ void silk_encode_signs(
icdf[ 1 ] = 0;
q_ptr = pulses;
- i = silk_SMULBB( 6, silk_ADD_LSHIFT( quantOffsetType, signalType, 1 ) );
+ i = silk_SMULBB( 7, silk_ADD_LSHIFT( quantOffsetType, signalType, 1 ) );
icdf_ptr = &silk_sign_iCDF[ i ];
length = silk_RSHIFT( length + SHELL_CODEC_FRAME_LENGTH/2, LOG2_SHELL_CODEC_FRAME_LENGTH );
for( i = 0; i < length; i++ ) {
p = sum_pulses[ i ];
if( p > 0 ) {
- icdf[ 0 ] = icdf_ptr[ silk_min( p - 1, 5 ) ];
+ icdf[ 0 ] = icdf_ptr[ silk_min( p & 0x1F, 6 ) ];
for( j = 0; j < SHELL_CODEC_FRAME_LENGTH; j++ ) {
if( q_ptr[ j ] != 0 ) {
ec_enc_icdf( psRangeEnc, silk_enc_map( q_ptr[ j ]), icdf, 8 );
@@ -88,13 +88,13 @@ void silk_decode_signs(
icdf[ 1 ] = 0;
q_ptr = pulses;
- i = silk_SMULBB( 6, silk_ADD_LSHIFT( quantOffsetType, signalType, 1 ) );
+ i = silk_SMULBB( 7, silk_ADD_LSHIFT( quantOffsetType, signalType, 1 ) );
icdf_ptr = &silk_sign_iCDF[ i ];
length = silk_RSHIFT( length + SHELL_CODEC_FRAME_LENGTH/2, LOG2_SHELL_CODEC_FRAME_LENGTH );
for( i = 0; i < length; i++ ) {
p = sum_pulses[ i ];
if( p > 0 ) {
- icdf[ 0 ] = icdf_ptr[ silk_min( p - 1, 5 ) ];
+ icdf[ 0 ] = icdf_ptr[ silk_min( p & 0x1F, 6 ) ];
for( j = 0; j < SHELL_CODEC_FRAME_LENGTH; j++ ) {
if( q_ptr[ j ] > 0 ) {
/* attach sign */