Commit cebf8d6d authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

Merge branch '1332-port-bitstream-debugging-from-float-repo' into 'main'

Port bitstream debugging from BASOP repo

See merge request !2144
parents c4a2e549 32316b04
Loading
Loading
Loading
Loading
Loading
+1984 −24

File changed.

Preview size limit exceeded, changes collapsed.

+2 −1
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/" */
+11 −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__ )
#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
#define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ )
#define push_next_bits( ... )   push_next_bits_( __func__, __VA_ARGS__ );
#endif


#if defined( DEBUGGING ) && defined( 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__ )
#if defined( DEBUGGING ) && defined( 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 */
+13 −0
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@
#include <assert.h>
#endif
#include "wmc_auto.h"
#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
#include <string.h>
#endif

/*-------------------------------------------------------------------*
 * ivas_corecoder_enc_reconfig()
@@ -167,6 +170,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;
#if defined( DEBUGGING ) && defined( 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 +377,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;
#if defined( DEBUGGING ) && defined( 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 +397,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;
#if defined( DEBUGGING ) && defined( 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;
+10 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@
#include "debug.h"
#endif
#include "wmc_auto.h"
#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
#include <string.h>
#endif


/*-------------------------------------------------------------------*
@@ -463,6 +466,13 @@ ivas_error ivas_init_encoder(
        st_ivas->ind_list[i].nb_bits = -1;
    }

#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
    for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ )
    {
        memset( st_ivas->ind_list[i].function_name, 'A', 100 * sizeof( char ) );
    }
#endif

    /* set the maximum allowed number of metadata indices in the list */
    st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate );

Loading