Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A side comment, instead of datestr(now(), 'yyyy'); I suggest currentYear = datestr(datetime('now'), 'yyyy');

And there's a unused code , please consider removing it

%% Plot to compare
        if 0
                f = linspace(0, fs/2, 1000);
                h1 = freqz(src.coefs/src.L, 1, f, fs);
                h2 = freqz(bq0/sref/src.L, 1, f, fs);
                h3 = freqz(bi/sref/src.L, 1, f, fs);
                figure;
                plot(f, 20*log10(abs(h1)), f, 20*log10(abs(h2)), f, 20*log10(abs(h3)));
                grid on;
                fprintf('Original = %4.1f dB, optimized = %4.1f dB, delta = %4.1f dB\n', ...
                        sb1, sb2, sb1-sb2);
        end

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', ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused variables are there ppath in the function call, please consider ~

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