Disabling LBRR for whever there's a change in bandwidth/channels/framesize
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Wed, 5 Oct 2011 00:20:13 +0000 (20:20 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Wed, 5 Oct 2011 00:20:13 +0000 (20:20 -0400)
silk/enc_API.c

index 8251f01..3fa2715 100644 (file)
@@ -177,6 +177,7 @@ opus_int silk_Encode(
     opus_int32 TargetRate_bps, MStargetRates_bps[ 2 ], channelRate_bps, LBRR_symbol;
     silk_encoder *psEnc = ( silk_encoder * )encState;
     opus_int16 buf[ MAX_FRAME_LENGTH_MS * MAX_API_FS_KHZ ];
+    opus_int transition;
 
     psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded = psEnc->state_Fxx[ 1 ].sCmn.nFramesEncoded = 0;
 
@@ -199,6 +200,9 @@ opus_int silk_Encode(
             silk_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.In_HP_State,     &psEnc->state_Fxx[ 0 ].sCmn.In_HP_State,     sizeof( psEnc->state_Fxx[ 1 ].sCmn.In_HP_State ) );
         }
     }
+
+    transition = (encControl->payloadSize_ms != psEnc->state_Fxx[ 0 ].sCmn.PacketSize_ms) || (psEnc->nChannelsInternal != encControl->nChannelsInternal);
+
     psEnc->nChannelsAPI = encControl->nChannelsAPI;
     psEnc->nChannelsInternal = encControl->nChannelsInternal;
 
@@ -247,6 +251,12 @@ opus_int silk_Encode(
             silk_assert( 0 );
             return ret;
         }
+        if (psEnc->state_Fxx[n].sCmn.first_frame_after_reset || transition)
+        {
+            for( i = 0; i < psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket; i++ ) {
+                psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ] = 0;
+            }
+        }
     }
     silk_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->state_Fxx[ 1 ].sCmn.fs_kHz );