📄 play_video_checksum.c
字号:
#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,};#ifdef SEND_IBC RMbool ibc_sent = FALSE;#endif#endif struct DCCVideoSource *pVideoSource = 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*/ play_opt = mono->play_opt; video_opt = mono->video_opt; disp_opt = mono->disp_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; dcc_info.disp_info = &disp_info; dcc_info.dh_info = &dh_info; init_display_options(disp_opt); init_playback_options(play_opt); init_video_options(video_opt); video_opt->display_cc = TRUE; disp_opt->dh_info = &dh_info; context.dcc_info = &dcc_info; context.PSMcontext = &PSMContext; parse_cmdline(argc, argv); dcc_info.route = disp_opt->route; videoscaler_id = disp_opt->video_scaler; compute_crclog_filename(play_opt->filename, crcLogFilename); err = RUACreateInstance(&(dcc_info.pRUA), 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; } err = DCCInitMicroCodeEx(dcc_info.pDCC, disp_opt->init_mode); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot initialize microcode %d\n", err)); return -1; } #endif /* init crc table and delete any existing log file. */ crc32_init(); unlink(crcLogFilename); if (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 = 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); 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 = bufferCount * 2; err = setup_disk_control_parameters(&dcc_info, play_opt, NULL, 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 (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; /* 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; RMDBGLOG((ENABLE, "Video:\n\tBitstreamFIFOSize: %lu\n\tFIFOXFERCount: %lu\n", video_opt->fifo_size , video_opt->xfer_count)); RMDBGLOG((ENABLE, "DMA Pool:\n\tSize: %ld\n\tBufferCount: %ld\n\tBufferSize: %ld\n", (play_opt->dmapool_count << play_opt->dmapool_log2size), play_opt->dmapool_count, (1<<play_opt->dmapool_log2size))); 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)); return -1; } { // open first stc module struct DCCStcProfile stc_profile; RMuint32 timeScale; if (video_opt->vcodec == EMhwlibVideoCodec_WMV) timeScale = 1000; else timeScale = 90000; stc_profile.STCID = 0; stc_profile.master = Master_STC; stc_profile.stc_timer_id = 0; stc_profile.stc_time_resolution = timeScale; stc_profile.video_timer_id = 1; stc_profile.video_time_resolution = timeScale; stc_profile.video_offset = -(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 = 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 = 0; /* 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 cleanup; } } /* 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 cleanup; } vcodec = video_profile.Codec; err = DCCXSetVideoDecoderSourceCodec(pVideoSource, vcodec); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot set video decoder codec %d\n", err)); goto cleanup; } } err = DCCGetScalerModuleID(dcc_info.pDCC, dcc_info.route, DCCSurface_Video, videoscaler_id, &(dcc_info.SurfaceID)); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot get surface to display video source %d\n", err)); goto cleanup; }#ifdef INIT_DISPLAY_CONSUMER err = DCCSetSurfaceSource(dcc_info.pDCC, dcc_info.SurfaceID, pVideoSource); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot set the surface source %d\n", err)); goto cleanup; }#endif err = DCCGetVideoDecoderSourceInfo(pVideoSource, &(dcc_info.video_decoder), &(dcc_info.spu_decoder), &(dcc_info.video_timer)); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error getting video decoder source information %d\n", err)); goto cleanup; } dcc_info.pVideoSource = pVideoSource; dcc_info.state = (play_opt->start_pause) ? RM_PAUSED : RM_PLAYING; dcc_info.trickmode_id = RM_NO_TRICKMODE; dcc_info.seek_supported = FALSE; dcc_info.iframe_supported = FALSE; 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")); break; case Profile_WMV_SD: case Profile_WMV_816P: case Profile_WMV_HD: RMDBGLOG((ENABLE, "WMV9 video\n")); 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. Set video timescale\n")); if (!video_opt->vtimescale.enable) { video_opt->vtimescale.enable = TRUE; video_opt->vtimescale.time_resolution = 90000; } break; case Profile_VC1_SD: case Profile_VC1_HD: RMDBGLOG((ENABLE, "WMV9 video\n")); break; case Profile_H264_SD: case Profile_H264_HD: case Profile_H264_SD_DeInt: case Profile_H264_HD_DeInt: RMDBGLOG((ENABLE, "H264 video\n")); break; } // apply the fixed vop rate if required err = apply_video_decoder_options(&dcc_info, video_opt); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error applying video_decoder_options %d\n", err)); goto cleanup; }#ifndef WITH_MONO set_default_out_window(&(dcc_info.disp_info->out_window)); set_default_out_window(&(dcc_info.disp_info->osd_window[0])); set_default_out_window(&(dcc_info.disp_info->osd_window[1])); dcc_info.disp_info->active_window = &(dcc_info.disp_info->out_window); dcc_info.disp_info->video_enable = TRUE; err = apply_display_options(&dcc_info, disp_opt); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot set display options %d\n", err)); goto cleanup; } display_key_usage(KEYFLAGS);#endif /*WITH_MONO*/ /* dmapool must be created after the module open in case we do no copy transfers */ err = RUAOpenPool(dcc_info.pRUA, dcc_info.video_decoder, play_opt->dmapool_count, play_opt->dmapool_log2size, RUA_POOL_DIRECTION_SEND, &pDMA); if (RMFAILED(err)) { RMuint32 poolSize = play_opt->dmapool_count << play_opt->dmapool_log2size; fprintf(stderr, "Error cannot open dmapool %d\n\n" "requested %lu bytes of dmapool (%lu buffers of %lu bytes), make sure you\n" "loaded llad with the right parameters. For example:\n" "max_dmapool_memory_size >= %lu max_dmabuffer_log2_size >= %lu\n\n", err, poolSize, play_opt->dmapool_count, (RMuint32)(1<<play_opt->dmapool_log2size), poolSize, play_opt->dmapool_log2size); goto cleanup; } context.pDMA = pDMA; file = open_stream(play_opt->filename, RM_FILE_OPEN_READ, 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -