Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
db0e306
Added rms_flag to disable gating under define BS1770DEMO_UPDATE
ErikNorvell-Ericsson May 2, 2023
3c295d4
Added output of scaling factor in dB
ErikNorvell-Ericsson May 4, 2023
6e94fc7
Add check for all blocks below ABSOLUTE_THRESHOLD
ErikNorvell-Ericsson May 4, 2023
5bb6dc4
Added test case for bs1770 demo rms option
ErikNorvell-Ericsson May 5, 2023
5ca49ac
Corrected tolerance level for bs1770demo rms test
ErikNorvell-Ericsson May 5, 2023
b5a3a1c
Added bs1770demo -rms option to manual
ErikNorvell-Ericsson May 5, 2023
bb40db3
Remove define BS1770DEMO_UPDATE
ErikNorvell-Ericsson May 5, 2023
4870d53
remove push_indice(), set_indice(), get_indice(), exist_indice(), res…
Sep 13, 2023
28f198a
fix the arguments of the itos() function
Sep 13, 2023
46161a5
fix the declaration of the itos() function
Sep 13, 2023
e60b8e2
- fix NaN printed in the complexity printout for a non-instrumented f…
Sep 13, 2023
6fff996
update the reference files wmc_auto.h and wmc_auto.c used in ctest
Sep 13, 2023
791d011
fix crash when no #include is present in the .c file
Sep 13, 2023
58c7226
update version to 1.5 and year to 2023
Sep 13, 2023
a6c80ed
introduce -f fps command-line option for setting the FRAMES_PER_SECON…
Sep 14, 2023
31acbb7
prevent calling twice push_wmops() when WMOPS_DETAILS is activated
Sep 14, 2023
c1d79a5
raise error if matching #undef WMC_TOOL_SKIP cannot be found
Sep 15, 2023
7851f8d
Python script for graphical analysis of the memory allocation tree ba…
Sep 15, 2023
dc6fdd8
replace printf() with fprintf() for better portability
Sep 15, 2023
51007bc
fix an EOL problem whjen replacing #define FRAMES_PER_SECOND
Sep 19, 2023
367cf4b
introduce dynamic allocation of internal WMOPS buffers and lists (rep…
Sep 19, 2023
cd23bfd
support for counting BASOP complexity
Sep 27, 2023
5bab9d2
new reference files wmc_auto.[c|h] for ctest
Sep 27, 2023
2c55841
unifiy macros and functions under WMOPS_FUNCTS_STRING
Sep 27, 2023
64e18f2
count PROM size of BASOP functions and operators
Oct 2, 2023
55316d1
small correction in the help printout
Oct 3, 2023
dae4383
fix warning about incorrect function declaration (missing void keyword)
Oct 3, 2023
bdbad60
fix incorrect reading of PROM size from .c files containing digits in…
Oct 3, 2023
d9f7d92
do not count PROM in skipped regions
Oct 3, 2023
4c842d4
update ctest files
Oct 3, 2023
48ddd41
print error message if #undef WMC_TOOL_SKIP is not found
Oct 3, 2023
b38ea9a
make sure that PROM size is calculated and inserted in .c files where…
Oct 3, 2023
bbd83a2
update PROM size in ctest vectors
Oct 3, 2023
1c85faf
add missing instrumentation in L40_mac()
Oct 24, 2023
a8d53ec
Update README.md with MAC OS compile instructions
Oct 24, 2023
64eec73
change default unit ion memory reports from 32b words to bytes
Nov 9, 2023
a79fea4
Merge branch 'dev' of github.com:malenov/STL into dev
Nov 9, 2023
135b113
create changelog file
Nov 9, 2023
69f2975
formatting in HISTORY.md
Nov 9, 2023
4577fe6
add inv_sqrtf() to the list of intrinsic math functions
Feb 12, 2024
5b3c4aa
update the manual
Feb 26, 2024
7155574
Typos in wmc_tool.tex
ludomal Mar 12, 2024
03069bd
Typos in README.md
ludomal Mar 12, 2024
08e8949
recognize "f" float variants of intrinsic mathematical functions (sin…
Mar 13, 2024
7720fc1
add Python requirements file
Mar 13, 2024
e5ab397
update helper files
Mar 13, 2024
ab4c8b7
add support for frexp() and frexpf() functions at the cost of MISC(2)
Mar 14, 2024
85add92
include the variants of log2() and round() functions
Mar 19, 2024
4d1a93c
Update wmc_tool.tex
Mar 19, 2024
9bf3543
update the WMC tool manual with additional info on how to format the …
Mar 20, 2024
6a747a7
Merge branch 'dev' of github.com:malenov/STL into dev
Mar 20, 2024
eb0917d
fix error when des-instrumenting one-line functions
Mar 20, 2024
4076d9b
fix the limitation of max string literals to 65535 with MSVC 2017 and…
Mar 20, 2024
6e21fc2
Merge branch 'pr/174' into itu_submission_april_2024
ludomal Mar 22, 2024
9020949
Manual and recommendation updates for STL2024
ludomal Apr 16, 2024
ac339cc
Minor update
ludomal Apr 16, 2024
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
Binary file added doc/draft_g191.docx
Binary file not shown.
24 changes: 19 additions & 5 deletions doc/g191.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,31 @@ Please refer to the official Recommendation ITU-T G.191 for the complete text: [

Recommendation ITU-T G.191 provides source code for speech and audio processing modules for narrowband, wideband and super-wideband telephony applications. The set includes codecs, filters, noise generators.

This edition introduces changes to Annex A, which describes the ITU-T Software Tools (STL) containing a high-quality, portable C code library for speech processing applications. This release of the STL, also known as STL2023, incorporates:
This edition introduces changes to Annex A, which describes the ITU-T Software Tools (STL) containing a high-quality, portable C code library for speech processing applications. This release of the STL, also known as STL2024, incorporates:

* An implementation of P.50 fullband MNRU as described in ITU-T P.810.
* BS1770demo improvements:

* A tool for automatic instrumentation of speech and audio codecs to measure their computational complexity and memory.
- a new RMS option disabling the gating function for background noise measurement,

Recommendation ITU-T G.191 includes an electronic attachment containing STL2023 and manual.
- the handling of the edge case where all gating blacks are below -70 LKFS,

- improved reporting with scaling factor being reported in the linear and log domains.

* WMC Tool updates:

- New command line parameter to allow control on the number of frames per second (default still 50)

- Export information on all memory allocations occurring during runtime

- Example script for graphical analysis and profiling of dymanic memory allocation

- Bugs fixes and code improvements

Recommendation ITU-T G.191 includes an electronic attachment containing STL2024 and manual.

## Keywords

DSP operators, filters, MNRU, P.50 FB MNRU, open source, reverb, STL2022, G.711, G.722, G.726, G.728, sv56, BS.1770, ESDRU, WMC Tool
DSP operators, filters, MNRU, P.50 FB MNRU, open source, reverb, G.711, G.722, G.726, G.728, sv56, BS.1770, ESDRU, WMC Tool

## 1. Scope

Expand Down
6 changes: 3 additions & 3 deletions doc/manual/STLmanual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
\addtolength{\itemsep}{-20pt}

% Define headers
\def\ugst_title{ ITU-T Software Tool Library, release 2023}
\def\ugst_title{ ITU-T Software Tool Library, release 2024}
\def\us{$\mu$s}
\markboth{ \hspace{1cm} \hfill \ugst_title }%
{ Version: \today \hfill \hspace{1cm} }
Expand Down Expand Up @@ -61,7 +61,7 @@
\pagenumbering{roman}

%==============================================================================
\title{ITU-T Software Tool Library 2023 User's Manual}
\title{ITU-T Software Tool Library 2024 User's Manual}
\author{ITU-T Users' Group on Software Tools}

%------------------------------------------------------------------------------
Expand All @@ -71,7 +71,7 @@

\ruley{100mm}

Copyright \copyright~ 2005, 2006, 2009, 2019, 2022 and 2023 by the International
Copyright \copyright~ 2005, 2006, 2009, 2019, 2022, 2023 and 2024 by the International
Telecommunication Union (ITU)

\ruley{15mm}
Expand Down
7 changes: 7 additions & 0 deletions doc/manual/bs1770demo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,18 @@ \section{Description of the Algorithm}
\texttt{fabs( 1.0 - fac / last\_fac ) \textless RELATIVE\_DIFF}, where \texttt{RELATIVE\_DIFF = 0.0001} or when the maximum number of iterations \texttt{MAX\_ITERATIONS = 10}
has been reached.

When measuring the loudness of signals with a large dynamic range, it may be desirable to disable the gating function
to obtain the level considering the full signal. This is useful e.g. for noise level adjustment in listening tests
including added background noise. For this reason, the gating function may be disabled using an RMS (Root-Mean-Square)
energy measurement option \texttt{-rms}. Note that this feature is not part of \cite{BS1770}.

{\tt\small
\begin{verbatim}
double find_scaling_factor( /* o: scaling factor */
const double *gating_block_energy, /* i: gating_block_energy */
const long n_gating_blocks, /* i: Number of gating blocks */
const double lev, /* i: Target level */
const short rms_flag, /* i: Flag for RMS (no gating) */
double *lev_input, /* o: Input level */
double *lev_obtained /* o: Obtained level */
)
Expand Down Expand Up @@ -158,6 +164,7 @@ \section{Usage of bs1770demo}
Options:
-nchan N Number of channels [1..24] (Default: 1)
-lev L Target level LKFS (Default: -26)
-rms Disable gating (for background noise level measurement)
-conf xxxx Configuration string:
'1' ldspk pos within |elev| < 30 deg, 60 deg <= |azim| <= 120 deg
'L' LFE channel (weight zero)
Expand Down
6 changes: 6 additions & 0 deletions doc/manual/intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ \chapter{Introduction}

In 2023, STL release incorporates an implementation of P.50 fullband MNRU as described in ITU-T Rec. P.810, as well as WMC tool, a tool for automatic instrumentation of speech and audio codecs to measure their computational complexity and memory.

In 2024, the revision of the STL offers additional features and bug fixes to the BS.1770 demo and WMC tool.

Since STL2019, the build toolchain uses CMake to generate platform-dependent and tool-dependent build scripts as well as to execute regression tests for each module in the STL.
Modules have been tested on Windows, MacOS and several Linux flavors.

Expand Down Expand Up @@ -191,6 +193,8 @@ \section{Acknowledgements}

For the STL2023, the implementation of the P.50 Fullband MNRU was kindly provided by Mrs Anna Llagostera and Mr Jens Berger from SwissQual AG/Rohde \& Schwarz, with a contribution from NTT on filter routines, the integration into the existing MNRU code and documentation from Ludovic Malfait, and the DC filter and amplitude clipping improvement suggestions from Anssi Ramo (Nokia). The implementation of the WMC tool was kindly provided by Mr Guy Richard and Mr Vladimir Malenovsky from VoiceAge Corporation.

For the STL2024, the improvements to BS.1770 demo and WMC Tool were kindly provided by Mr Erik Norvell from Ericsson and Mr Vladimir Malenovsky from VoiceAge Corporation respectively.

Above all, special thank goes to ITU-T SG16 Counselor Mr~Sim\~ao Ferraz de Campos Neto, the ``father'' of the STL.

%=============================================================================
Expand Down Expand Up @@ -230,6 +234,8 @@ \chapter{Tutorial}
\item[STL2009] ITU-T Software Tools Library, release 2009.
\item[STL2019] ITU-T Software Tools Library, release 2019.
\item[STL2022] ITU-T Software Tools Library, release 2022.
\item[STL2023] ITU-T Software Tools Library, release 2023.
\item[STL2024] ITU-T Software Tools Library, release 2024.
\item[UGST] Users' Group on Software Tools, of ITU-T Study Group 16.
\end{Descr}

Expand Down
65 changes: 58 additions & 7 deletions doc/manual/wmc_tool.tex
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ \subsection{Usage}
note: filename shall point to a .c file containing the print_mem() function
-b [--no-backup]: no backup of original files
-c dirname [--generate-wmc-files dirname]: copy wmc_auto.h and wmc_auto.c to a user-specified directory
-f value [--frames-per-second value]: set the number of frames per second (default 50.0)
\end{Verbatim}

The optional command-line parameters may be used to control either the instrumentation or the couting process. With the \verb|-i| optional argument the WMC tool prints the list of functions that are instrumented. It doesn't run the WMC tool. The parameter \verb|-d| runs the des-instrumentation phase only. The des-instrumentation phase removes all meta-information that has been previously added to the source code with the WMC tool. When \verb|-m| argument is provided the WMC tool adds code calculating ROM and RAM memory consumption and fills the \verb|print_mem()| function to print the statistics about memory usage. When \verb|-m| is provided the user needs to specify the name of the \verb|.c| file containing the \verb|print_mem()| function. The parameter \verb|-b| instructs the WMC tool not to create backup copies of the instrumented \verb|.c| files. The parameter \verb|-c| copies the control files \verb|wmc_auto.h| and \verb|wmc_auto.c| to a user-specified directory. The control files must be added to the project for calculating the complexity and memory consumption of all instrumented source files. The \verb|-f| parameter allows the users to override the default values for the number of frames per second. This value is important for the correct calculation of complexity in "WMOPS".

\subsection{Instrumentation process}
\label{ch:instrumentation_process}

Expand Down Expand Up @@ -107,7 +110,9 @@ \subsubsection{Warnings}
\section{Instrumentation of complexity}
\label{ch:instrumentation_of_complexity}

The WMC tool only instruments functions but not macros. System functions and functions with names that are considered as basic operations are skipped. The instrumentation mechanism has been designed to be as least intrusive as possible. The instrumentation code is inserted at the beginning of each instrumented line in the source code with a single macro that has the following form \verb|$("ops")| where \verb|ops| is a string of letters and symbols indicating individual operations. The WMC tool parses each source file and calculates the length of each instrumentation string. The maximum length is then used to indent the entire source file to make space for the instrumentation strings. This is shown in the example below.
The instrumentation mechanism has been designed to minimize intrusiveness. It skips system functions and functions labeled as basic operations. When instrumenting \verb|.c| source files, the WMC tool omits macros by default. However, it detects macros defined within the same \verb|.c| source file using the \verb|#define| pragma. Macros defined in external header files and included using \verb|#include| pragma cannot be directly detected. To address this, the instrumentation mechanism employs a heuristic: if a string contains more than 70\% capital letters, it's treated as a macro and skipped during instrumentation.

The instrumentation code is integrated at the start of every instrumented line in the source code using a singular macro format: \verb|$("ops")|, where \verb|ops| represents a string encompassing individual operations denoted by letters and symbols. Upon parsing each source file, the WMC tool computes the length of each instrumentation string. Subsequently, the maximum length determines the indentation of the entire source file to accommodate the instrumentation strings, as illustrated in the example below.

\begin{Verbatim}[fontsize=\small]
float calc_shift_value( const float totalStep )
Expand All @@ -125,13 +130,13 @@ \section{Instrumentation of complexity}
}
\end{Verbatim}

It is always possible to remove the instrumentation from the source code with the \verb|-d| command line option. In many cases, the source file will then return to its original non-instrumented state except for whitespace characters and text alignment. The un-instrumentation process is also invoked automatically by the WMC tool as the first step in the instrumentation process. This ensures that the results are identical even when the process is repeated multiple times. This allows the users to make modifications to an already instrumented source code by simply re-instrumenting it again. Note, that the un-instrumentation process does not remove the functions \verb|push_wmops()| and \verb|pop_wmops()| and the system functions. Lines that are preceded by
The removal of instrumentation from the source code can be achieved using the \verb|-d| command line option. In many instances, executing this option restores the source file to its original non-instrumented state, with the exception of whitespace characters and text alignment. The un-instrumentation process is automatically triggered by the WMC tool as the initial step in the instrumentation procedure. This ensures consistent results even with repeated executions. Consequently, users can modify previously instrumented source code by simply re-instrumenting it. It's important to note that the un-instrumentation process does not eliminate the \verb|push_wmops()| and \verb|pop_wmops()| functions, nor does it remove system functions. Lines preceded by

{
{\em /*AddedByWMC\_Tool*/}
}

are removed completely. At the end of the un-instrumentation process, the original indentation is restored.
are removed completely. At the end of the un-instrumentation process the original indentation is restored.

If, for any reason, it is necessary to avoid the automatic instrumentation and un-instrumentation of certain parts in the source code, the user may encapsulate such parts in \verb|#define WMC_TOOL_SKIP| \ldots \verb|#undef WMC_TOOL_SKIP| macro pairs. For example

Expand Down Expand Up @@ -224,18 +229,21 @@ \subsection{Mathematic functions}
\verb|sign()| & 1 \\
\verb|round()| & 0 (not supported by the WMC tool) \\
\verb|sqrt()| and \verb|inv_sqrt()| & 10 \\
\verb|log()|, \verb|log2()| and thier derivatives & 25 \\
\verb|log()|, \verb|log2()| and other logarithmic functions & 25 \\
\verb|exp()| and \verb|pow()| & 25 \\
\verb|sin()|, \verb|cos()| and all other trigonometric functions & 25 \\
\verb|frexp()| & 2 \\
\verb|fmod()| & 18 \\
\hline
\end{tabular}
\label{tab:cost_of_math_functions}
\end{table}


%-----------------------------------------------------------------------------
\subsection{User-defined functions}

All user-defined functions in the source code are instrumented with one or more underscore '\verb|_|' symbols appended to their names. The WMC tool will count the number of arguments from the function call and insert a wrapper macro at the top of the source file, after the first \verb|#include| section. See the example below.
All user-defined functions in the source code are instrumented with one or more underscore '\verb|_|' symbols appended to their names. The WMC tool counts the number of arguments in function calls and inserts a wrapper macro at the top of the source file, after the first \verb|#include| section. See the example below.

\begin{Verbatim}[fontsize=\small]
#include <stdlib.h>
Expand Down Expand Up @@ -266,6 +274,49 @@ \subsection{User-defined functions}

The WMC tool appends an additional underscore symbol '\verb|_|' in each variant of the user-defined function call. This means that if a function is defined to accept a variable number of arguments the first function call will have one underscore symbol '\verb|_|' appended to its name, the second function call will have two underscore symbols '\verb|__|' appended to its name and so on. The WMC tool supports up to 10 variants (different number of arguments) of the same function.

The WMC tool may encounter difficulties in properly instrumenting one-line functions that are defined as follows

\begin{Verbatim}[fontsize=\small]
float calculate_vector_norm( float vec[], int_16t size ) { return sum2_f(vec, size); }
\end{Verbatim}

It's advisable to define the function body on separate lines, like this

\begin{Verbatim}[fontsize=\small]
float calculate_vector_norm( float vec[], int_16t size )
{
return sum2_f(vec, size);
}
\end{Verbatim}

In a local function, all declared variables should be positioned at the start of the function body. Additionally, the initialization of local variables should be segregated from their declaration. For instance, consider the following code snippet, where the WMC tool inserts \verb|$("M")| before \verb|int ch = 0;|

\begin{Verbatim}[fontsize=\small]
int free_structs(MY_STRUCT_INFO *ptr_dec)
{
if (ptr_dec == NULL) return -1;

$("M") int ch = 0;

for (ch = 0; ch < n_channels; ch++)
{
struct_free(&decoder->cfg[ch]->fft_buf);
struct_free(&decoder->cfg[ch]->ifft_buf);
}

return 0;
}
\end{Verbatim}

Compiling the instrumented code provided above results in the following error (gcc):

\begin{Verbatim}[fontsize=\small]
lib_thj/struct_f.c:373:17: error: expected expression before ‘int’
125 | $("M") int ch = 0;
| ^~~
\end{Verbatim}


%-----------------------------------------------------------------------------
\subsection{Operators}

Expand Down Expand Up @@ -361,7 +412,7 @@ \subsection{Operators}
%-----------------------------------------------------------------------------
\subsection{Manual instrumentation}

It was already shown in the previous section in this document that it is possible to avoid the automatic instrumentation by encapsulating parts of the source code with
As demonstrated in the preceding section of this document, it's possible to bypass automatic instrumentation by encapsulating sections of the source code with

\begin{Verbatim}[fontsize=\small]
#define WMC_TOOL_SKIP
Expand Down Expand Up @@ -435,7 +486,7 @@ \subsection{Complexity of functions and functional blocks}
}
\end{Verbatim}

The string inside each \verb|push_wmops()| macro shall be unique in the entire project and reflect what is being measured. It does not need to be the same as the name of the function in which it is used. The macro \verb|pop_wmops()| must \textbf{ALWAYS} be used to terminate the complexity counters associated with each \verb|push_wmops()| macro. The WMC tool supports nesting of these macro pairs. Note, that the \verb|push_wmops()| and the \verb|pop_wmops()| macros do not need to be encapsulated within the \verb|#define WMC_TOOL_SKIP| \ldots \verb|#undef WMC_TOOL_SKIP| macro pairs.
The \verb|push_wmops()| macro must be placed after the declaration of local variables. The string inside each \verb|push_wmops()| macro shall be unique in the entire project and reflect what is being measured. It does not need to be the same as the name of the function in which it is used. The macro \verb|pop_wmops()| must \textbf{ALWAYS} be used to terminate the complexity counters associated with each \verb|push_wmops()| macro. The WMC tool supports nesting of these macro pairs. Note, that the \verb|push_wmops()| and the \verb|pop_wmops()| macros do not need to be encapsulated within the \verb|#define WMC_TOOL_SKIP| \ldots \verb|#undef WMC_TOOL_SKIP| macro pairs.

%-----------------------------------------------------------------------------
\subsection{Printing statistics about computational complexity}
Expand Down
6 changes: 6 additions & 0 deletions src/bs1770demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ add_test(bs1770demo2-verify ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/signal-diff -equiv

add_test(bs1770demo3 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bs1770demo -lev -16 -conf 11L000 test_data/sine_noise_test.pcm test_data/sine_noise_test.16LKFS.11L000.test.pcm)
add_test(bs1770demo3-verify ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/signal-diff -equiv 159 -q test_data/sine_noise_test.16LKFS.11L000.test.pcm test_data/sine_noise_test.16LKFS.11L000.pcm)

add_test(bs1770demo4 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bs1770demo -lev -26 test_data/sine_ramp.pcm test_data/sine_ramp.26LKFS.test.pcm)
add_test(bs1770demo4-verify ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/signal-diff -equiv 115 -q test_data/sine_ramp.26LKFS.test.pcm test_data/sine_ramp.26LKFS.pcm)

add_test(bs1770demo5 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bs1770demo -rms -lev -26 test_data/sine_ramp.pcm test_data/sine_ramp.26LKFSrms.test.pcm)
add_test(bs1770demo5-verify ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/signal-diff -equiv 206 -q test_data/sine_ramp.26LKFSrms.test.pcm test_data/sine_ramp.26LKFSrms.pcm)
Loading