diff options
author | Nils Wallménius <nils@rockbox.org> | 2012-09-25 19:28:32 +0200 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-09-28 00:09:54 +0200 |
commit | 082cd01eb212e9d973f64b3e90ed8e3345026ac5 (patch) | |
tree | ada1e3e2ebaf84c7e80de0a1b02f777136a23bed | |
parent | f49785cdceed9d73c4483cdc52a1e4be5aee4be3 (diff) | |
download | rockbox-082cd01eb212e9d973f64b3e90ed8e3345026ac5.tar.gz rockbox-082cd01eb212e9d973f64b3e90ed8e3345026ac5.zip |
opus: speed up deemphasis
Remove downsampling code from deemphasis loop as we don't use
it and remove multiplications that are not relevant when
not using custom modes. Saves 1.4MHz on h300 (cf), 4.3MHz on
c200 (pp) and 4.6 on fuzev1 (amsv1).
Change-Id: Iab3f1d737a656a563aaa351d50db987a9cff2287
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/celt.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/celt.c b/lib/rbcodec/codecs/libopus/celt/celt.c index a4afb247b1..d91b8689b5 100644 --- a/lib/rbcodec/codecs/libopus/celt/celt.c +++ b/lib/rbcodec/codecs/libopus/celt/celt.c | |||
@@ -458,10 +458,10 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X | |||
458 | RESTORE_STACK; | 458 | RESTORE_STACK; |
459 | } | 459 | } |
460 | 460 | ||
461 | static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem) | 461 | static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, /* int downsample,*/ const opus_val16 *coef, celt_sig *mem) |
462 | { | 462 | { |
463 | int c; | 463 | int c; |
464 | int count=0; | 464 | /* int count=0;*/ |
465 | c=0; do { | 465 | c=0; do { |
466 | int j; | 466 | int j; |
467 | celt_sig * OPUS_RESTRICT x; | 467 | celt_sig * OPUS_RESTRICT x; |
@@ -472,18 +472,21 @@ static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsa | |||
472 | for (j=0;j<N;j++) | 472 | for (j=0;j<N;j++) |
473 | { | 473 | { |
474 | celt_sig tmp = *x + m; | 474 | celt_sig tmp = *x + m; |
475 | m = MULT16_32_Q15(coef[0], tmp) | 475 | m = MULT16_32_Q15(coef[0], tmp); |
476 | - MULT16_32_Q15(coef[1], *x); | 476 | #ifdef CUSTOM_MODES |
477 | m -= MULT16_32_Q15(coef[1], *x); | ||
477 | tmp = SHL32(MULT16_32_Q15(coef[3], tmp), 2); | 478 | tmp = SHL32(MULT16_32_Q15(coef[3], tmp), 2); |
479 | #endif | ||
478 | x++; | 480 | x++; |
479 | /* Technically the store could be moved outside of the if because | 481 | /* Technically the store could be moved outside of the if because |
480 | the stores we don't want will just be overwritten */ | 482 | the stores we don't want will just be overwritten */ |
481 | if (count==0) | 483 | /* ROCKBOX: we don't downsample |
484 | if (count==0) */ | ||
482 | *y = SCALEOUT(SIG2WORD16(tmp)); | 485 | *y = SCALEOUT(SIG2WORD16(tmp)); |
483 | if (++count==downsample) | 486 | /* if (++count==downsample) */ |
484 | { | 487 | { |
485 | y+=C; | 488 | y+=C; |
486 | count=0; | 489 | /* count=0; */ |
487 | } | 490 | } |
488 | } | 491 | } |
489 | mem[c] = m; | 492 | mem[c] = m; |
@@ -2286,7 +2289,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R | |||
2286 | } while (++c<C); | 2289 | } while (++c<C); |
2287 | } | 2290 | } |
2288 | 2291 | ||
2289 | deemphasis(out_syn, pcm, N, C, st->downsample, st->mode->preemph, st->preemph_memD); | 2292 | deemphasis(out_syn, pcm, N, C, /*st->downsample,*/ st->mode->preemph, st->preemph_memD); |
2290 | 2293 | ||
2291 | st->loss_count++; | 2294 | st->loss_count++; |
2292 | 2295 | ||
@@ -2661,7 +2664,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat | |||
2661 | } while (++c<2); | 2664 | } while (++c<2); |
2662 | st->rng = dec->rng; | 2665 | st->rng = dec->rng; |
2663 | 2666 | ||
2664 | deemphasis(out_syn, pcm, N, CC, st->downsample, st->mode->preemph, st->preemph_memD); | 2667 | deemphasis(out_syn, pcm, N, CC, /*st->downsample,*/ st->mode->preemph, st->preemph_memD); |
2665 | st->loss_count = 0; | 2668 | st->loss_count = 0; |
2666 | RESTORE_STACK; | 2669 | RESTORE_STACK; |
2667 | if (ec_tell(dec) > 8*len) | 2670 | if (ec_tell(dec) > 8*len) |