summaryrefslogtreecommitdiff
path: root/silk/decode_indices.c
diff options
context:
space:
mode:
authorTimothy B. Terriberry <tterribe@xiph.org>2011-10-14 13:38:24 -0700
committerJean-Marc Valin <jmvalin@jmvalin.ca>2011-10-17 16:03:41 -0400
commit53cc1a033a3183c9d137b03446db58d2e58c0e0a (patch)
tree24476c962dbb081126c89d6f26dd9d02f7bf88e7 /silk/decode_indices.c
parent7ef6c7c1b465df4ef3b4ece2ecbf9d35c625beb4 (diff)
downloadopus-53cc1a033a3183c9d137b03446db58d2e58c0e0a.tar.gz
Fix the side frame conditional coding rules.
b24e5746 introduced changes to LastGainIndex which broke conditional coding for side frames after a mid-only frame (i.e., in a 60 ms frame where the side is coded, not coded, then coded again). These rules were a mess in general, however, because the side channel state kept a different nFramesDecoded count from the mid channel state, and had no way to tell if the prior side frame was coded. This patch attempts to rationalize them by moving the conditional coding decision up to the top level, where all this information is available. The first coded side frame after an uncoded side frame now always uses independent coding. If such a frame is also not the first side frame in an Opus frame, then it doesn't include an LTP scaling parameter (because the LTP state is well-defined).
Diffstat (limited to 'silk/decode_indices.c')
-rw-r--r--silk/decode_indices.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/silk/decode_indices.c b/silk/decode_indices.c
index 9ea0a80e..8ac53f4b 100644
--- a/silk/decode_indices.c
+++ b/silk/decode_indices.c
@@ -36,21 +36,15 @@ void silk_decode_indices(
silk_decoder_state *psDec, /* I/O State */
ec_dec *psRangeDec, /* I/O Compressor data structure */
opus_int FrameIndex, /* I Frame number */
- opus_int decode_LBRR /* I Flag indicating LBRR data is being decoded */
+ opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */
+ opus_int condCoding /* I The type of conditional coding to use */
)
{
- opus_int i, k, Ix, condCoding;
+ opus_int i, k, Ix;
opus_int decode_absolute_lagIndex, delta_lagIndex;
opus_int16 ec_ix[ MAX_LPC_ORDER ];
opus_uint8 pred_Q8[ MAX_LPC_ORDER ];
- /* Use conditional coding if previous frame available */
- if( FrameIndex > 0 && ( decode_LBRR == 0 || psDec->LBRR_flags[ FrameIndex - 1 ] == 1 ) ) {
- condCoding = 1;
- } else {
- condCoding = 0;
- }
-
/*******************************************/
/* Decode signal type and quantizer offset */
/*******************************************/
@@ -66,7 +60,7 @@ void silk_decode_indices(
/* Decode gains */
/****************/
/* First subframe */
- if( condCoding ) {
+ if( condCoding == CODE_CONDITIONALLY ) {
/* Conditional coding */
psDec->indices.GainsIndices[ 0 ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 );
} else {
@@ -110,7 +104,7 @@ void silk_decode_indices(
/*********************/
/* Get lag index */
decode_absolute_lagIndex = 1;
- if( condCoding && psDec->ec_prevSignalType == TYPE_VOICED ) {
+ if( condCoding == CODE_CONDITIONALLY && psDec->ec_prevSignalType == TYPE_VOICED ) {
/* Decode Delta index */
delta_lagIndex = (opus_int16)ec_dec_icdf( psRangeDec, silk_pitch_delta_iCDF, 8 );
if( delta_lagIndex > 0 ) {
@@ -142,7 +136,7 @@ void silk_decode_indices(
/**********************/
/* Decode LTP scaling */
/**********************/
- if( !condCoding ) {
+ if( condCoding == CODE_INDEPENDENTLY ) {
psDec->indices.LTP_scaleIndex = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTPscale_iCDF, 8 );
} else {
psDec->indices.LTP_scaleIndex = 0;