Skip to content
This repository was archived by the owner on Jan 17, 2019. It is now read-only.

Commit c43666d

Browse files
committed
EQ FIR: Add check and removal for trailing zeros in filter coefficients
This patch adds removing of extra zeros in the FIR coefficients. The zeros can happen in some responses due to fixed point quantization of very small values. The zero taps consume DSP resources for nothing so better to clean them out for EQ configuration data. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent d77beaf commit c43666d

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

tune/eq/eq_fir_blob_quant.m

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,31 @@
4444
bits = 16;
4545
end
4646

47+
%% Quantize
4748
[bq, shift] = eq_fir_quantize(b, bits);
4849

49-
nb = length(bq);
50+
%% Check trailing zeros
51+
nf = length(bq);
52+
nz = nf;
53+
while bq(nz) == 0
54+
nz = nz - 1;
55+
end
56+
if nz < nf
57+
nb = nz + 1;
58+
fprintf(1,'Note: Filter length was reduced to %d -> %d due to trailing zeros.\n', ...
59+
nf, nb);
60+
bq = bq(1:nb);
61+
else
62+
nb = nf;
63+
end
64+
65+
%% Make length multiple of four (optimized FIR core)
5066
mod4 = mod(nb, 4);
5167
if mod4 > 0
5268
pad = zeros(1,4-mod4);
5369
bqp = [bq pad];
5470
nnew = length(bqp);
55-
fprintf(1,'Note: Filter length was %d, padded length into %d,\n', nb, nnew);
71+
fprintf(1,'Note: Filter length was %d, padded length into %d.\n', nb, nnew);
5672
else
5773
nnew = nb;
5874
bqp = bq;

0 commit comments

Comments
 (0)