Commit b3e6e7ff authored by emerit's avatar emerit
Browse files

correction lfe handling in MC to binaural case, bugs fix

parent 9d5d5c46
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -4,18 +4,20 @@
IVAS_cod
IVAS_dec
IVAS_rend
IVAS_crend_unit_test
obj/
*.a
*.o
*.P

# default CMake
build/**/*
build*/**/*

# Compiler output VS2017
IVAS_cod.exe
IVAS_dec.exe
IVAS_rend.exe
IVAS_crend_unit_test.exe
*.user
.vs/
Debug_*/
@@ -50,3 +52,6 @@ scripts/tests/ref/
__pycache__/
*.py[cod]
*$py.class

#history
.history/
+8 −0
Original line number Diff line number Diff line
@@ -152,6 +152,13 @@ file(GLOB libUtilSrcs "lib_util/*.c")
file(GLOB libUtilHeaders "lib_util/*.h")
add_library(lib_util ${libUtilSrcs} ${libUtilHeaders})

file(GLOB libCRendSrcs "scripts/ivas_pytests/tests/unit_tests/crend/*.c")
file(GLOB libCRendHeaders "scripts/ivas_pytests/tests/unit_tests/crend/*.h")
message(${libCRendSrcs})
message(${libCRendHeaders})
add_executable(IVAS_crend_unit_test ${libCRendSrcs} ${libCRendHeaders})
target_link_libraries(IVAS_crend_unit_test lib_dec lib_rend lib_util lib_com lib_debug)

