Commit b8619200 authored by Lauros Pajunen's avatar Lauros Pajunen
Browse files

Diffuseness-preserving MASA and ISM metadata merge in low-bitrate OMASA. OMASA...

Diffuseness-preserving MASA and ISM metadata merge in low-bitrate OMASA. OMASA metadata bitrate reduction and allocation update.
parent ac2065bc
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -493,6 +493,12 @@ void reconstruct_ism_ratios(
    }

    q_energy_ratio_ism[n_ism - 1] = 1.0f - sum;
#ifdef REDUCE_OMASA_META_BITS
    if ( q_energy_ratio_ism[n_ism - 1] < 0 )
    {
        q_energy_ratio_ism[n_ism - 1] = 0.0f;
    }
#endif

    return;
}
+110 −17
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "prot.h"
#ifdef REDUCE_OMASA_META_BITS
#include "ivas_rom_com.h"
#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
@@ -57,6 +60,11 @@
#define GAMMA_ISM_LOW_IMP3    0.85f
#define GAMMA_ISM_MEDIUM_IMP3 1.15f
#define GAMMA_ISM_HIGH_IMP3   1.3f
#ifdef TUNING_DISC_3_4obj
#define GAMMA_ISM_LOW_IMP4    0.6f
#define GAMMA_ISM_MEDIUM_IMP4 0.8f
#define GAMMA_ISM_HIGH_IMP4   1.0f
#endif
#endif

/*---------------------------------------------------------------
@@ -99,17 +107,13 @@ ISM_MODE ivas_omasa_ism_mode_select(
            {
                ism_mode = ISM_MASA_MODE_ONE_OBJ;
            }
            /* else if ( ivas_total_brate >= IVAS_32k )
            {
                ism_mode = ISM_MASA_MODE_PARAM;
            } */
            else
            {
                ism_mode = ISM_MODE_NONE;
            }
            break;
        case 3:
#ifdef TUNING_96kbps_3obj
#ifdef TUNING_DISC_3_4obj
            if ( ivas_total_brate >= IVAS_96k )
#else
            if ( ivas_total_brate >= IVAS_128k )
@@ -131,7 +135,11 @@ ISM_MODE ivas_omasa_ism_mode_select(
            }
            break;
        case 4:
 #ifdef TUNING_DISC_3_4obj
            if ( ivas_total_brate >= IVAS_128k )
#else
            if ( ivas_total_brate >= IVAS_160k )
 #endif
            {
                ism_mode = ISM_MASA_MODE_DISC;
            }
@@ -181,24 +189,20 @@ int32_t ivas_interformat_brate(
    }
    else
    {
#ifdef TUNING_96kbps_3obj
        if ( ( ism_mode == ISM_MASA_MODE_DISC && nchan_ism >= 3 && element_brate == 16000 ) /* this condition corresponds to the ivas_total_brate = 96000 and 3 objects and 128 kbps and 4 objects */
#ifdef TUNING_48kbps_2obj
             || ( ism_mode == ISM_MASA_MODE_DISC && nchan_ism == 2 && element_brate == 9600 ) /* this condition corresponds to the ivas_total_brate = 48000 and 2 objects */
#endif
        )
#ifdef TUNING_DISC_3_4obj
        if ( ism_mode == ISM_MASA_MODE_DISC && ( ( nchan_ism == 4 && element_brate == 24000 ) || (  nchan_ism == 3 && element_brate == 20000 ) ) ) /* this condition corresponds to the ivas_total_brate = 96000 and 3 objects */
        {
            if ( ism_imp == ISM_LOW_IMP )
            {
                nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP3 );
                nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP4 );
            }
            else if ( ism_imp == ISM_MEDIUM_IMP )
            {
                nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP3 );
                nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP4 );
            }
            else /* ISM_HIGH_IMP */
            {
                nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP3 );
                nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP4 );
            }
        }
        else
@@ -209,15 +213,15 @@ int32_t ivas_interformat_brate(
        {
            if ( ism_imp == ISM_LOW_IMP )
            {
                nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP2 );
                nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP3 );
            }
            else if ( ism_imp == ISM_MEDIUM_IMP )
            {
                nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP2 );
                nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP3 );
            }
            else /* ISM_HIGH_IMP */
            {
                nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP2 );
                nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP3 );
            }
        }
        else
@@ -302,4 +306,93 @@ void ivas_combined_format_brate_sanity(
    return;
}
#endif

#ifdef REDUCE_OMASA_META_BITS
int16_t bits_index_ism_ratio(
    int16_t no_ism
)
{
    int16_t bits_index;

    bits_index = 0;
    if ( no_ism == 2 )
    {
        bits_index = 3;
    }
    else if ( no_ism == 3 )
    {
        bits_index = 6;
    }
    else if ( no_ism == 4 )
    {
        bits_index = 7;
    }
    else
    {
        assert( ( no_ism >= 2 && no_ism <= 4 ) && "Wrong number of objects for MASA_ISM." );
    }
    return bits_index;
}
#endif

