📄 dcc_video.c
字号:
evt.ModuleID = EMHWLIB_MODULE(DisplayBlock, 0); evt.Mask = EMHWLIB_DISPLAY_EVENT_ID(pVideoSource->scaler_moduleID); /* Safely wait for the stop/flush to be processed. The event occurs every VSYNC. We may wait one extra VSYNC for safety. */ RUAResetEvent(pVideoSource->pRUA, &evt); err = RUAWaitForMultipleEvents(pVideoSource->pRUA, &evt, 1, WAIT_COMMAND_TIMEOUT_US, NULL); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "wait for display update event completion failed, %s\n", RMstatusToString(err))); } } return RM_OK;}RMstatus DCCPauseVideoSource(struct DCCVideoSource *pVideoSource){ ASSERT_NULL_POINTER(pVideoSource); return RM_OK;}RMstatus DCCEnableVideoSource(struct DCCVideoSource *pVideoSource, RMbool enable){ RMuint32 src_index, mixer, scaler; RMstatus err; enum EMhwlibMixerSourceState state; ASSERT_NULL_POINTER(pVideoSource); mixer = pVideoSource->mixer_moduleID; if (mixer == 0) { RMDBGLOG((ENABLE, "Error No route attached to this source\n")); return RM_ERROR; } scaler = pVideoSource->scaler_moduleID; if (scaler == 0) { RMDBGLOG((ENABLE, "Error No surface attached to this source\n")); return RM_ERROR; } err = RUAExchangeProperty(pVideoSource->pRUA, mixer, RMGenericPropertyID_MixerSourceIndex, &scaler, sizeof(scaler), &src_index, sizeof(src_index)); if (err != RM_OK) { RMDBGLOG((ENABLE, "Cannot get scaler index, %s\n", RMstatusToString(err))); return err; } mixer = EMHWLIB_TARGET_MODULE(EMHWLIB_MODULE_CATEGORY(mixer), 0 , src_index); if(enable) state = EMhwlibMixerSourceState_Master; else state = EMhwlibMixerSourceState_Disable; DCCSP(pVideoSource->pRUA, mixer, RMGenericPropertyID_MixerSourceState, &state, sizeof(state)); DCCSP(pVideoSource->pRUA, mixer, RMGenericPropertyID_Validate, NULL, 0); return RM_OK;}RMstatus DCCXGetBtsFIFO(struct DCCVideoSource *pVideoSource, RMuint32 *BtsFIFO){ RMstatus err; ASSERT_NULL_POINTER(pVideoSource); ASSERT_NULL_POINTER(BtsFIFO); err = RUAGetProperty(pVideoSource->pRUA, pVideoSource->decoder_moduleID , RMVideoDecoderPropertyID_BtsFIFO, BtsFIFO, sizeof(RMuint32)); return err;}#ifdef DCC_WITH_RESOURCESRMstatus DCCVideoGetModuleIDsFromIndexes(struct DCC *pDCC, RMuint32 engine_index, RMuint32 decoder_index, RMuint32 *pEngineModuleID, RMuint32 *pDecoderModuleID){ RMuint32 nb_mpeg_engines, nb_video_decoders; RMuint32 temp; RMstatus status; ASSERT_NULL_POINTER(pDCC); // Get number of video engines and video decoders temp = MpegEngine; status = RUAExchangeProperty(pDCC->pRUA, Enumerator, RMEnumeratorPropertyID_CategoryIDToNumberOfInstances, &temp, sizeof(temp), &nb_mpeg_engines, sizeof(nb_mpeg_engines)); if (status != RM_OK) { RMDBGLOG((ENABLE, "Can't exchange property RMEnumeratorPropertyID_CategoryIDToNumberOfInstances %s\n", RMstatusToString(status))); return status; } else { if (engine_index < nb_mpeg_engines) RMDBGLOG((LOCALDBG, "Number of video engines: %lu\n", nb_mpeg_engines)); else { RMDBGLOG((ENABLE, "video engine index out of range! (%lu < %lu)\n", engine_index, nb_mpeg_engines)); return RM_PARAMETER_OUT_OF_RANGE; } } temp = VideoDecoder; status = RUAExchangeProperty(pDCC->pRUA, Enumerator, RMEnumeratorPropertyID_CategoryIDToNumberOfInstances, &temp, sizeof(temp), &nb_video_decoders, sizeof(nb_video_decoders)); if (status != RM_OK) { RMDBGLOG((ENABLE, "Can't exchange property RMEnumeratorPropertyID_CategoryIDToNumberOfInstances %s\n", RMstatusToString(status))); return status; } else { if (decoder_index < (nb_video_decoders / nb_mpeg_engines)) RMDBGLOG((LOCALDBG, "Number of video decoders: %lu\n", nb_video_decoders)); else { RMDBGLOG((ENABLE, "Video decoder index out of range! (%lu < %lu)\n", decoder_index, (nb_video_decoders / nb_mpeg_engines))); return RM_PARAMETER_OUT_OF_RANGE; } } if (pEngineModuleID) { *pEngineModuleID = EMHWLIB_MODULE(MpegEngine, engine_index); RMDBGLOG((LOCALDBG, "MPEGEngine: 0x%lx\n", *pEngineModuleID)); } if (pDecoderModuleID) { // !!Hack!! We assume there are an equal amount of decoders per engine; (nb_video_decoders / nb_mpeg_engines) // gives the number of decoders per engine. *pDecoderModuleID = EMHWLIB_MODULE(VideoDecoder, engine_index * (nb_video_decoders / nb_mpeg_engines) + decoder_index); RMDBGLOG((LOCALDBG, "VideoDecoder: 0x%lx\n", *pDecoderModuleID)); } return RM_OK;}RMstatus DCCGetVideoResourcesRequired(struct DCC *pDCC, struct DCCXVideoProfile *pDCCVideoProfile, struct DCCVideoResources *pVideoResources){ struct VideoDecoder_DecoderDataMemory_in_type memory_in; struct VideoDecoder_DecoderDataMemory_out_type memory_out; /* Decoder share memory is required for specific codecs as VC1 etc. The size of this memory depends on codec, profile, level, width, height. */ struct MpegEngine_DecoderSharedMemory_type shared; /* Scheduler memory is required for video RISC in order to run one or multiple video, spu tasks. The size of this memory is fixed at compile time. */ struct MpegEngine_SchedulerSharedMemory_type schedmem; struct VideoDecoder_DRAMSizeX_in_type dram_in; struct VideoDecoder_DRAMSizeX_out_type dram_out; RMuint32 engine_module_id; RMuint32 decoder_module_id; RMstatus status; RMDBGLOG((LOCALDBG, "DCCGetVideoResourcesRequired()\n")); ASSERT_NULL_POINTER(pDCC); ASSERT_NULL_POINTER(pDCCVideoProfile); ASSERT_NULL_POINTER(pVideoResources); RMMemset((void*)(pVideoResources), 0, sizeof(struct DCCVideoResources)); status = DCCVideoGetModuleIDsFromIndexes(pDCC, pDCCVideoProfile->MpegEngineID, pDCCVideoProfile->VideoDecoderID, &engine_module_id, &decoder_module_id); if (status != RM_OK) { RMDBGLOG((ENABLE, "Couldn't get module IDs (%s)\n", RMstatusToString(status))); return status; } /* check if scheduler task database table is already initialized. */ status = RUAGetProperty(pDCC->pRUA, engine_module_id, RMMpegEnginePropertyID_SchedulerSharedMemory, &schedmem, sizeof(schedmem)); if (status != RM_OK) { RMDBGLOG((ENABLE, "Cannot get SchedulerSharedMemory, %s\n", RMstatusToString(status))); return status; } if (schedmem.Address) { RMDBGLOG((ENABLE, "%lx_DRAM SCHEDULER MEMORY is already set addr=0x%lx size=0x%lx!\n", pDCCVideoProfile->MpegEngineID, schedmem.Address, schedmem.Size)); pVideoResources->SchedulerSharedMemorySize = 0; // if 0, then it has already been allocated and doesn't need to be allocated again } else { // HACK! // HACK! // HACK! // shouldn't we be using an exchange property???? to get the scheduler shared memory size, not a get like in this case. pVideoResources->SchedulerSharedMemorySize = schedmem.Size; } /* find the memory requirements for the specified codec, profile, level, width, height and extra pictures */ memory_in.Codec = pDCCVideoProfile->Codec; memory_in.Profile = pDCCVideoProfile->Profile; memory_in.Level = pDCCVideoProfile->Level; memory_in.ExtraPictureBufferCount = pDCCVideoProfile->ExtraPictureBufferCount; memory_in.MaxWidth = pDCCVideoProfile->MaxWidth; memory_in.MaxHeight = pDCCVideoProfile->MaxHeight; status = RUAExchangeProperty(pDCC->pRUA, decoder_module_id, RMVideoDecoderPropertyID_DecoderDataMemory, &memory_in, sizeof(memory_in), &memory_out, sizeof(memory_out)); if (status != RM_OK) { RMDBGLOG((ENABLE, "Error getting property RMVideoDecoderPropertyID_DecoderDataMemory! %s\n", RMstatusToString(status))); return status; } /* check if video shared memory is already set in mpeg engine */ status = RUAGetProperty(pDCC->pRUA, engine_module_id, RMMpegEnginePropertyID_DecoderSharedMemory, &shared, sizeof(shared)); if (status != RM_OK) { RMDBGLOG((ENABLE, "Cannot get DecoderSharedMemory, %s\n", RMstatusToString(status))); return status; } if (shared.Address) { if (shared.Size < memory_out.DecoderSharedSize) { status = RM_ERROR; RMDBGLOG((ENABLE, "ERROR: video shared memory is already set with a smaller value than needed by DCCOpen %s\n", RMstatusToString(status))); return status; } else RMDBGLOG((ENABLE, "%lx_DRAM VIDEO SHARED MEMORY is already set addr=0x%lx size=0x%lx\n", pDCCVideoProfile->MpegEngineID, shared.Address, shared.Size)); } else pVideoResources->DecoderSharedMemorySize = memory_out.DecoderSharedSize; /* find the required protected, unprotected memory */ dram_in.ProtectedFlags = pDCCVideoProfile->ProtectedFlags; dram_in.BitstreamFIFOSize = pDCCVideoProfile->BitstreamFIFOSize; dram_in.UserDataSize = 0x1000; //TODO - it should be exposed to dcc ??? dram_in.DecoderDataSize = memory_out.DecoderDataSize; dram_in.XferFIFOCount = pDCCVideoProfile->XferFIFOCount; dram_in.PtsFIFOCount = pDCCVideoProfile->PtsFIFOCount; dram_in.InbandFIFOCount = pDCCVideoProfile->InbandFIFOCount; dram_in.XtaskInbandFIFOCount = pDCCVideoProfile->XtaskInbandFIFOCount; status = RUAExchangeProperty(pDCC->pRUA, decoder_module_id, RMVideoDecoderPropertyID_DRAMSizeX, &dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out)); if (status != RM_OK) { RMDBGLOG((ENABLE, "Error getting property RMVideoDecoderPropertyID_DRAMSize! %s\n", RMstatusToString(status))); return status; } pVideoResources->PictureProtectedMemorySize = dram_out.PictureProtectedSize; pVideoResources->BitstreamProtectedMemorySize = dram_out.BitstreamProtectedSize; pVideoResources->UnprotectedMemorySize = dram_out.UnprotectedSize; RMDBGLOG((LOCALDBG, "SchedulerSharedMemoryAddress 0x%lx\n", pVideoResources->SchedulerSharedMemoryAddress)); RMDBGLOG((LOCALDBG, "SchedulerSharedMemorySize %lu\n", pVideoResources->SchedulerSharedMemorySize)); RMDBGLOG((LOCALDBG, "DecoderSharedMemoryAddress 0x%lx\n", pVideoResources->DecoderSharedMemoryAddress)); RMDBGLOG((LOCALDBG, "DecoderSharedMemorySize %lu\n", pVideoResources->DecoderSharedMemorySize)); RMDBGLOG((LOCALDBG, "PictureProtectedMemoryAddress 0x%lx\n", pVideoResources->PictureProtectedMemoryAddress)); RMDBGLOG((LOCALDBG, "PictureProtectedMemorySize %lu\n", pVideoResources->PictureProtectedMemorySize)); RMDBGLOG((LOCALDBG, "BitstreamProtectedMemoryAddress 0x%lx\n", pVideoResources->BitstreamProtectedMemoryAddress)); RMDBGLOG((LOCALDBG, "BitstreamProtectedMemorySize %lu\n", pVideoResources->BitstreamProtectedMemorySize)); RMDBGLOG((LOCALDBG, "UnprotectedMemoryAddress 0x%lx\n", pVideoResources->UnprotectedMemoryAddress)); RMDBGLOG((LOCALDBG, "UnprotectedMemorySize %lu\n", pVideoResources->UnprotectedMemorySize)); return RM_OK;}RMstatus DCCOpenVideoDecoderSourceWithResources(struct DCC *pDCC, struct DCCXVideoProfile *pDCCVideoProfile, struct DCCVideoResources *pVideoResources, struct DCCVideoSource **ppVideoSource){ struct VideoDecoder_OpenX_type profile; RMuint32 surface; RMstatus status; RMuint32 engine_module_id; RMuint32 decoder_module_id; RMDBGLOG((LOCALDBG, "DCCOpenVideoDecoderSourceWithResources()\n")); ASSERT_NULL_POINTER(pDCC); ASSERT_NULL_POINTER(pDCCVideoProfile); ASSERT_NULL_POINTER(pVideoResources); ASSERT_NULL_POINTER(ppVideoSource); RMDBGLOG((LOCALDBG, "SchedulerSharedMemoryAddress 0x%lx size %lu\n", pVideoResources->SchedulerSharedMemoryAddress, pVideoResources->SchedulerSharedMemorySize)); RMDBGLOG((LOCALDBG, "DecoderSharedMemoryAddress 0x%lx size %lu\n", pVideoResources->DecoderSharedMemoryAddress, pVideoResources->DecoderSharedMemorySize)); RMDBGLOG((LOCALDBG, "PictureProtectedMemoryAddress 0x%lx size %lu\n", pVideoResources->PictureProtectedMemoryAddress, pVideoResources->PictureProtectedMemorySize)); RMDBGLOG((LOCALDBG, "BitstreamProtectedMemoryAddress 0x%lx size %lu\n", pVideoResources->BitstreamProtectedMemoryAddress, pVideoResources->BitstreamProtectedMemorySize)); RMDBGLOG((LOCALDBG, "UnprotectedMemoryAddress 0x%lx size %lu\n", pVideoResources->UnprotectedMemoryAddress, pVideoResources->UnprotectedMemorySize));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -