Commit 7efb6485 authored by multrus's avatar multrus
Browse files

Merge branch 'main' into new-osba-baseline

parents dad8a6d9 fe5eac0c
Loading
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -420,8 +420,6 @@ static char *readNextMetadataChunk( char *line, const char *delimiter );

static void parseUint8( const char *line, uint8_t *ret );

static void parseUint16( const char *line, uint16_t *ret );

static int8_t parseUint32( const char *line, uint32_t *ret );

static int8_t parseInt32( const char *line, int32_t *ret );
+0 −191
Original line number Diff line number Diff line
@@ -3306,197 +3306,6 @@ ivas_error read_indices(
    return error;
}

/*-------------------------------------------------------------------*
 * read_indices_mime_handle_dtx()
 *
 * Handle DTX for MIME and RTP_DUMP decoding.
 * Returns the actual total_brate.
 *-------------------------------------------------------------------*/

static Word32 read_indices_mime_handle_dtx(
    Decoder_State *st,
    int16_t *CNG,
    const Word16 isAMRWB_IOmode,
    const Word16 core_mode,
    Word32 total_brate,
    const Word16 sti,
    const Word16 speech_lost,
    Word16 no_data,
    const Word16 amrwb_rfc4867_flag )
{
    Word16 curr_ft_good_sp = 0;
    Word16 speech_bad = 0;
    Word16 sid_upd_bad = 0, sid_update = 0;
    Word16 amrwb_sid_first = 0; /* derived from sti  SID_FIRST indicator in AMRWB payload */

    /* keep st->CNG , st_bfi and total_brate  updated  for proper synthesis in DTX and FER  */
    if ( total_brate > SID_2k40 )
    {
        if ( st->bfi != 1 ) /* so  far derived from q bit in AMRWB/AMRWBIO cases   */
        {
            curr_ft_good_sp = 1;
        }
    }

    /* handle q_bit and  lost_sp  clash ,  assume worst case  */
    if ( speech_lost != 0 ) /*  overrides  a good q_bit */
    {
        curr_ft_good_sp = 0;
        st->bfi = 1; /* override  qbit */
    }

    /* now_bfi_fx has been set based on q_bit and ToC fields */

    /* SID_UPDATE check */
    if ( total_brate == SID_1k75 || total_brate == SID_2k40 )
    {
        if ( st->bfi == 0 )
        {
            /* typically from q bit  */
            sid_update = 1;
        }
        else
        {
            sid_upd_bad = 1; /* may happen in saving from e.g. a CS-connection */
        }
    }

    if ( isAMRWB_IOmode && total_brate == 0 && sti == 0 )
    {
        if ( st->bfi )
        {
            sid_upd_bad = 1; /*  corrupt sid_first, signaled as bad SID  */
        }
        else
        {
            amrwb_sid_first = 1; /* 1-sti  */
        }
    }

    if ( sid_upd_bad != 0 && ( ( isAMRWB_IOmode != 0 && st->Opt_AMR_WB == 0 ) || /* switch to    AMRWBIO */
                               ( isAMRWB_IOmode != 1 && st->Opt_AMR_WB == 1 )    /* switch from  AMRWBIO */
                               ) )
    {
        /* do not allow a normal start of  CNG synthesis if this SID(with BER or FER) is a switch to/from AMRWBIO  */
        sid_upd_bad = 0; /* revert this detection due to AMRWBIO/EVS mode switch */
        total_brate = 0;
        no_data = 1;
        assert( st->bfi == 1 ); /* bfi stays 1 */
    }

    if ( total_brate > SID_2k40 && st->bfi == 1 ) /* typically from q bit  */
    {
        speech_bad = 1; /* initial assumption,   CNG synt state decides what to actually do */
    }
    /* all frame types decoded */

    /*    update CNG synthesis state */
    /*    Decoder can only  enter CNG-synthesis  for  CNG frame types (sid_upd,  sid_bad, sid_first) */
    if ( *CNG != 0 )
    {
        /* We were in CNG synthesis  */
        if ( curr_ft_good_sp != 0 )
        {
            /* only a good speech frame makes decoder leave CNG synthesis */
            *CNG = 0;
        }
    }
    else
    {
        /*   We were in SPEECH synthesis  */
        /*   only a received SID frame can make the decoder enter into CNG synthesis  */
        if ( amrwb_sid_first || sid_update || sid_upd_bad )
        {
            *CNG = 1;
        }
    }

    /* Now modify bfi flag for the  decoder's  SPEECH/CNG synthesis logic  */
    /*   in SPEECH synthesis, make sure to activate speech PLC for a received NO_DATA frame,
                     no_data frames may be injected by the network or by the dejitter buffer   */
    /*   modify bfi_flag to stay/move into the correct decoder PLC section  */
    if ( ( *CNG == 0 ) && ( no_data != 0 ) )
    {
        /* treat NO_DATA received in speech synthesis as  SP_LOST frames, SPEECH PLC code will now become active */
        st->bfi = 1;
        /* total_brate= 0;    always zero for no_data */
    }

    /* in CNG  */
    /* handle bad speech frame(and bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi)  */
    if ( ( *CNG != 0 && ( speech_bad || speech_lost || no_data ) ) || /* SP_BAD or SPEECH_LOST)   --> stay in CNG */
         sid_upd_bad )                                                /* SID_UPD_BAD               --> start/stay  CNG   */
    {
        st->bfi = 0;     /* mark as good to not start speech PLC */
        total_brate = 0; /* this zeroing needed  for  speech_bad, sid_bad frames */
    }


    /*  now  bfi, total_brate are set by RX-DTX handler::
                    bfi==0, total_brate!=0    CNG or speech pending  bitrate
                    bfi==0, total_brate==0    CNG will continue or start(sid_first, sid_bad)
                    bfi==1, total_brate!=0    speech PLC
                    bfi==1, total_brate==0 ,  speech PLC */

    /*  handle available AMRWB/AMRWBIO MIME header ToC rate-info at startup   */
    if ( ( st->bfi == 1 && st->ini_frame == 0 ) && ( ( amrwb_rfc4867_flag != 0 ) || ( amrwb_rfc4867_flag == 0 && isAMRWB_IOmode != 0 ) ) ) /*AMRWB ToC */
    {
        Word32 init_rate;

        init_rate = total_brate; /* default , may have been modified from original ToC value */
        if ( speech_lost != 0 || no_data != 0 )
        {
            init_rate = ACELP_12k65; /* make sure the decoder starts up in a selected AMRWB mode */
        }
        else if ( speech_bad != 0 )
        {
            init_rate = AMRWB_IOmode2rate[core_mode]; /* read from from ToC */
        }
        st->total_brate = init_rate; /* not updated on bfi as  decoderSelectCodec is not called below */
        st->core_brate = init_rate;
    }

    return total_brate;
}


/*-------------------------------------------------------------------*
 * read_indices_mime_handle_sti_and_all_zero_bits()
 *
 * Handle STI and frames with all zero bits for MIME and RTP_DUMP decoding.
 *-------------------------------------------------------------------*/
static void read_indices_mime_handle_sti_and_all_zero_bits(
    Decoder_State *st,
    Word32 *total_brate,
    Word16 sti )
{
    Word16 k, sum = 0;

    if ( sti == 0 )
    {
        *total_brate = 0; /* signal received SID_FIRST as a good frame with no bits */
        for ( k = 0; k < 35; k++ )
        {
            st->bfi |= st->bit_stream[k]; /* partity check of 35 zeroes,  any single 1 gives BFI */
        }
    }
    /* all zero bit SID_update results in a valid LP filter with extremely high LP-filter-gain  */
    /* all zero bits signal may be a result of CS bit errors  or erronesouly injected by gateways or bad dejitter handlers */
    if ( sti == 1 )
    { /*sid_update received */
        for ( k = 0; k < 35; k++ )
        {
            sum += st->bit_stream[k]; /*   check of 35 zeroes   */
        }

        if ( sum == 0 )
        {
            st->bfi = 1; /* eventually becomes SID_UPD_BAD */
        }
    }
}


/*-------------------------------------------------------------------*
 * get_rfFrameType()
 *
+45 −0
Original line number Diff line number Diff line
@@ -5039,7 +5039,13 @@ void ivas_masa_enc_reconfigure(
);

ivas_error ivas_masa_dec_reconfigure(
#ifdef MASA_AND_OBJECTS
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                          */
    uint16_t *nSamplesRendered,                                 /* o  : number of samples flushed from the previous frame (JBM) */
    int16_t *data                                               /* o  : flushed PCM samples                             */
