?? play_vdemux.c
字號:
/* * * 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*/// utilizing mono so the main function can easily be attached as a thread function// assuming software demux support only one demux task#include <pthread.h>#include "sample_os.h"#define ENABLE_SPU_OP 1#define ALLOW_OS_CODE 1#include "../dcc/include/dcc.h"#include "../dcc/src/dcc_common.h"#include "common.h"#include "psfdemux_common.h"#include "play_psfdemux_helper.h"#include "main_apps.h"#include "../rmvdemux/include/rmvdemuxapi.h"#include "play_vdemux.h"#define PTS_DISCONTINUITY_DETECTION /* defined for files with pts discontinuities */#define GETBUFFER_TIMEOUT_US (TIMEOUT_10MS)#define SENDDATA_TIMEOUT_US (TIMEOUT_10MS)#define DMA_BUFFER_SIZE_LOG2 15#define DMA_BUFFER_COUNT 32#define REPACK_SIZE (4096)#define VIDEO_FIFO_SIZE (1792*1024)#define AUDIO_FIFO_SIZE (128*1024)#define SPU_FIFO_SIZE (256*1024)#define XFER_FIFO_COUNT (32)#define VIDEO_PTS_FIFO_COUNT (512) /* ~8 sec fifo for 60 frames/sec */#define VIDEO_INBAND_FIFO_COUNT (16)#define RM_DEVICES_STC 0x1#define RM_DEVICES_VIDEO 0x2#define RM_DEVICES_AUDIO 0x4#define KEYFLAGS (SET_KEY_DISPLAY | SET_KEY_PLAYBACK | SET_KEY_AUDIO | SET_KEY_DEBUG)#define PTS_DISCONTINUITY_RANGE 0x20000 // ~1.4sec#if 0 #define SENDDBG ENABLE#else #define SENDDBG DISABLE#endif#if 0#define KEYDBG ENABLE#else#define KEYDBG DISABLE#endif#define WAIT_KEY() \{ \ RMascii key; \ fprintf(stderr, "press key to continue\n"); \ while ( !(RMGetKeyNoWait(&key)) ); \} #define GET_XFER_FIFO_INFO(pRUA, ModuleId) \{ \ struct XferFIFOInfo_type XferFIFOInfo; \ fprintf(stderr, "( %lx: 0x%08lx %ld %ld %ld %ld ) ", ModuleId, XferFIFOInfo.StartAddress, \ XferFIFOInfo.Size, XferFIFOInfo.Writable, XferFIFOInfo.Readable, XferFIFOInfo.Erasable); \ RUAGetProperty(pRUA, ModuleId, RMGenericPropertyID_XferFIFOInfo, &XferFIFOInfo, sizeof(XferFIFOInfo)); \} // copy from dcc_multiple_audio.cstruct DCCMultipleAudioSource { struct RUA *pRUA; struct DCC *pDCC; RMuint32 instances; //number of decoders opened struct DCCAudioSourceHandle AudioSourceHandles[MAX_AUDIO_DECODER_INSTANCES]; RMuint32 nextInstance;};// hardcode the thread filename for now//char alt_filename[] = "/media/transport/mpeg2/svt1.ts";RMascii alt_filename[2048] = { 0, };// software demux thread idpthread_t software_demux_tid;RMbool software_demux_in_action;RMuint64 start_time_stamp;RMuint64 start_file_position;// mirror the task variables from static struct context_per_task *Tasks;static RMuint32 task_count;static RMuint32 output_count_per_task;// software demux keeps its own copy of dcc_info// while command line options structures are shared with the hardware demux modulestatic struct dcc_context dcc_info = {0,};extern RMbool manutest; // should be removedstatic RMbool enable_spu = FALSE;static RMuint32 NTimes = 0;static RMuint32 file_offset = 0;static RMuint32 trickBuffersToSend = 0;static RMuint32 trickSizeToSend = 0;static RMuint32 trickBuffersSent = 0;static struct playback_cmdline *play_opt;static struct video_cmdline *video_opt;static struct audio_cmdline *audio_opt;static struct demux_cmdline *demux_opt;static RMuint32 manutest_res = 0;static struct display_cmdline *disp_opt;struct demux_context { struct RUA *pRUA; struct RUABufferPool *pDMA; RMbool FirstSystemTimeStamp; RMbool ResumeFromTrickMode; RMuint32 audio_byte_counter; RMuint32 video_byte_counter; RMbool repack_sample; RMuint8 *audio_repack_buf; RMuint8 *video_repack_buf; RMuint8 *spu_repack_buf; RMuint32 audio_repack_offset; RMuint32 video_repack_offset; RMuint32 spu_repack_offset; RMuint32 audio_repack_size; RMuint32 video_repack_size; RMuint32 spu_repack_size; RMuint64 audio_repack_pts; RMuint64 video_repack_pts; RMuint64 spu_repack_pts; RMbool audio_repack_pts_valid; RMbool video_repack_pts_valid; RMbool spu_repack_pts_valid; RMbool enable_spu; struct dcc_context *dcc_info; struct RM_PSM_Context *PSMcontext; RMbool isTrickMode; RMbool isIFrameMode; RMbool initVideo; RMbool initAudio; RMbool waitForValidAudioPTS; RMbool waitForValidVideoPTS; RMuint32 cmd; RMuint32 audio_first_access_unit_pointer; // a value of 0 is invalid - see DVD VI.5.2.4 RMbool audio_first_access_unit_pointer_valid; RMuint32 start_90khz; RMint64 file_size; // test user data receive struct ReceiveObject_type *pReceive; struct RUABufferPool *pDmaUserData; struct RUAEvent EventUserData; FILE *f_record; RMuint32 f_record_size; RMbool ignoreCallback; RMbool fakePrevPts; RMuint32 prebufferedBytes; RMint64 realFirstPTS;};static RMstatus SyncTimerWithDecoderPTS(struct demux_context *pSendContext);#define REPACK_AUDIO 1#define REPACK_VIDEO 2#define REPACK_SPU 4#define REPACK_ALL 7static void release_repacked_buffers(void *context, RMuint32 flag){ struct demux_context *pSendContext = (struct demux_context *) context; if ((flag & REPACK_VIDEO) & (pSendContext->video_repack_buf != NULL)) { RUAReleaseBuffer(pSendContext->pDMA, pSendContext->video_repack_buf); pSendContext->video_repack_buf = (RMuint8 *) NULL; pSendContext->video_repack_offset = 0; pSendContext->video_repack_size = 0; pSendContext->video_repack_pts = 0; pSendContext->video_repack_pts_valid = FALSE; } if ((flag & REPACK_AUDIO) && (pSendContext->audio_repack_buf != NULL)) { RUAReleaseBuffer(pSendContext->pDMA, pSendContext->audio_repack_buf); pSendContext->audio_repack_buf = (RMuint8 *) NULL; pSendContext->audio_repack_offset = 0; pSendContext->audio_repack_size = 0; pSendContext->audio_repack_pts = 0; pSendContext->audio_repack_pts_valid = FALSE; } if ((flag & REPACK_SPU) && (pSendContext->spu_repack_buf != NULL)) { RUAReleaseBuffer(pSendContext->pDMA, pSendContext->spu_repack_buf); pSendContext->spu_repack_buf = (RMuint8 *) NULL; pSendContext->spu_repack_offset = 0; pSendContext->spu_repack_size = 0; pSendContext->spu_repack_pts = 0; pSendContext->spu_repack_pts_valid = FALSE; }}static struct RM_PSM_Actions actions;#define PROCESS_KEY(release, getkey) \do { \ RMDBGLOG((KEYDBG, "processkey(%lu, %lu)\n", release, getkey)); \ if (getkey) { \ PlaybackStatus = RM_PSM_GetState(context.PSMcontext, &(context.dcc_info)); \ if ((PlaybackStatus == RM_PSM_Stopped) || (PlaybackStatus == RM_PSM_Paused)) { \ switch (play_opt->disk_ctrl_state) { \ case DISK_CONTROL_STATE_DISABLE: \ case DISK_CONTROL_STATE_SLEEPING: \ break; \ case DISK_CONTROL_STATE_RUNNING: \ if(play_opt->disk_ctrl_callback && play_opt->disk_ctrl_callback(DISK_CONTROL_ACTION_SLEEP) == RM_OK) \ play_opt->disk_ctrl_state = DISK_CONTROL_STATE_SLEEPING; \ break; \ } \ } \ err = process_command(&PSMContext, &(context.dcc_info), &actions); \ if (RMFAILED(err)) { \ fprintf(stderr, "Error processing key %d\n", err); \ goto cleanup; \ } \ } \ if (actions.toDoActions & RM_PSM_FLUSH_VIDEO) { \ RMDBGLOG((ENABLE, "flushVIDEO\n")); \ Stop(&context, RM_DEVICES_VIDEO, DCCStopMode_LastFrame); \ 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.performedActions & RM_PSM_VIDEO_STOPPED) { \ RMDBGLOG((ENABLE, "video stopped\n")); \ context.initVideo = TRUE; \ actions.performedActions &= ~RM_PSM_VIDEO_STOPPED; \ } \ if (actions.performedActions & RM_PSM_AUDIO_STOPPED) { \ RMDBGLOG((ENABLE, "audio stopped\n")); \ if (release) { \ if (context.repack_sample) { \ RMDBGLOG((ENABLE, "release audio buffers\n")); \ release_repacked_buffers(&context, REPACK_AUDIO); \ } \ else { \ RMDBGLOG((ENABLE, "release a buffer\n")); \ RUAReleaseBuffer(pDMA, buf); \ buf = NULL; \ } \ } \ context.initAudio = TRUE; \ context.waitForValidAudioPTS = TRUE; \ actions.performedActions &= ~RM_PSM_AUDIO_STOPPED; \ } \ if ((actions.cmd == RM_QUIT) && (!actions.cmdProcessed)) { \ RMDBGLOG((ENABLE, "quit\n")); \ actions.cmdProcessed = TRUE; \ if (manutest == TRUE) \ manutest_res = RM_QUIT; \ if (release) { \ if (context.repack_sample) { \ RMDBGLOG((ENABLE, "release audio buffers\n")); \ release_repacked_buffers(&context, REPACK_ALL); \ } \ else { \ RMDBGLOG((ENABLE, "release a buffer\n")); \ RUAReleaseBuffer(pDMA, buf); \ buf = NULL; \ } \ } \ goto cleanup; \ } \ if ((manutest == TRUE) && (actions.cmd == RM_MANU_QUIT_OK) && (!actions.cmdProcessed)) { \ if (manutest == TRUE) \ manutest_res = RM_MANU_QUIT_OK; \ if (release) { \ if (context.repack_sample) { \ RMDBGLOG((ENABLE, "release audio buffers\n")); \ release_repacked_buffers(&context, REPACK_ALL); \ } \ else { \ RMDBGLOG((ENABLE, "release a buffer\n")); \ RUAReleaseBuffer(pDMA, buf); \ buf = NULL; \ } \ } \ 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.isTrickMode)) { \ RMDBGLOG((ENABLE, ">> trick mode all frames\n")); \ context.isTrickMode = TRUE; \ } \ if ((RM_PSM_GetState(context.PSMcontext, &(context.dcc_info)) == RM_PSM_Playing) && \ (context.isTrickMode) && \ (actions.cmdProcessed)) { \ RMDBGLOG((ENABLE, ">> resume from trickmode\n")); \ context.isTrickMode = FALSE; \ } \ if (actions.toDoActions & RM_PSM_DEMUX_NORMAL) { \ RMDBGLOG((ENABLE, "demuxNormal\n")); \ context.isTrickMode = FALSE; \ Play(&context, RM_DEVICES_VIDEO, DCCVideoPlayFwd); \ actions.toDoActions &= ~RM_PSM_DEMUX_NORMAL; \ } \ if (actions.toDoActions & RM_PSM_DEMUX_IFRAME) { \ RMDBGLOG((ENABLE, "demuxIFrame\n")); \ Play(&context, RM_DEVICES_VIDEO | RM_DEVICES_STC, DCCVideoPlayIFrame); \ context.isIFrameMode = TRUE; \ if (context.ignoreCallback) \ context.ignoreCallback = FALSE; \ actions.toDoActions &= ~RM_PSM_DEMUX_IFRAME; \ } \ if (actions.toDoActions & RM_PSM_RESYNC_TIMER) { \ RMDBGLOG((ENABLE, "resyncTimer\n")); \ SyncTimerWithDecoderPTS(&context); \ actions.toDoActions &= ~RM_PSM_RESYNC_TIMER; \ } \ if ((RM_PSM_GetState(context.PSMcontext, &(context.dcc_info)) == RM_PSM_Stopped) && (actions.cmdProcessed)) { \ RMDBGLOG((ENABLE,"Got stop command\n")); \ if (release) { \ if (context.repack_sample) { \ RMDBGLOG((ENABLE, "release audio buffers\n")); \ release_repacked_buffers(&context, REPACK_ALL); \ } \ else { \ RMDBGLOG((ENABLE, "release a buffer\n")); \ RUAReleaseBuffer(pDMA, buf); \ buf = NULL; \ } \ } \ context.isIFrameMode = FALSE; \ context.FirstSystemTimeStamp = TRUE; \ goto mainloop_no_seek; \ } \ if ((actions.cmd == RM_STOP_SEEK_ZERO) && (!actions.cmdProcessed)) { \ RMDBGLOG((ENABLE,"Got stop seek zero command\n")); \ Stop(&context, RM_DEVICES_VIDEO | RM_DEVICES_AUDIO | RM_DEVICES_STC, DCCStopMode_BlackFrame); \ RM_PSM_SetState(context.PSMcontext, &(context.dcc_info), RM_PSM_Stopped); \ context.isIFrameMode = FALSE; \ context.FirstSystemTimeStamp = TRUE; \ actions.cmdProcessed = TRUE; \ if (release) { \ if (context.repack_sample) { \ RMDBGLOG((ENABLE, "release audio buffers\n")); \ release_repacked_buffers(&context, REPACK_ALL); \ } \ else { \ RMDBGLOG((ENABLE, "release a buffer\n")); \ RUAReleaseBuffer(pDMA, buf); \ buf = NULL; \ } \ } \ goto mainloop; \ } \ if ((actions.cmd == RM_SEEK) && (!actions.cmdProcessed)) { \ RMDBGLOG((ENABLE, "got seek command\n")); \
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -