From 1ed65227188f85a93860d78f5edb473bbb0053b1 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 29 Nov 2022 17:49:49 +0200 Subject: [PATCH 1/7] Audio: SRC: Increase stage buffer size and change copy() run condition This patch increases the buffer between stage 1 and stage 2 by factor 1/8. It prevents a freeze that happens with conversion from 11025 to 8000 Hz. Also the SRC is let run if stage 1 can consume samples or stage 2 can produce samples. There is no need to prevent run if both can't happen. Signed-off-by: Seppo Ingalsuo --- src/audio/src/src.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/audio/src/src.c b/src/audio/src/src.c index fa18b9fb414e..cdbf3373fdbd 100644 --- a/src/audio/src/src.c +++ b/src/audio/src/src.c @@ -196,6 +196,7 @@ int src_buffer_lengths(struct src_param *a, int fs_in, int fs_out, int nch, * there is no equation known for minimum size. */ a->sbuf_length = 2 * nch * stage1->blk_out * r1; + a->sbuf_length += a->sbuf_length >> 3; } a->src_multich = a->fir_s1 + a->fir_s2 + a->out_s1 + a->out_s2; @@ -855,7 +856,7 @@ static int src_get_copy_limits(struct comp_data *cd, sp->blk_out = sp->stage1_times * s1->blk_out; } - if (sp->blk_in == 0 || sp->blk_out == 0) + if (sp->blk_in == 0 && sp->blk_out == 0) return -EIO; return 0; From 615356cca4a495fb02bd8bc4db05164524753270 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 1 Dec 2022 17:28:02 +0200 Subject: [PATCH 2/7] Audio: SRC: Fix generic C version overflow in 16 bit round This patch adds the missing saturation to rounding in function src_polyphase_stage_cir_s16(). The error was caught with "src_test(16, 16, [176400 192000], 8000)" where both conversions made an overflow in chirp test. Signed-off-by: Seppo Ingalsuo --- src/audio/src/src_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/src/src_generic.c b/src/audio/src/src_generic.c index 0c4f3b6ceb75..28de2215c892 100644 --- a/src/audio/src/src_generic.c +++ b/src/audio/src/src_generic.c @@ -408,7 +408,7 @@ void src_polyphase_stage_cir_s16(struct src_stage_prm *s) n_min = (m < n_min) ? m : n_min; m -= n_min; for (i = 0; i < n_min; i++) { - *y_wptr = Q_SHIFT_RND(*fir->out_rp, 31, 15); + *y_wptr = sat_int16(Q_SHIFT_RND(*fir->out_rp, 31, 15)); y_wptr++; fir->out_rp++; } From a69d941163bf5dfba0299be9122a84e628b275e0 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 29 Nov 2022 15:56:12 +0200 Subject: [PATCH 3/7] Tools: Test: Timeout src_test.m after 300k copy() iterations This prevents testbench run freeze from src_test.m. Function test_run_src() passes to testbench option -C that limits the number iterations to 300k that corresponds to 5 min of audio. Signed-off-by: Seppo Ingalsuo --- tools/test/audio/src_test.m | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/test/audio/src_test.m b/tools/test/audio/src_test.m index 96878909ea6d..85daadba3931 100644 --- a/tools/test/audio/src_test.m +++ b/tools/test/audio/src_test.m @@ -456,6 +456,7 @@ function test = test_run_src(test, t) test.fs_in = test.fs1; test.fs_out = test.fs2; +test.extra_opts = '-C 300000'; % Limit to 5 min max, assume 1 ms scheduling delete_check(1, test.fn_out); test = test_run(test); end From ea4322413b12497e78f8be29db7aa07d003cc752 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 29 Nov 2022 17:51:54 +0200 Subject: [PATCH 4/7] Tools: Test: Audio: Reduce testing verbosity in test measure scripts These prints are normally not useful and slow down test with a lot of scrolled text output. Signed-off-by: Seppo Ingalsuo --- tools/test/audio/std_utils/aap_test_measure.m | 6 +++++- tools/test/audio/std_utils/aip_test_measure.m | 6 +++++- tools/test/audio/std_utils/fr_test_measure.m | 6 +++++- tools/test/audio/std_utils/thdnf_test_measure.m | 5 ++++- tools/test/audio/test_utils/mix_sweep.m | 6 +++++- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tools/test/audio/std_utils/aap_test_measure.m b/tools/test/audio/std_utils/aap_test_measure.m index 9e171ac341e5..9da8a5bde031 100644 --- a/tools/test/audio/std_utils/aap_test_measure.m +++ b/tools/test/audio/std_utils/aap_test_measure.m @@ -7,6 +7,8 @@ %% Reference: AES17 6.6.6 Attenuation of alias products % http://www.aes.org/publications/standards/ +debug = 0; + %% Load output file [x, nx] = load_test_output(test); if nx == 0 @@ -21,7 +23,9 @@ win = hamming(nt_use); m0 = zeros(test.nf,1); for n=1:test.nf - fprintf('Measuring %.0f Hz ...\n', test.f(n)); + if debug + fprintf('Measuring %.0f Hz ...\n', test.f(n)); + end i1 = d+(n-1)*nt+nt_skip; i2 = i1+nt_use-1; m0(n) = level_dbfs(x(i1:i2).*win); diff --git a/tools/test/audio/std_utils/aip_test_measure.m b/tools/test/audio/std_utils/aip_test_measure.m index 11ab30830f83..e78d82535cd6 100644 --- a/tools/test/audio/std_utils/aip_test_measure.m +++ b/tools/test/audio/std_utils/aip_test_measure.m @@ -7,6 +7,8 @@ %% Reference: AES17 6.6.7 Attenuation of image products % http://www.aes.org/publications/standards/ +debug = 0; + %% Load output file [x, nx] = load_test_output(test); if nx == 0 @@ -25,7 +27,9 @@ b_lpf = stdlpf_get(test.fu, test.fs); % Get LPF coef b_hpf = stdhpf_get(test.fu, test.fs); % Get HPF coef for n=1:test.nf - fprintf('Measuring %.0f Hz ...\n', test.f(n)); + if debug + fprintf('Measuring %.0f Hz ...\n', test.f(n)); + end % Get notch coef for this frequency [b_notch, a_notch] = stdnotch_get(test.f(n), test.fs); i1 = d+(n-1)*nt+nt_skip; diff --git a/tools/test/audio/std_utils/fr_test_measure.m b/tools/test/audio/std_utils/fr_test_measure.m index 90d5207058df..2e2d1d478379 100644 --- a/tools/test/audio/std_utils/fr_test_measure.m +++ b/tools/test/audio/std_utils/fr_test_measure.m @@ -32,6 +32,8 @@ % Copyright(c) 2017 Intel Corporation. All rights reserved. % Author: Seppo Ingalsuo +debug = 0; + %% Check if upper and lower mask is defined if length(test.fr_mask_flo) || length(test.fr_mask_fhi) test.fr_lo = 0; @@ -74,7 +76,9 @@ win = hamming(nt_use); m0 = zeros(test.nf,1); for n=1:test.nf - fprintf('Measuring %.0f Hz ...\n', test.f(n)); + if debug + fprintf('Measuring %.0f Hz ...\n', test.f(n)); + end i1 = d+(n-1)*nt+nt_skip; i2 = i1+nt_use-1; m0(n) = level_dbfs(x(i1:i2,j).*win) -test.a_db; diff --git a/tools/test/audio/std_utils/thdnf_test_measure.m b/tools/test/audio/std_utils/thdnf_test_measure.m index a0bc35f1f856..1fb9076acfa8 100644 --- a/tools/test/audio/std_utils/thdnf_test_measure.m +++ b/tools/test/audio/std_utils/thdnf_test_measure.m @@ -4,6 +4,7 @@ % Copyright(c) 2017 Intel Corporation. All rights reserved. % Author: Seppo Ingalsuo +debug = 0; test.ph = []; test.fh = []; @@ -62,7 +63,9 @@ nn = 1; for m=1:test.na for n=1:test.nf - fprintf('Measuring %.0f Hz ...\n', test.f(n)); + if debug + fprintf('Measuring %.0f Hz ...\n', test.f(n)); + end i1 = d+(nn-1)*nt+nt_skip; i2 = i1+nt_use-1; nn = nn+1; diff --git a/tools/test/audio/test_utils/mix_sweep.m b/tools/test/audio/test_utils/mix_sweep.m index a171f99de008..9bda9e70290c 100644 --- a/tools/test/audio/test_utils/mix_sweep.m +++ b/tools/test/audio/test_utils/mix_sweep.m @@ -4,6 +4,8 @@ % Copyright(c) 2017 Intel Corporation. All rights reserved. % Author: Seppo Ingalsuo +debug = 0; + %% Adjust tone lengt to integer number of samples test.nt = round(test.tl*test.fs); % Make number of samples per tone test.tl = test.nt/test.fs; % an integer by adjusting tl. @@ -59,7 +61,9 @@ else a = test.a; end - fprintf('Mixing %.0f Hz %.1f dBFS sine ...\n', f, 20*log10(a)); + if debug + fprintf('Mixing %.0f Hz %.1f dBFS sine ...\n', f, 20*log10(a)); + end s = multitone(test.fs, f, a, test.tl); for ch=test.ch x(i1:i2, ch) = dither_and_quantize(s.*win, test.bits_in); From f1f95dc6052a6f874327342c912fe70e4abf98d1 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 29 Nov 2022 19:51:33 +0200 Subject: [PATCH 5/7] Tools: Test: Prevent in src_test.m unnecessary window open This speeds up src_test.m with no plot window opening for rate that is not supported in the conversions matrix. No output file returns failure -1. Signed-off-by: Seppo Ingalsuo --- tools/test/audio/src_test.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/test/audio/src_test.m b/tools/test/audio/src_test.m index 85daadba3931..24a0878193af 100644 --- a/tools/test/audio/src_test.m +++ b/tools/test/audio/src_test.m @@ -413,7 +413,9 @@ %% Analyze test.fs = t.fs2; test = chirp_test_analyze(test); -src_test_result_print(t, 'Chirp', 'chirpf'); +if test.fail >= 0 + src_test_result_print(t, 'Chirp', 'chirpf'); +end % Delete files unless e.g. debugging and need data to run delete_check(t.files_delete, test.fn_in); From f9cf6d7a61bebbdf1bdbffce07943bd29528d1fc Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 29 Nov 2022 19:56:05 +0200 Subject: [PATCH 6/7] Tools: Test: In src_test.m prevent error with empty plot handle Octave errors if plot handle is empty, Matlab doesn't. This can happen if frequency response test data read fails. In that case an empty plot window is stored as indication of error. Signed-off-by: Seppo Ingalsuo --- tools/test/audio/src_test.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/audio/src_test.m b/tools/test/audio/src_test.m index 24a0878193af..ceb19ee4af1c 100644 --- a/tools/test/audio/src_test.m +++ b/tools/test/audio/src_test.m @@ -465,7 +465,7 @@ function src_test_result_print(t, testverbose, testacronym, ph) tstr = sprintf('%s SRC %d, %d', testverbose, t.fs1, t.fs2); -if nargin > 3 +if nargin > 3 && ~isempty(ph) title(ph, tstr); else title(tstr); From b73f584edeff04b36ff251c77a5b18beb86244b2 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 30 Nov 2022 15:16:50 +0200 Subject: [PATCH 7/7] Tools: Test: In src_test.m do quick test without specify in/out rates If the rates are an empty vector [] the default rates are used. This allows test command "src_test(32, 32, [], [], 0, 0);" to do a quick test without plots with default 8 - 192 kHz in/out matrix. Signed-off-by: Seppo Ingalsuo --- tools/test/audio/src_test.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/test/audio/src_test.m b/tools/test/audio/src_test.m index ceb19ee4af1c..607fa846ca0d 100644 --- a/tools/test/audio/src_test.m +++ b/tools/test/audio/src_test.m @@ -7,8 +7,8 @@ % % bits_in - input word length % bits_out - output word length -% fs_in - vector of rates in -% fs_out - vector of rates out +% fs_in - vector of rates in, default 8 to 192 kHz +% fs_out - vector of rates out, default 8 to 192 kHz % full_test - set to 0 for chirp only, 1 for all, default 1 % show_plots - set to 1 to see plots, default 0 % @@ -27,6 +27,8 @@ mkdir_check('reports'); %% Defaults for call parameters +default_in = [ 8 11.025 12 16 18.9 22.050 24 32 37.8 44.1 48 50 64 88.2 96 176.4 192] * 1e3; +default_out = [ 8 11.025 12 16 22.05 24 32 44.1 48 50 64 88.2 96 176.4 192] * 1e3; if nargin < 1 bits_in = 32; end @@ -34,12 +36,10 @@ bits_out = 32; end if nargin < 3 - fs_in_list = [ 8 11.025 12 16 18.9 22.050 24 32 37.8 44.1 48 ... - 50 64 88.2 96 176.4 192] * 1e3; + fs_in_list = default_in; end if nargin < 4 - fs_out_list = [ 8 11.025 12 16 22.05 24 32 44.1 48 ... - 50 64 88.2 96 176.4 192] * 1e3; + fs_out_list = default_out; end if nargin < 5 full_test = 1; @@ -47,6 +47,12 @@ if nargin < 6 show_plots = 0; end +if isempty(fs_in_list) + fs_in_list = default_in; +end +if isempty(fs_out_list) + fs_out_list = default_out; +end %% Generic test pass/fail criteria % Note that AAP and AIP are relaxed a bit from THD+N due to inclusion