Skip to content

Commit

Permalink
Tools: Tune: SRC: Update generator to produce similar as edited
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
singalsu authored and lgirdwood committed Feb 23, 2024
1 parent 97a50e3 commit a9a05e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
5 changes: 2 additions & 3 deletions tools/tune/src/src_export_coef.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
fprintf(fh, ' */\n');
fprintf(fh, '\n');
fprintf(fh, '/** \\cond GENERATED_BY_TOOLS_TUNE_SRC */\n');
fprintf(fh, '#include <sof/audio/src/src.h>\n');
fprintf(fh, '#include <stdint.h>\n');
fprintf(fh, '\n');

Expand All @@ -77,14 +76,14 @@
fprintf(fh, '\n');
switch ctype
case 'float'
fprintf(fh, 'struct src_stage %s = {\n', sfn);
fprintf(fh, 'const struct src_stage %s = {\n', sfn);
fprintf(fh, '\t%d, %d, %d, %d, %d, %d, %d, %d, %f,\n\t%s};\n', ...
src.idm, src.odm, src.num_of_subfilters, ...
src.subfilter_length, src.filter_length, ...
src.blk_in, src.blk_out, src.halfband, ...
src.gain, vfn);
case { 'int16' 'int24' 'int32' }
fprintf(fh, 'struct src_stage %s = {\n', sfn);
fprintf(fh, 'const struct src_stage %s = {\n', sfn);
fprintf(fh, '\t%d, %d, %d, %d, %d, %d, %d, %d, %d,\n\t%s};\n', ...
src.idm, src.odm, src.num_of_subfilters, ...
src.subfilter_length, src.filter_length, ...
Expand Down
35 changes: 17 additions & 18 deletions tools/tune/src/src_export_table_2s.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,45 +82,44 @@
um_tmp = unique_modes(i,:);
if isequal(um_tmp(1:2),[1 1]) || isequal(um_tmp(1:2),[0 0])
else
fprintf(fh, '#include <%ssrc_%s_%d_%d_%d_%d.h>\n', ...
ppath, prof_ctype, um_tmp(1:4));
fprintf(fh, '#include \"src_%s_%d_%d_%d_%d.h\"\n', ...
prof_ctype, um_tmp(1:4));

n = all_modes(ia(i), 5);
a = all_modes(ia(i), 6);
b = all_modes(ia(i), 7);
sfl = sfl +taps_2s(n, a, b); % Count sum of filter lengths
end
end
fprintf(fh, '#include <sof/audio/src/src.h>\n');
fprintf(fh, '#include <stdint.h>\n');
fprintf(fh,'\n');

fprintf(fh, '/* SRC table */\n');
switch ctype
case 'float'
fprintf(fh, '%s fir_one = 1.0;\n', vtype);
fprintf(fh, 'struct src_stage src_double_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, 1.0, &fir_one };\n');
fprintf(fh, 'struct src_stage src_double_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0.0, &fir_one };\n');
fprintf(fh, 'const %s fir_one = 1.0;\n', vtype);
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');
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');
case 'int16'
scale16 = 2^15;
fprintf(fh, '%s fir_one = %d;\n', vtype, round(scale16*0.5));
fprintf(fh, 'struct src_stage src_int16_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
fprintf(fh, 'struct src_stage src_int16_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
fprintf(fh, 'const %s fir_one = %d;\n', vtype, round(scale16*0.5));
fprintf(fh, 'const struct src_stage src_int16_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
fprintf(fh, 'const struct src_stage src_int16_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
case 'int24'
scale24 = 2^23;
fprintf(fh, '%s fir_one = %d;\n', vtype, round(scale24*0.5));
fprintf(fh, 'struct src_stage src_int24_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
fprintf(fh, 'struct src_stage src_int24_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
fprintf(fh, 'const %s fir_one = %d;\n', vtype, round(scale24*0.5));
fprintf(fh, 'const struct src_stage src_int24_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
fprintf(fh, 'const struct src_stage src_int24_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
case 'int32'
scale32 = 2^31;
fprintf(fh, '%s fir_one = %d;\n', vtype, round(scale32*0.5));
fprintf(fh, 'struct src_stage src_int32_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
fprintf(fh, 'struct src_stage src_int32_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
fprintf(fh, 'const %s fir_one = %d;\n', vtype, round(scale32*0.5));
fprintf(fh, 'const struct src_stage src_int32_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n');
fprintf(fh, 'const struct src_stage src_int32_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n');
otherwise
error('Unknown coefficient type!');
end

fprintf(fh, 'int src_in_fs[%d] = {', n_in);
fprintf(fh, 'const int src_in_fs[%d] = {', n_in);
j = 1;
for i=1:n_in
fprintf(fh, ' %d', fs_in(i));
Expand All @@ -135,7 +134,7 @@
end
fprintf(fh, '};\n');

fprintf(fh, 'int src_out_fs[%d] = {', n_out);
fprintf(fh, 'const int src_out_fs[%d] = {', n_out);
j = 1;
for i=1:n_out
fprintf(fh, ' %d', fs_out(i));
Expand All @@ -151,7 +150,7 @@
fprintf(fh, '};\n');

for n = 1:2
fprintf(fh, 'struct src_stage *src_table%d[%d][%d] = {\n', ...
fprintf(fh, 'const struct src_stage * const src_table%d[%d][%d] = {\n', ...
n, n_out, n_in);
i = 1;
for b = 1:n_out
Expand Down

0 comments on commit a9a05e2

Please sign in to comment.