예제 #1
0
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
{
    switch(cmd)
    {
      case ADCTRL_RESYNC_STREAM:
         aac_sync(sh);
         AACFlushCodec(hAACDecoder);
	 return CONTROL_TRUE;
    }
  return CONTROL_UNKNOWN;
}
예제 #2
0
HX_RESULT
aac_decode_reset(void*   pDecode,
                 UINT16* pSamplesOut,
                 UINT32  ulNumSamplesAvail,
                 UINT32* pNumSamplesOut)
{
    aac_decode* pDec = (aac_decode*) pDecode;
    AACFlushCodec(pDec->pDecoder);
    *pNumSamplesOut = 0;
    pDec->ulSamplesToConceal = 0;

    /* reset the delay compensation */
    pDec->ulDelayRemaining = pDec->ulSamplesPerFrame;

    return HXR_OK;
}
예제 #3
0
/*----------------------------------------------------------------------
|    AacDecoder_Seek
+---------------------------------------------------------------------*/
BLT_METHOD
AacDecoder_Seek(BLT_MediaNode* _self,
                BLT_SeekMode*  mode,
                BLT_SeekPoint* point)
{
    AacDecoder* self = ATX_SELF_EX(AacDecoder, BLT_BaseMediaNode, BLT_MediaNode);

    BLT_COMPILER_UNUSED(mode);
    BLT_COMPILER_UNUSED(point);
    
    /* clear the eos flag */
    self->input.eos  = BLT_FALSE;

    /* remove any packets in the output list */
    AacDecoderOutput_Flush(self);

    /* reset the decoder */
    if (self->helix_decoder) AACFlushCodec(self->helix_decoder);

    return BLT_SUCCESS;
}
예제 #4
0
HX_RESULT
aac_decode_decode(void*       pDecode,
                  UINT8*      pData,
                  UINT32      ulNumBytes,
                  UINT32*     pNumBytesConsumed,
                  UINT16*     pSamplesOut,
                  UINT32      ulNumSamplesAvail,
                  UINT32*     pNumSamplesOut,
                  UINT32      ulFlags,
                  UINT32	  ulTimeStamp)
{
    HX_RESULT retVal = HXR_FAIL;
    aac_decode* pDec = (aac_decode*) pDecode;
    AACFrameInfo *frameInfo = pDec->pFrameInfo;
    UINT32 lostFlag, maxSamplesOut;
    UINT32 ulNumBytesRemaining;
    UINT8* inBuf = pData;
    UINT16* outBuf = pSamplesOut;

    ulNumBytesRemaining = ulNumBytes;
    *pNumBytesConsumed = 0;
    *pNumSamplesOut = 0;

    lostFlag = !(ulFlags & 1);

    if (pDec->ulSamplesToConceal || lostFlag)
    {
        if (lostFlag) /* conceal one frame */
            *pNumSamplesOut = pDec->ulSamplesPerFrame;
        else
        {
            maxSamplesOut = pDec->ulSamplesPerFrame * pDec->ulFramesPerBlock;
            *pNumSamplesOut = maxSamplesOut;
            if (pDec->ulSamplesToConceal < maxSamplesOut)
                *pNumSamplesOut = pDec->ulSamplesToConceal;
            pDec->ulSamplesToConceal -= *pNumSamplesOut;
        }
        /* just fill with silence */
        memset(pSamplesOut, 0, *pNumSamplesOut * sizeof(INT16));
        AACFlushCodec(pDec->pDecoder);

        *pNumBytesConsumed = 0;
        return HXR_OK;
    }

    retVal = AACDecode(pDec->pDecoder, &inBuf,
                       (INT32*)&ulNumBytesRemaining, (INT16*)outBuf);
    if (retVal == ERR_AAC_NONE)
    {
        AACGetLastFrameInfo(pDec->pDecoder, frameInfo);
        AACReorderPCMChannels((INT16*)outBuf, frameInfo->outputSamps, frameInfo->nChans);
        pDec->ulSampleRateCore = frameInfo->sampRateCore;
        pDec->ulSampleRateOut = frameInfo->sampRateOut;
        pDec->ulNumChannels = frameInfo->nChans;
        *pNumSamplesOut = frameInfo->outputSamps;
        *pNumBytesConsumed = ulNumBytes - ulNumBytesRemaining;
        retVal = HXR_OK;
    }
    else if (retVal == ERR_AAC_INDATA_UNDERFLOW)
    {
        retVal = HXR_NO_DATA;
    }
    else
    {
        retVal = HXR_FAIL;
    }

    /* Zero out invalid output samples */
    if (*pNumSamplesOut == 0)
    {
        /* protect consumer ears by zeroing the output buffer */
        memset(pSamplesOut, 0, pDec->ulSamplesPerFrame * sizeof(UINT16));
    }
    else if (pDec->ulDelayRemaining > 0) /* delay samples */
    {
        if (pDec->ulDelayRemaining >= *pNumSamplesOut)
        {
            pDec->ulDelayRemaining -= *pNumSamplesOut;
            *pNumSamplesOut = 0;
        }
        else
        {
            *pNumSamplesOut -= pDec->ulDelayRemaining;
            memmove(pSamplesOut, pSamplesOut + pDec->ulDelayRemaining, *pNumSamplesOut);
            pDec->ulDelayRemaining = 0;
        }
    }

    return retVal;
}