⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcc_video.c

📁 1. 8623L平台
💻 C
📖 第 1 页 / 共 5 页
字号:
		RMDBGLOG((ENABLE, "%lx_DRAM SCHEDULER MEMORY is already set addr=0x%lx size=0x%lx!\n",			pDCCVideoProfile->MpegEngineID, schedmem.Address, schedmem.Size));	}	else {		schedmem.Address = pDCC->rua_malloc(pDCC->pRUA, mpeg_engine, pDCC->dram, RUA_DRAM_UNCACHED, schedmem.Size);		if (!schedmem.Address) {			RMDBGLOG((ENABLE, "ERROR: could not allocate scheduler table!\n"));			return err;		}		RMDBGLOG((ENABLE, "ALLOCATING %lx_DRAM SCHEDULER MEMORY addr: 0x%08lX, size 0x%08lX\n",			pDCCVideoProfile->MpegEngineID, schedmem.Address, schedmem.Size));		DCCSP(pDCC->pRUA, mpeg_engine, RMMpegEnginePropertyID_SchedulerSharedMemory, &schedmem, sizeof(schedmem));	}	/* 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;	err = RUAExchangeProperty(pDCC->pRUA, video_decoder, RMVideoDecoderPropertyID_DecoderDataMemory, &memory_in, sizeof(memory_in), &memory_out, sizeof(memory_out));	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error getting property RMVideoDecoderPropertyID_DecoderDataMemory! %s\n", RMstatusToString(err)));		return err;	}	/* check if video shared memory is already set in mpeg engine */	err = RUAGetProperty(pDCC->pRUA, mpeg_engine, RMMpegEnginePropertyID_DecoderSharedMemory, &shared, sizeof(shared));	if (err != RM_OK) {		RMDBGLOG((ENABLE, "Cannot get DecoderSharedMemory, %s\n", RMstatusToString(err)));		return err;	}	if (shared.Address) {		if (shared.Size < memory_out.DecoderSharedSize) {			RMDBGLOG((ENABLE, "ERROR: video shared memory is already set with a smaller value than needed by DCCOpen %s\n", RMstatusToString(err)));			return err;		}		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 {		/* allocate and set the shared memory used by all decoders of the same engine */		shared.Size = memory_out.DecoderSharedSize;		if (shared.Size) {			shared.Address = pDCC->rua_malloc(pDCC->pRUA, mpeg_engine, pDCC->dram, RUA_DRAM_UNCACHED, shared.Size);			if (!shared.Address) {				RMDBGLOG((ENABLE, "ERROR: could not allocate shared 0x%08lX bytes in DRAM %lu!\n", shared.Address, 0L));				return RM_FATALOUTOFMEMORY;			}					RMDBGLOG((ENABLE, "ALLOCATING %lx_DRAM VIDEO SHARED MEMORY addr: 0x%08lX, size 0x%08lX\n",				pDCCVideoProfile->MpegEngineID, shared.Address, shared.Size));			DCCSP(pDCC->pRUA, mpeg_engine, RMMpegEnginePropertyID_DecoderSharedMemory, &shared, sizeof(shared));		}	}	/* 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;	err = RUAExchangeProperty(pDCC->pRUA, video_decoder, RMVideoDecoderPropertyID_DRAMSizeX, &dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out));	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error getting property RMVideoDecoderPropertyID_DRAMSize! %s\n", RMstatusToString(err)));		return err;	}		/* allocate the picture protected memory for video decoder */	profile.PictureProtectedAddress = 0;	profile.PictureProtectedSize = dram_out.PictureProtectedSize;	if (profile.PictureProtectedSize > 0) {		profile.PictureProtectedAddress = pDCC->rua_malloc(pDCC->pRUA, video_decoder, pDCC->dram, RUA_DRAM_UNCACHED, profile.PictureProtectedSize);		if (!profile.PictureProtectedAddress) {			RMDBGLOG((ENABLE, "ERROR: could not allocate 0x%08lX bytes in Protected DRAM %lu!\n", profile.PictureProtectedSize, 0L));			return RM_FATALOUTOFMEMORY;		}		RMDBGLOG((LOCALDBG, "video PictureProtectedAddress: 0x%08lX, size 0x%08lX, end: 0x%08lX\n",			profile.PictureProtectedAddress, profile.PictureProtectedSize, profile.PictureProtectedAddress + profile.PictureProtectedSize));	} 		(*ppVideoSource)->picture_protected_address = profile.PictureProtectedAddress;		/* allocate the bitstream protected memory for video decoder */	profile.BitstreamProtectedAddress = 0;	profile.BitstreamProtectedSize = dram_out.BitstreamProtectedSize;	if (profile.BitstreamProtectedSize > 0) {		profile.BitstreamProtectedAddress = pDCC->rua_malloc(pDCC->pRUA, video_decoder, pDCC->dram, RUA_DRAM_UNCACHED, profile.BitstreamProtectedSize);		if (!profile.BitstreamProtectedAddress) {			RMDBGLOG((ENABLE, "ERROR: could not allocate 0x%08lX bytes in Protected DRAM %lu!\n", profile.BitstreamProtectedSize, 0L));			return RM_FATALOUTOFMEMORY;		}		RMDBGLOG((LOCALDBG, "video BitstreamProtectedAddress: 0x%08lX, size 0x%08lX, end: 0x%08lX\n",			profile.BitstreamProtectedAddress, profile.BitstreamProtectedSize, profile.BitstreamProtectedAddress + profile.BitstreamProtectedSize));	} 		(*ppVideoSource)->cached_address = profile.BitstreamProtectedAddress;		/* allocate the unprotected memory required for video decoder */	profile.UnprotectedAddress = 0;	profile.UnprotectedSize = dram_out.UnprotectedSize;	if (profile.UnprotectedSize > 0) {		profile.UnprotectedAddress = pDCC->rua_malloc(pDCC->pRUA, video_decoder, pDCC->dram, RUA_DRAM_UNCACHED, profile.UnprotectedSize);		if (!profile.UnprotectedAddress) {			RMDBGLOG((ENABLE, "ERROR: could not allocate 0x%08lX bytes in unprotected DRAM %lu!\n", profile.UnprotectedSize, 0L));			return RM_FATALOUTOFMEMORY;		}		RMDBGLOG((LOCALDBG, "video UnprotectedAddress: 0x%08lX, size 0x%08lX, end: 0x%08lX\n",			profile.UnprotectedAddress, profile.UnprotectedSize, profile.UnprotectedAddress + profile.UnprotectedSize));	} 		(*ppVideoSource)->uncached_address = profile.UnprotectedAddress;		/* open VideoDecoder module */	profile.ProtectedFlags = dram_in.ProtectedFlags;	profile.BitstreamFIFOSize = dram_in.BitstreamFIFOSize;	profile.UserDataSize = dram_in.UserDataSize;	profile.DecoderDataSize = dram_in.DecoderDataSize;	profile.DecoderContextSize = memory_out.DecoderContextSize; //TODO to be removed when microcode calculates it	profile.ExtraPictureBufferCount = pDCCVideoProfile->ExtraPictureBufferCount;	profile.XferFIFOCount = dram_in.XferFIFOCount;	profile.PtsFIFOCount = dram_in.PtsFIFOCount;	profile.InbandFIFOCount = dram_in.InbandFIFOCount;	profile.XtaskInbandFIFOCount = dram_in.XtaskInbandFIFOCount;	profile.XtaskId = pDCCVideoProfile->XtaskID;		DCCSP(pDCC->pRUA, video_decoder, RMVideoDecoderPropertyID_OpenX, &profile, sizeof(profile));		err = RUAGetProperty(pDCC->pRUA, video_decoder, RMGenericPropertyID_Surface, &surface, sizeof(surface));	if (err != RM_OK) {		RMDBGLOG((ENABLE, "Cannot get the video surface, %s\n", RMstatusToString(err)));		return err;	}	(*ppVideoSource)->surface = surface;#endif // DCC_WITH_RESOURCES	(*ppVideoSource)->free_scheduler = TRUE;	(*ppVideoSource)->free_shared = TRUE;	(*ppVideoSource)->free_cached = TRUE;	(*ppVideoSource)->free_uncached = TRUE;	(*ppVideoSource)->free_spu_cached = TRUE;	(*ppVideoSource)->free_spu_uncached = TRUE;	(*ppVideoSource)->free_picture_protected = TRUE;	if (pDCCVideoProfile->SPUBitstreamFIFOSize > 0) {		struct SpuDecoder_DRAMSizeX_in_type dram_in;		struct SpuDecoder_DRAMSizeX_out_type dram_out;		struct SpuDecoder_DecoderDataMemory_in_type memory_in;		struct SpuDecoder_DecoderDataMemory_out_type memory_out;		struct SpuDecoder_OpenX_type profile;		RMuint32 spu_decoder, nb_spu_decoders;		RMuint32 temp;		RMstatus err;		RMuint32 nb_mpeg_engines;		RMDBGLOG((LOCALDBG, "-- Initializing SPU decoder!\n"));		// Get number of video engines and video decoders		temp = MpegEngine;		err = RUAExchangeProperty(pDCC->pRUA, Enumerator, RMEnumeratorPropertyID_CategoryIDToNumberOfInstances,					  &temp, sizeof(temp), &nb_mpeg_engines, sizeof(nb_mpeg_engines));		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Error getting property  RMEnumeratorPropertyID_CategoryIDToNumberOfInstances %s\n", 				  RMstatusToString(err)));			return err;		}		else {			if (pDCCVideoProfile->MpegEngineID < nb_mpeg_engines)				RMDBGLOG((LOCALDBG, "Number of video engines: %d\n", (RMint32) nb_mpeg_engines));			else {				RMDBGLOG((ENABLE, "Error: video engine index %d out of range!!! Should be < %d\n", 					  (RMint32) pDCCVideoProfile->MpegEngineID, (RMint32) nb_mpeg_engines));				err = RM_PARAMETER_OUT_OF_RANGE;				return err;			}		}				temp = SpuDecoder;		err = RUAExchangeProperty(pDCC->pRUA, Enumerator, RMEnumeratorPropertyID_CategoryIDToNumberOfInstances,					&temp, sizeof(temp), &nb_spu_decoders, sizeof(nb_spu_decoders));		// !!Hack!! We assume there are an equal amount of decoders per engine		spu_decoder = EMHWLIB_MODULE(SpuDecoder, pDCCVideoProfile->MpegEngineID * (nb_spu_decoders / nb_mpeg_engines) + 0);		(*ppVideoSource)->spu_decoder_moduleID = spu_decoder;		memory_in.Codec = pDCCVideoProfile->SPUCodec;		memory_in.Profile = pDCCVideoProfile->SPUProfile;		memory_in.Level = pDCCVideoProfile->SPULevel;		memory_in.ExtraPictureBufferCount = pDCCVideoProfile->SPUExtraPictureBufferCount;		memory_in.MaxWidth = pDCCVideoProfile->SPUMaxWidth;		memory_in.MaxHeight = pDCCVideoProfile->SPUMaxHeight;		err = RUAExchangeProperty(pDCC->pRUA, spu_decoder, RMSpuDecoderPropertyID_DecoderDataMemory, &memory_in, sizeof(memory_in), &memory_out, sizeof(memory_out));		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Error getting property RMVideoDecoderPropertyID_DecoderDataMemory! %s\n", RMstatusToString(err)));			return err;		}		dram_in.ProtectedFlags 			= pDCCVideoProfile->ProtectedFlags;		dram_in.BitstreamFIFOSize 		= pDCCVideoProfile->SPUBitstreamFIFOSize;		dram_in.XferFIFOCount 			= pDCCVideoProfile->SPUXferFIFOCount;		dram_in.DecoderDataSize 		= memory_out.DecoderDataSize;		dram_in.PtsFIFOCount 			= pDCCVideoProfile->PtsFIFOCount;		dram_in.InbandFIFOCount 		= pDCCVideoProfile->InbandFIFOCount;		dram_in.XtaskInbandFIFOCount 	= pDCCVideoProfile->XtaskInbandFIFOCount;		dram_in.HilightCount			= 3;		err = RUAExchangeProperty(pDCC->pRUA, spu_decoder, RMSpuDecoderPropertyID_DRAMSizeX, &dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out));		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Error getting property RMSpuDecoderPropertyID_DRAMSizeX! %s\n", RMstatusToString(err)));			return err;		}			/* allocate the unprotected memory required for Spu decoder */		profile.UnprotectedAddress = 0;		profile.UnprotectedSize = dram_out.UnprotectedSize;		if (profile.UnprotectedSize > 0) {			profile.UnprotectedAddress = pDCC->rua_malloc(pDCC->pRUA, spu_decoder, pDCC->dram, RUA_DRAM_UNCACHED, profile.UnprotectedSize);			if (!profile.UnprotectedAddress) {				RMDBGLOG((ENABLE, "ERROR: could not allocate 0x%08lX bytes in unprotected DRAM %lu!\n", profile.UnprotectedSize, 0L));				return RM_FATALOUTOFMEMORY;			}			RMDBGLOG((LOCALDBG, "SPU UnprotectedAddress: 0x%08lX, size 0x%08lX, end: 0x%08lX\n",				profile.UnprotectedAddress, profile.UnprotectedSize, profile.UnprotectedAddress + profile.UnprotectedSize));		} 			(*ppVideoSource)->spu_uncached_address = profile.UnprotectedAddress;		/* open SpuDecoder module */		profile.ProtectedFlags 				= dram_in.ProtectedFlags;		profile.PictureProtectedAddress		= 0;		profile.PictureProtectedSize 		= 0;		profile.BitstreamProtectedAddress 	= 0;		profile.BitstreamProtectedSize		= 0;		profile.BitstreamFIFOSize 			= dram_in.BitstreamFIFOSize;		profile.DecoderDataSize 			= memory_out.DecoderDataSize;		profile.DecoderContextSize 			= memory_out.DecoderContextSize;		profile.ExtraPictureBufferCount 	= pDCCVideoProfile->SPUExtraPictureBufferCount;		profile.XferFIFOCount 				= dram_in.XferFIFOCount;		profile.PtsFIFOCount 				= dram_in.PtsFIFOCount;		profile.InbandFIFOCount 			= dram_in.InbandFIFOCount;		profile.XtaskInbandFIFOCount 		= dram_in.XtaskInbandFIFOCount;		profile.XtaskId 					= pDCCVideoProfile->XtaskID;		profile.HilightCount				= dram_in.HilightCount;		profile.STCId = pDCCVideoProfile->STCID;		DCCSP(pDCC->pRUA, spu_decoder, RMSpuDecoderPropertyID_OpenX, &profile, sizeof(profile));#ifdef ENABLE_SPU_OP		err = RUAGetProperty(pDCC->pRUA, spu_decoder, RMSpuDecoderPropertyID_VSyncSurface, &((*ppVideoSource)->spu_surface), sizeof(RMuint32));		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Error getting property RMSpuDecoderPropertyID_VSyncSurface! %s\n", RMstatusToString(err)));			return err;		}#endif	}	return RM_OK;}RMstatus DCCXSetVideoDecoderSourceCodec(struct DCCVideoSource *pVideoSource, enum EMhwlibVideoCodec Codec){	RMstatus err;	RMDBGLOG((LOCALDBG, "DCCXSetVideoDecoderSourceCodec codec = %ld\n", (RMint32)Codec));	ASSERT_NULL_POINTER(pVideoSource);	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;	}	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_CodecX, &Codec, sizeof(enum EMhwlibVideoCodec));	if (pVideoSource->spu_decoder_moduleID != 0) {		Codec = EMhwlibDVDSpuCodec;		DCCSP(pVideoSource->pRUA, pVideoSource->spu_decoder_moduleID, RMSpuDecoderPropertyID_CodecX, &Codec, sizeof(enum EMhwlibVideoCodec));	}	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;	}	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;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -