Commit 602dfad2 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Implements bitrate switching within McMASA and partially to other MC modes.

parent 0bc24dea
Loading
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ void ivas_mcmasa_set_separate_channel_mode(
    return;
}

#ifndef MCMASA_BITRATE_SWITCHING
/*--------------------------------------------------------------------------*
 * ivas_mcmasa_mono_brate()
 *
@@ -112,3 +113,39 @@ int32_t ivas_mcmasa_mono_brate(
        return ( const int32_t )( MCMASA_MONOBITRATIO * ivas_total_brate );
    }
}
#else
/*--------------------------------------------------------------------------*
 * ivas_mcmasa_split_brate()
 *
 * Split the total bitrate to elements in McMASA
 *--------------------------------------------------------------------------*/
void ivas_mcmasa_split_brate(
    const uint8_t separateChannelEnabled, /* i  : Transport running in "separate channel" mode      */
    const int32_t ivas_total_brate,       /* i  : Total bitrate available to be split               */
    const int16_t nSCE,                   /* i  : Number of SCEs in use (0 or 1)                    */
    const int16_t nCPE,                   /* i  : Number of CPEs in use (0 or 1)                    */
    int32_t *brate_sce,                   /* o  : Pointer to SCE element bitrate                    */
    int32_t *brate_cpe                    /* o  : Pointer to CPE element bitrate                    */
)
{
    if ( separateChannelEnabled )
    {
        /* 25% of total bitrate is used for SCE below 96 kb/s (separated mono channel), otherwise 30% */
        if ( ivas_total_brate < IVAS_96k )
        {
            *brate_sce = (int32_t) ( MCMASA_MONOBITRATIO_64k * ivas_total_brate );
        }
        else
        {
            *brate_sce = (int32_t) ( MCMASA_MONOBITRATIO * ivas_total_brate );
        }

        *brate_cpe = ivas_total_brate - *brate_sce;
    }
    else
    {
        *brate_sce = nSCE > 0 ? ivas_total_brate / ( nCPE + nSCE ) : 0;
        *brate_cpe = nCPE > 0 ? ivas_total_brate / ( nCPE + nSCE ) : 0;
    }
}
#endif
+47 −0
Original line number Diff line number Diff line
@@ -128,7 +128,14 @@ ivas_error ivas_corecoder_enc_reconfig(
    Encoder_Struct *st_ivas,                                    /* i/o: IVAS encoder structure                  */
    const int16_t nSCE_old,                                     /* i  : number of SCEs in previous frame        */
    const int16_t nCPE_old,                                     /* i  : number of CPEs in previous frame        */
#ifdef MCMASA_BITRATE_SWITCHING
    const int16_t nchan_transport_old,                          /* i  : number of TCs in previous frame         */
    const int32_t brate_SCE,                                    /* i  : bitrate to be set for the SCEs          */
    const int32_t brate_CPE,                                    /* i  : bitrate to be set for the CPEs          */
    const MC_MODE last_mc_mode                                  /* i  : switching between MC modes: last mode   */
#else
    const int16_t nchan_transport_old                           /* i  : number of TCs in previous frame         */
#endif
);
#endif

