Commit a867a8ba authored by TYAGIRIS's avatar TYAGIRIS
Browse files

lc3 plus unit tests changes from ISAR BASOP code

parent 14335862
Loading
Loading
Loading
Loading
Loading
+193 −40
Original line number Diff line number Diff line
@@ -38,11 +38,23 @@ the United Nations Convention on Contracts on the International Sales of Goods.
#include "isar_lc3plus_common.h"
#include "isar_lc3plus_dec.h"
#include "ivas_error_utils.h"
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
#include "lc3.h"
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
#define MAX_SAMPLES_PER_CHANNEL 960 / 4
#else
#define MAX_SAMPLES_PER_CHANNEL 960
#endif
#define DEFAULT_BPS 256000

#ifndef PCM_SAMPLE_TYPEDEF_DEFINED
#define PCM_SAMPLE_TYPEDEF_DEFINED
typedef int32_t PcmSample;
#endif

static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps )
{
    ivas_error err;
@@ -70,11 +82,11 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps )

    /* encode one frame */
    int16_t numSamplesPerChannels = config.samplerate / ( 1000000 / config.isar_frame_duration_us );
    float *pcm_in[2];
    float pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )];
    memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( float ) );
    float pcm_in_ch2[MAX_SAMPLES_PER_CHANNEL * sizeof( float )];
    memset( pcm_in_ch2, 0, numSamplesPerChannels * sizeof( float ) );
    PcmSample *pcm_in[2];
    PcmSample pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )];
    memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) );
    PcmSample pcm_in_ch2[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )];
    memset( pcm_in_ch2, 0, numSamplesPerChannels * sizeof( PcmSample ) );
    pcm_in[0] = pcm_in_ch1;
    pcm_in[1] = pcm_in_ch2;

@@ -88,6 +100,7 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps )
    uint8_t *bitstream_out = malloc( bitstreamSizePerIvasFrame );
    memset( bitstream_out, 0, bitstreamSizePerIvasFrame );

#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    int perChannelBitrate = lc3plus_enc_get_real_bitrate(encHandle->handles[0]);
    int perLc3plusFrameDataBlockOctets = encHandle->num_ftds * perChannelBitrate / 8 / (1000*1000/config.lc3plus_frame_duration_us);
    int targetOctets =  bps / 8 / (1000*1000/config.isar_frame_duration_us);
@@ -102,7 +115,12 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps )
        return err;
    }

    err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame );
    Word16 Q_in[16];
    memset(Q_in, 0, sizeof(Q_in) );
        err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame, Q_in );
#else
    err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out );
#endif
    if ( IVAS_ERR_OK != err )
    {
        ISAR_LC3PLUS_ENC_Close( &encHandle );
@@ -140,11 +158,11 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps )

    uint8_t *bitstream_in = bitstream_out;

    float *pcm_out[2];
    float pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )];
    memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( float ) );
    float pcm_out_ch2[MAX_SAMPLES_PER_CHANNEL * sizeof( float )];
    memset( pcm_out_ch2, 0, numSamplesPerChannels * sizeof( float ) );
    PcmSample *pcm_out[2];
    PcmSample pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )];
    memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) );
    PcmSample pcm_out_ch2[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )];
    memset( pcm_out_ch2, 0, numSamplesPerChannels * sizeof( PcmSample ) );
    pcm_out[0] = pcm_out_ch1;
    pcm_out[1] = pcm_out_ch2;

@@ -182,7 +200,11 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps )
static int openCloseEncoder( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    uint32_t bps = 128000;

    ISAR_LC3PLUS_ENC_HANDLE encHandle;
@@ -199,23 +221,36 @@ static int openCloseEncoder( void )
static int tryOpenEncoderWithInvalidBitrate( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    /* lc3plus max bitrate is 320000 per channel */
    uint32_t invalid_high_bps = 700000;
    uint32_t invalid_low_bps = 8;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    uint32_t limitedBitrate;
#endif
    ISAR_LC3PLUS_ENC_HANDLE encHandle;
    err = ISAR_LC3PLUS_ENC_Open( config, invalid_high_bps, &encHandle );
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    /* setting an invalid bitrate should result in a limited bitrate*/
    if ( IVAS_ERR_OK != err )
#else
    /* setting an invalid bitrate should trigger an error - which is what we expect */
    if ( IVAS_ERR_LC3PLUS_INVALID_BITRATE != err )
#endif
    {
        return 1;
    }
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    limitedBitrate = lc3plus_enc_get_real_bitrate(encHandle->handles[0]);
    if(limitedBitrate != 320000)
    {
        return 1;
    }
#endif
    ISAR_LC3PLUS_ENC_Close(&encHandle);
    err = ISAR_LC3PLUS_ENC_Open( config, invalid_low_bps, &encHandle );
    /* setting an invalid bitrate should trigger an error - which is what we expect */
@@ -230,7 +265,11 @@ static int tryOpenEncoderWithInvalidBitrate( void )
static int tryOpenEncoderWithInvalidFrameDuration( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    config.lc3plus_frame_duration_us = 1234; /*unsupported frame duration*/
    uint32_t bps = 320000;

@@ -247,7 +286,11 @@ static int tryOpenEncoderWithInvalidFrameDuration( void )
static int tryOpenEncoderWithInvalidSampleRate( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    config.samplerate = 1234; /*unsupported sample rate */
    uint32_t bps = 320000;

@@ -268,13 +311,13 @@ static int tryCallEncoderApiWithInvalidParams( void )
    int32_t bsSize;
    int32_t *invalidDelayInSamples = NULL;
    int32_t delayInSamples;
    float **invalidPcm_in = NULL;
    PcmSample **invalidPcm_in = NULL;
    void *invalidBitstream_out = NULL;

    const int16_t numSamplesPerChannels = MAX_SAMPLES_PER_CHANNEL;
    float *pcm_in[1];
    float pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )];
    memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( float ) );
    PcmSample *pcm_in[1];
    PcmSample pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )];
    memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) );
    pcm_in[0] = pcm_in_ch1;
    uint8_t bitstream_out[1200];

