Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

Commit 5a207a5

Browse files
committed
添加CSI DSP支持,添加双精度浮点支持
1 parent 5443873 commit 5a207a5

18 files changed

Lines changed: 673 additions & 490 deletions

.clang-format

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright 2016 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
#
18+
# Below are some minor deviations from the default Google style to
19+
# accommodate for handling of the large legacy code base.
20+
#
21+
22+
BasedOnStyle: Google
23+
CommentPragmas: NOLINT:.*
24+
DerivePointerAlignment: false
25+
ColumnLimit: 100
26+
AllowShortFunctionsOnASingleLine: Empty
27+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
28+
BreakConstructorInitializers: BeforeColon
29+
AlignAfterOpenBracket: AlwaysBreak
30+
BinPackArguments: false
31+
BinPackParameters: false
32+
# 连续宏时,进行对齐
33+
AlignConsecutiveMacros: AcrossEmptyLinesAndComments

CMakeLists.txt

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,44 @@ cmake_minimum_required(VERSION 3.15)
22

33
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
44

5+
6+
option(Only_compile_decoder "Only compile decoder" ON)
7+
option(Used_CSI_DSP "Used CSI DSP" OFF)
8+
option(Used_double "Used double" OFF)
9+
510
include_directories(
611
./inc
712
)
8-
file(GLOB_RECURSE SRC_DIR_LIST_dec "./src/*.c")
13+
set(LDAC_SRC_DIC ./src)
914
add_library(
1015
ldac_dec_lib STATIC
11-
${SRC_DIR_LIST_dec}
16+
${LDAC_SRC_DIC}/ldacBT.c
17+
${LDAC_SRC_DIC}/ldaclib.c
1218
)
13-
option(Only_compile_decoder "Only compile decoder" ON)
19+
20+
if(Used_CSI_DSP)
21+
add_definitions(-DCONFIG_USED_CSI_DSP)
22+
endif()
23+
24+
if(Used_double)
25+
add_definitions(-DCONFIG_SCALAR_F64)
26+
endif()
27+
1428
if(NOT Only_compile_decoder)
1529
set(lib_enc_dic ../encode/libldac)#from aosp
1630

17-
set(libldac ${lib_enc_dic})
31+
32+
set(libldac_enc ${lib_enc_dic})
1833
include_directories(
19-
${libldac}/inc
34+
${libldac_enc}/inc
2035
)
2136

22-
set(enc_dic ${libldac}/src)
37+
set(enc_dic ${libldac_enc}/src)
2338

2439
add_library(
2540
ldac_enc_lib STATIC
26-
27-
${enc_dic}/bitalloc_ldac.c
28-
${enc_dic}/bitalloc_sub_ldac.c
29-
${enc_dic}/encode_ldac.c
3041
${enc_dic}/ldacBT.c
31-
${enc_dic}/ldacBT_api.c
32-
${enc_dic}/ldacBT_internal.c
3342
${enc_dic}/ldaclib.c
34-
${enc_dic}/ldaclib_api.c
35-
${enc_dic}/memory_ldac.c
36-
${enc_dic}/pack_ldac.c
37-
${enc_dic}/tables_ldac.c
38-
39-
${enc_dic}/mdct_ldac.c
40-
${enc_dic}/quant_ldac.c
41-
${enc_dic}/setpcm_ldac.c
42-
${enc_dic}/sigana_ldac.c
43-
${enc_dic}/tables_sigproc_ldac.c
4443
)
4544

4645

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ auto_test.c用于执行自动测试
55

66
ldac_enc_test.c 用于生成测试解码器所需的bin文件,执行3次会生成三个后缀分别为 _HQ.bin _SQ.bin _MQ.bin 的LDAC流文件
77
输入的wav文件要放在cmake生成目录的上级文件夹
8-
这个仓库没有包含编码库,缺失的函数请从aosp获取
8+
这个分支没有包含编码库,缺失的函数请从aosp获取或者使用all分支,all分支合并了编码器和解码器
99

1010
ldac_dec_test.c 用于测试解码器,执行3次会生成三个后缀分别为 _HQ.wav _SQ.wav _MQ.wav 的wav文件

auto_test.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ int main()
77

88
DIR *dir;
99
struct dirent *ent;
10-
10+
#if __WIN32
11+
unsigned __int64 t0 = *(
12+
unsigned __int64 *)(0x7FFE0000 + 0x8); // like QueryUnbiasedInterruptTime
13+
#endif
1114
if ((dir = opendir("../")) != NULL)
1215
{
1316
// 打开当前目录
@@ -66,6 +69,10 @@ int main()
6669
{
6770
perror("");
6871
}
69-
72+
#if __WIN32
73+
unsigned __int64 t = *(unsigned __int64 *)(0x7FFE0000 + 0x8) - t0;
74+
printf("used %lfs\n", ((double)t) / 10000000.0);
75+
#endif
76+
system("pause");
7077
return 0;
7178
}

