Commit cc645b55 authored by malenov's avatar malenov
Browse files

set correct pointer in ind_list_realloc()

parent 238a397f
Loading
Loading
Loading
Loading
Loading
+20 −17
Original line number Diff line number Diff line
@@ -244,12 +244,12 @@ ivas_error ind_list_realloc(
    /* move indices from the old list to the new list */
    for ( i = 0; i < min( max_num_indices, *( hBstr->ivas_max_num_indices ) ); i++ )
    {
        if ( hBstr->ivas_ind_list_zero[i].nb_bits > -1 )
        if ( (* hBstr->ivas_ind_list_zero)[i].nb_bits > -1 )
        {
            new_ind_list[i].id = hBstr->ivas_ind_list_zero[i].id;
            new_ind_list[i].value = hBstr->ivas_ind_list_zero[i].value;
            new_ind_list[i].id = ( *hBstr->ivas_ind_list_zero )[i].id;
            new_ind_list[i].value = ( *hBstr->ivas_ind_list_zero )[i].value;
        }
        new_ind_list[i].nb_bits = hBstr->ivas_ind_list_zero[i].nb_bits;
        new_ind_list[i].nb_bits = ( *hBstr->ivas_ind_list_zero )[i].nb_bits;
    }

    /* reset nb_bits of all other indices to -1 */
@@ -259,14 +259,14 @@ ivas_error ind_list_realloc(
    }

    /* get the current position inside the old list */
    ind_list_pos = (int16_t) ( hBstr->ind_list - hBstr->ivas_ind_list_zero );
    ind_list_pos = ( int16_t )( hBstr->ind_list - ( *hBstr->ivas_ind_list_zero ) );

    /* free the old list */
    free( hBstr->ivas_ind_list_zero );
    free( ( *hBstr->ivas_ind_list_zero ) );

    /* set pointers in the new list */
    hBstr->ind_list = &new_ind_list[ind_list_pos];
    hBstr->ivas_ind_list_zero = new_ind_list;
    *( hBstr->ivas_ind_list_zero ) = new_ind_list;

    /* set the new maximum number of indices */
    *( hBstr->ivas_max_num_indices ) = max_num_indices;
@@ -730,7 +730,7 @@ int16_t get_ivas_max_num_indices_metadata( /* o
    {
        if ( ivas_total_brate <= IVAS_16k4 )
        {
            return 40;
            return 60;
        }
        else
        {
@@ -749,7 +749,7 @@ int16_t get_ivas_max_num_indices_metadata( /* o
        }
        else
        {
            return 30;
            return 80;
        }
    }
    else if ( ivas_format == SBA_FORMAT )
@@ -776,11 +776,11 @@ int16_t get_ivas_max_num_indices_metadata( /* o
        }
        else if ( ivas_total_brate <= IVAS_384k )
        {
            return 1000;
            return 1500;
        }
        else
        {
            return 1000;
            return 2000;
        }
    }
    else if ( ivas_format == MASA_FORMAT )
@@ -819,11 +819,11 @@ int16_t get_ivas_max_num_indices_metadata( /* o
        }
        else if ( ivas_total_brate <= IVAS_384k )
        {
            return 850;
            return 1000;
        }
        else
        {
            return 900;
            return 1500;
        }
    }
    else if ( ivas_format == MC_FORMAT )
@@ -846,7 +846,7 @@ int16_t get_ivas_max_num_indices_metadata( /* o
        }
        else
        {
            return 60;
            return 300;
        }
    }

@@ -910,13 +910,15 @@ ivas_error check_ind_list_limits(
    BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle                    */
)
{
    Indice *ivas_ind_list_zero, *ivas_ind_list_last;
    ivas_error error;

    error = IVAS_ERR_OK;
    ivas_ind_list_zero = *( hBstr->ivas_ind_list_zero );

    /* check, if the maximum number of indices has been reached and re-allocate the buffer */
    /* the re-allocation can be avoided by increasing the limits in get_ivas_max_num_indices() or get_ivas_max_num_indices_metadata() */
    if ( ( &hBstr->ind_list[hBstr->nb_ind_tot] - hBstr->ivas_ind_list_zero ) >= *( hBstr->ivas_max_num_indices ) )
    if ( ( &hBstr->ind_list[hBstr->nb_ind_tot] - ivas_ind_list_zero ) >= *( hBstr->ivas_max_num_indices ) )
    {
#ifdef DEBUGGING
        fprintf( stderr, "Warning: The maximum number of indices %d has been exceeded in frame %d! Increase the limits in get_ivas_max_num_indices() or get_max_num_indices_metadata().\n", *( hBstr->ivas_max_num_indices ), frame );
@@ -935,12 +937,13 @@ ivas_error check_ind_list_limits(
            fprintf( stderr, "Warning: Trying to overwrite an existing indice ID = %d in frame %d!\n", hBstr->ind_list[hBstr->nb_ind_tot].id, frame );
#endif
            /* move the pointer to the next available empty slot */
            while ( hBstr->ind_list[0].nb_bits > 0 && hBstr->ind_list < &hBstr->ivas_ind_list_zero[*( hBstr->ivas_max_num_indices )] )
            ivas_ind_list_last = &ivas_ind_list_zero[*( hBstr->ivas_max_num_indices )];
            while ( hBstr->ind_list[0].nb_bits > 0 && hBstr->ind_list < ivas_ind_list_last )
            {
                hBstr->ind_list++;
            }

            if ( hBstr->ind_list >= &hBstr->ivas_ind_list_zero[*( hBstr->ivas_max_num_indices )] )
            if ( hBstr->ind_list >= ivas_ind_list_last )
            {
#ifdef DEBUGGING
                fprintf( stderr, "Warning: The maximum number of indices %d has been exceeded in frame %d! Increase the limits in get_ivas_max_num_indices() or get_max_num_indices_metadata().\n", *( hBstr->ivas_max_num_indices ), frame );
+1 −1
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ ivas_error init_encoder(
#ifdef IND_LIST_DYN
        /* set pointer to the buffer of indices */
        st->hBstr->ind_list = st_ivas->ind_list;
        st->hBstr->ivas_ind_list_zero = st_ivas->ind_list;
        st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list;
        st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices;
        st->hBstr->nb_ind_tot = 0;
        st->hBstr->nb_bits_tot = 0;
+1 −1
Original line number Diff line number Diff line
@@ -552,7 +552,7 @@ ivas_error ivas_corecoder_enc_reconfig(
#ifdef IND_LIST_DYN
                /* set pointer to the buffer of metadata indices */
                st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ind_list = st_ivas->ind_list_metadata;
                st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ivas_ind_list_zero = st_ivas->ind_list_metadata;
                st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata;
                st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata;
                st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->nb_ind_tot = 0;
                st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->nb_bits_tot = 0;
+1 −1
Original line number Diff line number Diff line
@@ -821,7 +821,7 @@ ivas_error create_cpe_enc(
#ifdef IND_LIST_DYN
        /* set pointer to the buffer of metadata indices */
        hCPE->hMetaData->ind_list = st_ivas->ind_list_metadata;
        hCPE->hMetaData->ivas_ind_list_zero = st_ivas->ind_list_metadata;
        hCPE->hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata;
        hCPE->hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata;
        reset_indices_enc( hCPE->hMetaData, st_ivas->ivas_max_num_indices_metadata );
#endif
+1 −1
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ ivas_error create_sce_enc(
#ifdef IND_LIST_DYN
        /* set pointer to the buffer of metadata indices */
        hSCE->hMetaData->ind_list = st_ivas->ind_list_metadata;
        hSCE->hMetaData->ivas_ind_list_zero = st_ivas->ind_list_metadata;
        hSCE->hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata;
        hSCE->hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata;
        reset_indices_enc( hSCE->hMetaData, st_ivas->ivas_max_num_indices_metadata );
#endif
Loading