Commit 3edc172c authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

port DBG_BITSTREAM_ANALYSIS from BASOP MR 1478

parent c4a2e549
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -756,7 +756,13 @@ int main(
        }

        /* *** Encode one frame *** */
        if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits ) ) != IVAS_ERR_OK )
        if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits
#ifdef DBG_BITSTREAM_ANALYSIS
                                                     ,
                                                     frame
#endif

                                                     ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
            goto cleanup;
+2007 −26

File changed.

Preview size limit exceeded, changes collapsed.

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

#ifdef DEBUGGING
/*#define DBG_BITSTREAM_ANALYSIS*/              /* Write bitstream with annotations to a text file */
/*#define DEBUG_MODE_INFO*/                     /* output most important parameters to the subdirectory "res/" */
#ifdef DEBUG_MODE_INFO
/*#define DEBUG_MODE_ACELP*/                    /* output most important ACELP core parameters to the subdirectory "res/" */
+15 −44
Original line number Diff line number Diff line
@@ -484,53 +484,40 @@ void delay_signal(
    const int16_t delay /* i  : delay in samples                        */
);

#ifdef DEBUG_BS_READ_WRITE
#define push_indice( ... ) push_indice_( __VA_ARGS__, __LINE__, __func__ )
ivas_error push_indice_(
#else

ivas_error push_indice(
#endif
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                    */
    int16_t id,            /* i  : ID of the indice                            */
    uint16_t value,        /* i  : value of the quantized indice               */
    int16_t nb_bits        /* i  : number of bits used to quantize the indice  */
#ifdef DEBUG_BS_READ_WRITE
    ,
    int16_t line,
    const char *func
#endif
);

#ifdef DEBUG_BS_READ_WRITE
#define push_next_indice( ... ) push_next_indice_( __VA_ARGS__, __LINE__, __func__ )
#ifdef DBG_BITSTREAM_ANALYSIS
#define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ )
#define push_next_bits( ... )   push_next_bits_( __func__, __VA_ARGS__ );
#endif


#ifdef DBG_BITSTREAM_ANALYSIS
ivas_error push_next_indice_(
    const char *caller,
#else
ivas_error push_next_indice(
#endif
    BSTR_ENC_HANDLE hBstr,
    uint16_t value, /* i  : value of the quantized indice          */
    int16_t nb_bits /* i  : number of bits used to quantize the indice */
#ifdef DEBUG_BS_READ_WRITE
    ,
    int16_t line,
    const char *func
#endif
);

#ifdef DEBUG_BS_READ_WRITE
#define push_next_bits( ... ) push_next_bits_( __VA_ARGS__, __LINE__, __func__ )
#ifdef DBG_BITSTREAM_ANALYSIS
ivas_error push_next_bits_(
    const char *caller,
#else
ivas_error push_next_bits(
#endif
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle               */
    const uint16_t bits[], /* i  : bit buffer to pack, sequence of single bits */
    const int16_t nb_bits  /* i  : number of bits to pack                 */
#ifdef DEBUG_BS_READ_WRITE
    ,
    int16_t line,
    const char *func
#endif
);

/*! r: maximum number of indices */
@@ -581,19 +568,9 @@ uint16_t delete_indice(
);

/*! r: value of the indice */
#ifdef DEBUG_BS_READ_WRITE
#define get_next_indice( ... ) get_next_indice_( __VA_ARGS__, __LINE__, __func__ )
uint16_t get_next_indice_(
#else
uint16_t get_next_indice(
#endif
    Decoder_State *st, /* i/o: decoder state structure                */
    int16_t nb_bits    /* i  : number of bits that were used to quantize the indice */
#ifdef DEBUG_BS_READ_WRITE
    ,
    int16_t line,
    const char *func
#endif
);

/*! r: value of the indice */
@@ -607,20 +584,10 @@ void get_next_indice_tmp(
);

/*! r: value of the indice */
#ifdef DEBUG_BS_READ_WRITE
#define get_indice( ... ) get_indice_( __VA_ARGS__, __LINE__, __func__ )
uint16_t get_indice_(
#else
uint16_t get_indice(
#endif
    Decoder_State *st, /* i/o: decoder state structure                */
    int16_t pos,       /* i  : absolute position in the bitstream     */
    int16_t nb_bits    /* i  : number of bits that were used to quantize the indice */
#ifdef DEBUG_BS_READ_WRITE
    ,
    int16_t line,
    const char *func
#endif
);

/*! r: value of the indice */
@@ -642,6 +609,10 @@ ivas_error write_indices_ivas(
    Encoder_Struct *st_ivas, /* i/o: encoder state structure                                       */
    uint16_t *bit_stream,    /* i/o: output bitstream                                              */
    uint16_t *num_bits       /* i/o: number of bits written to output                              */
#ifdef DBG_BITSTREAM_ANALYSIS
    ,
    int32_t frame
#endif
);

Word16 rate2EVSmode(
+14 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@
#include <assert.h>
#endif
#include "wmc_auto.h"
#ifdef DBG_BITSTREAM_ANALYSIS
#include <string.h>
#endif


/*-------------------------------------------------------------------*
 * ivas_corecoder_enc_reconfig()
@@ -167,6 +171,10 @@ ivas_error ivas_corecoder_enc_reconfig(
                temp_ind_list[i].id = hBstr->ind_list[i].id;
                temp_ind_list[i].value = hBstr->ind_list[i].value;
                temp_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits;
#ifdef DBG_BITSTREAM_ANALYSIS
                strncpy( temp_ind_list[i].function_name, hBstr->ind_list[i].function_name, 100 );
#endif

                hBstr->ind_list[i].nb_bits = -1;
            }

@@ -370,6 +378,9 @@ ivas_error ivas_corecoder_enc_reconfig(
                    st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id;
                    st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value;
                    st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits;
#ifdef DBG_BITSTREAM_ANALYSIS
                    strncpy( st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].function_name, temp_ind_list[i].function_name, 100 );
#endif
                }

                nb_bits += temp_ind_list[i].nb_bits;
@@ -387,6 +398,9 @@ ivas_error ivas_corecoder_enc_reconfig(
                    st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id;
                    st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value;
                    st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits;
#ifdef DBG_BITSTREAM_ANALYSIS
                    strncpy( st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].function_name, temp_ind_list[i].function_name, 100 );
#endif
                }

                nb_bits += temp_ind_list[i].nb_bits;
Loading