ldac_dec_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ int main(int argc, char *argv[]) {
268268
npack += 1;
269269
}
270270
if (result != 0) {
271+
printf("%s\r\n",get_error_code_string(ldacBT_get_error_code(ldacBT_dec_handle)));
271272
printf("Error generated in the %dth stage of decoding\r\n", result);
272273
printf("error\r\n");
273274
}
@@ -276,8 +277,7 @@ int main(int argc, char *argv[]) {
276277
printf("used %lfs,%lfus per pack\n", ((double)t) / 10000000.0,
277278
((double)t / (double)npack) / 10.0);
278279
#endif
279-
printf("%s\r\n",
280-
get_error_code_string(ldacBT_get_error_code(ldacBT_dec_handle)));
280+
281281

282282
free(pStream);
283283
ldacBT_close_handle(ldacBT_dec_handle);

src/imdct_ldac.o.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ static void proc_imdct_core_ldac(SCALAR* p_y, SCALAR* p_x, int nlnn) {
44
int loop1, loop2;
55
int coef, index0, index1, offset;
66
const int nsmpl = npow2_ldac(nlnn);
7+
const int nsmpl_half = nsmpl >> 1;
78
const int* p_rp;
89
const SCALAR *p_w, *p_c, *p_s;
910
SCALAR a_work[LDAC_MAXLSU];
@@ -12,6 +13,7 @@ static void proc_imdct_core_ldac(SCALAR* p_y, SCALAR* p_x, int nlnn) {
1213

1314
i = nlnn - LDAC_1FSLNN;
1415
p_w = gaa_bwin_ldac[i];
16+
#if !(CONFIG_USED_CSI_DSP)
1517
p_c = gaa_wcos_ldac[i];
1618
p_s = gaa_wsin_ldac[i];
1719
p_rp = gaa_rev_perm_ldac[i];
@@ -68,24 +70,25 @@ static void proc_imdct_core_ldac(SCALAR* p_y, SCALAR* p_x, int nlnn) {
6870
index1 += 2 - nsmpl;
6971
}
7072
}
71-
const int nsmpl_half = nsmpl >> 1;
72-
if (nsmpl_half > 0) {
73-
i = 0;
74-
do {
75-
p_y[2 * i] = p_s[coef + i] * a_work[2 * i + 1] + p_c[coef + i] * a_work[2 * i];
76-
p_y[nsmpl - 2 * i - 1] = p_s[coef + i] * a_work[2 * i] - a_work[2 * i + 1] * p_c[coef + i];
77-
i++;
78-
} while (nsmpl_half != i);
79-
i = 0;
80-
do {
81-
p_x[i] = p_y[nsmpl_half + i] * p_w[i] - p_w[nsmpl - 1 - i] * p_x[nsmpl + i];
82-
p_x[nsmpl_half + i] = -p_w[nsmpl_half - 1 - i] * p_x[nsmpl + nsmpl_half + i] -
83-
p_y[nsmpl - 1 - i] * p_w[nsmpl_half + i];
84-
p_x[nsmpl + i] = p_y[nsmpl_half - 1 - i];
85-
p_x[nsmpl + nsmpl_half + i] = p_y[i];
86-
i++;
87-
} while (nsmpl_half != i);
88-
}
73+
74+
i = 0;
75+
do {
76+
p_y[2 * i] = p_s[coef + i] * a_work[2 * i + 1] + p_c[coef + i] * a_work[2 * i];
77+
p_y[nsmpl - 2 * i - 1] = p_s[coef + i] * a_work[2 * i] - a_work[2 * i + 1] * p_c[coef + i];
78+
i++;
79+
} while (nsmpl_half != i);
80+
#else
81+
csi_dct4_f32(&dct4f32, a_work, p_y);
82+
#endif
83+
i = 0;
84+
do {
85+
p_x[i] = p_y[nsmpl_half + i] * p_w[i] - p_w[nsmpl - 1 - i] * p_x[nsmpl + i];
86+
p_x[nsmpl_half + i] = -p_w[nsmpl_half - 1 - i] * p_x[nsmpl + nsmpl_half + i] -
87+
p_y[nsmpl - 1 - i] * p_w[nsmpl_half + i];
88+
p_x[nsmpl + i] = p_y[nsmpl_half - 1 - i];
89+
p_x[nsmpl + nsmpl_half + i] = p_y[i];
90+
i++;
91+
} while (nsmpl_half != i);
8992
}
9093

9194
DECLFUNC void proc_imdct_ldac(SFINFO* p_sfinfo, int nlnn) {

src/ldac.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,5 +259,4 @@ struct _hcdec_ldac {
259259
(((bs) & (0x1 << ((nbits)-1))) ? ((bs) | ((~0x0) << (nbits))) : bs)
260260

261261
#include "proto_ldac.h"
262-
#include "tables.h"
263262
#endif /* _LDAC_H */

src/ldacBT.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "ldacBT.h"
2+
3+
#include "ldacBT_internal.o.c"
4+
#include "ldacBT_api.o.c"
5+

src/ldacBT_api.o.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ LDACBT_API void ldacBT_free_handle(HANDLE_LDAC_BT hLdacBT) {
5555

5656
if (hLdacBT->hLDAC != NULL) {
5757
/* close ldaclib handle */
58-
if (hLdacBT->proc_mode == LDACBT_PROCMODE_ENCODE) {
58+
if (hLdacBT->proc_mode == LDACBT_PROCMODE_DECODE) {
5959
ldaclib_free_decode(hLdacBT->hLDAC);
6060
}
6161
/* free ldaclib handle */
@@ -85,7 +85,7 @@ LDACBT_API void ldacBT_close_handle(HANDLE_LDAC_BT hLdacBT) {
8585

8686
if (hLdacBT->hLDAC != NULL) {
8787
/* close ldaclib handle */
88-
if (hLdacBT->proc_mode == LDACBT_PROCMODE_ENCODE) {
88+
if (hLdacBT->proc_mode == LDACBT_PROCMODE_DECODE) {
8989
ldaclib_free_decode(hLdacBT->hLDAC);
9090
}
9191
/* clear error code */

src/ldacBT_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern "C" {
1313
#endif
1414

1515
/* Function declaration */
16-
#define DECLFUNC// static
16+
#define DECLFUNC static
1717

1818
/* Limit for alter EQMID process */
1919
#define LDACBT_LIMIT_ALTER_EQMID_PRIORITY LDACBT_EQMID_MQ

0 commit comments

Comments
 (0)