Commit d0cbad6f authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'enc_funcs_fxd_12' into 'main'

Sub-functions in MASA/OMASA path [allow regression]

See merge request !644
parents 8306575a be1302ed
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@
 * General constants
 *----------------------------------------------------------------------------------*/

#define DEGREE_90_Q_22  377487360
#define DEGREE_180_Q_22 754974720
#define DEGREE_360_Q_22 1509949440

+2 −1
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#define PI_OVER_2                               ( EVS_PI / 2.0f )
#define PI_OVER_180                             ( EVS_PI / 180.0f )
#define ONE_BY_PI_OVER_180_Q25                  ( 1922527360 )
#define PI_OVER_180_Q22                         ( 73204 )
#define _180_OVER_PI                            ( 180.0f / EVS_PI )
#ifdef IVAS_FLOAT_FIXED
#define _180_OVER_PI_Q25                         1922521886
+41 −0
Original line number Diff line number Diff line
@@ -3295,4 +3295,45 @@ void ivas_mct_core_enc_fx(
    const Word16 sba_order               /* i  : Ambisonic (SBA) order           */
);

Word16 quantize_phi_chan_compand_fx(
    Word32 phi,                 /* i  : azimuth value                   Q22 */
    Word32 *phi_hat,            /* o  : quantized azimuth               Q22 */
    const Word16 n,             /* i  : azimuth codebook size               */
    const Word16 theta_flag,    /* i  : flag signaling high elevation       */
    const MC_LS_SETUP mc_format /* i  : channel format if in MC-mode        */
);

Word16 quantize_phi_chan_lbr_fx(
    const Word32 phi, /* i  : azimuth value, Q22               */
    Word32 *phi_hat,  /* o  : quantized azimuth, Q22           */
    const Word16 n    /* i  : azimuth codebook size            */
);

UWord16 quantize_direction_fx(
    const Word32 theta,         /* i  : input elevation value, Q22        */
    Word32 phi,                 /* i  : input azimuth value, Q22          */
    const Word16 no_bits,       /* i  : number of bits                    */
    Word32 *theta_q,            /* o  : quantized elevation, Q22          */
    Word32 *phi_q,              /* o  : quantized azimuth, Q22            */
    UWord16 *index_theta,       /* o  : quantized elevation index         */
    UWord16 *index_phi,         /* o  : quantized azimuth index           */
    const MC_LS_SETUP mc_format /* i  : channel format if in MC-mode      */
);

void quantize_direction_frame_fx(
    IVAS_QDIRECTION *q_direction,                                                     /* i/o: quantized direction structure            */
    Word32 azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES],   /* o  : Q22                                      */
    Word32 elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* o  : Q22                                      */
    const Word16 hrmasa_flag                                                          /* i  : flag indicating high-rate MASA MD coding */
);

ivas_error ivas_qmetadata_enc_encode_hr_384_512_fx(
    BSTR_ENC_HANDLE hMetaData,  /* i/o: metadata bitstream handle */
    IVAS_QMETADATA *hQMetaData, /* i/o: metadata handle           */
    const Word16 bits_sph_idx,
    const Word16 bits_sp_coh );
void ivas_merge_masa_metadata_fx(
    MASA_ENCODER_HANDLE hMasa,           /* i/o: MASA enc handle. source for MASA metadata and combined metadata will be here */
    OMASA_SPATIAL_META_HANDLE hOMasaMeta /* i  : ISM-object metadata to be merged with the MASA metadata                      */
);
#endif
+113 −3
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
#include "prot_fx.h"
#include "ivas_rom_com_fx.h"
#endif

