Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-06-03 22:49:11 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-06-04 02:15:52 +0300
commite387e7793748124f6c4dcb70f12a503912c06987 (patch)
treea9196719f59dd6b6faff76c4950618d9026e0751
parent48cc9792941b13cc65a6573e4328c80ffd82a0fc (diff)
Set pulses to zero if we can't meet rate target
-rw-r--r--silk/fixed/encode_frame_FIX.c13
-rw-r--r--silk/float/encode_frame_FLP.c13
2 files changed, 26 insertions, 0 deletions
diff --git a/silk/fixed/encode_frame_FIX.c b/silk/fixed/encode_frame_FIX.c
index af5ad865..5bc94c34 100644
--- a/silk/fixed/encode_frame_FIX.c
+++ b/silk/fixed/encode_frame_FIX.c
@@ -206,6 +206,9 @@ opus_int silk_encode_frame_FIX(
/****************************************/
silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding );
+ if ( iter == maxIter && !found_lower ) {
+ silk_memcpy( &sRangeEnc_copy2, psRangeEnc, sizeof( ec_enc ) );
+ }
/****************************************/
/* Encode Excitation Signal */
/****************************************/
@@ -214,6 +217,16 @@ opus_int silk_encode_frame_FIX(
nBits = ec_tell( psRangeEnc );
+ if ( iter == maxIter && !found_lower && nBits > maxBits ) {
+ silk_memcpy( psRangeEnc, &sRangeEnc_copy2, sizeof( ec_enc ) );
+ for ( i = 0; i < psEnc->sCmn.frame_length; i++ ) {
+ psEnc->sCmn.pulses[ i ] = 0;
+ }
+ silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
+ psEnc->sCmn.pulses, psEnc->sCmn.frame_length );
+ nBits = ec_tell( psRangeEnc );
+ }
+
if( useCBR == 0 && iter == 0 && nBits <= maxBits ) {
break;
}
diff --git a/silk/float/encode_frame_FLP.c b/silk/float/encode_frame_FLP.c
index b654ddc6..59efcb44 100644
--- a/silk/float/encode_frame_FLP.c
+++ b/silk/float/encode_frame_FLP.c
@@ -192,6 +192,9 @@ opus_int silk_encode_frame_FLP(
/****************************************/
silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding );
+ if ( iter == maxIter && !found_lower ) {
+ silk_memcpy( &sRangeEnc_copy2, psRangeEnc, sizeof( ec_enc ) );
+ }
/****************************************/
/* Encode Excitation Signal */
/****************************************/
@@ -200,6 +203,16 @@ opus_int silk_encode_frame_FLP(
nBits = ec_tell( psRangeEnc );
+ if ( iter == maxIter && !found_lower && nBits > maxBits ) {
+ silk_memcpy( psRangeEnc, &sRangeEnc_copy2, sizeof( ec_enc ) );
+ for ( i = 0; i < psEnc->sCmn.frame_length; i++ ) {
+ psEnc->sCmn.pulses[ i ] = 0;
+ }
+ silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
+ psEnc->sCmn.pulses, psEnc->sCmn.frame_length );
+ nBits = ec_tell( psRangeEnc );
+ }
+
if( useCBR == 0 && iter == 0 && nBits <= maxBits ) {
break;
}