Commit 1ff4ddda authored by thomas dettbarn's avatar thomas dettbarn
Browse files

the apps/ambi_converter had uninitliazed memory due to not reading enough...

the apps/ambi_converter had uninitliazed memory due to not reading enough samples from the input file.
parent 31241964
Loading
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ int main( int argc, char *argv[] )
    int16_t samples[L_FRAME48k * AMBI_MAX_CHANNELS];
    int16_t order = 0;
    int16_t numChannels;
    const char *name_conventions[6]= { "ACN-SN3D", "ACN-N3D", "FuMa-MaxN", "FuMa-FuMa", "SID-SN3D", "SID-N3D" };

    AMBI_FMT in_format, out_format;

@@ -97,8 +98,12 @@ int main( int argc, char *argv[] )
    fileName_out = argv[2];
    in_format = atoi( argv[3] );
    out_format = atoi( argv[4] );

    printf( "In %d, Out: %d\n", in_format, out_format );
    if ( in_format < 0 || out_format < 0 || in_format > 5 || out_format > 5 )
    {
        printf( "input_convention and output convention must be an integer number in [0,5]\n" );
        return -1;
    }
    printf( "In: [%s], Out: [%s]\n",name_conventions[in_format], name_conventions[out_format] );

    wavFile_in = OpenWav( fileName_in, &samplingRate, &numChannels, &samplesInFile, &bps );
    if ( !wavFile_in )
@@ -117,6 +122,7 @@ int main( int argc, char *argv[] )
    order = (int16_t) sqrtf( numChannels ) - 1;
    assert( order > 0 && order <= 3 );

    numSamples = L_FRAME48k * numChannels;
    while ( ReadWavShort( wavFile_in, samples, numSamples, &numSamplesRead32 ) == __TWI_SUCCESS )
    {
        int32_t err = 0;
@@ -126,7 +132,7 @@ int main( int argc, char *argv[] )
            break;
        }

        for ( uint16_t i = 0; i < numSamplesRead32; i++ )
        for ( uint16_t i = 0; i < (uint16_t)numSamplesRead32 / numChannels; i++ )
        {
            for ( int16_t j = 0; j < numChannels; j++ )
            {
@@ -141,7 +147,7 @@ int main( int argc, char *argv[] )
        }


        for ( uint16_t i = 0; i < numSamplesRead32; i++ )
        for ( uint16_t i = 0; i < (uint16_t)numSamplesRead32 / numChannels; i++ )
        {
            for ( int16_t j = 0; j < numChannels; j++ )
            {