本文整理汇总了C++中DVD_MSEC_TO_TIME函数的典型用法代码示例。如果您正苦于以下问题:C++ DVD_MSEC_TO_TIME函数的具体用法?C++ DVD_MSEC_TO_TIME怎么用?C++ DVD_MSEC_TO_TIME使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DVD_MSEC_TO_TIME函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
double OMXPlayerVideo::NextOverlay(double pts)
{
double delta_start, delta_stop, min_delta = DVD_NOPTS_VALUE;
CSingleLock lock(*m_pOverlayContainer);
VecOverlays* pVecOverlays = m_pOverlayContainer->GetOverlays();
VecOverlaysIter it = pVecOverlays->begin();
//Find the minimum time before a subtitle is added or removed
while (it != pVecOverlays->end())
{
CDVDOverlay* pOverlay = *it++;
if(!pOverlay->bForced && !m_bRenderSubs)
continue;
double pts2 = pOverlay->bForced ? pts : pts - m_iSubtitleDelay;
delta_start = pOverlay->iPTSStartTime - pts2;
delta_stop = pOverlay->iPTSStopTime - pts2;
// when currently on screen, we periodically update to allow (limited rate) ASS animation
if (delta_start <= 0.0 && delta_stop > 0.0 && (min_delta == DVD_NOPTS_VALUE || DVD_MSEC_TO_TIME(100) < min_delta))
min_delta = DVD_MSEC_TO_TIME(100);
else if (delta_start > 0.0 && (min_delta == DVD_NOPTS_VALUE || delta_start < min_delta))
min_delta = delta_start;
else if (delta_stop > 0.0 && (min_delta == DVD_NOPTS_VALUE || delta_stop < min_delta))
min_delta = delta_stop;
}
return min_delta == DVD_NOPTS_VALUE ? pts+DVD_MSEC_TO_TIME(500) : pts+min_delta;
}
示例2: FreeSubtitle
int CDVDOverlayCodecFFmpeg::Decode(DemuxPacket *pPacket)
{
if (!m_pCodecContext || !pPacket)
return 1;
int gotsub = 0, len = 0;
FreeSubtitle(m_Subtitle);
AVPacket avpkt;
av_init_packet(&avpkt);
avpkt.data = pPacket->pData;
avpkt.size = pPacket->iSize;
avpkt.pts = pPacket->pts == DVD_NOPTS_VALUE ? AV_NOPTS_VALUE : (int64_t)pPacket->pts;
avpkt.dts = pPacket->dts == DVD_NOPTS_VALUE ? AV_NOPTS_VALUE : (int64_t)pPacket->dts;
len = avcodec_decode_subtitle2(m_pCodecContext, &m_Subtitle, &gotsub, &avpkt);
if (len < 0)
{
CLog::Log(LOGERROR, "%s - avcodec_decode_subtitle returned failure", __FUNCTION__);
Flush();
return OC_ERROR;
}
if (len != avpkt.size)
CLog::Log(LOGWARNING, "%s - avcodec_decode_subtitle didn't consume the full packet", __FUNCTION__);
if (!gotsub)
return OC_BUFFER;
double pts_offset = 0.0;
if (m_pCodecContext->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE && m_Subtitle.format == 0)
{
// for pgs subtitles the packet pts of the end_segments are wrong
// instead use the subtitle pts to calc the offset here
// see http://git.videolan.org/?p=ffmpeg.git;a=commit;h=2939e258f9d1fff89b3b68536beb931b54611585
if (m_Subtitle.pts != AV_NOPTS_VALUE && pPacket->pts != DVD_NOPTS_VALUE)
{
pts_offset = m_Subtitle.pts - pPacket->pts ;
}
}
m_StartTime = DVD_MSEC_TO_TIME(m_Subtitle.start_display_time);
m_StopTime = DVD_MSEC_TO_TIME(m_Subtitle.end_display_time);
//adapt start and stop time to our packet pts
bool dummy = false;
CDVDOverlayCodec::GetAbsoluteTimes(m_StartTime, m_StopTime, pPacket, dummy, pts_offset);
m_SubtitleIndex = 0;
return OC_OVERLAY;
}
示例3: lock
bool CDVDClock::Update(double clock, double absolute, double limit, const char* log)
{
CExclusiveLock lock(m_critSection);
double was_absolute = SystemToAbsolute(m_startClock);
double was_clock = m_iDisc + absolute - was_absolute;
lock.Leave();
double error = std::abs(clock - was_clock);
// skip minor updates while speed adjust is active
// -> adjusting buffer levels
if (m_speedAdjust != 0 && error < DVD_MSEC_TO_TIME(100))
{
return false;
}
else if (error > limit)
{
Discontinuity(clock, absolute);
CLog::Log(LOGDEBUG, "CDVDClock::Discontinuity - %s - was:%f, should be:%f, error:%f"
, log
, was_clock
, clock
, clock - was_clock);
return true;
}
else
return false;
}
示例4: fabs
double OMXReader::NormalizeFrameduration(double frameduration)
{
//if the duration is within 20 microseconds of a common duration, use that
const double durations[] = {DVD_TIME_BASE * 1.001 / 24.0, DVD_TIME_BASE / 24.0, DVD_TIME_BASE / 25.0,
DVD_TIME_BASE * 1.001 / 30.0, DVD_TIME_BASE / 30.0, DVD_TIME_BASE / 50.0,
DVD_TIME_BASE * 1.001 / 60.0, DVD_TIME_BASE / 60.0
};
double lowestdiff = DVD_TIME_BASE;
int selected = -1;
for (size_t i = 0; i < sizeof(durations) / sizeof(durations[0]); i++)
{
double diff = fabs(frameduration - durations[i]);
if (diff < DVD_MSEC_TO_TIME(0.02) && diff < lowestdiff)
{
selected = i;
lowestdiff = diff;
}
}
if (selected != -1)
{
return durations[selected];
}
else
{
return frameduration;
}
}
示例5: DVD_MSEC_TO_TIME
void OMXPlayerVideo::Output(double pts, bool bDropPacket)
{
if (!g_renderManager.IsStarted()) {
CLog::Log(LOGERROR, "%s - renderer not started", __FUNCTION__);
return;
}
if (CThread::m_bStop)
return;
// we aim to submit subtitles 100ms early
const double preroll = DVD_MSEC_TO_TIME(100);
double media_pts = m_av_clock->OMXMediaTime();
if (m_nextOverlay != DVD_NOPTS_VALUE && media_pts + preroll <= m_nextOverlay)
return;
int buffer = g_renderManager.WaitForBuffer(CThread::m_bStop);
if (buffer < 0)
return;
double subtitle_pts = m_nextOverlay;
double time = subtitle_pts != DVD_NOPTS_VALUE ? subtitle_pts - media_pts : 0.0;
if (m_nextOverlay != DVD_NOPTS_VALUE)
media_pts = m_nextOverlay;
m_nextOverlay = NextOverlay(media_pts);
ProcessOverlays(media_pts);
time += m_av_clock->GetAbsoluteClock();
g_renderManager.FlipPage(CThread::m_bStop, time/DVD_TIME_BASE);
}
示例6: fabs
double CDVDCodecUtils::NormalizeFrameduration(double frameduration, bool *match)
{
//if the duration is within 20 microseconds of a common duration, use that
const double durations[] = {DVD_TIME_BASE * 1.001 / 24.0, DVD_TIME_BASE / 24.0, DVD_TIME_BASE / 25.0,
DVD_TIME_BASE * 1.001 / 30.0, DVD_TIME_BASE / 30.0, DVD_TIME_BASE / 50.0,
DVD_TIME_BASE * 1.001 / 60.0, DVD_TIME_BASE / 60.0};
double lowestdiff = DVD_TIME_BASE;
int selected = -1;
for (size_t i = 0; i < ARRAY_SIZE(durations); i++)
{
double diff = fabs(frameduration - durations[i]);
if (diff < DVD_MSEC_TO_TIME(0.02) && diff < lowestdiff)
{
selected = i;
lowestdiff = diff;
}
}
if (selected != -1)
{
if (match)
*match = true;
return durations[selected];
}
else
{
if (match)
*match = false;
return frameduration;
}
}
示例7: lock
double CDVDClock::ErrorAdjust(double error, const char* log)
{
CSingleLock lock(m_critSection);
double clock, absolute, adjustment;
clock = GetClock(absolute);
// skip minor updates while speed adjust is active
// -> adjusting buffer levels
if (m_speedAdjust != 0 && error < DVD_MSEC_TO_TIME(100))
{
return 0;
}
adjustment = error;
if (m_vSyncAdjust != 0)
{
if (error > 0.5 * m_frameTime)
adjustment = m_frameTime;
else if (error < -0.5 * m_frameTime)
adjustment = -m_frameTime;
else
adjustment = 0;
}
if (adjustment == 0)
return 0;
Discontinuity(clock+adjustment, absolute);
CLog::Log(LOGDEBUG, "CDVDClock::ErrorAdjust - %s - error:%f, adjusted:%f",
log, error, adjustment);
return adjustment;
}
示例8: ofLog
bool OMXReader::SeekTime(int time, bool backwords, double *startpts, bool doLoopOnFail)
{
if(time < 0)
time = 0;
if(!avFormatContext)
return false;
if(fileObject && !fileObject->IoControl(IOCTRL_SEEK_POSSIBLE, NULL))
{
ofLog(OF_LOG_VERBOSE, "%s - input stream reports it is not seekable", __FUNCTION__);
return false;
}
lock();
//FlushRead();
if(avioContext)
{
avioContext->buf_ptr = avioContext->buf_end;
}
int64_t seek_pts = (int64_t)time * (AV_TIME_BASE / 1000);
if (avFormatContext->start_time != (int64_t)AV_NOPTS_VALUE)
{
seek_pts += avFormatContext->start_time;
};
int ret = av_seek_frame(avFormatContext, -1, seek_pts, backwords ? AVSEEK_FLAG_BACKWARD : 0);
if(ret >= 0)
{
updateCurrentPTS();
}else {
//ofLogVerbose(__func__) << "av_seek_frame returned >= 0, no updateCurrentPTS" << ret;
fileObject->rewindFile();
}
// in this case the start time is requested time
if(startpts)
{
*startpts = DVD_MSEC_TO_TIME(time);
}
isEOF = false;
if (fileObject && fileObject->getIsEOF() && ret <= 0)
{
isEOF = true;
ret = 0;
}
unlock();
return (ret >= 0);
}
示例9: Lock
bool OMXReader::SeekTime(int time, bool backwords, double *startpts)
{
if(time < 0)
time = 0;
if(!m_pFormatContext)
return false;
if(m_pFile && !m_pFile->IoControl(IOCTRL_SEEK_POSSIBLE, NULL))
{
CLog::Log(LOGDEBUG, "%s - input stream reports it is not seekable", __FUNCTION__);
return false;
}
Lock();
//FlushRead();
if(m_ioContext)
m_ioContext->buf_ptr = m_ioContext->buf_end;
int64_t seek_pts = (int64_t)time * (AV_TIME_BASE / 1000);
if (m_pFormatContext->start_time != (int64_t)AV_NOPTS_VALUE)
seek_pts += m_pFormatContext->start_time;
int ret = m_dllAvFormat.av_seek_frame(m_pFormatContext, -1, seek_pts, backwords ? AVSEEK_FLAG_BACKWARD : 0);
if(ret >= 0)
{
UpdateCurrentPTS();
}
else {
//m_pFile->rewindFile();
m_pFile->Seek(0);
UpdateCurrentPTS();
wasFileRewound = true;
}
// in this case the start time is requested time
if(startpts)
*startpts = DVD_MSEC_TO_TIME(time);
// demuxer will return failure, if you seek to eof
m_eof = false;
if (m_pFile && m_pFile->IsEOF() && ret <= 0)
{
m_eof = true;
ret = 0;
}
CLog::Log(LOGDEBUG, "OMXReader::SeekTime(%d) - seek ended up on time %d",time,(int)(m_iCurrentPts / DVD_TIME_BASE * 1000));
UnLock();
return (ret >= 0);
}
示例10: Lock
bool OMXReader::SeekTime(int64_t seek_ms, int seek_flags, double *startpts)
{
if(seek_ms < 0)
seek_ms = 0;
if(!m_pFile || !m_pFormatContext)
return false;
if(!m_pFile->IoControl(IOCTRL_SEEK_POSSIBLE, NULL))
return false;
Lock();
//FlushRead();
if(m_ioContext)
m_ioContext->buf_ptr = m_ioContext->buf_end;
int64_t seek_pts = (int64_t)seek_ms * (AV_TIME_BASE / 1000);
if (m_pFormatContext->start_time != (int64_t)AV_NOPTS_VALUE)
seek_pts += m_pFormatContext->start_time;
/* seek behind eof */
if((seek_pts / AV_TIME_BASE) > (GetStreamLength() / 1000))
{
m_eof = true;
UnLock();
return true;
}
int ret = m_dllAvFormat.av_seek_frame(m_pFormatContext, -1, seek_pts, seek_flags ? AVSEEK_FLAG_BACKWARD : 0);
if(ret >= 0)
{
UpdateCurrentPTS();
m_eof = false;
}
if(m_iCurrentPts == DVD_NOPTS_VALUE)
{
CLog::Log(LOGDEBUG, "OMXReader::SeekTime - unknown position after seek");
}
else
{
CLog::Log(LOGDEBUG, "OMXReader::SeekTime - seek ended up on time %d",(int)(m_iCurrentPts / DVD_TIME_BASE * 1000));
}
if(startpts)
*startpts = DVD_MSEC_TO_TIME(seek_ms);
UnLock();
return (ret >= 0);
}
示例11: Reset
bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts)
{
if(time < 0)
time = 0;
if (m_pInput->IsStreamType(DVDSTREAM_TYPE_DVD))
{
CLog::Log(LOGDEBUG, "%s - seeking using navigator", __FUNCTION__);
if (((CDVDInputStreamNavigator*)m_pInput)->SeekTime(time))
{
// since seek happens behind demuxers back, we have to reset it
// this won't be a problem if we setup ffmpeg properly later
Reset();
// todo, calculate starting pts in this case
return true;
}
return false;
}
if(!m_pInput->Seek(0, SEEK_POSSIBLE)
&& !m_pInput->IsStreamType(DVDSTREAM_TYPE_FFMPEG))
{
CLog::Log(LOGDEBUG, "%s - input stream reports it is not seekable", __FUNCTION__);
return false;
}
__int64 seek_pts = (__int64)time * (AV_TIME_BASE / 1000);
if (m_pFormatContext->start_time != (int64_t)AV_NOPTS_VALUE)
seek_pts += m_pFormatContext->start_time;
Lock();
int ret = m_dllAvFormat.av_seek_frame(m_pFormatContext, -1, seek_pts, backwords ? AVSEEK_FLAG_BACKWARD : 0);
if(ret >= 0)
UpdateCurrentPTS();
Unlock();
if(m_iCurrentPts == DVD_NOPTS_VALUE)
CLog::Log(LOGDEBUG, "%s - unknown position after seek", __FUNCTION__);
else
CLog::Log(LOGDEBUG, "%s - seek ended up on time %d", __FUNCTION__, (int)(m_iCurrentPts / DVD_TIME_BASE * 1000));
// in this case the start time is requested time
if(startpts)
*startpts = DVD_MSEC_TO_TIME(time);
// demuxer will return failure, if you seek to eof
if (m_pInput->IsEOF() && ret <= 0)
return true;
return (ret >= 0);
}
示例12: DVD_MSEC_TO_TIME
bool CDVDDemuxVobsub::SeekTime(int time, bool backwords, double* startpts)
{
double pts = DVD_MSEC_TO_TIME(time);
m_Timestamp = m_Timestamps.begin();
for (;m_Timestamp != m_Timestamps.end();++m_Timestamp)
{
if(m_Timestamp->pts > pts)
break;
}
for (unsigned i=0;i<m_Streams.size() && m_Timestamps.begin() != m_Timestamp;i++)
{
--m_Timestamp;
}
return true;
}
示例13: OutputPacket
bool CDVDPlayerAudio::OutputPacket(DVDAudioFrame &audioframe)
{
double syncerror = m_dvdAudio.GetSyncError();
if (m_synctype == SYNC_DISCON && fabs(syncerror) > DVD_MSEC_TO_TIME(10))
{
double correction = m_pClock->ErrorAdjust(syncerror, "CDVDPlayerAudio::OutputPacket");
if (correction != 0)
{
m_dvdAudio.SetSyncErrorCorrection(-correction);
}
}
m_dvdAudio.AddPackets(audioframe);
return true;
}
示例14: GetAbsoluteClock
double OMXClock::OMXMediaTime(bool lock /* = true */)
{
double pts = 0.0;
if(m_omx_clock.GetComponent() == NULL)
return 0;
double now = GetAbsoluteClock();
if (now - m_last_media_time_read > DVD_MSEC_TO_TIME(100) || m_last_media_time == 0.0)
{
if(lock)
Lock();
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
OMX_TIME_CONFIG_TIMESTAMPTYPE timeStamp;
OMX_INIT_STRUCTURE(timeStamp);
timeStamp.nPortIndex = m_omx_clock.GetInputPort();
omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeCurrentMediaTime, &timeStamp);
if(omx_err != OMX_ErrorNone)
{
LOG_ERROR << "OMXClock::MediaTime error getting OMX_IndexConfigTimeCurrentMediaTime";
if(lock)
UnLock();
return 0;
}
pts = FromOMXTime(timeStamp.nTimestamp);
//CLog::Log(LOGINFO, "OMXClock::MediaTime %.2f (%.2f, %.2f)", pts, m_last_media_time, now - m_last_media_time_read);
m_last_media_time = pts;
m_last_media_time_read = now;
if(lock)
UnLock();
}
else
{
double speed = m_pause ? 0.0 : (double)m_omx_speed / DVD_PLAYSPEED_NORMAL;
pts = m_last_media_time + (now - m_last_media_time_read) * speed;
//CLog::Log(LOGINFO, "OMXClock::MediaTime cached %.2f (%.2f, %.2f)", pts, m_last_media_time, now - m_last_media_time_read);
}
return pts;
}
示例15: DVD_MSEC_TO_TIME
bool CVideoPlayerAudio::OutputPacket(DVDAudioFrame &audioframe)
{
double syncerror = m_dvdAudio.GetSyncError();
if (m_synctype == SYNC_DISCON)
{
double limit, error;
limit = DVD_MSEC_TO_TIME(10);
error = syncerror;
double absolute;
double clock = m_pClock->GetClock(absolute);
if (m_pClock->Update(clock + error, absolute, limit - 0.001, "CVideoPlayerAudio::OutputPacket"))
{
m_dvdAudio.SetSyncErrorCorrection(-error);
}
}
m_dvdAudio.AddPackets(audioframe);
return true;
}