summaryrefslogtreecommitdiff
path: root/drivers/opus/silk/control_codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/opus/silk/control_codec.c')
-rw-r--r--drivers/opus/silk/control_codec.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/opus/silk/control_codec.c b/drivers/opus/silk/control_codec.c
index beb6dfe6cd..03caab36a9 100644
--- a/drivers/opus/silk/control_codec.c
+++ b/drivers/opus/silk/control_codec.c
@@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
-
-#ifdef OPUS_ENABLED
#include "opus/opus_config.h"
-#endif
#ifdef OPUS_FIXED_POINT
#include "opus/silk/fixed/main_FIX.h"
#define silk_encoder_state_Fxx silk_encoder_state_FIX
@@ -397,9 +394,10 @@ static OPUS_INLINE opus_int silk_setup_LBRR(
const opus_int32 TargetRate_bps /* I */
)
{
- opus_int ret = SILK_NO_ERROR;
+ opus_int LBRR_in_previous_packet, ret = SILK_NO_ERROR;
opus_int32 LBRR_rate_thres_bps;
+ LBRR_in_previous_packet = psEncC->LBRR_enabled;
psEncC->LBRR_enabled = 0;
if( psEncC->useInBandFEC && psEncC->PacketLoss_perc > 0 ) {
if( psEncC->fs_kHz == 8 ) {
@@ -413,8 +411,13 @@ static OPUS_INLINE opus_int silk_setup_LBRR(
if( TargetRate_bps > LBRR_rate_thres_bps ) {
/* Set gain increase for coding LBRR excitation */
+ if( LBRR_in_previous_packet == 0 ) {
+ /* Previous packet did not have LBRR, and was therefore coded at a higher bitrate */
+ psEncC->LBRR_GainIncreases = 7;
+ } else {
+ psEncC->LBRR_GainIncreases = silk_max_int( 7 - silk_SMULWB( (opus_int32)psEncC->PacketLoss_perc, SILK_FIX_CONST( 0.4, 16 ) ), 2 );
+ }
psEncC->LBRR_enabled = 1;
- psEncC->LBRR_GainIncreases = silk_max_int( 7 - silk_SMULWB( (opus_int32)psEncC->PacketLoss_perc, SILK_FIX_CONST( 0.4, 16 ) ), 2 );
}
}