Commit 37e36f33 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Few funcs in ivas_jbm_dec.c, synchonize_channels_mdct_sid converted

parent b7bb1f8e
Loading
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1517,4 +1517,16 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
  const Word16 nchan_in                                                                                         /* i  : number of input channels                              */
);

void configureFdCngDec_fx(
    HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */
    const Word16 bwidth,
    const Word32 total_brate,
    const Word16 L_frame,
    const Word16 last_L_frame,
    const Word16 element_mode );

void synchonize_channels_mdct_sid_fx(
    Decoder_State *sts[CPE_CHANNELS],                           /* i/o: decoder state structure                 */
    const Word16 n                                             /* i  : channel number                          */
);
#endif
+8 −0
Original line number Diff line number Diff line
@@ -8746,4 +8746,12 @@ void v_mult16_fixed(
    const Word16 N     /* i  : Vector length                                    */
);

void configureFdCngDec(
    HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */
    const Word16 bwidth,
    const Word32 total_brate,
    const Word16 L_frame,
    const Word16 last_L_frame,
    const Word16 element_mode );

#endif
+220 −0
Original line number Diff line number Diff line
@@ -370,6 +370,226 @@ void configureFdCngDec_flt(
    return;
}

#ifdef IVAS_FLOAT_FIXED
void configureFdCngDec_fx(
    HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */
    const Word16 bwidth,
    const Word32 total_brate,
    const Word16 L_frame,
    const Word16 last_L_frame,
    const Word16 element_mode )
{
    Word16 j, stopBandFR;
    HANDLE_FD_CNG_COM hsCom = hFdCngDec->hFdCngCom;

    hsCom->CngBandwidth = bwidth;
    move16();
    IF ( EQ_16( hsCom->CngBandwidth, FB ) )
    {
        hsCom->CngBandwidth = SWB;
        move16();
    }
    test();
    IF ( NE_32( total_brate, FRAME_NO_DATA ) && NE_32( total_brate, SID_2k40 ) )
    {
        hsCom->CngBitrate = total_brate;
        move32();
    }
    ELSE IF ( EQ_32( hsCom->CngBitrate, -1 ) )
    {
        /* set minimum active CBR bitrate IF CngBitrate is uninitialized */
        IF ( GT_16( element_mode, EVS_MONO ) )
        {
            hsCom->CngBitrate = IVAS_13k2;
            move32();
        }
        ELSE
        {
            hsCom->CngBitrate = ACELP_7k20;
            move32();
        }
    }

    /* FD-CNG config for MDCT-Stereo is always the same (since for > 48 kbps only) */
    /* This may need adjustment in the future IF 2TC DTX for some mode uses MDCT-Stereo DTX for lower bitrates too */
    IF ( EQ_16( element_mode, IVAS_CPE_MDCT ) )
    {
        hsCom->CngBitrate = IVAS_48k;
        move32();
    }
    hsCom->numSlots = 16;
    move32();

    /* NB configuration */
    IF ( EQ_16( bwidth, NB ) )
    {
        hsCom->FdCngSetup = FdCngSetup_nb;
        hsCom->numCoreBands = 16;
        move16();
        hsCom->regularStopBand = 16;
        move16();
    }

    /* WB configuration */
    ELSE IF ( EQ_16( bwidth, WB ) )
    {
        /* FFT 6.4kHz, no CLDFB */
        test();
        test();
        IF ( LE_32( hsCom->CngBitrate, ACELP_8k00 ) && EQ_16( L_frame, L_FRAME ) )
        {
            hsCom->FdCngSetup = FdCngSetup_wb1;
            hsCom->numCoreBands = 16;
            move16();
            hsCom->regularStopBand = 16;
            move16();
        }
        /* FFT 6.4kHz, CLDFB 8.0kHz */
        ELSE IF ( LE_32( hsCom->CngBitrate, ACELP_13k20 ) || EQ_16( L_frame, L_FRAME ) )
        {
            hsCom->FdCngSetup = FdCngSetup_wb2;
            hsCom->numCoreBands = 16;
            move16();
            hsCom->regularStopBand = 20;
            move16();
            IF ( EQ_16( L_frame, L_FRAME16k ) )
            {
                hsCom->FdCngSetup = FdCngSetup_wb2;
                hsCom->numCoreBands = 20;
                move16();
                hsCom->regularStopBand = 20;
                move16();
                hsCom->FdCngSetup.fftlen = 640;
                move16();
                hsCom->FdCngSetup.stopFFTbin = 256;
                move16();
            }
        }
        /* FFT 8.0kHz, no CLDFB */
        ELSE
        {
            hsCom->FdCngSetup = FdCngSetup_wb3;
            hsCom->numCoreBands = 20;
            move16();
            hsCom->regularStopBand = 20;
            move16();
        }
    }

    /* SWB/FB configuration */
    ELSE
    {
        /* FFT 6.4kHz, CLDFB 14kHz */
        IF ( EQ_16( L_frame, L_FRAME ) )
        {
            hsCom->FdCngSetup = FdCngSetup_swb1;
            hsCom->numCoreBands = 16;
            move16();
            hsCom->regularStopBand = 35;
            move16();
        }
        /* FFT 8.0kHz, CLDFB 16kHz */
        ELSE
        {
            hsCom->FdCngSetup = FdCngSetup_swb2;
            hsCom->numCoreBands = 20;
            move16();
            hsCom->regularStopBand = 40;
            move16();
            test();
            IF ( EQ_16( last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) )
            {
                hsCom->regularStopBand = 35;
                move16();
            }
        }
    }


    hsCom->fftlen = hsCom->FdCngSetup.fftlen;
    move16();
    hsCom->stopFFTbin = hsCom->FdCngSetup.stopFFTbin;
    move16();

    /* Configure the SID quantizer and the Comfort Noise Generator */

    hsCom->startBand = 2;
    move16();
    hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 );
    /* remove floating point dependency */
    initPartitions_flt( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize_flt, hsCom->psize_inv_flt, 0 );
    initPartitions(hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0);

    IF ( EQ_16( hsCom->stopFFTbin, 160 ) )
    {
        hsCom->nFFTpart = 17;
        move16();
    }
    ELSE IF ( EQ_16( hsCom->stopFFTbin, 256 ) )
    {
        hsCom->nFFTpart = 20;
        move16();
    }
    ELSE
    {
        hsCom->nFFTpart = 21;
        move16();
    }
    hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart );
    FOR ( j = 0; j < hsCom->nCLDFBpart; j++ )
    {
        hsCom->CLDFBpart[j] = sub( hsCom->part[j + hsCom->nFFTpart], sub( hsCom->stopFFTbin, hsCom->startBand ) );
        hsCom->CLDFBpsize_inv_flt[j] = hsCom->psize_inv_flt[j + hsCom->nFFTpart]; // TODO remove floating point dependency
        hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart];
        move16();
    }

    stopBandFR = 40; //(Word16)floor(1000.f /*Hz*/ / 25.f /*Hz/Bin*/);
    move16();
    IF ( GT_16( stopBandFR, hsCom->stopFFTbin ) )
    {
        stopBandFR = hsCom->stopFFTbin;
        move16();
    }

    initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping, stopBandFR );
    /* remove floating point dependency */
    initPartitions_flt( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping_float, hFdCngDec->psize_inv_shaping_float, stopBandFR );

    hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping;
    move16();

    SWITCH ( hsCom->fftlen )
    {
        case 512:
            hsCom->olapWinAna_fx = olapWinAna512_fx;
            hsCom->fftSineTab_fx = NULL;
            hsCom->olapWinSyn_fx = olapWinSyn256_fx;

            /* TODO: remove floating point dependency */
            hsCom->fftSineTab_flt = NULL;
            hsCom->olapWinAna_flt = olapWinAna512;
            hsCom->olapWinSyn_flt = olapWinSyn256;
            BREAK;
        case 640:
            hsCom->olapWinAna_fx = olapWinAna640_fx;
            hsCom->fftSineTab_fx = fftSineTab640_fx;
            hsCom->olapWinSyn_fx = olapWinSyn320_fx;

            /* remove floating point dependency */
            hsCom->fftSineTab_flt = fftSineTab640;
            hsCom->olapWinAna_flt = olapWinAna640;
            hsCom->olapWinSyn_flt = olapWinSyn320;
            BREAK;
        default:
            assert( !"Unsupported FFT length for FD-based CNG" );
            BREAK;
    }
    hsCom->frameSize = shr( hsCom->fftlen, 1 );

    return;
}
#endif

