Commit 878d7e41 authored by vaclav's avatar vaclav
Browse files

Merge remote-tracking branch 'remotes/origin/main' into 651-framework-improvements

parents 92f29aff 30936203
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -239,6 +239,7 @@
    <ClCompile Include="..\lib_rend\ivas_omasa_ana.c" />
    <ClCompile Include="..\lib_rend\ivas_orient_trk.c" />
    <ClCompile Include="..\lib_rend\ivas_output_init.c" />
	<ClCompile Include="..\lib_rend\ivas_reflections.c" />
    <ClCompile Include="..\lib_rend\ivas_render_config.c" />
    <ClCompile Include="..\lib_rend\ivas_reverb.c" />
    <ClCompile Include="..\lib_rend\ivas_reverb_delay_line.c" />
@@ -251,6 +252,7 @@
    <ClCompile Include="..\lib_rend\ivas_rom_binaural_crend_head.c" />
    <ClCompile Include="..\lib_rend\ivas_rotation.c" />
    <ClCompile Include="..\lib_rend\ivas_rom_rend.c" />
	<ClCompile Include="..\lib_rend\ivas_shoebox.c" />
    <ClCompile Include="..\lib_rend\lib_rend.c" />
  </ItemGroup>
  <ItemGroup>
+75 −3
Original line number Diff line number Diff line
@@ -154,6 +154,13 @@ typedef struct
#endif
#endif

#ifdef CONTROL_METADATA_REVERB
    uint16_t acousticEnvironmentId;
#ifdef CONTROL_METADATA_DIRECTIVITY
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
#endif
#endif

} DecArguments;


@@ -601,12 +608,42 @@ int main(
            goto cleanup;
        }

#ifdef CONTROL_METADATA_REVERB
        if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK )
#else
        if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK )
#endif
        {
            fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename );
            goto cleanup;
        }
#ifdef CONTROL_METADATA_DIRECTIVITY
        if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Failed to get directivity for objects: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] );
            goto cleanup;
        }
#endif

#ifdef CONTROL_METADATA_REVERB
        if ( arg.outputFormat == IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB )
        {
            if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.acousticEnvironmentId, &renderConfig.room_acoustics ) ) == IVAS_ERR_OK )
            {
                if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Invalid reverberation configuration parameters\n\n" );
                    goto cleanup;
                }
            }
            else if ( error != IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING )
            {
                fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", arg.acousticEnvironmentId );
                goto cleanup;
            }
            renderConfig.room_acoustics.override = true;
        }
