Commit 5bbf4a42 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into...

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into update-main-pc-from-main
parents 467f5689 31b60873
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1677,7 +1677,7 @@ ivas-pytest-enc-usan:
  before_script:
    - CLANG_NUM=3
    - DUT_DECODER_PATH=./$REF_DECODER_PATH
    - TEST_SUITE=$SHORT_TEST_SUITE_ENCODER
    - TEST_SUITE=$LONG_TEST_SUITE_ENCODER
  <<: *ivas-pytest-sanitizers-anchor
  
### jobs that test flt encoder -> fx decoder
@@ -1767,7 +1767,7 @@ ivas-pytest-dec-usan:
  before_script:
    - CLANG_NUM=3
    - DUT_ENCODER_PATH=./$REF_ENCODER_PATH
    - TEST_SUITE=$SHORT_TEST_SUITE
    - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER
  <<: *ivas-pytest-sanitizers-anchor

# ---------------------------------------------------------------
+1 −1
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@
    <ClCompile Include="..\lib_rend\lib_rend.c" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_rend\ivas_prot_rend.h" />
    <ClInclude Include="..\lib_rend\ivas_prot_rend_fx.h" />
    <ClInclude Include="..\lib_rend\ivas_rom_binauralRenderer.h" />
    <ClInclude Include="..\lib_rend\ivas_rom_binaural_crend_head.h" />
    <ClInclude Include="..\lib_rend\ivas_rom_rend.h" />
+3 −3
Original line number Diff line number Diff line
@@ -125,9 +125,6 @@
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_rend\lib_rend.h" />
    <ClInclude Include="..\lib_rend\ivas_prot_rend.h">
      <Filter>rend_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_rend\ivas_rom_rend.h">
      <Filter>rend_h</Filter>
    </ClInclude>
@@ -143,6 +140,9 @@
    <ClInclude Include="..\lib_rend\ivas_rom_TdBinauralRenderer.h">
      <Filter>rend_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_rend\ivas_prot_rend_fx.h">
      <Filter>rend_h</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <Filter Include="rend_h">
+118 −79
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@
#include "stat_dec.h"
#include "rom_com.h"
#include "mime.h"
#include "ivas_prot.h"
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
@@ -1319,33 +1318,6 @@ UWord16 get_indice_st(
}
#define WMC_TOOL_SKIP

/*-------------------------------------------------------------------*
 * reset_indices_enc()
 *
 * Reset the buffer of encoder indices
 *-------------------------------------------------------------------*/

void reset_indices_enc(
    BSTR_ENC_HANDLE hBstr,       /* i/o: encoder bitstream handle    */
    const Word16 max_num_indices /* i  : max number of indices       */
)
{
    Word16 i;

    hBstr->nb_bits_tot = 0;
    move16();
    hBstr->nb_ind_tot = 0;
    move16();

    FOR( i = 0; i < max_num_indices; i++ )
    {
        hBstr->ind_list[i].nb_bits = -1;
        move16();
    }

    return;
}

/*-------------------------------------------------------------------*
 * reset_indices_dec()
 *
@@ -1534,21 +1506,21 @@ static ivas_error write_indices_element_fx(
    {
        IF( st_ivas->hSCE[element_id]->hMetaData != NULL )
        {
            reset_indices_enc( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot );
            reset_indices_enc_fx( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot );
        }

        reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot );
        reset_indices_enc_fx( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot );
    }
    ELSE
    {
        IF( st_ivas->hCPE[element_id]->hMetaData != NULL )
        {
            reset_indices_enc( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot );
            reset_indices_enc_fx( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot );
        }

        FOR( n = 0; n < n_channels; n++ )
        {
            reset_indices_enc( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot );
            reset_indices_enc_fx( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot );
        }
    }

@@ -2060,67 +2032,84 @@ void ivas_set_bitstream_pointers(
 *-------------------------------------------------------------------*/

