Commit d302cdb6 authored by fotopoulou's avatar fotopoulou
Browse files

Merge branch '116-Bitrate-Switching-in-MC' into 'main'

Bitrate switching in MC

See merge request !333
parents 7ac3f332 4554d745
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -283,6 +283,7 @@
    <ClCompile Include="..\lib_dec\ivas_lfe_dec.c" />
    <ClCompile Include="..\lib_dec\ivas_lfe_plc.c" />
    <ClCompile Include="..\lib_dec\ivas_masa_dec.c" />
    <ClCompile Include="..\lib_dec\ivas_mcmasa_dec.c" />
    <ClCompile Include="..\lib_dec\ivas_mct_core_dec.c" />
    <ClCompile Include="..\lib_dec\ivas_mct_dec.c" />
    <ClCompile Include="..\lib_dec\ivas_mct_dec_mct.c" />
+3 −0
Original line number Diff line number Diff line
@@ -500,6 +500,9 @@
    <ClCompile Include="..\lib_dec\ivas_td_low_rate_dec.c">
      <Filter>dec_ivas_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_dec\ivas_mcmasa_dec.c">
      <Filter>dec_ivas_c</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_dec\jbm_jb4_inputbuffer.h">
+2 −0
Original line number Diff line number Diff line
@@ -879,10 +879,12 @@ static ivas_error write_indices_element(

        for ( n = 0; n < n_channels; n++ )
        {
#ifndef MC_BITRATE_SWITCHING
            if ( ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCT ) && ( element_id * CPE_CHANNELS + n == LFE_CHANNEL ) )
            {
                continue;
            }
#endif
            reset_indices_enc( sts[n]->hBstr, MAX_NUM_INDICES );
        }
    }
+98 −1
Original line number Diff line number Diff line
@@ -330,6 +330,100 @@ void ivas_param_mc_default_icc_map(
}


#ifdef MC_BITRATE_SWITCHING
/*-------------------------------------------------------------------------
 * ivas_param_mc_get_num_param_bands()
 *
 *
 *------------------------------------------------------------------------*/

static int16_t ivas_param_mc_get_num_param_bands(
    const MC_LS_SETUP mc_ls_setup, /* i  : MC ls setup                      */
    const int32_t ivas_total_brate /* i  : IVAS total bitrate               */
)
{
    int16_t num_parameter_bands;

    num_parameter_bands = 0;

    /* parameter bands */
    switch ( mc_ls_setup )
    {
        case MC_LS_SETUP_5_1:
            switch ( ivas_total_brate )
            {
                case IVAS_48k:
                    num_parameter_bands = 10;
                    break;
                case IVAS_64k:
                case IVAS_80k:
                    num_parameter_bands = 14;
                    break;
                default:
                    assert( 0 && "PARAM_MC: bitrate for CICP6 not supported!" );
            }
            break;

        case MC_LS_SETUP_7_1:
            switch ( ivas_total_brate )
            {
                case IVAS_48k:
                    num_parameter_bands = 10;
                    break;
                case IVAS_64k:
                case IVAS_80k:
                    num_parameter_bands = 14;
                    break;
                case IVAS_96k:
                    num_parameter_bands = 20;
                    break;
            }
            break;
        case MC_LS_SETUP_5_1_2:
            switch ( ivas_total_brate )
            {
                case IVAS_48k:
                    num_parameter_bands = 10;
                    break;
                case IVAS_64k:
                case IVAS_80k:
                    num_parameter_bands = 14;
                    break;
                case IVAS_96k:
                    num_parameter_bands = 20;
                    break;
            }
            break;
        case MC_LS_SETUP_5_1_4:
            switch ( ivas_total_brate )
            {
                case IVAS_96k:
                    num_parameter_bands = 14;
                    break;
                case IVAS_128k:
                    num_parameter_bands = 20;
                    break;
            }
            break;
        case MC_LS_SETUP_7_1_4:
            switch ( ivas_total_brate )
            {
                case IVAS_128k:
                    num_parameter_bands = 20;
                    break;
                case IVAS_160k:
                    num_parameter_bands = 20;
                    break;
            }
            break;
        default:
            assert( 0 && "PARAM_MC: channel configuration not supportet!" );
    }

    return num_parameter_bands;
}
#endif

/*-------------------------------------------------------------------------
 * Local functions
 *------------------------------------------------------------------------*/
@@ -427,6 +521,9 @@ static void ivas_param_mc_set_coding_scheme(
            assert( 0 && "PARAM_MC: channel configuration not supported!" );
    }

#ifdef MC_BITRATE_SWITCHING
    hMetadataPMC->num_parameter_bands = ivas_param_mc_get_num_param_bands( mc_ls_setup, ivas_total_brate );
#else
    /* parameter bands */
    switch ( mc_ls_setup )
    {
@@ -500,6 +597,6 @@ static void ivas_param_mc_set_coding_scheme(
        default:
            assert( 0 && "PARAM_MC: channel configuration not supportet!" );
    }

#endif
    return;
}
+43 −2
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ void ivas_mcmasa_set_separate_channel_mode(
    return;
}


#ifndef MC_BITRATE_SWITCHING
/*--------------------------------------------------------------------------*
 * ivas_mcmasa_mono_brate()
 *
@@ -105,10 +107,49 @@ int32_t ivas_mcmasa_mono_brate(
    /* 25% of total bitrate is used for SCE below 96 kb/s (separated mono channel), otherwise 30% */
    if ( ivas_total_brate < IVAS_96k )
    {
        return ( const int32_t )( MCMASA_MONOBITRATIO_64k * ivas_total_brate );
        return (int32_t) ( MCMASA_MONOBITRATIO_64k * ivas_total_brate );
    }
    else
    {
        return (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
    {
        return ( const int32_t )( MCMASA_MONOBITRATIO * ivas_total_brate );
        *brate_sce = nSCE > 0 ? ivas_total_brate / ( nCPE + nSCE ) : 0;
        *brate_cpe = nCPE > 0 ? ivas_total_brate / ( nCPE + nSCE ) : 0;
    }

    return;
}
#endif
Loading