summaryrefslogtreecommitdiff
path: root/silk/enc_API.c
diff options
context:
space:
mode:
authorTimothy B. Terriberry <tterribe@xiph.org>2011-10-14 16:14:36 -0700
committerJean-Marc Valin <jmvalin@jmvalin.ca>2011-10-17 16:03:41 -0400
commit1e03a6eb0472cc78e33541af11733f4f27ed3219 (patch)
tree55e7478f507e7d803ae1ba577d65bc935015e5b4 /silk/enc_API.c
parent53cc1a033a3183c9d137b03446db58d2e58c0e0a (diff)
downloadopus-1e03a6eb0472cc78e33541af11733f4f27ed3219.tar.gz
Fix side-channel index for VAD/LBRR flags.
Neither the encoder nor decoder were incrementing the side-channel index for a mid-only frame. Unfortunately, they used that index to index the VAD flags and LBRR flags. This made the VAD flags for the side channel particularly useless, as you couldn't tell which frame a flag belonged to without decoding most of the packet. It also desynched the LBRR information, as look at the wrong LBRR flags to decide when it had to code a mid-only flag. If some frames were skipped in the side channel, then the last few VAD flags and LBRR flags would be garbage, but still get encoded. This patch fixes this by continuing to increment nFramesDecoded or nFramesEncoded, even when skipping a frame in the side channel. This makes the side-channel VAD and LBRR flags correspond to the correct time periods for frames greater than 20 ms. It also fixes a bug where if DTX was not used on the packet where the side channel got turned off, it would never get used again until the encoder attempted to encode something in the side channel again.
Diffstat (limited to 'silk/enc_API.c')
-rw-r--r--silk/enc_API.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/silk/enc_API.c b/silk/enc_API.c
index 7177d4d5..3b4d1a9b 100644
--- a/silk/enc_API.c
+++ b/silk/enc_API.c
@@ -222,6 +222,7 @@ opus_int silk_Encode(
psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ] = 0;
}
}
+ psEnc->state_Fxx[ n ].sCmn.inDTX = psEnc->state_Fxx[ n ].sCmn.useDTX;
}
silk_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->state_Fxx[ 1 ].sCmn.fs_kHz );
@@ -435,10 +436,12 @@ opus_int silk_Encode(
if( ( ret = silk_encode_frame_Fxx( &psEnc->state_Fxx[ n ], nBytesOut, psRangeEnc, condCoding ) ) != 0 ) {
silk_assert( 0 );
}
- psEnc->state_Fxx[ n ].sCmn.nFramesEncoded++;
+ } else {
+ psEnc->state_Fxx[ n ].sCmn.VAD_flags[ psEnc->state_Fxx[ n ].sCmn.nFramesEncoded ] = 0;
}
psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0;
psEnc->state_Fxx[ n ].sCmn.inputBufIx = 0;
+ psEnc->state_Fxx[ n ].sCmn.nFramesEncoded++;
}
psEnc->prev_decode_only_middle = psEnc->sStereo.mid_only_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded - 1 ];