@@ -333,11 +340,21 @@ void ivas_mct_dec_close(

#ifdef CORECODER_BITRATE_SWITCHING
ivas_error ivas_corecoder_dec_reconfig(
#ifdef MCMASA_BITRATE_SWITCHING
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                    */
    const int16_t nSCE_old,                                     /* i  : number of SCEs in previous frame                          */
    const int16_t nCPE_old,                                     /* i  : number of CPEs in previous frame                          */
    const int16_t nchan_transport_old,                          /* i  : number of TCs in previous frame                           */
    const int16_t sba_dirac_stereo_flag_old,                    /* i  : signal stereo rendering using DFT upmix in previous frame */
    const int32_t brate_SCE,                                    /* i  : bitrate to be set for the SCEs                            */
    const int32_t brate_CPE                                     /* i  : bitrate to be set for the CPEs                            */
#else
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    const int16_t nSCE_old,                                     /* i  : number of SCEs in previous frame        */
    const int16_t nCPE_old,                                     /* i  : number of CPEs in previous frame        */
    const int16_t nchan_transport_old,                          /* i  : number of TCs in previous frame         */
    const int16_t sba_dirac_stereo_flag_old                     /* i  : signal stereo output for SBA DirAC in previous frame */
#endif
);

ivas_error ivas_hp20_dec_reconfig(
@@ -4779,6 +4796,16 @@ void ivas_mcmasa_enc_close(
    const int32_t input_Fs                                      /* i  : input sampling rate                             */
);

#ifdef MCMASA_BITRATE_SWITCHING
ivas_error ivas_mcmasa_enc_reconfig(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder handle                              */
);

ivas_error ivas_mcmasa_dec_reconfig(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                              */
);
#endif

void ivas_mcmasa_setNumTransportChannels(
    int16_t* nchan_transport,                                   /* o  : Pointer to number of transport channels to be set */
    int16_t* element_mode,                                      /* o  : Pointer to element mode to be set                 */
@@ -4791,10 +4818,21 @@ void ivas_mcmasa_set_separate_channel_mode(
    const int32_t ivas_total_brate                              /* i  : Total bitrate of IVAS                             */
);

#ifndef MCMASA_BITRATE_SWITCHING
/*! r: McMASA SCE bitrate */
int32_t ivas_mcmasa_mono_brate(
    const int32_t ivas_total_brate                              /* i  : IVAS total bitrate                                */
);
#else
void ivas_mcmasa_split_brate(
    const uint8_t separateChannelEnabled,                       /* i  : Transport running in "separate channel" mode      */
    const int32_t ivas_total_brate,                             /* i  : Total bitrate available to be split               */
    const int16_t nSCE,                                         /* i  : Number of SCEs in use (0 or 1)                    */
    const int16_t nCPE,                                         /* i  : Number of CPEs in use (0 or 1)                    */
    int32_t *brate_sce,                                         /* o  : Pointer to SCE element bitrate                    */
    int32_t *brate_cpe                                          /* o  : Pointer to CPE element bitrate                    */
);
#endif

void ivas_mcmasa_enc(
    MCMASA_ENC_HANDLE hMcMasa,                                  /* i/o: Encoder McMASA handle                             */
@@ -4819,6 +4857,15 @@ void ivas_mcmasa_param_est_enc(
    const int16_t nchan_inp                                     /* i  : Number of input channels                          */
);

#ifdef MCMASA_BITRATE_SWITCHING
void ivas_mcmasa_dmx_modify(
    const int16_t n_samples,                                        /* i  : input frame length in samples                        */
    float dmx[][L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS )], /* i/o: downmix signal to be transformed into another format */
    const uint8_t n_chnls_dmx_old,                                  /* i  : number of downmix channels in the old format         */
    const uint8_t n_chnls_dmx_new                                   /* i  : number of downmix channels in the target format      */
);
#endif

void v_multc_acc(
    const float x[],                                            /* i  : Input vector                                     */
    const float c,                                              /* i  : Constant                                         */
+4 −2
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@

#ifdef DEBUGGING

#define MEM_COUNT_DETAILS                       /* RAM counting tool: print per sub-structure details */
/*#define MEM_COUNT_DETAILS*/                   /* RAM counting tool: print per sub-structure details */

/*#define DEBUG_MODE_INFO*/                     /* output most important parameters to the subdirectory "res/" */
#ifdef DEBUG_MODE_INFO
@@ -159,7 +159,9 @@

#define CORECODER_BITRATE_SWITCHING                     /* Issue 133: support bitrate switching in core-coder */
#define MC_BITRATE_SWITCHING                            /* Issue 116: support bitrate switching in MC format  */

#ifdef MC_BITRATE_SWITCHING
#define MCMASA_BITRATE_SWITCHING                        /* Issue 116: support bitrate switching in MC format: sub-part of McMASA modes */
#endif

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+4 −0
Original line number Diff line number Diff line
@@ -1891,6 +1891,10 @@ void tbe_celp_exc(
        return;
    }

#ifdef MCMASA_BITRATE_SWITCHING
    assert( bwe_exc != NULL && "BWE excitation is NULL" );
#endif

    if ( L_frame == L_FRAME )
    {
        offset = tbe_celp_exc_offset( T0, T0_frac );
+0 −1
Original line number Diff line number Diff line
@@ -442,7 +442,6 @@ ivas_error ivas_core_dec(
            }
        }
#endif

    }

    /*---------------------------------------------------------------------*
Loading