diff options
author | Timothy B. Terriberry <tterribe@xiph.org> | 2011-10-15 00:38:24 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-10-18 00:03:41 +0400 |
commit | 53cc1a033a3183c9d137b03446db58d2e58c0e0a (patch) | |
tree | 24476c962dbb081126c89d6f26dd9d02f7bf88e7 /silk/fixed/encode_frame_FIX.c | |
parent | 7ef6c7c1b465df4ef3b4ece2ecbf9d35c625beb4 (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/fixed/encode_frame_FIX.c')
-rw-r--r-- | silk/fixed/encode_frame_FIX.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/silk/fixed/encode_frame_FIX.c b/silk/fixed/encode_frame_FIX.c index 6f4367f7..c3da9bcf 100644 --- a/silk/fixed/encode_frame_FIX.c +++ b/silk/fixed/encode_frame_FIX.c @@ -38,7 +38,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. opus_int silk_encode_frame_FIX( silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ opus_int32 *pnBytesOut, /* O Number of payload bytes */ - ec_enc *psRangeEnc /* I/O compressor data structure */ + ec_enc *psRangeEnc, /* I/O compressor data structure */ + opus_int condCoding /* I The type of conditional coding to use */ ) { silk_encoder_control_FIX sEncCtrl; @@ -116,7 +117,7 @@ TOC(NOISE_SHAPE_ANALYSIS) /* Find linear prediction coefficients (LPC + LTP) */ /***************************************************/ TIC(FIND_PRED_COEF) - silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame ); + silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame, condCoding ); TOC(FIND_PRED_COEF) /****************************************/ @@ -137,7 +138,7 @@ TOC(PREFILTER) /* Low Bitrate Redundant Encoding */ /****************************************/ TIC(LBRR) - silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw ); + silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw, condCoding ); TOC(LBRR) /*****************************************/ @@ -174,7 +175,7 @@ TOC(NSQ) /* Encode Parameters */ /****************************************/ TIC(ENCODE_PARAMS) - silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0 ); + silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding ); TOC(ENCODE_PARAMS) /****************************************/ @@ -242,7 +243,8 @@ TOC(ENCODE_FRAME) void silk_LBRR_encode_FIX( silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ - const opus_int16 xfw[] /* I Input signal */ + const opus_int16 xfw[], /* I Input signal */ + opus_int condCoding /* I The type of conditional coding used so far for this frame */ ) { opus_int32 TempGains_Q16[ MAX_NB_SUBFR ]; @@ -274,7 +276,7 @@ void silk_LBRR_encode_FIX( /* Decode to get gains in sync with decoder */ /* Overwrite unquantized gains with quantized gains */ silk_gains_dequant( psEncCtrl->Gains_Q16, psIndices_LBRR->GainsIndices, - &psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesEncoded, psEnc->sCmn.nb_subfr ); + &psEnc->sCmn.LBRRprevLastGainIndex, condCoding == CODE_CONDITIONALLY, psEnc->sCmn.nb_subfr ); /*****************************************/ /* Noise shaping quantization */ |