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

📄 process_key.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
#define ALLOW_OS_CODE 1#include "../rua/include/rua.h"#include "../dcc/include/dcc.h"#include "../emhwlib_hal/pll/include/pll_hal.h"#include "common.h"#include "command_ids.h"#include "get_key.h"#include "sample_os.h"#include "dvi_hdmi.h"#ifdef WITH_TIME_SHIFT#include <pthread.h>#include "play_vdemux.h"#endif#define MAX_SPEED 64#define VOLUME_0DB		0x10000000#define VOLUME_INDEX_0DB	49extern RMbool manutest;#if 0#define MULTIDECODERDBG ENABLE#else#define MULTIDECODERDBG DISABLE#endifextern int verbose_stdout;extern int verbose_stderr;static RMuint32 VolumeTable[VOLUME_INDEX_0DB+1+24] = {	0x00000000,								// mute	0x00100000, 0x0011f59c, 0x001428a4, 0x0016a09f, 0x001965ff, 0x001c823e, // -48dB ... -43dB	0x00200000, 0x0023eb35, 0x00285145, 0x002d413c, 0x0032cbfc, 0x0039047b, // -42dB ... -37dB	0x00400000, 0x0047d66a, 0x0050a28b, 0x005a8279, 0x006597fa, 0x007208f8, // -36dB ... -31dB	0x00800000, 0x008facd6, 0x00a14518, 0x00b504f3, 0x00cb2ff5, 0x00e411f0, // -30dB ... -25dB	0x01000000, 0x011f59ac, 0x01428a2f, 0x016a09e6, 0x01965fea, 0x01c823e0, // -24dB ... -19dB	0x02000000, 0x023eb358, 0x0285145f, 0x02d413cd, 0x032cbfd5, 0x039047c1, // -18dB ... -13dB	0x04000000, 0x047d66b1, 0x050a28be, 0x05a82799, 0x06597fa9, 0x07208f82, // -12dB ...  -7dB	0x08000000, 0x08facd62, 0x0a14517d, 0x0b504f34, 0x0cb2ff53, 0x0e411f04, //  -6dB ...  -1dB	0x10000000, 0x11f59ac4, 0x1428a2fa, 0x16a09e67, 0x1965fea6, 0x1c823e08, //   0dB ...   5dB	0x20000000, 0x23eb3589, 0x285145f5, 0x2d413ccf, 0x32cbfd4c, 0x39047c10, //   6dB ...  11dB	0x40000000, 0x47d66b10, 0x50a28be7, 0x5a82799a, 0x6597fa95, 0x7208f81d, //  12dB ...  17dB	0x80000000, 0x8facd61c, 0xa14517c9, 0xb504f32f, 0xcb2ff523, 0xe411f032, //  18dB ...  23dB	0xffffffff  // ~24dB};static void PGCD(RMint32 *N, RMuint32 *M){ 	RMuint32 num, den, mod;	/* compute PGCD */	num = *N;	den = *M;	while ((mod=num%den) > 0) {		num = den;		den = mod;	}		/* reduce in an exact way first */	*N /= den;	*M /= den;}static RMint32 ppm = 0;struct VideoMode {	RMuint32 PixelClock;	RMuint32 HActive;	RMuint32 HFrontPorch;	RMuint32 HSyncWidth;	RMuint32 HBackPorch;	RMbool HSyncPolarity;  /* TRUE: positive, FALSE: negative */	RMuint32 VActive;	RMuint32 VFrontPorch;	RMuint32 VSyncWidth;	RMuint32 VBackPorch;	RMbool VSyncPolarity;  /* TRUE: positive, FALSE: negative */	RMbool Interlaced;	enum EMhwlibColorSpace dig_color_space;	enum EMhwlibDigitalTimingSignal dig_timing;	RMuint32 dig_bus_size;	enum EMhwlibColorSpace analog_color_space;};static RMstatus GetVideoModeStructFromEmhwlibDigitalFormat(	struct EMhwlibTVFormatDigital *format_dig, 	struct VideoMode *pVidMode){	if ((pVidMode == NULL) || (format_dig == NULL)) {		return RM_ERROR;	}	pVidMode->PixelClock = format_dig->PixelClock;	pVidMode->HActive = format_dig->ActiveWidth;	pVidMode->VActive = format_dig->ActiveHeight;	pVidMode->HSyncWidth = format_dig->HSyncWidth;	pVidMode->VSyncWidth = format_dig->VSyncWidth / 2;	pVidMode->HBackPorch = format_dig->XOffset - pVidMode->HSyncWidth;	pVidMode->VBackPorch = format_dig->YOffsetTop - pVidMode->VSyncWidth;	pVidMode->Interlaced = format_dig->TopFieldHeight ? TRUE : FALSE;	pVidMode->HFrontPorch = format_dig->HTotalSize - pVidMode->HActive - pVidMode->HBackPorch - pVidMode->HSyncWidth;	pVidMode->VFrontPorch = (pVidMode->Interlaced ? format_dig->VTotalSize / 2 : format_dig->VTotalSize) - pVidMode->VActive - pVidMode->VBackPorch - pVidMode->VSyncWidth;	pVidMode->HSyncPolarity = ! format_dig->HSyncActiveLow;	pVidMode->VSyncPolarity = ! format_dig->VSyncActiveLow;	return RM_OK;}static RMstatus GetEmhwlibDigitalFormatFromVideoModeStruct(	struct VideoMode *pVidMode,	struct EMhwlibTVFormatDigital *format_dig){	if ((pVidMode == NULL) || (format_dig == NULL)) {		return RM_ERROR;	}	format_dig->PixelClock = pVidMode->PixelClock;	format_dig->ActiveWidth = pVidMode->HActive;	format_dig->ActiveHeight = pVidMode->VActive;	format_dig->XOffset = pVidMode->HSyncWidth + pVidMode->HBackPorch;	format_dig->YOffsetTop = pVidMode->VSyncWidth + pVidMode->VBackPorch;	format_dig->YOffsetBottom = (pVidMode->Interlaced) ? format_dig->YOffsetTop : 0;;	format_dig->VSyncActiveLow = ! pVidMode->VSyncPolarity;	format_dig->HSyncActiveLow = ! pVidMode->HSyncPolarity;	format_dig->HTotalSize = pVidMode->HActive + pVidMode->HFrontPorch + pVidMode->HSyncWidth + pVidMode->HBackPorch;	format_dig->VTotalSize = pVidMode->VActive + pVidMode->VFrontPorch + pVidMode->VSyncWidth + pVidMode->VBackPorch;	if (pVidMode->Interlaced) format_dig->VTotalSize = format_dig->VTotalSize * 2 + 1;	format_dig->TopFieldHeight = (pVidMode->Interlaced) ? format_dig->VTotalSize : 0;	format_dig->HSyncWidth = pVidMode->HSyncWidth;	format_dig->VSyncWidth = pVidMode->VSyncWidth * 2;	format_dig->VSyncFineAdjust = 0;	format_dig->ColorSpace = EMhwlibColorSpace_RGB_0_255;	format_dig->TrailingEdge = FALSE;	format_dig->VSyncDelay1PixClk = FALSE;	format_dig->Progressive = ! pVidMode->Interlaced;	format_dig->HDTVMode = TRUE;	format_dig->VbiStandard = EMhwlibVbiStandard_Custom;	return RM_OK;}static RMstatus GetEmhwlibAnalogFormatFromVideoModeStruct(	struct VideoMode *pVidMode,	struct EMhwlibTVFormatAnalog *format_analog){	if ((pVidMode == NULL) || (format_analog == NULL)) {		return RM_ERROR;	}	format_analog->PixelClock = pVidMode->PixelClock;	format_analog->ActiveWidth = pVidMode->HActive;	format_analog->ActiveHeight = pVidMode->VActive;	format_analog->XOffset = pVidMode->HSyncWidth + pVidMode->HBackPorch;	format_analog->YOffsetTop = pVidMode->VSyncWidth + pVidMode->VBackPorch;	format_analog->YOffsetBottom = (pVidMode->Interlaced) ? format_analog->YOffsetTop : 0;	format_analog->VSyncActiveLow = ! pVidMode->VSyncPolarity;	format_analog->HSyncActiveLow = ! pVidMode->HSyncPolarity;	format_analog->Width = pVidMode->HActive + pVidMode->HFrontPorch + pVidMode->HSyncWidth + pVidMode->HBackPorch;	format_analog->Height = pVidMode->VActive + pVidMode->VFrontPorch + pVidMode->VSyncWidth + pVidMode->VBackPorch;	if (pVidMode->Interlaced) format_analog->Height = format_analog->Height * 2 + 1;	format_analog->ColorSpace = EMhwlibColorSpace_RGB_0_255;	format_analog->Progressive = ! pVidMode->Interlaced;	format_analog->ComponentMode = EMhwlibComponentMode_RGB_SCART;	format_analog->CompositeMode = EMhwlibCompositeMode_Disable;	format_analog->HDTVMode = TRUE;	format_analog->VbiStandard = EMhwlibVbiStandard_Custom;	format_analog->HDSyncDown = TRUE;	format_analog->OversampledInput = FALSE;	format_analog->ChromaFilter = EMhwlibChromaFilter_3_25_MHz;	format_analog->LumaFilter = EMhwlibLumaFilter_6_5_MHz;	format_analog->SyncOnPbPr = FALSE;	format_analog->Pedestal = FALSE;	format_analog->HSync0 = format_analog->HSyncActiveLow ? 0 : pVidMode->HSyncWidth;	format_analog->HSync1 = format_analog->HSyncActiveLow ? pVidMode->HSyncWidth : 0;	format_analog->VSyncO0Line = format_analog->VSyncActiveLow ? 0 : pVidMode->VSyncWidth;	format_analog->VSyncO0Pixel = format_analog->HSync0;	format_analog->VSyncO1Line = format_analog->VSyncActiveLow ? pVidMode->VSyncWidth : 0;	format_analog->VSyncO1Pixel = format_analog->HSync1;	if (pVidMode->Interlaced) {		format_analog->VSyncE0Line = format_analog->Height / 2 + (format_analog->VSyncActiveLow ? 0 : pVidMode->VSyncWidth);		format_analog->VSyncE0Pixel = format_analog->Width / 2 + format_analog->HSync0;		format_analog->VSyncE1Line = format_analog->Height / 2 + (format_analog->VSyncActiveLow ? pVidMode->VSyncWidth : 0);		format_analog->VSyncE1Pixel = format_analog->Width / 2 + format_analog->HSync1;	} else {		format_analog->VSyncE0Line = 0;		format_analog->VSyncE0Pixel = 0;		format_analog->VSyncE1Line = 0;		format_analog->VSyncE1Pixel = 0;	}	format_analog->HDHSyncWidth = pVidMode->HSyncWidth;	format_analog->HDVSyncWidth = 0;	format_analog->HDVSyncStart = 0;	return RM_OK;}static RMstatus get_current_video_mode(struct dcc_context *dcc_info, struct VideoMode *pVidMode){	RMstatus err;	struct EMhwlibTVFormatDigital format_digital;		if (! pVidMode) return RM_ERROR;		err = RUAGetProperty(dcc_info->pRUA, DispDigitalOut, 		RMGenericPropertyID_DigitalTVFormat, &format_digital, sizeof(format_digital));	if (RMFAILED(err)) {		fprintf(stderr, "Failed to get property TVFormat\n");	}		GetVideoModeStructFromEmhwlibDigitalFormat(&format_digital, pVidMode);		err = RUAGetProperty(dcc_info->pRUA, DispDigitalOut, 		RMGenericPropertyID_ColorSpace, &(pVidMode->dig_color_space), sizeof(pVidMode->dig_color_space));	err = RUAGetProperty(dcc_info->pRUA, DispDigitalOut, 		RMDispDigitalOutPropertyID_TimingSignal, &(pVidMode->dig_timing), sizeof(pVidMode->dig_timing));	err = RUAGetProperty(dcc_info->pRUA, DispDigitalOut, 		RMDispDigitalOutPropertyID_BusSize, &(pVidMode->dig_bus_size), sizeof(pVidMode->dig_bus_size));	err = RUAGetProperty(dcc_info->pRUA, DispMainAnalogOut, 		RMGenericPropertyID_ColorSpace, &(pVidMode->analog_color_space), sizeof(pVidMode->analog_color_space));		return RM_OK;}static RMstatus set_modifyed_video_mode(struct dcc_context *dcc_info, struct VideoMode *pVidMode){	RMstatus err;	struct EMhwlibTVFormatDigital format_digital;	struct EMhwlibTVFormatAnalog format_analog;		if (RMFAILED(err = GetEmhwlibDigitalFormatFromVideoModeStruct(pVidMode, &format_digital)))		return err;	if (RMFAILED(err = GetEmhwlibAnalogFormatFromVideoModeStruct(pVidMode, &format_analog)))		return err;		err = DCCSetTVFormat(dcc_info->pDCC, dcc_info->route, &format_digital, &format_analog);	if (RMFAILED(err)) return err;		while ((err = RUASetProperty(dcc_info->pRUA, DispDigitalOut, RMGenericPropertyID_ColorSpace, &(pVidMode->dig_color_space), sizeof(pVidMode->dig_color_space), 0)) == RM_PENDING);	while ((err = RUASetProperty(dcc_info->pRUA, DispDigitalOut, RMDispDigitalOutPropertyID_TimingSignal, &(pVidMode->dig_timing), sizeof(pVidMode->dig_timing), 0)) == RM_PENDING);	while ((err = RUASetProperty(dcc_info->pRUA, DispDigitalOut, RMDispDigitalOutPropertyID_BusSize, &(pVidMode->dig_bus_size), sizeof(pVidMode->dig_bus_size), 0)) == RM_PENDING);	while ((err = RUASetProperty(dcc_info->pRUA, DispDigitalOut, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING);	while ((err = RUASetProperty(dcc_info->pRUA, DispMainAnalogOut, RMGenericPropertyID_ColorSpace, &(pVidMode->analog_color_space), sizeof(pVidMode->analog_color_space), 0)) == RM_PENDING);	while ((err = RUASetProperty(dcc_info->pRUA, DispMainAnalogOut, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING);#ifdef RMFEATURE_HAS_COMPONENT_OUT	while ((err = RUASetProperty(dcc_info->pRUA, DispComponentOut, RMGenericPropertyID_ColorSpace, &(pVidMode->analog_color_space), sizeof(pVidMode->analog_color_space), 0)) == RM_PENDING);	while ((err = RUASetProperty(dcc_info->pRUA, DispComponentOut, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING);#endif		return RM_OK;}void set_default_out_window(struct EMhwlibDisplayWindow *window) {	window->X = 2048;	window->Y = 2048;	window->Width = 4096;	window->Height = 4096;	window->XPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToCenter;	window->YPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToCenter;	window->XMode = EMhwlibDisplayWindowValueMode_Relative;	window->YMode = EMhwlibDisplayWindowValueMode_Relative;	window->WidthMode = EMhwlibDisplayWindowValueMode_Relative;	window->HeightMode = EMhwlibDisplayWindowValueMode_Relative;}//------------------------------------------------------------------------------//	Keyboard layout//------------------------------------------------------------------------------// 	0 = Enable output//	1 =	Half size// 	2 = Move scaler//	3 = Decrease size//	4 = Move scaler//	5 = Video/OSD switch//	6 = Move scaler//	7 = Full size//	8 = Move scaler//	9 = Increase size//	+ = Increase speed//	- = Decrease speed//	= = Set speed//	[ = Backward I-Frame//	] = Forward I-Frame//	< = Dec aud playback speed//	> = Inc aud playback speed//	| = print STC drift information//	A = SPI Video stream change		a = cycle Audio stream change//	B = Increase brightness			b = Decrease brightness//	C = Increase contrast			c = Decrease contrast//	D = Prev Chapter			d = Dump OSD info//	E = Dualmode toggle			e =//	F = 					f = Seek//	G = Cycle Subtitle			g = Debug read/write/freq//	H = Increase hue			h = Decrease hue//	I = I2C debug access			i = SPI PAT info//	J =					j =//	K = switch between spi & file playback	k = SPI channel change//	L =					l = Change audio//	M = Video mode				m = SPI PMT change//	N = Next track				n = Next picture//	O =					o =//	P = Previous track			p = Play//	Q =					q = quit//	R =					r = Rotate picture//	S = Next Chapter			s = Stop//	T = Increase saturation			t = Decrease saturation//	U =					u =//	V = Increase volume			v = Decrease volume//	W = Non-linear level			w = Non-linear width//	X = Change video			x = Toggle Video output on/off//	Y = Display Info			y = Manu test (?!?)//	Z =	debug vsync time diff				z = Stop//	  = Pause//------------------------------------------------------------------------------void display_key_usage(RMuint32 keyflags){ 	if (verbose_stderr == 0) 		return; 	fprintf(stderr, "Commands: (press enter to validate a command)\n");	fprintf(stderr, "  q: Quit\n");		if (keyflags & SET_KEY_PLAYBACK) 		fprintf(stderr, 			"  s,z - Stop, p - Play, <space> - Pause, n - Next picture (after PAUSE only) \n"			"  + increase speed, - decrease speed, = set speed\n"			"  ] Forward I-frame 1x, [ Backward I-frame 1x, R rewind (if supported, adjust speed with +/-)\n"			"  f: seek (if supported)\n");		if (keyflags & SET_KEY_DISPLAY)		fprintf(stderr, 			"  c: decrease contrast - C: increase contrast\n"			"  b: decrease brightness - B: increase brightness\n"			"  t: decrease saturation - T: increase saturation\n"			"  h: decrease hue - H: increase hue\n"

⌨️ 快捷键说明

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