📄 play_video_checksum.c
字号:
headerread = StoreHeader(buf, header, &HeaderSize, (1<<play_opt->dmapool_log2size)); if (headerread) RMDBGLOG((ENABLE, "stored SeqHeader, %lu bytes\n", HeaderSize)); }#endif //STORE_SEQ_HEADER_LOCALLY /* fast forward may have been too fast for the decoder. Must set the STC to the current picture in display to avoid skipping frames to catch STC */ if (context.byte_counter == 0) { /* set the VopInfo property */ if (video_opt->MSflag == TRUE) { RMuint32 timeScale; DCCSTCGetTimeResolution(dcc_info.pStcSource, DCC_Video, &timeScale); DCCSTCSetTime(dcc_info.pStcSource, play_opt->send_video_pts ? MSPts : 0, timeScale); } else { DCCSTCSetTime(dcc_info.pStcSource, 0, 90000); Info.ValidFields = TIME_STAMP_INFO; Info.TimeStamp = 0; } } else if ((context.ResyncTimer) && (!context.FirstPTS)) { RMuint64 stc; RMuint32 timeScale; RMuint64 currentSTC; err = RUAGetProperty(dcc_info.pRUA, dcc_info.SurfaceID, RMGenericPropertyID_CurrentDisplayPTS, &stc, sizeof(stc)); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot get video PTS\n")); } DCCSTCGetTimeResolution(dcc_info.pStcSource, DCC_Video, &timeScale); if (timeScale == 90000) stc *= 2; DCCSTCGetTime(dcc_info.pStcSource, ¤tSTC, timeScale); RMDBGLOG((ENABLE, "resync STC(%llu) to %llu, timeScale %lu\n", currentSTC, stc, timeScale)); DCCSTCSetTime(dcc_info.pStcSource, stc, timeScale); context.ResyncTimer = FALSE; } else if (context.FirstPTS) { //after a seek RMDBGLOG((ENABLE, "first pts %lu\n", context.FirstPTS)); DCCSTCSetTime(dcc_info.pStcSource, context.FirstPTS, 90000); Info.ValidFields = TIME_STAMP_INFO; Info.TimeStamp = context.FirstPTS; context.FirstPTS = 0; context.FirstSystemTimeStamp = FALSE; } else { Info.ValidFields = 0; Info.TimeStamp = 0; } if (RM_PSM_GetState(context.PSMcontext, &(context.dcc_info)) == RM_PSM_Prebuffering) { RMDBGPRINT((ENABLE, ".")); } if (video_opt->MSflag == TRUE) { if ((RMint64) MSPts != -1) { Info.ValidFields = play_opt->send_video_pts ? TIME_STAMP_INFO:0; Info.TimeStamp = MSPts; } else Info.ValidFields = 0; RMDBGLOG((DISABLE, "MSPts = %lld (0x%llx) pts= %lld (0x%llx) (valid %lu) byte_counter=0x%lx\n", MSPts, MSPts, Info.TimeStamp, Info.TimeStamp, Info.ValidFields, context.byte_counter)); } RMDBGLOG((SENDDBG, "sending %lu bytes, pts %llu, valid %lu\n", count, Info.TimeStamp, (RMuint32)Info.ValidFields)); if (Info.ValidFields) context.last_video_pts = Info.TimeStamp; while (RUASendData(dcc_info.pRUA, dcc_info.video_decoder, pDMA, buf, count, &Info, sizeof(Info)) != RM_OK) { struct RUAEvent e; /* see previous comment on RUAGetBuffer */ check_prebuf_state(&context, 0);// PROCESS_KEY(TRUE, TRUE); e.ModuleID = dcc_info.video_decoder; e.Mask = RUAEVENT_XFER_FIFO_READY; RUAWaitForMultipleEvents(dcc_info.pRUA, &e, 1, COMMON_TIMEOUT_US, NULL); } context.bitrate += count * 8; context.byte_counter += count; /* sendind data may fill-up the xfer fifo, so we reset the event */ { struct RUAEvent e; e.ModuleID = dcc_info.video_decoder; e.Mask = RUAEVENT_XFER_FIFO_READY; RUAResetEvent(dcc_info.pRUA, &e); } RUAReleaseBuffer(pDMA, buf); buf = NULL;#ifdef DO_CAPTURE get_picture(context.dcc_info);#endif if (RMKeyAvailable()) { RMuint8 key = RMGetKey(); if ((key == 'Q') || (key == 'q')) { break; } } } //while(1)// check_prebuf_state(&context, 0); 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; }#if 1 err = WaitForEOS(&context, &actions); { RMuint64 stc; DCCSTCGetTime(dcc_info.pStcSource, &stc, 90000); RMDBGLOG((ENABLE, "Timer duration %llu s\n", stc/90000)); } err = WaitForFrames(&context); if (err == RM_OK) break;#else err = WaitForEOS(&context, &actions); { RMuint64 stc; DCCSTCGetTime(dcc_info.pStcSource, &stc, 90000); RMDBGLOG((ENABLE, "Timer duration %llu s\n", stc/90000)); } if (err == RM_KEY_WHILE_WAITING_EOS) { RMDBGLOG((ENABLE, "command while waiting for EOS\n")); err = RM_OK; PROCESS_KEY(FALSE, FALSE); } else {#ifdef WITH_MONO /* callback to signal EOS to curacao/mono */ RMEOSCallback(); break;#else // WITH_MONO break; // EOS#endif // WITH_MONO }#endif // 1 } // additional while if (play_opt->loop_count > 0) play_opt->loop_count --; /* if there is another loop, send stop... */ if ((play_opt->loop_count > 0) || (play_opt->waitexit != TRUE) || (play_opt->infinite_loop)) Stop(&context, RM_DEVICES_VIDEO | RM_DEVICES_STC); } while ((play_opt->loop_count > 0) || (play_opt->infinite_loop)); cleanup: if (file) RMCloseFile(file); if( play_opt->waitexit ) { RMascii key; Stop(&context, RM_DEVICES_STC); fprintf(stderr, "press q key again if you really want to stop & quit\n"); while ( !(RMGetKeyNoWait(&key) && ((key == 'q') || (key =='Q'))) ); Stop(&context, RM_DEVICES_VIDEO | RM_DEVICES_STC); }#ifndef WITH_MONO RMTermExit();#endif if (dmabuffer_index) { RMuint32 i; for (i = 0; i < dmabuffer_index; i++) { RUAReleaseBuffer(pDMA, dmabuffer_array[i]); RMDBGLOG((ENABLE, "released buffer[%lu] @ 0x%08lx\n", i, dmabuffer_array[i])); } RMFree(dmabuffer_array); } if (context.bcc_enabled) { RMDBGLOG((DEBUG, "Closing external closed caption subsystem...\n")); bcc_close(context.pbcc, dcc_info.pRUA); context.bcc_enabled = FALSE; RMDBGLOG((DEBUG, "Done closing external closed caption subsystem.\n")); } if (dcc_info.pStcSource) { Stop(&context, RM_DEVICES_STC); RMDBGLOG((DEBUG, "Closing STC...\n")); err = DCCSTCClose(dcc_info.pStcSource); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error cannot close STC %d\n", err)); } RMDBGLOG((DEBUG, "Done closing STC.\n")); } if (pVideoSource) { RMDBGLOG((DEBUG, "Stopping video source...\n")); err = DCCStopVideoSource(pVideoSource, DCCStopMode_LastFrame); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot stop video decoder %d\n", err)); } RMDBGLOG((DEBUG, "Done stopping video source.\n")); RMDBGLOG((DEBUG, "Closing video source...\n")); err = DCCCloseVideoSource(pVideoSource); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error cannot close video decoder %d\n", err)); } RMDBGLOG((DEBUG, "Done closing video source.\n"));#ifndef WITH_MONO clear_display_options(&dcc_info, disp_opt);#endif /*WITH_MONO*/ } clear_video_options(&dcc_info, video_opt); if (pDMA) { RMDBGLOG((DEBUG, "Closing RUA DMA pool...\n")); err = RUAClosePool(pDMA); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error cannot close dmapool %d\n", err)); } RMDBGLOG((DEBUG, "Done closing RUA DMA pool.\n")); }#ifndef WITH_MONO err = DCCClose(dcc_info.pDCC); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot close DCC %d\n", err)); } err = RUADestroyInstance(dcc_info.pRUA); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot destroy RUA instance %d\n", err)); return -1; }#endif /*WITH_MONO*/ return 0;}#ifdef DO_CAPTURE/* Check FIFO, if picture is available copy data... */int get_picture(struct dcc_context *dccContext) { int result = 0; struct VideoDecoder_NextPicture_type new_pic; RMstatus err; struct RUA* pRUA = dccContext->pRUA; static RMuint32 framecount = 0;// RMDBGLOG((ENABLE, "get_picture()\n")); err = RUAGetProperty(dccContext->pRUA, dccContext->video_decoder, RMVideoDecoderPropertyID_NextPicture, &new_pic, sizeof(new_pic)); if(err == RM_OK) { RMuint32 luma_x, luma_y; RMuint32 luma_w, luma_h; RMuint32 chroma_x, chroma_y; RMuint32 chroma_w, chroma_h; RMuint32 luma_address, chroma_address; RMuint32 luma_width, chroma_width; RMuint32 luma_size_linear, chroma_size_linear; RMuint32 luma_size_tile, chroma_size_tile; RMuint32 buf_width, buf_height; RMuint8* pLuma; RMuint8* pChroma;#ifdef DO_CRC32 RMuint32 luma_crc, chroma_crc; FILE* ofp;#endif// RMuint32 a;#ifdef HANDLE_DISPLAY_STATUS if (new_pic.Picture.picture_display_status) {#endif#ifdef DO_CRC32 ofp = fopen(crcLogFilename, "a");#endif RMDBGLOG((CRCDBG, "FRAME %ld AVAILABLE @ 0x%08lx!\n", framecount, new_pic.PictureAddress)); luma_x = new_pic.Picture.luma_position_in_buffer.x; luma_y = new_pic.Picture.luma_position_in_buffer.y; luma_w = new_pic.Picture.luma_position_in_buffer.width; luma_h = new_pic.Picture.luma_position_in_buffer.height; RMDBGLOG((ENABLE, "FRAME DIMENSIONS : %ld X %ld\n", luma_w, luma_h)); // RMDBGLOG((ENABLE, "LUMA: X=%d Y=%d W=%d H=%d\n", luma_x, luma_y, luma_w, luma_h)); chroma_x = new_pic.Picture.chroma_position_in_buffer.x; chroma_y = new_pic.Picture.chroma_position_in_buffer.y; chroma_w = new_pic.Picture.chroma_position_in_buffer.width; chroma_h = new_pic.Picture.chroma_position_in_buffer.height; // RMDBGLOG((ENABLE, "CHROMA: X=%d Y=%d W=%d H=%d\n", chroma_x, chroma_y, chroma_w, chroma_h)); /* Get Luma & Chroma addresses */ luma_address = new_pic.Picture.luma_address; chroma_address = new_pic.Picture.chroma_address; RMDBGLOG((CRCDBG, "LUMA @ 0x%08lx CHROMA @ 0x%08lx\n", luma_address, chroma_address)); luma_width = new_pic.Picture.luma_total_width ; //& 0x3f; chroma_width = new_pic.Picture.chroma_total_width ; // & 0x3f; RMDBGLOG((CRCDBG, "LUMA WIDTH = %ld CHROMA WIDTH = %ld\n", luma_width, chroma_width)); /* luma */ buf_width = ((luma_w + 127)/128)*128; buf_height = ((luma_h + 31)/32)*32; luma_size_tile = (buf_width * buf_height); RMDBGLOG((CRCDBG, "LUMA TILE BUFFER %ld x %ld size = %ld\n", buf_width, buf_height, luma_size_tile)); /* chroma */ buf_width = ((chroma_w + 127)/128)*128; buf_height = ((chroma_h + 31)/32)*32; chroma_size_tile = (buf_width * buf_height) * 2; RMDBGLOG((CRCDBG, "CHROMA TILE BUFFER %ld x %ld size = %ld\n", buf_width, buf_height, chroma_size_tile)); luma_size_linear = luma_w * luma_h; chroma_size_linear = chroma_w * chroma_h * 2;#if 0 if (new_pic.Picture.picture_display_status == 0) { RMDBGLOG((ENABLE, "picture_decode_status = %ld picture_display_status = %ld\n", new_pic.Picture.picture_decode_status, new_pic.Picture.picture_display_status)); RMDBGLOG((ENABLE, "LUMA BUFFER @ 0x%08lx CHROMA BUFFER @ 0x%08lx\n", luma_address, chroma_address)); RMDBGLOG((ENABLE, "___WAITING____\n")); while (1) { sleep(1); } }#endif#ifdef WAIT_FOR_KEY /* if environment WAITKEY is defined, wait for user to hit a key. */ if (getenv("WAITKEY") != 0L) { printf("HIT A KEY!\n"); while (!RMKeyAvailable()) { } RMGetKey(); }#endif /* lock memory regions */ err = RUALock(pRUA, luma_address, luma_size_tile); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "ERROR: Unable to lock luma buffer!\n")); } err = RUALock(pRUA, chroma_address, chroma_size_tile); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "ERROR: Unable to lock chroma buffer!\n")); } /* map memory regions */ pLuma = RUAMap(pRUA, luma_address, luma_size_tile); pChroma = RUAMap(pRUA, chroma_address, chroma_size_tile); RMDBGLOG((CRCDBG, "Mapped Luma @ 0x%08lx and Chroma @ 0x%08lx\n", (RMuint32)pLuma, (RMuint32)pChroma));#ifdef DO_CRC32#ifdef DO_SOFT_CRC luma_crc = _crc32(pLuma, luma_width, luma_x, luma_w, luma_y, luma_h, 0, 0); chroma_crc = _crc32(pChroma, chroma_width, chroma_x, chroma_w*2, chroma_y, chroma_h, 0, 0); RMDBGLOG((CRCDBG, "FRAME # %ld : LUMA CRC = 0x%08lx CHROMA CRC = 0x%08lx\n", framecount, luma_crc, chroma_crc));#else // DO_SOFT_CRC luma_crc = crc32_be_h(pRUA, luma_address, luma_width, luma_x, luma_w, luma_y, luma_h); chroma_crc = crc32_be_h(pRUA, chroma_address, chroma_width, chroma_x, chroma_w * 2, chroma_y, chroma_h);#endif // DO_SOFT_CRC fprintf(stderr, "#%10lu luma %10lx chroma %10lx\n", framecount, luma_crc, chroma_crc); // to standard error stream if (ofp) fprintf(ofp, "#%10lu luma %10lx chroma %10lx\n", framecount, luma_crc, chroma_crc); // to file#endif // DO_CRC32#ifdef DO_SAVE /* if environment SAVEPATH is defined, save the Y, U, & V components to specified path. */ if (getenv(SAVEPATH) != NULL) save_frame( framecount, pLuma, luma_w, luma_h, luma_width, pChroma, chroma_w, chroma_h, ch
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -