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

📄 wmawrap.c

📁 本程序为ST公司开发的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
             & (CAPTURE_EVENT_SUBCODE_BEGIN_OF_SONG | CAPTURE_EVENT_SUBCODE_REL_TIME) )            {#ifdef APM_PICKUP              //APM: time in miliseconds:              time_event.ms.rel_time = tPresTimeMiliSec;              time_event.ms.event_type = WMABufferElement.subcode.event_type;#else              //STM: calculate time into MSF format:              time_event.ms.event_type = WMABufferElement.subcode.event_type;              time_event.subcode.q_subcode.q_min = (tPresTimeMiliSec / 60000);          // min;              time_event.subcode.q_subcode.q_sec = ((tPresTimeMiliSec / 1000) % 60);  // sec;              time_event.subcode.q_subcode.q_frame = 0; // frame;              time_event.subcode.q_subcode.q_tno = position.song_number;               time_event.subcode.q_subcode.xid = position.xfile;#endif              time_event.subcode.event_subcode = 0; // CA - info for AB to enable/disable de-emphasis              WMABufferElement.subcode.event_type = CAPTURE_EVENT_SUBCODE_NONE; // clear not to send 2nd time            }            /* Writing of output data into AudioBuffer has finished */            /* Set flag: */            AudioBufferSetFull(num_samples, nextABElementFlag, &time_event, &position);            nextABElementFlag = FT_MIDDLE;            unreported_subcode_event_type = 0;          }          WMA_FetchedSamples += num_samples;          if (num_samples == 0)          {            /* no more, so on with the decoding... */            break;          }#define BREAK_AT_SAMPLE 68000#ifdef  BREAK_AT_SAMPLE          if (g_ulOutputSamples <= BREAK_AT_SAMPLE           && BREAK_AT_SAMPLE < (g_ulOutputSamples + num_samples))            //{ int j; j = (int)g_ulOutputSamples; }#endif /*BREAK_AT_SAMPLE*/            g_ulOutputSamples += num_samples;        }        while (WMA_FetchedSamples < WMA_DecodedSamples);#if (WMA_WRAP_DEBUG != 0)        //      set_gpio(PORT_B, GPIO_4, FALSE);#endif /*WMA_WRAP_DEBUG*/        WMADecoderNextState = decodingFrames;        break;      }    case fatalError:      {        /* Should not arrive here, but anyway... */        return decoderFatalError;      }    default:      ASSERT(0, "Hit default case in while(1)");      break;    }  }}/************************************* WMAFileFBGetData()** Description:** Wma decoder directly takes data* from Frame Buffer.*************************************/tWMA_U32 WMAFileFBGetData(tHWMAFileState *state,                          tWMA_U64 offset,                          tWMA_U32 num_bytes,                          unsigned char **ppData){  tWMA_U32 ret;  unsigned char g_previousElement;  tWMA_I64 iRelativeOffset;  /* set number of DECODED bytes */  SetDecodedBytesWMA(offset);  /* Initialize return values */  *ppData = NULL;  ret = 0;#if (WMA_WRAP_DEBUG != 0)  WMADecodeDBG.num_bytes_count_tmp_buf[WMADecodeDBG.count2] = WMABufferElement.en;  WMADecodeDBG.num_bytes_remain_tmp_buf[WMADecodeDBG.count2] = WMA_FBufferRemain;  WMADecodeDBG.num_bytes_tmp_buf[WMADecodeDBG.count2++] = num_bytes;  WMADecodeDBG.count2 %= NUM_SAMPLES_TMP_BUF_LEN;  WMADecodeDBG.num_bytes_count_tmp_buf[WMADecodeDBG.count2] = 0;  WMADecodeDBG.num_bytes_remain_tmp_buf[WMADecodeDBG.count2] = 0;  WMADecodeDBG.num_bytes_tmp_buf[WMADecodeDBG.count2] = 0;  if (WMADecodeDBG.prev_offset > offset)    DBG_PRINTF("WMAWRAP: **Error: prev_offset > offset !!!");  WMADecodeDBG.prev_offset = offset;#endif /*WMA_WRAP_DEBUG*/  /* check whether there was Controller request to stop (NEXT/PREV/STOP/FF/FR) */  if (decoderStopRequest())  {    return decoderEOF_immediate;  }  do  {    if (WaitingMode == 0)    {      if (g_FB_clearFrom != g_FB_readFrom)      {        /* functionality like SetEmptyFBECycle() but excluding g_FB_readFrom element */        if (g_FB_readFrom == 0)          g_previousElement = FrameBufferElements;        else          g_previousElement = (g_FB_readFrom - 1);        SetEmptyFBECycle(g_FB_clearFrom, g_previousElement);        g_FB_clearFrom = g_FB_readFrom;      }    }    if (WMADecoderNextState == waitingFrameData)    {      /* test if previous FBE was 'the last' */      if (WMABufferElement.ElementFlag == FT_LAST)      {        /*if so, return 0 bytes */        WMADecoderNextState = decodingFrames;        WMA_FBufferRemain = 0;        WaitingMode = 0;        return -1;  /* FrameBuffer not prepared */      }      if (WMABufferElement.ElementFlag == FT_FSLAST)      {        /* if so, return 0 bytes */        WMADecoderNextState = decodingFrames;        WMA_FBufferRemain = 0;        WaitingMode = 0;        return -2;      }      if (FrameBufferGetData(&WMABufferElement, 1) == fbDataReady)      {        WMA_PlusFBufferOffset = WMABufferElement.startOffset;        if (WMA_PlusFBufferOffset < offset)        {          /* we still didn't reach begining of requested byte; discard FBE */          if (g_FB_clearFrom != g_FB_readFrom)          {            SetEmptyFBECycle(g_FB_clearFrom, g_FB_readFrom - 1);            g_FB_clearFrom = g_FB_readFrom;          }        }        else        {          WMADecoderNextState = decodingFrames;          WaitingMode = 0;          WMA_FBufferRemain += WMABufferElement.availableDataLength;        }      }      else      {        WaitingMode = 1;        return -1;  /* FrameBuffer not prepared */      }    }    if (WMADecoderNextState == decodingFrames)    {      iRelativeOffset = (tWMA_I64) offset                      - ((tWMA_I64) WMA_PlusFBufferOffset - WMABufferElement.availableDataLength);      if (offset < WMA_PlusFBufferOffset)      {        /* all requested range is available */        if (offset + num_bytes <= WMA_PlusFBufferOffset)        {          /* Entire request is entirely within range of current buffer */          *ppData = (WMABufferElement.data + iRelativeOffset);          WMA_FBufferRemain = WMA_PlusFBufferOffset - offset - num_bytes;#if (IN_BUF != 0)          if ((FBTmpCount + num_bytes) < TMP_FB_SIZE)          {            memcpy(pFBTmpBuf, WMA_pDataPrevious, num_bytes);            pFBTmpBuf += num_bytes;            FBTmpCount += num_bytes;          }          else          {            pFBTmpBuf = FBTmpBuf;            FBTmpCount = 0;          }#endif /*IN_BUF*/          WaitingMode = 0;          return num_bytes;        }        /* Only the start of requested range is in our buffer. */        /* If this is the last FBE give all we have */        if (WMABufferElement.ElementFlag == FT_LAST)        {          *ppData = (WMABufferElement.data + iRelativeOffset);          ret = WMA_FBufferRemain;          WMA_FBufferRemain = 0;#if (IN_BUF != 0)          if ((FBTmpCount + ret) < TMP_FB_SIZE)          {            memcpy(pFBTmpBuf, WMA_pDataPrevious, ret);            pFBTmpBuf += ret;            FBTmpCount += ret;          }          else          {            pFBTmpBuf = FBTmpBuf;            FBTmpCount = 0;          }#endif /*IN_BUF*/          WaitingMode = 0;          return ret;        }        WMA_FBufferRemain = WMABufferElement.availableDataLength - iRelativeOffset;        /* if Top FB Element, copy the rest to the FB[0] */        if (WMABufferElement.en == FrameBufferElements)        {#if (1 == HAVE_WMDRM_LARGE_BUFFER)                      if (WMA_FBufferRemain & 0x1) /* Check 8 bit boundary address or not. */          {            WMA_FBufferRemain++;       /* Change 8 bit boundary to 16 bits. */          }          if (iRelativeOffset & 0x1)   /* Check 8 bit boundary address or not. */          {            iRelativeOffset--;         /* Change 8 bit boundary to 16 bits. */          }                                                                         /* Copy data to external device with 16 bits data size. */          memcpy16(FrameBuffer[1].data - WMA_FBufferRemain,                  WMABufferElement.data + iRelativeOffset,                  WMA_FBufferRemain);#else          memmove(FrameBuffer[1].data - WMA_FBufferRemain,                  WMABufferElement.data + iRelativeOffset,                  (size_t) WMA_FBufferRemain);#endif          WaitingMode = 1;        }        else        {          // [LL] ?        }      }      WMADecoderNextState = waitingFrameData;      WaitingMode = 1;    }  }  while (WMA_PlusFBufferOffset < offset + num_bytes);  return ret;}/************************************* WMAKill()** Description:** Free all memory allocated during* decoder initialization.*************************************/void WMAKill(DecoderKillType killType){  // TBD - could return something  WaitingMode = 0;                  /* can be used by another decoder */  if (killType == closeOnly)  {    WMADecoderNextState = notInitialized;    /* clear used FBElements */  }  else if (killType == destroy)  {  }  SetEmptyFBECycle(g_FB_clearFrom, g_FB_readFrom);  /* [OK] should be cleared after decoding */  WMAFileDecodeClose(WMA_pStateDecoder);        /* de-allocate memory allocated by WMAFileDecodeInitEx()*/  FREE(WMA_pStateDecoder);              /* free main pointer */  INIT_FAST_MALLOC();                 /* to ensure 1000% NONE items allocated */}#else /*HAVE_WMA*///tWMA_U32 WMAFileFBGetData (tHWMAFileState *state, tWMA_U64 offset, tWMA_U32 num_bytes, unsigned char **ppData) { return decoderFatalError; }WMAERR WMAInit(t_bool bFileTypeChanged) { return WMAERR_OK; }decoderReturnType WMADecode(int flag) { return decoderFatalError; }tWMAFileStatus WMAFileDecodeData (tHWMAFileState hstate, tWMA_U32 *pnDecodedSamples) { return cWMA_Failed; }tWMAFileStatus WMAF_UpdateNewPayload (tWMAFileStateInternal *pInt) { return cWMA_Failed; }WMAERR WMA_ParsePacketHeader (tWMAFileStateInternal *pInt) { return WMAERR_OK; }WMAERR WMA_ParsePayloadHeader (tWMAFileStateInternal *pInt) { return WMAERR_OK; }#endif /*HAVE_WMA*/

⌨️ 快捷键说明

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