diff options
author | Dan Everton <dan@iocaine.org> | 2007-05-22 09:50:31 +0000 |
---|---|---|
committer | Dan Everton <dan@iocaine.org> | 2007-05-22 09:50:31 +0000 |
commit | df6f2f9a3c88a7a4a8ad0382ee4ee7c9a3ee3256 (patch) | |
tree | d9862e5d04f4014def5911bb4ff8206c85636fb7 /apps/codecs/libspeex/sb_celp.c | |
parent | 8970055ec107a2387eedbb373889d0f540745121 (diff) | |
download | rockbox-df6f2f9a3c88a7a4a8ad0382ee4ee7c9a3ee3256.tar.gz rockbox-df6f2f9a3c88a7a4a8ad0382ee4ee7c9a3ee3256.zip |
Upgrade to libspeex 1.2beta2. Very minor performance increase (0.6% on coldfire).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13461 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libspeex/sb_celp.c')
-rw-r--r-- | apps/codecs/libspeex/sb_celp.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/apps/codecs/libspeex/sb_celp.c b/apps/codecs/libspeex/sb_celp.c index 0b4b619e52..faabe24766 100644 --- a/apps/codecs/libspeex/sb_celp.c +++ b/apps/codecs/libspeex/sb_celp.c | |||
@@ -192,16 +192,18 @@ void *sb_encoder_init(const SpeexMode *m) | |||
192 | st = (SBEncState*)speex_alloc(sizeof(SBEncState)); | 192 | st = (SBEncState*)speex_alloc(sizeof(SBEncState)); |
193 | if (!st) | 193 | if (!st) |
194 | return NULL; | 194 | return NULL; |
195 | #if defined(VAR_ARRAYS) || defined (USE_ALLOCA) | ||
196 | st->stack = NULL; | ||
197 | #else | ||
198 | st->stack = (char*)speex_alloc_scratch(SB_ENC_STACK); | ||
199 | #endif | ||
200 | st->mode = m; | 195 | st->mode = m; |
201 | mode = (const SpeexSBMode*)m->mode; | 196 | mode = (const SpeexSBMode*)m->mode; |
202 | 197 | ||
203 | 198 | ||
204 | st->st_low = speex_encoder_init(mode->nb_mode); | 199 | st->st_low = speex_encoder_init(mode->nb_mode); |
200 | #if defined(VAR_ARRAYS) || defined (USE_ALLOCA) | ||
201 | st->stack = NULL; | ||
202 | #else | ||
203 | /*st->stack = (char*)speex_alloc_scratch(SB_ENC_STACK);*/ | ||
204 | speex_encoder_ctl(st->st_low, SPEEX_GET_STACK, &st->stack); | ||
205 | #endif | ||
206 | |||
205 | st->full_frame_size = 2*mode->frameSize; | 207 | st->full_frame_size = 2*mode->frameSize; |
206 | st->frame_size = mode->frameSize; | 208 | st->frame_size = mode->frameSize; |
207 | st->subframeSize = mode->subframeSize; | 209 | st->subframeSize = mode->subframeSize; |
@@ -275,7 +277,7 @@ void sb_encoder_destroy(void *state) | |||
275 | 277 | ||
276 | speex_encoder_destroy(st->st_low); | 278 | speex_encoder_destroy(st->st_low); |
277 | #if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) | 279 | #if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) |
278 | speex_free_scratch(st->stack); | 280 | /*speex_free_scratch(st->stack);*/ |
279 | #endif | 281 | #endif |
280 | 282 | ||
281 | speex_free(st->high); | 283 | speex_free(st->high); |
@@ -629,7 +631,11 @@ int sb_encode(void *state, void *vin, SpeexBits *bits) | |||
629 | quant=31; | 631 | quant=31; |
630 | speex_bits_pack(bits, quant, 5); | 632 | speex_bits_pack(bits, quant, 5); |
631 | } | 633 | } |
632 | 634 | if (st->innov_rms_save) | |
635 | { | ||
636 | st->innov_rms_save[sub] = eh; | ||
637 | } | ||
638 | st->exc_rms[sub] = eh; | ||
633 | } else { | 639 | } else { |
634 | spx_word16_t gc; /*Q7*/ | 640 | spx_word16_t gc; /*Q7*/ |
635 | spx_word32_t scale; /*Q14*/ | 641 | spx_word32_t scale; /*Q14*/ |
@@ -716,11 +722,11 @@ int sb_encode(void *state, void *vin, SpeexBits *bits) | |||
716 | { | 722 | { |
717 | st->innov_rms_save[sub] = MULT16_16_Q15(QCONST16(.70711f, 15), compute_rms(innov, st->subframeSize)); | 723 | st->innov_rms_save[sub] = MULT16_16_Q15(QCONST16(.70711f, 15), compute_rms(innov, st->subframeSize)); |
718 | } | 724 | } |
725 | st->exc_rms[sub] = compute_rms16(exc, st->subframeSize); | ||
719 | 726 | ||
720 | 727 | ||
721 | } | 728 | } |
722 | 729 | ||
723 | st->exc_rms[sub] = compute_rms16(exc, st->subframeSize); | ||
724 | 730 | ||
725 | /*Keep the previous memory*/ | 731 | /*Keep the previous memory*/ |
726 | for (i=0;i<st->lpcSize;i++) | 732 | for (i=0;i<st->lpcSize;i++) |
@@ -754,20 +760,18 @@ void *sb_decoder_init(const SpeexMode *m) | |||
754 | st = (SBDecState*)speex_alloc(sizeof(SBDecState)); | 760 | st = (SBDecState*)speex_alloc(sizeof(SBDecState)); |
755 | if (!st) | 761 | if (!st) |
756 | return NULL; | 762 | return NULL; |
757 | #if defined(VAR_ARRAYS) || defined (USE_ALLOCA) | ||
758 | st->stack = NULL; | ||
759 | #else | ||
760 | st->stack = (char*)speex_alloc_scratch(SB_DEC_STACK); | ||
761 | #endif | ||
762 | st->mode = m; | 763 | st->mode = m; |
763 | mode=(const SpeexSBMode*)m->mode; | 764 | mode=(const SpeexSBMode*)m->mode; |
764 | |||
765 | st->encode_submode = 1; | 765 | st->encode_submode = 1; |
766 | 766 | ||
767 | |||
768 | |||
769 | |||
770 | st->st_low = speex_decoder_init(mode->nb_mode); | 767 | st->st_low = speex_decoder_init(mode->nb_mode); |
768 | #if defined(VAR_ARRAYS) || defined (USE_ALLOCA) | ||
769 | st->stack = NULL; | ||
770 | #else | ||
771 | /*st->stack = (char*)speex_alloc_scratch(SB_DEC_STACK);*/ | ||
772 | speex_decoder_ctl(st->st_low, SPEEX_GET_STACK, &st->stack); | ||
773 | #endif | ||
774 | |||
771 | st->full_frame_size = 2*mode->frameSize; | 775 | st->full_frame_size = 2*mode->frameSize; |
772 | st->frame_size = mode->frameSize; | 776 | st->frame_size = mode->frameSize; |
773 | st->subframeSize = mode->subframeSize; | 777 | st->subframeSize = mode->subframeSize; |
@@ -813,7 +817,7 @@ void sb_decoder_destroy(void *state) | |||
813 | st = (SBDecState*)state; | 817 | st = (SBDecState*)state; |
814 | speex_decoder_destroy(st->st_low); | 818 | speex_decoder_destroy(st->st_low); |
815 | #if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) | 819 | #if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) |
816 | speex_free_scratch(st->stack); | 820 | /*speex_free_scratch(st->stack);*/ |
817 | #endif | 821 | #endif |
818 | 822 | ||
819 | speex_free(st->g0_mem); | 823 | speex_free(st->g0_mem); |
@@ -882,6 +886,8 @@ int sb_decode(void *state, SpeexBits *bits, void *vout) | |||
882 | const SpeexSBMode *mode; | 886 | const SpeexSBMode *mode; |
883 | spx_word16_t *out = (spx_word16_t*)vout; | 887 | spx_word16_t *out = (spx_word16_t*)vout; |
884 | spx_word16_t *low_innov_alias; | 888 | spx_word16_t *low_innov_alias; |
889 | spx_word32_t exc_ener_sum = 0; | ||
890 | |||
885 | st = (SBDecState*)state; | 891 | st = (SBDecState*)state; |
886 | stack=st->stack; | 892 | stack=st->stack; |
887 | mode = (const SpeexSBMode*)(st->mode->mode); | 893 | mode = (const SpeexSBMode*)(st->mode->mode); |
@@ -925,7 +931,7 @@ int sb_decode(void *state, SpeexBits *bits, void *vout) | |||
925 | } | 931 | } |
926 | if (st->submodeID != 0 && st->submodes[st->submodeID] == NULL) | 932 | if (st->submodeID != 0 && st->submodes[st->submodeID] == NULL) |
927 | { | 933 | { |
928 | speex_warning("Invalid mode encountered: corrupted stream?"); | 934 | speex_notify("Invalid mode encountered. The stream is corrupted."); |
929 | return -2; | 935 | return -2; |
930 | } | 936 | } |
931 | } | 937 | } |
@@ -1006,8 +1012,8 @@ int sb_decode(void *state, SpeexBits *bits, void *vout) | |||
1006 | rh = LPC_SCALING; | 1012 | rh = LPC_SCALING; |
1007 | for (i=0;i<st->lpcSize;i+=2) | 1013 | for (i=0;i<st->lpcSize;i+=2) |
1008 | { | 1014 | { |
1009 | rh += st->interp_qlpc[i+1] - st->interp_qlpc[i]; | 1015 | rh += ak[i+1] - ak[i]; |
1010 | st->pi_gain[sub] += st->interp_qlpc[i] + st->interp_qlpc[i+1]; | 1016 | st->pi_gain[sub] += ak[i] + ak[i+1]; |
1011 | } | 1017 | } |
1012 | 1018 | ||
1013 | rl = low_pi_gain[sub]; | 1019 | rl = low_pi_gain[sub]; |
@@ -1083,9 +1089,9 @@ int sb_decode(void *state, SpeexBits *bits, void *vout) | |||
1083 | for (i=0;i<st->lpcSize;i++) | 1089 | for (i=0;i<st->lpcSize;i++) |
1084 | st->interp_qlpc[i] = ak[i]; | 1090 | st->interp_qlpc[i] = ak[i]; |
1085 | st->exc_rms[sub] = compute_rms16(st->excBuf, st->subframeSize); | 1091 | st->exc_rms[sub] = compute_rms16(st->excBuf, st->subframeSize); |
1086 | 1092 | exc_ener_sum = ADD32(exc_ener_sum, DIV32(MULT16_16(st->exc_rms[sub],st->exc_rms[sub]), st->nbSubframes)); | |
1087 | } | 1093 | } |
1088 | st->last_ener = compute_rms16(out+st->frame_size, st->frame_size); | 1094 | st->last_ener = spx_sqrt(exc_ener_sum); |
1089 | 1095 | ||
1090 | qmf_synth(out, out+st->frame_size, h0, out, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack); | 1096 | qmf_synth(out, out+st->frame_size, h0, out, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack); |
1091 | for (i=0;i<st->lpcSize;i++) | 1097 | for (i=0;i<st->lpcSize;i++) |
@@ -1335,7 +1341,9 @@ int sb_encoder_ctl(void *state, int request, void *ptr) | |||
1335 | case SPEEX_SET_WIDEBAND: | 1341 | case SPEEX_SET_WIDEBAND: |
1336 | speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr); | 1342 | speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr); |
1337 | break; | 1343 | break; |
1338 | 1344 | case SPEEX_GET_STACK: | |
1345 | *((char**)ptr) = st->stack; | ||
1346 | break; | ||
1339 | default: | 1347 | default: |
1340 | speex_warning_int("Unknown nb_ctl request: ", request); | 1348 | speex_warning_int("Unknown nb_ctl request: ", request); |
1341 | return -1; | 1349 | return -1; |
@@ -1433,7 +1441,9 @@ int sb_decoder_ctl(void *state, int request, void *ptr) | |||
1433 | case SPEEX_GET_HIGHPASS: | 1441 | case SPEEX_GET_HIGHPASS: |
1434 | speex_decoder_ctl(st->st_low, SPEEX_GET_HIGHPASS, ptr); | 1442 | speex_decoder_ctl(st->st_low, SPEEX_GET_HIGHPASS, ptr); |
1435 | break; | 1443 | break; |
1436 | 1444 | case SPEEX_GET_ACTIVITY: | |
1445 | speex_decoder_ctl(st->st_low, SPEEX_GET_ACTIVITY, ptr); | ||
1446 | break; | ||
1437 | case SPEEX_GET_PI_GAIN: | 1447 | case SPEEX_GET_PI_GAIN: |
1438 | { | 1448 | { |
1439 | int i; | 1449 | int i; |
@@ -1458,7 +1468,9 @@ int sb_decoder_ctl(void *state, int request, void *ptr) | |||
1458 | case SPEEX_SET_WIDEBAND: | 1468 | case SPEEX_SET_WIDEBAND: |
1459 | speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr); | 1469 | speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr); |
1460 | break; | 1470 | break; |
1461 | 1471 | case SPEEX_GET_STACK: | |
1472 | *((char**)ptr) = st->stack; | ||
1473 | break; | ||
1462 | default: | 1474 | default: |
1463 | speex_warning_int("Unknown nb_ctl request: ", request); | 1475 | speex_warning_int("Unknown nb_ctl request: ", request); |
1464 | return -1; | 1476 | return -1; |