Loading apps/renderer.c +76 −29 Original line number Diff line number Diff line Loading @@ -293,6 +293,17 @@ static void convert_backslash( static void remove_cr( char *str ); static void convertInputBuffer( const int16_t *intBuffer, int32_t numIntSamplesPerChannel, /* Number of samples per channel in the int buffer */ int32_t numFloatSamplesPerChannel, /* Per-channel length of the float buffer. If > numIntSamplesPerChannel, remaining samples will be set to 0. */ int32_t numChannels, float *floatBuffer ); static void convertOutputBuffer( const float *floatBuffer, int32_t numSamplesPerChannel, int32_t numChannels, int16_t *intBuffer ); /* ============================================================================ */ Loading Loading @@ -475,10 +486,8 @@ int32_t main( int32_t argc, char **argv ) while ( 1 ) { int32_t chnl, smpl; int32_t num_in_channels; num_in_channels = inBuffer.config.numChannels; i = 0; /* Read the input data */ if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK ) Loading @@ -494,22 +503,7 @@ int32_t main( int32_t argc, char **argv ) } /* Convert from int to float and from interleaved to packed */ for ( smpl = 0; smpl < frameSize_smpls; ++smpl ) { for ( chnl = 0; chnl < num_in_channels; ++chnl ) { if ( i < numSamplesRead ) { inFloatBuffer[chnl * frameSize_smpls + smpl] = (float) inpInt16Buffer[i] / INT16_MAX; } else { inFloatBuffer[chnl * frameSize_smpls + smpl] = 0.f; } ++i; } } convertInputBuffer( inpInt16Buffer, numSamplesRead, frameSize_smpls, num_in_channels, inFloatBuffer ); if ( masaReader != NULL ) { Loading Loading @@ -537,18 +531,10 @@ int32_t main( int32_t argc, char **argv ) int32_t num_out_channels; num_out_channels = outBuffer.config.numChannels; i = 0; /* Convert from float to int and from packed to interleaved */ for ( smpl = 0; smpl < frameSize_smpls; ++smpl ) { for ( chnl = 0; chnl < num_out_channels; ++chnl ) { outInt16Buffer[i] = (int16_t) ( outFloatBuffer[chnl * frameSize_smpls + smpl] * INT16_MAX ); ++i; } } /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ convertOutputBuffer( outFloatBuffer, frameSize_smpls, num_out_channels, outInt16Buffer ); /* TODO tmu : delay compensation not finalized yet */ if ( delayNumSamples == -1 ) Loading Loading @@ -2064,3 +2050,64 @@ static void remove_cr( char *str ) return; } /*--------------------------------------------------------------------------* * convertInputBuffer() * * Convert input buffer from WAV/PCM file (int16_t, interleaved) to a format * accepted by the renderer (float, packed) *--------------------------------------------------------------------------*/ static void convertInputBuffer( const int16_t *intBuffer, int32_t numIntSamplesPerChannel, int32_t numFloatSamplesPerChannel, int32_t numChannels, float *floatBuffer ) { int32_t chnl, smpl, i; i = 0; for ( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) { for ( chnl = 0; chnl < numChannels; ++chnl ) { if ( i < numIntSamplesPerChannel ) { floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = (float) intBuffer[i]; } else { floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = 0.f; } ++i; } } } /*--------------------------------------------------------------------------* * convertOutputBuffer() * * Convert output buffer from the renderer (float, packed) to a format ready * for writing to a WAV/PCM file (int16_t, interleaved) *--------------------------------------------------------------------------*/ static void convertOutputBuffer( const float *floatBuffer, int32_t numSamplesPerChannel, int32_t numChannels, int16_t *intBuffer ) { int32_t chnl, smpl, i; i = 0; for ( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) { for ( chnl = 0; chnl < numChannels; ++chnl ) { intBuffer[i] = (int16_t) roundf( floatBuffer[chnl * numSamplesPerChannel + smpl] ); ++i; } } } lib_rend/lib_rend.c +2 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ #include <string.h> #define LIMITER_THRESHOLD 0.9988493699f /* -0.01 dBFS */ #define LIMITER_THRESHOLD ( 0.9988493699f * INT16_MAX ) /* -0.01 dBFS */ /* Due to API of some rendering methods, the renderer has to use the decoder struct. Only struct members relevant for rendering will be initialized, therefore typedef as "dummy" decoder struct */ Loading Loading @@ -3136,7 +3136,7 @@ static int32_t ivas_limiter_renderer( } #endif output[i] = min( max( -1.0f, output[i] ), 1.0f ); output[i] = min( max( INT16_MIN, output[i] ), INT16_MAX ); } return numClipping; Loading Loading
apps/renderer.c +76 −29 Original line number Diff line number Diff line Loading @@ -293,6 +293,17 @@ static void convert_backslash( static void remove_cr( char *str ); static void convertInputBuffer( const int16_t *intBuffer, int32_t numIntSamplesPerChannel, /* Number of samples per channel in the int buffer */ int32_t numFloatSamplesPerChannel, /* Per-channel length of the float buffer. If > numIntSamplesPerChannel, remaining samples will be set to 0. */ int32_t numChannels, float *floatBuffer ); static void convertOutputBuffer( const float *floatBuffer, int32_t numSamplesPerChannel, int32_t numChannels, int16_t *intBuffer ); /* ============================================================================ */ Loading Loading @@ -475,10 +486,8 @@ int32_t main( int32_t argc, char **argv ) while ( 1 ) { int32_t chnl, smpl; int32_t num_in_channels; num_in_channels = inBuffer.config.numChannels; i = 0; /* Read the input data */ if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK ) Loading @@ -494,22 +503,7 @@ int32_t main( int32_t argc, char **argv ) } /* Convert from int to float and from interleaved to packed */ for ( smpl = 0; smpl < frameSize_smpls; ++smpl ) { for ( chnl = 0; chnl < num_in_channels; ++chnl ) { if ( i < numSamplesRead ) { inFloatBuffer[chnl * frameSize_smpls + smpl] = (float) inpInt16Buffer[i] / INT16_MAX; } else { inFloatBuffer[chnl * frameSize_smpls + smpl] = 0.f; } ++i; } } convertInputBuffer( inpInt16Buffer, numSamplesRead, frameSize_smpls, num_in_channels, inFloatBuffer ); if ( masaReader != NULL ) { Loading Loading @@ -537,18 +531,10 @@ int32_t main( int32_t argc, char **argv ) int32_t num_out_channels; num_out_channels = outBuffer.config.numChannels; i = 0; /* Convert from float to int and from packed to interleaved */ for ( smpl = 0; smpl < frameSize_smpls; ++smpl ) { for ( chnl = 0; chnl < num_out_channels; ++chnl ) { outInt16Buffer[i] = (int16_t) ( outFloatBuffer[chnl * frameSize_smpls + smpl] * INT16_MAX ); ++i; } } /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ convertOutputBuffer( outFloatBuffer, frameSize_smpls, num_out_channels, outInt16Buffer ); /* TODO tmu : delay compensation not finalized yet */ if ( delayNumSamples == -1 ) Loading Loading @@ -2064,3 +2050,64 @@ static void remove_cr( char *str ) return; } /*--------------------------------------------------------------------------* * convertInputBuffer() * * Convert input buffer from WAV/PCM file (int16_t, interleaved) to a format * accepted by the renderer (float, packed) *--------------------------------------------------------------------------*/ static void convertInputBuffer( const int16_t *intBuffer, int32_t numIntSamplesPerChannel, int32_t numFloatSamplesPerChannel, int32_t numChannels, float *floatBuffer ) { int32_t chnl, smpl, i; i = 0; for ( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) { for ( chnl = 0; chnl < numChannels; ++chnl ) { if ( i < numIntSamplesPerChannel ) { floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = (float) intBuffer[i]; } else { floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = 0.f; } ++i; } } } /*--------------------------------------------------------------------------* * convertOutputBuffer() * * Convert output buffer from the renderer (float, packed) to a format ready * for writing to a WAV/PCM file (int16_t, interleaved) *--------------------------------------------------------------------------*/ static void convertOutputBuffer( const float *floatBuffer, int32_t numSamplesPerChannel, int32_t numChannels, int16_t *intBuffer ) { int32_t chnl, smpl, i; i = 0; for ( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) { for ( chnl = 0; chnl < numChannels; ++chnl ) { intBuffer[i] = (int16_t) roundf( floatBuffer[chnl * numSamplesPerChannel + smpl] ); ++i; } } }
lib_rend/lib_rend.c +2 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ #include <string.h> #define LIMITER_THRESHOLD 0.9988493699f /* -0.01 dBFS */ #define LIMITER_THRESHOLD ( 0.9988493699f * INT16_MAX ) /* -0.01 dBFS */ /* Due to API of some rendering methods, the renderer has to use the decoder struct. Only struct members relevant for rendering will be initialized, therefore typedef as "dummy" decoder struct */ Loading Loading @@ -3136,7 +3136,7 @@ static int32_t ivas_limiter_renderer( } #endif output[i] = min( max( -1.0f, output[i] ), 1.0f ); output[i] = min( max( INT16_MIN, output[i] ), INT16_MAX ); } return numClipping; Loading