add_executable(IVAS_cod apps/encoder.c)
target_link_libraries(IVAS_cod lib_enc lib_util)
if(WIN32)
@@ -174,4 +181,5 @@ if(COPY_EXECUTABLES_TO_ROOT)
  add_custom_command(TARGET IVAS_cod POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:IVAS_cod>" "${CMAKE_CURRENT_SOURCE_DIR}/")
  add_custom_command(TARGET IVAS_dec POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:IVAS_dec>" "${CMAKE_CURRENT_SOURCE_DIR}/")
  add_custom_command(TARGET IVAS_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:IVAS_rend>" "${CMAKE_CURRENT_SOURCE_DIR}/")
  add_custom_command(TARGET IVAS_crend_unit_test POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:IVAS_crend_unit_test>" "${CMAKE_CURRENT_SOURCE_DIR}/")
endif()
 No newline at end of file
+25 −6
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ typedef struct CmdlnArgs
    bool neverDropLfe;             /* flag */
    bool delayCompensationEnabled; /* flag */
    bool quietModeEnabled;
    bool lpLfeEnabled;
} CmdlnArgs;

static int8_t setInConfig(
@@ -319,7 +320,7 @@ int32_t main( int32_t argc, char **argv )
    AudioFileReader *audioReader = NULL;
    AudioFileWriter *audioWriter;
    int16_t inBufferSize;
    int32_t outBufferSize;
    int16_t outBufferSize;
    int16_t *inpInt16Buffer;
    float *inFloatBuffer;
    int16_t *outInt16Buffer;
@@ -414,7 +415,7 @@ int32_t main( int32_t argc, char **argv )
    }

    /* === Configure === */
    if ( ( error = IVAS_REND_Configure( hIvasRend, args.inConfig, args.outConfig, args.sampleRate, args.trajectoryFile[0] != '\0', args.renderConfigFile[0] != '\0' ) ) != IVAS_ERR_OK )
    if ( ( error = IVAS_REND_Configure( hIvasRend, args.inConfig, args.outConfig, args.sampleRate, args.trajectoryFile[0] != '\0', args.renderConfigFile[0] != '\0', args.lpLfeEnabled ) ) != IVAS_ERR_OK )
    {
        exit( -1 );
    }
@@ -680,7 +681,7 @@ static int8_t setInConfig( AUDIO_CONFIG input_config, IVAS_REND_InputConfig *inC
        case AUDIO_CONFIG_ISM2:
        case AUDIO_CONFIG_ISM3:
        case AUDIO_CONFIG_ISM4:
            inConfig->numAudioObjects = input_config - AUDIO_CONFIG_ISM1 + 1; /* TODO(sgi): Don't do arithemtic on enums, find a better way */
            inConfig->numAudioObjects = (uint16_t)input_config - (uint16_t)AUDIO_CONFIG_ISM1 + 1; /* TODO(sgi): Don't do arithemtic on enums, find a better way */
            positionProvider->numObjects = inConfig->numAudioObjects;

            for ( i = 0; i < inConfig->numAudioObjects; ++i )
@@ -1144,6 +1145,7 @@ static CmdlnArgs defaultArgs( void )
    args.neverDropLfe = false;
    args.delayCompensationEnabled = true;
    args.quietModeEnabled = false;
    args.lpLfeEnabled = false;

    for ( size_t i = 0; i < RENDERER_MAX_ISM_INPUTS; i++ )
    {
@@ -1168,7 +1170,8 @@ typedef enum
    CmdLnOptionId_neverDropLfe,
    CmdLnOptionId_noDelayCmp,
    CmdLnOptionId_quietModeEnabled,
    CmdLnOptionId_inputMetadata,
    CmdLnOptionId_lpLfeEnabled,
//    CmdLnOptionId_inputMetadata,
} CmdLnOptionId;

static void parseOption( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct )
@@ -1245,6 +1248,10 @@ static void parseOption( int32_t optionId, char **optionValues, int16_t numOptio
            assert( numOptionValues == 0 );
            args->quietModeEnabled = true;
            break;
        case CmdLnOptionId_lpLfeEnabled:
            assert( numOptionValues == 0 );
            args->lpLfeEnabled = true;
            break;            
        default:
            /* Unreachable */
            break;
@@ -1346,6 +1353,18 @@ static CmdlnArgs parseCmdlnArgs( int32_t argc, char **argv )
            .matchShort = "q",
            .description = "[flag] Limit printouts to terminal",
        },
        {
            .id = CmdLnOptionId_lpLfeEnabled,
            .match = "lowpass_lfe",
            .matchShort = "lp_lfe",
            .description = "[flag] Apply lowpass filter to lfe",
        },
        // { /* TODO(sgi): move metadata file paths from input_format to this separate flag */
        //     .id = CmdLnOptionId_inputMetadata,
        //     .match = "input_metadata",
        //     .matchShort = "im",
        //     .description = "Space-separated list of path to metadata files for ISM or MASA inputs",
        // },        
    };

    CmdlnArgs parsedArgs = defaultArgs();
@@ -1529,7 +1548,7 @@ static void splitConfigFile( const char *mdfFilePath,
        fprintf( stderr, "Error reading metadata\n" );
        exit( -1 );
    }
    *wavFileNameLength = strlen( wavFileName );
    *wavFileNameLength = (uint32_t)strlen( wavFileName );

    mdlength = bufferlength - currentPositionIdxs;
    /* "+1" for null termination */
@@ -2013,7 +2032,7 @@ void parseConfigFile( char *path, char *audioFilePath, IVAS_REND_InputConfig *in

static void convert_backslash( char *str )
{
    int i, len;
    size_t i, len;

    /* check that all backslashes are correct on the given platform */
    len = strlen( str );
+2 −0
Original line number Diff line number Diff line
@@ -196,6 +196,8 @@ typedef enum

#define IVAS_MAX_SBA_ORDER                      3                           /* Maximum supported Ambisonics order */

#define IVAS_LIMITER_THRESHOLD      32729 /* -0.01 dBFS */
#define IVAS_LIMITER_ATTACK_SECONDS 0.005f

/*----------------------------------------------------------------------------------*
 * IVAS Bitrates
+4 −8
Original line number Diff line number Diff line
@@ -43,10 +43,6 @@
 * Local constants
 *----------------------------------------------------------------------------------*/

#define LIMITER_THRESHOLD      32729 /* -0.01 dBFS */
#define LIMITER_ATTACK_SECONDS 0.005f


/*-------------------------------------------------------------------*
 * detect_strong_saturations()
 *
@@ -71,11 +67,11 @@ static int16_t detect_strong_saturations(
        *strong_saturation_cnt = 50;
        apply_strong_limiting = 1;
    }
    else if ( max_val > 3 * LIMITER_THRESHOLD && *strong_saturation_cnt > 0 )
    else if ( max_val > 3 * IVAS_LIMITER_THRESHOLD && *strong_saturation_cnt > 0 )
    {
        apply_strong_limiting = 1;
    }
    else if ( max_val > 10 * LIMITER_THRESHOLD )
    else if ( max_val > 10 * IVAS_LIMITER_THRESHOLD )
    {
        *strong_saturation_cnt += 20;
        *strong_saturation_cnt = min( *strong_saturation_cnt, 50 );
@@ -130,7 +126,7 @@ IVAS_LIMITER_HANDLE ivas_limiter_open(
    hLimiter->sampling_rate = sampling_rate;
    hLimiter->gain = 1.f;
    hLimiter->release_heuristic = 0.f;
    hLimiter->attack_constant = powf( 0.01f, 1.0f / ( LIMITER_ATTACK_SECONDS * sampling_rate ) );
    hLimiter->attack_constant = powf( 0.01f, 1.0f / ( IVAS_LIMITER_ATTACK_SECONDS * sampling_rate ) );
    hLimiter->strong_saturation_count = 0;
#ifdef DEBUGGING
    hLimiter->cnt_frames_limited = 0;
@@ -202,7 +198,7 @@ void ivas_limiter_dec(
        channels[c] = output[c];
    }

    limiter_process( hLimiter, output_frame, LIMITER_THRESHOLD, BER_detect, &hLimiter->strong_saturation_count );
    limiter_process( hLimiter, output_frame, IVAS_LIMITER_THRESHOLD, BER_detect, &hLimiter->strong_saturation_count );

    return;
}
Loading