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

📄 umc_aac_decoder_int.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*//////////////////////////////////////////////////////////////////////////////////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//          Copyright(c) 2002-2005 Intel Corporation. All Rights Reserved.//*/#include "umc_aac_decoder_int.h"#include "mp4cmn_config.h"namespace UMC {/********************************************************************/  AACDecoderInt::AACDecoderInt()  {    state = NULL;  }/********************************************************************/  Status AACDecoderInt::Init(BaseCodecParams * init)  {    AudioCodecParams *pAudioCodecInit = (AudioCodecParams *) init;    if (!pAudioCodecInit)      return UMC_NULL_PTR;    aacdecInit(&state);    initSubtype = 0;    m_info.m_audio_object_type = AOT_UNDEF;    m_info.m_decode_mode = DM_UNDEF_STREAM;    m_info.m_init_stream_type = pAudioCodecInit->m_info_in.stream_type;    if (NULL == pAudioCodecInit->m_pData) {      m_info.m_init_config_data_size = 0;    } else {      m_info.m_init_config_data_size = pAudioCodecInit->m_pData->GetDataSize();    }    m_info.m_sampling_frequency_index = 0;    m_info.m_frame_number = 0;    m_pts_prev = 0;    params.is_valid = 0;    return UMC_OK;  }/********************************************************************/  Status  AACDecoderInt::SetParams(BaseCodecParams * params) {    AACDecoderIntParams *info = DynamicCast < AACDecoderIntParams > (params);    if (info) {      if ((info->ModeDecodeHEAACprofile == HEAAC_HQ_MODE ||           info->ModeDecodeHEAACprofile == HEAAC_LP_MODE) &&          (info->ModeDwnmxHEAACprofile == HEAAC_DWNSMPL_ON ||           info->ModeDwnmxHEAACprofile == HEAAC_DWNSMPL_OFF)) {        aacdecSetSBRModeDecode(info->ModeDecodeHEAACprofile, state);        aacdecSetSBRModeDwnmx(info->ModeDwnmxHEAACprofile, state);      } else        return UMC_UNSUPPORTED;    } else {      return UMC_NOT_INITIALIZED;    }    return UMC_OK;  }/********************************************************************/  Status  AACDecoderInt::GetFrame(MediaData * in,                                  MediaData * out)  {    AACStatus result;    sBitsreamBuffer BS;    int     res;    int     nDecodedBytes, tmp_decodedBytes;    int     firstTime;    sAudio_specific_config audio_config_data;    unsigned char *inPointer;    double  pts_start = in->GetTime();    double  pts_end;    int SbrFlagPresent, frameSize, freq, ch;    if (!in || !out)      return UMC_NULL_PTR;    if (in->GetDataSize() == 0)      return UMC_NOT_ENOUGH_DATA;    inPointer = (unsigned char *)in->GetDataPointer();    GET_INIT_BITSTREAM(&BS, inPointer)    firstTime = 0;    while ((DM_UNDEF_STREAM == m_info.m_decode_mode) && (0 == firstTime)) {      firstTime = 1;      m_info.m_audio_object_type = AOT_UNDEF;      if (AAC_MPEG4_STREAM == m_info.m_init_stream_type) {        dec_audio_specific_config(&audio_config_data, &BS);        m_info.m_sampling_frequency_index =          get_sampling_frequency_index(&audio_config_data);        m_info.m_decode_mode = DM_RAW_STREAM;        m_info.m_audio_object_type =          (AudioObjectType) audio_config_data.audioObjectType;        aacdecSetAudioObjectType(m_info.m_audio_object_type, state);        /* Init tables */        aacdecSetSamplingFrequency(m_info.m_sampling_frequency_index, state);        in->MoveDataPointer(m_info.m_init_config_data_size);        out->SetDataSize(0);        /* IMPORTANT!!! */        return UMC_NOT_FIND_SYNCWORD;      }      bs_save(&BS);      res = dec_adif_header(&m_adif_header, &BS);      if (res == 0) {        sProgram_config_element *m_p_pce = &m_adif_header.pce[0];        aacdecSetPCE(m_p_pce, state);        m_info.m_sampling_frequency_index = m_p_pce->sampling_frequency_index;        m_info.m_decode_mode = DM_RAW_STREAM;        /* Init tables */        aacdecSetSamplingFrequency(m_info.m_sampling_frequency_index, state);        switch (m_p_pce->object_type) {        case 0:          m_info.m_audio_object_type = AOT_AAC_MAIN;          break;        case 1:          m_info.m_audio_object_type = AOT_AAC_LC;          break;        case 2:          m_info.m_audio_object_type = AOT_AAC_SSR;          break;        case 3:          m_info.m_audio_object_type = AOT_AAC_LTP;          break;        }        aacdecSetAudioObjectType(m_info.m_audio_object_type, state);        break;      }      bs_restore(&BS);      if ((0 == dec_adts_fixed_header(&m_adts_fixed_header, &BS)) &&          (0 == dec_adts_variable_header(&m_adts_variable_header, &BS))) {        m_info.m_sampling_frequency_index =          m_adts_fixed_header.sampling_frequency_index;        m_info.m_audio_object_type = (AudioObjectType)          get_audio_object_type_by_adts_header(&m_adts_fixed_header);        m_info.m_decode_mode = DM_ADTS_STREAM;        aacdecSetAudioObjectType(m_info.m_audio_object_type, state);        /* Init tables */        aacdecSetSamplingFrequency(m_info.m_sampling_frequency_index, state);        adts_sw = (0xFFF << 12) + ((m_adts_fixed_header.ID & 1) << 11) +                                  ((m_adts_fixed_header.Layer & 3) << 8) +                                  ((m_adts_fixed_header.Profile & 3) << 6) +                                  ((m_adts_fixed_header.sampling_frequency_index & 15) << 2);        bs_restore(&BS);        break;      }      bs_restore(&BS);      m_info.m_stream_subtype = UNDEF_AUDIO_SUBTYPE;      if (m_info.m_audio_object_type == AOT_AAC_MAIN) {        m_info.m_stream_subtype = AAC_MAIN_PROFILE;      } else if (m_info.m_audio_object_type == AOT_AAC_LC) {        m_info.m_stream_subtype = AAC_LC_PROFILE;      } else if (m_info.m_audio_object_type == AOT_AAC_SSR) {        m_info.m_stream_subtype = AAC_SSR_PROFILE;      } else if (m_info.m_audio_object_type == AOT_AAC_LTP) {        m_info.m_stream_subtype = AAC_LTP_PROFILE;      }    }    if (AOT_UNDEF == m_info.m_audio_object_type)      return UMC_UNSUPPORTED;    if (DM_ADTS_STREAM == m_info.m_decode_mode) {      int DataSize = in->GetDataSize();      unsigned char *tmp_ptr = (unsigned char *)in->GetDataPointer();      unsigned int val;      if (DataSize < 9)        return UMC_NOT_ENOUGH_DATA;      val = (tmp_ptr[0] << 16) + (tmp_ptr[1] << 8) + tmp_ptr[2];      DataSize -= 3;      tmp_ptr += 3;      while (((val & 0xFFFEFC) != adts_sw) && (DataSize > 0)) {        val = (val << 16) + tmp_ptr[0];        DataSize--;        tmp_ptr++;      }      if ((val & 0xFFFEFC) != adts_sw) {        in->MoveDataPointer(in->GetDataSize()-2);        return UMC_NOT_ENOUGH_DATA;      }      DataSize += 3;      in->MoveDataPointer(in->GetDataSize()-DataSize);      if (DataSize < 9) {        return UMC_NOT_ENOUGH_DATA;      }      inPointer = (unsigned char *)in->GetDataPointer();      GET_INIT_BITSTREAM(&BS, inPointer)      dec_adts_fixed_header(&m_adts_fixed_header, &BS);      dec_adts_variable_header(&m_adts_variable_header, &BS);      if (m_adts_fixed_header.protection_absent == 0) {        GET_BITS(&BS, val, 16)      }      if (m_adts_variable_header.aac_frame_length > DataSize) {        return UMC_NOT_ENOUGH_DATA;      }      aacdecSetAdtsChannelConfiguration(m_adts_fixed_header.channel_configuration,                                        state);    }

⌨️ 快捷键说明

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