#endif
        if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -676,6 +713,7 @@ int main(
        {
            fprintf( stderr, "\nError in loading HRTF binary file %s for FastConv \n\n", arg.hrtfFileName );
            goto cleanup;
            goto cleanup;
        }

        IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin = NULL;
@@ -689,6 +727,7 @@ int main(
        {
            fprintf( stderr, "\nError in loading HRTF binary file %s for parametric binauralizer \n\n", arg.hrtfFileName );
            goto cleanup;
            goto cleanup;
        }
    }

@@ -976,7 +1015,15 @@ static bool parseCmdlIVAS_dec(
#endif
#endif


#ifdef CONTROL_METADATA_REVERB
    arg->acousticEnvironmentId = 0;
#ifdef CONTROL_METADATA_DIRECTIVITY
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
        arg->directivityPatternId[i] = 0;
    }
#endif
#endif
    /*-----------------------------------------------------------------*
     * Initialization
     *-----------------------------------------------------------------*/
@@ -1337,8 +1384,27 @@ static bool parseCmdlIVAS_dec(
                fprintf( stdout, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" );
            }
        }


#ifdef CONTROL_METADATA_REVERB
        else if ( strcmp( argv_to_upper, "-AEID" ) == 0 )
        {
            ++i;
            arg->acousticEnvironmentId = (int16_t) atoi( argv[i++] );
        }
#ifdef CONTROL_METADATA_DIRECTIVITY
        else if ( strcmp( argv_to_upper, "-DPID" ) == 0 )
        {
            ++i;
            int16_t tmp;
            tmp = 0;
            while ( is_number( argv[i + tmp] ) && tmp < IVAS_MAX_NUM_OBJECTS )
            {
                arg->directivityPatternId[tmp] = (int16_t) atoi( argv[i + tmp] );
                ++tmp;
            }
            i += tmp;
        }
#endif
#endif
        /*-----------------------------------------------------------------*
         * Option not recognized
         *-----------------------------------------------------------------*/
@@ -1523,6 +1589,12 @@ static void usage_dec( void )
    fprintf( stdout, "                      Currently, all values default to level 3 (full functionality).\n" );
#endif
    fprintf( stdout, "-exof File          : External orientation file for external orientation trajectory\n" );
#ifdef CONTROL_METADATA_DIRECTIVITY
    fprintf( stdout, "-dpid ID            : Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration\n" );
#endif
#ifdef CONTROL_METADATA_REVERB
    fprintf( stdout, "-aeid ID            : Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output configuration\n" );
#endif
#ifdef DEBUG_MODE_INFO
#ifdef DEBUG_MODE_INFO_TWEAK
    fprintf( stdout, "-info <folder>      : specify subfolder name for debug output\n" );
+75 −0
Original line number Diff line number Diff line
@@ -178,6 +178,12 @@ typedef struct
#ifdef FIX_488_SYNC_DELAY
    float syncMdDelay;
#endif
#ifdef CONTROL_METADATA_DIRECTIVITY
    uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS];
#endif
#ifdef CONTROL_METADATA_REVERB
    uint16_t acousticEnvironmentId;
#endif
} CmdlnArgs;

typedef enum
@@ -209,6 +215,12 @@ typedef enum
#ifdef FIX_488_SYNC_DELAY
    CmdLnOptionId_syncMdDelay,
#endif
#ifdef CONTROL_METADATA_DIRECTIVITY
    CmdLnOptionId_directivityPatternId,
#endif
#ifdef CONTROL_METADATA_REVERB
    CmdLnOptionId_acousticEnvironmentId
#endif
} CmdLnOptionId;

static const CmdLnParser_Option cliOptions[] = {
@@ -356,6 +368,22 @@ static const CmdLnParser_Option cliOptions[] = {
        .description = "Metadata Synchronization Delay in ms, Default is 0. Quantized by 5ms subframes for TDRenderer (13ms -> 10ms -> 2subframes)",
    },
#endif
#ifdef CONTROL_METADATA_DIRECTIVITY
    {
        .id = CmdLnOptionId_directivityPatternId,
        .match = "ism_directivity_pattern_id",
        .matchShort = "dpid",
        .description = "Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration",
    },
#endif
#ifdef CONTROL_METADATA_REVERB
    {
        .id = CmdLnOptionId_acousticEnvironmentId,
        .match = "acoustic_environment_id",
        .matchShort = "aeid",
        .description = "Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output configuration",
    },
#endif
};


@@ -1069,7 +1097,11 @@ int main(
            exit( -1 );
        }

#ifdef CONTROL_METADATA_REVERB
        if ( RenderConfigReader_read( renderConfigReader, args.renderConfigFilePath, &renderConfig ) != IVAS_ERR_OK )
#else
        if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK )
#endif
        {
            fprintf( stderr, "Failed to read renderer configuration from file %s\n", args.renderConfigFilePath );
            exit( -1 );
@@ -1077,6 +1109,21 @@ int main(

        if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
#ifdef CONTROL_METADATA_REVERB
            if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, args.acousticEnvironmentId, &renderConfig.room_acoustics ) ) == IVAS_ERR_OK )
            {
                if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Invalid room acoustics configuration parameters\n\n" );
                    exit( -1 );
                }
            }
            else
            {
                fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", args.acousticEnvironmentId );
                exit( -1 );
            }
#endif
            renderConfig.room_acoustics.override = TRUE;
        }