@@ -287,11 +330,22 @@ static int tryCallEncoderApiWithInvalidParams( void )
        return 1;
    }
    ISAR_LC3PLUS_ENC_Close( &invalidEncHandle );
    if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, invalidBitstream_out, bsSize ) )
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    Word16 Q_in[16];
    memset(Q_in, 0, sizeof(Q_in) );
            if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, invalidBitstream_out, bsSize, Q_in ) )
#else
    if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, invalidBitstream_out ) )
#endif
    {
        return 1;
    }
    if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, invalidBitstream_out, bsSize ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, bitstream_out, bsSize ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, bitstream_out, bsSize ) )
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    memset(Q_in, 0, sizeof(Q_in) );
            if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, invalidBitstream_out, bsSize, Q_in) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, bitstream_out, bsSize, Q_in ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, bitstream_out, bsSize, Q_in ) )
#else
    if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, invalidBitstream_out ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, bitstream_out ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, bitstream_out ) )
#endif
    {
        return 1;
    }
@@ -305,15 +359,15 @@ static int tryCallDecoderApiWithInvalidParams( void )

    int32_t *invalidDelayInSamples = NULL;
    int32_t delayInSamples;
    float **invalidPcm_out = NULL;
    PcmSample **invalidPcm_out = NULL;
    void *invalidBitstream_in = NULL;
    int32_t invalidBitstream_in_size = 0;
    int32_t bitstream_in_size = 100;

    const int16_t numSamplesPerChannels = MAX_SAMPLES_PER_CHANNEL;
    float *pcm_out[1];
    float pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )];
    memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( float ) );
    PcmSample *pcm_out[1];
    PcmSample pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )];
    memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) );
    pcm_out[0] = pcm_out_ch1;
    uint8_t bitstream_in[1200];

@@ -337,7 +391,11 @@ static int tryCallDecoderApiWithInvalidParams( void )
static int openCloseDecoderWithCaching( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    ISAR_LC3PLUS_DEC_HANDLE decHandle;
    err = ISAR_LC3PLUS_DEC_Open( config,
#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING
@@ -356,7 +414,11 @@ static int openCloseDecoderWithCaching( void )
static int openCloseDecoderWithoutCaching( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    ISAR_LC3PLUS_DEC_HANDLE decHandle;
    err = ISAR_LC3PLUS_DEC_Open( config,
#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING
@@ -376,7 +438,11 @@ static int openCloseDecoderWithoutCaching( void )
static int tryOpenDecoderWithInvalidFrameDuration( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    config.lc3plus_frame_duration_us = 1234; /*unsupported frame duration*/

    ISAR_LC3PLUS_DEC_HANDLE decHandle;
@@ -396,7 +462,11 @@ static int tryOpenDecoderWithInvalidFrameDuration( void )
static int tryOpenDecoderWithInvalidSampleRate( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    config.samplerate = 1234; /*unsupported sample rate*/

    ISAR_LC3PLUS_DEC_HANDLE decHandle;
@@ -416,7 +486,11 @@ static int tryOpenDecoderWithInvalidSampleRate( void )
static int encodeOneFrame( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    uint32_t bps = 128000;

    ISAR_LC3PLUS_ENC_HANDLE encHandle;
@@ -426,9 +500,9 @@ static int encodeOneFrame( void )

    int16_t numSamplesPerChannels = config.samplerate / ( 1000000 / config.isar_frame_duration_us );

    float *pcm[1];
    float pcm_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )];
    memset( pcm_ch1, 0, numSamplesPerChannels * sizeof( float ) );
    PcmSample *pcm[1];
    PcmSample pcm_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )];
    memset( pcm_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) );
    pcm[0] = pcm_ch1;

    int32_t bitstreamSizePerIvasFrame = 0;
@@ -437,7 +511,14 @@ static int encodeOneFrame( void )
        return err;
    uint8_t *bitstream_out = malloc( bitstreamSizePerIvasFrame );
    memset( bitstream_out, 0, bitstreamSizePerIvasFrame );
    err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm, bitstream_out, bitstreamSizePerIvasFrame );
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    Word16 Q_in[16];
    memset(Q_in, 0, sizeof(Q_in) );
    err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm, bitstream_out, bitstreamSizePerIvasFrame, Q_in );

