Commit e4692f72 authored by norvell's avatar norvell
Browse files

Merge branch 'ci/basop-ci-branch-add-renderer_short' into 'basop-ci-branch'

Ci/basop ci branch add renderer short

See merge request !2362
parents 0f0ff01e a6ad7eb2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -78,6 +78,14 @@ if __name__ == '__main__':
    cmds_rend.sort()
    cmds_isar_post_rend.sort()

    # Remove duplicates from cmds_enc -- some decoder tests use same encoder options
    i = 0
    while i + 1 < len(cmds_enc):
        if " ".join(cmds_enc[i].split()[:-1]) == " ".join(cmds_enc[i+1].split()[:-1]):
            del cmds_enc[i+1]
        else:
            i = i + 1

    with open(txt_file.replace('.','_enc.'),'w', newline='\n') as outfile:
        with open('scripts/enc_header.txt','r') as header:
            outfile.write(header.read())
+44 −0
Original line number Diff line number Diff line
========================================
THIS FOLDER WILL NOT BE PART OF DELIVERY
========================================

# External Renderer Tests

See also the [contribution page](https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/wikis/Contributions/2-external-renderer) for related presentations.

### Run tests with:

## Smoke test:

```bash
python3 -m pytest -q -n auto tests/renderer/test_renderer.py
```

## Comparison test:

```bash
python3 -m pytest -q -n auto tests/renderer/test_renderer.py --create_ref # requires IVAS_rend_ref in root!
python3 -m pytest -q -n auto tests/renderer/test_renderer.py --create_cut
```

### Important flags (see [pytest docs](https://docs.pytest.org/en/7.2.x/) for more information):

- `-k` flag can filter test cases, e.g. `-k "test_ism_binaural_static"`
- `-rA` reports ALL (pass, xpass, xfail, fail) instead of the default behaviour of reporting only failed tests\
  this option will also report captured logs, **required for obtaining the commandline of testcases that pass or xfail**
- `--last-failed` re-runs only the cases that failed in the last test run
- `--collect-only` is useful when adding new testcases to check if argument parametrization is working correctly

### Directory tree

```
.
├── compare_audio.py                    ->  Python implementation of CompAudio, used for comparisons in tests
├── conftest.py                         ->  Pytest configuration (enable commandline argument ingestion)
├── constants.py                        ->  Important paths, formats, metadata files and commandline templates
├── cut                                 ->  Default location for output files for test conditions
├── data                                ->  Input test vectors
├── ref                                 ->  Default location for output files for reference conditions
├── test_renderer.py                    ->  Runs the renderer for all modes
└── utils.py                            ->  Wrapper functions for executables for use in testcases
```
+31 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

"""
   (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository. All Rights Reserved.

   This software is protected by copyright law and by international treaties.
   The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository retain full ownership rights in their respective contributions in
   the software. This notice grants no license of any kind, including but not limited to patent
   license, nor is any license granted by implication, estoppel or otherwise.

   Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
   contributions.

   This software is provided "AS IS", without any express or implied warranties. The software is in the
   development stage. It is intended exclusively for experts who have experience with such software and
   solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
   and fitness for a particular purpose are hereby disclaimed and excluded.

   Any dispute, controversy or claim arising under or in relation to providing this software shall be
   submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
   accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
   the United Nations Convention on Contracts on the International Sales of Goods.
"""
+105 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

"""
   (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository. All Rights Reserved.

   This software is protected by copyright law and by international treaties.
   The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository retain full ownership rights in their respective contributions in
   the software. This notice grants no license of any kind, including but not limited to patent
   license, nor is any license granted by implication, estoppel or otherwise.

   Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
   contributions.

   This software is provided "AS IS", without any express or implied warranties. The software is in the
   development stage. It is intended exclusively for experts who have experience with such software and
   solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
   and fitness for a particular purpose are hereby disclaimed and excluded.

   Any dispute, controversy or claim arising under or in relation to providing this software shall be
   submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
   accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
   the United Nations Convention on Contracts on the International Sales of Goods.
"""

import sys
import warnings
from typing import Tuple

import numpy as np

from .constants import SCRIPTS_DIR

sys.path.append(str(SCRIPTS_DIR))
from pyaudio3dtools.audioarray import getdelay


def compare_audio_arrays(
    left: np.ndarray, left_fs: int, right: np.ndarray, right_fs: int
) -> Tuple[float, float]:
    if left_fs != right_fs:
        return ValueError(f"Differing samplerates: {left_fs} vs {right_fs}!")

    if left.shape[1] != right.shape[1]:
        cmp_ch = min(left.shape[1], right.shape[1])
        warnings.warn(
            f"Differing number of channels: {left.shape[1]} vs {right.shape[1]}! Comparing first {cmp_ch} channel(s)",
            category=RuntimeWarning,
        )
        left = left[:, :cmp_ch]
        right = right[:, :cmp_ch]

    if left.shape[0] != right.shape[0]:
        cmp_smp = min(left.shape[0], right.shape[0])
        warnings.warn(
            f"Warning - different durations: {left.shape[0] / left_fs:.2f}s vs {right.shape[0] / right_fs:.2f}s! Comparing first {cmp_smp / left_fs : .2f} sample(s)",
            category=RuntimeWarning,
        )
        left = left[:cmp_smp, :]
        right = right[:cmp_smp, :]

    if not np.array_equal(left, right):
        delay = getdelay(left, right)
        delay_abs = np.abs(delay)
        # getdelay can return large values if signals are quite different
        # limit any delay compensation to 20 ms
        if delay != 0 and (delay_abs < left_fs / 50):
            warnings.warn(
                f"File B is delayed by {delay} samples ({delay*1000 / left_fs : .2f}ms)!",
                category=RuntimeWarning,
            )

            # shift array
            left = np.roll(left, delay, axis=0)

            # zero shifted out samples
            if delay < 0:
                left[-np.abs(delay) :, :] = 0
            elif delay > 0:
                left[: np.abs(delay), :] = 0
        """
        http://www-mmsp.ece.mcgill.ca/Documents/Software/Packages/AFsp/AFsp/CompAudio.html
        """
        num = np.sum(left * right)
        den = np.sqrt(np.sum(left**2) * np.sum(right**2))
        if den > 0:
            r = num / den
        else:
            r = np.inf
        snr = 10 * np.log10(1 / (1 - (r**2)))
        gain_b = num / np.sum(right**2)
        max_diff = np.abs(np.max(left - right))
    else:
        snr = np.inf
        gain_b = 1
        max_diff = 0

    return snr, gain_b, max_diff
+421 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading