📄 dcc_video.c
字号:
DCCSP(pVideoSource->pRUA, pVideoSource->scaler_moduleID, RMGenericPropertyID_Surface, &surface, sizeof(surface)); surface_changed = TRUE; } } if (surface_changed) { RMstatus err; struct RUAEvent evt; RMuint32 index; evt.Mask = EMHWLIB_DISPLAY_EVENT_ID(pVideoSource->scaler_moduleID); evt.ModuleID = EMHWLIB_MODULE(DisplayBlock, 0); err = RUAWaitForMultipleEvents(pVideoSource->pRUA, &evt, 1, WAIT_COMMAND_TIMEOUT_US, &index); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "wait for display update event completion failed, %s\n", RMstatusToString(err))); return err; } } if (pVideoSource->decoder_moduleID != 0) { RMuint32 close_profile = 0; if (EMHWLIB_MODULE_CATEGORY(pVideoSource->decoder_moduleID) == DispVideoInput) { DCCSPERR(pVideoSource->pRUA, pVideoSource->decoder_moduleID, RMDispVideoInputPropertyID_Close, &close_profile, sizeof(close_profile), "Error closing video input profile"); } else if (EMHWLIB_MODULE_CATEGORY(pVideoSource->decoder_moduleID) == DispGraphicInput) { DCCSPERR(pVideoSource->pRUA, pVideoSource->decoder_moduleID, RMDispGraphicInputPropertyID_Close, &close_profile, sizeof(close_profile), "Error closing graphic input profile"); } else { RMDBGLOG((LOCALDBG, ">>>closing video decoder\n")); DCCSPERR(pVideoSource->pRUA, pVideoSource->decoder_moduleID, RMVideoDecoderPropertyID_Close, &close_profile, sizeof(close_profile), "Error closing video decoder profile"); } } if (pVideoSource->spu_decoder_moduleID != 0) { RMuint32 close_profile = 0; DCCSP(pVideoSource->pRUA, pVideoSource->spu_decoder_moduleID, RMSpuDecoderPropertyID_Close, &close_profile, sizeof(close_profile)); } if (pVideoSource->picture_protected_address) pVideoSource->pDCC->rua_free(pVideoSource->pRUA, pVideoSource->picture_protected_address); if (pVideoSource->cached_address) pVideoSource->pDCC->rua_free(pVideoSource->pRUA, pVideoSource->cached_address); if (pVideoSource->uncached_address) pVideoSource->pDCC->rua_free(pVideoSource->pRUA, pVideoSource->uncached_address); if (pVideoSource->spu_cached_address) pVideoSource->pDCC->rua_free(pVideoSource->pRUA, pVideoSource->spu_cached_address); if (pVideoSource->spu_uncached_address) pVideoSource->pDCC->rua_free(pVideoSource->pRUA, pVideoSource->spu_uncached_address); if (pVideoSource->pictures != NULL) RMFree(pVideoSource->pictures); /* is it a video source or an OSD source ? */ if (pVideoSource->engine_moduleID != 0) { /* Free the video scheduler task database table {see DCCXOpenVideoDecoderSource for allocation} */ RMstatus err; RMuint32 connected_task_count; err = RUAGetProperty(pVideoSource->pRUA, pVideoSource->engine_moduleID, RMMpegEnginePropertyID_ConnectedTaskCount, &connected_task_count, sizeof(connected_task_count)); if (err != RM_OK) { RMDBGLOG((ENABLE, "Cannot get RMMpegEnginePropertyID_ConnectedTaskCount %s %lu\n", RMstatusToString(err), pVideoSource->engine_moduleID)); return err; } if (connected_task_count == 0) { struct MpegEngine_SchedulerSharedMemory_type schedmem; struct MpegEngine_DecoderSharedMemory_type shared; RMuint32 address; err = RUAGetProperty(pVideoSource->pRUA, pVideoSource->engine_moduleID, RMMpegEnginePropertyID_DecoderSharedMemory, &shared, sizeof(shared)); if (err != RM_OK) { RMDBGLOG((ENABLE, "Cannot get DecoderSharedMemory0, %s\n", RMstatusToString(err))); return err; } if (shared.Address) { RMDBGLOG((ENABLE, "FREE %lx_DRAM VIDEO SHARED MEMORY addr=0x%lx size=0x%lx!\n", EMHWLIB_MODULE_INDEX(pVideoSource->engine_moduleID), shared.Address, shared.Size)); address = shared.Address; shared.Address = 0; shared.Size = 0; DCCSP(pVideoSource->pRUA, pVideoSource->engine_moduleID, RMMpegEnginePropertyID_DecoderSharedMemory, &shared, sizeof(shared)); /* Unlock the shared address */ err = RUASetAddressID(pVideoSource->pRUA, address, 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "RUASetAddressID scheduler 0 ERROR %s\n", RMstatusToString(err))); return err; } RUAFree(pVideoSource->pRUA, address); } err = RUAGetProperty(pVideoSource->pRUA, pVideoSource->engine_moduleID, RMMpegEnginePropertyID_SchedulerSharedMemory, &schedmem, sizeof(schedmem)); if (err != RM_OK) { RMDBGLOG((ENABLE, "Cannot get SchedulerSharedMemory, %s\n", RMstatusToString(err))); return err; } if (schedmem.Address) { RMDBGLOG((ENABLE, "FREE %lx_DRAM SCHEDULER MEMORY addr=0x%lx size=0x%lx!\n", EMHWLIB_MODULE_INDEX(pVideoSource->engine_moduleID), schedmem.Address, schedmem.Size)); address = schedmem.Address; schedmem.Address = 0; schedmem.Size = 0; DCCSP(pVideoSource->pRUA, pVideoSource->engine_moduleID, RMMpegEnginePropertyID_SchedulerSharedMemory, &schedmem, sizeof(schedmem)); /* Unlock the schedulers's address */ err = RUASetAddressID(pVideoSource->pRUA, address, 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "RUASetAddressID scheduler 0 ERROR %s\n", RMstatusToString(err))); return err; } RUAFree(pVideoSource->pRUA, address); } } else { RMDBGLOG((ENABLE, "CANNOT FREE %lx SCHEDULER and SHARED MEMORY. There are still %lx video tasks opened. \n", EMHWLIB_MODULE_INDEX(pVideoSource->engine_moduleID), connected_task_count)); } } RMFree(pVideoSource); return RM_OK;}RMstatus DCCGetVideoDecoderSourceInfo(struct DCCVideoSource *pVideoSource, RMuint32 *video_decoder, RMuint32 *spu_decoder, RMuint32 *timer){ if (video_decoder) *video_decoder = pVideoSource->decoder_moduleID; if (timer) *timer = pVideoSource->timer_number; if (spu_decoder) *spu_decoder = pVideoSource->spu_decoder_moduleID; return RM_OK;}RMstatus DCCSetVideoDecoderSourceCodec(struct DCCVideoSource *pVideoSource, enum VideoDecoder_Codec_type codec){ RMstatus err; RMDBGLOG((LOCALDBG, "DCCSetVideoSourceCodec codec=%ld\n", (int)codec)); err = send_video_command(pVideoSource->pRUA, pVideoSource->decoder_moduleID, VideoDecoder_Command_Uninit); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send VideoDecoder_Command_Uninit, %s\n", RMstatusToString(err))); return err; } /* send uninit command to spu decoder */ if (pVideoSource->spu_decoder_moduleID != 0) { err = send_spu_command(pVideoSource->pRUA, pVideoSource->spu_decoder_moduleID, SpuDecoder_Command_Uninit); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send SpuDecoder_Command_Uninit, %s\n", RMstatusToString(err))); return err; } } DCCSP(pVideoSource->pRUA, pVideoSource->decoder_moduleID, RMVideoDecoderPropertyID_Codec, &codec, sizeof(codec)); err = send_video_command(pVideoSource->pRUA, pVideoSource->decoder_moduleID, VideoDecoder_Command_Init); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send VideoDecoder_Command_Init, %s\n", RMstatusToString(err))); return err; } /* send init command to spu decoder */ if (pVideoSource->spu_decoder_moduleID != 0) { err = send_spu_command(pVideoSource->pRUA, pVideoSource->spu_decoder_moduleID, SpuDecoder_Command_Init); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send SpuDecoder_Command_Init, %s\n", RMstatusToString(err))); return err; } } return RM_OK;}RMstatus DCCPlayVideoSource(struct DCCVideoSource *pVideoSource, enum DCCVideoPlayCommand cmd){ RMstatus err; /* IMPORTANT NOTE: 'cmd=DCCVideoPlayNextFrame' only affects the display, so the video decoder remains in the current playback state, ie: playFwd, playIFrame, etc. */ if (cmd == DCCVideoPlayNextFrame) { if (pVideoSource->scaler_moduleID != 0) { DCCSP(pVideoSource->pRUA, pVideoSource->scaler_moduleID, RMGenericPropertyID_Step, NULL, 0); } //cmd = VideoDecoder_Command_PlayFwd; } if (cmd != DCCVideoPlayNextFrame) { err = send_video_command(pVideoSource->pRUA, pVideoSource->decoder_moduleID, cmd); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send video command play, %s\n", RMstatusToString(err))); return err; } } if (pVideoSource->spu_decoder_moduleID != 0) { err = send_spu_command(pVideoSource->pRUA, pVideoSource->spu_decoder_moduleID, SpuDecoder_Command_Play); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send SpuDecoder_Command_Play, %s\n", RMstatusToString(err))); return err; } } return RM_OK;}RMstatus DCCStopVideoSource(struct DCCVideoSource *pVideoSource, enum DCCStopMode stop_mode){ RMstatus err; err = send_video_command(pVideoSource->pRUA, pVideoSource->decoder_moduleID, VideoDecoder_Command_Stop); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send VideoDecoder_Command_Stop, %s\n", RMstatusToString(err))); return err; } if (pVideoSource->spu_decoder_moduleID != 0) { err = send_spu_command(pVideoSource->pRUA, pVideoSource->spu_decoder_moduleID, SpuDecoder_Command_Stop); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send SpuDecoder_Command_Stop, %s\n", RMstatusToString(err))); return err; } } if (pVideoSource->scaler_moduleID != 0) { struct RUAEvent evt; switch (stop_mode) { case DCCStopMode_BlackFrame: DCCSP(pVideoSource->pRUA, pVideoSource->scaler_moduleID, RMGenericPropertyID_Stop, NULL, 0); break; case DCCStopMode_LastFrame: DCCSP(pVideoSource->pRUA, pVideoSource->scaler_moduleID, RMGenericPropertyID_Flush, NULL, 0); break; } 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){ return RM_OK;}RMstatus DCCEnableVideoSource(struct DCCVideoSource *pVideoSource, RMbool enable){ RMuint32 src_index, mixer, scaler; RMstatus err; enum EMhwlibMixerSourceState state; 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; err = RUAGetProperty(pVideoSource->pRUA, pVideoSource->decoder_moduleID , RMVideoDecoderPropertyID_BtsFIFO, BtsFIFO, sizeof(RMuint32)); return err;} RMstatus DCCXOpenVideoDecoderSource(struct DCC *pDCC, struct DCCXVideoProfile *dcc_profile, struct DCCVideoSource **ppVideoSource){ 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; struct VideoDecoder_OpenX_type profile; RMuint32 surface, video_decoder = 0; RMuint32 nb_mpeg_engines, nb_video_decoders; RMuint32 mpeg_engine = 0; RMuint32 temp; RMstatus err; *ppVideoSource = (struct DCCVideoSource *) RMMalloc(sizeof(struct DCCVideoSource)); if (*ppVideoSource == NULL) { RMDBGLOG((ENABLE, "ERROR: could not allocate 0x%08lX bytes in system memory %lu!\n", sizeof(struct DCCVideoSource))); return RM_FATALOUTOFMEMORY; } RMMemset((void*)(*ppVideoSource), 0, sizeof(struct DCCVideoSource)); (*ppVideoSource)->pRUA = pDCC->pRUA;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -