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

📄 watermark.c

📁 Sigma SMP8634 Mrua v. 2.8.2.0
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * * Copyright (c) Sigma Designs, Inc. 2002. All rights reserved. * *//**	@file dcc_demo.c	@brief sample application to access the Mambo chip and test DMA transfers		@author Julien Soulier   	@ingroup dccsamplecode*//*  ****************************************************************************************  This file is part of libsamples library, therefore no static variables should be defined  *****************************************************************************************/#include "../../samples/sample_os.h"//#define SEND_IBC#define ALLOW_OS_CODE 1#include "../../dcc/include/dcc.h"#include "../../rmlibcw/include/rmfile.h"#include "../../samples/common.h"#include "../filters/bridge/include/ppf_bridge.h"#include "../include/rmppf.h"#define COMMON_TIMEOUT_US    (TIMEOUT_10MS)#define DMA_BUFFER_SIZE_LOG2 15#define DMA_BUFFER_COUNT     32#define REPACK_SIZE (4096)#define VIDEO_FIFO_SIZE (1024*1024)#define XFER_FIFO_COUNT (1024) // 32#define KEYFLAGS (SET_KEY_DISPLAY | SET_KEY_PLAYBACK | SET_KEY_DEBUG)#define ALLOW_OS_CODE 1#define MAXHEADERSIZE 4095#define RM_DEVICES_STC 0x1#define RM_DEVICES_VIDEO 0x2#define DEBUG	ENABLE#define START_IN_IFRAME_MODE 0#ifdef	SEND_IBC#define HARDCODE_BYTECOUNT	0x100000#endif#if 0#define SENDDBG ENABLE#else#define SENDDBG DISABLE#endif#define ENABLE_MONITOR 0#define FORCE_IFRAME_FWD_COMMAND 1/* 0 the decoder will remember the seqHeader,    1 we must store it locally and resend it (trickmodes not supported) */#define STORE_SEQ_HEADER_LOCALLY 0 RMuint32 output1_surface_addr, output2_surface_addr, input_surface_addr, filter_slot = 0;struct RMppf *pppf;struct video_context {	struct RUABufferPool *pDMA;	RMbool FirstSystemTimeStamp;	RMuint32 FirstPTS;	struct dcc_context *dcc_info;	struct RM_PSM_Context *PSMcontext;	RMfile f_bitstream;	RMint64 fileSize;	RMbool video_decoder_initialized;	RMbool initVideo;	RMbool trickMode;	RMbool iframeMode;	RMbool ResyncTimer;	RMuint64 lastSTC;	RMuint64 lastVideoPTS;	RMuint64 lastDecoded;	RMbool highSpeedIFrameMode;	RMuint32 highSpeedIFrameSpeed;	RMuint32 prebuf_level;	RMuint32 byte_counter;	RMbool monitor;	RMuint32 bitrate;	RMuint64 meanBitrate;	RMuint32 meanCount;	RMuint64 last_video_pts;	RMuint32 NTimes;	struct timeval last;	struct playback_cmdline *play_opt;	struct video_cmdline *video_opt;#ifndef WITH_MONO	struct display_cmdline *disp_opt;#endif};#define GET_DATA_FIFO_INFO(pRUA, ModuleId)				\	{								\		struct DataFIFOInfo DataFIFOInfo;			\		RMreal fullness;					\		RUAGetProperty(pRUA, ModuleId, RMGenericPropertyID_DataFIFOInfo, &DataFIFOInfo, sizeof(DataFIFOInfo)); \		fullness = (RMreal)((100./DataFIFOInfo.Size)*DataFIFOInfo.Readable); \		fprintf(stderr, "Data %lx: st=%08lx sz=%ld wr=%ld rd=%ld --> f : %.02f\n", ModuleId, DataFIFOInfo.StartAddress,	\			DataFIFOInfo.Size, DataFIFOInfo.Writable,  DataFIFOInfo.Readable, fullness); \	}								\#define GET_XFER_FIFO_INFO(pRUA, ModuleId)				\	{								\		struct XferFIFOInfo_type XferFIFOInfo;			\		RMreal fullness;					\		RUAGetProperty(pRUA, ModuleId, RMGenericPropertyID_XferFIFOInfo, &XferFIFOInfo, sizeof(XferFIFOInfo)); \		fullness = (RMreal)((100./XferFIFOInfo.Size)*XferFIFOInfo.Readable); \		fprintf(stderr, "XFER %lx: st=%08lx sz=%ld wr=%ld rd=%ld er=%lx --> f : %.02f	\n", ModuleId, XferFIFOInfo.StartAddress, \			XferFIFOInfo.Size, XferFIFOInfo.Writable,  XferFIFOInfo.Readable, XferFIFOInfo.Erasable, fullness); \	}#define MONITOR_INTERVAL_US 250000static void monitor(struct video_context *context, RMbool alwaysShow){		/* the bitrate reading of this probe is accurate only if the blocking call is RUASendData */	struct timeval now;		static int first = 1;	RMuint64 elapsed; 		RMuint64 ptime; 		struct dcc_context *dcc_info = context->dcc_info;	gettimeofday(&now, NULL);	elapsed = (now.tv_sec - context->last.tv_sec) * 1000000;			elapsed += (now.tv_usec - context->last.tv_usec);	if (elapsed > MONITOR_INTERVAL_US || first || alwaysShow){		RMuint64 bitrate = (RMuint64)context->bitrate * 1000000;		bitrate /= elapsed;		context->meanBitrate += bitrate;		context->meanCount++;		DCCSTCGetTime(dcc_info->pStcSource, &ptime, 90000);					fprintf(stderr, "\n*****************************\n");					fprintf(stderr, "STC = %llu (%llu secs)\n", ptime, (ptime/90000));		/* sample code to get fifo info */		fprintf(stderr, "Video :\n"); 					GET_DATA_FIFO_INFO(dcc_info->pRUA, dcc_info->video_decoder);		GET_XFER_FIFO_INFO(dcc_info->pRUA, dcc_info->video_decoder);					fprintf(stderr, "bitrate: mean %llu bit/sec, pseudo-instantaneus %llu bit/sec (%lu bytes/%llu us)\n", 			context->meanBitrate / context->meanCount,			bitrate, 			context->bitrate >> 3, 			elapsed);		fprintf(stderr, "*****************************\n");					gettimeofday(&context->last, NULL);		first = 0;		context->bitrate = 0;		fflush(stderr);			}					        	return;}static RMuint32 trickBuffersToSend = 0;static RMuint32 trickSizeToSend = 0;static RMuint32 trickBuffersSent = 0;static struct RM_PSM_Actions actions;#define PROCESS_KEY(release, getkey)					\do	{								\		RMDBGLOG((DISABLE, "process_key\n"));			\		if (getkey) {						\		        FSMstate = RM_PSM_GetState(context.PSMcontext, &(context.dcc_info));			\                        if ((FSMstate == RM_PSM_Stopped) || (FSMstate == RM_PSM_Paused)) {			\			        switch (context.play_opt->disk_ctrl_state) {						\			        case DISK_CONTROL_STATE_DISABLE:						\			        case DISK_CONTROL_STATE_SLEEPING:						\				        break;									\			        case DISK_CONTROL_STATE_RUNNING:						\						if(context.play_opt->disk_ctrl_callback && context.play_opt->disk_ctrl_callback(DISK_CONTROL_ACTION_SLEEP) == RM_OK) \					        context.play_opt->disk_ctrl_state = DISK_CONTROL_STATE_SLEEPING;	\				        break;									\			        }										\		        }						\			err = process_command(context.PSMcontext, &(context.dcc_info), &actions); \			if (RMFAILED(err)) {				\				fprintf(stderr, "Error while processing key %d\n", err); \				goto cleanup;				\			}						\		}							\		if (((RM_PSM_GetState(context.PSMcontext, &(context.dcc_info)) == RM_PSM_Slow) || \		     (RM_PSM_GetState(context.PSMcontext, &(context.dcc_info)) == RM_PSM_Fast) || \		     (RM_PSM_GetState(context.PSMcontext, &(context.dcc_info)) == RM_PSM_NextPic)) && \		    (actions.cmdProcessed) && (!context.trickMode)) {	\			RMDBGLOG((ENABLE, ">> trick mode\n"));		\			if (release) {					\				RUAReleaseBuffer(pDMA, buf);		\				buf = NULL;				\			}						\			context.trickMode = TRUE;			\			context.FirstSystemTimeStamp = TRUE;		\		}							\		if (actions.toDoActions & RM_PSM_FLUSH_VIDEO) {		\			RMDBGLOG((ENABLE, "flushVIDEO\n"));		\			Stop(&context, RM_DEVICES_VIDEO);		\			context.video_decoder_initialized = FALSE;	\			context.initVideo = TRUE;			\			actions.toDoActions &= ~RM_PSM_FLUSH_VIDEO;	\		}							\		if (actions.toDoActions & RM_PSM_FIRST_PTS) {		\			RMDBGLOG((ENABLE, "firstPTS\n"));		\			context.FirstSystemTimeStamp = TRUE;		\			actions.toDoActions &= ~RM_PSM_FIRST_PTS;	\		}							\		if (actions.toDoActions & RM_PSM_RESYNC_TIMER) {	\			RMDBGLOG((ENABLE, "resyncTimer\n"));		\			context.ResyncTimer = TRUE;			\			actions.toDoActions &= ~RM_PSM_RESYNC_TIMER;	\		}							\		if (actions.performedActions & RM_PSM_VIDEO_STOPPED) {	\			RMDBGLOG((ENABLE, "video stopped\n"));		\			context.video_decoder_initialized = FALSE;	\			context.initVideo = TRUE;			\			actions.performedActions &= ~RM_PSM_VIDEO_STOPPED; \			/* needed for no dram copy version on standalone */ \			err = RUAResetPool(pDMA);			\			if (RMFAILED(err)) {				\				RMDBGLOG((ENABLE, "Error cannot reset dmapool\n")); \				goto cleanup;				\			}						\		}							\		if (actions.performedActions & RM_PSM_STC_STOPPED) {	\			RMDBGLOG((ENABLE, "stc stopped\n"));		\			actions.performedActions &= ~RM_PSM_STC_STOPPED; \		}							\		if (actions.toDoActions & RM_PSM_DEMUX_IFRAME) {	\			RMDBGLOG((ENABLE, "demuxIFrame\n"));		\			Play(&context, RM_DEVICES_VIDEO, DCCVideoPlayIFrame); \			context.iframeMode = TRUE;			\			actions.toDoActions &= ~RM_PSM_DEMUX_IFRAME;	\		}							\		if (actions.toDoActions & RM_PSM_DEMUX_NORMAL) {	\			RMDBGLOG((ENABLE, "demuxNormal\n"));		\			context.iframeMode = FALSE;			\			RMDBGLOG((ENABLE, "flushing fifos\n")); \			Stop(&context, RM_DEVICES_VIDEO);		\			Play(&context, RM_DEVICES_VIDEO, DCCVideoPlayFwd); \			context.highSpeedIFrameMode = FALSE;		\			actions.toDoActions &= ~RM_PSM_DEMUX_NORMAL;	\		}							\		if ((RM_PSM_GetState(context.PSMcontext, &(context.dcc_info)) == RM_PSM_Playing) && \		    (context.trickMode))	{			\			RMDBGLOG((ENABLE, "got play after trickmode\n")); \			if (release) {					\				RUAReleaseBuffer(pDMA, buf);		\				buf = NULL;				\			}						\			context.trickMode = FALSE;			\		}							\		if ((RM_PSM_GetState(context.PSMcontext, &(context.dcc_info)) == RM_PSM_Stopped) && (actions.cmdProcessed)) { \			RMDBGLOG((ENABLE,"Got stop command\n"));	\			if (release) {					\				RUAReleaseBuffer(pDMA, buf);		\				buf = NULL;				\			}						\			context.trickMode = FALSE;			\			context.iframeMode = FALSE;			\			context.highSpeedIFrameMode = FALSE;		\			context.video_decoder_initialized = FALSE;	\			context.initVideo = TRUE;			\			context.byte_counter = 0;			\			goto mainloop_no_seek;				\		}							\		if ((actions.cmd == RM_QUIT) && (!actions.cmdProcessed)) { \			RMDBGLOG((ENABLE, "Got quit command\n"));	\			if (release) {					\				RUAReleaseBuffer(pDMA, buf);		\				buf = NULL;				\			}						\			goto cleanup;					\		}							\		if ((actions.cmd == RM_STOP_SEEK_ZERO) && (!actions.cmdProcessed)) { \			RMDBGLOG((ENABLE,"Got stop seek zero command\n")); \			Stop(&context, RM_DEVICES_VIDEO | RM_DEVICES_STC); \			RM_PSM_SetState(context.PSMcontext, &(context.dcc_info), RM_PSM_Stopped); \			if (release) {					\				RUAReleaseBuffer(pDMA, buf);		\				buf = NULL;				\			}						\			context.trickMode = FALSE;			\			context.iframeMode = FALSE;			\			context.highSpeedIFrameMode = FALSE;		\			context.video_decoder_initialized = FALSE;	\			/*context.initVideo = TRUE;*/			\			goto mainloop;					\		}							\		if ((actions.cmd == RM_SEEK) && (!actions.cmdProcessed)){ \			RMDBGLOG((ENABLE,"Got seek command\n"));	\			if (release) {					\				RUAReleaseBuffer(pDMA, buf);		\				buf = NULL;				\			}						\			if (dcc_info.seek_supported)			\				seek(&context, context.dcc_info->seek_time); \			else						\				fprintf(stderr, "Unsuported command\n"); \			context.trickMode = FALSE;			\			context.iframeMode = FALSE;			\			context.highSpeedIFrameMode = FALSE;		\			RM_PSM_SetState(context.PSMcontext, &(context.dcc_info), RM_PSM_Playing); \			goto mainloop_no_seek;				\		}							\		computeSpeed(&context);					\		if (context.monitor)					\			monitor(&context, FALSE);			\} while(0)static RMstatus computeSpeed(struct video_context *pSendContext);static RMuint64 round_int_div(RMuint64 numerator, RMuint32 divisor) {	RMuint64 temp;	temp = numerator / divisor;	if ((numerator % divisor) * 2 > divisor)		temp++;	return temp;}#ifndef WITH_MONOstatic void show_usage(char *progname){	show_playback_options();	show_display_options();	show_video_options();	fprintf(stderr, "--------------------------------\n");	fprintf(stderr, "Minimum cmd line: %s <file name>\n", progname);	fprintf(stderr, "--------------------------------\n");	exit(1);}static void parse_cmdline(struct video_context *pSendContext, int argc, char *argv[]){	int i;	RMstatus err;	if (argc < 2) 		show_usage(argv[0]);		i = 1;	while ((argc > i)) {		if (argv[i][0] != '-') {			if (pSendContext->play_opt->filename == NULL) {				pSendContext->play_opt->filename = argv[i];				i++;			}			else				show_usage(argv[0]);		}		else {			err = parse_playback_cmdline(argc, argv, &i, pSendContext->play_opt);			if (err == RM_ERROR) 				show_usage(argv[0]);			if (err != RM_PENDING)				continue;			err = parse_display_cmdline(argc, argv, &i, pSendContext->disp_opt);			if (err == RM_ERROR) 				show_usage(argv[0]);			if (err != RM_PENDING)				continue;			err = parse_video_cmdline(argc, argv, &i, pSendContext->video_opt);			if (RMFAILED(err))				show_usage(argv[0]);		}	}	if (pSendContext->play_opt->filename == NULL)		show_usage(argv[0]);}#endif //WITH_MONO

⌨️ 快捷键说明

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