Commit c7e04a8e authored by vaillancour's avatar vaillancour
Browse files

update init_enc.c

parent 15adbc6e
Loading
Loading
Loading
Loading
+45 −9
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ ivas_error init_encoder_fx(
Word16 idchan = 0;            /* i  : channel ID                           */
Word16 vad_only_flag = 0;            /* i  : channel ID                           */
ISM_MODE ism_mode = ISM_MODE_NONE;
    Word32 igf_brate;
    ivas_error error;
PMT("ism_mode, idchan, vad_only_flag to be move to function header")
    error = IVAS_ERR_OK;
@@ -840,31 +841,66 @@ PMT("ism_mode, idchan, vad_only_flag to be move to function header")
    /*-----------------------------------------------------------------*
     * IGF
     *-----------------------------------------------------------------*/

    test();test();
    IF (idchan == 0 || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT))
    igf_brate = st_fx->total_brate_fx;
#ifdef IVAS_CODE
    if (st->element_mode == IVAS_SCE && (st_ivas->hEncoderConfig->ivas_format == ISM_FORMAT || st_ivas->hEncoderConfig->ivas_format == MASA_ISM_FORMAT))
    {
        IF ((st_fx->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE)count_malloc(sizeof(IGF_ENC_INSTANCE))) == NULL)
        igf_brate = st->total_brate - ISM_NB_BITS_METADATA_NOMINAL * FRAMES_PER_SEC;
    }
    else if (st->element_mode == IVAS_CPE_DFT || (st->element_mode == IVAS_SCE && (st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT ||
        st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT ||
        st_ivas->hEncoderConfig->ivas_format == MC_FORMAT ||
        st_ivas->hEncoderConfig->ivas_format == MASA_FORMAT)))
    {
            return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n"));
        /* use nominal bitrates for DFT Stereo and (O)SBA, same as in stereo_dft_config()/ivas_spar_config() */
        if (element_brate == IVAS_13k2)
        {
            igf_brate = ACELP_9k60;
        }
        else if (element_brate == IVAS_16k4)
        {
            igf_brate = ACELP_13k20;
        }
        else if (element_brate == IVAS_24k4)
        {
            igf_brate = ACELP_16k40;
        }
        else if (element_brate == IVAS_32k)
        {
            igf_brate = ACELP_24k40;
        }
    }
    else if (st->element_mode == IVAS_CPE_MDCT)
    {
        igf_brate = element_brate;
    }
#endif
    test();
    IF(EQ_16(st_fx->codec_mode, MODE2) || GT_16(st_fx->element_mode, EVS_MONO) )
    {
        st_fx->igf = getIgfPresent(st_fx->element_mode, igf_brate, st_fx->max_bwidth_fx, st_fx->rf_mode);
    }
    ELSE
    {
        st_fx->hIGFEnc = NULL;
        st_fx->igf = 0;
        move16();
    }

    IF( EQ_16(st_fx->codec_mode, MODE2))
    test();test();test();
    IF ( (idchan == 0 || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT)) && (st_fx->igf || EQ_16(st_fx->element_mode, EVS_MONO) ) )
    {
        st_fx->igf = getIgfPresent(st_fx->element_mode, st_fx->total_brate_fx, st_fx->bwidth_fx, st_fx->rf_mode);
        IF ((st_fx->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE)count_malloc(sizeof(IGF_ENC_INSTANCE))) == NULL)
        {
            return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n"));
        }
    }
    ELSE
    {
        st_fx->igf = 0;
        st_fx->hIGFEnc = NULL;
        move16();
    }


    /* FD-CNG encoder */
    createFdCngEnc(&st_fx->hFdCngEnc_fx);
    initFdCngEnc(st_fx->hFdCngEnc_fx, st_fx->input_Fs_fx, st_fx->cldfbAna_Fx->scale);