📄 parse_playback_cmdline.c
字号:
options->require_video_audio = FALSE; i ++; err = RM_OK; } *index = i; return err;}RMstatus open_save_files(struct playback_cmdline *options){ if (options->save_video) { options->f_video_data = open("video.out", O_CREAT | O_TRUNC | O_WRONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (options->f_video_data == -1) { fprintf(stderr, "Cannot open file %s\n", "video.out"); return RM_ERROR; } options->f_video_pts = open("videopts.out", O_CREAT | O_TRUNC | O_WRONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (options->f_video_pts == -1) { fprintf(stderr, "Cannot open file %s\n", "videopts.out"); return RM_ERROR; } } if (options->save_audio) { options->f_audio_data = open("audio.out", O_CREAT | O_TRUNC | O_WRONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (options->f_audio_data == -1) { fprintf(stderr, "Cannot open file %s\n", "audio.out"); return RM_ERROR; } options->f_audio_pts = open("audiopts.out", O_CREAT | O_TRUNC | O_WRONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (options->f_audio_pts == -1) { fprintf(stderr, "Cannot open file %s\n", "audiopts.out"); return RM_ERROR; } } if (options->save_spu) { options->f_spu_data = open("spu.out", O_CREAT | O_TRUNC | O_WRONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (options->f_spu_data == -1) { fprintf(stderr, "Cannot open file %s\n", "spu.out"); return RM_ERROR; } options->f_spu_pts = open("spupts.out", O_CREAT | O_TRUNC | O_WRONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (options->f_spu_pts == -1) { fprintf(stderr, "Cannot open file %s\n", "spupts.out"); return RM_ERROR; } } return RM_OK;} RMstatus close_save_files(struct playback_cmdline *options){ if (options->f_video_data != -1) { close(options->f_video_data); options->f_video_data = -1; } if (options->f_video_pts != -1) { close(options->f_video_pts); options->f_video_pts = -1; } if (options->f_audio_data != -1) { close(options->f_audio_data); options->f_audio_data = -1; } if (options->f_audio_pts != -1) { close(options->f_audio_pts); options->f_audio_pts = -1; } if (options->f_spu_data != -1) { close(options->f_spu_data); options->f_spu_data = -1; } if (options->f_spu_pts != -1) { close(options->f_spu_pts); options->f_spu_pts = -1; } return RM_OK;}RMstatus dump_data_into_file(struct playback_cmdline *options, RMvdemuxDataType dataType, RMuint8 *buf, RMuint32 size, RMuint64 PTS, RMbool PTSValid, RMuint32 first_access_unit_pointer){ int fd_data, fd_pts; RMuint32 *byte_count; switch (dataType) { case RMVDEMUX_VIDEO: if (! options->save_video) return RM_OK; fd_data = options->f_video_data; fd_pts = options->f_video_pts; byte_count = &(options->video_byte_count); break; case RMVDEMUX_AUDIO: if (! options->save_audio) return RM_OK; fd_data = options->f_audio_data; fd_pts = options->f_audio_pts; byte_count = &(options->audio_byte_count); break; case RMVDEMUX_SUBPICTURE: if (! options->save_spu) return RM_OK; fd_data = options->f_spu_data; fd_pts = options->f_spu_pts; byte_count = &(options->spu_byte_count); break; default: return RM_ERROR; } RMDBGLOG((DISABLE, "dumping %lu bytes of %s\n", size, (dataType == RMVDEMUX_VIDEO) ? "video":((dataType == RMVDEMUX_AUDIO) ? "audio":"spu"))); if (write(fd_data, buf, size) == -1) return RM_ERROR; fsync(fd_data); if (PTSValid) { RMuint8 temp[4]; RMuint32 ByteCount = *byte_count; if ( first_access_unit_pointer ) ByteCount += (first_access_unit_pointer - 1); temp[0] = (RMuint8)(ByteCount>>24); temp[1] = (RMuint8)(ByteCount>>16); temp[2] = (RMuint8)(ByteCount>>8); temp[3] = (RMuint8)(ByteCount>>0); if (write(fd_pts, temp, 4) == -1) return RM_ERROR; temp[0] = (RMuint8)(PTS>>25); temp[1] = (RMuint8)(PTS>>17); temp[2] = (RMuint8)(PTS>>9); temp[3] = (RMuint8)(PTS>>1); if (write(fd_pts, temp, 4) == -1) return RM_ERROR; } fsync(fd_pts); *byte_count += size; return RM_OK; }RMstatus apply_playback_options(struct dcc_context *dcc_info, struct playback_cmdline *options){ RMstatus err; err = DCCSetMemoryManager(dcc_info->pDCC, options->dram); if (RMFAILED(err)){ RMDBGLOG((ENABLE, "Error setting Dram controller : %d !\n", err)); return RM_ERROR; } return RM_OK;}RMstatus setup_disk_control_parameters(struct dcc_context *dcc_info, struct playback_cmdline *play_opt, struct audio_cmdline *audio_opt, struct video_cmdline *video_opt, struct demux_cmdline *demux_opt){ RMuint32 maxRUAMem = 0; RMuint32 maxBufferingMem = 0; RMuint32 log2BlockSize = 0; RMuint32 videoRequiredMem = 0; RMuint32 videoMinXFERSize = 0; RMuint32 videoDecoderMem = 0; RMuint32 audioRequiredMem = 0; RMuint32 audioMinXFERSize = 0; RMuint32 audioDecoderMem = 0; RMuint32 demuxRequiredMem = 0; RMuint32 demuxMinXFERSize = 0; RMuint32 demuxMem = 0; RMuint32 xferFIFOPerEntrySize = 0; RMuint32 requiredMem = 0; RMstatus status; RMASSERT(dcc_info); RMASSERT(play_opt); maxRUAMem = play_opt->max_usable_RUA_mem; maxBufferingMem = play_opt->disk_ctrl_max_mem; log2BlockSize = play_opt->disk_ctrl_log2_block_size; RMDBGLOG((ENABLE, "setup_disk_control_parameters(maxRUAMem %lu, maxBuffering %lu, log2BlockSize %lu)\n", maxRUAMem, maxBufferingMem, log2BlockSize)); if (video_opt) { struct VideoDecoder_DRAMSize_in_type dram_in; struct VideoDecoder_DRAMSize_out_type dram_out; // compute video memory requirements dram_in.MPEGProfile = video_opt->MPEGProfile; dram_in.BitstreamFIFOSize = 0; dram_in.XferFIFOCount = 0; status = RUAExchangeProperty(dcc_info->pRUA, VideoDecoder, RMVideoDecoderPropertyID_DRAMSize, &dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out)); if (RMFAILED(status)) { RMDBGLOG((ENABLE, "Error getting property RMVideoDecoderPropertyID_DRAMSize! %s\n", RMstatusToString(status))); return status; } // cachedSize = fifo + decoder // uncachedSize = xfer task + xfer task queue videoDecoderMem = dram_out.CachedSize; // fifo = 0 videoMinXFERSize = dram_out.UncachedSize; dram_in.XferFIFOCount = 1; status = RUAExchangeProperty(dcc_info->pRUA, VideoDecoder, RMVideoDecoderPropertyID_DRAMSize, &dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out)); if (RMFAILED(status)) { RMDBGLOG((ENABLE, "Error getting property RMVideoDecoderPropertyID_DRAMSize! %s\n", RMstatusToString(status))); return status; } xferFIFOPerEntrySize = dram_out.UncachedSize - videoMinXFERSize; if (video_opt->xfer_count) videoRequiredMem = videoDecoderMem + video_opt->fifo_size + videoMinXFERSize + (xferFIFOPerEntrySize * video_opt->xfer_count); else videoRequiredMem = videoDecoderMem + video_opt->fifo_size; RMDBGLOG((ENABLE, "video requires %lu bytes (decoder %lu fifo %lu xfer %lu xferCount %lu)\n", videoRequiredMem, videoDecoderMem, video_opt->fifo_size, videoMinXFERSize + (xferFIFOPerEntrySize * video_opt->xfer_count), video_opt->xfer_count)); } if (audio_opt) { struct AudioDecoder_DRAMSize_in_type dram_in; struct AudioDecoder_DRAMSize_out_type dram_out; // compute audio memory requirements /* we need 8 x 0x300(0x180) for Ac3, 8 x 0xF00 for WMA, 8 x 0x400 for WMAPRO => allocate maximum=8 x 0xF00 */ dram_in.MaxChannelOutCount = 8; dram_in.PCMLineCount = 0xf00; dram_in.BitstreamFIFOSize = 0; dram_in.XferFIFOCount = 0; status = RUAExchangeProperty(dcc_info->pRUA, AudioDecoder, RMAudioDecoderPropertyID_DRAMSize, &dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out)); if (RMFAILED(status)) { RMDBGLOG((ENABLE, "Error getting property RMAudioDecoderPropertyID_DRAMSize! %s\n", RMstatusToString(status))); return status; } // cachedSize = fifo + decoder // uncachedSize = xfer task + xfer task queue audioDecoderMem = dram_out.CachedSize; // fifo = 0 audioMinXFERSize = dram_out.UncachedSize; dram_in.XferFIFOCount = 1; status = RUAExchangeProperty(dcc_info->pRUA, AudioDecoder, RMAudioDecoderPropertyID_DRAMSize, &dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out)); if (RMFAILED(status)) { RMDBGLOG((ENABLE, "Error getting property RMAudioDecoderPropertyID_DRAMSize! %s\n", RMstatusToString(status))); return status; } xferFIFOPerEntrySize = dram_out.UncachedSize - audioMinXFERSize; if (audio_opt->xfer_count) audioRequiredMem = audioDecoderMem + audio_opt->fifo_size + audioMinXFERSize + (xferFIFOPerEntrySize * audio_opt->xfer_count); else audioRequiredMem = audioDecoderMem + audio_opt->fifo_size; RMDBGLOG((ENABLE, "audio requires %lu bytes (decoder %lu fifo %lu xfer %lu xferCount %lu)\n", audioRequiredMem, audioDecoderMem, audio_opt->fifo_size, audioMinXFERSize + (xferFIFOPerEntrySize * audio_opt->xfer_count), audio_opt->xfer_count)); } if (demux_opt) { struct DemuxTask_DRAMSizeX_in_type dram_in; struct DemuxTask_DRAMSizeX_out_type dram_out; // compute hwdemux memory requirements dram_in.ProtectedFlags = 0; dram_in.BitstreamFIFOSize = 0; dram_in.XferFIFOCount = 0; dram_in.InbandFIFOCount = 0; dram_in.XTaskModuleId = 0; dram_in.XTaskInbandFIFOCount = 0; status = RUAExchangeProperty(dcc_info->pRUA, DemuxTask, RMDemuxTaskPropertyID_DRAMSizeX, &dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out)); if (RMFAILED(status)) { RMDBGLOG((ENABLE, "Error getting property RMDemuxTaskPropertyID_DRAMSize! %s\n", RMstatusToString(status))); return status; } // cachedSize = fifo // uncachedSize = xfer task + xfer task queue demuxMem = dram_out.BitstreamProtectedSize; // fifo = 0 demuxMinXFERSize = dram_out.UnprotectedSize; dram_in.XferFIFOCount = 1; status = RUAExchangeProperty(dcc_info->pRUA, DemuxTask, RMDemuxTaskPropertyID_DRAMSizeX, &dram_in, sizeof(dram_in), &dram_out, sizeof(dram_out)); if (RMFAILED(status)) { RMDBGLOG((ENABLE, "Error getting property RMDemuxTaskPropertyID_DRAMSize! %s\n", RMstatusToString(status))); return status; } xferFIFOPerEntrySize = dram_out.UnprotectedSize - demuxMinXFERSize; if (demux_opt->xfer_count) demuxRequiredMem = demuxMem + demux_opt->fifo_size + demuxMinXFERSize + (xferFIFOPerEntrySize * demux_opt->xfer_count); else demuxRequiredMem = demuxMem + demux_opt->fifo_size; RMDBGLOG((ENABLE, "demux requires %lu bytes (demux %lu fifo %lu xfer %lu xferCount %lu)\n", demuxRequiredMem, demuxMem, demux_opt->fifo_size, demuxMinXFERSize + (xferFIFOPerEntrySize * demux_opt->xfer_count), demux_opt->xfer_count)); } requiredMem = videoRequiredMem + audioRequiredMem + demuxRequiredMem; RMDBGLOG((ENABLE, ">> required RUA mem %lu\n", requiredMem)); if (requiredMem > maxRUAMem) { RMint32 sizeLeft = (RMint32)maxRUAMem; RMuint32 adjBufferCount = 0; RMuint32 adjXFERCount = 0; // we can only adjust the number of xfer transfers and the number of dmaBuffers // we cannot adjust fifo sizes because they are already minimal for all situations. RMDBGLOG((ENABLE, ">> not enough memory, adjust params\n")); if (video_opt) sizeLeft -= videoDecoderMem + video_opt->fifo_size + videoMinXFERSize; if (audio_opt) sizeLeft -= audioDecoderMem + audio_opt->fifo_size + audioMinXFERSize; if (demux_opt) { sizeLeft -= demuxMem + demux_opt->fifo_size + demuxMinXFERSize; if (sizeLeft <= 0) { fprintf(stderr, "not enough RUA memory for playback, available %lu, required %lu\n", maxRUAMem, requiredMem); return RM_ERROR; } // there's no A/V xfer fifos sizeLeft += videoMinXFERSize + audioMinXFERSize; adjXFERCount = sizeLeft / xferFIFOPerEntrySize; if (log2BlockSize > 15) { RMuint32 fragments = (1 << (log2BlockSize - 15)); adjBufferCount = adjXFERCount / (fragments * 2); } else adjBufferCount = adjXFERCount / 2; } else { if (sizeLeft <= 0) { fprintf(stderr, "not enough RUA memory for playback, available %lu, required %lu\n", maxRUAMem, requiredMem); return RM_ERROR; } sizeLeft /= 2; adjXFERCount = sizeLeft / xferFIFOPerEntrySize; adjBufferCount = (adjXFERCount * 512) >> log2BlockSize; } fprintf(stderr, "\nprevious params:\nbufferCount %lu log2bufferSize %lu bufferingMemory %lu\n", play_opt->dmapool_count, play_opt->dmapool_log2size, (RMuint32)play_opt->dmapool_count << play_opt->dmapool_log2size); if (video_opt) fprintf(stderr, "video: fifoSize %lu xferCount %lu\n", video_opt->fifo_size, video_opt->xfer_count); if (audio_opt) fprintf(stderr, "audio: fifoSize %lu xferCount %lu\n", audio_opt->fifo_size, audio_opt->xfer_count); if (demux_opt) fprintf(stderr, "demux: fifoSize %lu xferCount %lu\n", demux_opt->fifo_size, demux_opt->xfer_count); fprintf(stderr, "\n\n"); play_opt->dmapool_count = adjBufferCount; if (video_opt) video_opt->xfer_count = adjXFERCount; if (audio_opt) audio_opt->xfer_count = adjXFERCount; if (demux_opt) demux_opt->xfer_count = adjXFERCount; fprintf(stderr, "\nnew params:\nbufferCount %lu log2bufferSize %lu bufferingMemory %lu\n", play_opt->dmapool_count, play_opt->dmapool_log2size, (RMuint32)play_opt->dmapool_count << play_opt->dmapool_log2size); if (video_opt) fprintf(stderr, "video: fifoSize %lu xferCount %lu\n", video_opt->fifo_size, video_opt->xfer_count); if (audio_opt) fprintf(stderr, "audio: fifoSize %lu xferCount %lu\n", audio_opt->fifo_size, audio_opt->xfer_count); if (demux_opt) fprintf(stderr, "demux: fifoSize %lu xferCount %lu\n", demux_opt->fifo_size, demux_opt->xfer_count); fprintf(stderr, "\n\n"); } return RM_OK;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -