Commit 8988cbf3 authored by multrus's avatar multrus
Browse files

Merge branch 'cleanup_20230812' into 'main'

Cleanup most switches

See merge request !953
parents 125f882d e454fb3f
Loading
Loading
Loading
Loading
Loading
+0 −46
Original line number Diff line number Diff line
@@ -161,12 +161,8 @@ 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;

@@ -613,24 +609,17 @@ 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 )
@@ -648,7 +637,6 @@ int main(
            }
            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 ) );
@@ -1008,15 +996,11 @@ 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
     *-----------------------------------------------------------------*/
@@ -1377,13 +1361,11 @@ 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;
@@ -1396,8 +1378,6 @@ static bool parseCmdlIVAS_dec(
            }
            i += tmp;
        }
#endif
#endif
        /*-----------------------------------------------------------------*
         * Option not recognized
         *-----------------------------------------------------------------*/
@@ -1582,12 +1562,8 @@ 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" );
@@ -1828,11 +1804,7 @@ static ivas_error initOnFirstGoodFrame(
#endif
                /* Duplicate good first frame metadata to fill the beginning of stream. */
                MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta = NULL;
#ifdef FIX_470_MASA_JBM_EXT
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    return error;
@@ -2222,11 +2194,7 @@ static ivas_error decodeG192(
#endif
            {
                MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
#ifdef FIX_470_MASA_JBM_EXT
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
#else
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
@@ -2818,11 +2786,7 @@ static ivas_error decodeVoIP(
#endif
                {
                    MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
#ifdef FIX_470_MASA_JBM_EXT
                    if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 1 ) ) != IVAS_ERR_OK )
#else
                    if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
                    {
                        fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
@@ -2891,13 +2855,11 @@ cleanup:
#ifdef SUPPORT_JBM_TRACEFILE
    JbmTraceFileWriter_close( &jbmTraceWriter );
#endif
#ifdef FIX_683_JBM_CLEANUP
    MasaFileWriter_close( &masaWriter );
    for ( int16_t i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ )
    {
        IsmFileWriter_close( &ismWriters[i] );
    }
#endif

    if ( decodingFailed && error == IVAS_ERR_OK )
    {
@@ -3263,11 +3225,7 @@ static ivas_error decodeVariableSpeed(
#endif
            {
                MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
#ifdef FIX_470_MASA_JBM_EXT
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 1 ) ) != IVAS_ERR_OK )
#else
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
@@ -3451,11 +3409,7 @@ static ivas_error decodeVariableSpeed(
#endif
            {
                MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
#ifdef FIX_470_MASA_JBM_EXT
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
#else
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
+0 −40
Original line number Diff line number Diff line
@@ -175,15 +175,9 @@ typedef struct
    float lfeConfigElevation;
    bool lfeCustomRoutingEnabled;
    char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH];
#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
@@ -212,15 +206,9 @@ typedef enum
#endif
    CmdLnOptionId_referenceVectorFile,
    CmdLnOptionId_exteriorOrientationFile,
#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[] = {
@@ -360,30 +348,24 @@ static const CmdLnParser_Option cliOptions[] = {
        .matchShort = "exof",
        .description = "External orientation trajectory file for simulation of external orientations",
    },
#ifdef FIX_488_SYNC_DELAY
    {
        .id = CmdLnOptionId_syncMdDelay,
        .match = "sync_md_delay",
        .matchShort = "smd",
        .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
};


@@ -1095,11 +1077,7 @@ 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 );
@@ -1107,7 +1085,6 @@ 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 )
@@ -1121,7 +1098,6 @@ int main(
                fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", args.acousticEnvironmentId );
                exit( -1 );
            }
#endif
            renderConfig.room_acoustics.override = TRUE;
        }

@@ -1172,9 +1148,7 @@ int main(
    if ( args.inConfig.numAudioObjects > 0 )
    {
        IVAS_REND_SetTotalNumberOfObjects( hIvasRend, args.inConfig.numAudioObjects );
#ifdef FIX_488_SYNC_DELAY
        IVAS_REND_SetIsmMetadataDelay( hIvasRend, args.syncMdDelay );
#endif
    }

    IVAS_REND_LfePanMtx lfePanMatrix;
@@ -1961,12 +1935,10 @@ int main(
    }
#endif

#ifdef FIX_488_SYNC_DELAY
    if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
    {
        fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ) );
    }
#endif

    if ( !args.quietModeEnabled && args.delayCompensationEnabled )
    {
@@ -2555,20 +2527,14 @@ static CmdlnArgs defaultArgs(
    args.lfeCustomRoutingEnabled = false;
    clearString( args.inLfePanningMatrixFile );

#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;
}

@@ -2709,7 +2675,6 @@ static void parseOption(
            }
            break;

#ifdef CONTROL_METADATA_DIRECTIVITY
        case CmdLnOptionId_directivityPatternId:
            assert( numOptionValues <= RENDERER_MAX_ISM_INPUTS );
            for ( int16_t i = 0; i < numOptionValues; ++i )
@@ -2717,21 +2682,16 @@ static void parseOption(
                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 );
            /* Metadata Delay to sync with audio delay in ms */
            args->syncMdDelay = strtof( optionValues[0], NULL );
            break;
#endif
        default:
            assert( 0 && "This should be unreachable - all command line options should be explicitly handled." );
            break;
+0 −15
Original line number Diff line number Diff line
@@ -394,9 +394,7 @@ static ivas_error acelp_FCB_allocator(
    int16_t nBits_tmp;
    int16_t *p_fixed_cdk_index;
    ivas_error error;
#ifdef FIX_680_ACELP_TABLE_OMASA
    int16_t max_n;
#endif

    error = IVAS_ERR_OK;

@@ -427,7 +425,6 @@ static ivas_error acelp_FCB_allocator(
    }

    /* distribute the bit-budget equally between subframes */
#ifdef FIX_680_ACELP_TABLE_OMASA
    if ( L_subfr > L_SUBFR ) /* access fast_FCB_bits_2sfr */
    {
        max_n = 6;
@@ -444,14 +441,6 @@ static ivas_error acelp_FCB_allocator(
        }
    }
    cdbk--;
#else
    cdbk = 0;
    while ( fcb_table( cdbk, L_subfr ) * nb_subfr <= *nBits )
    {
        cdbk++;
    }
    cdbk--;
#endif
#ifdef DEBUGGING
    if ( cdbk < 0 && coder_type != TRANSITION )
    {
@@ -476,10 +465,8 @@ static ivas_error acelp_FCB_allocator(
    *nBits -= nBits_tmp * nb_subfr;

    /* try to increase the FCB bit-budget of the first subframe(s) */
#ifdef FIX_680_ACELP_TABLE_OMASA
    if ( cdbk < ACELP_FIXED_CDK_NB - 1 )
    {
#endif
        step = fcb_table( cdbk + 1, L_subfr ) - nBits_tmp;
        while ( *nBits >= step )
        {
@@ -502,9 +489,7 @@ static ivas_error acelp_FCB_allocator(
                *nBits -= step;
            }
        }
#ifdef FIX_680_ACELP_TABLE_OMASA
    }
#endif
    /* TRANSITION coding: allocate highest FCBQ bit-budget to the subframe with the glottal-shape codebook */
    if ( tc_subfr >= L_SUBFR )
    {
+0 −60
Original line number Diff line number Diff line
@@ -169,7 +169,6 @@ Word16 rate2EVSmode(
 * Re-allocate the list of indices
 *-------------------------------------------------------------------*/

#ifdef FIX_MEM_REALLOC_IND_LIST
ivas_error ind_list_realloc(
    INDICE_HANDLE old_ind_list,    /* i  : pointer to the beginning of the old buffer of indices */
    const int16_t max_num_indices, /* i  : new maximum number of allowed indices in the list */
@@ -292,57 +291,6 @@ ivas_error ind_list_realloc(
    return IVAS_ERR_OK;
}

#else

ivas_error ind_list_realloc(
    BSTR_ENC_HANDLE hBstr,        /* i/o: encoder bitstream handle                          */
    const int16_t max_num_indices /* i  : new maximum number of allowed indices in the list */
)
{
    int16_t i, ind_list_pos;
    INDICE_HANDLE new_ind_list;

    /* allocate new buffer of indices */
    if ( ( new_ind_list = (INDICE_HANDLE) malloc( max_num_indices * sizeof( Indice ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) );
    }

    /* move indices from the old list to the new list */
    for ( i = 0; i < min( max_num_indices, *( hBstr->ivas_max_num_indices ) ); i++ )
    {
        if ( ( *hBstr->ivas_ind_list_zero )[i].nb_bits > -1 )
        {
            new_ind_list[i].id = ( *hBstr->ivas_ind_list_zero )[i].id;
            new_ind_list[i].value = ( *hBstr->ivas_ind_list_zero )[i].value;
        }
        new_ind_list[i].nb_bits = ( *hBstr->ivas_ind_list_zero )[i].nb_bits;
    }

    /* reset nb_bits of all other indices to -1 */
    for ( ; i < max_num_indices; i++ )
    {
        new_ind_list[i].nb_bits = -1;
    }

    /* get the current position inside the old list */
    ind_list_pos = (int16_t) ( hBstr->ind_list - ( *hBstr->ivas_ind_list_zero ) );

    /* free the old list */
    free( ( *hBstr->ivas_ind_list_zero ) );

    /* set pointers in the new list */
    hBstr->ind_list = &new_ind_list[ind_list_pos];
    *( hBstr->ivas_ind_list_zero ) = new_ind_list;

    /* set the new maximum number of indices */
    *( hBstr->ivas_max_num_indices ) = max_num_indices;

    return IVAS_ERR_OK;
}

#endif


/*-----------------------------------------------------------------------*
 * get_ivas_max_num_indices()
@@ -1088,11 +1036,7 @@ ivas_error check_ind_list_limits(
#endif

        /* reallocate the buffer of indices with increased limit */
#ifdef FIX_MEM_REALLOC_IND_LIST
        if ( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ind_list_realloc( hBstr, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -1120,11 +1064,7 @@ ivas_error check_ind_list_limits(
#endif

                /* no available empty slot -> need to re-allocate the buffer */
#ifdef FIX_MEM_REALLOC_IND_LIST
                if ( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
#else
                if ( ( error = ind_list_realloc( hBstr, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES ) ) != IVAS_ERR_OK )
#endif
                {
                    return error;
                }
+0 −7
Original line number Diff line number Diff line
@@ -2243,13 +2243,6 @@ enum
    VOIP_RTPDUMP
};

#ifndef JBM_PARAMUPMIX
typedef enum _COV_SMOOTHING_TYPE
{
    COV_SMOOTH_SPAR,
    COV_SMOOTH_MC
} COV_SMOOTHING_TYPE;
#endif

/* clang-format on */
#endif /* CNST_H */
Loading