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

📄 dcc_capture.c

📁 dcc code for smp 8634 media processor
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************** Copyright © 2001-2003   Sigma Designs, Inc. All Rights Reserved Proprietary and Confidential *****************************************//**  @file   dcc.c  @brief  Decoding Chain Control API  @author Julien Soulier  @date   2003-10-02*/// to enable or disable the debug messages of this source file, put 1 or 0 below#if 0#define LOCALDBG ENABLE#else#define LOCALDBG DISABLE#endif#include "dcc_common.h"#define DCCCAPTURE_PROGRESSIVE_BUF 5  // number of picture buffers for progressive capture#define DCCCAPTURE_INTERLACED_BUF 5   // number of picture buffers for interlaced capture without de-interlacing#define DCCCAPTURE_DEINT_BUF 6        // number of picture buffers for interlaced capture with de-interlacingRMstatus DCCOpenVideoInputSource(	struct DCC *pDCC, 	struct DCCCaptureProfile *pProfile, 	RMuint32 TimerNumber, 	RMuint32 dram, 	struct DCCVideoSource **ppVideoSource){	struct DispVideoInput_DRAMSize_in_type dram_in;	struct DispVideoInput_DRAMSize_out_type dram_out;	struct DispVideoInput_Open_type profile;	struct DCCVideoSource *pVideoSource;	RMuint32 surface, input;	RMstatus err;		if (ppVideoSource == NULL) {		RMDBGLOG((ENABLE, "WARNING: DCCOpenVideoInputSource() ppVideoSource == NULL!\n"));	}	if (ppVideoSource && *ppVideoSource) {		pVideoSource = *ppVideoSource;	} else {		pVideoSource = (struct DCCVideoSource *)RMMalloc(sizeof(struct DCCVideoSource));		if (pVideoSource == NULL) {			RMDBGLOG((ENABLE, "ERROR: could not allocate %lu bytes in system memory!\n", sizeof(struct DCCVideoSource)));			return RM_FATALOUTOFMEMORY;		}		if (ppVideoSource) *ppVideoSource = pVideoSource;		RMMemset((void*)pVideoSource, 0, sizeof(struct DCCVideoSource));	}	pVideoSource->pRUA = pDCC->pRUA;	pVideoSource->pDCC = pDCC;	input = EMHWLIB_MODULE(DispVideoInput, 0);	pVideoSource->decoder_moduleID = input;		pVideoSource->timer_number = TimerNumber;		{		struct DispDigitalOut_PadsControl_type ipad;		RMMemset(&ipad, 0, sizeof(ipad));		ipad.APIVersion = 1;		ipad.ModifyVideoInputV2 = TRUE;		ipad.VideoInputV2 = pProfile->UseV2Pads;		DCCSPERR(pDCC->pRUA, DispDigitalOut, 			RMDispDigitalOutPropertyID_PadsControl, 			&ipad, sizeof(ipad), 			"Failed to set property PadsControl");		DCCSPERR(pDCC->pRUA, DispDigitalOut, 			RMGenericPropertyID_Validate, NULL, 0, 			"Failed to validate DispDigitalOut");	}		dram_in.ColorMode = pProfile->ColorMode;	dram_in.ColorFormat = pProfile->ColorFormat;	dram_in.SamplingMode = pProfile->SamplingMode;	dram_in.Width = pProfile->Width;	dram_in.Height = pProfile->Height;	dram_in.NumBuffer = (pProfile->Width && pProfile->Height) ? 		(pProfile->Interlaced ? 			(pProfile->DeInt ? DCCCAPTURE_DEINT_BUF : DCCCAPTURE_INTERLACED_BUF) : 			DCCCAPTURE_PROGRESSIVE_BUF) : 		0;	err = RUAExchangeProperty(pDCC->pRUA, input, 		RMDispVideoInputPropertyID_DRAMSize, 		&dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out));	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error getting property RMDispVideoInputPropertyID_DRAMSize! %s\n", RMstatusToString(err)));		return err;	}		profile.ColorMode = dram_in.ColorMode;	profile.ColorFormat = dram_in.ColorFormat;	profile.SamplingMode = dram_in.SamplingMode;	profile.Width = dram_in.Width;	profile.Height = dram_in.Height;	profile.NumBuffer = dram_in.NumBuffer;	profile.ColorSpace = pProfile->ColorSpace;	profile.PixelAspectRatio.X = pProfile->PixelAspectRatio.X;	profile.PixelAspectRatio.Y = pProfile->PixelAspectRatio.Y;	profile.STCIndex = TimerNumber;		if (pVideoSource->uncached_address) 		pDCC->rua_free(pDCC->pRUA, pVideoSource->uncached_address);	profile.BufferSize = dram_out.BufferSize;	profile.BufferAddress = pDCC->rua_malloc(pDCC->pRUA, input, dram, RUA_DRAM_UNCACHED, profile.BufferSize);	if (! profile.BufferAddress) {		RMDBGLOG((ENABLE, "ERROR: could not allocate 0x%08lX bytes in cached DRAM %lu!\n", profile.BufferSize, dram));		return RM_FATALOUTOFMEMORY;	}	RMDBGLOG((LOCALDBG, "video input cached addr: 0x%08lX, size 0x%08lX, end: 0x%08lX\n", 		profile.BufferAddress, profile.BufferSize, profile.BufferAddress + profile.BufferSize));	pVideoSource->uncached_address = profile.BufferAddress;		err = RUASetProperty(pDCC->pRUA, input, 		RMDispVideoInputPropertyID_Open, 		&profile, sizeof(profile), 0);	if (err != RM_OK) {		RMDBGLOG((ENABLE, "Cannot create the video input surface, %s\n", RMstatusToString(err)));		return err;	}		err = RUAGetProperty(pDCC->pRUA, input, 		RMGenericPropertyID_Surface, 		&surface, sizeof(surface));	if (err != RM_OK) {		RMDBGLOG((ENABLE, "Cannot get the video input surface, %s\n", RMstatusToString(err)));		return err;	}	pVideoSource->surface = surface;		return RM_OK;}RMstatus DCCOpenGraphicInputSource(	struct DCC *pDCC, 	struct DCCCaptureProfile *pProfile, 	RMuint32 TimerNumber, 	RMuint32 dram, 	struct DCCVideoSource **ppVideoSource){	struct DispGraphicInput_DRAMSize_in_type dram_in;	struct DispGraphicInput_DRAMSize_out_type dram_out;	struct DispGraphicInput_Open_type profile;	struct DCCVideoSource *pVideoSource;	RMuint32 surface, input;	RMstatus err;		if (ppVideoSource == NULL) {		RMDBGLOG((ENABLE, "WARNING: DCCOpenGraphicInputSource() ppVideoSource == NULL!\n"));	}	if (ppVideoSource && *ppVideoSource) {		pVideoSource = *ppVideoSource;	} else {		pVideoSource = (struct DCCVideoSource *)RMMalloc(sizeof(struct DCCVideoSource));		if (pVideoSource == NULL) {			RMDBGLOG((ENABLE, "ERROR: could not allocate %lu bytes in system memory!\n", sizeof(struct DCCVideoSource)));			return RM_FATALOUTOFMEMORY;		}		if (ppVideoSource) *ppVideoSource = pVideoSource;		RMMemset((void*)pVideoSource, 0, sizeof(struct DCCVideoSource));	}	pVideoSource->pRUA = pDCC->pRUA;	pVideoSource->pDCC = pDCC;	input = EMHWLIB_MODULE(DispGraphicInput, 0);	pVideoSource->decoder_moduleID = input;		pVideoSource->timer_number = TimerNumber;		{		struct DispDigitalOut_PadsControl_type ipad;		RMMemset(&ipad, 0, sizeof(ipad));		ipad.APIVersion = 1;		ipad.ModifyGraphicInputV2 = TRUE;		ipad.GraphicInputV2 = pProfile->UseV2Pads;		DCCSPERR(pDCC->pRUA, DispDigitalOut, 			RMDispDigitalOutPropertyID_PadsControl, 			&ipad, sizeof(ipad), 			"Failed to set property PadsControl");		DCCSPERR(pDCC->pRUA, DispDigitalOut, 			RMGenericPropertyID_Validate, NULL, 0, 			"Failed to validate DispDigitalOut");	}		dram_in.ColorMode = pProfile->ColorMode;	dram_in.ColorFormat = pProfile->ColorFormat;	dram_in.SamplingMode = pProfile->SamplingMode;	dram_in.Width = pProfile->Width;	dram_in.Height = pProfile->Height;	dram_in.NumBuffer = (pProfile->Width && pProfile->Height) ? 		(pProfile->Interlaced ? 			(pProfile->DeInt ? DCCCAPTURE_DEINT_BUF : DCCCAPTURE_INTERLACED_BUF) : 			DCCCAPTURE_PROGRESSIVE_BUF) : 		0;	err = RUAExchangeProperty(pDCC->pRUA, input, 		RMDispGraphicInputPropertyID_DRAMSize, 		&dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out));	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error getting property RMDispGraphicInputPropertyID_DRAMSize! %s\n", RMstatusToString(err)));		return err;	}		profile.ColorMode = dram_in.ColorMode;	profile.ColorFormat = dram_in.ColorFormat;	profile.SamplingMode = dram_in.SamplingMode;	profile.Width = dram_in.Width;	profile.Height = dram_in.Height;	profile.NumBuffer = dram_in.NumBuffer;	profile.ColorSpace = pProfile->ColorSpace;	profile.PixelAspectRatio.X = pProfile->PixelAspectRatio.X;	profile.PixelAspectRatio.Y = pProfile->PixelAspectRatio.Y;	profile.STCIndex = TimerNumber;		if (pVideoSource->uncached_address) 		pDCC->rua_free(pDCC->pRUA, pVideoSource->uncached_address);	profile.BufferSize = dram_out.BufferSize;	profile.BufferAddress = pDCC->rua_malloc(pDCC->pRUA, input, dram, RUA_DRAM_UNCACHED, profile.BufferSize);	if (! profile.BufferAddress) {		RMDBGLOG((ENABLE, "ERROR: could not allocate 0x%08lX bytes in cached DRAM %lu!\n", profile.BufferSize, dram));		return RM_FATALOUTOFMEMORY;	}	RMDBGLOG((LOCALDBG, "video input cached addr: 0x%08lX, size 0x%08lX, end: 0x%08lX\n", profile.BufferAddress, profile.BufferSize, profile.BufferAddress + profile.BufferSize));	pVideoSource->uncached_address = profile.BufferAddress;		err = RUASetProperty(pDCC->pRUA, input, 		RMDispGraphicInputPropertyID_Open, 		&profile, sizeof(profile), 0);	if (err != RM_OK) {		RMDBGLOG((ENABLE, "Cannot create the graphic input surface, %s\n", RMstatusToString(err)));		return err;	}		err = RUAGetProperty(pDCC->pRUA, input, RMGenericPropertyID_Surface, &surface, sizeof(surface));	if (err != RM_OK) {		RMDBGLOG((ENABLE, "Cannot get the graphic input surface, %s\n", RMstatusToString(err)));		return err;	}	pVideoSource->surface = surface;		return RM_OK;}/* If bussize is 8 bit, the following members of fmt have to be already doubled:   PixelClock, ActiveWidth, XOffset, HTotalSize, HSyncWidth */RMstatus DCCSetupVideoInputFormat(	struct DCC *pDCC, 	struct EMhwlibTVFormatDigital fmt,	enum EMhwlibDigitalTimingSignal DigitalTimingSignal, 	RMbool UseVideoValid, 	RMuint32 bussize, 	RMint32 over_pos_x, 	RMint32 over_pos_y, 	RMuint32 over_width, 	RMuint32 over_height, 	RMbool InvertVSync, 	RMbool InvertHSync, 	RMbool InvertFieldID, 	RMbool UseGPIOFieldID){	RMuint32 vo_in;	struct DispVideoInput_InputFormat_type vi_format;	struct Input_GPIOFieldID_type gpio;	RMuint32 SyncSourceModuleID = 0;  // external sync	RMbool enable = TRUE;		if (DigitalTimingSignal == EMhwlibDigitalTimingSignal_601) {		vi_format.ProtocolV = UseVideoValid; // 601 with or without vvld		vi_format.ProtocolM = TRUE;  // 601	} else {		vi_format.ProtocolV = FALSE; // 656		vi_format.ProtocolM = FALSE; // 656	}	vi_format.ComponentOrderReverse = FALSE; 	vi_format.TrailingEdge = FALSE; 	vi_format.VSyncDelay = FALSE; 		gpio.GPIONumber = 2;	gpio.Enable = UseGPIOFieldID;	gpio.Invert = InvertFieldID;		vo_in = EMHWLIB_MODULE(DispVideoInput, 0);		DCCSPERR(pDCC->pRUA, vo_in, 		RMDispVideoInputPropertyID_BusSize, &bussize, sizeof(bussize), 		"Failed to set property DispVideoInputProperty_BusSize");	if (- over_pos_x > (RMint32)fmt.XOffset) over_pos_x = - fmt.XOffset;	if (- over_pos_y > (RMint32)fmt.YOffsetTop) over_pos_y = - fmt.YOffsetTop;	if ((!fmt.Progressive) && (- over_pos_y > (RMint32)fmt.YOffsetBottom)) over_pos_y = - fmt.YOffsetBottom;	fmt.ActiveWidth += over_width;	fmt.ActiveHeight += over_height;	fmt.XOffset += over_pos_x;	fmt.YOffsetTop += over_pos_y;	fmt.YOffsetBottom += (fmt.Progressive ? 0 : over_pos_y);	if (InvertVSync) fmt.VSyncActiveLow = ! fmt.VSyncActiveLow;	if (InvertHSync) fmt.HSyncActiveLow = ! fmt.HSyncActiveLow;	DCCSPERR(pDCC->pRUA, vo_in, 		RMGenericPropertyID_TVFormat, &fmt, sizeof(fmt), 		"Failed to set property TVFormat");	DCCSPERR(pDCC->pRUA, vo_in, 		RMGenericPropertyID_SyncSourceModuleID, &SyncSourceModuleID, sizeof(SyncSourceModuleID), 		"Failed to set property DispVideoInputProperty_SyncSourceModuleID");	DCCSPERR(pDCC->pRUA, vo_in, 		RMDispVideoInputPropertyID_InputFormat, &vi_format, sizeof(vi_format), 		"Failed to set property DispVideoInputProperty_InputFormat");	DCCSPERR(pDCC->pRUA, vo_in, 		RMGenericPropertyID_GPIOFieldID, &gpio, sizeof(gpio), 		"Failed to set property GPIOFieldID");	DCCSPERR(pDCC->pRUA, vo_in, 		RMGenericPropertyID_Validate, NULL, 0, 		"Failed to validate input");	DCCSPERR(pDCC->pRUA, vo_in, 		RMGenericPropertyID_Enable, &enable, sizeof(enable), 		"Failed to enable input");

⌨️ 快捷键说明

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