/*-------------------------------------------------------------------
 * deleteFdCngDec_flt()
+4 −1
Original line number Diff line number Diff line
@@ -212,8 +212,11 @@ ivas_error ivas_core_dec(
#else
            ivas_decision_matrix_dec( st, &sharpFlag[n], &core_switching_flag[n], element_brate, nchan_out );
#endif

#ifdef IVAS_FLOAT_FIXED
            synchonize_channels_mdct_sid_fx( sts, n );
#else
            synchonize_channels_mdct_sid( sts, n );
#endif

            if ( st->bfi != 1 ) /* note: st->bfi can be changed from 0 to 1 in ivas_decision_matrix_dec() when BER is detected */
            {
+251 −0
Original line number Diff line number Diff line
@@ -62,10 +62,25 @@ static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint1

static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas );

#ifdef IVAS_FLOAT_FIXED
static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const Word16 nCldfbTs );
#else
static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t nCldfbTs );
#endif



#ifdef IVAS_FLOAT_FIXED
static Word16 ceil_fx16( Word16 inp, Word16 Q );
static Word16 ceil_fx16( Word16 inp, Word16 Q ) {
    Word16 ret = shr( inp, Q );
    IF( inp & ( ( 1 << Q ) - 1) > 0) {
        ret = ret + 1;
    }
    return ret;
}
#endif

