Commit e81514ef authored by vaclav's avatar vaclav
Browse files

replace hardcoded numbers by ONE_BY_SUBFR_PER_SEC_Q15

parent a69ea576
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1676,7 +1676,7 @@ int main(

    ObjectPositionBuffer mtdBuffer;
    outBuffer.pq_fact = &outBuffer.q_factor;
    Word16 subframe_len = (Word16) ( args.sampleRate / ( 200 ) ); // sample rate /FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES
    Word16 subframe_len = (Word16) ( args.sampleRate / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) );
    Word16 gd_bits = find_guard_bits( subframe_len );
    Word16 prev_q_fact = Q11;
    while ( 1 )
+0 −3
Original line number Diff line number Diff line
@@ -593,12 +593,9 @@ enum
 *----------------------------------------------------------------------------------*/

#define FRAMES_PER_SEC                      50
#define MAX_PARAM_SPATIAL_SUB_FRAMES_PER_SEC              200 //(FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)
#define ONE_BY_SUBFRAME_LEN_MS_Q31                (429496730)
#define ONE_BY_FRAMES_PER_SEC_Q31           ( 42949673 )
#define FRAMES_PER_SEC_BY_2                 (FRAMES_PER_SEC >> 1)
#define INV_FRAME_PER_SEC_Q15               656
#define INV_FR_P_S_MX_PRM_SPL_SBFR_Q15      164
#define FRAME_SIZE_NS                       20000000L

#define ACELP_LOOK_NS                       8750000L
+3 −2
Original line number Diff line number Diff line
@@ -204,14 +204,15 @@ typedef enum
#define EDIT_GAIN_MAX_Q12                       16306                       /* Maximum allowed object gain edit in Q12: 3.9810719f,  +12 dB */
#endif



typedef enum
{
    TC_BUFFER_MODE_RENDERER,
    TC_BUFFER_MODE_BUFFER
} TC_BUFFER_MODE;

#define ONE_BY_SUBFRAME_LEN_MS_Q31              429496730
#define ONE_BY_SUBFR_PER_SEC_Q15                164


/*----------------------------------------------------------------------------------*
 * IVAS Bitrates
+1 −1
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ void ivas_ism_render_sf_fx(
    {
        Word16 n_samples_in_subframe;

        n_samples_in_subframe = st_ivas->hTcBuffer->n_samples_granularity * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx];
        n_samples_in_subframe = imult1616(st_ivas->hTcBuffer->n_samples_granularity , st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]);
        test();
        IF( st_ivas->hCombinedOrientationData && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) )
        {
+21 −16
Original line number Diff line number Diff line
@@ -2856,12 +2856,12 @@ ivas_error ivas_jbm_dec_set_discard_samples_fx(
{
    Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe;
    Word16 temp, temp_e;

    /* render first frame with front zero padding and discarding those samples */
    // nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity;
    temp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), &temp_e );
    temp = shr( temp, sub( 15, temp_e ) );
    nMaxSlotsPerSubframe = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e );
    nMaxSlotsPerSubframe = shr( nMaxSlotsPerSubframe, sub( 15, temp_e ) ); // Q0
    /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */
    temp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 );
    temp = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e );
    nMaxSlotsPerSubframe = shr( temp, sub( 15, temp_e ) ); /* Q0 */
    nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] );
    IF( nSlotsInFirstSubframe > 0 )
    {
@@ -3500,7 +3500,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx(
    Word16 nMaxSlotsPerSubframe;
    ivas_error error;
    Word16 tmp, tmp_e;
    Word32 tmp32;

    /*-----------------------------------------------------------------*
     * prepare library opening
@@ -3538,9 +3537,10 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx(
    hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES;
    move16();

    tmp32 = L_mult0( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, hTcBuffer->n_samples_granularity ); // Q0
    tmp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, tmp32, &tmp_e );
    nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); // Q0
    /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */
    tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 );
    tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e );
    nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */

    hTcBuffer->num_slots = mult0( nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES );
    move16();
@@ -3606,8 +3606,13 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) )
    {
        Word16 nMaxSlotsPerSubframeNew;
        Word16 tmp, tmp_e;

        /* nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; */
        tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 );
        tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e );
        nMaxSlotsPerSubframeNew = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */

        nMaxSlotsPerSubframeNew = idiv1616( divide3216( st_ivas->hDecoderConfig->output_Fs, ( ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) >> 1 ) ), n_samples_granularity ); // Q0
        /* if samples were flushed, take that into account here */
        test();
        IF( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && hTcBuffer->n_samples_flushed > 0 )
@@ -3739,17 +3744,17 @@ void ivas_jbm_dec_td_renderers_adapt_subframes(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
)
{
    Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, exp, tmp1, tmp2, s1, s2;
    Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, tmp_e, tmp1, tmp2, s1, s2;
    UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe;

    /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; */
    tmp = extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) );
    tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &exp );
    nMaxSlotsPerSubframe = shr( tmp, sub( 15, exp ) ); // Q0
    tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 );
    tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e );
    nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */

    /* nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */
    tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp );
    nSlotsAvailable = shr( tmp, sub( 15, exp ) ); // Q0
    tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e );
    nSlotsAvailable = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */

    st_ivas->hTcBuffer->num_slots = nSlotsAvailable;
    move16();
Loading