Commit 2978a304 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'sba_path_cleanup_Q_info_updates' into 'main'

SBA path function integration, dirac enc cleanup, Q-info updates

See merge request !719
parents 716de4f0 a9832a36
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -25,12 +25,12 @@ void bitallocsum_fx(
    Word16 total, tmp;
    Word16 diff;

    total = (Word16) 0;
    total = 0;
    move16();
    FOR( i = 0; i < nb_sfm; i++ )
    {
        tmp = extract_l( L_mult0( R[i], sfmsize[i] ) );
        Rsubband[i] = shl( tmp, 3 );
        tmp = extract_l( L_mult0( R[i], sfmsize[i] ) ); // Q0
        Rsubband[i] = shl( tmp, 3 );                    // Q3
        move16();
        total = add( total, tmp );
    }
@@ -40,7 +40,7 @@ void bitallocsum_fx(
    IF( LE_16( length, L_FRAME32k ) )
    {
        diff = sub( num_bits, *sum );
        i = (Word16) 0;
        i = 0;
        move16();
        WHILE( diff > 0 )
        {
@@ -55,7 +55,7 @@ void bitallocsum_fx(
            i = add( i, 1 );
            if ( GE_16( i, nb_sfm ) )
            {
                i = (Word16) 0;
                i = 0;
                move16();
            }
        }
+100 −97

File changed.

Preview size limit exceeded, changes collapsed.

+11 −6
Original line number Diff line number Diff line
@@ -698,6 +698,8 @@ Word16 get_ivas_max_num_indices_fx(
    const Word32 ivas_total_brate  /* i  : IVAS total bitrate        */
)
{
    test();
    test();
    IF( EQ_16( ivas_format, STEREO_FORMAT ) )
    {
        IF( LE_32( ivas_total_brate, IVAS_16k4 ) )
@@ -1179,6 +1181,7 @@ Word16 get_ivas_max_num_indices_metadata_fx(
)
{
    /* set the maximum required number of metadata indices */
    test();
    IF( EQ_16( ivas_format, MONO_FORMAT ) )
    {
        return 0;
@@ -1418,7 +1421,7 @@ ivas_error check_ind_list_limits(
    {

        /* reallocate the buffer of indices with increased limit */
        IF( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
        IF( NE_32( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
@@ -1440,7 +1443,7 @@ ivas_error check_ind_list_limits(
            {

                /* no available empty slot -> need to re-allocate the buffer */
                IF( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
                IF( NE_32( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ), IVAS_ERR_OK ) )
                {
                    return error;
                }
@@ -1532,7 +1535,7 @@ ivas_error push_indice(
    move32();

    /* check the limits of the list of indices */
    IF( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
    IF( NE_32( ( error = check_ind_list_limits( hBstr ) ), IVAS_ERR_OK ) )
    {
        return IVAS_ERROR( error, "Error occured in push_indice() while re-allocating the list of indices (frame %d) !\n" );
    }
@@ -1540,8 +1543,10 @@ ivas_error push_indice(
    /* find the location in the list of indices based on ID */
    i = hBstr->nb_ind_tot;
    move16();
    WHILE( i > 0 && LT_16( id, hBstr->ind_list[i - 1].id ) )
    test();
    WHILE( i > 0 && ( id < hBstr->ind_list[i - 1].id ) )
    {
        test();
        i = sub( i, 1 );
    }

@@ -1649,7 +1654,7 @@ ivas_error push_next_indice(


    /* check the limits of the list of indices */
    IF( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
    IF( NE_32( ( error = check_ind_list_limits( hBstr ) ), IVAS_ERR_OK ) )
    {
        return error;
    }
@@ -2102,7 +2107,7 @@ UWord16 get_indice_st(
    FOR( i = 0; i < nb_bits; i++ )
    {
        value = shl( value, 1 );
        value = add( value, st->bit_stream[add( pos, i )] );
        value = add( value, st->bit_stream[pos + i] );
    }

    return value;
+64 −46
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ static Word16 rate2AMRWB_IOmode(
    Word32 brate /* i: bitrate */
)
{
    switch ( brate )
    SWITCH( brate )
    {
            /* EVS AMR-WB IO modes */
        case SID_1k75:
@@ -289,7 +289,7 @@ void push_indice_fx(
        /* new indice - find an empty slot in the list */
        i = id;
        move16();
        WHILE( NE_16( hBstr->ind_list[i].nb_bits, -1 ) )
        WHILE( hBstr->ind_list[i].nb_bits != -1 )
        {
            i = add( i, 1 );
        }
@@ -506,7 +506,7 @@ UWord16 get_indice_fx( /* o : value of the indice */
    FOR( i = 0; i < nb_bits; i++ )
    {
        value = lshl( value, 1 );
        value = add( value, st_fx->bit_stream[add( pos, i )] );
        value = add( value, st_fx->bit_stream[pos + i] );
    }

    return value;
@@ -703,62 +703,65 @@ void write_indices_buf_fx(
    UWord8 header;
    Word16 isAmrWb = 0;

    if ( st_fx->bitstreamformat == G192 )
    IF( st_fx->bitstreamformat == G192 )
    {
        /*-----------------------------------------------------------------*
         * Encode Sync Header and Frame Length
         *-----------------------------------------------------------------*/
        pt_stream = stream;
        for ( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i )
        FOR( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i )
        {
            stream[i] = 0;
            move16();
        }
        //*pt_stream++ = (Word16) SYNC_GOOD_FRAME;
        //*pt_stream++ = hBstr->nb_bits_tot;
        *num_bits = hBstr->nb_bits_tot;

        move16();
        /*----------------------------------------------------------------*
         * Bitstream packing (conversion of individual indices into a serial stream)
         * Writing the serial stream into file
         *----------------------------------------------------------------*/
        for ( i = 0; i < MAX_NUM_INDICES; i++ )
        FOR( i = 0; i < MAX_NUM_INDICES; i++ )
        {
            if ( hBstr->ind_list[i].nb_bits != -1 )
            IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) )
            {
                /* mask from MSB to LSB */
                mask = 1 << ( hBstr->ind_list[i].nb_bits - 1 );
                mask = L_shl( 1, ( sub( hBstr->ind_list[i].nb_bits, 1 ) ) );

                /* write bit by bit */
                for ( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
                FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
                {
                    if ( hBstr->ind_list[i].value & mask )
                    IF( L_and( hBstr->ind_list[i].value, mask ) )
                    {
                        //*pt_stream++ = G192_BIN1;
                        *pt_stream++ = 1;
                        move16();
                    }
                    else
                    ELSE
                    {
                        //*pt_stream++ = G192_BIN0;
                        *pt_stream++ = 0;
                        move16();
                    }

                    mask >>= 1;
                    mask = L_shr( mask, 1 );
                }
            }
        }
    }
    else
    ELSE
    {
        /* Create and write ToC header */
        /*  qbit always  set to  1 on encoder side  for AMRWBIO ,  no qbit in use for EVS, but set to 0(bad)  */
        header = (UWord8) ( st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode( hBstr->nb_bits_tot * 50, &isAmrWb ) );
        header = (UWord8) ( s_or( s_or( shl( st_fx->Opt_AMR_WB, 5 ), shl( st_fx->Opt_AMR_WB, 4 ) ), rate2EVSmode( i_mult( hBstr->nb_bits_tot, 50 ), &isAmrWb ) ) );
        // fwrite(&header, sizeof(UWord8), 1, file);
        memcpy( out_buf, &header, sizeof( UWord8 ) );
        *num_bits += sizeof( UWord8 );
        /* Write speech bits */
        // fwrite(pFrame, sizeof(UWord8), (pFrame_size + 7) >> 3, file);
        memcpy( out_buf, pFrame, sizeof( UWord8 ) * ( ( pFrame_size + 7 ) >> 3 ) );
        *num_bits += sizeof( UWord8 ) * ( ( pFrame_size + 7 ) >> 3 );
        memcpy( out_buf, pFrame, sizeof( UWord8 ) * ( shr( add( pFrame_size, 7 ), 3 ) ) );
        *num_bits += sizeof( UWord8 ) * ( shr( ( add( pFrame_size, 7 ) ), 3 ) );
    }

    /* Clearing of indices */
@@ -769,7 +772,7 @@ void write_indices_buf_fx(
    }


    if ( st_fx->bitstreamformat == G192 )
    IF( st_fx->bitstreamformat == G192 )
    {
        /* write the serial stream into file */
        // fwrite(stream, sizeof(unsigned short), 2 + stream[1], file);
@@ -783,6 +786,9 @@ void write_indices_buf_fx(
    hBstr->nb_bits_tot = 0;
    hBstr->next_ind_fx = 0;
    hBstr->last_ind_fx = -1;
    move16();
    move16();
    move16();

    return;
}
@@ -920,7 +926,7 @@ void indices_to_serial_generic(
    FOR( k = 0; k < ind_list[i].nb_bits; k++ )
    {
        pack_bit( ind_list[i].value & mask, &pt_pFrame, &omask );
        j++;
        j = add( j, 1 );
        mask = L_shr( mask, 1 );
    }
    nb_bits_tot = add( nb_bits_tot, ind_list[i].nb_bits );
@@ -1194,7 +1200,7 @@ void decision_matrix_core_dec(
        move16();
    }
    /* SC-VBR */
    ELSE IF( st->total_brate == PPP_NELP_2k80 )
    ELSE IF( EQ_32( st->total_brate, PPP_NELP_2k80 ) )
    {
        st->core = ACELP_CORE;
        move16();
@@ -1232,7 +1238,7 @@ void decision_matrix_core_dec(
        /* find the section in the ACELP signalling table corresponding to bitrate */
        start_idx = 0;
        move16();
        WHILE( NE_32( acelp_sig_tbl[start_idx], st->total_brate ) )
        WHILE( acelp_sig_tbl[start_idx] != st->total_brate )
        {
            start_idx = add( start_idx, 1 );
        }
@@ -1245,7 +1251,7 @@ void decision_matrix_core_dec(
        start_idx = add( start_idx, 1 );

        /* retrieve the signalling indice */
        ind = acelp_sig_tbl[add( start_idx, get_next_indice_fx( st, nBits ) )];
        ind = acelp_sig_tbl[start_idx + get_next_indice_fx( st, nBits )];
        st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7 ) );
        move16();

@@ -1573,6 +1579,8 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem

    /* read the Sync Header field from the bitstream */
    /* in case rew_flag is set, read until first good frame is encountered */
    test();
    test();
    DO
    {
        /* read the Sync header */
@@ -1647,9 +1655,8 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
            fprintf( stderr, "\nError, invalid number of bits read ! Exiting ! \n" );
            exit( -1 );
        }
        test();
    }
    WHILE( rew_flag && ( st->bfi || LT_32( total_brate, 2800 ) ) );
    WHILE( rew_flag && ( st->bfi || ( total_brate < 2800 ) ) );

    /* G.192 RX DTX handler*/
    IF( !rew_flag )
@@ -1807,7 +1814,7 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
        test();
        test();
        test();
        if ( ( ( st->CNG_fx != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST)   --> stay in CNG */
        IF( ( ( st->CNG_fx != 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->bfi = 0;
@@ -1844,7 +1851,7 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
    {
        rewind( file );
        st->total_brate = total_brate;
        move16();
        move32();
        return 1;
    }

@@ -1938,7 +1945,7 @@ static Word32 read_indices_mime_handle_dtx(

    /* SID_UPDATE check */
    test();
    IF( total_brate == SID_1k75 || total_brate == SID_2k40 )
    IF( EQ_32( total_brate, SID_1k75 ) || EQ_32( total_brate, SID_2k40 ) )
    {
        IF( st->bfi == 0 )
        {
@@ -2210,7 +2217,6 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
        isAMRWB_IOmode = 1;
        move16();
        qbit = s_and( shr( header, 2 ), 0x01 ); /* b2 bit       (b7 is the F bit ) */
        move16();
        st->bfi = !qbit;
        move16();
        core_mode = s_and( shr( header, 3 ), 0x0F ); /*  b6..b3      */
@@ -2382,8 +2388,14 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
    IF( st->bfi == 0 )
    {
        /* select MODE1 or MODE2 in  MIME */
        decoder_selectCodec( st, total_brate, *st->bit_stream ? G192_BIN1 : G192_BIN0 );

        IF( *st->bit_stream )
        {
            decoder_selectCodec( st, total_brate, G192_BIN1 );
        }
        ELSE
        {
            decoder_selectCodec( st, total_brate, G192_BIN0 );
        }
        /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */
        st->total_brate = total_brate;
        move32();
@@ -2523,9 +2535,9 @@ void get_rfFlag(
        /* find the section in the ACELP signalling table corresponding to bitrate */
        start_idx = 0;
        move16();
        WHILE( NE_32( acelp_sig_tbl[start_idx], st->total_brate ) )
        WHILE( acelp_sig_tbl[start_idx] != st->total_brate )
        {
            start_idx++;
            start_idx = add( start_idx, 1 );
            assert( ( start_idx < MAX_ACELP_SIG ) && "ERROR: start_idx larger than acelp_sig_tbl[].\n" );
        }

@@ -2725,12 +2737,12 @@ void get_NextCoderType_fx(

    FOR( k = 0; k < ACELP_13k20 / 50; k++ )
    {
        bit_stream[k] = (UWord8) s_and( shr( bitsteam[k / 8], sub( 7, ( k % 8 ) ) ), 0x1 );
        bit_stream[k] = (UWord8) s_and( shr( bitsteam[k / 8], sub( 7, s_and( k, 7 ) ) ), 0x1 );
        move16();
    }
    start_idx = 0;
    move16();
    WHILE( NE_32( acelp_sig_tbl[start_idx], ACELP_13k20 ) )
    WHILE( acelp_sig_tbl[start_idx] != ACELP_13k20 )
    {
        start_idx = add( start_idx, 1 );
        assert( ( start_idx < MAX_ACELP_SIG ) && "ERROR: start_idx larger than acelp_sig_tbl[].\n" );
@@ -2741,7 +2753,7 @@ void get_NextCoderType_fx(

    tmp = 0;
    move16();
    nBits_tmp = (Word16) acelp_sig_tbl[start_idx++];
    nBits_tmp = extract_l( acelp_sig_tbl[start_idx++] );
    move16();
    FOR( k = 0; k < nBits_tmp; k++ )
    {
@@ -2749,7 +2761,7 @@ void get_NextCoderType_fx(
        tmp = add( tmp, bit_stream[k] );
    }
    /* retrieve the signalling indice */
    *next_coder_type = s_and( (Word16) acelp_sig_tbl[add( start_idx, tmp )], 0x7 );
    *next_coder_type = s_and( extract_l( acelp_sig_tbl[start_idx + tmp] ), 0x7 );
    move16();
}

@@ -2806,7 +2818,6 @@ void read_indices_from_djb_fx(
        move16();
        no_data = st->CNG_fx != 0;
        move16();
        move16();
    }

    test();
@@ -2833,7 +2844,7 @@ void read_indices_from_djb_fx(
    FOR( k = 0; k < num_bits; k++ )
    {
        test();
        IF( st->bitstreamformat == VOIP_RTPDUMP && isAMRWB_IOmode )
        IF( EQ_16( st->bitstreamformat, VOIP_RTPDUMP ) && isAMRWB_IOmode )
        {
            st->bit_stream[sort_ptr[core_mode][k]] = unpack_bit( &pt_stream, &mask );
            move16();
@@ -2877,7 +2888,15 @@ void read_indices_from_djb_fx(
    IF( NE_16( st->bfi, 1 ) )
    {
        /* select Mode 1 or Mode 2 */
        decoder_selectCodec( st, total_brate, *st->bit_stream ? G192_BIN1 : G192_BIN0 );
        IF( *st->bit_stream )
        {
            decoder_selectCodec( st, total_brate, G192_BIN1 );
        }
        ELSE
        {
            decoder_selectCodec( st, total_brate, G192_BIN0 );
        }


        /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */
        st->total_brate = total_brate;
@@ -2908,7 +2927,7 @@ static UWord16 get_indice_preview(
    bitstreamShortPtr = bitstreamShort;
    FOR( i = 0; i < bitstreamSize; i++ )
    {
        *bitstreamShortPtr++ = s_and( shr( bitstream[i / 8], sub( 7, ( i % 8 ) ) ), 0x1 );
        *bitstreamShortPtr++ = s_and( shr( bitstream[i / 8], sub( 7, ( s_and( i, 7 ) ) ) ), 0x1 );
        move16();
    }

@@ -2918,7 +2937,7 @@ static UWord16 get_indice_preview(
    FOR( i = 0; i < nb_bits; i++ )
    {
        value = shl( value, 1 );
        value = add( value, bitstreamShort[add( pos, i )] );
        value = add( value, bitstreamShort[pos + i] );
    }
    return value;
}
@@ -2952,7 +2971,7 @@ void evs_dec_previewFrame(
        /* find the section in the ACELP signalling table corresponding to bitrate */
        start_idx = 0;
        move16();
        WHILE( NE_32( acelp_sig_tbl[start_idx], total_brate ) )
        WHILE( acelp_sig_tbl[start_idx] != total_brate )
        {
            start_idx = add( start_idx, 1 );
            assert( ( start_idx < MAX_ACELP_SIG ) && "ERROR: start_idx larger than acelp_sig_tbl[].\n" );
@@ -2961,11 +2980,10 @@ void evs_dec_previewFrame(
        /* skip the bitrate */
        start_idx = add( start_idx, 1 );
        /* retrieve the number of bits */
        nBits = (Word16) acelp_sig_tbl[start_idx++];
        move16();
        nBits = extract_l( acelp_sig_tbl[start_idx++] );

        /* retrieve the signalling indice */
        ind = acelp_sig_tbl[add( start_idx, get_indice_preview( bitstream, bitstreamSize, 0, nBits ) )];
        ind = acelp_sig_tbl[( start_idx + get_indice_preview( bitstream, bitstreamSize, 0, nBits ) )];
        move32();

        /* convert signalling indice into RF flag. */
+2 −2
Original line number Diff line number Diff line
@@ -2156,8 +2156,7 @@ void calculate_hodirac_sector_parameters_fx(

    return;
}
#endif

#else
void calculate_hodirac_sector_parameters(
    DIRAC_ENC_HANDLE hDirAC,                                      /* i  : DirAC handle                               */
    float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i  : signal vector (L+1)^2 x N_bins, real part  */
@@ -2350,6 +2349,7 @@ void calculate_hodirac_sector_parameters(

    return;
}
#endif


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