Commit 5c9b1761 authored by malenov's avatar malenov
Browse files

fixes within IND_LIST_DYN

parent fa905e29
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -48,8 +48,9 @@

#define WMC_TOOL_SKIP

#ifdef DEBUG_IND
extern int16_t total_num_id;
#ifdef DEBUG_IND_LIST
extern int16_t max_total_num_ind;
extern int32_t max_at_brate;
#endif

/*------------------------------------------------------------------------------------------*
@@ -572,9 +573,6 @@ int main(

    while ( 1 )
    {
#ifdef DEBUG_IND
        total_num_id = 0;
#endif

        /* Read the input data */
        if ( ( error = AudioFileReader_read( audioReader, pcmBuf, pcmBufSize, &numSamplesRead ) ) != IVAS_ERR_OK )
@@ -718,14 +716,6 @@ int main(
            goto cleanup;
        }

#ifdef DEBUG_IND
        {
            //int16_t tmp_i = -1;
            //dbgwrite( &tmp_i, sizeof( int16_t ), 1, 960 - total_num_id, "res/ind_list.x" );
            dbgwrite( &total_num_id, sizeof( int16_t ), 1, 1, "res/ind_total_num.x" );
        }
#endif

        frame++;
        if ( !arg.quietModeEnabled )
        {
@@ -753,6 +743,11 @@ int main(
    print_snr();
#endif

#ifdef DEBUG_IND_LIST
    printf( "\nMaximum total number of indices: %d at bitrate: %d\n", max_total_num_ind, max_at_brate );
#endif


    /*------------------------------------------------------------------------------------------*
     * Close files and deallocate resources
     *------------------------------------------------------------------------------------------*/
+66 −28
Original line number Diff line number Diff line
@@ -53,10 +53,6 @@

#ifdef DEBUGGING

#ifdef DEBUG_IND
int16_t total_num_id = 0;
#endif

#define FEC_SEED 12558

/*-------------------------------------------------------------------*
@@ -66,6 +62,11 @@ int16_t total_num_id = 0;
FILE *FEC_pattern = NULL; /* FEC pattern file (for simulation of FEC) */
#endif

#ifdef DEBUG_IND_LIST
int16_t max_total_num_ind = 0;
int32_t max_at_brate;
#endif

#ifndef IND_LIST_DYN
/*-------------------------------------------------------------------*
 * pack_bit()
@@ -272,16 +273,18 @@ ivas_error push_indice(
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice ID = %d with value %d is trying to allocate %d bits which exceeds 16 bits (frame %d) !\n", id, value, nb_bits, frame );
    }

#ifndef IND_LIST_DYN
    if ( id >= MAX_NUM_INDICES )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice ID = %d exceeds the total number of indices: %d (frame %d) !\n", id, MAX_NUM_INDICES, frame );
    }
#endif

#ifdef IND_LIST_DYN
    /* check, if max number of indices has not been exceeded */
    if ( hBstr->nb_ind_tot >= MAX_NUM_INDICES )
    if ( hBstr->nb_ind_tot >= hBstr->max_num_indices )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Maximum number of indices %d has been exceeded (frame %d) !\n", MAX_NUM_INDICES, frame );
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Maximum number of indices %d has been exceeded (frame %d) !\n", hBstr->max_num_indices, frame );
    }
#endif
#endif
@@ -341,17 +344,15 @@ ivas_error push_indice(
#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
#else
    hBstr->next_ind = i + 1;
#endif
    hBstr->last_ind = id;
    hBstr->nb_bits_tot += nb_bits;

#ifdef DEBUG_IND
    dbgwrite( &i, sizeof( int16_t ), 1, 1, "res/ind_list.x" );
    total_num_id++;
#endif

    return error;
}

@@ -397,10 +398,12 @@ ivas_error push_next_indice(
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice with value %d is trying to allocate %d bits which exceeds 16 bits !\n", value, nb_bits );
    }

#ifndef IND_LIST_DYN
    if ( hBstr->next_ind >= MAX_NUM_INDICES )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Total number of indices exceeded: %d !\n", MAX_NUM_INDICES );
    }
#endif

#ifndef IND_LIST_DYN
    if ( hBstr->ind_list[hBstr->next_ind].nb_bits > 0 )
