Commit 95ea2c5f authored by vaillancour's avatar vaillancour Committed by Manuel Jander
Browse files

work on encoder config duplication

parent 112e0cd6
Loading
Loading
Loading
Loading
+22 −24
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ void ivas_initialize_handles_enc_fx(
 *
 * Initialize IVAS encoder state structure
 *-------------------------------------------------------------------*/

#if 0
ivas_error ivas_init_encoder(
    Encoder_Struct *st_ivas /* i/o: IVAS encoder structure      */
)
@@ -1073,6 +1073,7 @@ ivas_error ivas_init_encoder(
    }
    return error;
}
#endif
ivas_error ivas_init_encoder_fx(
    Encoder_Struct *st_ivas /* i/o: IVAS encoder structure      */
)
@@ -1100,10 +1101,10 @@ ivas_error ivas_init_encoder_fx(
    hEncoderConfig->last_ivas_total_brate = ivas_total_brate; /* Q0 */
    move32();

    IF( NE_16( ivas_format, MONO_FORMAT ) )
    if ( NE_16( ivas_format, MONO_FORMAT ) )
    {
        /* In IVAS, ensure that minimum coded bandwidth is WB */
        hEncoderConfig->max_bwidth = extract_l( L_max( hEncoderConfig->max_bwidth, WB ) ); /* Q0 */
        hEncoderConfig->max_bwidth = s_max( hEncoderConfig->max_bwidth, WB ); /* Q0 */
        move16();
    }
    st_ivas->ism_mode = ISM_MODE_NONE;
@@ -1142,7 +1143,10 @@ ivas_error ivas_init_encoder_fx(
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) );
        }
        set32_fx( st_ivas->p_data_fx[n], 0, extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ) );
    }
    st_ivas->q_data_fx = Q11;
    move16();
    FOR( ; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
    {
        st_ivas->p_data_fx[n] = NULL;
@@ -1196,7 +1200,7 @@ ivas_error ivas_init_encoder_fx(
    /*-----------------------------------------------------------------*
     * Allocate and initialize SCE/CPE and other handles
     *-----------------------------------------------------------------*/
    test();

    IF( EQ_32( ivas_format, MONO_FORMAT ) )
    {
        st_ivas->nSCE = 1; /* in mono, there is always only one SCE */
@@ -1209,20 +1213,10 @@ ivas_error ivas_init_encoder_fx(
        move16();

        test();
        IF( st_ivas->hEncoderConfig->element_mode_init == EVS_MONO )
        {
        IF( NE_32( ( error = create_evs_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
        }
        ELSE
        {
            IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }

        /* prepare stereo downmix for EVS */
        IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) )
@@ -1342,7 +1336,7 @@ ivas_error ivas_init_encoder_fx(

            FOR( n = 0; n < CPE_CHANNELS; n++ )
            {
                IF( hEncoderConfig->Opt_DTX_ON )
                if ( hEncoderConfig->Opt_DTX_ON )
                {
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1;
                    move16();
@@ -1350,7 +1344,7 @@ ivas_error ivas_init_encoder_fx(
            }
        }

        IF( st_ivas->nCPE > 1 )
        IF( GT_16( st_ivas->nCPE, 1 ) )
        {
            IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
            {
@@ -1358,7 +1352,7 @@ ivas_error ivas_init_encoder_fx(
            }
        }
    }
    ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
    ELSE IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) )
    {
        Word32 ism_total_brate;
        Word16 k;
@@ -1428,12 +1422,12 @@ ivas_error ivas_init_encoder_fx(
    ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
    {
        st_ivas->ism_mode = ISM_MODE_NONE;
        move32();
        move16();

        IF( GE_32( ivas_total_brate, IVAS_256k ) )
        {
            st_ivas->ism_mode = ISM_SBA_MODE_DISC;
            move32();
            move16();
        }

        IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
@@ -1523,7 +1517,7 @@ ivas_error ivas_init_encoder_fx(
            return error;
        }

        IF( NE_32( st_ivas->mc_mode, MC_MODE_MCT ) )
        IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
        {
            st_ivas->nSCE = 0;
            move16();
@@ -1596,7 +1590,9 @@ ivas_error ivas_init_encoder_fx(

            FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
            {
                IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ) != IVAS_ERR_OK )
                Word32 res_dec, res_frac;
                iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nCPE, st_ivas->nSCE ), &res_dec, &res_frac, 0 );
                IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
@@ -1658,7 +1654,9 @@ ivas_error ivas_init_encoder_fx(
     *-----------------------------------------------------------------*/

    /* set number of input channels used for analysis/coding */
    n = getNumChanAnalysis_fx( st_ivas );
    n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */
    move16();

    IF( n > 0 )
    {
        IF( ( st_ivas->mem_hp20_in_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL )
+7 −3
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ struct IVAS_ENC
 * Local functions
 *---------------------------------------------------------------------*/

static ivas_error configureEncoder_fx( IVAS_ENC_HANDLE hIvasEnc, const Word32 inputFs, const Word32 initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig );
//static ivas_error configureEncoder_fx( IVAS_ENC_HANDLE hIvasEnc, const Word32 inputFs, const Word32 initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig );
static ivas_error setBandwidth_fx( IVAS_ENC_HANDLE hIvasEnc, const IVAS_ENC_BANDWIDTH maxBandwidth );
static ivas_error setChannelAwareConfig_fx( IVAS_ENC_HANDLE hIvasEnc, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig );
static ivas_error sanitizeBandwidth_fx( const IVAS_ENC_HANDLE hIvasEnc );
@@ -609,6 +609,7 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics(

    return error;
}
#if 0
ivas_error IVAS_ENC_ConfigureForAmbisonics_fx(
    IVAS_ENC_HANDLE hIvasEnc,              /* i/o: IVAS encoder handle                                                                                 */
    const Word32 inputFs,                  /* i  : input sampling frequency                                                                            */
@@ -649,11 +650,12 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics_fx(

    hIvasEnc->maxBandwidthUser = max_bwidth_user;

    error = configureEncoder_fx( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() );
    error = configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() );


    return error;
}
#endif
/*---------------------------------------------------------------------*
 * IVAS_ENC_ConfigureForSBAObjects()
 *
@@ -1188,7 +1190,7 @@ static ivas_error configureEncoder(
     * Finalize initialization
     *-----------------------------------------------------------------*/

    IF( ( error = ivas_init_encoder( st_ivas ) ) != IVAS_ERR_OK )
    IF( ( error = ivas_init_encoder_fx( st_ivas ) ) != IVAS_ERR_OK )
    {
        return error;
    }
@@ -1211,6 +1213,7 @@ static ivas_error configureEncoder(

    return error;
}
#if 0
static ivas_error configureEncoder_fx(
    IVAS_ENC_HANDLE hIvasEnc,
    const Word32 inputFs,
@@ -1543,6 +1546,7 @@ static ivas_error configureEncoder_fx(

    return error;
}
#endif
/*---------------------------------------------------------------------*
 * IVAS_ENC_GetDelay()
 *