Optimise target gain computation in parametric binauralizer.
Description
The function getDirectPartGains
in the parametric binauralizer has been one of the most significant complexity contributors within. This is due to the function being called quite many times per frame as the gain coefficients are required for each frequency bin (60), each subframe (4), each direction (2), and coherence rendering (3). Thus, it can be called up to 60*4*2*3 = 1440
times for each frame (2dir 512 kbps MASA).
However, in many cases, the direction data (azi & ele) is provided on frequency bands which means that there is a lot of data duplication. Furthermore, real analysed data often may have neighbouring bands pointing to the same direction. Although the HRTF is frequency dependent, it is possible to reduce complexity a lot by employing cache approach to solving of 3rd order SHD response which is required for obtaining the gains.
Another optimization is also possible by including the azi & ele rotation function into the cached value. This is because new head orientation is provided for each subframe and is not frequency dependent, and thus it is possible to reuse the rotated azi & ele as long as the input azi & ele have not changed.
One more trivial optimization is to disable call to azi & ele rotation if head-tracking is not active. This seems to have been left into the code.
These optimisations are BE. In practice, there can be a minor complexity increase if the input azi & ele are always completely different due to storing to cache the new values. However, this is offset by having even one cache hit within one frame as the complexity decrease is so significant in that case.
Complexity analysis
- Zero RAM impact as cache is stored in stack and is not on the highest stack path (in practice, stores
6 * (2*int16 + 16*float)
) - Minor increase in renderer PROM (was something like +100 earlier but analysed version did not provide renderer PROM)
21a710dc
WMOPS compared against main at2dir MASA 512 kbps -> BIN (no head-track)
min max avg
ref 143.329 149.788 147.745
opt 129.852 133.336 131.296
diff -13.477 -16.452 -16.449
2dir MASA 512 kbps -> BIN (head-track)
min max avg
ref 145.550 152.007 149.965
opt 135.221 139.559 137.495
diff -10.329 -12.448 -12.470
MASA 48 kbps -> BIN (no head-track)
min max avg
ref 109.099 125.702 118.370
opt 100.760 114.290 107.060
diff -8.339 -11.412 -11.310
MASA 48 kbps -> BIN (head-track)
min max avg
ref 111.319 127.921 120.589
opt 103.217 116.907 109.648
diff -8.102 -11.014 -10.941
MC 7.1+4 96 kbps -> BIN (no head-track)
min max avg
ref 132.409 165.895 150.045
opt 124.582 150.386 137.842
diff -7.827 -15.509 -12.203
MC 7.1+4 96 kbps -> BIN (head-track)
min max avg
ref 134.629 168.115 152.264
opt 126.956 152.955 140.354
diff -7.673 -15.160 -11.910
HOA3 80 kbps -> BIN (no head-track)
min max avg
ref 124.859 165.918 132.328
opt 121.713 163.541 131.325
diff -3.146 -2.377 -1.003
HOA3 80 kbps -> BIN (head-track)
min max avg
ref 127.365 168.137 134.862
opt 124.966 166.609 135.400
diff -2.399 -1.528 +0.538
ParamISM 4 obj 32 kbps -> BIN (no head-track)
min max avg
ref 90.441 122.542 109.355
opt 82.855 114.522 101.960
diff -7.586 -8.020 -7.395
ParamISM 4 obj 32 kbps -> BIN (head-track)
min max avg
ref 92.638 124.752 111.573
opt 85.278 116.789 104.550
diff -7.360 -7.963 -7.023