@@ -425,25 +428,27 @@ ivas_error push_next_indice(
    /* store the values in the list */
#ifdef IND_LIST_DYN
    hBstr->ind_list[hBstr->nb_ind_tot].id = prev_id;
#endif
    hBstr->ind_list[hBstr->nb_ind_tot].value = value;
    hBstr->ind_list[hBstr->nb_ind_tot].nb_bits = nb_bits;
#else
    hBstr->ind_list[hBstr->next_ind].value = value;
    hBstr->ind_list[hBstr->next_ind].nb_bits = nb_bits;
#endif

    /* 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

#else
    hBstr->next_ind++;
#endif

    hBstr->nb_bits_tot += nb_bits;

#ifdef DEBUG_IND
    dbgwrite( &hBstr->last_ind, sizeof( int16_t ), 1, 1, "res/ind_list.x" );
    total_num_id++;
#endif

    return error;
}

@@ -506,13 +511,12 @@ void push_next_bits(
#ifdef IND_LIST_DYN
        ptr->id = prev_id;
        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
#endif
        ++ptr;

#ifdef DEBUG_IND
        dbgwrite( &hBstr->last_ind, sizeof( int16_t ), 1, 1, "res/ind_list.x" );
        total_num_id++;
#endif
    }

    for ( ; i < nb_bits; ++i )
@@ -525,19 +529,17 @@ void push_next_bits(
#ifdef IND_LIST_DYN
        ptr->id = prev_id;
        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
#endif
        ++ptr;

#ifdef DEBUG_IND
        dbgwrite( &hBstr->last_ind, sizeof( int16_t ), 1, 1, "res/ind_list.x" );
        total_num_id++;
#endif
    }

    hBstr->next_ind = (int16_t) ( ptr - hBstr->ind_list );
    hBstr->nb_bits_tot = hBstr->nb_bits_tot + nb_bits;


    return;
}

@@ -1086,20 +1088,56 @@ static ivas_error write_indices_element(
        if ( st_ivas->hSCE[element_id]->hMetaData != NULL )
        {
            reset_indices_enc( st_ivas->hSCE[element_id]->hMetaData, MAX_BITS_METADATA );
#ifdef IND_LIST_DYN
            st_ivas->hSCE[element_id]->hMetaData->max_num_indices = MAX_BITS_METADATA;
#endif
        }

#ifdef DEBUG_IND_LIST
        /* find the maximum number of core-coder indices */
        if ( sts[0]->hBstr->nb_ind_tot > max_total_num_ind )
        {
            max_total_num_ind = sts[0]->hBstr->nb_ind_tot;
            max_at_brate = sts[0]->total_brate;
        }
#endif

        reset_indices_enc( sts[0]->hBstr, MAX_NUM_INDICES );
        reset_indices_enc( sts[0]->hBstr,
#ifdef IND_LIST_DYN
            sts[0]->hBstr->max_num_indices
#else
            MAX_NUM_INDICES
#endif        
        );
    }
    else
    {
        if ( st_ivas->hCPE[element_id]->hMetaData != NULL )
        {
            reset_indices_enc( st_ivas->hCPE[element_id]->hMetaData, MAX_BITS_METADATA );
#ifdef IND_LIST_DYN
            st_ivas->hCPE[element_id]->hMetaData->max_num_indices = MAX_BITS_METADATA;
#endif
        }

        for ( n = 0; n < n_channels; n++ )
        {
            reset_indices_enc( sts[n]->hBstr, MAX_NUM_INDICES );
#ifdef DEBUG_IND_LIST
            /* find the maximum number of core-coder indices */
            if ( sts[n]->hBstr->nb_ind_tot > max_total_num_ind )
            {
                max_total_num_ind = sts[n]->hBstr->nb_ind_tot;
                max_at_brate = sts[0]->total_brate;
            }
#endif

            reset_indices_enc( sts[n]->hBstr, 
#ifdef IND_LIST_DYN
                               sts[n]->hBstr->max_num_indices
#else
                               MAX_NUM_INDICES
#endif        
            );
        }
    }

+2 −0
Original line number Diff line number Diff line
@@ -449,7 +449,9 @@ enum
    IND_STEREO_2ND_CODER_T,

    IND_UNUSED,
#ifndef IND_LIST_DYN
    MAX_NUM_INDICES = IND_UNUSED + 772 /* Total 2640 in line with MAX_BITS_METADATA */
#endif
};

/*----------------------------------------------------------------------------------*
+1 −1
Original line number Diff line number Diff line
@@ -57,8 +57,8 @@
/*#define MEM_COUNT_DETAILS*/                   /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */

/*#define BITSTREAM_INDICES_MEMORY*/                        /* Don't count memory for bitstream Indice at the encoder - it is a temporary solution for development only */
#define DEBUG_IND
#define IND_LIST_DYN                            /* dynamic allocation of ind_list based on transport channels */
#define DEBUG_IND_LIST

#ifdef DEBUGGING

+3 −0
Original line number Diff line number Diff line
@@ -2238,6 +2238,9 @@ void read_next_force(
#endif
ivas_error init_encoder(
    Encoder_State *st,               /* i/o: state structure                   */
#ifdef IND_LIST_DYN
    ENCODER_CONFIG_HANDLE hEncoderConfig, /* i  : encoder configuration handle            */
#endif
    const int16_t idchan,            /* i  : channel ID                        */
    const int16_t var_SID_rate_flag, /* i  : flag for variable SID update rate */
    const int16_t interval_SID,      /* i  : interval for SID update                */
Loading