⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decoder.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
📖 第 1 页 / 共 3 页
字号:
    /* copy the relevant info to the decoder handle */    *samplerate = mp4ASC.samplingFrequency;    if (mp4ASC.channelsConfiguration)    {        *channels = mp4ASC.channelsConfiguration;    } else {        *channels = hDecoder->pce.channels;        hDecoder->pce_set = 1;    }    hDecoder->sf_index = mp4ASC.samplingFrequencyIndex;    hDecoder->object_type = mp4ASC.objectTypeIndex;#ifdef ERROR_RESILIENCE    hDecoder->aacSectionDataResilienceFlag = mp4ASC.aacSectionDataResilienceFlag;    hDecoder->aacScalefactorDataResilienceFlag = mp4ASC.aacScalefactorDataResilienceFlag;    hDecoder->aacSpectralDataResilienceFlag = mp4ASC.aacSpectralDataResilienceFlag;#endif#ifdef SBR_DEC    hDecoder->sbr_present_flag = mp4ASC.sbr_present_flag;    if (hDecoder->config.dontUpSampleImplicitSBR == 0)        hDecoder->forceUpSampling = mp4ASC.forceUpSampling;    else        hDecoder->forceUpSampling = 0;    /* AAC core decoder samplerate is 2 times as low */    if (hDecoder->sbr_present_flag == 1 || hDecoder->forceUpSampling == 1)    {//printf("faacDecInit2: hDecoder->sbr_present_flag %d, hDecoder->forceUpSampling %d\n", hDecoder->sbr_present_flag, hDecoder->forceUpSampling);        hDecoder->sf_index = get_sr_index(mp4ASC.samplingFrequency / 2);    }#endif    if (rc != 0)    {        return rc;    }    hDecoder->channelConfiguration = mp4ASC.channelsConfiguration;        if (mp4ASC.frameLengthFlag)#ifdef ALLOW_SMALL_FRAMELENGTH        hDecoder->frameLength = 960;#else        return -1;#endif     xheader.iFramesize = hDecoder->frameLength;     xheader.iSBR = mp4ASC.sbr_present_flag;    /* must be done before frameLength is divided by 2 for LD */#ifdef SSR_DEC    if (hDecoder->object_type == SSR)        hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS);    else#endif        hDecoder->fb = filter_bank_init(hDecoder->frameLength);#ifdef LD_DEC    if (hDecoder->object_type == LD)        hDecoder->frameLength >>= 1;#endif    return 0;}#ifdef DRMint8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate,                              uint8_t channels){    uint8_t i;    if (hDecoder == NULL)        return 1; /* error */    /* Special object type defined for DRM */    hDecoder->config.defObjectType = DRM_ER_LC;    hDecoder->config.defSampleRate = samplerate;#ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM    hDecoder->aacSectionDataResilienceFlag = 1; /* VCB11 */    hDecoder->aacScalefactorDataResilienceFlag = 0; /* no RVLC */    hDecoder->aacSpectralDataResilienceFlag = 1; /* HCR */#endif    hDecoder->frameLength = 960;    hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);    hDecoder->object_type = hDecoder->config.defObjectType;    if ((channels == DRMCH_STEREO) || (channels == DRMCH_SBR_STEREO))        hDecoder->channelConfiguration = 2;    else        hDecoder->channelConfiguration = 1;#ifdef SBR_DEC    if (channels == DRMCH_SBR_LC_STEREO)        hDecoder->lcstereo_flag = 1;    else        hDecoder->lcstereo_flag = 0;    if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO))        hDecoder->sbr_present_flag = 0;    else        hDecoder->sbr_present_flag = 1;    /* Reset sbr for new initialization */    sbrDecodeEnd(hDecoder->sbr[0]);    hDecoder->sbr[0] = NULL;#endif    if (hDecoder->fb) filter_bank_end(hDecoder->fb);    hDecoder->fb = NULL;    /* Take care of buffers */    if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer);    hDecoder->sample_buffer = NULL;    hDecoder->alloced_channels = 0;    for (i = 0; i < MAX_CHANNELS; i++)    {        hDecoder->window_shape_prev[i] = 0;        if (hDecoder->time_out[i]) faad_free(hDecoder->time_out[i]);        hDecoder->time_out[i] = NULL;        if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]);        hDecoder->fb_intermed[i] = NULL;#ifdef SSR_DEC        if (hDecoder->ssr_overlap[i]) faad_free(hDecoder->ssr_overlap[i]);        hDecoder->ssr_overlap[i] = NULL;        if (hDecoder->prev_fmd[i]) faad_free(hDecoder->prev_fmd[i]);        hDecoder->prev_fmd[i] = NULL;#endif#ifdef MAIN_DEC        if (hDecoder->pred_stat[i]) faad_free(hDecoder->pred_stat[i]);        hDecoder->pred_stat[i] = NULL;#endif#ifdef LTP_DEC        hDecoder->ltp_lag[i] = 0;        if (hDecoder->lt_pred_stat[i]) faad_free(hDecoder->lt_pred_stat[i]);        hDecoder->lt_pred_stat[i] = NULL;#endif    }    for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)    {#ifdef SBR_DEC        if (hDecoder->sbr[i])            sbrDecodeEnd(hDecoder->sbr[i]);        hDecoder->sbr_alloced[i] = 0;#endif        hDecoder->element_alloced[i] = 0;        hDecoder->element_output_channels[i] = 0;    }    hDecoder->fb = filter_bank_init(hDecoder->frameLength);    return 0;}#endifvoid FAADAPI faacDecClose(faacDecHandle hDecoder){    uint8_t i;    if (hDecoder == NULL)        return;#ifdef PROFILE    printf("AAC decoder total:  %I64d cycles\n", hDecoder->cycles);    printf("requant:            %I64d cycles\n", hDecoder->requant_cycles);    printf("spectral_data:      %I64d cycles\n", hDecoder->spectral_cycles);    printf("scalefactors:       %I64d cycles\n", hDecoder->scalefac_cycles);    printf("output:             %I64d cycles\n", hDecoder->output_cycles);#endif    for (i = 0; i < MAX_CHANNELS; i++)    {        if (hDecoder->time_out[i]) faad_free(hDecoder->time_out[i]);        if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]);#ifdef SSR_DEC        if (hDecoder->ssr_overlap[i]) faad_free(hDecoder->ssr_overlap[i]);        if (hDecoder->prev_fmd[i]) faad_free(hDecoder->prev_fmd[i]);#endif#ifdef MAIN_DEC        if (hDecoder->pred_stat[i]) faad_free(hDecoder->pred_stat[i]);#endif#ifdef LTP_DEC        if (hDecoder->lt_pred_stat[i]) faad_free(hDecoder->lt_pred_stat[i]);#endif    }#ifdef SSR_DEC    if (hDecoder->object_type == SSR)        ssr_filter_bank_end(hDecoder->fb);    else#endif        filter_bank_end(hDecoder->fb);    drc_end(hDecoder->drc);    if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer);#ifdef SBR_DEC    for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)    {        if (hDecoder->sbr[i])            sbrDecodeEnd(hDecoder->sbr[i]);    }#endif    if (hDecoder) faad_free(hDecoder);}void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, int32_t frame){    if (hDecoder)    {        hDecoder->postSeekResetFlag = 1;        if (frame != -1)            hDecoder->frame = frame;    }}static void create_channel_config(faacDecHandle hDecoder, faacDecFrameInfo *hInfo){    hInfo->num_front_channels = 0;    hInfo->num_side_channels = 0;    hInfo->num_back_channels = 0;    hInfo->num_lfe_channels = 0;        //m emset(hInfo->channel_position, 0, MAX_CHANNELS*sizeof(uint8_t)); happens a lot, but apparently not needed    if (hDecoder->downMatrix)    {        hInfo->num_front_channels = 2;        hInfo->channel_position[0] = FRONT_CHANNEL_LEFT;        hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT;        return;    }    /* check if there is a PCE */    if (hDecoder->pce_set)    {        uint8_t i, chpos = 0;        uint8_t chdir, back_center = 0;        hInfo->num_front_channels = hDecoder->pce.num_front_channels;        hInfo->num_side_channels = hDecoder->pce.num_side_channels;        hInfo->num_back_channels = hDecoder->pce.num_back_channels;        hInfo->num_lfe_channels = hDecoder->pce.num_lfe_channels;        chdir = hInfo->num_front_channels;        if (chdir & 1)        {            hInfo->channel_position[chpos++] = FRONT_CHANNEL_CENTER;            chdir--;        }        for (i = 0; i < chdir; i += 2)        {            hInfo->channel_position[chpos++] = FRONT_CHANNEL_LEFT;            hInfo->channel_position[chpos++] = FRONT_CHANNEL_RIGHT;        }        for (i = 0; i < hInfo->num_side_channels; i += 2)        {            hInfo->channel_position[chpos++] = SIDE_CHANNEL_LEFT;            hInfo->channel_position[chpos++] = SIDE_CHANNEL_RIGHT;        }        chdir = hInfo->num_back_channels;        if (chdir & 1)        {            back_center = 1;            chdir--;        }        for (i = 0; i < chdir; i += 2)        {            hInfo->channel_position[chpos++] = BACK_CHANNEL_LEFT;            hInfo->channel_position[chpos++] = BACK_CHANNEL_RIGHT;        }        if (back_center)        {            hInfo->channel_position[chpos++] = BACK_CHANNEL_CENTER;        }        for (i = 0; i < hInfo->num_lfe_channels; i++)        {            hInfo->channel_position[chpos++] = LFE_CHANNEL;        }    } else {        switch (hDecoder->channelConfiguration)        {        case 1:            hInfo->num_front_channels = 1;            hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;            break;        case 2:            hInfo->num_front_channels = 2;            hInfo->channel_position[0] = FRONT_CHANNEL_LEFT;            hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT;            break;        case 3:            hInfo->num_front_channels = 3;            hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;            hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;            hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;            break;        case 4:            hInfo->num_front_channels = 3;            hInfo->num_back_channels = 1;            hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;            hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;            hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;            hInfo->channel_position[3] = BACK_CHANNEL_CENTER;            break;        case 5:            hInfo->num_front_channels = 3;            hInfo->num_back_channels = 2;            hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;            hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;            hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;            hInfo->channel_position[3] = BACK_CHANNEL_LEFT;            hInfo->channel_position[4] = BACK_CHANNEL_RIGHT;            break;        case 6:            hInfo->num_front_channels = 3;            hInfo->num_back_channels = 2;            hInfo->num_lfe_channels = 1;            hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;            hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;            hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;            hInfo->channel_position[3] = BACK_CHANNEL_LEFT;            hInfo->channel_position[4] = BACK_CHANNEL_RIGHT;            hInfo->channel_position[5] = LFE_CHANNEL;            break;        case 7:            hInfo->num_front_channels = 3;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -