Commit fe5eac0c authored by vaclav's avatar vaclav
Browse files

Merge branch '383-unused-functions-more' into 'main'

Resolve "Unused functions"

See merge request !915
parents a4b8e4b8 886e1752
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
@@ -3266,197 +3266,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()
 *
+0 −120
Original line number Diff line number Diff line
@@ -944,108 +944,6 @@ static ivas_error create_HRTF_from_rawdata(
    return IVAS_ERR_OK;
}

static ivas_error init_fastconv_HRTF_handle(
    HRTFS_FASTCONV *hHrtf /* i/o: HRTF FastConv handle */
)
{
    int16_t i, j;

    if ( hHrtf == NULL )
    {
        return IVAS_ERR_WRONG_PARAMS;
    }

    hHrtf->FASTCONV_HRIR_latency_s = 0;
    for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
    {
        for ( j = 0; j < HRTF_LS_CHANNELS; j++ )
        {
            set_zero( hHrtf->leftHRIRReal[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->leftHRIRImag[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->rightHRIRReal[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->rightHRIRImag[i][j], BINAURAL_NTAPS );
        }
    }

    hHrtf->FASTCONV_HOA3_latency_s = 0;
    for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
    {
#ifdef UPDATE_FASTCONV_SBA_FILTER
        for ( j = 0; j < HOA3_CHANNELS; j++ )
        {
            set_zero( hHrtf->leftHRIRReal_HOA3[i][j], BINAURAL_NTAPS_SBA );
            set_zero( hHrtf->leftHRIRImag_HOA3[i][j], BINAURAL_NTAPS_SBA );
            set_zero( hHrtf->rightHRIRReal_HOA3[i][j], BINAURAL_NTAPS_SBA );
            set_zero( hHrtf->rightHRIRImag_HOA3[i][j], BINAURAL_NTAPS_SBA );
#else
        for ( j = 0; j < HRTF_SH_CHANNELS; j++ )
        {
            set_zero( hHrtf->leftHRIRReal_HOA3[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->leftHRIRImag_HOA3[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->rightHRIRReal_HOA3[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->rightHRIRImag_HOA3[i][j], BINAURAL_NTAPS );
#endif
        }
    }
    hHrtf->FASTCONV_HOA2_latency_s = 0;
    for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
    {
#ifdef UPDATE_FASTCONV_SBA_FILTER
        for ( j = 0; j < HOA2_CHANNELS; j++ )
        {
            set_zero( hHrtf->leftHRIRReal_HOA2[i][j], BINAURAL_NTAPS_SBA );
            set_zero( hHrtf->leftHRIRImag_HOA2[i][j], BINAURAL_NTAPS_SBA );
            set_zero( hHrtf->rightHRIRReal_HOA2[i][j], BINAURAL_NTAPS_SBA );
            set_zero( hHrtf->rightHRIRImag_HOA2[i][j], BINAURAL_NTAPS_SBA );
#else
        for ( j = 0; j < 9; j++ )
        {
            set_zero( hHrtf->leftHRIRReal_HOA2[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->leftHRIRImag_HOA2[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->rightHRIRReal_HOA2[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->rightHRIRImag_HOA2[i][j], BINAURAL_NTAPS );
#endif
        }
    }
    hHrtf->FASTCONV_FOA_latency_s = 0;
    for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
    {
#ifdef UPDATE_FASTCONV_SBA_FILTER
        for ( j = 0; j < FOA_CHANNELS; j++ )
        {
            set_zero( hHrtf->leftHRIRReal_FOA[i][j], BINAURAL_NTAPS_SBA );
            set_zero( hHrtf->leftHRIRImag_FOA[i][j], BINAURAL_NTAPS_SBA );
            set_zero( hHrtf->rightHRIRReal_FOA[i][j], BINAURAL_NTAPS_SBA );
            set_zero( hHrtf->rightHRIRImag_FOA[i][j], BINAURAL_NTAPS_SBA );
#else
        for ( j = 0; j < 4; j++ )
        {
            set_zero( hHrtf->leftHRIRReal_FOA[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->leftHRIRImag_FOA[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->rightHRIRReal_FOA[i][j], BINAURAL_NTAPS );
            set_zero( hHrtf->rightHRIRImag_FOA[i][j], BINAURAL_NTAPS );
#endif
        }
    }

    hHrtf->FASTCONV_BRIR_latency_s = 0;
    for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
    {
        for ( j = 0; j < HRTF_LS_CHANNELS; j++ )
        {
            set_zero( hHrtf->leftBRIRReal[i][j], BINAURAL_NTAPS_MAX );
            set_zero( hHrtf->leftBRIRImag[i][j], BINAURAL_NTAPS_MAX );
            set_zero( hHrtf->rightBRIRReal[i][j], BINAURAL_NTAPS_MAX );
            set_zero( hHrtf->rightBRIRImag[i][j], BINAURAL_NTAPS_MAX );
        }
    }

    set_zero( hHrtf->fastconvReverberationTimes, CLDFB_NO_CHANNELS_MAX );
    set_zero( hHrtf->fastconvReverberationEneCorrections, CLDFB_NO_CHANNELS_MAX );

    return IVAS_ERR_OK;
}


static ivas_error create_fastconv_HRTF_from_rawdata(
    HRTFS_FASTCONV_HANDLE *hHRTF,         /* i/o: HRTF FastConv handle */
@@ -1061,24 +959,6 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
    ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag );
#endif

    // if ( hHRTF == NULL )
    // {
#ifdef SPLIT_REND_WITH_HEAD_ROT
    //     if ( ( ( *hHRTF ) = (HRTFS_FASTCONV_HANDLE) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL )
#else
    //     if ( ( ( *hHRTF ) = (HRTFS_FASTCONV_HANDLE) count_malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL )
#endif
    //     {
    //         return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Can not allocate memory for Fastconv HRTF binary\n" );
    //     }

    //     init_fastconv_HRTF_handle( *hHRTF );
    // }
    // else
    // {
    //     return IVAS_ERR_INTERNAL;
    // }

    hrtf_data_rptr = hrtf_data;

    /* BINAURAL_CONVBANDS */