mirror of
https://github.com/xiph/opus.git
synced 2025-05-31 23:57:42 +00:00
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).
This commit is contained in:
parent
7ef6c7c1b4
commit
53cc1a033a
18 changed files with 134 additions and 71 deletions
|
@ -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 ) );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue