Commit 94c829b2 authored by vaclav's avatar vaclav
Browse files

add error codes to bitstream buffer functions

parent f6ad1220
Loading
Loading
Loading
Loading
+40 −11
Original line number Diff line number Diff line
@@ -899,16 +899,13 @@ int16_t get_ivas_max_num_indices_metadata( /* o
 * Move indices inside the buffer or among two buffers
 *-------------------------------------------------------------------*/

ivas_error move_indices(
void move_indices(
    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;
    ivas_error error;

    error = IVAS_ERR_OK;

    if ( new_ind_list < old_ind_list )
    {
@@ -933,7 +930,7 @@ ivas_error move_indices(
        }
    }

    return error;
    return;
}

#endif
@@ -967,7 +964,10 @@ ivas_error check_ind_list_limits(
#endif

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

    /* check, if we will not overwrite an existing indice */
@@ -994,7 +994,10 @@ ivas_error check_ind_list_limits(
#endif

                /* no available empty slot -> need to re-allocate the buffer */
                ind_list_realloc( hBstr, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES );
                if ( ( error = ind_list_realloc( hBstr, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
        }
        else
@@ -1072,7 +1075,10 @@ ivas_error push_indice(

#ifdef IND_LIST_DYN
    /* check the limits of the list of indices */
    error = check_ind_list_limits( hBstr );
    if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice buffer writing failure (frame %d) !\n", frame );
    }
#endif

#ifdef IND_LIST_DYN
@@ -1195,7 +1201,11 @@ ivas_error push_next_indice(

#ifdef IND_LIST_DYN
    /* check the limits of the list of indices */
    error = check_ind_list_limits( hBstr );
    if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice buffer writing failure (frame %d) !\n", frame );
    }

#endif

#ifdef IND_LIST_DYN
@@ -1238,9 +1248,17 @@ ivas_error push_next_indice(
 *-------------------------------------------------------------------*/

#ifdef DEBUG_BS_READ_WRITE
#ifdef IND_LIST_DYN
ivas_error push_next_bits_(
#else
void push_next_bits_(
#endif
#else
#ifdef IND_LIST_DYN
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  */
@@ -1257,6 +1275,7 @@ void push_next_bits(
    Indice *ptr;
#ifdef IND_LIST_DYN
    int16_t prev_id;
    ivas_error error;
#endif
#ifdef DEBUG_BS_READ_WRITE
    printf( "%s: %d: %d\n", func, line, nb_bits );
@@ -1285,7 +1304,10 @@ void push_next_bits(

#ifdef IND_LIST_DYN
        /* check the limits of the list of indices */
        check_ind_list_limits( hBstr );
        if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
        {
            return IVAS_ERROR( error, "Indice buffer writing failure (frame %d) !\n", frame );
        }
        ptr = &hBstr->ind_list[hBstr->nb_ind_tot];
#endif

@@ -1305,7 +1327,10 @@ void push_next_bits(
    {
#ifdef IND_LIST_DYN
        /* check the limits of the list of indices */
        check_ind_list_limits( hBstr );
        if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
        {
            return IVAS_ERROR( error, "Indice buffer writing failure (frame %d) !\n", frame );
        }
        ptr = &hBstr->ind_list[hBstr->nb_ind_tot];
#endif

@@ -1326,7 +1351,11 @@ void push_next_bits(
#endif
    hBstr->nb_bits_tot = hBstr->nb_bits_tot + nb_bits;

#ifdef IND_LIST_DYN
    return IVAS_ERR_OK;
#else
    return;
#endif
}


+9 −1
Original line number Diff line number Diff line
@@ -505,9 +505,17 @@ ivas_error push_next_indice(

#ifdef DEBUG_BS_READ_WRITE
#define push_next_bits( ... ) push_next_bits_( __VA_ARGS__, __LINE__, __func__ )
#ifdef IND_LIST_DYN
ivas)error push_next_bits_(
#else
void push_next_bits_(
#endif
#else
#ifdef IND_LIST_DYN
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 */
@@ -548,7 +556,7 @@ ivas_error check_ind_list_limits(
    BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle                    */
);

ivas_error move_indices(
void move_indices(
    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 */