OMX_ERRORTYPE AacEnc::AudioFilterCodecInit() { OMX_ERRORTYPE ret = OMX_ErrorNone; VO_CODEC_INIT_USERDATA userData; fsl_osal_memset(&userData, 0, sizeof(userData)); userData.memflag = VO_IMF_USERMEMOPERATOR; userData.memData = (VO_PTR) mMemOperator; if (VO_ERR_NONE != mApiHandle->Init(&mEncoderHandle, VO_AUDIO_CodingAAC, &userData)) { LOG_ERROR("Failed to init AAC encoder"); return OMX_ErrorUndefined; } // Configure AAC encoder$ AACENC_PARAM params; fsl_osal_memset(¶ms, 0, sizeof(params)); params.sampleRate = AacType.nSampleRate; params.bitRate = AacType.nBitRate; params.nChannels = AacType.nChannels; params.adtsUsed = 0; // For MP4 file, don't use adts format$ LOG_DEBUG("Encoder Sample Rate = %d\t channels: %d\t bitRate = %d\n", \ AacType.nSampleRate, AacType.nChannels, AacType.nBitRate); if (VO_ERR_NONE != mApiHandle->SetParam(mEncoderHandle, VO_PID_AAC_ENCPARAM, ¶ms)) { LOG_ERROR("Failed to set AAC encoder parameters"); return OMX_ErrorUndefined; } return ret; }
RINGBUFFER_ERRORTYPE RingBuffer::BufferAddZeros(fsl_osal_u32 BufferLen, fsl_osal_u32 *pActualLen) { RINGBUFFER_ERRORTYPE ret = RINGBUFFER_SUCCESS; fsl_osal_u32 DataLen = AudioDataLen(); fsl_osal_u32 FreeBufferLen = nRingBufferLen - DataLen - 1; if (FreeBufferLen < BufferLen) { *pActualLen = FreeBufferLen; } else { *pActualLen = BufferLen; } if (Begin + *pActualLen > RingBufferPtr + nRingBufferLen) { fsl_osal_u32 FirstSegmentLen = nRingBufferLen - (Begin - RingBufferPtr); fsl_osal_memset(Begin, 0, FirstSegmentLen); fsl_osal_memset(RingBufferPtr, 0, *pActualLen - FirstSegmentLen); Begin = RingBufferPtr + *pActualLen - FirstSegmentLen; } else { fsl_osal_memset(Begin, 0, *pActualLen); Begin += *pActualLen; } LOG_LOG("nRingBufferLen = %d\t DataLen = %d\n", nRingBufferLen, DataLen); return ret; }
WmvDecoder::WmvDecoder() { fsl_osal_strcpy((fsl_osal_char*)name, "OMX.Freescale.std.video_decoder.wmv.sw-based"); ComponentVersion.s.nVersionMajor = 0x0; ComponentVersion.s.nVersionMinor = 0x1; ComponentVersion.s.nRevision = 0x0; ComponentVersion.s.nStep = 0x0; role_cnt = 1; role[0] = (OMX_STRING)"video_decoder.wmv"; fsl_osal_memset(&sInFmt, 0, sizeof(OMX_VIDEO_PORTDEFINITIONTYPE)); sInFmt.nFrameWidth = 320; sInFmt.nFrameHeight = 240; sInFmt.xFramerate = 30 * Q16_SHIFT; sInFmt.eColorFormat = OMX_COLOR_FormatUnused; sInFmt.eCompressionFormat = OMX_VIDEO_CodingWMV; nInPortFormatCnt = 0; nOutPortFormatCnt = 1; eOutPortPormat[0] = OMX_COLOR_FormatYUV420Planar; sOutFmt.nFrameWidth = 320; sOutFmt.nFrameHeight = 240; sOutFmt.eColorFormat = OMX_COLOR_FormatYUV420Planar; sOutFmt.eCompressionFormat = OMX_VIDEO_CodingUnused; bFilterSupportPartilInput = OMX_FALSE; nInBufferCnt = 1; nInBufferSize = 128*1024; nOutBufferCnt = 1; nOutBufferSize = sOutFmt.nFrameWidth * sOutFmt.nFrameHeight * pxlfmt2bpp(sOutFmt.eColorFormat) / 8; pInBuffer = pOutBuffer = NULL; nInputSize = nInputOffset = 0; bInEos = OMX_FALSE; nFrameSize = 0;; pFrameBuffer = NULL; OMX_INIT_STRUCT(&sOutCrop, OMX_CONFIG_RECTTYPE); sOutCrop.nPortIndex = OUT_PORT; sOutCrop.nLeft = sOutCrop.nTop = 0; sOutCrop.nWidth = sInFmt.nFrameWidth; sOutCrop.nHeight = sInFmt.nFrameHeight; fsl_osal_memset(&sDecObj, 0, sizeof(sWmv9DecObjectType)); eFormat = E_WMV9D_COMP_FMT_UNSUPPORTED; eWmvDecState = WMVDEC_LOADED; hLib = NULL; libMgr = NULL; nTop = nLeft = 0; }
void GMInbandSubtitleSource::Convert3GPPToText( SUBTITLE_SAMPLE &sample) { sample.fmt = TEXT; if(sample.nFilledLen >= BUFFER_SIZE_3GP) { sample.nFilledLen = BUFFER_SIZE_3GP - 1; LOG_ERROR("buffer size is not enough, need: %d, now: %d\n", BUFFER_SIZE_3GP, sample.nFilledLen); } fsl_osal_memset(pBuffer, 0, sample.nFilledLen + 1); OMX_S32 i, j = 0; for(OMX_S32 i=0; i<sample.nFilledLen; i++) { if(sample.pBuffer[i] != 0) { pBuffer[j] = sample.pBuffer[i]; j++; } } sample.nFilledLen = j; if(j > 0) sample.pBuffer = pBuffer; else sample.pBuffer = NULL; return; }
OMX_ERRORTYPE GMInbandSubtitleSource::SetType(OMX_STRING type) { SUBTITLE_TYPE mType1; OMX_S32 nLen = 0; LOG_DEBUG("GMInbandSubtitleSource set type: %s\n", type); mType1 = GetSubtitleType(type); switch(mType1) { case TYPE_3GPP: nLen = BUFFER_SIZE_3GP; case TYPE_SRT: nLen = BUFFER_SIZE_SRT; default: break; } if(mType1 == TYPE_UNKNOWN) return OMX_ErrorNotImplemented; if(mType != mType1) { if(pBuffer) FSL_FREE(pBuffer); pBuffer = (OMX_U8*)FSL_MALLOC(nLen); if(pBuffer == NULL) return OMX_ErrorInsufficientResources; mType = mType1; } fsl_osal_memset(pBuffer, 0, nLen); return OMX_ErrorNone; }
OMX_ERRORTYPE UniaDecoder::SetParameterToDecoder() { OMX_S32 value; for ( OMX_U32 i = UNIA_SAMPLERATE; i < UNIA_STREAM_TYPE; i++){ if(i == UNIA_CODEC_DATA) continue; value = 0; if(OMX_ErrorNone == UniaDecoderGetParameter((UA_ParaType)i,&value)){ IDecoder->SetParameter(uniaHandle,(UA_ParaType)i,(UniACodecParameter*)&value); } } //set output format for channel layout fsl_osal_memset(&channelTable,0,sizeof(CHAN_TABLE)); if(OMX_ErrorNone == UniaDecoderGetParameter(UNIA_CHAN_MAP_TABLE,(OMX_S32*)&channelTable)){ IDecoder->SetParameter(uniaHandle,UNIA_CHAN_MAP_TABLE,(UniACodecParameter*)&channelTable); } value = 0; if(OMX_ErrorNone == UniaDecoderGetParameter(UNIA_WMA_BlOCKALIGN,&value)){ IDecoder->SetParameter(uniaHandle,UNIA_WMA_BlOCKALIGN,(UniACodecParameter*)&value); } value = 0; if(OMX_ErrorNone == UniaDecoderGetParameter(UNIA_WMA_VERSION,&value)){ IDecoder->SetParameter(uniaHandle,UNIA_WMA_VERSION,(UniACodecParameter*)&value); } LOG_DEBUG("SetParameterToDecoder"); return OMX_ErrorNone; }
PMEMADDR GetPMBuffer(OMX_PTR Context, OMX_U32 nSize, OMX_U32 nNum) { PMCONTEXT *pContext = (PMCONTEXT*)Context; PMEMADDR sMemAddr; fsl_osal_memset(&sMemAddr, 0, sizeof(PMEMADDR)); if(pContext == NULL) return sMemAddr; if(pContext->fd == 0) if(OMX_ErrorNone != InitPMemAllocator(pContext, nSize, nNum)) return sMemAddr; OMX_S32 i; for(i=0; i<(OMX_S32)pContext->nBufferNum; i++) if(pContext->bSlotAllocated[i] != OMX_TRUE) break; if(i == (OMX_S32)pContext->nBufferNum) { LOG_ERROR("No freed P memory for allocate.\n"); return sMemAddr; } pContext->bSlotAllocated[i] = OMX_TRUE; LOG_DEBUG("PM allocate: %p\n", pContext->BufferSlot[i]); return pContext->BufferSlot[i]; }
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 VideoProcessorComponent::omxSetHeader(OMX_PTR pHeader, OMX_S32 nHeaderSize) { fsl_osal_memset(pHeader,0,nHeaderSize); OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_U8 *)pHeader + sizeof(OMX_U32)); *((OMX_U32*)pHeader) = nHeaderSize; pVersion->nVersion = ComponentVersion.nVersion; return OMX_ErrorNone; }
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; }
fsl_osal_void deinit_memmanager() { printandfree_allnonfreememory(tm); if (tm->allocatedbuffer) { fsl_osal_dealloc(tm->allocatedbuffer); } fsl_osal_memset(tm, 0, sizeof(Mem_Mgr)); }
VideoProcessorComponent::VideoProcessorComponent() { fsl_osal_strcpy((fsl_osal_char*)name, VP_NAME); ComponentVersion.s.nVersionMajor = 0x1; ComponentVersion.s.nVersionMinor = 0x1; ComponentVersion.s.nRevision = 0x2; ComponentVersion.s.nStep = 0x0; bInContext = OMX_FALSE; nPorts = 2; bStarted = OMX_FALSE; bReset = OMX_FALSE; bFlush = OMX_FALSE; bUseEGLImage = OMX_FALSE; fsl_osal_memset(&ipu_handle,0,sizeof(ipu_lib_handle_t)); fsl_osal_memset(&sInParam,0,sizeof(ipu_lib_input_param_t)); fsl_osal_memset(&sOutParam,0,sizeof(ipu_lib_output_param_t)); }
OMX_ERRORTYPE WbAmrEncWrapper::InstanceInit() { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_S32 i; pAmrEncConfig = (WBAMRE_Encoder_Config *)FSL_MALLOC(sizeof(WBAMRE_Encoder_Config)); if (pAmrEncConfig == NULL) { LOG_ERROR("Can't get memory.\n"); return OMX_ErrorInsufficientResources; } fsl_osal_memset(pAmrEncConfig, 0, sizeof(WBAMRE_Encoder_Config)); pAmrEncConfig->wbappe_initialized_data_start = NULL; WBAMRE_RET_TYPE AmrRet; AmrRet = wbamre_query_enc_mem(pAmrEncConfig); if (AmrRet != WBAMRE_OK) { LOG_ERROR("Amr encoder query memory fail.\n"); return OMX_ErrorUndefined; } OMX_S32 MemoryCnt = pAmrEncConfig->wbamre_mem_info.wbamre_num_reqs; for (i = 0; i < MemoryCnt; i ++) { OMX_U32 BufferSize; OMX_U8 *pBuffer; BufferSize = pAmrEncConfig->wbamre_mem_info.mem_info_sub[i].wbamre_size; pBuffer = (OMX_U8 *)FSL_MALLOC(BufferSize); if (pBuffer == NULL) { LOG_ERROR("Can't get memory.\n"); return OMX_ErrorInsufficientResources; } fsl_osal_memset(pBuffer, 0, BufferSize); pAmrEncConfig->wbamre_mem_info.mem_info_sub[i].wbappe_base_ptr = pBuffer; } return ret; }
IpulibRender::IpulibRender() { OMX_U32 i; fsl_osal_strcpy((fsl_osal_char*)name, "OMX.Freescale.std.video_render.ipulib.sw-based"); ComponentVersion.s.nVersionMajor = 0x0; ComponentVersion.s.nVersionMinor = 0x1; ComponentVersion.s.nRevision = 0x0; ComponentVersion.s.nStep = 0x0; role_cnt = 1; role[0] = (OMX_STRING)"video_render.ipulib"; nFrameBufferMin = 2; nFrameBufferActual = 2; TunneledSupplierType = OMX_BufferSupplyInput; fsl_osal_memset(&sVideoFmt, 0, sizeof(OMX_VIDEO_PORTDEFINITIONTYPE)); sVideoFmt.nFrameWidth = 320; sVideoFmt.nFrameHeight = 240; sVideoFmt.eColorFormat = OMX_COLOR_FormatYUV420Planar; sVideoFmt.eCompressionFormat = OMX_VIDEO_CodingUnused; eRotation = ROTATE_NONE; OMX_INIT_STRUCT(&sRectIn, OMX_CONFIG_RECTTYPE); sRectIn.nWidth = sVideoFmt.nFrameWidth; sRectIn.nHeight = sVideoFmt.nFrameHeight; sRectIn.nTop = 0; sRectIn.nLeft = 0; OMX_INIT_STRUCT(&sRectOut, OMX_CONFIG_RECTTYPE); sRectOut.nWidth = DISP_WIDTH; sRectOut.nHeight = DISP_HEIGHT; sRectOut.nTop = 0; sRectOut.nLeft = 0; bInitDev = OMX_FALSE; lock = NULL; pShowFrame = NULL; nFrameLen = 0; bSuspend = OMX_FALSE; fsl_osal_memset(&ipu_handle, 0, sizeof(ipu_lib_handle_t)); OMX_INIT_STRUCT(&sCapture, OMX_CONFIG_CAPTUREFRAME); sCapture.eType = CAP_NONE; }
OMX_ERRORTYPE UniaDecoder::MapOutputLayoutChannel(UniAcodecOutputPCMFormat * outputValue) { OMX_U32 nChannels = outputValue->channels; OMX_U32 i = 0; if(nChannels == 0 || nChannels > OMX_AUDIO_MAXCHANNELS){ return OMX_ErrorBadParameter; } fsl_osal_memset(&PcmMode.eChannelMapping[0],0 ,OMX_AUDIO_MAXCHANNELS*sizeof(OMX_AUDIO_CHANNELTYPE)); for( i = 0; i < nChannels; i++){ switch(outputValue->layout[i]){ case UA_CHANNEL_FRONT_LEFT: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelLF; break; case UA_CHANNEL_FRONT_RIGHT: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelRF; break; case UA_CHANNEL_REAR_CENTER: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelCS; break; case UA_CHANNEL_REAR_LEFT: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelLR; break; case UA_CHANNEL_REAR_RIGHT: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelRR; break; case UA_CHANNEL_LFE: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelLFE; break; case UA_CHANNEL_FRONT_CENTER: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelCF; break; case UA_CHANNEL_FRONT_LEFT_CENTER: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelLF; break; case UA_CHANNEL_FRONT_RIGHT_CENTER: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelRF; break; case UA_CHANNEL_SIDE_LEFT: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelLS; break; case UA_CHANNEL_SIDE_RIGHT: PcmMode.eChannelMapping[i] = OMX_AUDIO_ChannelRS; break; default: break; } } return OMX_ErrorNone; }
HTEST * create_test( OMX_STRING component, OMX_STRING in_file, OMX_STRING out_file, FORMAT fmt) { HTEST *hTest = NULL; hTest = (HTEST*)FSL_MALLOC(sizeof(HTEST)); if(hTest == NULL) { printf("Failed to allocate memory for test handle.\n"); return 0; } fsl_osal_memset(hTest, 0, sizeof(HTEST)); hTest->name = component; hTest->pMsgQ = FSL_NEW(Queue, ()); if(hTest->pMsgQ == NULL) { printf("Create message queue failed.\n"); return 0; } hTest->pMsgQ->Create(128, sizeof(MSG), E_FSL_OSAL_TRUE); hTest->pInFile = fopen(in_file, "rb"); if(hTest->pInFile == NULL) { printf("Failed to open file: %s\n", in_file); return 0; } hTest->pOutFile = fopen(out_file, "wb"); if(hTest->pOutFile == NULL) { printf("Failed to open file: %s\n", out_file); return 0; } hTest->fmt = fmt; if(fmt == MPEG4) { hTest->role = "video_decoder.mpeg4"; hTest->get_video_frame_len = get_mpeg4_frame_length; } if(fmt == H264) { hTest->role = "video_decoder.avc"; hTest->get_video_frame_len = get_h264_frame_length; } return hTest; }
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; }
HTEST * create_test( OMX_STRING component, OMX_STRING in_file, OMX_S32 width, OMX_S32 height, OMX_STRING out_file, FORMAT fmt, OMX_S32 bitrate) { HTEST *hTest = NULL; hTest = (HTEST*)FSL_MALLOC(sizeof(HTEST)); if(hTest == NULL) { printf("Failed to allocate memory for test handle.\n"); return 0; } fsl_osal_memset(hTest, 0, sizeof(HTEST)); hTest->name = component; hTest->pMsgQ = FSL_NEW(Queue, ()); if(hTest->pMsgQ == NULL) { printf("Create message queue failed.\n"); return 0; } hTest->pMsgQ->Create(128, sizeof(MSG), E_FSL_OSAL_TRUE); hTest->pInFile = fopen(in_file, "rb"); if(hTest->pInFile == NULL) { printf("Failed to open file: %s\n", in_file); return 0; } hTest->pOutFile = fopen(out_file, "wb"); if(hTest->pOutFile == NULL) { printf("Failed to open file: %s\n", out_file); return 0; } hTest->width = width; hTest->height = height; hTest->bitrate = bitrate; hTest->fmt = fmt; if(fmt == H263) { hTest->role = "video_encoder.h263"; } if(fmt == H264) { hTest->role = "video_encoder.avc"; } return hTest; }
static void RegistSignalHandler() { struct sigaction act; act.sa_handler = segfault_signal_handler; sigemptyset(&act.sa_mask); act.sa_flags = 0; fsl_osal_memset(&default_act, 0, sizeof(struct sigaction)); sigaction(SIGSEGV, &act, &default_act); return; }
OMX_ERRORTYPE AacDec::AudioFilterHandleEOS() { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_U32 padding = 0; // pad the end of the stream with one buffer of which the value are all 2(avoid gap/overlap), // since that the actual last buffer isn't sent by aac decoder. padding = AACD_FRAME_SIZE * AacType.nChannels * sizeof(OMX_S16); fsl_osal_memset(pOutBufferHdr->pBuffer + pOutBufferHdr->nOffset + pOutBufferHdr->nFilledLen, 2, padding); pOutBufferHdr->nFilledLen += padding; return ret; }
OMX_PTR CreatePMeoryContext() { OMX_PTR Context = NULL; Context = (OMX_PTR)FSL_MALLOC(sizeof(PMCONTEXT)); if(Context == NULL) { LOG_ERROR("Failed allocate PMemory context.\n"); return NULL; } fsl_osal_memset(Context, 0, sizeof(PMCONTEXT)); return Context; }
//add this function to check whether input data is raw data. OMX_ERRORTYPE AacDec::AudioFilterCheckFrameHeader() { OMX_U8 *pBuffer; OMX_U32 nActuralLen = 0; OMX_U32 nVal = 0; AUDIO_FRAME_INFO FrameInfo; fsl_osal_memset(&FrameInfo, 0, sizeof(AUDIO_FRAME_INFO)); LOG_DEBUG("AacDec AudioFilterCheckFrameHeader"); if(bFrameCheck){ return OMX_ErrorNone; } do{ AudioRingBuffer.BufferGet(&pBuffer, AAC_PUSH_MODE_LEN, &nActuralLen); LOG_LOG("Get stream length: %d\n", nActuralLen); if (nActuralLen < AAC_PUSH_MODE_LEN && ePlayMode == DEC_FILE_MODE) break; nVal = *pBuffer<<24|*(pBuffer+1)<<16|*(pBuffer+2)<<8|*(pBuffer+3); if(nVal == ADIF_FILE){ LOG_DEBUG("ADIF_FILE"); frameInput = OMX_FALSE; bFrameCheck = OMX_TRUE; AacType.eAACStreamFormat = OMX_AUDIO_AACStreamFormatADIF; break; } if(AFP_SUCCESS != AacCheckFrame(&FrameInfo, pBuffer, nActuralLen)){ LOG_DEBUG("CHECK FAILED"); break; } if(FrameInfo.bGotOneFrame){ LOG_DEBUG("ADTS_FILE"); AacType.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP2ADTS; frameInput = OMX_FALSE; bFrameCheck = OMX_TRUE; break; } AacType.eAACStreamFormat = OMX_AUDIO_AACStreamFormatRAW; frameInput = OMX_TRUE; bFrameCheck = OMX_TRUE; LOG_DEBUG("FrameInfo.nHeaderCount"); }while(0); return OMX_ErrorNone; }
QUEUE_ERRORTYPE Queue::Get(fsl_osal_ptr pMsg, fsl_osal_u32 nIndex) { QNODE *pQNode, *pQNodePrev = NULL; fsl_osal_u32 i; if(nIndex > nQSize) { fsl_osal_memset(pMsg, 0, nMsgSize); return QUEUE_FAILURE; } if(nIndex == 1) return Get(pMsg); 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; } pQNodePrev = pHead; pQNode = pQNodePrev->NextNode; for(i=2; i<nIndex; i++){ pQNodePrev = pQNodePrev->NextNode; pQNode = pQNode->NextNode; } fsl_osal_memcpy(pMsg, pQNode->pMsg, nMsgSize); pQNodePrev->NextNode = pQNode->NextNode; pQNode->NextNode = pFreeNodes; pFreeNodes = pQNode; nQSize --; if(pTail == pQNode) pTail = pQNodePrev; fsl_osal_sem_post(freeNodesSem); fsl_osal_mutex_unlock(lock); return QUEUE_SUCCESS; }
OMX_ERRORTYPE VideoFilter::ReturnInputBuffer() { if(PartialInputHdr.pBuffer != NULL) { FreeInputBuffer(PartialInputHdr.pBuffer); fsl_osal_memset(&PartialInputHdr, 0, sizeof(OMX_BUFFERHEADERTYPE)); pInBufferHdr = NULL; } else if(pInBufferHdr != NULL) { ports[IN_PORT]->SendBuffer(pInBufferHdr); pInBufferHdr = NULL; } return OMX_ErrorNone; }
fsl_osal_void init_memmanager(fsl_osal_char * shortname) { fsl_osal_memset(tm, 0, sizeof(Mem_Mgr)); if (shortname) { tm->shortname = shortname; } else { tm->shortname = DEFAULT_SHORT_NAME_OF_MM; } tm->allocatednum = 5000; }
OMX_ERRORTYPE IpulibRender::CloseDevice() { if(bInitDev != OMX_TRUE) return OMX_ErrorNone; UnRegistSignalHandler(); mxc_ipu_lib_task_uninit(&ipu_handle); bInitDev = OMX_FALSE; fsl_osal_memset(&ipu_handle, 0, sizeof(ipu_lib_handle_t)); return OMX_ErrorNone; }
static OMX_ERRORTYPE DeInitPMemAllocator(PMCONTEXT *Context) { if(Context == NULL) return OMX_ErrorBadParameter; if(Context->fd) { munmap(Context->VAddrBase, Context->nSize); close(Context->fd); } fsl_osal_memset(Context, 0, sizeof(PMCONTEXT)); return OMX_ErrorNone; }
OMX_ERRORTYPE GMSubtitlePlayer::Reset() { LOG_DEBUG("GMSubtitlePlayer::Reset\n"); bReset = OMX_TRUE; while(fsl_osal_sem_trywait(pSem) == E_FSL_OSAL_SUCCESS); fsl_osal_cond_broadcast(Cond); mSample.pBuffer = NULL; RenderOneSample(); fsl_osal_memset(&delayedSample, 0, sizeof(delayedSample)); delayedSample.nFilledLen = -1; return OMX_ErrorNone; }
OMX_ERRORTYPE WmaDec::AudioFilterInstanceInit() { OMX_ERRORTYPE ret = OMX_ErrorNone; pWmaDecConfig = (WMADDecoderConfig *)FSL_MALLOC(sizeof(WMADDecoderConfig)); if (pWmaDecConfig == NULL) { LOG_ERROR("Can't get memory.\n"); return OMX_ErrorInsufficientResources; } fsl_osal_memset(pWmaDecConfig, 0, sizeof(WMADDecoderConfig)); pWmaDecParams = (WMADDecoderParams *)FSL_MALLOC(sizeof(WMADDecoderParams)); if (pWmaDecParams == NULL) { LOG_ERROR("Can't get memory.\n"); return OMX_ErrorInsufficientResources; } fsl_osal_memset(pWmaDecParams, 0, sizeof(WMADDecoderParams)); if (nPushModeInputLen < WmaType.nBlockAlign * 2) nPushModeInputLen = WmaType.nBlockAlign * 2; return ret; }
OMX_ERRORTYPE VideoProcessorComponent::InitComponent() { OMX_ERRORTYPE eRetVal = OMX_ErrorNone; OMX_PARAM_PORTDEFINITIONTYPE sPortDef; /** * Initialising inport information * video raw data in YUV420 format */ VP_DEBUG(" Begin InitComponent\n"); fsl_osal_memset(&sPortDef, 0, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); sPortDef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); sPortDef.nVersion.nVersion = VP_COMP_VERSION; sPortDef.nPortIndex = VP_IN_PORT; sPortDef.eDir = OMX_DirInput; sPortDef.nBufferCountActual = 1; sPortDef.nBufferCountMin = 1; sPortDef.nBufferSize = 0; sPortDef.eDomain = OMX_PortDomainVideo; sPortDef.bEnabled = OMX_TRUE; sPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; sPortDef.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar; eRetVal = ports[VP_IN_PORT]->SetPortDefinition(&sPortDef); if(eRetVal != OMX_ErrorNone) return eRetVal; /** * Initialising outport information * video raw data in RGB565 format */ sPortDef.nPortIndex = VP_OUT_PORT; sPortDef.eDir = OMX_DirOutput; sPortDef.format.video.eColorFormat = OMX_COLOR_Format16bitRGB565; sPortDef.format.video.nFrameWidth = 1024; sPortDef.format.video.nFrameHeight = 768; eRetVal = ports[VP_OUT_PORT]->SetPortDefinition(&sPortDef); if(eRetVal != OMX_ErrorNone) return eRetVal; pInBufHdr[0]=pInBufHdr[1]= NULL; pOutBufHdr[0]=pOutBufHdr[1]= NULL; VP_DEBUG(" Exit InitComponent\n"); return eRetVal; }