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

📄 play_gt.c

📁 1. 8623L平台
💻 C
📖 第 1 页 / 共 5 页
字号:
				diff2 = (RMint64)stc - (RMint64)(currentDecoded / 45);				speed1 = diff1;				speed2 = diff2;				skip = FALSE;			}		}		else {			N *= -1;			samplingT *= N;			samplingT = (RMuint32) round_int_div((RMuint64)samplingT, M);			if (stc < pSendContext->lastSTC - samplingT) {								delta = pSendContext->lastSTC - stc;				pSendContext->lastSTC = stc;				err = RUAGetProperty(pSendContext->dcc_info->pRUA, pSendContext->dcc_info->SurfaceID, RMGenericPropertyID_CurrentDisplayPTS, &currentPTS, sizeof(currentPTS));				err = RUAGetProperty(pSendContext->dcc_info->pRUA, pSendContext->dcc_info->video_decoder, RMVideoDecoderPropertyID_LastDecodedPTS, &currentDecoded, sizeof(currentDecoded));				diff1 = (RMint64)(currentPTS / 45) - (RMint64)stc;				diff2 = (RMint64)(currentDecoded / 45) - (RMint64)stc;				speed1 = diff1;				speed2 = diff2;								skip = FALSE;			}		}		if (skip == FALSE) {			sum1 = sum2 = 0;			for (i = 0; i < MEAN_DEPTH; i++) {				if (shiftReg1[0] < shiftReg1[i])					sum1++;				if (shiftReg2[0] < shiftReg2[i])					sum2++;			}					if (sum1 > MEAN_DEPTH/2)				count1++;			else				count1 = 0;					if (sum2 > MEAN_DEPTH/2)				count2++;			else				count2 = 0;					speedX = (RMuint32)round_int_div((RMuint64)N, M);			speedX2 = (RMuint32)round_int_div((RMuint64)delta, 200);					RMDBGLOG((ENABLE, "time %llu (%ld/%lu=%lux, %lu), sampling %lu, delta %4llu, sum1 %lld, sum2 %lld, diff3 %lld(%ld), diff4 %lld(%ld) %s\n", 				  stc,				  N,				  M,				  speedX,				  speedX2,				  samplingT,				  delta,				  sum1,				  sum2,				  speed1,				  count1,				  speed2,				  count2,				  ((count1 > DIVERGENCE_TRIGGER) && (count2 > DIVERGENCE_TRIGGER)) ? "DIVERGE!":""));					pSendContext->lastVideoPTS = currentPTS;			pSendContext->lastDecoded = currentDecoded;					for (i = 0 ; i < MEAN_DEPTH-1 ; i++)				shiftReg1[i] = shiftReg1[i+1];			shiftReg1[MEAN_DEPTH-1] = speed1;					for (i = 0 ; i < MEAN_DEPTH-1 ; i++)				shiftReg2[i] = shiftReg2[i+1];			shiftReg2[MEAN_DEPTH-1] = speed2;					if ((count1 > DIVERGENCE_TRIGGER) && 			    (count2 > DIVERGENCE_TRIGGER) &&			    (!pSendContext->highSpeedIFrameMode)) {				RMDBGLOG((ENABLE, "enable high speed iframe mode\n"));				pSendContext->highSpeedIFrameMode = TRUE;			}			pSendContext->highSpeedIFrameSpeed = speedX;		}	}		return RM_OK;}static void check_prebuf_state(struct video_context *pSendContext, RMuint32 buffersize){	RMbool quit_prebuf;	enum RM_PSM_State PlaybackStatus = RM_PSM_GetState(pSendContext->PSMcontext, &(pSendContext->dcc_info));		if (PlaybackStatus != RM_PSM_Prebuffering)		return;	/* if fail in getbuffer force quitting prebuffering state */	quit_prebuf = ((buffersize == 0) || ((pSendContext->play_opt->prebuf_max > 0) && (pSendContext->prebuf_level >= pSendContext->play_opt->prebuf_max))) ? TRUE : FALSE;	pSendContext->prebuf_level += buffersize;			if (quit_prebuf) {		RMDBGLOG((ENABLE, "exit prebuffering state\n"));		RMDBGLOG((ENABLE, "setting play state\n"));		RM_PSM_SetState(pSendContext->PSMcontext, &(pSendContext->dcc_info), RM_PSM_Playing);#if START_IN_IFRAME_MODE		Play(pSendContext, RM_DEVICES_VIDEO | RM_DEVICES_STC, DCCVideoPlayIFrame);#else		Play(pSendContext, RM_DEVICES_VIDEO | RM_DEVICES_STC, DCCVideoPlayFwd);#endif	}}#ifdef	SEND_IBCstatic RMbool SendInbandCommand(struct video_context* context) {	struct InbandCommandX_type 	ibcx;	RMbool						result = FALSE;	RMstatus					err;	RMDBGLOG((ENABLE, "*******************************************Sending action stop inband command!\n"));	/* test pts offset */	ibcx.flags_tag 		= INBAND_COMMAND_TAG_PTS_OFFSET|INBAND_COMMAND_ACTION_STOP;	ibcx.offset_value 	= 0; // byte_cnt[state]; /* ignored */	ibcx.output_mask 	= 0; /* no need to propagate it to the outputs */	ibcx.offset_control = EMhwlibInbandOffset_Absolute;	err = RUASetProperty(context->dcc_info->pRUA, context->dcc_info->video_decoder,			RMGenericPropertyID_InbandCommandX, &ibcx, sizeof(ibcx), 0);	if ( RMSUCCEEDED(err) ) {		result = TRUE;	}	return result;}#endif#ifdef WITH_MONOint main_video(struct mono_info *mono){#elseint main(int argc, char *argv[]){	/*for MONO compatibility, always access these variables through the global pointers*/	struct playback_cmdline playback_options; /*access through play_opt*/	struct display_cmdline  display_options;/*not accessible*/	struct video_cmdline video_options; /*access through video_opt*/	struct display_context disp_info;	struct dh_context dh_info = {0,};	struct PictureTransform_Open_type xform_profile;	RMuint32 output_surface, video_surface;#ifdef	SEND_IBC	RMbool ibc_sent = FALSE;#endif#endif	struct DCCVideoSource *pVideoSource = NULL;/*  	struct DCCVideoSource *pVideoSourceXFORM = NULL; */	struct RUABufferPool *pDMA = NULL;	RMstatus err;	RMfile file = NULL;	static struct dcc_context dcc_info = {0,};	RMuint32  videoscaler_id = 0;	struct RM_PSM_Context PSMContext;	void **dmabuffer_array = (void **) NULL;	RMuint32 dmabuffer_index = 0;	RMuint64 MSPts = 0LL;	RMuint32 MSLength = 0L;#if STORE_SEQ_HEADER_LOCALLY	RMuint8 header[MAXHEADERSIZE];	RMbool headerread = FALSE;	RMbool resendheader = FALSE;	RMint32 HeaderSize = 0;#endif //STORE_SEQ_HEADER_LOCALLY	struct video_context context = {0,};#ifdef WITH_MONO	/*make the mono arguments global*/	context.play_opt = mono->play_opt;	context.video_opt = mono->video_opt;	dcc_info.pRUA = mono->pRUA;	dcc_info.pDCC = mono->pDCC;	dcc_info.disp_info = NULL;	videoscaler_id = mono->video_scaler;	dcc_info.route = DCCRoute_Main;#else	context.play_opt = &playback_options;	context.disp_opt = &display_options;	context.video_opt = &video_options;	dcc_info.disp_info = &disp_info;	init_display_options(context.disp_opt);	init_playback_options(context.play_opt);	init_video_options(context.video_opt);	context.video_opt->display_cc = TRUE;	context.disp_opt->dh_info = &dh_info;	context.dcc_info = &dcc_info;	context.PSMcontext = &PSMContext;	parse_cmdline(&context, argc, argv);	dcc_info.route = context.disp_opt->route;	videoscaler_id = context.disp_opt->video_scaler;	err = RUACreateInstance(&(dcc_info.pRUA), context.play_opt->chip_num);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error creating RUA instance! %d\n", err));		return -1;	}	err = DCCOpen(dcc_info.pRUA, &(dcc_info.pDCC));	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error Opening DCC! %d\n", err));		return -1;	}	if (!context.play_opt->noucode) {		err = DCCInitMicroCodeEx(dcc_info.pDCC, context.disp_opt->init_mode);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot initialize microcode %d\n", err));			return -1;		}	}	else		RMDBGLOG((ENABLE, "microcode not loaded\n"));#endif	if (context.video_opt->auto_detect_codec) {		fprintf(stderr, "you must specify the codec, '-pv auto' is not valid for this application\n");		return -1;	}	context.dcc_info = &dcc_info;	dcc_info.chip_num = context.play_opt->chip_num;	/* if HD control is enabled and mode is auto, setup parameters */	if ((context.play_opt->disk_ctrl_low_level) &&	    (context.play_opt->disk_ctrl_log2_block_size) &&	    (context.play_opt->disk_ctrl_max_mem)) {		RMuint32 bufferSize = 0;		RMuint32 bufferCount = 0;		RMuint32 log2BlockSize = context.play_opt->disk_ctrl_log2_block_size;		RMuint32 maxBufferingMem = context.play_opt->disk_ctrl_max_mem;		bufferSize = (1 << log2BlockSize);		bufferCount = maxBufferingMem >> log2BlockSize;			context.play_opt->dmapool_count = bufferCount;		context.play_opt->dmapool_log2size = log2BlockSize;			/* from #4005		   		videoOpt.fifo_size = 4*1024*1024; 		videoOpt.xfer_count = (1<<playOpt.dmapool_log2size)/1024*playOpt.dmapool_count;		audioOpt.fifo_size = 1*1024*1024; 		audioOpt.xfer_count = (1<<playOpt.dmapool_log2size)/512*playOpt.dmapool_count;				*/		if (context.play_opt->disk_ctrl_low_level >= bufferCount)			context.play_opt->disk_ctrl_low_level = bufferCount >> 1;			context.video_opt->fifo_size = 4 * (1024 * 1024);		fprintf(stderr, ">> low level %lu => %lu bytes bufferized (+ bitstreamFIFO)\n", 			context.play_opt->disk_ctrl_low_level,			context.play_opt->disk_ctrl_low_level * bufferSize);			context.video_opt->xfer_count = bufferCount * 2;		err = setup_disk_control_parameters(&dcc_info, context.play_opt, NULL, context.video_opt, NULL);		if (err != RM_OK) {			fprintf(stderr, "Error %d trying to setup HD control params\n", err);			return -1;		}	}	/* update fifo and xfer size */	if (context.video_opt->fifo_size == 0) 		context.video_opt->fifo_size = VIDEO_FIFO_SIZE;	if (context.video_opt->xfer_count == 0)		context.video_opt->xfer_count = XFER_FIFO_COUNT;	/* update dmapool size and count */	if (context.play_opt->dmapool_count == 0)		context.play_opt->dmapool_count = DMA_BUFFER_COUNT;	if (context.play_opt->dmapool_log2size == 0)		context.play_opt->dmapool_log2size = DMA_BUFFER_SIZE_LOG2;	RMDBGLOG((ENABLE, "Video:\n\tBitstreamFIFOSize: %lu\n\tFIFOXFERCount: %lu\n", 		  context.video_opt->fifo_size , 		  context.video_opt->xfer_count));	RMDBGLOG((ENABLE, "DMA Pool:\n\tSize: %ld\n\tBufferCount: %ld\n\tBufferSize: %ld\n", 		  (context.play_opt->dmapool_count << context.play_opt->dmapool_log2size), 		  context.play_opt->dmapool_count, 		  (1 << context.play_opt->dmapool_log2size)));	switch (context.play_opt->disk_ctrl_state) {	case DISK_CONTROL_STATE_DISABLE:		break;	case DISK_CONTROL_STATE_SLEEPING:	case DISK_CONTROL_STATE_RUNNING:		dmabuffer_array = (void **) RMMalloc(sizeof(void*) * context.play_opt->dmapool_count);		dmabuffer_index = 0;		if (dmabuffer_array == NULL) {			RMDBGLOG((ENABLE, "Cannot allocate dmapool array! Disable disk control\n"));			context.play_opt->disk_ctrl_state = DISK_CONTROL_STATE_DISABLE;		}		break;	}	err = apply_playback_options(&dcc_info, context.play_opt);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Cannot set playback options %d\n", err));		return -1;	}	{		// open first stc module		struct DCCStcProfile stc_profile;		RMuint32 timeScale;		if (context.video_opt->vcodec == EMhwlibVideoCodec_WMV)			timeScale = 1000;		else			timeScale = 90000;		RMDBGLOG((ENABLE, "using STC ID %lu\n", context.play_opt->STCid));		stc_profile.STCID = 0;		stc_profile.master = Master_STC;			stc_profile.stc_timer_id =  3*stc_profile.STCID+0;		stc_profile.stc_time_resolution = timeScale;				stc_profile.video_timer_id =  3*stc_profile.STCID+1;		stc_profile.video_time_resolution = timeScale;		stc_profile.video_offset = -(context.play_opt->video_delay_ms * (RMint32)stc_profile.video_time_resolution / 1000);				stc_profile.audio_timer_id = NO_TIMER;		stc_profile.audio_time_resolution = 0;		stc_profile.audio_offset = 0;				err = DCCSTCOpen(dcc_info.pDCC, &stc_profile, &dcc_info.pStcSource);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot open stc module %d\n", err));			goto cleanup;		}	}	{		struct DCCXVideoProfile video_profile;		enum EMhwlibVideoCodec vcodec;			video_profile.ProtectedFlags = 0;		video_profile.BitstreamFIFOSize = context.video_opt->fifo_size;		video_profile.XferFIFOCount = context.video_opt->xfer_count;		video_profile.PtsFIFOCount = 180;		video_profile.InbandFIFOCount = 16;		video_profile.XtaskInbandFIFOCount = 0;		video_profile.MpegEngineID = context.video_opt->MpegEngineID;		video_profile.VideoDecoderID = context.video_opt->VideoDecoderID;		video_profile.SPUBitstreamFIFOSize = 0;		video_profile.SPUXferFIFOCount = 0;		video_profile.STCID = context.play_opt->STCid;		/* set codec based on command line options either "-pv" or "-vcodec" */		if (context.video_opt->vcodec_max_width) {			video_profile.Codec = context.video_opt->vcodec;			video_profile.Profile = context.video_opt->vcodec_profile;			video_profile.Level = context.video_opt->vcodec_level;			video_profile.ExtraPictureBufferCount = context.video_opt->vcodec_extra_pictures;			video_profile.MaxWidth = context.video_opt->vcodec_max_width;			video_profile.MaxHeight = context.video_opt->vcodec_max_height;		}		else {			err = video_profile_to_codec(context.video_opt->Codec, 						     &video_profile.Codec,						     &video_profile.Profile, 						     &video_profile.Level, 						     &video_profile.ExtraPictureBufferCount,						     &video_profile.MaxWidth, 						     &video_profile.MaxHeight);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "Unknown video decoder codec \n"));				goto cleanup;			}		}		{			struct MpegEngine_DecoderSharedMemory_type shared;			RMuint32 mpeg_engine;						/* calling DCCXOpenVideoDecoderSource here will allocate as much decoder shared			   memory as needed by the video decoder. if this value is low (depends on codec), 			   chances are that the xform engine won't have enough shared memory.

⌨️ 快捷键说明

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