#ifdef REDUCE_OMASA_META_BITS
void calculate_nbits_meta(
    int16_t n_ism,
    float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS],
    float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],
    int16_t numSf,
    int16_t numCodingBands,
    int16_t *bits_ism,
    int16_t idx_sep_obj, 
    int16_t ism_imp
)
{
    int16_t sf, band, obj;
    float priority[MAX_NUM_OBJECTS], max_p;


    if ( n_ism > 1 )
    {
        set_f( priority, 0.0f, n_ism );
        for ( sf = 0; sf < numSf; sf++ )
        {
            for ( band = 0; band < numCodingBands; band++ )
            {
                for ( obj = 0; obj < n_ism; obj++ )
                {
                    priority[obj] = max( priority[obj], ( q_energy_ratio_ism[sf][band][obj] * ( 1 - masa_to_total_energy_ratio[sf][band] ) ) );
                }
            }
        }
    }
    else
    {
        priority[0] = 1;
    }


    /* decide parameters for ISM metadata quantization */
     maximum( priority, n_ism, &max_p );
    for ( obj = 0; obj < n_ism; obj++ )
    {
        if ( obj == idx_sep_obj )
        {
            if ( ism_imp == 3 )
            {
                priority[obj] = 1;
            }
            else if ( ism_imp == 2 )
            {
                priority[obj] = ( 1 + max_p ) * 0.5f;
            }
            else
            {
                priority[obj] = max_p;
            }
        }
        bits_ism[obj] = bits_direction_masa[0] - (int16_t) ( ( 1 - priority[obj] ) * 7 );
    }
    return;
}
#endif
#endif
+34 −0
Original line number Diff line number Diff line
@@ -4529,6 +4529,10 @@ void ivas_masa_encode(
    ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS],          /* i  : ISM metadata handle                             */
    const int16_t idx_separated_object,                         /* i  : index of the separated object                   */
    OMASA_ENC_HANDLE hOMasa                                     /* i  : OMASA encoder handle */
#ifdef REDUCE_OMASA_META_BITS
    ,
    int16_t ism_imp                                             /* i: importance of separated object                     */
#endif
#endif
);

@@ -4604,6 +4608,32 @@ int32_t calculate_cpe_brate_MASA_ISM(
    const int32_t ivas_total_brate,                             /* i  : total bit rate for IVAS                         */
    const int16_t n_ism                                         /* i  : number of objects                               */
);
#ifdef OMASA_DIFFUSE_ISM_MERGE
void ivas_merge_masa_metadatas(
    MASA_ENCODER_HANDLE hMasa,                                 /* i/o: MASA enc handle. source for MASA metadata and combined metadata will be here */
    OMASA_SPATIAL_META_HANDLE hMasaMeta                        /* i:   ISM-object metadata to be merged with the MASA metadata                      */
);
void ivas_masa_combine_directions(
    MASA_ENCODER_HANDLE hMasa                                  /* i/o: MASA encoder handle */
);
#endif  /* OMASA_DIFFUSE_ISM_MERGE */

#ifdef REDUCE_OMASA_META_BITS
int16_t bits_index_ism_ratio(                                   /* o : number of bits for ISM ratio index              */
    int16_t no_ism                                              /* i : number of objects                                */
);

void calculate_nbits_meta(
    int16_t n_ism,
    float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS],
    float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],
    int16_t numSf,
    int16_t numCodingBands,
    int16_t* bits_ism,
    int16_t idx_sep_obj,
    int16_t ism_imp
);
#endif
#endif

void ivas_masa_set_coding_config(
@@ -5181,6 +5211,10 @@ void ivas_omasa_set_config(
    OMASA_ENC_HANDLE hOMasa,                                    /* i/o: OMASA encoder handle                    */
    MASA_ENCODER_HANDLE hMasa,                                  /* i  : MASA encoder handle                     */
    const int32_t input_Fs                                      /* i  : Input sample rate                       */
#ifdef OMASA_DIFFUSE_ISM_MERGE
    ,
    ISM_MODE ismMode                                            /* i   : ISM mode                               */
#endif
);

void ivas_omasa_enc(
+6 −2
Original line number Diff line number Diff line
@@ -2805,12 +2805,16 @@ const int32_t sep_object_brate[][MAX_NUM_OBJECTS] =
    {16000,     IVAS_13k2, 0, 0},                   /* 64k  */
#endif
    {20000,     16000, 0, 0},                       /* 80k  */
#ifdef TUNING_96kbps_3obj
    {IVAS_32k,  20000,     16000, 0},               /* 96k  */
#ifdef TUNING_DISC_3_4obj
    {IVAS_32k,  20000,     20000, 0},               /* 96k  */
#else
    {IVAS_32k,  20000,     0, 0},                   /* 96k  */
#endif
#ifdef TUNING_DISC_3_4obj
     {IVAS_32k,  IVAS_24k4, 20000,    24000},       /* 128k */
#else
    {IVAS_32k,  IVAS_24k4, 20000,     16000},       /* 128k */
#endif
    {IVAS_48k,  IVAS_32k,  IVAS_24k4, 20000},       /* 160k */
    {IVAS_64k,  IVAS_48k,  IVAS_32k,  IVAS_24k4},   /* 192k */
    {IVAS_96k,  IVAS_64k,  IVAS_48k,  IVAS_32k},    /* 256k */
+11 −0
Original line number Diff line number Diff line
@@ -419,6 +419,17 @@ typedef struct ivas_masa_common_spatial_meta_struct

} MASA_COMMON_SPATIAL_META;

#ifdef MASA_AND_OBJECTS
#ifdef OMASA_DIFFUSE_ISM_MERGE
typedef struct ivas_omasa_meta_struct
{
    uint8_t num_dirs;
    MASA_DIRECTIONAL_SPATIAL_META directional_meta[MASA_MAXIMUM_DIRECTIONS];
    MASA_COMMON_SPATIAL_META common_meta;
} OMASA_SPATIAL_META, *OMASA_SPATIAL_META_HANDLE;
#endif
#endif

typedef struct ivas_masa_metadata_frame_struct
{
    MASA_DECRIPTIVE_META descriptive_meta;
Loading