#else
    err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm, bitstream_out );
#endif
    if ( IVAS_ERR_OK != err )
        return err;

@@ -450,7 +531,11 @@ static int encodeOneFrame( void )
static int encodeAndDecodeOneMonoFrame( void )
{
    ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
    uint32_t bps = 128000;

    ISAR_LC3PLUS_ENC_HANDLE encHandle;
@@ -462,9 +547,9 @@ static int encodeAndDecodeOneMonoFrame( void )

    /* encode one frame */
    int16_t numSamplesPerChannels = config.samplerate / ( 1000000 / config.isar_frame_duration_us );
    float *pcm_in[1];
    float pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )];
    memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( float ) );
    PcmSample *pcm_in[1];
    PcmSample pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )];
    memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) );
    pcm_in[0] = pcm_in_ch1;

    int32_t bitstreamSizePerIvasFrame = 0;
@@ -474,7 +559,13 @@ static int encodeAndDecodeOneMonoFrame( void )

    uint8_t *bitstream_out = malloc( bitstreamSizePerIvasFrame );
    memset( bitstream_out, 0, bitstreamSizePerIvasFrame );
    err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame );
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    Word16 Q_in[16];
    memset(Q_in, 0, sizeof(Q_in) );
            err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame, Q_in );
#else
    err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out );
#endif
    if ( IVAS_ERR_OK != err )
        return err;
    ISAR_LC3PLUS_ENC_Close( &encHandle );
@@ -493,9 +584,9 @@ static int encodeAndDecodeOneMonoFrame( void )

    uint8_t *bitstream_in = bitstream_out;

    float *pcm_out[1];
    float pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )];
    memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( float ) );
    PcmSample *pcm_out[1];
    PcmSample pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )];
    memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) );
    pcm_out[0] = pcm_out_ch1;
    err = ISAR_LC3PLUS_DEC_Decode( decHandle, bitstream_in, bitstreamSizePerIvasFrame, pcm_out );
    if ( IVAS_ERR_OK != err )
@@ -517,7 +608,11 @@ static int encodeAndDecodeOneMonoFrame( void )

static int encodeAndDecodeOneStereoFrameIvas20msLc3plus10ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}

@@ -535,88 +630,140 @@ static int encodeAndDecodeOneStereoFrameIvas20msLc3plus10ms_16kHz( void )

static int encodeAndDecodeOneStereoFrameIvas5msLc3plus5ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}

static int encodeAndDecodeOneStereoFrameIvas10msLc3plus10ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}

static int encodeAndDecodeOneMonoFrameIvas20msLc3plus10ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 1, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}

static int encodeAndDecodeOneMonoFrameIvas5msLc3plus5ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 1, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}

static int encodeAndDecodeOneStereoFrameIvas20msLc3plus2_5ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 2.5 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 2.5 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}


static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_80kbpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, config.channels * 82*1000 );
}

static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_96kbpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, config.channels * 98*1000 );
}

#ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_126kbpsPerChannel( void )
#else
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_124kbpsPerChannel( void )
#endif
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, config.channels * 126*1000 );
}

#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_800kbpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, config.channels * 800*1000 );
}
#endif

static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_204800bpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, config.channels * 204800 );
}

static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_205600bpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, config.channels * 205600 );
}

static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_206400bpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, config.channels * 206400 );
}

static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_207200bpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
    LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
    return encodeAndDecodeOneStereoFrame( config, config.channels * 207200 );
}

#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
#include "ivas_lc3plus_unit_test_payload_format.c"
#endif

int main(
    int argc,
@@ -691,16 +838,14 @@ int main(
    ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_96kbpsPerChannel();
    if ( ret != 0 )
        return 1;
#ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6
    ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_126kbpsPerChannel();
#else
    ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_124kbpsPerChannel();
#endif
    if ( ret != 0 )
        return 1;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_800kbpsPerChannel();
    if ( ret != 0 )
        return 1;
#endif
    /* start configs around the FDL threshold */
    ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_204800bpsPerChannel();
    if ( ret != 0 )
@@ -715,8 +860,16 @@ int main(
    if ( ret != 0 )
        return 1;
    /* end configs around the FDL threshold */
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
    ret = run_all_payload_tests();
    if ( ret != 0 )
        return 1;
#endif
    return 0;
}
#else
int main( void )
{
    return EXIT_SUCCESS;
}
#endif /* SPLIT_REND_WITH_HEAD_ROT */
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ the United Nations Convention on Contracts on the International Sales of Goods.
#include "isar_lc3plus_common.h"
#include "options.h"

#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS

/* included by ivas_lc3plus_unit_test.c */

@@ -447,3 +448,4 @@ static int run_all_payload_tests( void )
    }
    return 0;
}
#endif
+191 −0

File added.

Preview size limit exceeded, changes collapsed.