#else
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                          */
#endif
);

ivas_error ivas_masa_encode(
@@ -5788,7 +5794,13 @@ ivas_error ivas_omasa_enc_config(
);

ivas_error ivas_omasa_dec_config(
#ifdef MASA_AND_OBJECTS
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    uint16_t *nSamplesRendered,                                 /* o  : number of samples flushed from the previous frame (JBM) */
    int16_t *data                                               /* o  : flushed PCM samples                     */
#else
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
#endif
);

void ivas_omasa_set_config(
@@ -5900,12 +5912,34 @@ ivas_error ivas_omasa_dirac_td_binaural(
    const int16_t output_frame                                  /* i  : output frame length per channel         */
);

#ifdef MASA_AND_OBJECTS
ivas_error ivas_omasa_dirac_td_binaural_jbm(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                      */
    const uint16_t nSamplesAsked,                               /* i  : number of samples requested              */
    uint16_t *nSamplesRendered,                                 /* o  : number of samples rendered               */
    uint16_t *nSamplesAvailable,                                /* o  : number of samples still to render        */
    const int16_t nchan_transport,                              /* i  : number of transport channels             */
    float *output_f[]                                           /* o  : rendered time signal                     */
);
#endif

void ivas_omasa_dirac_rend(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    float output[][L_FRAME48k],                                 /* o  : output synthesis signal                 */
    const int16_t output_frame                                  /* i  : output frame length per channel         */
);

#ifdef MASA_AND_OBJECTS
void ivas_omasa_dirac_rend_jbm(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                      */
    const uint16_t nSamplesAsked,                               /* i  : number of samples requested              */
    uint16_t *nSamplesRendered,                                 /* o  : number of samples rendered               */
    uint16_t *nSamplesAvailable,                                /* o  : number of samples still to render        */
    const int16_t nchan_transport,                              /* i  : number of transport channels             */
    float *output_f[]                                           /* o  : rendered time signal                     */
);
#endif

void ivas_omasa_preProcessStereoTransportsForMovedObjects(
    Decoder_Struct *st_ivas,
    float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
@@ -5928,6 +5962,17 @@ void ivas_omasa_separate_object_render(
    float output_f[][L_FRAME48k],                               /* i/o: output signals                          */
    const int16_t output_frame                                  /* i  : output frame length per channel         */
);

#ifdef MASA_AND_OBJECTS
void ivas_omasa_separate_object_render_jbm(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                   */
    const uint16_t nSamplesRendered,                            /* i  : number of samples rendered               */
    float *output_f[],                                          /* o  : rendered time signal                     */
    const int16_t subframes_rendered,                           /* i  : number of subframes rendered             */
    const int16_t slots_rendered                                /* i  : number of CLDFB slots rendered           */
);
#endif

#ifndef FIX__657_REMOVE_EDITING
void ivas_omasa_set_edited_objects(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
+1 −0
Original line number Diff line number Diff line
@@ -249,6 +249,7 @@
/* all switches in this category should start with "CR_" */

#define CR_FIX_585_MASA_2TC_DTX_EXT                     /* Nokia: issue 585: fixes transition artifacts in MASA 2TC DTX by applying correct condition */
#define CR_FIX_639_HQ_ACELP_TRANSITION                  /* Ericsson: Issue 639: Wrong sampling rate of SWB TBE excitation memory in 16 kHz core for DFT Stereo@32 kbps */
#define CR_FIX_586_BPF_DFT_MEM                          /* FhG: issue 586: set input memory of DFT analysis of BPF signal to zero for HQ core to fix issue with PLC and bitrate switching */
#define CR_FIX_ISM_DTX_INFINITE_CNG_ON_TRAILING_SILENCE /* FhG: fix for cng in ISM DTX on sudden silence periods */

+11 −0
Original line number Diff line number Diff line
@@ -707,7 +707,18 @@ ivas_error acelp_core_dec(
            if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
            {
                /* Prepare ACB memory of old_bwe_exc */
#ifdef CR_FIX_639_HQ_ACELP_TRANSITION
                if ( st->L_frame == L_FRAME )
                {
                    lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
                }
                else
                {
                    lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC );
                }
#else
                lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
#endif
            }

            /*-----------------------------------------------------------------*
Loading