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

github.com/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-10-15 00:38:24 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2011-10-18 00:03:41 +0400
commit53cc1a033a3183c9d137b03446db58d2e58c0e0a (patch)
tree24476c962dbb081126c89d6f26dd9d02f7bf88e7 /silk/dec_API.c
parent7ef6c7c1b465df4ef3b4ece2ecbf9d35c625beb4 (diff)
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/dec_API.c')
-rw-r--r--silk/dec_API.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/silk/dec_API.c b/silk/dec_API.c
index ade060f9..018173ef 100644
--- a/silk/dec_API.c
+++ b/silk/dec_API.c
@@ -182,13 +182,21 @@ opus_int silk_Decode(
for( n = 0; n < decControl->nChannelsInternal; n++ ) {
if( channel_state[ n ].LBRR_flags[ i ] ) {
opus_int pulses[ MAX_FRAME_LENGTH ];
+ opus_int condCoding;
+
if( decControl->nChannelsInternal == 2 && n == 0 ) {
silk_stereo_decode_pred( psRangeDec, MS_pred_Q13 );
if( channel_state[ 1 ].LBRR_flags[ i ] == 0 ) {
silk_stereo_decode_mid_only( psRangeDec, &decode_only_middle );
}
}
- silk_decode_indices( &channel_state[ n ], psRangeDec, i, 1 );
+ /* Use conditional coding if previous frame available */
+ if( i > 0 && channel_state[ n ].LBRR_flags[ i - 1 ] ) {
+ condCoding = CODE_CONDITIONALLY;
+ } else {
+ condCoding = CODE_INDEPENDENTLY;
+ }
+ silk_decode_indices( &channel_state[ n ], psRangeDec, i, 1, condCoding );
silk_decode_pulses( psRangeDec, pulses, channel_state[ n ].indices.signalType,
channel_state[ n ].indices.quantOffsetType, channel_state[ n ].frame_length );
}
@@ -230,7 +238,23 @@ opus_int silk_Decode(
/* Call decoder for one frame */
for( n = 0; n < decControl->nChannelsInternal; n++ ) {
if( n == 0 || ( ( lostFlag != FLAG_PACKET_LOST ? decode_only_middle : psDec->prev_decode_only_middle ) == 0 ) ) {
- ret += silk_decode_frame( &channel_state[ n ], psRangeDec, &samplesOut1_tmp[ n ][ 2 + delay ], &nSamplesOutDec, lostFlag );
+ opus_int FrameIndex;
+ opus_int condCoding;
+
+ FrameIndex = channel_state[ 0 ].nFramesDecoded - n;
+ /* Use independent coding if no previous frame available */
+ if( FrameIndex <= 0 ) {
+ condCoding = CODE_INDEPENDENTLY;
+ } else if( lostFlag == FLAG_DECODE_LBRR ) {
+ condCoding = channel_state[ n ].LBRR_flags[ FrameIndex - 1 ] ? CODE_CONDITIONALLY : CODE_INDEPENDENTLY;
+ } else if( n > 0 && psDec->prev_decode_only_middle ) {
+ /* If we skipped a side frame in this packet, we don't
+ need LTP scaling; the LTP state is well-defined. */
+ condCoding = CODE_INDEPENDENTLY_NO_LTP_SCALING;
+ } else {
+ condCoding = CODE_CONDITIONALLY;
+ }
+ ret += silk_decode_frame( &channel_state[ n ], psRangeDec, &samplesOut1_tmp[ n ][ 2 + delay ], &nSamplesOutDec, lostFlag, condCoding);
} else {
silk_memset( &samplesOut1_tmp[ n ][ 2 + delay ], 0, nSamplesOutDec * sizeof( opus_int16 ) );
}