Commit d1cadd34 authored by malenov's avatar malenov
Browse files

removal of the next_ind parameter -> it is replaced by nb_ind_tot

parent 2d511518
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -644,7 +644,6 @@ ivas_error push_indice(
    /* updates */
#ifdef IND_LIST_DYN
    hBstr->nb_ind_tot++;
    hBstr->next_ind++;
#ifdef DEBUG_IND_LIST
    assert( (hBstr->nb_ind_tot < hBstr->max_num_indices) && "Maximum number of indices has been exceeded!" );
#endif
@@ -739,7 +738,6 @@ ivas_error push_next_indice(
    /* updates */
#ifdef IND_LIST_DYN
    hBstr->nb_ind_tot++;
    hBstr->next_ind = hBstr->nb_ind_tot;
#ifdef DEBUG_IND_LIST
    assert( ( hBstr->nb_ind_tot < hBstr->max_num_indices ) && "Maximum number of indices has been exceeded!" );
#endif
@@ -838,7 +836,9 @@ void push_next_bits(

    }

#ifndef IND_LIST_DYN
    hBstr->next_ind = ( int16_t )( ptr - hBstr->ind_list );
#endif
    hBstr->nb_bits_tot = hBstr->nb_bits_tot + nb_bits;

    return;
@@ -910,7 +910,9 @@ uint16_t delete_indice(
    }

    hBstr->nb_ind_tot = j;
#ifndef IND_LIST_DYN
    hBstr->next_ind = j;
#endif

    for ( ; j < i; j++ )
    {
@@ -1141,8 +1143,9 @@ void reset_indices_enc(
    hBstr->nb_bits_tot = 0;
#ifdef IND_LIST_DYN
    hBstr->nb_ind_tot = 0;
#endif
#else
    hBstr->next_ind = 0;
#endif
    hBstr->last_ind = -1;

    for ( i = 0; i < max_num_indices; i++ )
+0 −3
Original line number Diff line number Diff line
@@ -1806,10 +1806,7 @@ void IGFEncConcatenateBitstream(
    /* update list of indices */
    hBstr->nb_ind_tot -= bsBits;
    hBstr->nb_bits_tot -= nb_bits_written;
    hBstr->next_ind -= bsBits;

#else

    indices_to_serial_generic( &hBstr->ind_list[hBstr->next_ind], bsBits, hPrivateData->igfBitstream, &hPrivateData->igfBitstreamBits );

    /* make sure there are no leftovers from the temporary bitstream writing */
+12 −1
Original line number Diff line number Diff line
@@ -73,7 +73,10 @@ ivas_error ivas_corecoder_enc_reconfig(
    int16_t i, nb_bits;
    Indice temp_ind_list[MAX_NUM_IND_TEMP_LIST];
#endif
    int16_t nb_bits_tot, next_ind, last_ind;
    int16_t nb_bits_tot, last_ind;
#ifndef IND_LIST_DYN
    int16_t next_ind;
#endif
    ENCODER_CONFIG_HANDLE hEncoderConfig;
    ivas_error error;

@@ -184,7 +187,9 @@ ivas_error ivas_corecoder_enc_reconfig(
        ind_list = hBstr->ind_list; /* pointer to the beginning of the global list */
#endif
        nb_bits_tot = hBstr->nb_bits_tot;
#ifndef IND_LIST_DYN
        next_ind = hBstr->next_ind;
#endif
        last_ind = hBstr->last_ind;
#ifdef IND_LIST_DYN
        i = 0;
@@ -330,7 +335,9 @@ ivas_error ivas_corecoder_enc_reconfig(
                {
                    st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->last_ind = last_ind;
                    st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot;
#ifndef IND_LIST_DYN
                    st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->next_ind = next_ind;
#endif
#ifdef IND_LIST_DYN
                    /* re-fill the buffer of indices with already written indices */
                    i = 0;
@@ -392,7 +399,9 @@ ivas_error ivas_corecoder_enc_reconfig(
                    {
                        st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->last_ind = last_ind;
                        st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_bits_tot = nb_bits_tot;
#ifndef IND_LIST_DYN
                        st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->next_ind = next_ind;
#endif
#ifdef IND_LIST_DYN
                        i = 0;
                        nb_bits = 0;
@@ -458,7 +467,9 @@ ivas_error ivas_corecoder_enc_reconfig(
                    {
                        st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->last_ind = last_ind;
                        st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_bits_tot = nb_bits_tot;
#ifndef IND_LIST_DYN
                        st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->next_ind = next_ind;
#endif
#ifdef IND_LIST_DYN
                        i = 0;
                        nb_bits = 0;
+18 −3
Original line number Diff line number Diff line
@@ -98,7 +98,11 @@ static void ivas_lfe_enc_quant(
    BSTR_ENC_HANDLE hBstr )
{
    int16_t bits_written;
#ifdef IND_LIST_DYN
    int16_t nb_ind_tot;
#else
    int16_t next_ind_pos;
#endif
    uint16_t quant_strategy, write_bit;
    int16_t num_quant_strategies;
    int16_t shift_bits;
@@ -117,7 +121,11 @@ static void ivas_lfe_enc_quant(
    num_quant_strategies = IVAS_MAX_NUM_QUANT_STRATS;
    shift_bits = IVAS_LFE_SHIFT_BITS;
    bits_written = hBstr->nb_bits_tot;
#ifdef IND_LIST_DYN
    nb_ind_tot = hBstr->nb_ind_tot;
#else
    next_ind_pos = hBstr->next_ind;
#endif


    for ( quant_strategy = 0; quant_strategy < num_quant_strategies; quant_strategy++ )
@@ -243,7 +251,11 @@ static void ivas_lfe_enc_quant(
        }

        bits_written_arith_enc = hBstr->nb_bits_tot;
#ifdef IND_LIST_DYN
        next_ind_pos_arith_enc = hBstr->nb_ind_tot;
#else
        next_ind_pos_arith_enc = hBstr->next_ind;
#endif
        push_next_indice( hBstr, coding_strategy, 1 );
        base2_num_bits_tot = hBstr->nb_bits_tot - bits_written;

@@ -274,7 +286,9 @@ static void ivas_lfe_enc_quant(
                }
#endif
                hBstr->nb_bits_tot = bits_written_arith_enc;
#ifndef IND_LIST_DYN
                hBstr->next_ind = next_ind_pos_arith_enc;
#endif
                coding_strategy = 1;
                push_next_indice( hBstr, coding_strategy, 1 );

@@ -308,7 +322,7 @@ static void ivas_lfe_enc_quant(
                {
                    /* reset all indices that were already written - TODO: maybe better store them temporarily first and write at the very end? */
#ifdef IND_LIST_DYN
                    for ( j = hBstr->nb_ind_tot - 1; j >= next_ind_pos; j-- )
                    for ( j = hBstr->nb_ind_tot - 1; j >= nb_ind_tot; j-- )
#else
                    for ( j = hBstr->next_ind - 1; j >= next_ind_pos; j-- )
#endif
@@ -318,9 +332,10 @@ static void ivas_lfe_enc_quant(

                    hBstr->nb_bits_tot = bits_written;
#ifdef IND_LIST_DYN
                    hBstr->nb_ind_tot = next_ind_pos;
#endif
                    hBstr->nb_ind_tot = nb_ind_tot;
#else
                    hBstr->next_ind = next_ind_pos;
#endif
                }
            }
        }
+72 −3
Original line number Diff line number Diff line
@@ -403,7 +403,11 @@ ivas_error ivas_qmetadata_enc_encode(

        /* Save state of metadata bitstream buffer after writing energy ratios, number of dirs and save space for coherence*/
        bit_pos_start = hMetaData->nb_bits_tot;
#ifdef IND_LIST_DYN
        next_ind_start = hMetaData->nb_ind_tot;
#else
        next_ind_start = hMetaData->next_ind;
#endif
        last_ind_start = hMetaData->last_ind;

        /* Encode quantized directions with EC frame-wise*/
@@ -413,7 +417,11 @@ ivas_error ivas_qmetadata_enc_encode(
            bits_signaling[d]++;
        }

#ifdef IND_LIST_DYN
        next_ind_raw_flag = hMetaData->nb_ind_tot;
#else
        next_ind_raw_flag = hMetaData->next_ind;
#endif
        push_next_indice( hMetaData, 0, 1 ); /* Raw coding flag*/

        bits_dir_bands[0] = ivas_qmetadata_raw_encode_dir( NULL, q_direction, q_direction->cfg.nbands, q_direction->cfg.start_band );
@@ -453,7 +461,11 @@ ivas_error ivas_qmetadata_enc_encode(
            bits_signaling[d] = 3;

            /* Write raw flags */
#ifdef IND_LIST_DYN
            next_ind_raw_flag = hMetaData->nb_ind_tot;
#else
            next_ind_raw_flag = hMetaData->next_ind;
#endif
            for ( i = start_band; i < nbands; i++ )
            {
                push_next_indice( hMetaData, 0, 1 ); /* Raw coding flag*/
@@ -908,15 +920,19 @@ void ivas_qmetadata_enc_sid_encode(

void reset_metadata_spatial(
    const IVAS_FORMAT ivas_format,  /* i  : IVAS format                  */
    BSTR_ENC_HANDLE hMetaData,      /* i/o: Metadata bitstream handle    */
    BSTR_ENC_HANDLE hMetaData,      /* i/o: metadata bitstream handle    */
    const int32_t element_brate,    /* i  : element bitrate              */
    int32_t *total_brate,           /* o  : total bitrate                */
    const int32_t core_brate,       /* i  : core bitrate                 */
    const int16_t nb_bits_metadata, /* i  : number of meatdata bits      */
    const int16_t nb_bits_metadata, /* i  : number of metadata bits      */
    const SBA_MODE sba_mode         /* i  : SBA mode                     */
)
{
    int16_t i, next_ind_sid, last_ind_sid;
#ifdef IND_LIST_DYN
    int16_t j;
#endif

    int16_t metadata_sid_bits;

    if ( core_brate == SID_2k40 || core_brate == FRAME_NO_DATA )
@@ -925,7 +941,9 @@ void reset_metadata_spatial(
        {
            if ( sba_mode == SBA_MODE_SPAR )
            {
#ifdef DEBUGGING
                assert( hMetaData->ind_list[0].nb_bits == 1 );
#endif
                hMetaData->ind_list[0].value = 1;
                metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
                while ( hMetaData->nb_bits_tot < metadata_sid_bits )
@@ -936,15 +954,22 @@ void reset_metadata_spatial(
            else
            {
                /* Reset metadata and keep only SID metadata*/
#ifdef IND_LIST_DYN
                last_ind_sid = hMetaData->nb_ind_tot;
                next_ind_sid = hMetaData->nb_ind_tot;
#else
                last_ind_sid = hMetaData->next_ind;
                next_ind_sid = hMetaData->next_ind;
#endif
                while ( hMetaData->nb_bits_tot > nb_bits_metadata )
                {
                    next_ind_sid--;
                    hMetaData->nb_bits_tot -= hMetaData->ind_list[next_ind_sid].nb_bits;
                }

#ifndef IND_LIST_DYN
                hMetaData->next_ind = 0;
#endif
                hMetaData->nb_bits_tot = 0;

                for ( i = 0; i < next_ind_sid; i++ )
@@ -952,6 +977,18 @@ void reset_metadata_spatial(
                    hMetaData->ind_list[i].nb_bits = -1;
                }

#ifdef IND_LIST_DYN
                for ( j = 0, i = next_ind_sid; i < last_ind_sid; i++, j++ )
                {
                    hMetaData->ind_list[j].value = hMetaData->ind_list[i].value;
                    hMetaData->ind_list[j].nb_bits = hMetaData->ind_list[i].nb_bits;
                    hMetaData->nb_bits_tot += hMetaData->ind_list[j].nb_bits;
                    hMetaData->ind_list[i].nb_bits = -1;
                }

                hMetaData->nb_ind_tot = j;
                hMetaData->last_ind = j - 1;
#else
                for ( i = next_ind_sid; i < last_ind_sid; i++ )
                {
                    hMetaData->ind_list[hMetaData->next_ind].value = hMetaData->ind_list[i].value;
@@ -960,13 +997,20 @@ void reset_metadata_spatial(
                    hMetaData->next_ind++;
                    hMetaData->ind_list[i].nb_bits = -1;
                }

                hMetaData->last_ind = hMetaData->next_ind;
#endif
#ifdef DEBUGGING
                assert( ( hMetaData->nb_bits_tot == ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS ) && "Problem of SID metadata in SCE" );
#endif
            }
        }
        else
        {
            /*Reset metadata*/
#ifdef IND_LIST_DYN
            reset_indices_enc( hMetaData, hMetaData->max_num_indices );
#else
            for ( i = 0; i < hMetaData->next_ind; i++ )
            {
                hMetaData->ind_list[i].nb_bits = -1;
@@ -974,6 +1018,7 @@ void reset_metadata_spatial(
            hMetaData->nb_bits_tot = 0;
            hMetaData->next_ind = 0;
            hMetaData->last_ind = 0;
#endif
        }

        *total_brate = element_brate;
@@ -983,12 +1028,24 @@ void reset_metadata_spatial(
        /* Reset SID metadata bits*/
        while ( hMetaData->nb_bits_tot > nb_bits_metadata )
        {
#ifdef IND_LIST_DYN
            hMetaData->nb_ind_tot--;
            hMetaData->nb_bits_tot -= hMetaData->ind_list[hMetaData->nb_ind_tot].nb_bits;
            hMetaData->ind_list[hMetaData->nb_ind_tot].nb_bits = -1;
#else
            hMetaData->next_ind--;
            hMetaData->nb_bits_tot -= hMetaData->ind_list[hMetaData->next_ind].nb_bits;
            hMetaData->ind_list[hMetaData->next_ind].nb_bits = -1;
#endif
        }
#ifdef DEBUGGING
        assert( hMetaData->nb_bits_tot == nb_bits_metadata && "Problem in metadata for SCE" );
#endif
#ifdef IND_LIST_DYN
        hMetaData->last_ind = hMetaData->nb_ind_tot;
#else
        hMetaData->last_ind = hMetaData->next_ind;
#endif
    }

    return;
@@ -1494,7 +1551,7 @@ static int16_t ivas_qmetadata_entropy_encode_df_ratio(
/*-------------------------------------------------------------------------
 * restore_metadata_buffer()
 *
 * Reset metadata buffer
 * Restore metadata buffer
 *------------------------------------------------------------------------*/

void restore_metadata_buffer(
@@ -1505,12 +1562,20 @@ void restore_metadata_buffer(
{
    int16_t i;

#ifdef IND_LIST_DYN
    for ( i = next_ind_start; i <= hMetaData->nb_ind_tot; i++ )
#else
    for ( i = next_ind_start; i <= hMetaData->next_ind; i++ )
#endif
    {
        hMetaData->ind_list[i].nb_bits = -1;
    }
    hMetaData->nb_bits_tot = bit_pos_start;
#ifdef IND_LIST_DYN
    hMetaData->nb_ind_tot = next_ind_start;
#else
    hMetaData->next_ind = next_ind_start;
#endif
    hMetaData->last_ind = last_ind_start;

    return;
@@ -4701,7 +4766,11 @@ static int16_t ivas_qmetadata_quantize_coherence(
        else
        {
            /* write dummy data now and save the position */
#ifdef IND_LIST_DYN
            *indice_coherence = hMetaData->nb_ind_tot;
#else
            *indice_coherence = hMetaData->next_ind;
#endif
            k = nbits;
            while ( k > 0 )
            {
Loading