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

📄 play_demux.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
	case user_data_dma_minimum_size:	case user_data_dma_exact_size:	    {		RMuint8 *pBuf = NULL;		RMuint32 size = 0;				e.Mask = SOFT_IRQ_EVENT_XFER_RECEIVE_READY;		if (RUAWaitForMultipleEvents(pcontext->pRUA, &e, 1, 0, NULL) == RM_OK ) {			while(1) {				err = RUAReceiveData(pcontext->pRUA, targetModule, pcontext->pDmaUserData, &pBuf, &size, NULL, NULL);				if ( (err == RM_OK) && pBuf ) {					if ( pcontext->f_record && (size > 0) ) {						fwrite(pBuf, 1, size, pcontext->f_record);						pcontext->f_record_size += size;					}					RMDBGLOG((DISABLE, "user_data receive size=0x%lx\n", size));					RUAReleaseBuffer(pcontext->pDmaUserData, pBuf);				}				else					break;			}		}		break;	    }	case user_data_get_chunk256_without_dma:	    {		RMuint32 left_size;		struct DataFIFOInfo user_fifo_info;		e.Mask = SOFT_IRQ_EVENT_USER_DATA;		if (RUAWaitForMultipleEvents(pcontext->pRUA, &e, 1, 0, NULL) == RM_OK ) {			err = RUAGetProperty(pcontext->pRUA, targetModule, RMGenericPropertyID_DataFIFOInfo,				&user_fifo_info, sizeof(user_fifo_info));			left_size = user_fifo_info.Readable;			if(left_size) {				RMuint32 in;				struct EMhwlibChunk256 out;				in = RMmin(left_size, 256);				err = RUAExchangeProperty(pcontext->pRUA, targetModule, RMGenericPropertyID_ReadChunk256,					&in, sizeof(in), &out, sizeof(out));				if(err == RM_OK) {					left_size -= out.size;					if ( pcontext->f_record && (out.size > 0) ) {						fwrite(out.data, 1, out.size, pcontext->f_record);						pcontext->f_record_size += out.size;					}					RMDBGLOG((DISABLE, "user_data get chunk size= 0x%03lx / 0x%03lx total= 0x%lx \n",						out.size, user_fifo_info.Readable, pcontext->f_record_size));				}				else {					RMDBGLOG((ENABLE, "user_data RMGenericPropertyID_ReadChunk256 ERROR\n"));				}			}		}		break;	    }	case user_data_rua_mapping_without_dma:	    {		struct gbus_fifo *fifo;		RMuint32 rd, wr;		fifo = (struct gbus_fifo *)pcontext->user_data_fifo_container;		rd = gbus_read_uint32(pgbus, (RMuint32) &(fifo->rd));		wr = gbus_read_uint32(pgbus, (RMuint32) &(fifo->wr));		if ( wr > rd ) {			/* data is contiguos in one chunck */			if (pcontext->f_record) {				fwrite(pcontext->pmapped_user_data_fifo_base + rd, 1, wr-rd, pcontext->f_record);				pcontext->f_record_size += (wr-rd);			}		}		else if (wr != rd) {			/* data is separated in two chuncks because of circular fifo. */			if (pcontext->f_record) {				fwrite(pcontext->pmapped_user_data_fifo_base + rd, 1,					pcontext->user_data_fifo_size-rd, pcontext->f_record);				fwrite(pcontext->pmapped_user_data_fifo_base, 1, wr, pcontext->f_record);				pcontext->f_record_size += (pcontext->user_data_fifo_size+wr-rd);			}		}		gbus_write_uint32(pgbus, (RMuint32) &(fifo->rd), wr);		break;	    }	case no_user_data:	default:		break;	}}#ifdef WITH_MONOint main_demux(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;/*access through disp_opt*/	struct video_cmdline video_options; /*access through video_opt*/	struct audio_cmdline audio_options; /*access through audio_opt*/	struct demux_cmdline demux_options; /*access through demuxopt*/	struct display_context disp_info;	struct dh_context dh_info = {0,};#endif	struct DCCVideoSource *pVideoSource = NULL;	struct DCCAudioSource *pAudioSource = NULL;	struct DCCAudioProfile audio_profile;	struct RUABufferPool *pDMA = NULL;	ExternalRMvdemux demux;	struct demux_context context;	RMstatus err;	RMfile file = NULL;	RMuint32 videoscaler_id = 0;	RMuint8 *repack_buf = (RMuint8 *) NULL;		static struct dcc_context dcc_info = {0,};	void **dmabuffer_array = (void **) NULL;	RMuint32 dmabuffer_index = 0;	RMuint32 error = 0;	struct RM_PSM_Context PSMContext;	RMMemset(&context, 0, sizeof(struct demux_context));#ifdef WITH_MONO	/*make the mono arguments global*/	play_opt = mono->play_opt;	video_opt = mono->video_opt;	disp_opt = mono->disp_opt;	audio_opt = mono->audio_opt;	demux_opt = mono->demux_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	play_opt = &playback_options;	disp_opt = &display_options;	video_opt = &video_options;	audio_opt = &audio_options;	demux_opt = &demux_options;	dcc_info.disp_info = &disp_info;	dcc_info.dh_info = &dh_info;	init_display_options(disp_opt);	init_audio_options(audio_opt);	init_playback_options(play_opt);	init_video_options(video_opt);	disp_opt->dh_info = &dh_info;	audio_opt->dh_info = &dh_info;	parse_cmdline(argc, argv);	videoscaler_id = disp_opt->video_scaler;	dcc_info.route = disp_opt->route;	err = RUACreateInstance(&dcc_info.pRUA, play_opt->chip_num);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error creating RUA instance! %d\n", err));		goto exit_with_error;	}	err = DCCOpen(dcc_info.pRUA, &dcc_info.pDCC);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error Opening DCC! %d\n", err));		goto exit_with_error;	}	if (!play_opt->noucode) {		err = DCCInitMicroCodeEx(dcc_info.pDCC, disp_opt->init_mode);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot initialize microcode %d\n", err));			goto exit_with_error;		}	}	else		RMDBGLOG((ENABLE, "microcode not loaded\n"));#endif	err = open_save_files(play_opt);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "cannot open files to save data %d\n", err));		goto exit_with_error;	}	if (demux_opt->system_type != RM_SYSTEM_UNKNOWN) {		err = RMCreateVdemux(&demux);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot create demux %d\n", err));			goto exit_with_error;		}		RMvdemuxSetType(demux, demux_opt->system_type);		RMvdemuxSetCallbackData(demux, PESCallback, &context);		RMvdemuxSetAudioCallbacks(demux, AC3DTSCallback, LPCMCallback, aobPcm_callback, mlp_callback);	}	else {		demux = (ExternalRMvdemux) NULL;#if 0		RMDBGLOG((ENABLE, "system unknown, exiting\n"));		err = RM_ERROR;		goto exit_with_error;#endif	}	dcc_info.chip_num = play_opt->chip_num;	/* if HD control is enabled and mode is auto, setup parameters */	if ((play_opt->disk_ctrl_low_level) &&	    (play_opt->disk_ctrl_log2_block_size) &&	    (play_opt->disk_ctrl_max_mem)) {		RMuint32 bufferSize = 0;		RMuint32 bufferCount = 0;		RMuint32 log2BlockSize = play_opt->disk_ctrl_log2_block_size;		RMuint32 maxBufferingMem = play_opt->disk_ctrl_max_mem;		bufferSize = (1 << log2BlockSize);		bufferCount = maxBufferingMem >> log2BlockSize;			play_opt->dmapool_count = bufferCount;		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 (play_opt->disk_ctrl_low_level >= bufferCount)			play_opt->disk_ctrl_low_level = bufferCount >> 1;			video_opt->fifo_size = 4 * (1024 * 1024);		audio_opt->fifo_size = 2 * (1024 * 1024);		fprintf(stderr, ">> low level %lu => %lu bytes bufferized (+ bitstreamFIFO)\n", 			play_opt->disk_ctrl_low_level,			play_opt->disk_ctrl_low_level * bufferSize);			video_opt->xfer_count = (bufferSize / 512) * bufferCount;		audio_opt->xfer_count = (bufferSize / 512) * bufferCount;		err = setup_disk_control_parameters(&dcc_info, play_opt, audio_opt, video_opt, NULL);		if (err != RM_OK) {			fprintf(stderr, "Error %d trying to setup HD control params\n", err);			goto exit_with_error;		}	}	/* update fifo and xfer size */	if (video_opt->fifo_size == 0) 		video_opt->fifo_size = VIDEO_FIFO_SIZE;	if (video_opt->xfer_count == 0)		video_opt->xfer_count = XFER_FIFO_COUNT;	if (audio_opt->fifo_size == 0) 		audio_opt->fifo_size = AUDIO_FIFO_SIZE;	if (audio_opt->xfer_count == 0)		audio_opt->xfer_count = XFER_FIFO_COUNT;	/* update dmapool size and count */	if (play_opt->dmapool_count == 0)		play_opt->dmapool_count = DMA_BUFFER_COUNT;	if (play_opt->dmapool_log2size == 0)		play_opt->dmapool_log2size = DMA_BUFFER_SIZE_LOG2;	switch (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*) * play_opt->dmapool_count);		dmabuffer_index = 0;		if (dmabuffer_array == NULL) {			RMDBGLOG((ENABLE, "Cannot allocate dmapool array! Disable disk control\n"));			play_opt->disk_ctrl_state = DISK_CONTROL_STATE_DISABLE;		}		break;	}	err = apply_playback_options(&dcc_info, play_opt);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Cannot set playback options %d\n", err));		goto exit_with_error;	}	{		// open first stc module		struct DCCStcProfile stc_profile;		RMDBGLOG((ENABLE, "using STC ID %lu\n", play_opt->STCid));		stc_profile.STCID = play_opt->STCid;		stc_profile.master = Master_STC;				stc_profile.stc_timer_id = 3*stc_profile.STCID+0;		stc_profile.stc_time_resolution = 90000;				stc_profile.video_timer_id = 3*stc_profile.STCID+1;		stc_profile.video_time_resolution = 90000;		stc_profile.video_offset = -(play_opt->video_delay_ms * (RMint32)stc_profile.video_time_resolution / 1000);				stc_profile.audio_timer_id = 3*stc_profile.STCID+2;		stc_profile.audio_time_resolution = 90000;		stc_profile.audio_offset = -(play_opt->audio_delay_ms * (RMint32)stc_profile.audio_time_resolution / 1000);				err = DCCSTCOpen(dcc_info.pDCC, &stc_profile, &dcc_info.pStcSource);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot open stc module %d\n", err));			goto exit_with_error;		}	}#if 1	{		struct DCCXVideoProfile video_profile;		enum EMhwlibVideoCodec vcodec;		video_profile.ProtectedFlags = 0;		video_profile.BitstreamFIFOSize = video_opt->fifo_size;		video_profile.XferFIFOCount = video_opt->xfer_count;		video_profile.PtsFIFOCount = VIDEO_PTS_FIFO_COUNT;		video_profile.InbandFIFOCount = VIDEO_INBAND_FIFO_COUNT;		video_profile.XtaskInbandFIFOCount = 0;		video_profile.MpegEngineID = video_opt->MpegEngineID;		video_profile.VideoDecoderID = video_opt->VideoDecoderID;				video_profile.SPUProtectedFlags = 0;		video_profile.SPUBitstreamFIFOSize = (enable_spu) ? SPU_FIFO_SIZE : 0;		video_profile.SPUXferFIFOCount = (enable_spu) ? XFER_FIFO_COUNT : 0;		video_profile.SPUPtsFIFOCount = (enable_spu) ? VIDEO_PTS_FIFO_COUNT : 0;		video_profile.SPUInbandFIFOCount = (enable_spu) ? VIDEO_INBAND_FIFO_COUNT : 0;		video_profile.SPUCodec = EMhwlibDVDSpuCodec;		video_profile.SPUProfile = 0;		video_profile.SPULevel = 0;		video_profile.SPUExtraPictureBufferCount = 0;		video_profile.SPUMaxWidth = 720;		video_profile.SPUMaxHeight = 576;			video_profile.STCID = play_opt->STCid;			/* set codec based on command line options either "-pv" or "-vcodec" */		if (video_opt->vcodec_max_width) {			video_profile.Codec = video_opt->vcodec;			video_profile.Profile = video_opt->vcodec_profile;			video_profile.Level = video_opt->vcodec_level;			video_profile.MaxWidth = video_opt->vcodec_max_width;			video_profile.MaxHeight = video_opt->vcodec_max_height;		}		else {			err = video_profile_to_codec(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 exit_with_error;			}		}		/* set the extra pictures after the profile to codec conversion */		video_profile.ExtraPictureBufferCount = video_opt->vcodec_extra_pictures;		err = DCCXOpenVideoDecoderSource(dcc_info.pDCC, &video_profile, &pVideoSource);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot open video decoder %d\n", err));			goto exit_with_error;		}				vcodec = video_profile.Codec;		err = DCCXSetVideoDecoderSourceCodec(pVideoSource, vcodec);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot set video decoder codec %d\n", err));			goto exit_with_error;		}	}#else	{		struct DCCVideoProfile video_profile;		video_profile.MPEGProfile = video_opt->MPEGProfile;		video_profile.BitstreamFIFOSize = video_opt->fifo_size;		video_profile.XferFIFOCount = video_opt->xfer_count;		video_profile.DemuxProgramID = 0;		video_profile.MpegEngineID = video_opt->MpegEngineID;		video_pr

⌨️ 快捷键说明

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