OMX_ERRORTYPE UniaDecoder::AudioFilterCheckCodecConfig()
{
    OMX_S32 ret = OMX_ErrorNone;
    if(IDecoder == NULL || uniaHandle == NULL)
        return OMX_ErrorUndefined;

    if (codecConfig.buf != NULL) {
        codecConfig.buf = (char *)FSL_REALLOC(codecConfig.buf, \
            codecConfig.size + pInBufferHdr->nFilledLen);
        if (codecConfig.buf == NULL)
        {
            LOG_ERROR("Can't get memory.\n");
            return OMX_ErrorInsufficientResources;
        }
        fsl_osal_memcpy(codecConfig.buf + codecConfig.size, pInBufferHdr->pBuffer, pInBufferHdr->nFilledLen);
        codecConfig.size += pInBufferHdr->nFilledLen;

    } else {
         codecConfig.buf = (char *)FSL_MALLOC(pInBufferHdr->nFilledLen);
        if (codecConfig.buf == NULL)
        {
            LOG_ERROR("Can't get memory.\n");
            return OMX_ErrorInsufficientResources;
        }
        fsl_osal_memcpy(codecConfig.buf, pInBufferHdr->pBuffer, pInBufferHdr->nFilledLen);
        codecConfig.size = pInBufferHdr->nFilledLen;
    }

    ret = IDecoder->SetParameter(uniaHandle,UNIA_CODEC_DATA,(UniACodecParameter*)&codecConfig);

    LOG_DEBUG("UniaDec::AudioDecoderBaseCheckCodecConfig nFilledLen=%d,ret=%d",pInBufferHdr->nFilledLen,ret);
    pInBufferHdr->nFilledLen = 0;

    return (OMX_ERRORTYPE)ret;
}
OMX_ERRORTYPE  VideoProcessorComponent::GetConfig(
    OMX_IN  OMX_INDEXTYPE nIndex,
    OMX_INOUT OMX_PTR pComponentConfigStructure)

