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 @ 6a06b4847eef05c1c038d1156aef62668d97d8cb Lines: 79 83 95.2 %
Date: 2025-11-13 07:02:43 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             : #ifdef FIX_1318_ROOM_SIZE_CMD_LINE
      49             : #define IVAS_REVERB_DEFAULT_L_PRE_DELAY   0.016f
      50             : #define IVAS_REVERB_DEFAULT_L_INPUT_DELAY 0.1f
      51             : 
      52             : #define IVAS_REVERB_DEFAULT_S_PRE_DELAY   0.0125f
      53             : #define IVAS_REVERB_DEFAULT_S_INPUT_DELAY 0.0f
      54             : 
      55             : #define IVAS_REVERB_DEFAULT_M_PRE_DELAY   0.0125f
      56             : #define IVAS_REVERB_DEFAULT_M_INPUT_DELAY 0.0f
      57             : #else
      58             : #define IVAS_REVERB_DEFAULT_PRE_DELAY   0.016f
      59             : #define IVAS_REVERB_DEFAULT_INPUT_DELAY 0.1f
      60             : #endif
      61             : 
      62             : #define IVAS_REVERB_DEFAULT_USE_ER 0
      63             : 
      64             : 
      65             : /*-----------------------------------------------------------------------*
      66             :  * ivas_render_config_open()
      67             :  *
      68             :  * Allocates the renderer configuration structure
      69             :  *-----------------------------------------------------------------------*/
      70             : 
      71       29295 : ivas_error ivas_render_config_open(
      72             :     RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle    */
      73             : )
      74             : {
      75             :     /* Allocate HR filter set for headphones configuration */
      76       29295 :     if ( ( *hRenderConfig = (RENDER_CONFIG_HANDLE) malloc( sizeof( RENDER_CONFIG_DATA ) ) ) == NULL )
      77             :     {
      78           0 :         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer configuration!" );
      79             :     }
      80             : 
      81       29295 :     return IVAS_ERR_OK;
      82             : }
      83             : 
      84             : 
      85             : /*-------------------------------------------------------------------*
      86             :  * ivas_render_config_close()
      87             :  *
      88             :  * Deallocates the renderer configuration structure
      89             :  *-------------------------------------------------------------------*/
      90             : 
      91       95157 : void ivas_render_config_close(
      92             :     RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */
      93             : )
      94             : {
      95       95157 :     if ( hRenderConfig == NULL || *hRenderConfig == NULL )
      96             :     {
      97       65862 :         return;
      98             :     }
      99             : 
     100       29295 :     free( *hRenderConfig );
     101       29295 :     *hRenderConfig = NULL;
     102             : 
     103       29295 :     return;
     104             : }
     105             : 
     106             : 
     107             : /*-------------------------------------------------------------------*
     108             :  * ivas_render_config_init_from_rom()
     109             :  *
     110             :  * Initializes the renderer configuration structure from ROM
     111             :  *-------------------------------------------------------------------*/
     112             : 
     113       29295 : ivas_error ivas_render_config_init_from_rom(
     114             :     RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle     */
     115             : )
     116             : {
     117             :     int16_t i;
     118             : 
     119       29295 :     if ( hRenderConfig == NULL || *hRenderConfig == NULL )
     120             :     {
     121           0 :         return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" );
     122             :     }
     123             : 
     124             : #ifdef DEBUGGING
     125             :     ( *hRenderConfig )->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE;
     126             : #endif
     127             : #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
     128       29295 :     ( *hRenderConfig )->roomAcoustics.aeID = (uint16_t) IVAS_DEFAULT_AEID;
     129             : #endif
     130             : #ifdef FIX_1318_ROOM_SIZE_CMD_LINE
     131       29295 :     ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_L_N_BANDS;
     132       29295 :     ( *hRenderConfig )->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_L_PRE_DELAY;
     133       29295 :     ( *hRenderConfig )->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_L_INPUT_DELAY;
     134             : #else
     135             :     ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS;
     136             :     ( *hRenderConfig )->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_PRE_DELAY;
     137             :     ( *hRenderConfig )->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_INPUT_DELAY;
     138             : #endif
     139       29295 :     ( *hRenderConfig )->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER;
     140       29295 :     set_zero( &( *hRenderConfig )->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX );
     141       29295 :     set_zero( &( *hRenderConfig )->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX );
     142       29295 :     set_zero( &( *hRenderConfig )->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX );
     143             : 
     144             : #ifdef FIX_1318_ROOM_SIZE_CMD_LINE
     145       29295 :     mvr2r( ivas_reverb_default_large_fc, ( *hRenderConfig )->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_L_N_BANDS );
     146       29295 :     mvr2r( ivas_reverb_default_large_RT60, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_L_N_BANDS );
     147       29295 :     mvr2r( ivas_reverb_default_large_DSR, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_L_N_BANDS );
     148             : #else
     149             :     mvr2r( ivas_reverb_default_fc, ( *hRenderConfig )->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_N_BANDS );
     150             :     mvr2r( ivas_reverb_default_RT60, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_N_BANDS );
     151             :     mvr2r( ivas_reverb_default_DSR, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_N_BANDS );
     152             : #endif
     153             : 
     154      146475 :     for ( i = 0; i < MAX_NUM_OBJECTS; i++ )
     155             :     {
     156      117180 :         ( *hRenderConfig )->directivity[i * 3] = 360.0f;     /* Front cone */
     157      117180 :         ( *hRenderConfig )->directivity[i * 3 + 1] = 360.0f; /* Back cone */
     158      117180 :         ( *hRenderConfig )->directivity[i * 3 + 2] = 1.0f;   /* Back attenuation */
     159             :     }
     160             : 
     161       29295 :     ( *hRenderConfig )->distAtt[0] = 15.75f; /* Default max dist */
     162       29295 :     ( *hRenderConfig )->distAtt[1] = 1.0f;   /* Default ref dist */
     163       29295 :     ( *hRenderConfig )->distAtt[2] = 1.0f;   /* Default rolloff factor */
     164             : 
     165             :     /* ISAR-related parameters */
     166       29295 :     ( *hRenderConfig )->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE;
     167       29295 :     ( *hRenderConfig )->split_rend_config.dof = 3;
     168       29295 :     ( *hRenderConfig )->split_rend_config.hq_mode = 0;
     169       29295 :     ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0;
     170       29295 :     ( *hRenderConfig )->split_rend_config.isar_frame_size_ms = 20;
     171       29295 :     ( *hRenderConfig )->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */
     172       29295 :     ( *hRenderConfig )->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT;
     173       29295 :     ( *hRenderConfig )->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB;
     174       29295 :     ( *hRenderConfig )->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_DEFAULT;
     175       29295 :     ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0;
     176             : 
     177       29295 :     return IVAS_ERR_OK;
     178             : }
     179             : 
     180             : #ifdef FIX_1318_ROOM_SIZE_CMD_LINE
     181             : 
     182             : /*-------------------------------------------------------------------*
     183             :  * ivas_render_config_change_defaults()
     184             :  *
     185             :  *  Changes default values from ROM
     186             :  *-------------------------------------------------------------------*/
     187             : 
     188       11120 : ivas_error ivas_render_config_change_defaults(
     189             :     RENDER_CONFIG_HANDLE hRenderConfig,      /* i/o: Renderer config handle */
     190             :     IVAS_DefaultReverbSize defaultReverbSize /* i:   Reverb default size    */
     191             : )
     192             : {
     193       11120 :     switch ( defaultReverbSize )
     194             :     {
     195        2490 :         case DEFAULT_REVERB_SMALL:
     196        2490 :             hRenderConfig->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_S_N_BANDS;
     197        2490 :             hRenderConfig->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_S_PRE_DELAY;
     198        2490 :             hRenderConfig->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_S_INPUT_DELAY;
     199        2490 :             hRenderConfig->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER;
     200        2490 :             set_zero( &hRenderConfig->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX );
     201        2490 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX );
     202        2490 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX );
     203             : 
     204        2490 :             mvr2r( ivas_reverb_default_small_fc, hRenderConfig->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_S_N_BANDS );
     205        2490 :             mvr2r( ivas_reverb_default_small_RT60, hRenderConfig->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_S_N_BANDS );
     206        2490 :             mvr2r( ivas_reverb_default_small_DSR, hRenderConfig->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_S_N_BANDS );
     207        2490 :             break;
     208        5163 :         case DEFAULT_REVERB_MEDIUM:
     209        5163 :             hRenderConfig->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_M_N_BANDS;
     210        5163 :             hRenderConfig->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_M_PRE_DELAY;
     211        5163 :             hRenderConfig->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_M_INPUT_DELAY;
     212        5163 :             hRenderConfig->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER;
     213        5163 :             set_zero( &hRenderConfig->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX );
     214        5163 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX );
     215        5163 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX );
     216             : 
     217        5163 :             mvr2r( ivas_reverb_default_medium_fc, hRenderConfig->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_M_N_BANDS );
     218        5163 :             mvr2r( ivas_reverb_default_medium_RT60, hRenderConfig->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_M_N_BANDS );
     219        5163 :             mvr2r( ivas_reverb_default_medium_DSR, hRenderConfig->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_M_N_BANDS );
     220        5163 :             break;
     221        3467 :         case DEFAULT_REVERB_LARGE:
     222        3467 :             hRenderConfig->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_L_N_BANDS;
     223        3467 :             hRenderConfig->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_L_PRE_DELAY;
     224        3467 :             hRenderConfig->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_L_INPUT_DELAY;
     225        3467 :             hRenderConfig->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER;
     226        3467 :             set_zero( &hRenderConfig->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX );
     227        3467 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX );
     228        3467 :             set_zero( &hRenderConfig->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX );
     229             : 
     230        3467 :             mvr2r( ivas_reverb_default_large_fc, hRenderConfig->roomAcoustics.pFc_input, IVAS_REVERB_DEFAULT_L_N_BANDS );
     231        3467 :             mvr2r( ivas_reverb_default_large_RT60, hRenderConfig->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_L_N_BANDS );
     232        3467 :             mvr2r( ivas_reverb_default_large_DSR, hRenderConfig->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_L_N_BANDS );
     233        3467 :             break;
     234           0 :         default:
     235           0 :             return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING;
     236             :     }
     237             : 
     238       11120 :     return IVAS_ERR_OK;
     239             : }
     240             : #endif

Generated by: LCOV version 1.14