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

📄 play_avi_push.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
		/* sendind data may fill-up the xfer fifo, so we reset the event */		{			struct RUAEvent e;						e.ModuleID = decoder;			e.Mask = RUAEVENT_XFER_FIFO_READY;			RUAResetEvent(avi_info->pRUA, &e);		}	}}static void progressIndexCallback(RMuint32 progress){	fprintf(stderr, "indexing...%lu%%\n", progress);	return;}static RMstatus WaitForEOS(struct avi_context *avi_info, struct RM_PSM_Actions *pActions){	RMuint32 eos_bit_field = 0;	enum RM_PSM_State FSMstate;	FSMstate = RM_PSM_GetState(avi_info->PSMcontext, &(avi_info->dcc_info));	if (avi_info->sendVideoData) 		eos_bit_field |= EOS_BIT_FIELD_VIDEO;	if (avi_info->sendAudioData) 		eos_bit_field |= EOS_BIT_FIELD_AUDIO;		return WaitForEOSWithCommand(avi_info->PSMcontext, &(avi_info->dcc_info), pActions, eos_bit_field);}static RMbool parseVC1SeqHeader(struct avi_context *pSendContext, RMuint8 *buffer, RMuint32 size){	RMuint32 i;	RMuint32 entryHeaderFound = 0;	RMuint32 entryHeaderSize = 0;	if (size < 3)		return FALSE;	for (i = 3; i < size; i++) {		if ((entryHeaderFound) && (buffer[i-2] != 0) && (buffer[i-1] != 0) && (buffer[i] != 1))			entryHeaderSize++;				if ((buffer[i-3] == 0) && (buffer[i-2] == 0) && (buffer[i-1] == 1) && (buffer[i] == 0xe)) {			pSendContext->entryHeader = (buffer + i - 3);			entryHeaderFound = i;		}	}	pSendContext->entryHeaderSize = entryHeaderSize + 4;	if (entryHeaderFound) {		RMDBGLOG((ENABLE, "entryHeader found at i=%lu, size %lu\n", entryHeaderFound - 3, pSendContext->entryHeaderSize));#if 0		RMDBGLOG((ENABLE, "hacking it by clearing Broken_link and setting Closed_entry\n"));		*(pSendContext->entryHeader + 4) = *(pSendContext->entryHeader + 4) | 0xC;#endif		for (i = 0; i < pSendContext->entryHeaderSize; i++)			fprintf(stderr, "0x%02X ", *(pSendContext->entryHeader + i));		fprintf(stderr, "\n");		return TRUE;	}	return FALSE;}static RMstatus open_video(struct avi_context *avi_info, RMuint32 videoscaler_id){	RMAviStreamHeader m_videoHeader;	RMstatus err;	avi_info->setVOP = FALSE;	err = RMAviPushGetStreamInfo(avi_info->pAvi, RMAVI_VIDEO_STREAM, &m_videoHeader, (void *)&(avi_info->videoFormat));	if (RMFAILED(err)) {		fprintf(stderr, "Error getting avi stream info.\n");		return err;	}		/* known unsupported Four CC */	if ((avi_info->videoFormat.compression == MPG4FOURCC) || 	    (avi_info->videoFormat.compression == mpg4FOURCC)) {		fprintf(stderr, "Unsupported video codec : MSMPEG4V1\n");		err = RM_ERROR;		return err;	}	switch (video_opt->MPEGProfile){	case Profile_FIRST_:	case Profile_LAST_:		break;			case Profile_MPEG2_SD:	case Profile_MPEG2_DVD:	case Profile_MPEG2_HD:	case Profile_MPEG2_SD_Packed:	case Profile_MPEG2_HD_Packed:	case Profile_MPEG2_DVD_Packed:	case Profile_MPEG2_SD_DeInt:	case Profile_MPEG2_DVD_DeInt:	case Profile_MPEG2_HD_DeInt:	case Profile_MPEG2_SD_Packed_DeInt:	case Profile_MPEG2_DVD_Packed_DeInt:	case Profile_MPEG2_HD_Packed_DeInt:		RMDBGLOG((ENABLE, "MPEG 2 video\n"));		break;			case Profile_DIVX3_SD:	case Profile_DIVX3_HD:	case Profile_DIVX3_SD_Packed:	case Profile_DIVX3_HD_Packed:		RMDBGLOG((ENABLE, "DIVX3 video\n"));		avi_info->setVOP = TRUE;		break;			case Profile_WMV_SD:	case Profile_WMV_816P:	case Profile_WMV_HD:		RMDBGLOG((ENABLE, "WMV9 video\n"));		/* TODO		   Why do we need this?, fixedVOP it's supposed to be required only 		   for MPEG4, H264 and DIVX3 according to the hwlib		*/		avi_info->setVOP = TRUE;		break;			case Profile_MPEG4_SD:	case Profile_MPEG4_HD:	case Profile_MPEG4_SD_Packed:	case Profile_MPEG4_HD_Packed:	case Profile_MPEG4_SD_DeInt:	case Profile_MPEG4_HD_DeInt:	case Profile_MPEG4_SD_Packed_DeInt:	case Profile_MPEG4_HD_Packed_DeInt:	case Profile_MPEG4_SD_Padding:	case Profile_MPEG4_HD_Padding:	case Profile_MPEG4_SD_DeInt_Padding:	case Profile_MPEG4_HD_DeInt_Padding:		RMDBGLOG((ENABLE, "MPEG4 video\n"));		avi_info->setVOP = TRUE;		break;			case Profile_VC1_SD:	case Profile_VC1_HD:		RMDBGLOG((ENABLE, "VC1 video\n"));		{			RMuint32 index;			RMbool seqHdrFound = FALSE;			RMDBGLOG((ENABLE, ">> VC1 Advanced Profile\n"));						if (avi_info->videoFormat.extraData[0] & (1<<5))				RMDBGLOG((ENABLE, ">> progressive sequence\n"));						if (avi_info->videoFormat.extraData[0] & (1<<4))				RMDBGLOG((ENABLE, ">> single sequence header\n"));						if (avi_info->videoFormat.extraData[0] & (1<<3))				RMDBGLOG((ENABLE, ">> single entry point header\n"));						if (avi_info->videoFormat.extraData[0] & (1<<2))				RMDBGLOG((ENABLE, ">> single slice pictures\n"));						if (avi_info->videoFormat.extraData[0] & (1<<1))				RMDBGLOG((ENABLE, ">> no B frames\n"));									avi_info->seqHeader = (RMuint8 *)RMMalloc(avi_info->videoFormat.extraDataSize - 1);			avi_info->seqHeaderSize = avi_info->videoFormat.extraDataSize - 1;									RMDBGLOG((ENABLE, "VC1 seqHeader size %lu, seqHeader:\n", avi_info->seqHeaderSize));						for(index = 1; index < avi_info->videoFormat.extraDataSize; index++) {				RMDBGPRINT((ENABLE, "0x%02X ", avi_info->videoFormat.extraData[index]));				avi_info->seqHeader[index - 1] = avi_info->videoFormat.extraData[index];			}			RMDBGPRINT((ENABLE, "\n"));						//pSendContext->video_vop_tir = 90000;			//DCCSTCSetTimeResolution(pSendContext->dcc_info->pStcSource, DCC_Video, pSendContext->video_vop_tir);			seqHdrFound = parseVC1SeqHeader(avi_info, avi_info->seqHeader, avi_info->seqHeaderSize);			if (seqHdrFound) {				avi_info->isVC1 = TRUE;				avi_info->getStartCodeBuffer = TRUE;				avi_info->addSeqHeader = TRUE;				avi_info->addEntryHeader = TRUE;				avi_info->addFrameHeader = TRUE;			}		}		avi_info->setVOP = TRUE;		break;			case Profile_H264_SD:	case Profile_H264_HD:	case Profile_H264_SD_DeInt:	case Profile_H264_HD_DeInt:		RMDBGLOG((ENABLE, "H264 video\n"));		avi_info->setVOP = TRUE;		break;	}	if (!play_opt->send_video)		return RM_OK;#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 = 180;		video_profile.InbandFIFOCount = 16;		video_profile.XtaskInbandFIFOCount = 0;		video_profile.MpegEngineID = video_opt->MpegEngineID;		video_profile.VideoDecoderID = video_opt->VideoDecoderID;		video_profile.SPUBitstreamFIFOSize = 0;		video_profile.SPUXferFIFOCount = 0;		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"));				return err;			}		}				/* set the extra pictures after the profile to codec conversion */		video_profile.ExtraPictureBufferCount = video_opt->vcodec_extra_pictures;		err = DCCXOpenVideoDecoderSource(avi_info->dcc_info->pDCC, &video_profile, &avi_info->dcc_info->pVideoSource);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot open video decoder %d\n", err));			return err;		}			vcodec = video_profile.Codec;		err = DCCXSetVideoDecoderSourceCodec(avi_info->dcc_info->pVideoSource, vcodec);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot set video decoder codec %d\n", err));			return err;		}	}#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_profile.VideoDecoderID = video_opt->VideoDecoderID;		video_profile.SPUBitstreamFIFOSize = 0;		video_profile.SPUXferFIFOCount = 0;		video_profile.STCID = play_opt->STCid;			err = DCCOpenVideoDecoderSource(avi_info->dcc_info->pDCC, &video_profile, &(avi_info->dcc_info->pVideoSource));		if (RMFAILED(err)) {			fprintf(stderr, "Cannot open video decoder %d\n", err);			return err;		}			err = DCCSetVideoDecoderSourceCodec(avi_info->dcc_info->pVideoSource, video_opt->Codec);		if (RMFAILED(err)) {			fprintf(stderr, "Cannot set video decoder codec %d\n", err);			return err;		}	}#endif	err = DCCGetScalerModuleID(avi_info->dcc_info->pDCC, avi_info->dcc_info->route, DCCSurface_Video, videoscaler_id, &(avi_info->dcc_info->SurfaceID));	if (RMFAILED(err)) {		fprintf(stderr, "Cannot get surface to display video source %d\n", err);		return err;	}		err = DCCSetSurfaceSource(avi_info->dcc_info->pDCC, avi_info->dcc_info->SurfaceID, avi_info->dcc_info->pVideoSource);	if (RMFAILED(err)) {		fprintf(stderr, "Cannot set the surface source %d\n", err);		return err;	}		err = DCCGetVideoDecoderSourceInfo(avi_info->dcc_info->pVideoSource, &(avi_info->dcc_info->video_decoder), &(avi_info->dcc_info->spu_decoder), &(avi_info->dcc_info->video_timer));	if (RMFAILED(err)) {		fprintf(stderr, "Error getting video decoder source information %d\n", err);		return err;	}	#ifndef WITH_MONO	     	set_default_out_window(&(avi_info->dcc_info->disp_info->out_window));	set_default_out_window(&(avi_info->dcc_info->disp_info->osd_window[0]));	set_default_out_window(&(avi_info->dcc_info->disp_info->osd_window[1]));	avi_info->dcc_info->disp_info->active_window = &(avi_info->dcc_info->disp_info->out_window);	avi_info->dcc_info->disp_info->video_enable = TRUE;		err = apply_display_options(avi_info->dcc_info, disp_opt);	if (RMFAILED(err)) {		fprintf(stderr, "Cannot set display opions %d\n", err);		return err;	}		display_key_usage(KEYFLAGS);#endif /*WITH_MONO*/		switch (video_opt->MPEGProfile) {	case Profile_FIRST_:	case Profile_LAST_:		break;			case Profile_MPEG2_SD:	case Profile_MPEG2_DVD:	case Profile_MPEG2_HD:	case Profile_MPEG2_SD_Packed:	case Profile_MPEG2_HD_Packed:	case Profile_MPEG2_DVD_Packed:	case Profile_MPEG2_SD_DeInt:	case Profile_MPEG2_DVD_DeInt:	case Profile_MPEG2_HD_DeInt:	case Profile_MPEG2_SD_Packed_DeInt:	case Profile_MPEG2_DVD_Packed_DeInt:	case Profile_MPEG2_HD_Packed_DeInt:		RMDBGLOG((ENABLE, "MPEG 2 video\n"));		break;			case Profile_DIVX3_SD:	case Profile_DIVX3_HD:	case Profile_DIVX3_SD_Packed:	case Profile_DIVX3_HD_Packed:		{			/* Send DSI for DivX3.11 : only frame width and height */			struct VideoDecoder_DIVX3VSProp_type divx3_prop;			RMuint32 width, height;						err = RMAviPushGetVideoSize(avi_info->pAvi, &width, &height);			if (RMFAILED(err)){				RMDBGLOG((ENABLE,"Error getting video size : %d.\n", err));				return err;			}						divx3_prop.Image_Width = (RMuint16) width;			divx3_prop.Image_Height = (RMuint16) height;			RMDBGLOG((AVIDBG,"DivX3.11 DSI prop : %ld x %ld\n", divx3_prop.Image_Width, divx3_prop.Image_Height));			err = RUASetProperty(avi_info->dcc_info->pRUA, avi_info->dcc_info->video_decoder, RMVideoDecoderPropertyID_DIVX3VSProp, 					     &divx3_prop, sizeof(struct VideoDecoder_DIVX3VSProp_type), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE,"Error setting DIVX3 video info : %d !\n", err));				return err;			}		}		break;	case Profile_WMV_SD:	case Profile_WMV_816P:	case Profile_WMV_HD:		{			/* Send DSI for WMV9 */			RMuint32 width, height;			struct VideoDecoder_WMV9VSProp_type wmv9_prop;						err = RMAviPushGetVideoSize(avi_info->pAvi, &width, &height);			if (RMFAILED(err)){				RMDBGLOG((ENABLE,"Error getting video size : %d.\n", err));				return err;			}						wmv9_prop.Image_Width = (RMuint16) width;			wmv9_prop.Image_Height = (RMuint16) height;			wmv9_prop.MB_Width = (wmv9_prop.Image_Width + 15) / 16;	//round up			wmv9_prop.MB_Height = (wmv9_prop.Image_Height + 15) / 16;			wmv9_prop.Sequence = RMbeBufToUint32((RMuint8 *)(avi_info->videoFormat.extraData));			//wmv9_prop.Sequence = RMbeBufToUint32((RMuint8 *)&(avi_info->videoFormat.Colors[0]));						RMDBGLOG((ENABLE, "WMV9 DSI : seq 0x%08lx, %ld x %ld\n", wmv9_prop.Sequence, wmv9_prop.Image_Width,					  wmv9_prop.Image_Height));			err = RUASetProperty(avi_info->dcc_info->pRUA, avi_info->dcc_info->video_decoder, RMVideoDecoderPropertyID_WMV9VSProp, 					     &wmv9_prop, sizeof(struct VideoDecoder_WMV9VSProp_type), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE,"Error setting WMV9 video info : %d !\n", err));				retur

⌨️ 快捷键说明

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