Commit 87bf9864 authored by sagnowski's avatar sagnowski
Browse files

Clean up TODO and NOTE comments

parent 9dad8491
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2472,7 +2472,7 @@ ivas_error ivas_jbm_dec_render_fx(
            {
                p_output_fx_const[i] = p_output_fx[i];
            }
            ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); // TODO(sgi): change num_samples_per_channel to unsigned
            ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered );
        }

#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR  // TODO(sgi): verify if this is needed in BASOP
+14 −48
Original line number Diff line number Diff line
@@ -1187,21 +1187,12 @@ static Word16 isar_get_frame_size(
         ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ||
           st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
    {
#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here	// NOTE(det2sgi): ar_div() is a better fit than divide3216
        nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES );
        nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize );
#else
        nSamplesPerChannel = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES );
        nSamplesPerChannel *= (int16_t) st_ivas->hDecoderConfig->render_framesize;
#endif
    }
    else
    {
#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here // NOTE(det2sgi): ar_div() is a better fit than divide3216
        nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC );
#else
        nSamplesPerChannel = output_Fs / FRAMES_PER_SEC;
#endif
    }

    return nSamplesPerChannel;
@@ -1221,8 +1212,10 @@ static ivas_error isar_render_poses(
    bool *needNewFrame           /* o  : indication that the decoder needs a new frame              */
)
{
    // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream,
#ifndef FIX_1119_SPLIT_RENDERING_VOIP
    // Note for reviewers: Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream,
    //                     see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference
#endif
    Word16 pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k];
    Decoder_Struct *st_ivas;
    ivas_error error;
@@ -1242,27 +1235,8 @@ static ivas_error isar_render_poses(
    /* init flush buffer for rate switch if not already initizalized */
    if ( hIvasDec->flushbuffer == NULL )
    {
#if 1 // NOTE(sgi2det): I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream.
      //                Generally I've seen arithmetic within calls to malloc() not ported, so maybe this is ok.
      // NOTE(det2sgi): D'accord. But was the sizeof(float) correct? 
        hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES );
        set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES );
#else // NOTE(sgi): originally from det
        Word32 tmp;
        /* numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) */
        tmp = imult3216( L_deposit_l( numPoses ), hIvasDec->nSamplesFrame );
        /* BINAURAL_CHANNELS=2, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES=4, sizeof (Word16)=2. */
        /* BINAURAL_CHANNELS * sizeof(Word16)/ IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = 4/4 = 1 */
        hIvasDec->flushbuffer = (void *) malloc( tmp );
        if ( hIvasDec->flushbuffer == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" );
        }
        hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; // NOTE(sgi2det): the BASOP version of this struct has no pcmType member - only 16 bit PCM is supported.
        /* hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = tmp/2 */
        tmp = L_shr( tmp, 1);
        set_zero( (Word16 *) hIvasDec->flushbuffer, tmp );
#endif
    }

    /* render */
@@ -1297,8 +1271,10 @@ static ivas_error isar_generate_metadata_and_bitstream(
    Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]    /* o  : Q-format of each channel of p_head_pose_buf */
)
{
    // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream,
#ifndef FIX_1119_SPLIT_RENDERING_VOIP
    // Note for reviewers: Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream,
    //                     see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference
#endif
    ivas_error error;
    ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend;
    Word16 max_band;
@@ -1312,24 +1288,14 @@ static ivas_error isar_generate_metadata_and_bitstream(

    hSplitBinRend = st_ivas->hSplitBinRend;

#if 1 // NOTE(sgi2det): The divide function includes a right shift so the result ends up 2x too small here.// NOTE(det2sgi): ar_div() is a better fit than divide3216
      //                I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. Maybe this can just stay here.
    max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); // TODO remove division
#else // NOTE(sgi): originally from det
    // NOTE(sgi): warning: implicit conversion from 'int' to 'Word16' (aka 'short') changes value from 48000 to -17536 [-Wconstant-conversion]
    max_band = divide3216( imult3216( BINAURAL_MAXBANDS, st_ivas->hDecoderConfig->output_Fs ), 48000 );
#endif
    max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 );
    pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
    cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type );

    // NOTE(sgi): BASOP special - not in float version
    n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
    assert( nSamples % n_samples_in_cldfb_slot == 0 );
#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here// NOTE(det2sgi): int_div_s_x() is a better fit for a 16x16->16 bit division
    num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot );
#else
    num_cldfb_slots = nSamples / n_samples_in_cldfb_slot;
#endif

    num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses;

@@ -1422,7 +1388,7 @@ static ivas_error isar_generate_metadata_and_bitstream(
        }
        Q_out[0] = add( Q_out[0], Q11 );
        Q_out[1] = Q_out[0];
        Q_buff = Q31 + Q6; // TODO(sgi): likely unneeded
        Q_buff = Q31 + Q6; // likely unneeded
    }

    IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend,
@@ -1596,7 +1562,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    bool *needNewFrame                        /* o  : indication that the decoder needs a new frame                           */
)
{
#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi2det): this function still needs to be ported to BASOP
#ifdef FIX_1119_SPLIT_RENDERING_VOIP // TODO(sgi): this function still needs to be ported to BASOP
    Decoder_Struct *st_ivas;
    ivas_error error;
    Word32 head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k];
@@ -1916,7 +1882,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        ivas_syn_output_fx( pOutput, Q11, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (Word16 *) pcmBuf_out );
    }

#ifndef TMP_FIX_SPLIT_REND // TODO(sgi): need to port?
#ifndef TMP_FIX_SPLIT_REND
    free( st_ivas->hSplitBinRend->hMultiBinCldfbData );
#endif
#endif
+12 −8
Original line number Diff line number Diff line
@@ -410,7 +410,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural(

            tmp_e = 0;
            tmp = BASOP_Util_Divide3232_Scale( L_mult0( CLDFB_NO_COL_MAX, ivas_fs ), 20, &tmp_e );
            num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0                     // NOTE(sgi): this could be a macro constant?
            num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0
                                                      // num_slots = (Word16) CLDFB_NO_COL_MAX * ivas_fs  / 20;
            /* CLDFB synthesis of main pose */
            {
@@ -494,11 +494,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural(
    ELSE
    {
        Word16 ch, slot_idx, num_slots;
#if 1 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does.// NOTE(det2sgi): Missing Division by 10 added
        num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */
#else
        num_slots = isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS; 
#endif
        num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10);

        /* CLDFB synthesis of main pose */
        FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
@@ -509,7 +505,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural(
            move16();
            q2 = 31;
            move16();
            FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version
#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version
            FOR( j = 0; j < num_slots; j++ )
#else
            FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ )
#endif
            {
                q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 );
                q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 );
@@ -518,7 +518,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural(
            q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) );
            q_final = sub( q_final, 6 ); // guard bits
            q_final = s_min( q_final, Q25 );
            FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version
#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version
            FOR( j = 0; j < num_slots; j++ )
#else
            FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ )
#endif
            {
                Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) );
                Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) );
+2 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include "ivas_prot_rend_fx.h"
#include "options.h"
#include "wmc_auto.h"
#include "prot_fx.h"


/*-----------------------------------------------------------------------*
@@ -447,5 +448,5 @@ Word16 ivas_TD_RINGBUF_Size(
    const TD_RINGBUF_HANDLE h /* i  : Ring buffer handle */
)
{
    return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels; // TODO(sgi): port division
    return extract_l( ar_div( ivas_td_ringbuf_total_size( h ), L_deposit_l( h->num_channels ) ) );
}