Skip to content

Commit baef046

Browse files
committed
Tools: Tune: SRC: Update generator to produce similar as edited
This patch makes to SRC coefficients tables generator same changes as done in recent git commits. commit 88fdb10 ("audio: src: rename sample rate converter coefficient folder name") moved coefficients files location to src/audio/src/coefs. commit 90fef5a ("src_lite: add module") removed include of src.h from upper level due to another src-lite version. 'commit 7f4e6ae ("src: make coefficients constant") added const to struct src_stage. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent e04289d commit baef046

2 files changed

Lines changed: 19 additions & 21 deletions

File tree

tools/tune/src/src_export_coef.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
fprintf(fh, ' */\n');
5151
fprintf(fh, '\n');
5252
fprintf(fh, '/** \\cond GENERATED_BY_TOOLS_TUNE_SRC */\n');
53-
fprintf(fh, '#include <sof/audio/src/src.h>\n');
5453
fprintf(fh, '#include <stdint.h>\n');
5554
fprintf(fh, '\n');
5655

@@ -77,14 +76,14 @@
7776
fprintf(fh, '\n');
7877
switch ctype
7978
case 'float'
80-
fprintf(fh, 'struct src_stage %s = {\n', sfn);
79+
fprintf(fh, 'const struct src_stage %s = {\n', sfn);
8180
fprintf(fh, '\t%d, %d, %d, %d, %d, %d, %d, %d, %f,\n\t%s};\n', ...
8281
src.idm, src.odm, src.num_of_subfilters, ...
8382
src.subfilter_length, src.filter_length, ...
8483
src.blk_in, src.blk_out, src.halfband, ...
8584
src.gain, vfn);
8685
case { 'int16' 'int24' 'int32' }
87-
fprintf(fh, 'struct src_stage %s = {\n', sfn);
86+
fprintf(fh, 'const struct src_stage %s = {\n', sfn);
8887
fprintf(fh, '\t%d, %d, %d, %d, %d, %d, %d, %d, %d,\n\t%s};\n', ...
8988
src.idm, src.odm, src.num_of_subfilters, ...
9089
src.subfilter_length, src.filter_length, ...

tools/tune/src/src_export_table_2s.m

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,45 +82,44 @@
8282
um_tmp = unique_modes(i,:);
8383
if isequal(um_tmp(1:2),[1 1]) || isequal(um_tmp(1:2),[0 0])
8484
else
85-
fprintf(fh, '#include <%ssrc_%s_%d_%d_%d_%d.h>\n', ...
86-
ppath, prof_ctype, um_tmp(1:4));
85+
fprintf(fh, '#include \"src_%s_%d_%d_%d_%d.h\"\n', ...
86+
prof_ctype, um_tmp(1:4));
8787

8888
n = all_modes(ia(i), 5);
8989
a = all_modes(ia(i), 6);
9090
b = all_modes(ia(i), 7);
9191
sfl = sfl +taps_2s(n, a, b); % Count sum of filter lengths
9292
end
9393
end
94-
fprintf(fh, '#include <sof/audio/src/src.h>\n');
9594
fprintf(fh, '#include <stdint.h>\n');
9695
fprintf(fh,'\n');
9796

9897
fprintf(fh, '/* SRC table */\n');
9998
switch ctype
10099
case 'float'
101-
fprintf(fh, '%s fir_one = 1.0;\n', vtype);
102-
fprintf(fh, 'struct src_stage src_double_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, 1.0, &fir_one };\n');
103-
fprintf(fh, 'struct src_stage src_double_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0.0, &fir_one };\n');
100+
fprintf(fh, 'const %s fir_one = 1.0;\n', vtype);
101+
fprintf(fh, 'const struct src_stage src_double_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, 1.0, &fir_one };\n');
102+
fprintf(fh, 'const struct src_stage src_double_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0.0, &fir_one };\n');
104103
case 'int16'
105104
scale16 = 2^15;
106-
fprintf(fh, '%s fir_one = %d;\n', vtype, round(scale16*0.5));
107-
fprintf(fh, 'struct src_stage src_int16_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
108-
fprintf(fh, 'struct src_stage src_int16_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
105+
fprintf(fh, 'const %s fir_one = %d;\n', vtype, round(scale16*0.5));
106+
fprintf(fh, 'const struct src_stage src_int16_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
107+
fprintf(fh, 'const struct src_stage src_int16_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
109108
case 'int24'
110109
scale24 = 2^23;
111-
fprintf(fh, '%s fir_one = %d;\n', vtype, round(scale24*0.5));
112-
fprintf(fh, 'struct src_stage src_int24_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
113-
fprintf(fh, 'struct src_stage src_int24_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
110+
fprintf(fh, 'const %s fir_one = %d;\n', vtype, round(scale24*0.5));
111+
fprintf(fh, 'const struct src_stage src_int24_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
112+
fprintf(fh, 'const struct src_stage src_int24_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
114113
case 'int32'
115114
scale32 = 2^31;
116-
fprintf(fh, '%s fir_one = %d;\n', vtype, round(scale32*0.5));
117-
fprintf(fh, 'struct src_stage src_int32_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
118-
fprintf(fh, 'struct src_stage src_int32_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
115+
fprintf(fh, 'const %s fir_one = %d;\n', vtype, round(scale32*0.5));
116+
fprintf(fh, 'const struct src_stage src_int32_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
117+
fprintf(fh, 'const struct src_stage src_int32_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
119118
otherwise
120119
error('Unknown coefficient type!');
121120
end
122121

123-
fprintf(fh, 'int src_in_fs[%d] = {', n_in);
122+
fprintf(fh, 'const int src_in_fs[%d] = {', n_in);
124123
j = 1;
125124
for i=1:n_in
126125
fprintf(fh, ' %d', fs_in(i));
@@ -135,7 +134,7 @@
135134
end
136135
fprintf(fh, '};\n');
137136

138-
fprintf(fh, 'int src_out_fs[%d] = {', n_out);
137+
fprintf(fh, 'const int src_out_fs[%d] = {', n_out);
139138
j = 1;
140139
for i=1:n_out
141140
fprintf(fh, ' %d', fs_out(i));
@@ -151,7 +150,7 @@
151150
fprintf(fh, '};\n');
152151

153152
for n = 1:2
154-
fprintf(fh, 'struct src_stage *src_table%d[%d][%d] = {\n', ...
153+
fprintf(fh, 'const struct src_stage *src_table%d[%d][%d] = {\n', ...
155154
n, n_out, n_in);
156155
i = 1;
157156
for b = 1:n_out

0 commit comments

Comments
 (0)