LCOV - code coverage report
Current view: top level - lib_rend - ivas_render_config.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 315f7421ae713fcc5638c2d754c52d449e763731 Lines: 79 83 95.2 %
Date: 2025-12-05 05:57:24 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include "prot.h"
      36             : #include "ivas_prot_rend.h"
      37             : #include "ivas_rom_rend.h"
      38             : #ifdef DEBUGGING
      39             : #include "debug.h"
      40             : #endif
      41             : #include "wmc_auto.h"
      42             : 
      43             : 
      44             : /*-----------------------------------------------------------------------*
      45             :  * Local constants
      46             :  *-----------------------------------------------------------------------*/
      47             : 
      48             : #define IVAS_REVERB_DEFAULT_L_PRE_DELAY   0.016f
      49             : #define IVAS_REVERB_DEFAULT_L_INPUT_DELAY 0.1f
      50             : 
      51             : #define IVAS_REVERB_DEFAULT_S_PRE_DELAY   0.0125f
      52             : #define IVAS_REVERB_DEFAULT_S_INPUT_DELAY 0.0f
      53             : 
      54             : #define IVAS_REVERB_DEFAULT_M_PRE_DELAY   0.0125f
      55             : #define IVAS_REVERB_DEFAULT_M_INPUT_DELAY 0.0f
      56             : 
      57             : #define IVAS_REVERB_DEFAULT_USE_ER 0
      58             : 
      59             : 
      60             : /*-----------------------------------------------------------------------*
      61             :  * ivas_render_config_open()
      62             :  *
      63             :  * Allocates the renderer configuration structure
      64             :  *-----------------------------------------------------------------------*/
      65             : 
      66       30519 : ivas_error ivas_render_config_open(
      67             :     RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle    */
      68             : )
      69             : {
      70             :     /* Allocate HR filter set for headphones configuration */
      71       30519 :     if ( ( *hRenderConfig = (RENDER_CONFIG_HANDLE) malloc( sizeof( RENDER_CONFIG_DATA ) ) ) == NULL )
      72             :     {
      73           0 :         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer configuration!" );
      74             :     }
      75             : 
      76       30519 :     return IVAS_ERR_OK;
      77             : }
      78             : 
      79             : 
      80             : /*-------------------------------------------------------------------*
      81             :  * ivas_render_config_close()
      82             :  *
      83             :  * Deallocates the renderer configuration structure
      84             :  *-------------------------------------------------------------------*/
      85             : 
      86       96408 : void ivas_render_config_close(
      87             :     RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */
      88             : )
      89             : {
      90       96408 :     if ( hRenderConfig == NULL || *hRenderConfig == NULL )
      91             :     {
      92       65889 :         return;
      93             :     }
      94             : 
      95       30519 :     free( *hRenderConfig );
      96       30519 :     *hRenderConfig = NULL;
      97             : 
      98       30519 :     return;
      99             : }
     100             : 
     101             : 
     102             : /*-------------------------------------------------------------------*
     103             :  * ivas_render_config_init_from_rom()
     104             :  *
     105             :  * Initializes the renderer configuration structure from ROM
     106             :  *-------------------------------------------------------------------*/
     107             : 
     108       30519 : ivas_error ivas_render_config_init_from_rom(
     109             :     RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle     */
     110             : )
     111             : {
     112             :     int16_t i;
     113             : 
     114       30519 :     if ( hRenderConfig == NULL || *hRenderConfig == NULL )
     115             :     {
     116           0 :         return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" );
     117             :     }
     118             : 
     119       30519 :     ( *hRenderConfig )->roomAcoustics.aeID = IVAS_DEFAULT_AEID;
     120       30519 :     ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_L_N_BANDS;
     121       30519 :     ( *hRenderConfig )->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_L_PRE_DELAY;
     122       30519 :     ( *hRenderConfig )->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_L_INPUT_DELAY;
     123       30519 :     ( *hRenderConfig )->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER;
     124       30519 :     set_zero( &( *hRenderConfig )->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX );
     125       30519 :     set_zero( &( *hRenderConfig )->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX );
     126       30519 :     set_zero( &( *hRenderConfig )->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX );
     127             : 
     128       30519 :     mvr2r( ivas_reverb_default_large_fc, ( *hRenderConfig )->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_L_N_BANDS );
     129       30519 :     mvr2r( ivas_reverb_default_large_RT60, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_L_N_BANDS );
     130       30519 :     mvr2r( ivas_reverb_default_large_DSR, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_L_N_BANDS );
     131             : 
     132      152595 :     for ( i = 0; i < MAX_NUM_OBJECTS; i++ )
     133             :     {
     134      122076 :         ( *hRenderConfig )->directivity[i * 3] = 360.0f;     /* Front cone */
     135      122076 :         ( *hRenderConfig )->directivity[i * 3 + 1] = 360.0f; /* Back cone */
     136      122076 :         ( *hRenderConfig )->directivity[i * 3 + 2] = 1.0f;   /* Back attenuation */
     137             :     }
     138             : 
     139       30519 :     ( *hRenderConfig )->distAtt[0] = 15.75f; /* Default max dist */
     140       30519 :     ( *hRenderConfig )->distAtt[1] = 1.0f;   /* Default ref dist */
     141       30519 :     ( *hRenderConfig )->distAtt[2] = 1.0f;   /* Default rolloff factor */
     142             : 
     143             :     /* ISAR-related parameters */
     144       30519 :     ( *hRenderConfig )->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE;
     145       30519 :     ( *hRenderConfig )->split_rend_config.dof = 3;
     146       30519 :     ( *hRenderConfig )->split_rend_config.hq_mode = 0;
     147       30519 :     ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0;
     148       30519 :     ( *hRenderConfig )->split_rend_config.isar_frame_size_ms = 20;
     149       30519 :     ( *hRenderConfig )->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */
     150       30519 :     ( *hRenderConfig )->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT;
     151       30519 :     ( *hRenderConfig )->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB;
     152       30519 :     ( *hRenderConfig )->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_DEFAULT;
     153       30519 :     ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0;
     154             : 
     155       30519 :     return IVAS_ERR_OK;
     156             : }
     157             : 
     158             : 
     159             : /*-------------------------------------------------------------------*
     160             :  * ivas_render_config_change_defaults()
     161             :  *
     162             :  *  Changes default values from ROM
     163             :  *-------------------------------------------------------------------*/
     164             : 
     165       12344 : ivas_error ivas_render_config_change_defaults(
     166             :     RENDER_CONFIG_HANDLE hRenderConfig,      /* i/o: Renderer config handle */
     167             :     IVAS_DefaultReverbSize defaultReverbSize /* i:   Reverb default size    */
     168             : )
     169             : {
     170       12344 :     switch ( defaultReverbSize )
     171             :     {
     172        2670 :         case DEFAULT_REVERB_SMALL:
     173        2670 :             hRenderConfig->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_S_N_BANDS;
     174        2670 :             hRenderConfig->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_S_PRE_DELAY;
     175        2670 :             hRenderConfig->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_S_INPUT_DELAY;
     176        2670 :             hRenderConfig->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER;
     177        2670 :             set_zero( &hRenderConfig->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX );
     178        2670 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX );
     179        2670 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX );
     180             : 
     181        2670 :             mvr2r( ivas_reverb_default_small_fc, hRenderConfig->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_S_N_BANDS );
     182        2670 :             mvr2r( ivas_reverb_default_small_RT60, hRenderConfig->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_S_N_BANDS );
     183        2670 :             mvr2r( ivas_reverb_default_small_DSR, hRenderConfig->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_S_N_BANDS );
     184        2670 :             break;
     185        5343 :         case DEFAULT_REVERB_MEDIUM:
     186        5343 :             hRenderConfig->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_M_N_BANDS;
     187        5343 :             hRenderConfig->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_M_PRE_DELAY;
     188        5343 :             hRenderConfig->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_M_INPUT_DELAY;
     189        5343 :             hRenderConfig->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER;
     190        5343 :             set_zero( &hRenderConfig->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX );
     191        5343 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX );
     192        5343 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX );
     193             : 
     194        5343 :             mvr2r( ivas_reverb_default_medium_fc, hRenderConfig->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_M_N_BANDS );
     195        5343 :             mvr2r( ivas_reverb_default_medium_RT60, hRenderConfig->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_M_N_BANDS );
     196        5343 :             mvr2r( ivas_reverb_default_medium_DSR, hRenderConfig->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_M_N_BANDS );
     197        5343 :             break;
     198        4331 :         case DEFAULT_REVERB_LARGE:
     199        4331 :             hRenderConfig->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_L_N_BANDS;
     200        4331 :             hRenderConfig->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_L_PRE_DELAY;
     201        4331 :             hRenderConfig->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_L_INPUT_DELAY;
     202        4331 :             hRenderConfig->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER;
     203        4331 :             set_zero( &hRenderConfig->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX );
     204        4331 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX );
     205        4331 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX );
     206             : 
     207        4331 :             mvr2r( ivas_reverb_default_large_fc, hRenderConfig->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_L_N_BANDS );
     208        4331 :             mvr2r( ivas_reverb_default_large_RT60, hRenderConfig->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_L_N_BANDS );
     209        4331 :             mvr2r( ivas_reverb_default_large_DSR, hRenderConfig->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_L_N_BANDS );
     210        4331 :             break;
     211           0 :         default:
     212           0 :             return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING;
     213             :     }
     214             : 
     215       12344 :     return IVAS_ERR_OK;
     216             : }

Generated by: LCOV version 1.14