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

📄 play_capture_video.c

📁 1. 8623L平台
💻 C
📖 第 1 页 / 共 4 页
字号:
/* * * Copyright (c) 2001-2007 Sigma Designs, Inc.  * All Rights Reserved. Proprietary and Confidential. * *//**	@file   play_capture_video.c	@brief  functions to set up the emhwlib audio passthrough (no external chip interaction)		@author Christian Wolff Sean.Sekwon.Choi*/// 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 "sample_os.h"#define ALLOW_OS_CODE 1#include "../rua/include/rua.h"#include "../rua/include/rua_property.h"#include "../dcc/include/dcc.h"#include "../dcc/include/dcc_macros.h"#include "../rmcore/include/rmstatustostring.h"#include "../rmlibcw/include/rmlibcw.h"#include "../emhwlib_hal/pll/include/pll_hal.h"#include "common.h"#include "play_capture_common.h"//#include "play_capture_main.h"#include "play_capture_video.h"struct capsam_video_instance {	// Access	struct dcc_context *dcc_info;	struct capsam_video_config Setup;		// State	RMuint32 STCTimerNumber;	struct display_cmdline *disp_opt;  // options for the video output setup ((used because code in apply_display_options should not be duplicated)	struct DCCVideoSource *pVideoSource;};// STC open and start (local function)static RMstatus capsam_video_init_start_STC(	struct dcc_context *dcc_info, 	RMuint32 TimerNumber){	RMstatus err;		RMDBGLOG((FUNCNAME, "%s\n",__func__));		if (! dcc_info->pStcSource) {		struct DCCStcProfile stc_profile;				// open first stc module		stc_profile.STCID = TimerNumber;		stc_profile.master = Master_STC;				stc_profile.stc_timer_id = 3 * TimerNumber;		stc_profile.stc_time_resolution = 90000;				stc_profile.video_timer_id = 3 * TimerNumber + 1;		stc_profile.video_time_resolution = 90000;		stc_profile.video_offset = 0;				stc_profile.audio_timer_id = 3 * TimerNumber + 2;		stc_profile.audio_time_resolution = 90000;		stc_profile.audio_offset = 0;		err = DCCSTCOpen(dcc_info->pDCC, &stc_profile, &(dcc_info->pStcSource));		if (RMFAILED(err)) {			fprintf(stderr, "Cannot open stc module: %s\n", RMstatusToString(err));			return RM_ERROR;		}	}		DCCSTCSetTime(dcc_info->pStcSource, 0, 90000);	DCCSTCPlay(dcc_info->pStcSource);		return RM_OK;}// STC stop (local function)static RMstatus capsam_video_stop_STC(	struct dcc_context *dcc_info){	RMstatus err = RM_OK;		if (dcc_info->pStcSource) {		err = DCCSTCStop(dcc_info->pStcSource);		dcc_info->pStcSource = NULL;	}		return err;}/* create the video instance */RMstatus capsam_video_open(	struct dcc_context *dcc_info, 	RMuint32 STCTimerNumber,  // STC timer to be used	struct display_cmdline *disp_opt,  // optional reference to the app's disp_opt, to set up the output	struct capture_cmdline *capture_opt,	struct capsam_video_instance **ppVideo){	RMstatus err = RM_OK;	struct capsam_video_instance *pVideo;		RMDBGLOG((FUNCNAME, "%s\n",__func__));		// Sanity checks	if (ppVideo == NULL) return RM_FATALINVALIDPOINTER;	*ppVideo = NULL;	if (dcc_info == NULL) return RM_FATALINVALIDPOINTER;		// Allocate and clear local instance	pVideo = (struct capsam_video_instance *)RMMalloc(sizeof(struct capsam_video_instance));	if (pVideo == NULL) {		fprintf(stderr, "FATAL! Not enough memory for struct capsam_video_instance!\n");		return RM_FATALOUTOFMEMORY;	}	RMMemset(pVideo, 0, sizeof(struct capsam_video_instance));	*ppVideo = pVideo;		// Set default and non-zero startup values	pVideo->dcc_info = dcc_info;	pVideo->disp_opt = disp_opt;  // reference, can be NULL	pVideo->STCTimerNumber = STCTimerNumber;	pVideo->Setup.TVStandard = capture_opt->TVStandard;	pVideo->Setup.InputColorSpace = capture_opt->InputColorSpace;	pVideo->Setup.SurfaceColorSpace = capture_opt->SurfaceColorSpace;	pVideo->Setup.SamplingMode = capture_opt-> SamplingMode;	pVideo->Setup.ColorMode = capture_opt->ColorMode;	pVideo->Setup.InputColorFormat = capture_opt->InputColorFormat;	pVideo->Setup.PictureAspectRatio.X  = capture_opt->PictureAspectRatio.X; 	pVideo->Setup.PictureAspectRatio.Y  = capture_opt->PictureAspectRatio.Y; 	pVideo->Setup.InputModuleID = capture_opt->InputModuleID;	pVideo->Setup.DigitalTimingSignal = capture_opt->DigitalTimingSignal;	pVideo->Setup.UseVideoValid = capture_opt->UseVideoValid;	pVideo->Setup.bussize = capture_opt->bussize;	pVideo->Setup.override.ColorFormat = capture_opt->override.ColorFormat;	pVideo->Setup.zoom_x = ZOOM_0;	pVideo->Setup.zoom_y = ZOOM_0;	pVideo->Setup.zoom_w = ZOOM_1;	pVideo->Setup.zoom_h = ZOOM_1;	pVideo->Setup.zoomstep = 1;	pVideo->Setup.output_window = (struct EMhwlibDisplayWindow*)RMMalloc(sizeof(struct EMhwlibDisplayWindow));	set_default_out_window(pVideo->Setup.output_window);	pVideo->Setup.overscan_crop_amount = 5;	pVideo->Setup.active_format = disp_opt->active_format;	err = capsam_video_init_start_STC(pVideo->dcc_info, pVideo->STCTimerNumber);	return err;}/* destroy the video instance, close open chips */RMstatus capsam_video_close(	struct capsam_video_instance *pVideo){	RMstatus err = RM_OK;		RMDBGLOG((FUNCNAME, "%s\n",__func__));		// Sanity checks	if (pVideo == NULL) return RM_OK;  // already closed		// Free all available ressources	if (pVideo->disp_opt != NULL) {		err = capsam_video_stop_passthrough(pVideo);	} else {		err = capsam_video_stop_capture(pVideo);	}		err = capsam_video_stop_STC(pVideo->dcc_info);	if(pVideo->Setup.output_window){		RMFree(pVideo->Setup.output_window);	}		RMFree(pVideo);		return err;}RMstatus capsam_video_get_config(struct capsam_video_instance *pVideo,			      struct capsam_video_config *pSetup){	RMDBGLOG((FUNCNAME, "%s\n",__func__));	// Sanity checks	if (pVideo == NULL) return RM_FATALINVALIDPOINTER;	if (pSetup == NULL) return RM_FATALINVALIDPOINTER;		*pSetup = pVideo->Setup;  // copy		return RM_OK;}/* provide setup info to the video capture */RMstatus capsam_video_set_config(	struct capsam_video_instance *pVideo, 	struct capsam_video_config *pSetup)  // necessary info for the video capture{	RMDBGLOG((FUNCNAME, "%s\n",__func__));	// Sanity checks	if (pVideo == NULL) return RM_FATALINVALIDPOINTER;	if (pSetup == NULL) return RM_FATALINVALIDPOINTER;		pVideo->Setup = *pSetup;  // copy		return RM_OK;}/* helper function to reduce an aspect ratio */void capsam_video_reduce_aspect_ratio(	RMuint32 *X, 	RMuint32 *Y, 	RMuint32 boundary){	RMuint32 num, den, mod, max;		if (*X && *Y) {		num = *X;		den = *Y;		while ((mod = num % den) > 0) {			num = den;			den = mod;		}		(*X) /= den;		(*Y) /= den;		if (boundary) {			max = RMmax(*X, *Y);			if (max > boundary) {				den = (max + boundary - 1) / boundary;				*X /= den;				*Y /= den;			}		}	}}/* helper function, returns frame size and interlaced status */RMstatus capsam_video_get_frame_size(	struct capsam_video_instance *pVideo, 	enum EMhwlibTVStandard standard,	RMuint32 *x_size,	RMuint32 *y_size, 	RMbool *interlaced){	RMstatus err;	struct EMhwlibTVFormatDigital format;	RMDBGLOG((FUNCNAME, "%s\n",__func__));			// Sanity checks	if (pVideo == NULL) return RM_FATALINVALIDPOINTER;		err = RUAExchangeProperty(pVideo->dcc_info->pRUA, DisplayBlock, 		RMDisplayBlockPropertyID_TVFormatDigital, 		&standard, sizeof(standard), 		&format, sizeof(format));	if (RMSUCCEEDED(err)) {		if (interlaced) *interlaced = format.TopFieldHeight ? TRUE : FALSE;		if (x_size) *x_size = format.ActiveWidth;		if (y_size) {			*y_size = format.ActiveHeight;			if (format.TopFieldHeight) *y_size += format.ActiveHeight - format.YOffsetBottom + format.YOffsetTop;		}	}		return err;}/* helper function, returns the inherent aspect ratio of a video mode */RMstatus capsam_video_get_aspect_ratio_from_video_mode(	enum EMhwlibTVStandard TVStandard, 	struct EMhwlibTVFormatDigital *pTVFormat, 	RMbool wide,  // ambiguous modes (SDTV,EDTV): FALSE=4:3, TRUE=16:9 anamorphic	RMuint32 *asp_x, 	RMuint32 *asp_y){	RMDBGLOG((FUNCNAME, "%s\n",__func__));		if ((asp_x == NULL) || (asp_y == NULL)) return RM_FATALINVALIDPOINTER;		// determine aspect ratio from video mode	switch (TVStandard) {	case EMhwlibTVStandard_Custom:		if (pTVFormat) {			*asp_x = pTVFormat->ActiveWidth;			*asp_y = pTVFormat->ActiveHeight;			capsam_video_reduce_aspect_ratio(asp_x, asp_y, 0);		} else {			*asp_x = 4;			*asp_y = 3;		}		break;	case EMhwlibTVStandard_HDMI_720p59: 	case EMhwlibTVStandard_HDMI_720p60: 	case EMhwlibTVStandard_HDMI_1080i59: 	case EMhwlibTVStandard_HDMI_1080i60: 	case EMhwlibTVStandard_HDMI_1080p59: 	case EMhwlibTVStandard_HDMI_1080p60: 	case EMhwlibTVStandard_HDMI_720p50: 	case EMhwlibTVStandard_HDMI_1080i50: 	case EMhwlibTVStandard_HDMI_1080p50: 

⌨️ 快捷键说明

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