{

    if(pComponentConfigStructure == NULL)
        return OMX_ErrorBadParameter;

    switch(nIndex)
    {
    case OMX_IndexConfigCommonInputCrop:
    {
        fsl_osal_memcpy(pComponentConfigStructure, &sInRect, sizeof(OMX_CONFIG_RECTTYPE));
        break;
    }
    case OMX_IndexConfigCommonOutputCrop:
    {
        fsl_osal_memcpy(pComponentConfigStructure, &sOutRect, sizeof(OMX_CONFIG_RECTTYPE));
        break;
    }

    default:
        return OMX_ErrorUnsupportedIndex;
    }
    return OMX_ErrorNone;
}
Beispiel #3
0
OMX_ERRORTYPE VideoSource::GetParameter(
        OMX_INDEXTYPE nParamIndex,
        OMX_PTR pStructure)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    switch (nParamIndex) {
		case OMX_IndexParamCommonSensorMode:
            {
                OMX_PARAM_SENSORMODETYPE *pSensorMode;
                pSensorMode = (OMX_PARAM_SENSORMODETYPE*)pStructure;
                OMX_CHECK_STRUCT(pSensorMode, OMX_PARAM_SENSORMODETYPE, ret);
				fsl_osal_memcpy(pSensorMode, &SensorMode,	sizeof(OMX_PARAM_SENSORMODETYPE));
			}
			break;
		case OMX_IndexParamVideoPortFormat:
            {
				OMX_VIDEO_PARAM_PORTFORMATTYPE *pPortFormat;
				pPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*)pStructure;
				OMX_CHECK_STRUCT(pPortFormat, OMX_VIDEO_PARAM_PORTFORMATTYPE, ret);
				fsl_osal_memcpy(pPortFormat, &PortFormat,	sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
			}
			break;
        default:
            ret = InstanceGetParameter(nParamIndex, pStructure);
            break;
    }

    return ret;
}
OMX_ERRORTYPE AudioSource::GetConfig(
        OMX_INDEXTYPE nParamIndex,
        OMX_PTR pStructure)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    switch ((int)nParamIndex) {
        case OMX_IndexConfigAudioVolume:
            {
                OMX_AUDIO_CONFIG_VOLUMETYPE *pVolume;
                pVolume = (OMX_AUDIO_CONFIG_VOLUMETYPE*)pStructure;
                CHECK_STRUCT(pVolume, OMX_AUDIO_CONFIG_VOLUMETYPE, ret);
				fsl_osal_memcpy(pVolume, &Volume, sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE));
            }
            break;
        case OMX_IndexConfigAudioMute:
             {
                OMX_AUDIO_CONFIG_MUTETYPE *pMute;
                pMute = (OMX_AUDIO_CONFIG_MUTETYPE*)pStructure;
                CHECK_STRUCT(pMute, OMX_AUDIO_CONFIG_MUTETYPE, ret);
				fsl_osal_memcpy(pMute, &Mute, sizeof(OMX_AUDIO_CONFIG_MUTETYPE));
            }
            break;
        case OMX_IndexConfigMaxAmplitude:
            {
				 *((OMX_S32*)pStructure) = getMaxAmplitude();
            }
            break;
        default:
            ret = OMX_ErrorUnsupportedIndex;
            break;
    }

    return ret;
}
OMX_ERRORTYPE VideoFilter::ProcessPartialInput()
{
    if(PartialInputHdr.pBuffer == NULL) {
        PartialInputHdr.pBuffer = (OMX_U8*)AllocateInputBuffer(2*pInBufferHdr->nAllocLen);
        if(PartialInputHdr.pBuffer == NULL) {
            LOG_WARNING("Allocate buffer for partial input failed, size: %d.\n", 2*pInBufferHdr->nAllocLen);
            return OMX_ErrorInsufficientResources;
        }
        PartialInputHdr.nAllocLen = 2*pInBufferHdr->nAllocLen;
        PartialInputHdr.nFlags = pInBufferHdr->nFlags;
        PartialInputHdr.nTimeStamp = pInBufferHdr->nTimeStamp;
    }
    else {
        if(PartialInputHdr.nAllocLen - PartialInputHdr.nFilledLen < pInBufferHdr->nFilledLen) {
            OMX_PTR pBuffer = NULL;
            pBuffer = AllocateInputBuffer(2*PartialInputHdr.nAllocLen);
            if(pBuffer == NULL) {
                LOG_WARNING("Allocate buffer for partial input failed, size: %d.\n", PartialInputHdr.nAllocLen);
                return OMX_ErrorInsufficientResources;
            }
            fsl_osal_memcpy(pBuffer, PartialInputHdr.pBuffer, PartialInputHdr.nFilledLen);
            FreeInputBuffer(PartialInputHdr.pBuffer);
            PartialInputHdr.pBuffer = (OMX_U8 *)pBuffer;
            PartialInputHdr.nAllocLen *= 2;
        }
    }

    fsl_osal_memcpy(PartialInputHdr.pBuffer + PartialInputHdr.nFilledLen, pInBufferHdr->pBuffer, pInBufferHdr->nFilledLen);
    PartialInputHdr.nFilledLen += pInBufferHdr->nFilledLen;
    ports[IN_PORT]->SendBuffer(pInBufferHdr);
    pInBufferHdr = NULL;

    return OMX_ErrorNone;
}
OMX_ERRORTYPE VideoProcessorComponent::SetConfig(
    OMX_IN  OMX_INDEXTYPE nIndex,
    OMX_IN  OMX_PTR pComponentConfigStructure)
{
    if(pComponentConfigStructure == NULL)
        return OMX_ErrorBadParameter;

    switch(nIndex)
    {
    case OMX_IndexConfigCommonInputCrop:
    {
        fsl_osal_memcpy(&sInRect,(OMX_CONFIG_RECTTYPE *)pComponentConfigStructure, sizeof(OMX_CONFIG_RECTTYPE));
        if(bStarted == OMX_TRUE)
            bReset = OMX_TRUE;
        break;
    }
    case OMX_IndexConfigCommonOutputCrop:
    {
        fsl_osal_memcpy(&sOutRect,(OMX_CONFIG_RECTTYPE *)pComponentConfigStructure, sizeof(OMX_CONFIG_RECTTYPE));
        if(bStarted == OMX_TRUE)
            bReset = OMX_TRUE;
        break;
    }
    case OMX_IndexConfigCommonRotate:
    {
        fsl_osal_memcpy(&sRotation,(OMX_CONFIG_ROTATIONTYPE *)pComponentConfigStructure, sizeof(OMX_CONFIG_ROTATIONTYPE));
        break;
    }
    default:
        return OMX_ErrorUnsupportedIndex;
    }
    return OMX_ErrorNone;
}
RINGBUFFER_ERRORTYPE RingBuffer::BufferGet(fsl_osal_u8 **ppBuffer, fsl_osal_u32 BufferLen, fsl_osal_u32 *pActualLen)
{
	RINGBUFFER_ERRORTYPE ret = RINGBUFFER_SUCCESS;
	fsl_osal_s32 DataLen = AudioDataLen();
	if (DataLen < (fsl_osal_s32)BufferLen)
	{
		*pActualLen = DataLen;
	}
	else
	{
		*pActualLen = BufferLen;
	}
	if (ReservedLen < *pActualLen)
	{
		LOG_WARNING("Reserved buffer is too short.\n");
		*pActualLen = ReservedLen;
	}

	if (End + *pActualLen > RingBufferPtr + nRingBufferLen)
	{
		fsl_osal_u32 FirstSegmentLen = nRingBufferLen - (End - RingBufferPtr);
		fsl_osal_memcpy(Reserved, End, FirstSegmentLen);
		fsl_osal_memcpy(Reserved + FirstSegmentLen, RingBufferPtr, *pActualLen - FirstSegmentLen);
		*ppBuffer = Reserved;
	}
	else
	{
		*ppBuffer = End;
	}

	LOG_LOG("nRingBufferLen = %d\t DataLen = %d\n", nRingBufferLen, DataLen);
	return ret;
}
RINGBUFFER_ERRORTYPE RingBuffer::BufferAdd(fsl_osal_u8 *pBuffer, fsl_osal_u32 BufferLen, fsl_osal_u32 *pActualLen)
{
	RINGBUFFER_ERRORTYPE ret = RINGBUFFER_SUCCESS;

	fsl_osal_s32 DataLen = AudioDataLen();
	fsl_osal_s32 FreeBufferLen = nRingBufferLen - DataLen - 1;
	if (FreeBufferLen < (fsl_osal_s32)BufferLen)
	{
		*pActualLen = FreeBufferLen;
	}
	else
	{
		*pActualLen = BufferLen;
	}

	if (Begin + *pActualLen > RingBufferPtr + nRingBufferLen)
	{
		fsl_osal_u32 FirstSegmentLen = nRingBufferLen - (Begin - RingBufferPtr);
		fsl_osal_memcpy(Begin, pBuffer, FirstSegmentLen);
		fsl_osal_memcpy(RingBufferPtr, pBuffer + FirstSegmentLen, *pActualLen - FirstSegmentLen);
		Begin = RingBufferPtr + *pActualLen - FirstSegmentLen;
	}
	else
	{
		fsl_osal_memcpy(Begin, pBuffer, *pActualLen);
		Begin += *pActualLen;
	}

	LOG_LOG("nRingBufferLen = %d\t DataLen = %d\n", nRingBufferLen, DataLen);

	return ret;
}
OMX_ERRORTYPE V4lRender::RenderSetConfig(
    OMX_INDEXTYPE nParamIndex,
    OMX_PTR pStructure)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;

	switch (nParamIndex)
	{
	case OMX_IndexConfigCommonOutputCrop:
	{
		OMX_CONFIG_RECTTYPE *pRect;
		pRect = (OMX_CONFIG_RECTTYPE*)pStructure;
		CHECK_STRUCT(pRect, OMX_CONFIG_RECTTYPE, ret);
		fsl_osal_memcpy(&sRectOut, pRect, sizeof(OMX_CONFIG_RECTTYPE));
		SetDeviceDisplayRegion();
	}
	break;
	case OMX_IndexConfigCaptureFrame:
	{
		OMX_CONFIG_CAPTUREFRAME *pCapture;
		pCapture = (OMX_CONFIG_CAPTUREFRAME*)pStructure;
		CHECK_STRUCT(pCapture, OMX_CONFIG_CAPTUREFRAME, ret);
		sCapture.eType = pCapture->eType;
		sCapture.pBuffer = pCapture->pBuffer;
		bCaptureFrameDone = OMX_FALSE;
		if (sCapture.eType == CAP_SNAPSHOT)
		{
			CaptureFrame(EnqueueBufferIdx);
			bCaptureFrameDone = OMX_TRUE;
		}
	}
	break;
	case OMX_IndexOutputMode:
	{
		OMX_CONFIG_OUTPUTMODE *pOutputMode;
		pOutputMode = (OMX_CONFIG_OUTPUTMODE*)pStructure;
		CHECK_STRUCT(pOutputMode, OMX_CONFIG_OUTPUTMODE, ret);
		fsl_osal_memcpy(&sOutputMode, pOutputMode, sizeof(OMX_CONFIG_OUTPUTMODE));
//                AdjustCropIn(&sOutputMode.sRectIn);
		SetOutputMode();
	}
	break;
	case OMX_IndexSysSleep:
	{
		OMX_CONFIG_SYSSLEEP *pStreamOff;
		pStreamOff = (OMX_CONFIG_SYSSLEEP *)pStructure;
		CHECK_STRUCT(pStreamOff, OMX_CONFIG_SYSSLEEP, ret);
		if (pStreamOff->bSleep)
			V4lStreamOff(OMX_TRUE);
		else
			V4lStreamOnInPause();
	}
	break;
	default:
		ret = OMX_ErrorUnsupportedIndex;
		break;
	}

	return ret;
}
OMX_ERRORTYPE Mp3Parser::GetMetadata(OMX_CONFIG_METADATAITEMTYPE *pMatadataItem)
{
	fsl_osal_memcpy(pMatadataItem->nKey, psMatadataItem[pMatadataItem->nMetadataItemIndex]->nKey, 128);
	pMatadataItem->nKeySizeUsed = 128;
	fsl_osal_memcpy(pMatadataItem->nValue, psMatadataItem[pMatadataItem->nMetadataItemIndex]->nValue, psMatadataItem[pMatadataItem->nMetadataItemIndex]->nValueSizeUsed);
	pMatadataItem->nValueSizeUsed = psMatadataItem[pMatadataItem->nMetadataItemIndex]->nValueSizeUsed;

	return OMX_ErrorNone;
}
Beispiel #11
0
OMX_ERRORTYPE LibavAudioDec::AudioFilterGetParameter(
        OMX_INDEXTYPE nParamIndex,
        OMX_PTR pComponentParameterStructure)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    switch ((OMX_U32)nParamIndex) {
        case OMX_IndexParamStandardComponentRole:
            fsl_osal_strcpy((OMX_STRING)((OMX_PARAM_COMPONENTROLETYPE*) \
                        pComponentParameterStructure)->cRole,(OMX_STRING)cRole);
            break;
        case OMX_IndexParamAudioAdpcm:
        {
	        OMX_AUDIO_PARAM_ADPCMMODETYPE *pAdpcmMode;
            pAdpcmMode = (OMX_AUDIO_PARAM_ADPCMMODETYPE*)pComponentParameterStructure;
            OMX_CHECK_STRUCT(pAdpcmMode, OMX_AUDIO_PARAM_ADPCMMODETYPE, ret);

            if(ret != OMX_ErrorNone)
                break;

            fsl_osal_memcpy(pAdpcmMode, &(InputMode.AdpcmMode), sizeof(OMX_AUDIO_PARAM_ADPCMMODETYPE));
            CodingType = OMX_AUDIO_CodingADPCM;
            fsl_osal_strcpy((fsl_osal_char*)name, LIBAV_COMP_NAME_ADPCMDEC);
        }
            break;
        case OMX_IndexParamAudioOpus:
        {
            OMX_AUDIO_PARAM_OPUSTYPE *pOpusMode;
            pOpusMode = (OMX_AUDIO_PARAM_OPUSTYPE*)pComponentParameterStructure;
            OMX_CHECK_STRUCT(pOpusMode, OMX_AUDIO_PARAM_OPUSTYPE, ret);
            if(ret != OMX_ErrorNone)
                break;
            fsl_osal_memcpy(pOpusMode, &(InputMode.OpusMode), sizeof(OMX_AUDIO_PARAM_OPUSTYPE));
            CodingType = (OMX_AUDIO_CODINGTYPE)OMX_AUDIO_CodingOPUS;
            fsl_osal_strcpy((fsl_osal_char*)name, LIBAV_COMP_NAME_OPUSDEC);
        }
            break;
        case OMX_IndexParamAudioApe:
        {
            OMX_AUDIO_PARAM_APETYPE *pApeMode;
            pApeMode = (OMX_AUDIO_PARAM_APETYPE*)pComponentParameterStructure;
            OMX_CHECK_STRUCT(pApeMode, OMX_AUDIO_PARAM_APETYPE, ret);
            if(ret != OMX_ErrorNone)
                break;
            fsl_osal_memcpy(pApeMode, &(InputMode.ApeMode), sizeof(OMX_AUDIO_PARAM_APETYPE));
            CodingType = (OMX_AUDIO_CODINGTYPE)OMX_AUDIO_CodingAPE;
            fsl_osal_strcpy((fsl_osal_char*)name, LIBAV_COMP_NAME_APEDEC);
        }
            break;
        default:
            ret = OMX_ErrorUnsupportedIndex;
            break;
    }

    return ret;
}
Beispiel #12
0
OMX_ERRORTYPE AacDec::UniaDecoderGetParameter(UA_ParaType index,OMX_S32 * value)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;
    if(value == NULL){
        ret = OMX_ErrorBadParameter;
        return ret;
    }

    switch(index){
        case UNIA_SAMPLERATE:
            *value = AacType.nSampleRate;
            break;
        case UNIA_CHANNEL:
            *value = AacType.nChannels;
            break;
        case UNIA_BITRATE:
            *value = AacType.nBitRate;
            break;
        case UNIA_STREAM_TYPE:
            if(AacType.eAACStreamFormat == OMX_AUDIO_AACStreamFormatMP2ADTS){
                *value = STREAM_ADTS;
                if(DEC_STREAM_MODE == ePlayMode){
                    frameInput = OMX_TRUE;
                }
            }else if(AacType.eAACStreamFormat == OMX_AUDIO_AACStreamFormatADIF){
                *value = STREAM_ADIF;
            }else if(AacType.eAACStreamFormat == OMX_AUDIO_AACStreamFormatRAW ||
                     AacType.eAACStreamFormat == OMX_AUDIO_AACStreamFormatMP4FF){
                *value = STREAM_RAW;
                frameInput = OMX_TRUE;
            }else{
                *value = STREAM_UNKNOW;
            }
            LOG_DEBUG("Get aac format = %d",AacType.eAACStreamFormat);
            break;
        case UNIA_FRAMED:
            *value = OMX_TRUE;
            break;
        #ifndef OMX_STEREO_OUTPUT
        case UNIA_CHAN_MAP_TABLE:
            CHAN_TABLE table;
            fsl_osal_memset(&table,0,sizeof(table));
            table.size = AAC_MAX_CHANNELS;
            fsl_osal_memcpy(&table.channel_table,aacd_channel_layouts,sizeof(aacd_channel_layouts));
            fsl_osal_memcpy(value,&table,sizeof(CHAN_TABLE));
            break;
        #endif
        default:
            ret = OMX_ErrorNotImplemented;
            break;
    }
    return ret;
}
OMX_ERRORTYPE V4lRender::RenderGetConfig(
    OMX_INDEXTYPE nParamIndex,
    OMX_PTR pStructure)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;

	switch (nParamIndex)
	{
	case OMX_IndexConfigCommonOutputCrop:
	{
		OMX_CONFIG_RECTTYPE *pRect;
		pRect = (OMX_CONFIG_RECTTYPE*)pStructure;
		CHECK_STRUCT(pRect, OMX_CONFIG_RECTTYPE, ret);
		fsl_osal_memcpy(pRect, &sRectOut, sizeof(OMX_CONFIG_RECTTYPE));
	}
	break;
	case OMX_IndexOutputMode:
	{
		OMX_CONFIG_OUTPUTMODE *pOutputMode;
		pOutputMode = (OMX_CONFIG_OUTPUTMODE*)pStructure;
		CHECK_STRUCT(pOutputMode, OMX_CONFIG_OUTPUTMODE, ret);
		sOutputMode.bSetupDone = bStreamOn;
		fsl_osal_memcpy(pOutputMode, &sOutputMode, sizeof(OMX_CONFIG_OUTPUTMODE));
	}
	break;
	case OMX_IndexConfigCaptureFrame:
	{
		OMX_CONFIG_CAPTUREFRAME *pCapture;
		pCapture = (OMX_CONFIG_CAPTUREFRAME*)pStructure;
		CHECK_STRUCT(pCapture, OMX_CONFIG_CAPTUREFRAME, ret);
		pCapture->bDone = bCaptureFrameDone;
	}
	break;
	case OMX_IndexSysSleep:
	{
		OMX_CONFIG_SYSSLEEP *pStreamOff;
		pStreamOff = (OMX_CONFIG_SYSSLEEP *)pStructure;
		CHECK_STRUCT(pStreamOff, OMX_CONFIG_SYSSLEEP, ret);
		pStreamOff->bSleep = (OMX_BOOL)!bStreamOn;
	}
	break;

	default:
		ret = OMX_ErrorUnsupportedIndex;
		break;
	}

	return ret;
}
fsl_osal_ptr dbg_realloc(fsl_osal_ptr ptr, fsl_osal_u32 size, fsl_osal_char * desc, fsl_osal_s32 line)
{
	Mem_Desc * bt = tm->head;
	fsl_osal_ptr buf = NULL;

	if(ptr == NULL)
		return dbg_malloc(size, desc, line);

	if(size == 0)
	{
		dbg_free(ptr);
		return NULL;
	}

	//find the mem descripter for ptr
	while(bt)
	{
		if (bt->mem==ptr)
			break;
		bt=bt->next;
	}

	buf = dbg_malloc(size, desc, line);
	if(buf)
	{
		fsl_osal_memcpy(buf, ptr, bt->size - (PRE_SIZE + AFT_SIZE));
		dbg_free(ptr);
	}
	else
		dbg_free(ptr); //FIXME

	return buf;
}
Beispiel #15
0
OMX_ERRORTYPE Ac3Dec::AudioFilterGetParameter(OMX_INDEXTYPE nParamIndex, OMX_PTR pComponentParameterStructure)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    switch ((int)nParamIndex) {
        case OMX_IndexParamAudioAc3:
            {
                OMX_AUDIO_PARAM_AC3TYPE *pAc3Type;
                pAc3Type = (OMX_AUDIO_PARAM_AC3TYPE*)pComponentParameterStructure;
                OMX_CHECK_STRUCT(pAc3Type, OMX_AUDIO_PARAM_AC3TYPE, ret);
                if(ret != OMX_ErrorNone)
                    break;
                if (pAc3Type->nPortIndex != AUDIO_FILTER_INPUT_PORT)
                {
                    ret = OMX_ErrorBadPortIndex;
                    break;
                }
                fsl_osal_memcpy(pAc3Type, &Ac3Type, sizeof(OMX_AUDIO_PARAM_AC3TYPE));
                break;
            }
        default:
            ret = OMX_ErrorUnsupportedIndex;
            break;
    }

    return ret;
}
OMX_ERRORTYPE AacEnc::AudioFilterSetParameter(
    OMX_INDEXTYPE nParamIndex,
    OMX_PTR pComponentParameterStructure)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;

	switch (nParamIndex)
	{
	case OMX_IndexParamAudioAac:
	{
		OMX_AUDIO_PARAM_AACPROFILETYPE *pAacType;
		pAacType = (OMX_AUDIO_PARAM_AACPROFILETYPE*)pComponentParameterStructure;
		OMX_CHECK_STRUCT(pAacType, OMX_AUDIO_PARAM_AACPROFILETYPE, ret);
		if(ret != OMX_ErrorNone)
			break;
		if (pAacType->nPortIndex != AUDIO_FILTER_OUTPUT_PORT)
		{
			ret = OMX_ErrorBadPortIndex;
			break;
		}
		fsl_osal_memcpy(&AacType, pAacType, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
	}
	return ret;
	default:
		ret = OMX_ErrorUnsupportedIndex;
		break;
	}

	return ret;
}
OMX_ERRORTYPE AudioFilter::GetParameter(
    OMX_INDEXTYPE nParamIndex,
    OMX_PTR pComponentParameterStructure)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;

	switch (nParamIndex)
	{
	case OMX_IndexParamAudioPcm:
	{
		OMX_BOOL bOutputPort = OMX_FALSE;
		OMX_AUDIO_PARAM_PCMMODETYPE *pPcmMode;
		pPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*)pComponentParameterStructure;
		OMX_CHECK_STRUCT(pPcmMode, OMX_AUDIO_PARAM_PCMMODETYPE, ret);
		if(ret != OMX_ErrorNone)
			break;
		if (pPcmMode->nPortIndex == AUDIO_FILTER_OUTPUT_PORT)
		{
			bOutputPort = OMX_TRUE;
		}

		fsl_osal_memcpy(pPcmMode, &PcmMode,	sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
	}
	LOG_DEBUG("PcmMode.nSamplingRate = %d\n", PcmMode.nSamplingRate);
	break;
	default:
		ret = AudioFilterGetParameter(nParamIndex, pComponentParameterStructure);
		break;
	}

	return ret;
}
OMX_ERRORTYPE State::DoGetComponentVersion(
        OMX_STRING pComponentName, 
        OMX_VERSIONTYPE* pComponentVersion, 
        OMX_VERSIONTYPE* pSpecVersion, 
        OMX_UUIDTYPE* pComponentUUID) 
{
    if(pComponentName == NULL || pComponentVersion == NULL
            || pSpecVersion == NULL || pComponentUUID == NULL)
        return OMX_ErrorBadParameter;

    fsl_osal_strcpy(pComponentName, (OMX_STRING)(base->name));
    fsl_osal_memcpy(pComponentVersion, &(base->ComponentVersion), sizeof(OMX_VERSIONTYPE));
    fsl_osal_memcpy(pSpecVersion, &(base->SpecVersion), sizeof(OMX_VERSIONTYPE));

    return OMX_ErrorNone;
}
OMX_ERRORTYPE IpulibRender::StartDeviceInPause()
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;

	if(bInitDev != OMX_FALSE)
		return OMX_ErrorNone;

	if(pShowFrame == NULL)
		return OMX_ErrorBadParameter;

	OMX_PTR pFrame = NULL;
	GetHwBuffer(pShowFrame, &pFrame);

	ret = IpulibInit(pFrame);
	if(ret != OMX_ErrorNone)
		return ret;

	bInitDev = OMX_TRUE;

	if(pFrame == NULL)
		fsl_osal_memcpy(ipu_handle.inbuf_start[0], pShowFrame, ipu_handle.ifr_size);

	ret = IpulibRenderFrame(pFrame);
	if(ret != OMX_ErrorNone)
		return ret;

	return OMX_ErrorNone;
}
OMX_ERRORTYPE VideoFilter::OutputFmtChanged()
{
    OMX_PARAM_PORTDEFINITIONTYPE sPortDef;

    OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
    sPortDef.nPortIndex = OUT_PORT;
    ports[OUT_PORT]->GetPortDefinition(&sPortDef);

    if(sOutFmt.eCompressionFormat != OMX_VIDEO_CodingUnused)
    {
        //encoder
        fsl_osal_memcpy(&(sPortDef.format.video), &sOutFmt, sizeof(OMX_VIDEO_PORTDEFINITIONTYPE));
        ports[OUT_PORT]->SetPortDefinition(&sPortDef);
    }
    else
    {
        //decoder
        sPortDef.nPortIndex = IN_PORT;
        ports[IN_PORT]->GetPortDefinition(&sPortDef);
        sPortDef.format.video.nFrameWidth = sInFmt.nFrameWidth;
        sPortDef.format.video.nFrameHeight = sInFmt.nFrameHeight;
        ports[IN_PORT]->SetPortDefinition(&sPortDef);
        return CheckPortResource(OUT_PORT);
    }

    return OMX_ErrorNone;
}
OMX_ERRORTYPE AudioSource::SetParameter(
        OMX_INDEXTYPE nParamIndex, 
        OMX_PTR pStructure)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    switch ((int)nParamIndex) {
        case OMX_IndexParamAudioPcm:
            {
                OMX_AUDIO_PARAM_PCMMODETYPE *pPcmMode;
                pPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*)pStructure;
                CHECK_STRUCT(pPcmMode, OMX_AUDIO_PARAM_PCMMODETYPE, ret);
				fsl_osal_memcpy(&PcmMode, pPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
				LOG_DEBUG("Audio source samplerate: %d\n", PcmMode.nSamplingRate);
				LOG_DEBUG("Audio source channels: %d\n", PcmMode.nChannels);
				LOG_DEBUG("Audio source bitspersample: %d\n", PcmMode.nBitPerSample);
			}
            break;
		case OMX_IndexParamMaxFileDuration:
			 {
				 nMaxDuration = *((OMX_TICKS*)pStructure);
			 }
			 break;
		case OMX_IndexParamAudioSource:
			{
				 nAudioSource = *((OMX_S32*)pStructure);
			}
			break;
        default:
            ret = OMX_ErrorUnsupportedIndex;
            break;
    }

    return ret;
}
Beispiel #22
0
QUEUE_ERRORTYPE Queue::Get(fsl_osal_ptr pMsg)
{
    QNODE *pQNode = NULL;

    if(bBlocking == E_FSL_OSAL_TRUE)
        fsl_osal_sem_wait(usedNodesSem);
    else {
        if(fsl_osal_sem_trywait(usedNodesSem) != E_FSL_OSAL_SUCCESS)
            return QUEUE_NOT_READY;
    }

    fsl_osal_mutex_lock(lock);

    if(pHead == NULL) {
        fsl_osal_mutex_unlock(lock);
        return QUEUE_OVERFLOW;
    }

    pQNode = pHead;
    pHead = pHead->NextNode;
    fsl_osal_memcpy(pMsg, pQNode->pMsg, nMsgSize);
    pQNode->NextNode = pFreeNodes;
    pFreeNodes = pQNode;
    nQSize --;
    if(pHead == NULL)
        pTail = NULL;

    fsl_osal_sem_post(freeNodesSem);
    fsl_osal_mutex_unlock(lock);

    return QUEUE_SUCCESS;
}
Beispiel #23
0
OMX_ERRORTYPE VideoRender::InitComponent()
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;
    OMX_PARAM_PORTDEFINITIONTYPE sPortDef;
    OMX_BUFFERSUPPLIERTYPE SupplierType;

    OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
    sPortDef.nPortIndex = IN_PORT;
    sPortDef.eDir = OMX_DirInput;
    sPortDef.eDomain = OMX_PortDomainVideo;
    fsl_osal_memcpy(&sPortDef.format.video, &sVideoFmt, sizeof(OMX_VIDEO_PORTDEFINITIONTYPE));
    sPortDef.bPopulated = OMX_FALSE;
    sPortDef.bEnabled = OMX_TRUE;
    sPortDef.nBufferCountMin = nFrameBufferMin;
    sPortDef.nBufferCountActual = nFrameBufferActual;
    sPortDef.nBufferSize = sPortDef.format.video.nFrameWidth
        * sPortDef.format.video.nFrameHeight
        * pxlfmt2bpp(sVideoFmt.eColorFormat) / 8;
    ret = ports[IN_PORT]->SetPortDefinition(&sPortDef);
    if(ret != OMX_ErrorNone) {
        LOG_ERROR("Set port definition for in port failed.\n");
        return ret;
    }

    ports[IN_PORT]->SetSupplierType(TunneledSupplierType);

    sPortDef.nPortIndex = CLK_PORT;
    sPortDef.eDir = OMX_DirInput;
    sPortDef.eDomain = OMX_PortDomainOther;
    sPortDef.format.other.eFormat = OMX_OTHER_FormatTime;
    sPortDef.bPopulated = OMX_FALSE;
    sPortDef.bEnabled = OMX_FALSE;
    sPortDef.nBufferCountMin = 1;
    sPortDef.nBufferCountActual = 1;
    sPortDef.nBufferSize = sizeof(OMX_TIME_MEDIATIMETYPE);
    ret = ports[CLK_PORT]->SetPortDefinition(&sPortDef);
    if(ret != OMX_ErrorNone) {
        LOG_ERROR("Set port definition for clk port failed.\n");
        return ret;
    }

    SupplierType = OMX_BufferSupplyOutput;
    ports[CLK_PORT]->SetSupplierType(SupplierType);

    fsl_osal_memset(&hClock, 0, sizeof(TUNNEL_INFO));
    ClockState = OMX_TIME_ClockStateStopped;
    ClockScale = Q16_SHIFT;
    pSyncFrame = NULL;
    nFrameCnt = nDropCnt = nDeviceDropCnt = nContiniousDrop = 0;
    playbackMode = NORMAL_MODE;

    InitVideoVisitors();

    ret = InitRenderComponent();
    if(ret != OMX_ErrorNone)
        return ret;

    return ret;
}
OMX_ERRORTYPE load_component(HTEST *hTest)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;
	OMX_HANDLETYPE hComponent = NULL;
	OMX_PARAM_PORTDEFINITIONTYPE sPortDef;
	OMX_U32 i;

	ret = OMX_GetHandle(&hComponent, hTest->name, hTest, &gCallBacks);
	if(ret != OMX_ErrorNone)
	{
		printf("Load component %s failed.\n", hTest->name);
		return ret;
	}

	hTest->hComponent = (OMX_COMPONENTTYPE*)hComponent;
	hTest->nPorts = get_component_ports(hComponent);
	OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
	for(i=0; i<hTest->nPorts; i++)
	{
		sPortDef.nPortIndex = i;
		OMX_GetParameter(hComponent, OMX_IndexParamPortDefinition, &sPortDef);
		if (sPortDef.eDomain == OMX_PortDomainAudio)
			hTest->nAudioTrackNum = i;
		if (sPortDef.eDomain == OMX_PortDomainVideo)
			hTest->nVideoTrackNum = i;

		hTest->PortDir[i] = sPortDef.eDir;
		if(hTest->PortDir[i] == OMX_DirInput)
			hTest->bAllocater[i] = OMX_FALSE;
		if(hTest->PortDir[i] == OMX_DirOutput)
			hTest->bAllocater[i] = OMX_TRUE;
	}
	OMX_PARAM_CONTENTURITYPE *content = NULL;

	content =(OMX_PARAM_CONTENTURITYPE *) fsl_osal_malloc_new(sizeof(OMX_PARAM_CONTENTURITYPE) + 1024);
	if (!content)
		return OMX_ErrorInsufficientResources;

	fsl_osal_memset(content, 0 , sizeof(OMX_PARAM_CONTENTURITYPE)+1024);
	OMX_INIT_STRUCT(content,OMX_PARAM_CONTENTURITYPE);
	char* uri = (char*)&(content->contentURI);
	fsl_osal_memcpy(uri, hTest->media_name, strlen(hTest->media_name)+1);

	ret = OMX_SetParameter(hTest->hComponent,OMX_IndexParamContentURI,content);
	if (ret != OMX_ErrorNone)
	{
		OMX_FreeHandle(hTest->hComponent);
		hTest->hComponent = NULL;
		return ret;
	}




	fsl_osal_thread_create(&hTest->pThreadId, NULL, process_thread, hTest);

	return OMX_ErrorNone;
}
OMX_ERRORTYPE WmaDec::AudioFilterSetParameter(
        OMX_INDEXTYPE nParamIndex, 
        OMX_PTR pComponentParameterStructure)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    switch ((int)nParamIndex) {
        case OMX_IndexParamAudioWma:
            {
                OMX_AUDIO_PARAM_WMATYPE *pWmaType;
                pWmaType = (OMX_AUDIO_PARAM_WMATYPE*)pComponentParameterStructure;
                OMX_CHECK_STRUCT(pWmaType, OMX_AUDIO_PARAM_WMATYPE, ret);
                if(ret != OMX_ErrorNone)
                    break;
				if (pWmaType->nPortIndex != AUDIO_FILTER_INPUT_PORT)
				{
					ret = OMX_ErrorBadPortIndex;
					break;
				}
				fsl_osal_memcpy(&WmaType, pWmaType, sizeof(OMX_AUDIO_PARAM_WMATYPE));
			}
			return ret;
        case OMX_IndexParamAudioWmaExt:
            {
                OMX_AUDIO_PARAM_WMATYPE_EXT *pWmaTypeExt;
                pWmaTypeExt = (OMX_AUDIO_PARAM_WMATYPE_EXT*)pComponentParameterStructure;
                OMX_CHECK_STRUCT(pWmaTypeExt, OMX_AUDIO_PARAM_WMATYPE_EXT, ret);
                if(ret != OMX_ErrorNone)
                    break;
				if (pWmaTypeExt->nPortIndex != AUDIO_FILTER_INPUT_PORT)
				{
					ret = OMX_ErrorBadPortIndex;
					break;
				}
				fsl_osal_memcpy(&WmaTypeExt, pWmaTypeExt, sizeof(OMX_AUDIO_PARAM_WMATYPE_EXT));
			}
			return ret;
		default:
			ret = OMX_ErrorUnsupportedIndex;
            break;
    }

    return ret;
}
OMX_ERRORTYPE AudioFilter::SetParameter(
    OMX_INDEXTYPE nParamIndex,
    OMX_PTR pComponentParameterStructure)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;

	switch (nParamIndex)
	{
	case OMX_IndexParamAudioPortFormat:
	{
		OMX_AUDIO_PARAM_PORTFORMATTYPE *pPortFormat;
		pPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)pComponentParameterStructure;
		OMX_CHECK_STRUCT(pPortFormat, OMX_AUDIO_PARAM_PORTFORMATTYPE, ret);
		if(ret != OMX_ErrorNone)
			break;
		if (pPortFormat->nPortIndex > AUDIO_FILTER_PORT_NUMBER - 1)
		{
			ret = OMX_ErrorBadPortIndex;
			break;
		}
		fsl_osal_memcpy(&PortFormat[pPortFormat->nPortIndex], pPortFormat, \
		                sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
	}
	break;
	case OMX_IndexParamAudioPcm:
	{
		OMX_AUDIO_PARAM_PCMMODETYPE *pPcmMode;
		pPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*)pComponentParameterStructure;
		OMX_CHECK_STRUCT(pPcmMode, OMX_AUDIO_PARAM_PCMMODETYPE, ret);
		if(ret != OMX_ErrorNone)
			break;
		fsl_osal_memcpy(&PcmMode, pPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
	}
	AudioFilterSetParameterPCM();
	break;
	default:
		ret = AudioFilterSetParameter(nParamIndex, pComponentParameterStructure);
		break;
	}

	return ret;
}
Beispiel #27
0
OMX_ERRORTYPE AC3ToIEC937::AudioFilterGetParameter(
        OMX_INDEXTYPE nParamIndex,
        OMX_PTR pStructure)
{
    if(nParamIndex == OMX_IndexParamAudioAc3)
        fsl_osal_memcpy(pStructure, &Ac3Type, sizeof(OMX_AUDIO_PARAM_AC3TYPE));
    else
        return OMX_ErrorUnsupportedIndex;

    return OMX_ErrorNone;
}
Beispiel #28
0
OMX_ERRORTYPE Ac3Dec::UniaDecoderGetParameter(UA_ParaType index,OMX_S32 * value)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;
    if(value == NULL){
        ret = OMX_ErrorBadParameter;
        return ret;
    }

    switch(index){
        case UNIA_SAMPLERATE:
            *value = Ac3Type.nSampleRate;
            break;
        case UNIA_CHANNEL:
            *value = Ac3Type.nChannels;
            break;
        case UNIA_BITRATE:
            *value = Ac3Type.nBitRate;
            break;
        case UNIA_FRAMED:
            *value = OMX_TRUE;
            break;
        #ifdef OMX_STEREO_OUTPUT
        case UNIA_DOWNMIX_STEREO:
            *value = OMX_TRUE;
            break;
        #endif
        #ifndef OMX_STEREO_OUTPUT
        case UNIA_CHAN_MAP_TABLE:
            CHAN_TABLE table;
            fsl_osal_memset(&table,0,sizeof(table));
            table.size = AC3_MAX_CHANNELS;
            fsl_osal_memcpy(&table.channel_table,ac3d_channel_layouts,sizeof(ac3d_channel_layouts));
            fsl_osal_memcpy(value,&table,sizeof(CHAN_TABLE));
            break;
        #endif
        default:
            ret = OMX_ErrorNotImplemented;
            break;
    }
    return ret;
}
OMX_ERRORTYPE VideoFilter::CheckPortResource(OMX_U32 nPortIndex)
{
    OMX_PARAM_PORTDEFINITIONTYPE sPortDef;
    OMX_VIDEO_PORTDEFINITIONTYPE *pFmt;
    OMX_U32 nBufferCnt = 0;
    OMX_BOOL bResourceChanged = OMX_FALSE;

    OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
    sPortDef.nPortIndex = nPortIndex;
    ports[nPortIndex]->GetPortDefinition(&sPortDef);

    if(nPortIndex == IN_PORT)
    {
        pFmt = &sInFmt;
        nBufferCnt = nInBufferCnt;
    }
    else
    {
        pFmt = &sOutFmt;
        nBufferCnt = nOutBufferCnt;
    }

    if(pFmt->nFrameWidth != sPortDef.format.video.nFrameWidth
            || pFmt->nFrameHeight != sPortDef.format.video.nFrameHeight
            || nBufferCnt != sPortDef.nBufferCountActual)
    {
        LOG_INFO("Filter port #%d resource changed, need reconfigure.\n", nPortIndex);
        LOG_INFO("from %dx%dx%d to %dx%dx%d.\n",
                 sPortDef.format.video.nFrameWidth,
                 sPortDef.format.video.nFrameHeight,
                 sPortDef.nBufferCountActual,
                 pFmt->nFrameWidth, pFmt->nFrameHeight, nBufferCnt);

        bResourceChanged = OMX_TRUE;
        sPortDef.nBufferSize = pFmt->nFrameWidth * pFmt->nFrameHeight * pxlfmt2bpp(pFmt->eColorFormat) / 8;
        sPortDef.nBufferCountActual = nBufferCnt;
        LOG_DEBUG("Need buffer size: %d\n", sPortDef.nBufferSize);
    }

    fsl_osal_memcpy(&(sPortDef.format.video), pFmt, sizeof(OMX_VIDEO_PORTDEFINITIONTYPE));
    ports[nPortIndex]->SetPortDefinition(&sPortDef);

    if(bResourceChanged)
    {
        SendEvent(OMX_EventPortSettingsChanged, nPortIndex, 0, NULL);
        LOG_DEBUG("Send Port setting changed event.\n");
        bInReturnBufferState = OMX_TRUE;
        return OMX_ErrorNotReady;
    }

    return OMX_ErrorNoMore;
}
OMX_ERRORTYPE AudioSource::SetConfig(
        OMX_INDEXTYPE nParamIndex,
        OMX_PTR pStructure)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    switch ((int)nParamIndex) {
        case OMX_IndexConfigAudioVolume:
            {
                OMX_AUDIO_CONFIG_VOLUMETYPE *pVolume;
                pVolume = (OMX_AUDIO_CONFIG_VOLUMETYPE*)pStructure;
                CHECK_STRUCT(pVolume, OMX_AUDIO_CONFIG_VOLUMETYPE, ret);
				fsl_osal_memcpy(&Volume, pVolume, sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE));
            }
            break;
        case OMX_IndexConfigAudioMute:
             {
                OMX_AUDIO_CONFIG_MUTETYPE *pMute;
                pMute = (OMX_AUDIO_CONFIG_MUTETYPE*)pStructure;
                CHECK_STRUCT(pMute, OMX_AUDIO_CONFIG_MUTETYPE, ret);
				fsl_osal_memcpy(&Mute, pMute, sizeof(OMX_AUDIO_CONFIG_MUTETYPE));
            }
            break;
		case OMX_IndexConfigEOS:
			 {
				 OMX_CONFIG_BOOLEANTYPE *pEOS;
				 pEOS = (OMX_CONFIG_BOOLEANTYPE*)pStructure;
				 OMX_CHECK_STRUCT(pEOS, OMX_CONFIG_BOOLEANTYPE, ret);
				 fsl_osal_memcpy(&EOS, pEOS, sizeof(OMX_CONFIG_BOOLEANTYPE));
			 }
			 break;
		default:
			 ret = OMX_ErrorUnsupportedIndex;
			 break;
    }

    return ret;
}