Commit 1d9b752a authored by thomas dettbarn's avatar thomas dettbarn
Browse files

lib_isar_pre_rend.c and lib_dec_fx.c called the wrong functions for divisons.

parent 8c67d5ab
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -1262,8 +1262,8 @@ 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 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here
        nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES );
#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 );
@@ -1272,8 +1272,8 @@ static Word16 isar_get_frame_size(
    }
    else
    {
#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here
        nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC );
#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
@@ -1319,7 +1319,8 @@ static ivas_error isar_render_poses(
    {
#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.
        hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) );
      // 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;
@@ -1371,6 +1372,7 @@ static ivas_error isar_render_poses(
        // NOTE(sgi2det): We need signal in 32 bit here, but get only 16 bit from IVAS_DEC_GetSamplesRenderer...
        //                The float version of that function has switchable output format (int16 or float) but not in BASOP.
        //                Any ideas for a better solution than this pcmBuf32?
        // NOTE(det2sgi): Was the requirement for the TD_Ringbuf a 32 Bit Datatype? A 16 Bit would make more sense.
        ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples );
    }

@@ -1407,9 +1409,9 @@ 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.
#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) ( ( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); // TODO remove division
    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 );
@@ -1420,8 +1422,8 @@ static ivas_error isar_generate_metadata_and_bitstream(
    // 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 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here
    num_cldfb_slots = extract_l( divide3216( L_deposit_l( nSamples ), n_samples_in_cldfb_slot ) );
#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
+2 −2
Original line number Diff line number Diff line
@@ -494,8 +494,8 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural(
    ELSE
    {
        Word16 ch, slot_idx, num_slots;
#if 0 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does.
        num_slots = shl( isar_frame_size_ms, 3); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */
#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