/*! r: 1 = reading OK, 0 = problem */
ivas_error read_indices(
ivas_error read_indices_fx(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure         */
    uint16_t bit_stream[],   /* i  : bitstream buffer               */
    UWord16 bit_stream[],    /* i  : bitstream buffer               */
    UWord16 num_bits,        /* i  : number of bits in bitstream    */
    int16_t *prev_ft_speech,
    int16_t *CNG,
    int16_t bfi /* i  : bad frame indicator            */
    Word16 *prev_ft_speech,
    Word16 *CNG,
    Word16 bfi /* i  : bad frame indicator            */
)
{
    int16_t k;
    Word16 k;
    Decoder_State **sts;
    int32_t total_brate = 0;
    int16_t curr_ft_good_sp, curr_ft_bad_sp;
    int16_t g192_sid_first, sid_upd_bad, sid_update;
    int16_t speech_bad, speech_lost;
    int16_t n;
    Word32 total_brate = 0;
    move32();
    Word16 curr_ft_good_sp, curr_ft_bad_sp;
    Word16 g192_sid_first, sid_upd_bad, sid_update;
    Word16 speech_bad, speech_lost;
    Word16 n;
    ivas_error error;

    error = IVAS_ERR_OK;
    move32();

    st_ivas->BER_detect = 0;
    move16();
    st_ivas->num_bits = num_bits;
    move16();
    sts = reset_elements( st_ivas );

    st_ivas->bfi = bfi;
    move16();

    /* convert the frame length to total bitrate */
    total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC );
    total_brate = imult3216( num_bits, FRAMES_PER_SEC );
    move32();

    /*  verify that a  valid  num bits value  is present in the G.192 file */
    /*  only AMRWB, EVS or IVAS bitrates or 0(NO DATA) are  allowed  in G.192 file frame reading  */
    if ( st_ivas->ivas_format != MONO_FORMAT )
    IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) )
    {
        k = 0;
        while ( k < SIZE_IVAS_BRATE_TBL && total_brate != ivas_brate_tbl[k] )
        move16();

        test();
        WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( total_brate, ivas_brate_tbl[k] ) )
        {
            k++;
            k = add( k, 1 );
        }

        if ( st_ivas->ivas_format == ISM_FORMAT && ( k < SIZE_IVAS_BRATE_TBL || total_brate <= SID_2k40 ) )
        test();
        test();
        test();
        test();
        IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && ( LT_16( k, SIZE_IVAS_BRATE_TBL ) || LE_32( total_brate, SID_2k40 ) ) )
        {
            st_ivas->element_mode_init = IVAS_SCE;
            move16();
        }
        else if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) && ( total_brate <= SID_2k40 ) )
        ELSE IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) && LE_32( total_brate, SID_2k40 ) )
        {
            st_ivas->element_mode_init = IVAS_SCE;
            move16();
        }
        else if ( k == SIZE_IVAS_BRATE_TBL )
        ELSE IF( EQ_16( k, SIZE_IVAS_BRATE_TBL ) )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the  G.192 frame ! Exiting ! \n", total_brate );
        }
        else
        ELSE
        {
            st_ivas->element_mode_init = -1;
            move16();
        }
    }
    else /* AMRWB or EVS */
    ELSE /* AMRWB or EVS */
    {
        st_ivas->element_mode_init = EVS_MONO;
        move16();

        if ( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */
        IF( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in  the  G.192 frame ! Exiting ! \n", total_brate );
        }
@@ -2130,47 +2119,58 @@ ivas_error read_indices(
    /* handle SID_FIRST, SID_BAD, SPEECH_LOST,  NO_DATA as properly  as possible for the ITU-T  G.192 format  */
    /* (total_brate, bfi , st_CNG)   =  rx_handler(received frame type, [previous frame type],  past CNG state, past core) */
    curr_ft_good_sp = 0;
    move16();
    curr_ft_bad_sp = 0;
    move16();

    if ( is_DTXrate( total_brate ) == 0 )
    IF( is_DTXrate( total_brate ) == 0 )
    {
        if ( st_ivas->bfi == 0 )
        IF( st_ivas->bfi == 0 )
        {
            curr_ft_good_sp = 1;
            move16();
        }
        else
        ELSE
        {
            curr_ft_bad_sp = 1;
            move16();
        }
    }

    sid_update = 0;
    move16();
    sid_upd_bad = 0;
    if ( is_SIDrate( total_brate ) == 1 )
    move16();
    IF( EQ_16( is_SIDrate( total_brate ), 1 ) )
    {
        if ( st_ivas->bfi == 0 )
        IF( st_ivas->bfi == 0 )
        {
            sid_update = 1;
            move16();
        }
        else
        ELSE
        {
            sid_upd_bad = 1; /* this frame type may happen in ETSI/3GPP CS cases, a corrupt SID frames  */
            move16();
        }
    }

    /* all zero indices/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain  */
    /* all zero indices/bits  may be a result of CS bit errors  and/or  erroneously injected by gateways or by a bad dejitter handlers */
    if ( total_brate == SID_1k75 && sid_update == 1 )
    test();
    IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) )
    {
        /* valid sid_update received, check for very risky but formally valid content  */
        int16_t sum = 0;
        for ( k = 0; k < num_bits; ++k )
        Word16 sum = 0;
        move16();
        FOR( k = 0; k < num_bits; ++k )
        {
            sum += ( bit_stream[k] == 1 ); /*   check of 35 zeroes   */
            sum = add( sum, extract_l( EQ_32( bit_stream[k], 1 ) ) ); /*   check of 35 zeroes   */
        }
        if ( sum == 0 )
        {                    /* all zeros  */
            sid_upd_bad = 1; /* initial signal as corrupt (BER likely)  */
            move16();
        }
    }

@@ -2181,14 +2181,22 @@ ivas_error read_indices(

                      Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR .
                   */
    if ( sid_upd_bad )
    IF( sid_upd_bad )
    {
        sid_upd_bad = 0;
        move16();
        total_brate = FRAME_NO_DATA; /* treat SID_BAD  as a  stolen signaling frame --> SPEECH LOST */
        move32();
    }

    g192_sid_first = 0;
    if ( st_ivas->ivas_format == MONO_FORMAT && sts[0]->core == AMR_WB_CORE && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 )
    move16();

    test();
    test();
    test();
    test();
    if ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( sts[0]->core, AMR_WB_CORE ) && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 )
    {
        g192_sid_first = 1; /*  SID_FIRST detected for previous AMRWB/AMRWBIO  active frames only  */
                            /* It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO  where:
@@ -2196,104 +2204,135 @@ ivas_error read_indices(
                                           and  a  good length 0  "SID_FIRST"(NO_DATA)   frame is sent in AMRWBIO,
                                           due to the one frame state memory in the AMRWB legacy  G.192 SID_FIRST encoding
                                         */
        move16();
    }

    speech_bad = 0;
    move16();

    test();
    if ( st_ivas->bfi != 0 && ( is_DTXrate( total_brate ) == 0 ) )
    {
        speech_bad = 1; /* initial ft assumption, CNG_state decides what to do */
        move16();
    }

    speech_lost = 0;
    move16();

    test();
    if ( total_brate == FRAME_NO_DATA && st_ivas->bfi != 0 ) /*  unsent  NO_DATA or stolen NO_DATA/signaling  frame  */
    {
        speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */
        move16();
    }

    /* Do not allow decoder to enter CNG-synthesis for  any instantly  received  GOOD+LENGTH==0  frame
                   as this frame was never transmitted, one  can not know it is good and has a a length of zero ) */
    if ( *CNG != 0 )
    IF( *CNG != 0 )
    {
        /* We were in CNG synthesis  */
        if ( curr_ft_good_sp != 0 )
        {
            /* only a good speech frame makes you leave CNG synthesis */
            *CNG = 0;
            move16();
        }
    }
    else
    ELSE
    {
        /* We were in SPEECH synthesis  */
        /* only a received/detected SID frame can make the decoder enter into CNG synthsis  */
        test();
        test();
        if ( g192_sid_first || sid_update || sid_upd_bad )
        {
            *CNG = 1;
            move16();
        }
    }

    /* set bfi, total_brate pair  for proper decoding  */
    /*  handle the  G.192   _simulated_ untransmitted NO_DATA frame,  setting  for decoder  SPEECH synthesis  */
    test();
    test();
    if ( *CNG == 0 && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 )
    {
        st_ivas->bfi = 1; /*  SPEECH PLC code will now become active as in a real system */
                          /* total_brate= 0  */
        move16();
    }

    /* handle bad/lost speech frame(and CS bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */
    if ( (
             bfi != FRAMEMODE_FUTURE &&
    test();
    test();
    test();
    test();
    IF( (
            NE_16( bfi, FRAMEMODE_FUTURE ) &&
            ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST)   --> stay in CNG */
        ( sid_upd_bad != 0 ) )                                                    /* SID_UPD_BAD              --> start CNG */
    {
        st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */
        move16();
        total_brate = FRAME_NO_DATA;
        move32();
    }

    /* update for next frame's G.192 file format's  odd SID_FIRST detection (primarily for AMRWBIO)  */
    test();
    *prev_ft_speech = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) );
    move16();

    /*   st->total brate= total_brate;   updated in a good frame below */

    for ( k = 0; k < st_ivas->nCPE; k++ )
    FOR( k = 0; k < st_ivas->nCPE; k++ )
    {
        sts = st_ivas->hCPE[k]->hCoreCoder;
        for ( n = 0; n < CPE_CHANNELS; n++ )
        FOR( n = 0; n < CPE_CHANNELS; n++ )
        {
            sts[n]->bfi = st_ivas->bfi;
            move16();
        }
    }

    for ( k = 0; k < st_ivas->nSCE; k++ )
    FOR( k = 0; k < st_ivas->nSCE; k++ )
    {
        sts = st_ivas->hSCE[k]->hCoreCoder;
        sts[0]->bfi = st_ivas->bfi;
        move16();
    }

    if ( st_ivas->bfi == 0 )
    IF( st_ivas->bfi == 0 )
    {
        /* select Mode 1 or Mode 2 */
        if ( st_ivas->ivas_format == MONO_FORMAT ) /* EVS mono */
        IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) /* EVS mono */
        {
            decoder_selectCodec( sts[0], total_brate, bit_stream[0] );
            st_ivas->hDecoderConfig->Opt_AMR_WB = sts[0]->Opt_AMR_WB;
            move16();
        }
        else /* IVAS */
        ELSE /* IVAS */
        {
            st_ivas->codec_mode = MODE1;
            move16();
            st_ivas->hDecoderConfig->Opt_AMR_WB = 0;
            move16();
        }
    }

    /* GOOD frame */
    if ( st_ivas->bfi == 0 || st_ivas->bfi == FRAMEMODE_FUTURE )
    test();
    if ( st_ivas->bfi == 0 || EQ_16( st_ivas->bfi, FRAMEMODE_FUTURE ) )
    {
        /* GOOD frame - convert ITU-T G.192 words to short values */
        st_ivas->hDecoderConfig->ivas_total_brate = total_brate;
        move32();
    }

    st_ivas->bit_stream = bit_stream;

    if ( st_ivas->ivas_format == MONO_FORMAT )
    IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
    {
        ivas_set_bitstream_pointers( st_ivas );
    }
+3 −354

File changed.

Preview size limit exceeded, changes collapsed.

Loading