Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177699361
D61669.1795069335.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
14 KB
Referenced Files
None
Subscribers
None
D61669.1795069335.diff
View Options
diff --git a/lib/virtual_oss/bt/Makefile b/lib/virtual_oss/bt/Makefile
--- a/lib/virtual_oss/bt/Makefile
+++ b/lib/virtual_oss/bt/Makefile
@@ -4,7 +4,7 @@
avdtp.c \
sbc_encode.c
-LIBADD= bluetooth sdp
+LIBADD= bluetooth m sdp
.if defined(HAVE_LIBAV)
CFLAGS+= -I${LOCALBASE:U/usr/local}/include -DHAVE_LIBAV
diff --git a/lib/virtual_oss/bt/cosdata-gen/Makefile b/lib/virtual_oss/bt/cosdata-gen/Makefile
deleted file mode 100644
--- a/lib/virtual_oss/bt/cosdata-gen/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# $NetBSD$
-
-WARNS?= 3
-
-PROG= cosdata
-SRCS= cosdata.c
-MAN=
-
-DPADD+= ${LIBMATH}
-LDADD+= -lm
-
-.include <bsd.prog.mk>
diff --git a/lib/virtual_oss/bt/cosdata-gen/cosdata.c b/lib/virtual_oss/bt/cosdata-gen/cosdata.c
deleted file mode 100644
--- a/lib/virtual_oss/bt/cosdata-gen/cosdata.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*-
- * Copyright (c) 2015 - 2016 Nathanial Sloss <nathanialsloss@yahoo.com.au>
- * All rights reserved.
- *
- * This software is dedicated to the memory of -
- * Baron James Anlezark (Barry) - 1 Jan 1949 - 13 May 2012.
- *
- * Barry was a man who loved his music.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <stdint.h>
-
-static const double sbc8_coeffs[] = {
- 0.00000000e+00, 1.56575398e-04, 3.43256425e-04, 5.54620202e-04,
- 8.23919506e-04, 1.13992507e-03, 1.47640169e-03, 1.78371725e-03,
- 2.01182542e-03, 2.10371989e-03, 1.99454554e-03, 1.61656283e-03,
- 9.02154502e-04, -1.78805361e-04, -1.64973098e-03, -3.49717454e-03,
- 5.65949473e-03, 8.02941163e-03, 1.04584443e-02, 1.27472335e-02,
- 1.46525263e-02, 1.59045603e-02, 1.62208471e-02, 1.53184106e-02,
- 1.29371806e-02, 8.85757540e-03, 2.92408442e-03, -4.91578024e-03,
- -1.46404076e-02, -2.61098752e-02, -3.90751381e-02, -5.31873032e-02,
- 6.79989431e-02, 8.29847578e-02, 9.75753918e-02, 1.11196689e-01,
- 1.23264548e-01, 1.33264415e-01, 1.40753505e-01, 1.45389847e-01,
- 1.46955068e-01, 1.45389847e-01, 1.40753505e-01, 1.33264415e-01,
- 1.23264548e-01, 1.11196689e-01, 9.75753918e-02, 8.29847578e-02,
- -6.79989431e-02, -5.31873032e-02, -3.90751381e-02, -2.61098752e-02,
- -1.46404076e-02, -4.91578024e-03, 2.92408442e-03, 8.85757540e-03,
- 1.29371806e-02, 1.53184106e-02, 1.62208471e-02, 1.59045603e-02,
- 1.46525263e-02, 1.27472335e-02, 1.04584443e-02, 8.02941163e-03,
- -5.65949473e-03, -3.49717454e-03, -1.64973098e-03, -1.78805361e-04,
- 9.02154502e-04, 1.61656283e-03, 1.99454554e-03, 2.10371989e-03,
- 2.01182542e-03, 1.78371725e-03, 1.47640169e-03, 1.13992507e-03,
- 8.23919506e-04, 5.54620202e-04, 3.43256425e-04, 1.56575398e-04,
-};
-
-static const double sbc4_coeffs[] = {
- 0.00000000e+00, 5.36548976e-04, 1.49188357e-03, 2.73370904e-03,
- 3.83720193e-03, 3.89205149e-03, 1.86581691e-03, -3.06012286e-03,
- 1.09137620e-02, 2.04385087e-02, 2.88757392e-02, 3.21939290e-02,
- 2.58767811e-02, 6.13245186e-03, -2.88217274e-02, -7.76463494e-02,
- 1.35593274e-01, 1.94987841e-01, 2.46636662e-01, 2.81828203e-01,
- 2.94315332e-01, 2.81828203e-01, 2.46636662e-01, 1.94987841e-01,
- -1.35593274e-01, -7.76463494e-02, -2.88217274e-02, 6.13245186e-03,
- 2.58767811e-02, 3.21939290e-02, 2.88757392e-02, 2.04385087e-02,
- -1.09137620e-02, -3.06012286e-03, 1.86581691e-03, 3.89205149e-03,
- 3.83720193e-03, 2.73370904e-03, 1.49188357e-03, 5.36548976e-04,
-};
-
-#define AC(x) (int)(sizeof(x) / sizeof((x)[0]))
-
-int
-main(int argc, char **argv)
-{
- float S[8][16];
- int i;
- int k;
- int count = 0;
-
- printf("/* sbc_coeffs.h - Automatically generated by cosdata.c. */\n"
- "\n");
-
- printf("static const float sbc_coeffs8[] = {\n ");
- for (k = 0; k < AC(sbc8_coeffs); k++) {
- if ((count % 8) == 0 && count != 0)
- printf("\n ");
- printf("%0.12ff, ", (float)sbc8_coeffs[k]);
- count++;
- }
- printf("\n};\n");
-
- count = 0;
- printf("static const float sbc_coeffs4[] = {\n ");
- for (k = 0; k < AC(sbc4_coeffs); k++) {
- if ((count % 8) == 0 && count != 0)
- printf("\n ");
- printf("%0.12ff, ", (float)sbc4_coeffs[k]);
- count++;
- }
- printf("\n};\n");
-
- count = 0;
- printf("static const float cosdata8[8][16] = {\n ");
- for (i = 0; i < 8; i++) {
- for (k = 0; k < 16; k++) {
- S[i][k] = cosf((float)((i + 0.5) * (k - 4) * (M_PI / 8.0)));
-
- if ((count % 8) == 0 && count != 0)
- printf("\n ");
- if (k == 0)
- printf("{ ");
- printf("%0.12ff, ", S[i][k]);
- if (k == 15)
- printf("},");
- count++;
- }
- }
- printf("\n};\n");
-
- count = 0;
- printf("static const float cosdata4[4][8] = {\n ");
- for (i = 0; i < 4; i++) {
- for (k = 0; k < 8; k++) {
- S[i][k] = cosf((float)((i + 0.5) * (k - 2) * (M_PI / 4.0)));
-
- if ((count % 8) == 0 && count != 0)
- printf("\n ");
- if (k == 0)
- printf("{ ");
- printf("%0.12ff, ", S[i][k]);
- if (k == 7)
- printf("},");
- count++;
- }
- }
- printf("\n};\n");
-
- count = 0;
- printf("static const float cosdecdata8[8][16] = {\n ");
- for (i = 0; i < 8; i++) {
- for (k = 0; k < 16; k++) {
- S[i][k] = cosf((float)((i + 0.5) * (k + 4) * (M_PI / 8.0)));
-
- if ((count % 8) == 0 && count != 0)
- printf("\n ");
- if (k == 0)
- printf("{ ");
- printf("%0.12ff, ", S[i][k]);
- if (k == 15)
- printf("},");
- count++;
- }
- }
- printf("\n};\n");
-
- count = 0;
- printf("static const float cosdecdata4[4][8] = {\n ");
- for (i = 0; i < 4; i++) {
- for (k = 0; k < 8; k++) {
- S[i][k] = cosf((float)((i + 0.5) * (k + 2) * (M_PI / 4.0)));
-
- if ((count % 8) == 0 && count != 0)
- printf("\n ");
- if (k == 0)
- printf("{ ");
- printf("%0.12ff, ", S[i][k]);
- if (k == 7)
- printf("},");
- count++;
- }
- }
- printf("\n};\n");
-
- return (0);
-}
diff --git a/lib/virtual_oss/bt/sbc_coeffs.h b/lib/virtual_oss/bt/sbc_coeffs.h
--- a/lib/virtual_oss/bt/sbc_coeffs.h
+++ b/lib/virtual_oss/bt/sbc_coeffs.h
@@ -1,4 +1,4 @@
-/* sbc_coeffs.h - Automatically generated by cosdata.c. */
+/* SBC prototype filter window coefficients, from the A2DP specification. */
static const float sbc_coeffs8[] = {
0.000000000000f, 0.000156575392f, 0.000343256426f, 0.000554620230f, 0.000823919487f, 0.001139925094f, 0.001476401696f, 0.001783717307f,
@@ -19,51 +19,3 @@
-0.135593280196f, -0.077646352351f, -0.028821727261f, 0.006132451817f, 0.025876780972f, 0.032193928957f, 0.028875738382f, 0.020438509062f,
-0.010913762264f, -0.003060122952f, 0.001865816885f, 0.003892051522f, 0.003837201977f, 0.002733709058f, 0.001491883537f, 0.000536548963f,
};
-static const float cosdata8[8][16] = {
- { 0.707106769085f, 0.831469595432f, 0.923879504204f, 0.980785250664f, 1.000000000000f, 0.980785250664f, 0.923879504204f, 0.831469595432f,
- 0.707106769085f, 0.555570244789f, 0.382683426142f, 0.195090353489f, -0.000000043711f, -0.195090323687f, -0.382683396339f, -0.555570185184f, },
- { -0.707106769085f, -0.195090323687f, 0.382683426142f, 0.831469595432f, 1.000000000000f, 0.831469595432f, 0.382683426142f, -0.195090323687f,
- -0.707106769085f, -0.980785310268f, -0.923879504204f, -0.555570423603f, 0.000000011925f, 0.555570065975f, 0.923879563808f, 0.980785310268f, },
- { -0.707106828690f, -0.980785310268f, -0.382683396339f, 0.555570244789f, 1.000000000000f, 0.555570244789f, -0.382683396339f, -0.980785310268f,
- -0.707106828690f, 0.195090413094f, 0.923879563808f, 0.831469655037f, 0.000000139071f, -0.831469774246f, -0.923879444599f, -0.195090219378f, },
- { 0.707106649876f, -0.555570423603f, -0.923879504204f, 0.195090353489f, 1.000000000000f, 0.195090353489f, -0.923879504204f, -0.555570423603f,
- 0.707106649876f, 0.831469655037f, -0.382683008909f, -0.980785369873f, -0.000000290067f, 0.980785250664f, 0.382683545351f, -0.831469595432f, },
- { 0.707106769085f, 0.555570065975f, -0.923879504204f, -0.195090323687f, 1.000000000000f, -0.195090323687f, -0.923879504204f, 0.555570065975f,
- 0.707106769085f, -0.831469774246f, -0.382683843374f, 0.980785250664f, -0.000000035775f, -0.980785250664f, 0.382683902979f, 0.831469714642f, },
- { -0.707106590271f, 0.980785310268f, -0.382683575153f, -0.555570185184f, 1.000000000000f, -0.555570185184f, -0.382683575153f, 0.980785310268f,
- -0.707106590271f, -0.195090219378f, 0.923879683018f, -0.831469595432f, -0.000000592058f, 0.831469714642f, -0.923879623413f, 0.195090919733f, },
- { -0.707106530666f, 0.195090532303f, 0.382683604956f, -0.831469655037f, 1.000000000000f, -0.831469655037f, 0.382683604956f, 0.195090532303f,
- -0.707106530666f, 0.980785310268f, -0.923879384995f, 0.555569529533f, -0.000000687457f, -0.555570006371f, 0.923879563808f, -0.980785191059f, },
- { 0.707106828690f, -0.831469774246f, 0.923879563808f, -0.980785310268f, 1.000000000000f, -0.980785310268f, 0.923879563808f, -0.831469774246f,
- 0.707106828690f, -0.555570065975f, 0.382683902979f, -0.195089668036f, 0.000000059624f, 0.195089548826f, -0.382683813572f, 0.555569946766f, },
-};
-static const float cosdata4[4][8] = {
- { 0.707106769085f, 0.923879504204f, 1.000000000000f, 0.923879504204f, 0.707106769085f, 0.382683426142f, -0.000000043711f, -0.382683396339f, },
- { -0.707106769085f, 0.382683426142f, 1.000000000000f, 0.382683426142f, -0.707106769085f, -0.923879504204f, 0.000000011925f, 0.923879563808f, },
- { -0.707106828690f, -0.382683396339f, 1.000000000000f, -0.382683396339f, -0.707106828690f, 0.923879563808f, 0.000000139071f, -0.923879444599f, },
- { 0.707106649876f, -0.923879504204f, 1.000000000000f, -0.923879504204f, 0.707106649876f, -0.382683008909f, -0.000000290067f, 0.382683545351f, },
-};
-static const float cosdecdata8[8][16] = {
- { 0.707106769085f, 0.555570244789f, 0.382683426142f, 0.195090353489f, -0.000000043711f, -0.195090323687f, -0.382683396339f, -0.555570185184f,
- -0.707106769085f, -0.831469655037f, -0.923879504204f, -0.980785310268f, -1.000000000000f, -0.980785310268f, -0.923879504204f, -0.831469535828f, },
- { -0.707106769085f, -0.980785310268f, -0.923879504204f, -0.555570423603f, 0.000000011925f, 0.555570065975f, 0.923879563808f, 0.980785310268f,
- 0.707106769085f, 0.195090532303f, -0.382683008909f, -0.831469774246f, -1.000000000000f, -0.831469714642f, -0.382683843374f, 0.195090577006f, },
- { -0.707106828690f, 0.195090413094f, 0.923879563808f, 0.831469655037f, 0.000000139071f, -0.831469774246f, -0.923879444599f, -0.195090219378f,
- 0.707106828690f, 0.980785310268f, 0.382683545351f, -0.555570065975f, -1.000000000000f, -0.555570542812f, 0.382683902979f, 0.980785191059f, },
- { 0.707106649876f, 0.831469655037f, -0.382683008909f, -0.980785369873f, -0.000000290067f, 0.980785250664f, 0.382683545351f, -0.831469595432f,
- -0.707107424736f, 0.555569529533f, 0.923879802227f, -0.195089668036f, -1.000000000000f, -0.195090815425f, 0.923879384995f, 0.555570483208f, },
- { 0.707106769085f, -0.831469774246f, -0.382683843374f, 0.980785250664f, -0.000000035775f, -0.980785250664f, 0.382683902979f, 0.831469714642f,
- -0.707106173038f, -0.555570006371f, 0.923879384995f, 0.195089548826f, -1.000000000000f, 0.195089697838f, 0.923879325390f, -0.555570125580f, },
- { -0.707106590271f, -0.195090219378f, 0.923879683018f, -0.831469595432f, -0.000000592058f, 0.831469714642f, -0.923879623413f, 0.195090919733f,
- 0.707107424736f, -0.980785191059f, 0.382683366537f, 0.555569946766f, -1.000000000000f, 0.555571198463f, 0.382683783770f, -0.980785667896f, },
- { -0.707106530666f, 0.980785310268f, -0.923879384995f, 0.555569529533f, -0.000000687457f, -0.555570006371f, 0.923879563808f, -0.980785191059f,
- 0.707106173038f, -0.195089071989f, -0.382684975863f, 0.831468641758f, -1.000000000000f, 0.831470131874f, -0.382683992386f, -0.195090129972f, },
- { 0.707106828690f, -0.555570065975f, 0.382683902979f, -0.195089668036f, 0.000000059624f, 0.195089548826f, -0.382683813572f, 0.555569946766f,
- -0.707106053829f, 0.831468641758f, -0.923880040646f, 0.980785369873f, -1.000000000000f, 0.980785429478f, -0.923880159855f, 0.831468760967f, },
-};
-static const float cosdecdata4[4][8] = {
- { 0.707106769085f, 0.382683426142f, -0.000000043711f, -0.382683396339f, -0.707106769085f, -0.923879504204f, -1.000000000000f, -0.923879504204f, },
- { -0.707106769085f, -0.923879504204f, 0.000000011925f, 0.923879563808f, 0.707106769085f, -0.382683008909f, -1.000000000000f, -0.382683843374f, },
- { -0.707106828690f, 0.923879563808f, 0.000000139071f, -0.923879444599f, 0.707106828690f, 0.382683545351f, -1.000000000000f, 0.382683902979f, },
- { 0.707106649876f, -0.382683008909f, -0.000000290067f, 0.382683545351f, -0.707107424736f, 0.923879802227f, -1.000000000000f, 0.923879384995f, },
-};
diff --git a/lib/virtual_oss/bt/sbc_encode.c b/lib/virtual_oss/bt/sbc_encode.c
--- a/lib/virtual_oss/bt/sbc_encode.c
+++ b/lib/virtual_oss/bt/sbc_encode.c
@@ -65,6 +65,35 @@
{-2, 0, 0, 1},
};
+/* Analysis and synthesis matrices, filled once at load time. */
+static float cosdata8[8][16];
+static float cosdata4[4][8];
+static float cosdecdata8[8][16];
+static float cosdecdata4[4][8];
+
+static void __attribute__((constructor))
+sbc_init_tables(void)
+{
+ int i, k;
+
+ for (i = 0; i != 8; i++) {
+ for (k = 0; k != 16; k++) {
+ cosdata8[i][k] =
+ cosf((float)((i + 0.5) * (k - 4) * (M_PI / 8.0)));
+ cosdecdata8[i][k] =
+ cosf((float)((i + 0.5) * (k + 4) * (M_PI / 8.0)));
+ }
+ }
+ for (i = 0; i != 4; i++) {
+ for (k = 0; k != 8; k++) {
+ cosdata4[i][k] =
+ cosf((float)((i + 0.5) * (k - 2) * (M_PI / 4.0)));
+ cosdecdata4[i][k] =
+ cosf((float)((i + 0.5) * (k + 2) * (M_PI / 4.0)));
+ }
+ }
+}
+
static uint8_t
calc_scalefactors_joint(struct sbc_encode *sbc)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 19, 6:22 AM (11 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41824883
Default Alt Text
D61669.1795069335.diff (14 KB)
Attached To
Mode
D61669: virtual_oss: Retire the SBC cosine matrix generator
Attached
Detach File
Event Timeline