Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/external/speex/libspeex/cb_search_bfin.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | /* Copyright (C) 2005 Analog Devices */ |
| TMBOY | 47:9e361da97763 | 2 | /** |
| TMBOY | 47:9e361da97763 | 3 | @author Jean-Marc Valin |
| TMBOY | 47:9e361da97763 | 4 | @file cb_search_bfin.h |
| TMBOY | 47:9e361da97763 | 5 | @brief Fixed codebook functions (Blackfin version) |
| TMBOY | 47:9e361da97763 | 6 | */ |
| TMBOY | 47:9e361da97763 | 7 | /* |
| TMBOY | 47:9e361da97763 | 8 | Redistribution and use in source and binary forms, with or without |
| TMBOY | 47:9e361da97763 | 9 | modification, are permitted provided that the following conditions |
| TMBOY | 47:9e361da97763 | 10 | are met: |
| TMBOY | 47:9e361da97763 | 11 | |
| TMBOY | 47:9e361da97763 | 12 | - Redistributions of source code must retain the above copyright |
| TMBOY | 47:9e361da97763 | 13 | notice, this list of conditions and the following disclaimer. |
| TMBOY | 47:9e361da97763 | 14 | |
| TMBOY | 47:9e361da97763 | 15 | - Redistributions in binary form must reproduce the above copyright |
| TMBOY | 47:9e361da97763 | 16 | notice, this list of conditions and the following disclaimer in the |
| TMBOY | 47:9e361da97763 | 17 | documentation and/or other materials provided with the distribution. |
| TMBOY | 47:9e361da97763 | 18 | |
| TMBOY | 47:9e361da97763 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its |
| TMBOY | 47:9e361da97763 | 20 | contributors may be used to endorse or promote products derived from |
| TMBOY | 47:9e361da97763 | 21 | this software without specific prior written permission. |
| TMBOY | 47:9e361da97763 | 22 | |
| TMBOY | 47:9e361da97763 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| TMBOY | 47:9e361da97763 | 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| TMBOY | 47:9e361da97763 | 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| TMBOY | 47:9e361da97763 | 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
| TMBOY | 47:9e361da97763 | 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| TMBOY | 47:9e361da97763 | 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| TMBOY | 47:9e361da97763 | 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| TMBOY | 47:9e361da97763 | 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| TMBOY | 47:9e361da97763 | 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| TMBOY | 47:9e361da97763 | 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| TMBOY | 47:9e361da97763 | 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| TMBOY | 47:9e361da97763 | 34 | */ |
| TMBOY | 47:9e361da97763 | 35 | |
| TMBOY | 47:9e361da97763 | 36 | #define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK |
| TMBOY | 47:9e361da97763 | 37 | void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack) |
| TMBOY | 47:9e361da97763 | 38 | { |
| TMBOY | 47:9e361da97763 | 39 | int i; |
| TMBOY | 47:9e361da97763 | 40 | for (i=0;i<shape_cb_size;i++) |
| TMBOY | 47:9e361da97763 | 41 | { |
| TMBOY | 47:9e361da97763 | 42 | __asm__ __volatile__ ( |
| TMBOY | 47:9e361da97763 | 43 | "P0 = %0;\n\t" |
| TMBOY | 47:9e361da97763 | 44 | "LC0 = P0;\n\t" |
| TMBOY | 47:9e361da97763 | 45 | "P1 = %1;\n\t" |
| TMBOY | 47:9e361da97763 | 46 | "P2 = %2;\n\t" |
| TMBOY | 47:9e361da97763 | 47 | "P3 = %3;\n\t" |
| TMBOY | 47:9e361da97763 | 48 | "P0 = 1;\n\t" |
| TMBOY | 47:9e361da97763 | 49 | "L0 = 0;\n\t" |
| TMBOY | 47:9e361da97763 | 50 | "L1 = 0;\n\t" |
| TMBOY | 47:9e361da97763 | 51 | "R2 = 0;\n\t" |
| TMBOY | 47:9e361da97763 | 52 | "A1 = 0;\n\t" |
| TMBOY | 47:9e361da97763 | 53 | "LOOP outter%= LC0;\n\t" |
| TMBOY | 47:9e361da97763 | 54 | "LOOP_BEGIN outter%=;\n\t" |
| TMBOY | 47:9e361da97763 | 55 | "A0 = 0;\n\t" |
| TMBOY | 47:9e361da97763 | 56 | "P4 = P1;\n\t" |
| TMBOY | 47:9e361da97763 | 57 | "I1 = P2;\n\t" |
| TMBOY | 47:9e361da97763 | 58 | "R0 = B[P4++] (X) || R1.L = W[I1--];\n\t" |
| TMBOY | 47:9e361da97763 | 59 | "LOOP inner%= LC1 = P0;\n\t" |
| TMBOY | 47:9e361da97763 | 60 | "LOOP_BEGIN inner%=;\n\t" |
| TMBOY | 47:9e361da97763 | 61 | "A0 += R0.L*R1.L (IS) || R0 = B[P4++] (X) || R1.L = W[I1--];\n\t" |
| TMBOY | 47:9e361da97763 | 62 | "LOOP_END inner%=;\n\t" |
| TMBOY | 47:9e361da97763 | 63 | "R0 = A0;\n\t" |
| TMBOY | 47:9e361da97763 | 64 | "R0 >>>= 13;\n\t" |
| TMBOY | 47:9e361da97763 | 65 | "A1 += R0.L*R0.L (IS);\n\t" |
| TMBOY | 47:9e361da97763 | 66 | "W[P3++] = R0;\n\t" |
| TMBOY | 47:9e361da97763 | 67 | "P0 += 1;\n\t" |
| TMBOY | 47:9e361da97763 | 68 | "P2 += 2;\n\t" |
| TMBOY | 47:9e361da97763 | 69 | "LOOP_END outter%=;\n\t" |
| TMBOY | 47:9e361da97763 | 70 | "P4 = %4;\n\t" |
| TMBOY | 47:9e361da97763 | 71 | "R1 = A1;\n\t" |
| TMBOY | 47:9e361da97763 | 72 | "[P4] = R1;\n\t" |
| TMBOY | 47:9e361da97763 | 73 | : |
| TMBOY | 47:9e361da97763 | 74 | : "m" (subvect_size), "m" (shape_cb), "m" (r), "m" (resp), "m" (E) |
| TMBOY | 47:9e361da97763 | 75 | : "A0", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "I0", "I1", "L0", |
| TMBOY | 47:9e361da97763 | 76 | "L1", "A0", "A1", "memory" |
| TMBOY | 47:9e361da97763 | 77 | #if !(__GNUC__ == 3) |
| TMBOY | 47:9e361da97763 | 78 | , "LC0", "LC1" /* gcc 3.4 doesn't know about LC registers */ |
| TMBOY | 47:9e361da97763 | 79 | #endif |
| TMBOY | 47:9e361da97763 | 80 | ); |
| TMBOY | 47:9e361da97763 | 81 | shape_cb += subvect_size; |
| TMBOY | 47:9e361da97763 | 82 | resp += subvect_size; |
| TMBOY | 47:9e361da97763 | 83 | E++; |
| TMBOY | 47:9e361da97763 | 84 | } |
| TMBOY | 47:9e361da97763 | 85 | } |
| TMBOY | 47:9e361da97763 | 86 | |
| TMBOY | 47:9e361da97763 | 87 | #define OVERRIDE_TARGET_UPDATE |
| TMBOY | 47:9e361da97763 | 88 | static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len) |
| TMBOY | 47:9e361da97763 | 89 | { |
| TMBOY | 47:9e361da97763 | 90 | if (!len) |
| TMBOY | 47:9e361da97763 | 91 | return; |
| TMBOY | 47:9e361da97763 | 92 | __asm__ __volatile__ |
| TMBOY | 47:9e361da97763 | 93 | ( |
| TMBOY | 47:9e361da97763 | 94 | "I0 = %0;\n\t" |
| TMBOY | 47:9e361da97763 | 95 | "I1 = %1;\n\t" |
| TMBOY | 47:9e361da97763 | 96 | "L0 = 0;\n\t" |
| TMBOY | 47:9e361da97763 | 97 | "L1 = 0;\n\t" |
| TMBOY | 47:9e361da97763 | 98 | "R2 = 4096;\n\t" |
| TMBOY | 47:9e361da97763 | 99 | "LOOP tupdate%= LC0 = %3;\n\t" |
| TMBOY | 47:9e361da97763 | 100 | "LOOP_BEGIN tupdate%=;\n\t" |
| TMBOY | 47:9e361da97763 | 101 | "R0.L = W[I0] || R1.L = W[I1++];\n\t" |
| TMBOY | 47:9e361da97763 | 102 | "R1 = (A1 = R1.L*%2.L) (IS);\n\t" |
| TMBOY | 47:9e361da97763 | 103 | "R1 = R1 + R2;\n\t" |
| TMBOY | 47:9e361da97763 | 104 | "R1 >>>= 13;\n\t" |
| TMBOY | 47:9e361da97763 | 105 | "R0.L = R0.L - R1.L;\n\t" |
| TMBOY | 47:9e361da97763 | 106 | "W[I0++] = R0.L;\n\t" |
| TMBOY | 47:9e361da97763 | 107 | "LOOP_END tupdate%=;\n\t" |
| TMBOY | 47:9e361da97763 | 108 | : |
| TMBOY | 47:9e361da97763 | 109 | : "a" (t), "a" (r), "d" (g), "a" (len) |
| TMBOY | 47:9e361da97763 | 110 | : "R0", "R1", "R2", "A1", "I0", "I1", "L0", "L1" |
| TMBOY | 47:9e361da97763 | 111 | ); |
| TMBOY | 47:9e361da97763 | 112 | } |