@@ -2513,6 +2560,17 @@ static CmdlnArgs defaultArgs(
#ifdef FIX_488_SYNC_DELAY
    args.syncMdDelay = 0;
#endif

#ifdef CONTROL_METADATA_DIRECTIVITY
    for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
    {
        args.directivityPatternId[i] = 0;
    }
#endif

#ifdef CONTROL_METADATA_REVERB
    args.acousticEnvironmentId = 0;
#endif
    return args;
}

@@ -2652,6 +2710,23 @@ static void parseOption(
                exit( -1 );
            }
            break;

#ifdef CONTROL_METADATA_DIRECTIVITY
        case CmdLnOptionId_directivityPatternId:
            assert( numOptionValues <= RENDERER_MAX_ISM_INPUTS );
            for ( int16_t i = 0; i < numOptionValues; ++i )
            {
                args->directivityPatternId[i] = (int16_t) strtol( optionValues[i], NULL, 10 );
            }
            break;
#endif

#ifdef CONTROL_METADATA_REVERB
        case CmdLnOptionId_acousticEnvironmentId:
            assert( numOptionValues == 1 );
            args->acousticEnvironmentId = (int16_t) strtol( optionValues[0], NULL, 10 );
            break;
#endif
#ifdef FIX_488_SYNC_DELAY
        case CmdLnOptionId_syncMdDelay:
            assert( numOptionValues == 1 );
+2 −2
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ int16_t tcx_hm_render(
    }
    ELSE
    {
        div_s( &tmp, 13915, PeakDeviation );
        tmp = div_s( 13915, PeakDeviation );
        tmp = mult_r( tmp, tmp ); /* Q15 */
    }

@@ -282,7 +282,7 @@ void tcx_hm_modify_envelope(

    for ( k = 0; k < 2 * kTcxHmParabolaHalfWidth + 1; ++k )
    {
        div_s( &inv_shape[k], 512, add( 512, round_fx( L_mult( gain, p[k] ) ) ) );
        inv_shape[k] = div_s( 512, add( 512, round_fx( L_mult( gain, p[k] ) ) ) );
    }

    h = 1;
+4 −4
Original line number Diff line number Diff line
@@ -281,7 +281,7 @@ void tcx_arith_scale_envelope(
        mean = L_add( mean, ienv[k] );
    }
    tmp = norm_s( L_frame );
    div_s( &tmp2, 8192, shl( L_frame, tmp ) );
    tmp2 = div_s( 8192, shl( L_frame, tmp ) );
    tmp = shl( tmp2, sub( tmp, 7 ) );
    mean = L_shr( Mpy_32_16( mean, tmp ), 6 ); /* Q16 */

@@ -416,7 +416,7 @@ void tcx_arith_scale_envelope(

            IF( hib > 0 ) /* Bisection search */
            {
                div_s( &adjust, sub( hib_bits, target_bits ), sub( hib_bits, lob_bits ) );
                adjust = div_s( sub( hib_bits, target_bits ), sub( hib_bits, lob_bits ) );
                scale = add( mult_r( sub( lob, hib ), adjust ), hib );
            }
            ELSE
@@ -439,7 +439,7 @@ void tcx_arith_scale_envelope(

            IF( lob > 0 ) /* Bisection search */
            {
                div_s( &adjust, sub( hib_bits, target_bits ), sub( hib_bits, lob_bits ) );
                adjust = div_s( sub( hib_bits, target_bits ), sub( hib_bits, lob_bits ) );
                scale = add( mult_r( sub( lob, hib ), adjust ), hib );
            }
            ELSE
@@ -458,7 +458,7 @@ void tcx_arith_scale_envelope(
                }
                ELSE
                {
                    div_s( &adjust, mult_r( 31130 /*0.95f Q15*/, target_bits ), bits );
                    adjust = div_s( mult_r( 31130 /*0.95f Q15*/, target_bits ), bits );
                }
                scale = mult_r( scale, adjust );
            }
Loading