Commit 651a4334 authored by multrus's avatar multrus
Browse files

[cleanup] accept LFE_NO_ENTROPY_CODING, FIX_79_MASA2TC_BITRATE_SWITCHING

parent 385f0e19
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -147,8 +147,6 @@
/*#define FIX_I1_113*/                                  /* under review : MCT bit distribution optimization for SBA high bitrates*/


#define LFE_NO_ENTROPY_CODING                           /* issue 65: changes to add no entropy coding in LFE */
#define FIX_79_MASA2TC_BITRATE_SWITCHING                /* Nokia: Fix issue 79 on MASA 2TC bitrate switching crash in decoder. */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+0 −8
Original line number Diff line number Diff line
@@ -154,10 +154,8 @@ static int16_t ivas_lfe_dec_dequant(
{
    int16_t shift_bits, i;
    int16_t quant_strategy;
#ifdef LFE_NO_ENTROPY_CODING
    int16_t coding_strategy;
    int16_t base2_bit_size;
#endif
    int16_t lfe_bits;
    int16_t all_zeros_dct;
    int16_t min_shift_bits;
@@ -199,7 +197,6 @@ static int16_t ivas_lfe_dec_dequant(
            sign_bits[i] = get_next_indice( st0, 1 );
        }

#ifdef LFE_NO_ENTROPY_CODING
        coding_strategy = get_next_indice( st0, 1 );

        if ( coding_strategy )
@@ -214,7 +211,6 @@ static int16_t ivas_lfe_dec_dequant(
            }
        }
        else
#endif
        {
            for ( iii = 0; iii < num_groups; iii++ )
            {
@@ -364,9 +360,7 @@ ivas_error ivas_create_lfe_dec(
    const float *filt_coeff;
    LFE_DEC_HANDLE hLFE;
    float lfe_addl_delay_s;
#ifdef LFE_NO_ENTROPY_CODING
    int16_t i, j;
#endif

    low_pass_delay_dec_out = 0;
    block_offset_s = 0;
@@ -458,7 +452,6 @@ ivas_error ivas_create_lfe_dec(
        hLFE->lfe_delay_buf = NULL;
    }

#ifdef LFE_NO_ENTROPY_CODING
    /* Initialization base2 bits for each subgroup for no entropy coding */
    for ( i = 0; i < IVAS_MAX_NUM_QUANT_STRATS; i++ )
    {
@@ -468,7 +461,6 @@ ivas_error ivas_create_lfe_dec(
                (int16_t) ceilf( log2f( (float) ( ivas_lfe_num_ele_in_coder_models[i][j] + 1 ) ) );
        }
    }
#endif

    *hLFE_out = hLFE;

+0 −2
Original line number Diff line number Diff line
@@ -1860,9 +1860,7 @@ typedef struct ivas_lfe_dec_data_structure
    ivas_filters_process_state_t filter_state;
    LFE_WINDOW_HANDLE pWindow_state;
    const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
#ifdef LFE_NO_ENTROPY_CODING
    int16_t lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
#endif
    float lfe_block_delay_s;
    int16_t lfe_prior_buf_len;
    float *prior_out_buffer;
+0 −4
Original line number Diff line number Diff line
@@ -891,14 +891,12 @@ ivas_error stereo_memory_dec(
                count_free( hCPE->prev_synth_chs[1] );
                hCPE->prev_synth_chs[1] = NULL;
            }
#ifdef FIX_79_MASA2TC_BITRATE_SWITCHING
            
            if ( hCPE->hStereoTCA != NULL )
            {
                count_free( hCPE->hStereoTCA );
                hCPE->hStereoTCA = NULL;
            }
#endif
        }
        else /* nchan_out == 2 */
        {
@@ -917,7 +915,6 @@ ivas_error stereo_memory_dec(
                }
                set_zero( hCPE->prev_synth_chs[1], NS2SA( st->output_Fs, FRAME_SIZE_NS ) );
            }
#ifdef FIX_79_MASA2TC_BITRATE_SWITCHING

            if ( hCPE->hStereoICBWE == NULL && hCPE->element_mode == IVAS_CPE_DFT )
            {
@@ -954,7 +951,6 @@ ivas_error stereo_memory_dec(
                    hCPE->hStereoICBWE = NULL;
                }
            }
#endif
        }
    }

+0 −33
Original line number Diff line number Diff line
@@ -105,13 +105,11 @@ static void ivas_lfe_enc_quant(
    int16_t values[IVAS_LFE_MAX_NUM_DCT_COEFFS << 1];
    float temp_lfe_dct[IVAS_LFE_MAX_NUM_DCT_COEFFS];
    int16_t target_bits;
#ifdef LFE_NO_ENTROPY_CODING
    int16_t base2_num_bits_tot;
    int16_t coding_strategy;
    int16_t bits_written_arith_enc;
    int16_t next_ind_pos_arith_enc;
    int16_t num_ele_per_grp = IVAS_LFE_NUM_COEFFS_IN_SUBGRP << 1;
#endif

    target_bits = (int16_t) ( IVAS_LFE_BITRATE_5000 / FRAMES_PER_SEC );

@@ -134,9 +132,7 @@ static void ivas_lfe_enc_quant(
        uint16_t all_zeros_dct;

        lfe_abs_sum = 0;
#ifdef LFE_NO_ENTROPY_CODING
        coding_strategy = 0;
#endif
        num_dct_pass_bins = ivas_lfe_num_dct_pass_bins_tbl[quant_strategy];
        max_of_vals = 0;
        num_groups = num_dct_pass_bins >> 1;
@@ -246,43 +242,19 @@ static void ivas_lfe_enc_quant(
            push_next_indice( hBstr, write_bit, 1 );
        }

#ifdef LFE_NO_ENTROPY_CODING
        bits_written_arith_enc = hBstr->nb_bits_tot;
        next_ind_pos_arith_enc = hBstr->next_ind;
        push_next_indice( hBstr, coding_strategy, 1 );
        base2_num_bits_tot = hBstr->nb_bits_tot - bits_written;
#endif

        ivas_lfe_arith_coding( hLFE, hBstr, quant_strategy, values );

#ifdef LFE_NO_ENTROPY_CODING
        for ( i = 0; i < num_groups; i++ )
        {
            int16_t base2_num_bits = hLFE->lfe_enc_indices_coeffs_tbl[quant_strategy][i];
            base2_num_bits_tot += ( num_ele_per_grp * base2_num_bits );
        }
#endif

#ifndef LFE_NO_ENTROPY_CODING
        if ( ( target_bits + IVAS_LFE_ID_BITS ) >= ( hBstr->nb_bits_tot - bits_written ) )
        {
            break;
        }
        else
        {
            if ( quant_strategy < ( num_quant_strategies - 1 ) )
            {
                /* reset all indices that were already written - TODO: maybe better store them temporarily first and write at the very end? */
                for ( j = hBstr->next_ind - 1; j >= next_ind_pos; j-- )
                {
                    hBstr->ind_list[j].nb_bits = 0;
                }

                hBstr->nb_bits_tot = bits_written;
                hBstr->next_ind = next_ind_pos;
            }
        }
#else
        if ( ( base2_num_bits_tot ) < ( hBstr->nb_bits_tot - bits_written ) )
        {
            if ( quant_strategy == ( num_quant_strategies - 1 ) || ( ( target_bits + IVAS_LFE_ID_BITS ) >= base2_num_bits_tot ) )
@@ -336,7 +308,6 @@ static void ivas_lfe_enc_quant(
                }
            }
        }
#endif
    }

    /* bits spent for LFE coding */
@@ -412,9 +383,7 @@ ivas_error ivas_create_lfe_enc(
    int16_t input_frame;
    LFE_ENC_HANDLE hLFE;
    const float *filt_coeff;
#ifdef LFE_NO_ENTROPY_CODING
    int16_t i, j;
#endif

    input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC );

@@ -468,7 +437,6 @@ ivas_error ivas_create_lfe_enc(
    hLFE->cum_freq_models[1][2] = ivas_str_lfe_freq_models.entropy_coder_model_coarse_sg3;
    hLFE->cum_freq_models[1][3] = &ivas_str_lfe_freq_models.entropy_coder_model_coarse_sg4;

#ifdef LFE_NO_ENTROPY_CODING
    /* Initialization base2 bits for each subgroup for no entropy coding */
    for ( i = 0; i < IVAS_MAX_NUM_QUANT_STRATS; i++ )
    {
@@ -478,7 +446,6 @@ ivas_error ivas_create_lfe_enc(
                (int16_t) ceilf( log2f( (float) ( ivas_lfe_num_ele_in_coder_models[i][j] + 1 ) ) );
        }
    }
#endif

    *hLFE_out = hLFE;

Loading