Commit 72748eeb authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

FTF changes for ivas_qmetadata_to_dirac_fx and ivas_dirac_dec_set_md_map

Added changes for the following funcitons:
[x] ivas_qmetadata_to_dirac_fx()
[x] ivas_dirac_config_bands_fx()
[x] rand_triangular_signed_fx()
[x] ivas_dirac_dec_set_md_map()
[x] ivas_jbm_dec_get_adapted_subframes()
[x] ivas_jbm_dec_get_md_map_even_spacing()
[x] ivas_jbm_dec_get_md_map()
[x] ivas_get_hodirac_flag_fx()
[x] ivas_get_bits_to_encode_fx()
[x] ivas_get_spar_table_idx_fx()
parent 044085bf
Loading
Loading
Loading
Loading
Loading
+116 −1
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@
#include "prot.h"
#include "cnst.h"
#include "wmc_auto.h"

#include "prot_fx1.h"
#include "prot_fx2.h"

/*-----------------------------------------------------------------------*
 * Local function prototypes
@@ -74,7 +75,23 @@ int16_t ivas_get_hodirac_flag(
    }
}

#ifdef IVAS_FLOAT_FIXED
Word16 ivas_get_hodirac_flag_fx(
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate      */
    const Word16 sba_order         /* i  : Ambisonic (SBA) order   */
)
{
    IF( GT_16( sba_order, 1 ) && GT_32( ivas_total_brate, IVAS_256k ) )
    {
        return 1;
    }
    ELSE
    {
        return 0;
    }
}

#endif
/*-------------------------------------------------------------------------
 * ivas_dirac_sba_config()
 *
@@ -312,6 +329,104 @@ void ivas_dirac_config_bands(
    return;
}

#ifdef IVAS_FLOAT_FIXED
void ivas_dirac_config_bands_fx(
    Word16 *band_grouping, /* o  : band grouping                          */
    const Word16 nbands,   /* i  : number of bands                        */
    const Word16 max_band, /* i  : maximal band index +1                  */
    Word16 *dirac_to_spar_md_bands,
    const Word8 useLowerBandRes,
    const Word16 enc_param_start_band,
    IVAS_FB_MIXER_HANDLE hFbMdft )
{
    Word16 i;
    {
        IF( EQ_16( nbands, 5 ) )
        {
            Copy( DirAC_band_grouping_5, band_grouping, 5 + 1 );
        }
        ELSE IF(EQ_16( nbands, 6 ) )
        {
            Copy( DirAC_band_grouping_6, band_grouping, 6 + 1 );
        }
        ELSE IF(EQ_16( nbands, 12 ) )
        {
            Word16 band;
            FOR( band = 0; band < DIRAC_MAX_NBANDS; band++ )
            {
                dirac_to_spar_md_bands[band] = band;
            }
            IF( hFbMdft != NULL )
            {
                Word16 sb, idx1, idx2, b;

                idx1 = -1;
                sb = 0;
                FOR( b = 0; b < max_band; b++ )
                {
                    idx2 = hFbMdft->pFb->fb_bin_to_band.p_cldfb_map_to_spar_band[b];
                    IF( GT_16( idx2, idx1 ) )
                    {
                        band_grouping[sb++] = b;
                        idx1 = idx2;
                    }
                }
                band_grouping[sb] = max_band;

                /* set the remaining bands to max_band to avoid problems for the DirAC parameter estimation with bw < FB */
                FOR( b = sb; b <= nbands; b++ )
                {
                    band_grouping[b] = max_band;
                }
            }
            ELSE
            {
                Copy( DirAC_band_grouping_12, band_grouping, 12 + 1 );
            }

            IF( useLowerBandRes )
            {
                Word16 step = DIRAC_LOW_BANDRES_STEP;
                Word16 reduced_band;
                for ( band = enc_param_start_band + 2, reduced_band = enc_param_start_band + 1; band <= DIRAC_MAX_NBANDS; band += step, reduced_band++ )
                {
                    band_grouping[reduced_band] = band_grouping[band];
                }
                FOR( ; reduced_band <= DIRAC_MAX_NBANDS; reduced_band++ )
                {
                    band_grouping[reduced_band] = max_band;
                }
                for ( band = enc_param_start_band + ( DIRAC_MAX_NBANDS - enc_param_start_band ) / 2 - 1, reduced_band = DIRAC_MAX_NBANDS - 1; band >= enc_param_start_band; band--, reduced_band -= step )
                {
                    dirac_to_spar_md_bands[reduced_band] = dirac_to_spar_md_bands[band];
                    dirac_to_spar_md_bands[reduced_band - 1] = dirac_to_spar_md_bands[band];
                }
            }
            ELSE
            {
                /* always code the last two fb bands together */
                band_grouping[DIRAC_MAX_NBANDS - 1] = max_band;
                dirac_to_spar_md_bands[DIRAC_MAX_NBANDS - 1] = DIRAC_MAX_NBANDS - 2;
            }
        }
        ELSE
        {
            assert( 0 && "nbands must be 5 or 6!" );
        }
    }

    /* Limit the band range to band max */
    FOR( i = 0; i < nbands + 1; i++ )
    {
        IF( GT_16( band_grouping[i], max_band ) )
        {
            band_grouping[i] = max_band;
        }
    }

    return;
}
#endif
/*-------------------------------------------------------------------*
 * ivas_get_dirac_sba_max_md_bits()
 *
+31 −3
Original line number Diff line number Diff line
@@ -760,6 +760,11 @@ int16_t get_igf_startline_flt(
float rand_triangular_signed(
    int16_t *seed );

#ifdef IVAS_FLOAT_FIXED
Word16 rand_triangular_signed_fx(
    int16_t *seed,
    Word16 *exp_fac);
#endif
Word64 var_32_fx(
	const Word32 *x,   /* i  : input vector                          */
	const int16_t len, /* i  : length of inputvector                 */
@@ -3269,7 +3274,19 @@ int16_t ivas_qmetadata_dec_sid_decode(
    int16_t *element_mode,                                      /* o  : element mode                            */
    const int16_t ivas_format                                   /* i  : IVAS format                             */
);

#ifdef IVAS_FLOAT_FIXED
void ivas_qmetadata_to_dirac_fx(
    const IVAS_QMETADATA_HANDLE hQMetaData,               /* i  : frame of MASA q_metadata        */
    DIRAC_DEC_HANDLE hDirAC,                              /* i  : DirAC decoder structure         */
    MASA_DECODER_HANDLE hMasa,                            /* i  : MASA decoder structure          */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle     */
    const int32_t ivas_total_brate,                       /* i  : IVAS total bitrate              */
    const IVAS_FORMAT ivas_format,                        /* i  : IVAS format                     */
    const int16_t hodirac_flag,                           /* i  : flag to indicate HO-DirAC mode  */
    int16_t *dirac_to_spar_md_bands,                      /* o  : DirAC->SPAR MD bands            */
    Word32 q
);
#else
void ivas_qmetadata_to_dirac(
    const IVAS_QMETADATA_HANDLE hQMetaData,                     /* i  : frame of MASA q_metadata                */
    DIRAC_DEC_HANDLE hDirAC,                                    /* i  : DirAC decoder structure                 */
@@ -3280,7 +3297,7 @@ void ivas_qmetadata_to_dirac(
    const int16_t hodirac_flag,                                 /* i  : flag to indicate HO-DirAC mode          */
    int16_t *dirac_to_spar_md_bands                            /* o  : DirAC->SPAR MD bands                    */
);

#endif
ivas_error ivas_qmetadata_open(
    IVAS_QMETADATA_HANDLE *hQMetaData                           /* i/o: q_metadata handle                       */
);
@@ -3709,6 +3726,17 @@ void ivas_dirac_config_bands(
    IVAS_FB_MIXER_HANDLE hFbMdft
);

#ifdef IVAS_FLOAT_FIXED
void ivas_dirac_config_bands_fx(
    Word16 *band_grouping,                                     /* o  : band grouping                           */
    const Word16 nbands,                                       /* i  : number of bands                         */ 
    const Word16 max_band,                                     /* i  : maximal band index +1                   */
    Word16 *dirac_to_spar_md_bands,                            /* o  : mapping of DirAC parameter band index to SPAR FB band index */
    const Word8 useLowerBandRes,                               /* i  : flag indicating lower band resolution for DirAC             */
    const Word16 enc_param_start_band,                         /* i  : band index of first DirAC parameter band                    */
    IVAS_FB_MIXER_HANDLE hFbMdft
);
#endif
void ivas_get_dirac_sba_max_md_bits(
    const int32_t sba_total_brate,
    int16_t *bits_frame_nominal,
+47 −0
Original line number Diff line number Diff line
@@ -268,4 +268,51 @@ void stereo_dft_dec_core_switching_fx(
    Word16 *q,
    Word16 *q_DFT );

Word16 ivas_get_hodirac_flag_fx(
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate      */
    const Word16 sba_order         /* i  : Ambisonic (SBA) order   */
);

void ivas_sba_config_fx(
    const Word32 sba_total_brate, /* i  : SBA total bitrate                        */
    Word16 sba_order,             /* i  : Ambisonic (SBA) order                    */
    Word16 nb_channels,           /* i  : Number of ambisonic channels             */
    Word16 *nchan_transport,      /* o  : number of transport channels             */
    const Word16 sba_planar,      /* i  : SBA Planar flag                          */
    Word16 *nSCE,                 /* o  : number of SCEs                           */
    Word16 *nCPE,                 /* o  : number of CPEs                           */
    Word16 *element_mode          /* o  : element mode of the core coder           */
);

Word16 ivas_get_bits_to_encode_fx(
    Word32 val);

Word16 ivas_get_spar_table_idx_fx(
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate      */
    const Word16 sba_order,        /* i  : Ambisonic (SBA) order   */
    const Word16 bwidth,           /* i  : audio bandwidth         */
    Word16 *bitlen,                /* o  : number of bits          */
    Word16 *ind                    /* o  : indice                  */
);

Word16 ivas_get_sba_num_TCs_fx(
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate      */
    const Word16 sba_order         /* i  : Ambisonic (SBA) order   */
);

Word16 ivas_sba_get_nchan_fx(
    const Word16 sba_order,                                    /* i  : Ambisonic (SBA) order                   */
    const Word16 sba_planar                                    /* i  : SBA planar flag                         */
);

void ivas_dirac_dec_set_md_map_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    const Word16 nCldfbTs                                      /* i  : number of CLDFB time slots              */
);

void ivas_jbm_dec_get_adapted_subframes_fx(
    const Word16 nCldfbTs,                                     /* i  : number of time slots in the current frame                   */
    Word16 *subframe_nbslots,                                  /* i/o: subframe grid                                               */
    Word16 *nb_subframes                                       /* i/o: number of subframes in the frame                            */
);
#endif
 No newline at end of file
+56 −21
Original line number Diff line number Diff line
@@ -247,4 +247,39 @@ const Word16 dft_trigo_48k_fx[STEREO_DFT_N_MAX_ENC / 4 + 1] =
    32640, 32649, 32658, 32666, 32675, 32683, 32690, 32697, 32704, 32711, 32717, 32723, 32728, 32733, 32738, 32742, 32746, 32750, 32753, 32756, 32759, 32761, 32763,
    32765, 32766, 32767, 32767, 32767
};

const Word16 ivas_divde_255[256] = {
    0, 128, 257, 385, 514, 642, 771, 899, 1028,
    1156, 1285, 1413, 1542, 1670, 1799, 1927, 2056,
    2184, 2313, 2441, 2570, 2698, 2827, 2955, 3084,
    3212, 3341, 3469, 3598, 3726, 3855, 3983, 4112,
    4240, 4369, 4497, 4626, 4754, 4883, 5011, 5140,
    5268, 5397, 5525, 5654, 5782, 5911, 6039, 6168,
    6296, 6425, 6553, 6682, 6810, 6939, 7067, 7196,
    7324, 7453, 7581, 7710, 7838, 7967, 8095, 8224,
    8352, 8481, 8609, 8738, 8866, 8995, 9123, 9252,
    9380, 9509, 9637, 9766, 9894, 10023, 10151, 10280,
    10408, 10537, 10665, 10794, 10922, 11051, 11179, 11308,
    11436, 11565, 11693, 11822, 11950, 12079, 12207, 12336,
    12464, 12593, 12721, 12850, 12978, 13107, 13235, 13364,
    13492, 13621, 13749, 13878, 14006, 14135, 14263, 14392,
    14520, 14649, 14777, 14906, 15034, 15163, 15291, 15420,
    15548, 15677, 15805, 15934, 16062, 16191, 16319, 16448,
    16576, 16705, 16833, 16962, 17090, 17219, 17347, 17476,
    17604, 17733, 17861, 17990, 18118, 18247, 18375, 18504,
    18632, 18761, 18889, 19018, 19146, 19275, 19403, 19532,
    19660, 19789, 19917, 20046, 20174, 20303, 20431, 20560,
    20688, 20817, 20945, 21074, 21202, 21331, 21459, 21588,
    21716, 21845, 21973, 22102, 22230, 22359, 22487, 22616,
    22744, 22873, 23001, 23130, 23258, 23387, 23515, 23644,
    23772, 23901, 24029, 24158, 24286, 24415, 24543, 24672,
    24800, 24929, 25057, 25186, 25314, 25443, 25571, 25700,
    25828, 25957, 26085, 26214, 26342, 26471, 26599, 26728,
    26856, 26985, 27113, 27242, 27370, 27499, 27627, 27756,
    27884, 28013, 28141, 28270, 28398, 28527, 28655, 28784,
    28912, 29041, 29169, 29298, 29426, 29555, 29683, 29812,
    29940, 30069, 30197, 30326, 30454, 30583, 30711, 30840,
    30968, 31097, 31225, 31354, 31482, 31611, 31739, 31868,
    31996, 32125, 32253, 32382, 32510, 32639, 32767
};
/* clang-format on */
+2 −0
Original line number Diff line number Diff line
@@ -52,4 +52,6 @@ extern const Word16 dft_trigo_12k8_fx[STEREO_DFT_N_12k8_ENC / 4 + 1];
extern const Word16 dft_trigo_32k_fx[STEREO_DFT_N_32k_ENC / 4 + 1];
extern const Word16 dft_trigo_48k_fx[STEREO_DFT_N_MAX_ENC / 4 + 1];

extern const Word16 ivas_divde_255[256];

#endif
 No newline at end of file
Loading