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

📄 wmawrap.c

📁 本程序为ST公司开发的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/************************************************** * * wmawrap.c * * Author:   Ondrej Kutik * Date:     $Date: 2007/09/21 05:27:18 $ * Revision: $Revision: 1.49 $ * * Description: * * Wrapper functions around the WMA library functions. Interface between WMA decoder and Decoder Task. * *************************************************** * * STM CVS Log: * * $Log: wmawrap.c,v $ * Revision 1.49  2007/09/21 05:27:18  hara * Initial implementation for WMDRM feature into A+. * * Revision 1.48  2007/03/01 08:30:18  chlapik * fixed bug with BOS for special wma songs (e.g. Eve_v9_320_44100_stereo.wma) * * Revision 1.47  2007/02/27 09:38:10  belardi * Removed requirement to compile in ARM mode since the libraries are now in Thumb * * Revision 1.46  2007/02/01 16:51:45  chlapik * fixed bug - song_number * * Revision 1.45  2007/01/30 09:38:16  chlapik * fixed bug: * song_number and xid sent from CTR to PLY is not set in CTR task but it is provided by DEC to AB * * Revision 1.44  2006/12/04 16:56:01  chlapik * fixed bugs: * - in case of no data put to FB, remember previous possible BOS event * - in case of error, try to continue with shift not one packet, but one byte * * Revision 1.43  2006/10/17 09:53:07  trubac * pragma ARM * cosmetic, commented prototypes, whitespaces, newlines * * Revision 1.39  2006/09/15 19:40:59  belardi * Merged the m8_cav2_cm80506_cs3563. * - renamed _EVENT_TEP_NOEVENT * * **************************************************///#include <stdio.h>#include <string.h>#include <math.h>/* Accordo+ stuff */#include "configuration.h"#include "debug.h"//#include "accordoptypes.h"#include "gendef.h"#include "osal.h"#include "apdevsys.h"#include "allocation.h"#include "decoder_defines.h"#include "decoder_task.h"#include "wmawrap.h"#include "framebuffer.h"#include "audiobuffer.h"#include "controller.h"/* pure WMA stuff  */#include"aumalloc.h"#include "wmaudio.h"#include "wmaudio_type.h"#include "wmatypes.h" // [GP] added#include "wmatyps.h"  // [OK] added#include "pcmfmt.h"#include "AutoProfile.h"#if (HAVE_WMA != 0)#if (0 == HAVE_WMDRM) /* DRM implementation : Exclude the following original program [FHA] */#ifdef WMDRM_NETWORK#include "DrmXmr.h"#include "WmdrmNet.h"//#include "OEMImpl.h"#endif /*WMDRM_NETWORK*/#else #include "WMDRM_Receiver.h"#endif/***** function prototypes *******/extern tWMAFileStatus WMAFileDecodeClose(tHWMAFileState *phstate);   /* wma decoder *//***** application related stuff *******/FrameBufferElement WMABufferElement;unsigned char g_FB_clearFrom;/** extern declarations **/extern unsigned char g_FB_readFrom;           /* from framebuffer.c *//* amount of bytes to be skipped in fast seek mode */extern int g_decoderFastSeekJumpBytes;        /* from decoder_task.c - not used */extern t_PlayMode decoderPlayMode;CADecoderStateType WMADecoderNextState = notInitialized;extern char WaitingMode;                      /* from decoder_task.c *//***** Variables required by the WMA library *******///tWMA_U64 WMA_offset = 0; // [RB] unusedtWMAFileHeader WMA_Hdr;                       /* after init stores general info about song */tWMAFileHdrState WMA_HdrState;                /* after init stores specific info about song */tHWMAFileState *WMA_pStateDecoder;            /* after init it is instance of the decoder */tWMA_U32 WMA_DecodedSamples;                  /* number of samples decoded */tWMA_U32 WMA_FetchedSamples;                  /* number of read decoded samples */tWMA_I64 WMA_FBufferRemain = 0;               /* remaining bytes in the current FB element */tWMA_U64 WMA_PlusFBufferOffset = 0;           /* absolute offset in the file indicating max. prepared data in FB */unsigned int WMA_SampleRate;                  /* actual sample rate of the song */unsigned int g_ulOutputSamples = 0;/***** Debugging *******///extern int vectors_debug[32];#if (IN_BUF != 0)#define TMP_FB_SIZE 10*1024__attribute__((section("fb_tmp_buffer"),zero_init)) uint8 FBTmpBuf[TMP_FB_SIZE];uint8 *pFBTmpBuf = FBTmpBuf;uint32 FBTmpCount = 0;#endif /*IN_BUF*/#if (WMA_WRAP_DEBUG != 0)#include "utility.h"#define NUM_SAMPLES_TMP_BUF_LEN 10typedef struct _WMADecodeDBG_{  tWMA_U32 num_samples_tmp_buf[NUM_SAMPLES_TMP_BUF_LEN];  tWMA_U32 g_nDecSamples[NUM_SAMPLES_TMP_BUF_LEN];  sint32 count1;  sint32 count2;  tWMA_U32 num_bytes_count_tmp_buf[NUM_SAMPLES_TMP_BUF_LEN];  tWMA_U32 num_bytes_remain_tmp_buf[NUM_SAMPLES_TMP_BUF_LEN];  tWMA_U32 num_bytes_tmp_buf[NUM_SAMPLES_TMP_BUF_LEN];  tWMA_U64 prev_offset;  tWMA_U32 max_num_samples;} _WMADecodeDBG;_WMADecodeDBG WMADecodeDBG;#endif /*WMA_WRAP_DEBUG*//*********** FUNCTIONS **************//************************************* WMAInit()** Description:** Initializes the WMA decoder state* machine, so MUST be called before* WMADecode().Allocates and* initializes the memory structures.*************************************/WMAERR WMAInit(t_bool bFileTypeChanged){  Bool bDropPacket = False;  U16 nDRCSetting = 0;  U16 nDecoderFlags = 0;  U32 nDstChannelMask = 0;  U32 nInterpResampRate = 0;  U16 nMBRTargetStream = 1;  PCMFormat pcmFormat;  tWMAFileStatus rc;  //tWMA_U16 wMBRTotalStreams = 0;  /* reset global values for each file call. */  g_ulOutputSamples = 0;  /* init struct */  WMA_pStateDecoder = auMalloc(sizeof(*WMA_pStateDecoder));  memset((void *) WMA_pStateDecoder, 0, sizeof(*WMA_pStateDecoder));  memset((void *)&WMA_Hdr, 0, sizeof(WMA_Hdr));  /* test the checking API *//*  [LL] done during tag decoding  rc = WMAFileSetTargetMBRAudioStream(&WMA_HdrState, nMBRTargetStream);  if(rc != cWMA_NoErr)  {    DBG_PRINTF("WMAWRAP: ** Error while setting target stream number.\r\n");    return WMAERR_INVALIDARG;  }*//*  [OK] removed - will be in Controler block  rc = WMAFileIsWMA(&WMA_HdrState);  if(rc != cWMA_NoErr)  {    DBG_PRINTF("WMAWRAP: ** The file is not a WMA file.\r\n");    if (rc == cWMA_BadArgument)      return WMAERR_INVALIDARG;    else      return WMAERR_INVALIDHEADER;  }*/  /* Check for MBR *//*  [LL] done during tag decoding  rc = WMAFileMBRAudioStreams(&WMA_HdrState, &wMBRTotalStreams);  if(rc != cWMA_NoErr)  {    DBG_PRINTF("WMAWRAP: ** Error while verifying MBR information.\r\n");    return WMAERR_INVALIDARG;  }*/  /* init the decoder */  rc = WMAFileDecodeCreate(WMA_pStateDecoder);  if (rc != cWMA_NoErr)  {    DBG_PRINTF("WMAWRAP: ** Cannot create the WMA decoder.\r\n");    if (rc == cWMA_BadArgument)      return WMAERR_INVALIDARG;    else      return WMAERR_FAIL;  }#if (1 == HAVE_WMDRM)                   /* Check WMDRM License is available or not. ProximityContext.USBDeviceConfig */  if ( IS_USBDeviceLicense_Available )  {    ((tWMAFileStateInternal*)*WMA_pStateDecoder)->pWMDRMNetworkKey = (DRM_AES_KEY *)&ProximityContext.ContentEncryption_AES_Key[0];  }  else  {    ((tWMAFileStateInternal*)*WMA_pStateDecoder)->pWMDRMNetworkKey = NULL; /* Set NULL pointer. */  }#endif  rc = WMAFileDecodeInitEx(*WMA_pStateDecoder, nDecoderFlags, nDRCSetting, bDropPacket,                           nDstChannelMask, nInterpResampRate, &pcmFormat, nMBRTargetStream);  if (rc != cWMA_NoErr)  {    DBG_PRINTF("WMAWRAP: ** Cannot initialize the WMA decoder.\r\n");    return rc;    //[LL] type?  }  /* get header information */  rc = WMAFileDecodeInfo(*WMA_pStateDecoder, &WMA_Hdr);  if (rc != cWMA_NoErr)  {    DBG_PRINTF("WMAWRAP: ** Failed to retrieve information.\r\n");    return WMAERR_INVALIDARG;  }  /* get content description *//*  [OK] not needed, is done in Controller  rc = WMAFileContentDesc(WMA_state, &pdesc);  if(rc != cWMA_NoErr)  {    DBG_PRINTF("WMAWRAP: ** Failed to retrieve content description.\r\n");    return WMAERR_INVALIDARG;  }*/  WMA_SampleRate = WMA_Hdr.sample_rate;  WaitingMode = 1;  WMADecoderNextState = notInitialized;  decoderPlayMode = playModePlay;  return WMAERR_OK;}/************************************* WMAGetStereoData()** Description:** Used by WMADecode() to wisely move* decoder output data into AudioBuffer.*************************************/tWMA_U32 WMAGetStereoData(tHWMAFileState iWMA_state,                          pAudioBufferData AudioBuffer_p,                          tWMA_U32 nSamplesToTake,                          tWMA_I64 *ptPresTime){  //int32 count;  pAudioBufferData pAudioBuffer_src, pAudioBuffer_dst;  AudioBufferData AudioBufferTmp;  tWMA_U32 tmp;  tWMA_U32 SizeOfChannel;       /* max size to store (mono or stereo) data */  tWMA_U32 num_samples_stereo;    /* real samples read */  tWMA_U32 nRemainingStereoSamples; /* how big will be the last copied chunk [samples] */  //tWMA_U32 MemoryUsage;       /* how many bytes one stereo sample takes */  tWMAFileChannels NoOfChannels;    /* how many channels to interleave */  if (nSamplesToTake == 0)    return 0;  NoOfChannels = (tWMAFileChannels) ((tWMAFileStateInternal *) iWMA_state)->hdr_parse.nChannels;  //1.MemoryUsage = (((uint32)NoOfChannels >> 1) + (sizeof(tWMA_I16) >> 1) + (2 >> 1)); /* log2(NoOfChannels*sizeof(tWMA_I16)*2) */#if 0 /* reduction 2 */  MemoryUsage = ((uint32)NoOfChannels >> 1);      /* log2(NoOfChannels) */#endif  /* reduction 2 */  switch (NoOfChannels)  {  case cWMA_C_Mono:    //1.SizeOfChannel = AUDIO_BUFFER_ELEMENT_LENGTH*4/2; /* for (the same amount) stereo samples  */

⌨️ 快捷键说明

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