@@ -421,9 +422,9 @@ int16_t quantize_phi(
}
#ifdef IVAS_FLOAT_FIXED
Word16 quantize_phi_fx(
    Word32 phi,              /* i  : azimuth value                                                 */
    Word32 phi,              /* i  : azimuth value, Q22                                            */
    const Word16 flag_delta, /* i  : flag indicating if the azimuth codebook is translated or not  */
    Word32 *phi_hat,         /* o  : quantized azimuth                                             */
    Word32 *phi_hat,         /* o  : quantized azimuth, Q22                                        */
    const Word16 n           /* i  : azimuth codebook size                                         */
)
{
@@ -584,7 +585,7 @@ float companding_azimuth(

#ifdef IVAS_FLOAT_FIXED
Word32 companding_azimuth_fx(
    const Word32 azi_fx,         /* i  : input azimuth value                        */
    const Word32 azi_fx,         /* i  : input azimuth value, Q22                   */
    const MC_LS_SETUP mc_format, /* i  : input channel format                       */
    const Word16 theta_flag,     /* i  : zero/non zero elevation flag               */
    const Word16 direction       /* i  : direction of companding (direct or inverse)*/
@@ -813,6 +814,45 @@ int16_t quantize_phi_chan_lbr(

    return id_phi;
}
#ifdef IVAS_FLOAT_FIXED
/*! r: index azimuth */
Word16 quantize_phi_chan_lbr_fx(
    const Word32 phi, /* i  : azimuth value, Q22               */
    Word32 *phi_hat,  /* o  : quantized azimuth, Q22           */
    const Word16 n    /* i  : azimuth codebook size            */
)
{
    Word16 id_phi, phi_hat_16;


    IF( LE_16( n, 1 ) )
    {
        *phi_hat = 0;
        move32();

        return 0;
    }

    id_phi = squant_fx( extract_l( L_shr( L_abs( phi ), 22 ) ) /* Q0 */, &phi_hat_16 /* Q0 */, cb_azi_chan_16fx, shr( n, 1 ) );
    *phi_hat = L_shl( L_deposit_l( phi_hat_16 ), Q22 ); // Q0 -> Q22
    move32();

    test();
    IF( phi < 0 && id_phi > 0 )
    {
        id_phi = sub( shl( id_phi, 1 ), 1 );
        *phi_hat = L_negate( *phi_hat );
        move32();
    }
    ELSE
    {
        // id_phi *= 2;
        id_phi = shl( id_phi, 1 );
    }

    return id_phi;
}
#endif


/*-----------------------------------------------------------------------*
@@ -884,3 +924,73 @@ int16_t quantize_phi_chan_compand(

    return id_phi;
}
#ifdef IVAS_FLOAT_FIXED
/*! r: index azimuth */
Word16 quantize_phi_chan_compand_fx(
    Word32 phi,                 /* i  : azimuth value                Q22 */
    Word32 *phi_hat,            /* o  : quantized azimuth            Q22 */
    const Word16 n,             /* i  : azimuth codebook size            */
    const Word16 theta_flag,    /* i  : flag signaling high elevation    */
    const MC_LS_SETUP mc_format /* i  : channel format if in MC-mode     */
)
{
    Word16 id_phi;
    Word32 delta_phi; // Q22
    Word16 tmp_e;

    IF( LE_16( n, 1 ) )
    {
        *phi_hat = 0;
        move32();

        return 0;
    }

    phi = companding_azimuth_fx( L_sub( phi, 180 << Q22 ), mc_format, theta_flag, 1 );

    /* quantize companded value */
    // delta_phi = 360.0f / (float) n;
    delta_phi = BASOP_Util_Divide3232_Scale_cadence( 360, n, &tmp_e );
    delta_phi = L_shr( delta_phi, sub( 9, tmp_e ) ); // Q22
    // id_phi = (int16_t) round_f( ( phi / (float) delta_phi ) );
    id_phi = BASOP_Util_Divide3232_Scale( phi, delta_phi, &tmp_e );
    id_phi = shr( id_phi, sub( 15, tmp_e ) );

    IF( add( id_phi, shr( n, 1 ) ) < 0 )
    {
        id_phi = add( id_phi, 1 );
    }
    IF( sub( id_phi, shr( n, 1 ) ) >= 0 )
    {
        id_phi = negate( shr( n, 1 ) );
    }

    IF( EQ_16( id_phi, negate( add( shr( n, 1 ), ( n % 2 ) ) ) ) )
    {
        id_phi = add( id_phi, ( n % 2 ) );
    }
    ELSE{
        IF( EQ_16( id_phi, add( shr( n, 1 ), ( n % 2 ) ) ) ){
            IF( n % 2 ){
                id_phi = sub( id_phi, 1 );
}
ELSE
{
    id_phi = negate( id_phi );
}
}
}
//*phi_hat = id_phi * delta_phi;
*phi_hat = imult3216( delta_phi, id_phi );
move32();

// id_phi += ( n >> 1 );
id_phi = add( id_phi, shr( n, 1 ) );


*phi_hat = L_add( companding_azimuth_fx( *phi_hat, mc_format, theta_flag, -1 ), DEGREE_180_Q_22 );
move32();

return id_phi;
}
#endif
+2 −1
Original line number Diff line number Diff line
@@ -1674,7 +1674,8 @@ const Word32 dd_val[90] = {
    8778776, 8677870, 8579258, 8482862
};

const Word32 cb_azi_chan_fx[] = { 0, 125829120, 461373440, 566231040 };
const Word32 cb_azi_chan_fx[] = { 0, 125829120, 461373440, 566231040 }; // Q22
const Word16 cb_azi_chan_16fx[] = { 0, 30, 110, 135 };                  // Q0

/*----------------------------------------------------------------------------------*
 * MASA and ISM (OMASA) combined format ROM tables
Loading