/*--------------------------------------------------------------------------*
 * ivas_jbm_dec_tc()
 *
@@ -4927,6 +4942,69 @@ void ivas_jbm_dec_tc_buffer_close(
void ivas_jbm_dec_td_renderers_adapt_subframes(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
)
#ifdef IVAS_FLOAT_FIXED
{
    Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, exp, 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 = BASOP_Util_Divide3216_Scale(st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &exp);
    tmp = shr(tmp, -1 - exp );
    tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &exp);
    nMaxSlotsPerSubframe = shr( tmp, ( 15 - exp ) );

    //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, ( 15 - exp ) );

    st_ivas->hTcBuffer->num_slots = nSlotsAvailable;
    move16();
    //st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity;
    st_ivas->hTcBuffer->n_samples_available = i_mult( nSlotsAvailable, st_ivas->hTcBuffer->n_samples_granularity );
    nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] );
    st_ivas->hTcBuffer->nb_subframes = 0;
    move16();

    IF ( nSlotsInFirstSubframe > 0 )
    {
        st_ivas->hTcBuffer->nb_subframes = 1;
        nSlotsAvailable -= nSlotsInFirstSubframe;
    }

    //st_ivas->hTcBuffer->nb_subframes += (int16_t) ceilf( (float) nSlotsAvailable / (float) nMaxSlotsPerSubframe );
    s1 = norm_s(nSlotsAvailable) - 1;
    s2 = norm_s(nMaxSlotsPerSubframe);

    tmp1 = shl( nSlotsAvailable, s1 );
    tmp2 = shl( nMaxSlotsPerSubframe, s2 );

    tmp = div_s(tmp1, tmp2);
    st_ivas->hTcBuffer->nb_subframes = add( st_ivas->hTcBuffer->nb_subframes, ceil_fx16(tmp, ( 15 - ( s2 - s1 ) ) ) );

    nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe;
    set_s( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
    set_s( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes );

    IF ( nSlotsInFirstSubframe > 0 )
    {
        st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe;
        move16();
    }

    IF ( nSlotsInLastSubframe > 0 )
    {
        st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe;
        move16();
    }

    st_ivas->hTcBuffer->slots_rendered = 0;
    move16();
    st_ivas->hTcBuffer->subframes_rendered = 0;
    move16();

    return;
}
#else
{
    int16_t nMaxSlotsPerSubframe, nSlotsAvailable;
    uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe;
@@ -4963,6 +5041,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes(

    return;
}
#endif


/*--------------------------------------------------------------------------*
@@ -5238,6 +5317,30 @@ void ivas_jbm_dec_copy_tc_no_tsm(

ivas_error ivas_jbm_dec_metadata_open(
    Decoder_Struct *st_ivas )
#ifdef IVAS_FLOAT_FIXED
{
    JBM_METADATA_HANDLE hJbmMetadata;
    IF ( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM metadata handle\n" ) );
    }
    hJbmMetadata->sf_write_idx = 0;
    move16();
    hJbmMetadata->sf_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_PARAM_SPATIAL_SUBFRAMES;
    move16();

    hJbmMetadata->slot_write_idx = 0;
    move16();
    hJbmMetadata->slot_read_idx = 0;
    move16();
    hJbmMetadata->slot_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME;
    move16();

    st_ivas->hJbmMetadata = hJbmMetadata;

    return IVAS_ERR_OK;
}
#else
{
    JBM_METADATA_HANDLE hJbmMetadata;
    if ( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL )
@@ -5255,6 +5358,8 @@ ivas_error ivas_jbm_dec_metadata_open(

    return IVAS_ERR_OK;
}
#endif



/*--------------------------------------------------------------------------*
@@ -5265,6 +5370,43 @@ ivas_error ivas_jbm_dec_metadata_open(

static void ivas_jbm_dec_copy_masa_meta_to_buffer(
    Decoder_Struct *st_ivas )
#ifdef IVAS_FLOAT_FIXED
{
    Word16 sf, dir, band;
    JBM_METADATA_HANDLE hJbmMetadata;
    MASA_DECODER_EXT_OUT_META *extOutMeta;
    Word16 write_idx;

    hJbmMetadata = st_ivas->hJbmMetadata;
    extOutMeta = st_ivas->hMasa->data.extOutMeta;

    FOR ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
    {
        write_idx = ( hJbmMetadata->sf_write_idx + sf ) % hJbmMetadata->sf_md_buffer_length;
        move16();
        FOR ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
        {
            FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
            {
                hJbmMetadata->directionIndexBuffer[dir][write_idx][band] = extOutMeta->directionIndex[dir][sf][band];
                move16();
                hJbmMetadata->directToTotalRatioBuffer[dir][write_idx][band] = extOutMeta->directToTotalRatio[dir][sf][band];
                hJbmMetadata->spreadCoherenceBuffer[dir][write_idx][band] = extOutMeta->spreadCoherence[dir][sf][band];
            }
        }

        FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
        {
            hJbmMetadata->diffuseToTotalRatioBuffer[write_idx][band] = extOutMeta->diffuseToTotalRatio[sf][band];
            hJbmMetadata->surroundCoherenceBuffer[write_idx][band] = extOutMeta->surroundCoherence[sf][band];
        }

        hJbmMetadata->numberOfDirections[write_idx] = extOutMeta->descriptiveMeta.numberOfDirections;
    }

    return;
}
#else
{
    int16_t sf, dir, band;
    JBM_METADATA_HANDLE hJbmMetadata;
@@ -5299,6 +5441,8 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer(

    return;
}
#endif



/*--------------------------------------------------------------------------*
@@ -5309,6 +5453,43 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer(

static void ivas_jbm_masa_sf_to_slot_map(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure     */
#ifdef IVAS_FLOAT_FIXED
    const Word16 nCldfbTs   /* i  : number of CLDFB time slots */
)
{
    Word16 sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME];
    Word16 num_slots_in_subfr;
    JBM_METADATA_HANDLE hJbmMetadata;
    Word16 slot_idx;
    Word16 write_idx, sf_index;

    /* Set values */
    hJbmMetadata = st_ivas->hJbmMetadata;
    num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES;
    move16();

    /* Map input subframes to slots */
    ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map );

    FOR ( slot_idx = 0; slot_idx < nCldfbTs; slot_idx++ )
    {
        write_idx = ( add( hJbmMetadata->slot_write_idx, slot_idx ) ) % hJbmMetadata->slot_md_buffer_length;
        move16();
        sf_index = ( add( hJbmMetadata->sf_write_idx, sf_to_slot_map[slot_idx] ) ) % hJbmMetadata->sf_md_buffer_length;
        move16();

        hJbmMetadata->sf_to_slot_map[write_idx] = sf_index;
        move16();
    }

    hJbmMetadata->sf_write_idx = ( add( hJbmMetadata->sf_write_idx, MAX_PARAM_SPATIAL_SUBFRAMES ) ) % hJbmMetadata->sf_md_buffer_length;
    move16();
    hJbmMetadata->slot_write_idx = ( add( hJbmMetadata->slot_write_idx, nCldfbTs ) ) % hJbmMetadata->slot_md_buffer_length;
    move16();

    return;
}
#else
    const int16_t nCldfbTs   /* i  : number of CLDFB time slots */
)
{
@@ -5338,6 +5519,7 @@ static void ivas_jbm_masa_sf_to_slot_map(

    return;
}
#endif


/*--------------------------------------------------------------------------*
@@ -5349,6 +5531,74 @@ static void ivas_jbm_masa_sf_to_slot_map(
void ivas_jbm_masa_sf_to_sf_map(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
)
#ifdef IVAS_FLOAT_FIXED
{
    Word16 sf_to_sf_map[MAX_PARAM_SPATIAL_SUBFRAMES];
    JBM_METADATA_HANDLE hJbmMetadata;
    MASA_DECODER_EXT_OUT_META *extOutMeta;
    Word16 slot_read_idx, sf_read_idx;
    Word16 sf_idx;
    Word16 dir, band;
    UWord8 numberOfDirections;

    /* Set values */
    hJbmMetadata = st_ivas->hJbmMetadata;
    extOutMeta = st_ivas->hMasa->data.extOutMeta;

    /* Map slots to subframes */
    FOR ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
    {
        slot_read_idx = ( add( hJbmMetadata->slot_read_idx, 2 ) ) % hJbmMetadata->slot_md_buffer_length; /* Take the latter one of the middle slots of the output subframe */
        move16();
        sf_to_sf_map[sf_idx] = hJbmMetadata->sf_to_slot_map[slot_read_idx];
        move16();
        hJbmMetadata->slot_read_idx = ( add( hJbmMetadata->slot_read_idx, CLDFB_SLOTS_PER_SUBFRAME ) ) % hJbmMetadata->slot_md_buffer_length;
        move16();
    }

    /* Copy mapped metadata to the EXT meta buffer for writing */
    FOR ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
    {
        sf_read_idx = sf_to_sf_map[sf_idx];
        move16();

        FOR ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
        {
            FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
            {
                extOutMeta->directionIndex[dir][sf_idx][band] = hJbmMetadata->directionIndexBuffer[dir][sf_read_idx][band];
                move16();
                extOutMeta->directToTotalRatio[dir][sf_idx][band] = hJbmMetadata->directToTotalRatioBuffer[dir][sf_read_idx][band];
                extOutMeta->spreadCoherence[dir][sf_idx][band] = hJbmMetadata->spreadCoherenceBuffer[dir][sf_read_idx][band];
            }
        }

        FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
        {
            extOutMeta->diffuseToTotalRatio[sf_idx][band] = hJbmMetadata->diffuseToTotalRatioBuffer[sf_read_idx][band];
            extOutMeta->surroundCoherence[sf_idx][band] = hJbmMetadata->surroundCoherenceBuffer[sf_read_idx][band];
        }
    }

    /* Determine the number of directions for the frame to be written */
    numberOfDirections = 0;
    FOR ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
    {
        sf_read_idx = sf_to_sf_map[sf_idx];
        move16();

        IF ( hJbmMetadata->numberOfDirections[sf_read_idx] == 1 )
        {
            numberOfDirections = 1;
            BREAK;
        }
    }

    extOutMeta->descriptiveMeta.numberOfDirections = numberOfDirections;

    return;
}
#else 
{
    int16_t sf_to_sf_map[MAX_PARAM_SPATIAL_SUBFRAMES];
    JBM_METADATA_HANDLE hJbmMetadata;
@@ -5409,3 +5659,4 @@ void ivas_jbm_masa_sf_to_sf_map(

    return;
}
#endif
 No newline at end of file
Loading