Commit 67ec8548 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_545_ASSERT

parent a94f39dc
Loading
Loading
Loading
Loading
+0 −63
Original line number Diff line number Diff line
@@ -805,22 +805,13 @@ int16_t get_ivas_max_num_indices_metadata(
 * Move indices inside the buffer or among two buffers
 *-------------------------------------------------------------------*/

#ifdef FIX_545_ASSERT
void move_indices(
#else
ivas_error move_indices(
#endif
    INDICE_HANDLE old_ind_list, /* i/o: old location of indices */
    INDICE_HANDLE new_ind_list, /* i/o: new location of indices */
    const int16_t nb_indices    /* i  : number of moved indices */
)
{
    int16_t i;
#ifndef FIX_545_ASSERT
    ivas_error error;

    error = IVAS_ERR_OK;
#endif

    if ( new_ind_list < old_ind_list )
    {
@@ -845,11 +836,7 @@ ivas_error move_indices(
        }
    }

#ifdef FIX_545_ASSERT
    return;
#else
    return error;
#endif
}


@@ -875,24 +862,14 @@ ivas_error check_ind_list_limits(
    if ( ( &hBstr->ind_list[hBstr->nb_ind_tot] - ivas_ind_list_zero ) >= *( hBstr->ivas_max_num_indices ) )
    {
#ifdef DEBUGGING
#ifdef FIX_545_ASSERT
        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 );
#else
        /* TODO: replace with the warning message below before the finalization of the IVAS codec */
        /* 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 ); */
        assert( 0 && "The maximum number of indices has been exceeded! Increase the limits in get_ivas_max_num_indices() or get_max_num_indices_metadata()." );
#endif
#endif

        /* reallocate the buffer of indices with increased limit */
#ifdef FIX_545_ASSERT
        if ( ( error = ind_list_realloc( hBstr, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#else
        ind_list_realloc( hBstr, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES );
#endif
    }

    /* check, if we will not overwrite an existing indice */
@@ -913,24 +890,14 @@ ivas_error check_ind_list_limits(
            if ( hBstr->ind_list >= ivas_ind_list_last )
            {
#ifdef DEBUGGING
#ifdef FIX_545_ASSERT
                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 );
#else
                /* TODO: replace with the warning message below before the finalization of the IVAS codec */
                /* 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 ); */
                assert( 0 && "The maximum number of indices has been exceeded! Increase the limits in get_ivas_max_num_indices() or get_max_num_indices_metadata()." );
#endif
#endif

                /* no available empty slot -> need to re-allocate the buffer */
#ifdef FIX_545_ASSERT
                if ( ( error = ind_list_realloc( hBstr, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#else
                ind_list_realloc( hBstr, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES );
#endif
            }
        }
        else
@@ -988,14 +955,10 @@ ivas_error push_indice(
#endif

    /* check the limits of the list of indices */
#ifdef FIX_545_ASSERT
    if ( ( 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", frame );
    }
#else
    error = check_ind_list_limits( hBstr );
#endif

    /* find the location in the list of indices based on ID */
    i = hBstr->nb_ind_tot;
@@ -1071,14 +1034,10 @@ ivas_error push_next_indice(
#endif

    /* check the limits of the list of indices */
#ifdef FIX_545_ASSERT
    if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#else
    error = check_ind_list_limits( hBstr );
#endif

    /* get the id of the previous indice -> it will be re-used */
    if ( hBstr->nb_ind_tot > 0 )
@@ -1109,17 +1068,9 @@ ivas_error push_next_indice(
 *-------------------------------------------------------------------*/

#ifdef DEBUG_BS_READ_WRITE
#ifdef FIX_545_ASSERT
ivas_error push_next_bits_(
#else
void push_next_bits_(
#endif
#else
#ifdef FIX_545_ASSERT
ivas_error push_next_bits(
#else
void push_next_bits(
#endif
#endif
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                     */
    const uint16_t bits[], /* i  : bit buffer to pack, sequence of single bits  */
@@ -1135,11 +1086,9 @@ void push_next_bits(
    int16_t i, nb_bits_m15;
    Indice *ptr;
    int16_t prev_id;
#ifdef FIX_545_ASSERT
    ivas_error error;

    error = IVAS_ERR_OK;
#endif
#ifdef DEBUG_BS_READ_WRITE
    printf( "%s: %d: %d\n", func, line, nb_bits );
#endif
@@ -1162,14 +1111,10 @@ void push_next_bits(
        code = (uint16_t) ( ( bits[i] << 15 ) | ( ( bits[i + 1] << 14 ) | ( ( bits[i + 2] << 13 ) | ( ( bits[i + 3] << 12 ) | ( ( bits[i + 4] << 11 ) | ( ( bits[i + 5] << 10 ) | ( ( bits[i + 6] << 9 ) | ( ( bits[i + 7] << 8 ) | ( ( bits[i + 8] << 7 ) | ( ( bits[i + 9] << 6 ) | ( ( bits[i + 10] << 5 ) | ( ( bits[i + 11] << 4 ) | ( ( bits[i + 12] << 3 ) | ( ( bits[i + 13] << 2 ) | ( ( bits[i + 14] << 1 ) | bits[i + 15] ) ) ) ) ) ) ) ) ) ) ) ) ) ) );

        /* check the limits of the list of indices */
#ifdef FIX_545_ASSERT
        if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
        {
            return IVAS_ERROR( error, "Error occured in push_next_bits() while re-allocating the list of indices (frame %d) !\n", frame );
        }
#else
        check_ind_list_limits( hBstr );
#endif
        ptr = &hBstr->ind_list[hBstr->nb_ind_tot];

        ptr->value = code;
@@ -1185,14 +1130,10 @@ void push_next_bits(
    for ( ; i < nb_bits; ++i )
    {
        /* check the limits of the list of indices */
#ifdef FIX_545_ASSERT
        if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
        {
            return IVAS_ERROR( error, "Error occured in push_next_bits() while re-allocating the list of indices (frame %d) !\n", frame );
        }
#else
        check_ind_list_limits( hBstr );
#endif
        ptr = &hBstr->ind_list[hBstr->nb_ind_tot];

        ptr->value = bits[i];
@@ -1207,11 +1148,7 @@ void push_next_bits(

    hBstr->nb_bits_tot = hBstr->nb_bits_tot + nb_bits;

#ifdef FIX_545_ASSERT
    return error;
#else
    return;
#endif
}


+0 −1
Original line number Diff line number Diff line
@@ -141,7 +141,6 @@

/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */

#define FIX_545_ASSERT                                  /* VA: fix issue 545, replace assert() with warning message when hitting memory limit in the buffer of indices */

#define FIX_563_PARAMMC_LIMITER                         /* FhG: issue 563: fix ILD limiter when coming from silence w/o transient set             */

+0 −12
Original line number Diff line number Diff line
@@ -501,17 +501,9 @@ ivas_error push_next_indice(

#ifdef DEBUG_BS_READ_WRITE
#define push_next_bits( ... ) push_next_bits_( __VA_ARGS__, __LINE__, __func__ )
#ifdef FIX_545_ASSERT
ivas_error push_next_bits_(
#else
void push_next_bits_(
#endif
#else
#ifdef FIX_545_ASSERT
ivas_error push_next_bits(
#else
void push_next_bits(
#endif
#endif
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle               */
    const uint16_t bits[], /* i  : bit buffer to pack, sequence of single bits */
@@ -555,11 +547,7 @@ ivas_error check_ind_list_limits(
    BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle                    */
);

#ifdef FIX_545_ASSERT
void move_indices(
#else
ivas_error move_indices(
#endif
    INDICE_HANDLE old_ind_list, /* i/o: old location of indices */
    INDICE_HANDLE new_ind_list, /* i/o: new location of indices */
    const int16_t nb_indices    /* i  : number of moved indices */