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

📄 play_asf.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * * Copyright (c) Sigma Designs, Inc. 2002. All rights reserved. * *//**	@file play_asf.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  *******************************************************************************************/#define RELEASE_BUFFER_ENABLE	DISABLE#ifdef CHECK_BUFFER_PTS#define CHECK_BUFFER_4_FREAD	1#define CHECK_BUFFER_4_AUDIO	1#define CHECK_BUFFER_4_VIDEO	1#endif#define _LARGEFILE64_SOURCE 1 // Required for large files (> 4GB)#include "sample_os.h"#define ALLOW_OS_CODE 1#include "../dcc/include/dcc.h"#include "../rmasfdemux/include/rmasfdemuxapi.h"#include "../rmasfdemux/include/wmdrm.h"#include "../rmasfdemux/include/wmdrmopl.h"#include "common.h"#include "../rmwmaprodecoder/include/rmwmaprodefine.h"#include "../rmwmaprodecoder/include/rmwmaprodecoderapi.h"/* #### Begin CARDEA code #### */#include "rmupnp/rmlibwmdrmnd/include/ms_cardea.h"#if (EM86XX_CHIP == EM86XX_CHIPID_TANGO2)void test_cci( void *cardea_context );#endif/* #### End CARDEA code #### *//* ################## Begin DTCP code ################### */#if (EM86XX_CHIP == EM86XX_CHIPID_TANGO15)#include "../rmdtcp/include/dtcp_session.h"#else#include "../rmdtcpapi/include/dtcp_session.h"#endif/* ############### End DTCP code ####################### */#include "bcc.h"#define WAIT_COMMAND_TIMEOUT_US	(TIMEOUT_10MS)	  // 10 ms#define GETBUFFER_TIMEOUT_US	(TIMEOUT_10MS)	  // 10 ms#define SENDDATA_TIMEOUT_US		1000000	  //  1 sec#define WAIT_EOS_TIMEOUT_US		20000000  // 20 sec#define CODEC_SPECIFIC_DATA_MAX_SIZE_BYTES  32/*To correctly dimension the fifos for wmv we have to find the average of: - VideoBitRate, VideoFrameRate - AudioBitRate, AudioFrameRate, that will be determined from AudioBlockSize.The video PTS fifo size is 600 entries ~= 10 sec at 60frames/sec.The audio PTS fifo size is 300 entries ~= 10 sec at 30frames/sec.We could dimension the bitstream fifos to 10 seconds of video/audio in order tocompensate for the wmv files with video/audio not well interleaved.The drift vpts-apts can be 1.5 sec for Dolphins, 3 sec for KidRock, 4 sec for liquid_1.Ex: For liquid_1.wmv:	VideoBitRate = 8,494,469bits => 1063kBytes/sec. FrameRate = 60.	AudioBitRate =   193,758bits => 25kBytes/sec. BlockSize = 0x1000 bytes.	Max vpts-apts = 5sec.*/#define ASF_DMA_BUFFER_SIZE_LOG2	16		// 64kB#define ASF_DMA_BUFFER_COUNT		64		// 32*64kB ~= 2MB#ifdef WMAPRO_V1#define AUDIO_DMA_BUFFER_SIZE_LOG2	16		// 64kB#define AUDIO_DMA_BUFFER_COUNT		2		// 2*64kB ~= 128KB#else#define AUDIO_DMA_BUFFER_SIZE_LOG2	17		// 128kB#define AUDIO_DMA_BUFFER_COUNT		2		// 2*128kB ~= 256KB#endif#define VIDEO_XFER_FIFO_COUNT	(ASF_DMA_BUFFER_COUNT * (1<<ASF_DMA_BUFFER_SIZE_LOG2) / 2048)		// average video packet size = 2k#define AUDIO_XFER_FIFO_COUNT	(AUDIO_DMA_BUFFER_COUNT * (1<<AUDIO_DMA_BUFFER_SIZE_LOG2) / 2048)	// average audio packet size = 2k/* do NOT increase these values unless you have a reason to, otherwise, curacao wont be able to run due to lack of memory */#define VIDEO_FIFO_SIZE		(5*1024*1024)	// 5s @ 1MB/s#define AUDIO_FIFO_SIZE		(1*1024*1024)	// 1s @ 1MB/s #define ADDITIONAL_WMAPRO_FIFO_SIZE	1024*1024 #define KEYFLAGS (SET_KEY_DISPLAY | SET_KEY_PLAYBACK | SET_KEY_AUDIO | SET_KEY_DEBUG | SET_KEY_SPI)// uncomment next line for debug information//#define DISPLAY_VIDEO_STREAM_PAYLOAD_INFO// uncomment next line to save all input compressed frames into separate files//#define SAVE_INPUT_FRAMES#if 0#define PAYLOADDBG ENABLE#else#define PAYLOADDBG DISABLE#endif#if 0#define IFRAMEDBG ENABLE#else#define IFRAMEDBG DISABLE#endif#if 0#define TRICKDBG ENABLE#else#define TRICKDBG DISABLE#endif#if 0#define SENDDBG ENABLE#else#define SENDDBG DISABLE#endif#if 0#define WMAPRODBG	ENABLE#else#define WMAPRODBG	DISABLE#endif#if 0#define DISPLAY_AUDIO_BITRATE#endif#if 0#define DISPLAY_VIDEO_BITRATE#endif#if 0#define KEYDBG ENABLE#else#define KEYDBG DISABLE#endif#if 0#define VC1_STARTCODE_DBG ENABLE#else#define VC1_STARTCODE_DBG DISABLE#endif#define READ_DBG DISABLE#define MAX_INDEX_NUMBER 5#define INDEX_BUFFER_SIZE (200 * 1024)typedef enum {	RMasfIFrameFSM_Disabled = 0,	RMasfIFrameFSM_Init,	RMasfIFrameFSM_WaitIFrameMONChange,	RMasfIFrameFSM_SkipNext}RMasfIFrameFSMstates;#ifndef WITH_MONOtypedef struct {	RMuint16 languageIDCount;	RMuint16 languageIDIndex;	RMnonAscii * languageID;	RMuint8 languageIDLength;} RMasfdemuxLanguageID;#endif //WITH_MONO#define RM_DEVICES_STC 0x1#define RM_DEVICES_VIDEO 0x2#define RM_DEVICES_AUDIO 0x4#define RM_STREAM_VIDEO 0x1#define RM_STREAM_AUDIO 0x2#define RM_SKIP_TO_RESYNC 0x1#define MAX_NUMBER_OF_AUDIO_STREAMS 16struct wmapro_buffer_info {	RMbool new_buffer;	RMuint8 *ptr;	RMuint32 size;	struct emhwlib_info Info;	RMuint32 Stream_Number;	RMuint32 Media_Object_Number;	RMuint32 fSendPTS;#ifndef _ENABLE_WMALSL_	void *pBuffer;#endif // _ENABLE_WMALSL_};struct priv_cmdline {	RMuint32 dummy;};struct stream_info { 	RMuint32		stream_number; 	RMuint8			*aes_buf; 	RMuint32		aes_buf_len;};enum RMProcess_key_goto{    RMProcess_key_goto_none=1,    RMProcess_key_goto_got_key_but_noaction,    RMProcess_key_goto_nojump_but_exit,    RMProcess_key_goto_cleanup,    RMProcess_key_goto_mainloop_seek,    RMProcess_key_goto_wmapro_decoder_delete};struct RMaudio_parameters {      RMbool enabled;      unsigned short Codec_ID;      unsigned short Number_of_Channels;       unsigned long Samples_Per_Second;      unsigned long Average_Number_of_Bytes_Per_Second;      unsigned short Block_Alignment;      unsigned short Bits_Per_Sample;      unsigned char Codec_Specific_Data[CODEC_SPECIFIC_DATA_MAX_SIZE_BYTES];      unsigned long Codec_Specific_Data_Size;}; RMuint32 RMSupported_codec_list[] = {0x161,0x7A21,0x7A21,0x162,0x163,0x1};struct asf_context {	struct RUA *pRUA;	struct RUABufferPool *pDMA;	struct RUABufferPool *pDMAuncompressed;	unsigned char *UncompressedBuffer;	unsigned char *SequenceHeaderBuffer;	RMbool FirstSystemTimeStamp;	struct dcc_context *dcc_info;	struct RM_PSM_Context *PSMcontext;	RMuint32 video_stream_index;	RMint32 audio_stream_index;	RMuint32 cmd;	RMbool SendVideoData;	RMuint32 prev_video_media_object_number;	RMuint32 video_frame_counter;	RMuint32 VideoByteCounter;	RMbool SendVideoPts;	RMuint32 video_last_pts;	// used for video hack	RMuint32 video_vop_tir;#ifdef CHECK_BUFFER_PTS	RMuint32 video_pts;#endif	RMuint32 videoscaler_id;	RMbool SendAudioData;	RMuint32 prev_audio_media_object_number;	RMuint32 audio_frame_counter;	RMuint32 AudioByteCounter;	RMbool SendAudioPts; 	RMuint32 audio_vop_tir;	RMbool isWMAPRO;	RMuint32 start_ms; 	#ifdef CHECK_BUFFER_PTS	RMuint32 audio_pts;	RMuint32 max_avpts_diff;#endif	ExternWMAProVdecoder vDecoder;	ExternalRMASFDemux vASFDemux;	RMbool firstIFrame;	RMbool isIFrameMode;	RMbool isTrickMode;	RMint32 IFrameSize;	RMbool SeekAudio;	RMbool SeekVideo;	RMuint32 PrevAudioMON;	RMuint32 PrevVideoMON;//	struct AudioDecoder_WMAParameters_type wma_params[MAX_NUMBER_OF_AUDIO_STREAMS];	// David: I want it to pass information to payload decoder	RMuint32 WMAPROBitsPacketLength;    struct RMaudio_parameters audio_parameters[MAX_NUMBER_OF_AUDIO_STREAMS];	    RMfile f_bitstream;#ifdef _DUMP_INT_FILE_	FILE *intfile;#endif	#ifdef SAVE_INPUT_FRAMES	int f_compressed_frames;#endif	RMbool video_decoder_initialized;	RMbool audio_decoder_initialized;	RMuint32 Compression_ID;	struct VideoDecoder_WMV9VSProp_type wmv9_prop;	struct VideoDecoder_DIVX3VSProp_type divx3_prop;	RMuint32 asf_packetSize;	RMuint64 asf_Header_Object_Size;	RMasfIFrameFSMstates IFrameFSMState;	RMuint32 inband_aspect_ratio_x;	RMuint32 inband_aspect_ratio_y;	RMuint32 save_inband_aspect_ratio_y;	RMuint32 save_inband_aspect_ratio_x;	RMuint16 inband_aspect_ratio_stream_index;	RMint32 drmError;	RMbool isContentEncrypted;	RMbool unsupported_video;	struct SurfaceAspectRatio_type InBandAspectRatioParams;	RMbool setAspectRatio;	RMuint64 Preroll;	RMbool PrerollSET;	RMuint64 Duration;	RMbool ignoreCallback; /* when we catch a key during a callback, we must ignore all subsequent calls to the payload				  callback  until 'PROCESS_KEY' process it. 				  Required for 'stop', 'quit', 'seek[zero]' and 'iframe' */	RMuint64 CurrentDisplayPTS; /*used for 'accurate' iframe seeking when resuming from iframe mode */	RMint32 IFrameDirection;	RMbool VideoStreamFound;	RMbool AudioStreamFound;	RMuint64 lastSTC;	RMuint64 accurateAudioSeekTo;	RMbool IgnoreAudio;	RMuint32 Video_Codec_Specific_Data_Received;	RMuint32 Audio_Codec_Specific_Data_Received;	RMuint32 ContiguousVideoLength;	RMuint32 ContiguousAudioLength;	RMuint64 video_time_start;	RMuint64 video_time_end;	RMuint64 audio_time_start;	RMuint64 audio_time_end;	RMuint64 video_time_stamp;	RMuint64 audio_time_stamp;	RMint32 min_diff;	RMint32 max_diff;	RMuint32 packet_counter;	RMbool filePropSET;	RMbool langPropSET;	RMasfdemuxLanguageID lang[MAX_NUMBER_OF_AUDIO_STREAMS];#ifdef DISPLAY_AUDIO_BITRATE	RMuint32 prev_timeA;	RMuint32 prev_MON_A;	RMuint32 nb_bytes_since_prev_timeA;	RMuint32 byteRateA;	RMuint32 maxByteRateA;#endif#ifdef DISPLAY_VIDEO_BITRATE	RMuint32 prev_timeV;

⌨️ 快捷键说明

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