aboutsummaryrefslogtreecommitdiffstats
path: root/libgsmhr
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2015-12-30 11:45:58 +0100
committerSylvain Munaut <tnt@246tNt.com>2015-12-30 11:55:03 +0100
commit5e2e0442e0fd0f4d6cfaed7049d4dad2139d7d4c (patch)
tree693fbc9d673e6764d4e5f05ec9188bdd15b1eff0 /libgsmhr
parent59a6c2dc621cedb6480f0704170137dc28aca846 (diff)
libgsmhr: Add some code cleanup / speedup patches for reference codec
Mostly this will help witht the upcoming bss switcheroo patch Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'libgsmhr')
-rw-r--r--libgsmhr/Makefile.am2
-rw-r--r--libgsmhr/patches/0003-Remove-unused-variables.patch22
-rw-r--r--libgsmhr/patches/0004-Make-sure-all-constants-are-marked-as-such.patch175
-rw-r--r--libgsmhr/patches/0005-Remove-globals-initialization.patch48
-rw-r--r--libgsmhr/patches/0006-Allow-inlining-of-most-of-the-math-function-for-bett.patch142
5 files changed, 388 insertions, 1 deletions
diff --git a/libgsmhr/Makefile.am b/libgsmhr/Makefile.am
index fa62bfe..15166b4 100644
--- a/libgsmhr/Makefile.am
+++ b/libgsmhr/Makefile.am
@@ -6,7 +6,7 @@ EXTRA_DIST=fetch_sources.py
LIBVERSION=0:0:0
REFSRC_PATH=refsrc
-REFSRC_SRC=refsrc/dtx.c refsrc/globdefs.c refsrc/host.c refsrc/mathhalf.c refsrc/sp_enc.c refsrc/sp_rom.c refsrc/vad.c refsrc/err_conc.c refsrc/homing.c refsrc/mathdp31.c refsrc/sp_dec.c refsrc/sp_frm.c refsrc/sp_sfrm.c
+REFSRC_SRC=refsrc/dtx.c refsrc/globdefs.c refsrc/host.c refsrc/sp_enc.c refsrc/sp_rom.c refsrc/vad.c refsrc/err_conc.c refsrc/homing.c refsrc/mathdp31.c refsrc/sp_dec.c refsrc/sp_frm.c refsrc/sp_sfrm.c
${REFSRC_PATH}/.downloaded:
$(srcdir)/fetch_sources.py "${REFSRC_PATH}"
diff --git a/libgsmhr/patches/0003-Remove-unused-variables.patch b/libgsmhr/patches/0003-Remove-unused-variables.patch
new file mode 100644
index 0000000..1a761db
--- /dev/null
+++ b/libgsmhr/patches/0003-Remove-unused-variables.patch
@@ -0,0 +1,22 @@
+From 22bf213844de942c6692c4f11d7561f4ff87a183 Mon Sep 17 00:00:00 2001
+From: Sylvain Munaut <tnt@246tNt.com>
+Date: Wed, 30 Dec 2015 09:50:58 +0100
+Subject: [PATCH 3/6] Remove unused variables
+
+Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
+---
+ dtx.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git refsrc/dtx.c refsrc/dtx.c
+index 4ec8edb..27dcb0d 100644
+--- refsrc/dtx.c
++++ refsrc/dtx.c
+@@ -748 +747,0 @@
+- pswFlatsRc[NP], /* Unquantized Rc's computed by FLAT */
+@@ -754 +753 @@
+- int i,
++ int
+--
+2.4.10
+
diff --git a/libgsmhr/patches/0004-Make-sure-all-constants-are-marked-as-such.patch b/libgsmhr/patches/0004-Make-sure-all-constants-are-marked-as-such.patch
new file mode 100644
index 0000000..37fc413
--- /dev/null
+++ b/libgsmhr/patches/0004-Make-sure-all-constants-are-marked-as-such.patch
@@ -0,0 +1,175 @@
+From 8344eeb802a60a52bde844e4cf0ee81cffc9c329 Mon Sep 17 00:00:00 2001
+From: Sylvain Munaut <tnt@246tNt.com>
+Date: Wed, 30 Dec 2015 09:56:12 +0100
+Subject: [PATCH 4/6] Make sure all constants are marked as such
+
+This removes 'static' and moves stuff from .data to .rodata
+
+Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
+---
+ dtx.c | 4 ++--
+ homing.c | 4 ++--
+ sp_dec.c | 22 ++++++++++++----------
+ sp_dec.h | 8 ++++----
+ sp_enc.c | 8 ++++----
+ sp_frm.c | 10 +++++-----
+ sp_frm.h | 4 ++--
+ sp_rom.c | 2 +-
+ sp_rom.h | 2 +-
+ sp_sfrm.c | 7 +++----
+ typedefs.h | 4 ++--
+ 11 files changed, 38 insertions(+), 37 deletions(-)
+
+diff --git refsrc/dtx.c refsrc/dtx.c
+index 27dcb0d..918dc88 100644
+--- refsrc/dtx.c
++++ refsrc/dtx.c
+@@ -103 +103 @@
+-Shortword psrCNNewFactor[12] = {0x0aaa, 0x1554, 0x1ffe, 0x2aa8, 0x3552,
++const Shortword psrCNNewFactor[12] = {0x0aaa, 0x1554, 0x1ffe, 0x2aa8, 0x3552,
+@@ -110 +110 @@
+-LongwordRom ppLr_gsTable[4][32] =
++const LongwordRom ppLr_gsTable[4][32] =
+diff --git refsrc/homing.c refsrc/homing.c
+index b45ea03..9901ac8 100644
+--- refsrc/homing.c
++++ refsrc/homing.c
+@@ -120 +120 @@
+- static int n[] = {5, 11, 9, 8, 1, 2, 7, 7, 5, 7, 7, 5, 7, 7, 5, 7, 7, 5};
++ const int n[] = {5, 11, 9, 8, 1, 2, 7, 7, 5, 7, 7, 5, 7, 7, 5, 7, 7, 5};
+@@ -122 +122 @@
+- static Shortword dhf_mask[] =
++ const Shortword dhf_mask[] =
+diff --git refsrc/sp_dec.c refsrc/sp_dec.c
+index 07398a7..6022f5a 100644
+--- refsrc/sp_dec.c
++++ refsrc/sp_dec.c
+@@ -733 +733 @@
+- static ShortwordRom psrSST[NP + 1] = {0x7FFF,
++ const ShortwordRom psrSST[NP + 1] = {0x7FFF,
+@@ -1477,2 +1477,2 @@
+- Shortword *ppswSynthAs[], Shortword *ppswPFNumAs[],
+- Shortword *ppswPFDenomAs[])
++ Shortword * const ppswSynthAs[], Shortword * const ppswPFNumAs[],
++ Shortword * const ppswPFDenomAs[])
+@@ -4621 +4620,0 @@
+- *pswLtpStateOut = &pswLtpStateBaseDec[LTP_LEN],
+@@ -4624,2 +4623,5 @@
+- pswPFDenomAsSpace[NP * N_SUB],
+- *ppswSynthAs[N_SUB] = {
++ pswPFDenomAsSpace[NP * N_SUB];
++
++ static Shortword
++ * const pswLtpStateOut = &pswLtpStateBaseDec[LTP_LEN],
++ * const ppswSynthAs[N_SUB] = {
+@@ -4632 +4634 @@
+- *ppswPFNumAs[N_SUB] = {
++ * const ppswPFNumAs[N_SUB] = {
+@@ -4638 +4640 @@
+- *ppswPFDenomAs[N_SUB] = {
++ * const ppswPFDenomAs[N_SUB] = {
+@@ -4645 +4647 @@
+- static ShortwordRom
++ const ShortwordRom
+@@ -5429 +5431 @@
+-void v_con(Shortword pswBVects[], Shortword pswOutVect[],
++void v_con(const Shortword pswBVects[], Shortword pswOutVect[],
+diff --git refsrc/sp_dec.h refsrc/sp_dec.h
+index b18e3cb..2d3bd71 100644
+--- refsrc/sp_dec.h
++++ refsrc/sp_dec.h
+@@ -38,3 +38,3 @@
+- Shortword *ppswSynthAs[],
+- Shortword *ppswPFNumAs[],
+- Shortword *ppswPFDenomAs[]);
++ Shortword * const ppswSynthAs[],
++ Shortword * const ppswPFNumAs[],
++ Shortword * const ppswPFDenomAs[]);
+@@ -97 +97 @@
+- void v_con(Shortword pswBVects[], Shortword pswOutVect[],
++ void v_con(const Shortword pswBVects[], Shortword pswOutVect[],
+diff --git refsrc/sp_enc.c refsrc/sp_enc.c
+index 6dcb985..5f7eeef 100644
+--- refsrc/sp_enc.c
++++ refsrc/sp_enc.c
+@@ -133 +133 @@
+- static Shortword *pswLpcStart = &pswSpeech[LPCSTARTINDEX];
++ Shortword * const pswLpcStart = &pswSpeech[LPCSTARTINDEX];
+@@ -136 +136 @@
+- static Shortword *pswNewSpeech = &pswSpeech[NUMSTARTUPSMP];
++ Shortword * const pswNewSpeech = &pswSpeech[NUMSTARTUPSMP];
+@@ -139 +139 @@
+- static Shortword *pswWgtSpeech = &pswWgtSpeechSpace[LSMAX];
++ Shortword * const pswWgtSpeech = &pswWgtSpeechSpace[LSMAX];
+@@ -141 +141 @@
+- static struct NormSw *psnsWSfrmEng = &psnsWSfrmEngSpace[N_SUB];
++ struct NormSw * const psnsWSfrmEng = &psnsWSfrmEngSpace[N_SUB];
+diff --git refsrc/sp_frm.c refsrc/sp_frm.c
+index c4854ad..bb26381 100644
+--- refsrc/sp_frm.c
++++ refsrc/sp_frm.c
+@@ -2142 +2142 @@
+-void filt4_2nd(Shortword pswCoeff[], Shortword pswIn[],
++void filt4_2nd(const Shortword pswCoeff[], Shortword pswIn[],
+@@ -3106 +3106 @@
+- static Shortword pswPCoefE[3] =
++ const Shortword pswPCoefE[3] =
+@@ -3230 +3230 @@
+- static Shortword
++ const Shortword
+@@ -3938 +3938 @@
+-void iir_d(Shortword pswCoeff[], Shortword pswIn[], Shortword pswXstate[],
++void iir_d(const Shortword pswCoeff[], Shortword pswIn[], Shortword pswXstate[],
+@@ -5279 +5279 @@
+- static ShortwordRom psrSubMultFactor[] = {0x0aab, /* 1.0/12.0 */
++ const ShortwordRom psrSubMultFactor[] = {0x0aab, /* 1.0/12.0 */
+diff --git refsrc/sp_frm.h refsrc/sp_frm.h
+index 92317d9..8e2fb14 100644
+--- refsrc/sp_frm.h
++++ refsrc/sp_frm.h
+@@ -24 +24 @@
+-void iir_d(Shortword pswCoeff[], Shortword pswIn[],
++void iir_d(const Shortword pswCoeff[], Shortword pswIn[],
+@@ -32 +32 @@
+- void filt4_2nd(Shortword pswCoeff[],
++ void filt4_2nd(const Shortword pswCoeff[],
+diff --git refsrc/sp_rom.c refsrc/sp_rom.c
+index e666774..f9349d1 100644
+--- refsrc/sp_rom.c
++++ refsrc/sp_rom.c
+@@ -6416 +6416 @@
+-struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES] =
++const struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES] =
+diff --git refsrc/sp_rom.h refsrc/sp_rom.h
+index 8ac7d91..92a1537 100644
+--- refsrc/sp_rom.h
++++ refsrc/sp_rom.h
+@@ -128 +128 @@
+-extern struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES];
++extern const struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES];
+diff --git refsrc/sp_sfrm.c refsrc/sp_sfrm.c
+index d4f0cd6..f20837a 100644
+--- refsrc/sp_sfrm.c
++++ refsrc/sp_sfrm.c
+@@ -1961 +1961 @@
+- static Shortword
++ const Shortword
+@@ -2054,0 +2055,2 @@
++ const Shortword *pswBIndex, *pswUIndex, *pswModNextBit;
++
+@@ -2062,3 +2063,0 @@
+- *pswUIndex,
+- *pswBIndex,
+- *pswModNextBit,
+diff --git refsrc/typedefs.h refsrc/typedefs.h
+index 15200cc..819f999 100644
+--- refsrc/typedefs.h
++++ refsrc/typedefs.h
+@@ -26,2 +26,2 @@
+-typedef short int ShortwordRom; /* 16 bit ROM data (sr*) */
+-typedef int LongwordRom; /* 32 bit ROM data (L_r*) */
++typedef const short int ShortwordRom; /* 16 bit ROM data (sr*) */
++typedef const int LongwordRom; /* 32 bit ROM data (L_r*) */
+--
+2.4.10
+
diff --git a/libgsmhr/patches/0005-Remove-globals-initialization.patch b/libgsmhr/patches/0005-Remove-globals-initialization.patch
new file mode 100644
index 0000000..93b4a90
--- /dev/null
+++ b/libgsmhr/patches/0005-Remove-globals-initialization.patch
@@ -0,0 +1,48 @@
+From f91b68f12fe184640122db53f624cdad18c7e5be Mon Sep 17 00:00:00 2001
+From: Sylvain Munaut <tnt@246tNt.com>
+Date: Wed, 30 Dec 2015 09:58:23 +0100
+Subject: [PATCH 5/6] Remove globals initialization
+
+Theses will also be reset by calling resetDec / resetEnc, so we don't
+need them initialized here.
+
+This will move them from .data to .bss
+
+Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
+---
+ dtx.c | 2 +-
+ sp_dec.c | 8 ++++----
+ sp_enc.c | 2 +-
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git refsrc/dtx.c refsrc/dtx.c
+index 918dc88..254aff3 100644
+--- refsrc/dtx.c
++++ refsrc/dtx.c
+@@ -72 +72 @@
+-Shortword swNElapsed = 50;
++Shortword swNElapsed;
+diff --git refsrc/sp_dec.c refsrc/sp_dec.c
+index 6022f5a..b6f065d 100644
+--- refsrc/sp_dec.c
++++ refsrc/sp_dec.c
+@@ -168 +168 @@
+- Shortword swRxDTXState = CNINTPER - 1; /* DTX State at the rx.
++ Shortword swRxDTXState; /* DTX State at the rx.
+@@ -173,3 +173,3 @@
+- Shortword swDecoMode = SPEECH;
+- Shortword swDtxMuting = 0;
+- Shortword swDtxBfiCnt = 0;
++ Shortword swDecoMode;
++ Shortword swDtxMuting;
++ Shortword swDtxBfiCnt;
+diff --git refsrc/sp_enc.c refsrc/sp_enc.c
+index 5f7eeef..c71473c 100644
+--- refsrc/sp_enc.c
++++ refsrc/sp_enc.c
+@@ -72 +72 @@
+-Shortword swPtch = 1;
++Shortword swPtch;
+--
+2.4.10
+
diff --git a/libgsmhr/patches/0006-Allow-inlining-of-most-of-the-math-function-for-bett.patch b/libgsmhr/patches/0006-Allow-inlining-of-most-of-the-math-function-for-bett.patch
new file mode 100644
index 0000000..ea0162a
--- /dev/null
+++ b/libgsmhr/patches/0006-Allow-inlining-of-most-of-the-math-function-for-bett.patch
@@ -0,0 +1,142 @@
+From 6449c83295a4307a6cc7e7fb3a8b53c944116d27 Mon Sep 17 00:00:00 2001
+From: Sylvain Munaut <tnt@246tNt.com>
+Date: Wed, 30 Dec 2015 10:16:50 +0100
+Subject: [PATCH 6/6] Allow inlining of most of the math function for better
+ speed
+
+Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
+---
+ mathhalf.c | 29 +++++++++++++++++++++++++++++
+ mathhalf.h | 31 +++++++++++++++++++++++++++++++
+ 2 files changed, 60 insertions(+)
+
+diff --git refsrc/mathhalf.c refsrc/mathhalf.c
+index 40a2152..fe5d192 100644
+--- refsrc/mathhalf.c
++++ refsrc/mathhalf.c
+@@ -139,0 +140 @@
++static __attribute__((unused))
+@@ -201,0 +203 @@
++static __attribute__((unused))
+@@ -251,0 +254 @@
++static __attribute__((unused))
+@@ -304,0 +308 @@
++static __attribute__((unused))
+@@ -345,0 +350 @@
++static __attribute__((unused))
+@@ -385,0 +391 @@
++static __attribute__((unused))
+@@ -448,0 +455 @@
++static __attribute__((unused))
+@@ -514,0 +522 @@
++static __attribute__((unused))
+@@ -552,0 +561 @@
++static __attribute__((unused))
+@@ -613,0 +623 @@
++static __attribute__((unused))
+@@ -671,0 +682 @@
++static __attribute__((unused))
+@@ -717,0 +729 @@
++static __attribute__((unused))
+@@ -763,0 +776 @@
++static __attribute__((unused))
+@@ -831,0 +845 @@
++static __attribute__((unused))
+@@ -899,0 +914 @@
++static __attribute__((unused))
+@@ -1008,0 +1024 @@
++static __attribute__((unused))
+@@ -1104,0 +1121 @@
++static __attribute__((unused))
+@@ -1184,0 +1202 @@
++static __attribute__((unused))
+@@ -1247,0 +1266 @@
++static __attribute__((unused))
+@@ -1292,0 +1312 @@
++static __attribute__((unused))
+@@ -1348,0 +1369 @@
++static __attribute__((unused))
+@@ -1385,0 +1407 @@
++static __attribute__((unused))
+@@ -1454,0 +1477 @@
++static __attribute__((unused))
+@@ -1546,0 +1570 @@
++static __attribute__((unused))
+@@ -1597,0 +1622 @@
++static __attribute__((unused))
+@@ -1660,0 +1686 @@
++static __attribute__((unused))
+@@ -1740,0 +1767 @@
++static __attribute__((unused))
+@@ -1843,0 +1871 @@
++static __attribute__((unused))
+@@ -1943,0 +1972 @@
++static __attribute__((unused))
+diff --git refsrc/mathhalf.h refsrc/mathhalf.h
+index 247cfde..81c4004 100644
+--- refsrc/mathhalf.h
++++ refsrc/mathhalf.h
+@@ -14,0 +15 @@
++static
+@@ -15,0 +17 @@
++static
+@@ -16,0 +19 @@
++static
+@@ -17,0 +21 @@
++static
+@@ -22,0 +27 @@
++static
+@@ -23,0 +29 @@
++static
+@@ -24,0 +31 @@
++static
+@@ -30,0 +38 @@
++static
+@@ -31,0 +40 @@
++static
+@@ -32,0 +42 @@
++static
+@@ -33,0 +44 @@
++static
+@@ -34,0 +46 @@
++static
+@@ -35,0 +48 @@
++static
+@@ -40,0 +54 @@
++static
+@@ -41,0 +56 @@
++static
+@@ -47,0 +63 @@
++static
+@@ -49,0 +66 @@
++static
+@@ -51,0 +69 @@
++static
+@@ -53,0 +72 @@
++static
+@@ -59,0 +79 @@
++static
+@@ -60,0 +81 @@
++static
+@@ -66,0 +88 @@
++static
+@@ -67,0 +90 @@
++static
+@@ -68,0 +92 @@
++static
+@@ -69,0 +94 @@
++static
+@@ -74,0 +100 @@
++static
+@@ -79,0 +106 @@
++static
+@@ -80,0 +108 @@
++static
+@@ -84,0 +113 @@
++static
+@@ -96,0 +126,2 @@
++#include "mathhalf.c"
++
+--
+2.4.10
+