shithub: opus

Download patch

ref: 23b75af29de249581a4bed840cf33b2f75d57d42
parent: f6e781ab8b73a1f9a1c625b51b694fda26d75c53
parent: 047f0256c88a248119ee53516707328b9cbd42b7
author: Jean-Marc Valin <[email protected]>
date: Sat Jun 11 04:51:53 EDT 2011

Merge remote branch 'repo/master'

--- a/silk/silk_enc_API.c
+++ b/silk/silk_enc_API.c
@@ -304,7 +304,8 @@
             /* Total target bits for packet */
             nBits = SKP_DIV32_16( SKP_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 );
             /* Subtract half of the bits already used */
-            nBits -= ec_tell( psRangeEnc ) >> 1;
+            if (!prefillFlag)
+                nBits -= ec_tell( psRangeEnc ) >> 1;
             /* Divide by number of uncoded frames left in packet */
             nBits = SKP_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded );
             /* Convert to bits/second */
@@ -323,7 +324,8 @@
                 silk_stereo_LR_to_MS( &psEnc->sStereo, psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->state_Fxx[ 1 ].sCmn.inputBuf, 
                     psEnc->sStereo.ix[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ], MStargetRates_bps, TargetRate_bps, 
                     psEnc->state_Fxx[ 0 ].sCmn.speech_activity_Q8, psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length );
-                silk_stereo_encode_pred( psRangeEnc, psEnc->sStereo.ix[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] );
+                if (!prefillFlag)
+                    silk_stereo_encode_pred( psRangeEnc, psEnc->sStereo.ix[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] );
             } else {
                 /* Buffering */
                 SKP_memcpy( &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ -2 ], psEnc->sStereo.sMid, 2 * sizeof( SKP_int16 ) );
@@ -361,7 +363,8 @@
                     flags  = SKP_LSHIFT( flags, 1 );
                     flags |= psEnc->state_Fxx[ n ].sCmn.LBRR_flag;
                 }
-                ec_enc_patch_initial_bits( psRangeEnc, flags, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannelsInternal );
+                if (!prefillFlag)
+                    ec_enc_patch_initial_bits( psRangeEnc, flags, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannelsInternal );
 
                 /* Return zero bytes if all channels DTXed */
                 if( psEnc->state_Fxx[ 0 ].sCmn.inDTX && ( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 1 ].sCmn.inDTX ) ) {
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -347,7 +347,7 @@
         for (c=0;c<st->channels;c++)
         {
             for (i=0;i<F2_5;i++)
-                pcm[st->channels*i+c] = redundant_audio[st->channels*i];
+                pcm[st->channels*i+c] = redundant_audio[st->channels*i+c];
         }
         smooth_fade(redundant_audio+st->channels*F2_5, pcm+st->channels*F2_5,
                 pcm+st->channels*F2_5, F2_5, st->channels, window, st->Fs);
@@ -354,10 +354,11 @@
     }
     if (transition)
     {
-    	for (i=0;i<F2_5;i++)
+    	for (i=0;i<st->channels*F2_5;i++)
     		pcm[i] = pcm_transition[i];
     	if (audiosize >= F5)
-    	    smooth_fade(pcm_transition+F2_5, pcm+F2_5, pcm+F2_5, F2_5,
+    	    smooth_fade(pcm_transition+st->channels*F2_5, pcm+st->channels*F2_5,
+    	            pcm+st->channels*F2_5, F2_5,
     	            st->channels, window, st->Fs);
     }
 #if OPUS_TEST_RANGE_CODER_STATE