From d941362c13eceb888dc3ee843ddb5df7de82696b Mon Sep 17 00:00:00 2001 From: Mark Calderbank Date: Sun, 11 Jun 2006 21:46:52 +0000 Subject: [PATCH] Fix to PTS/frame mapping in demuxer --- demuxervdr.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/demuxervdr.cc b/demuxervdr.cc index 9bdf7ba..526b300 100644 --- a/demuxervdr.cc +++ b/demuxervdr.cc @@ -255,20 +255,29 @@ ULONG DemuxerVDR::getFrameNumFromPTS(ULLONG pts) bool onTarget = false; while (iter != pts_map.end()) { - bool inRange; + bool inRange, inDoubleRange; if (pts < PTSMAP_THRESHOLD) inRange = (iter->pts <= pts || iter->pts >= (1LL<<33) - PTSMAP_THRESHOLD + pts); else inRange = (iter->pts <= pts && iter->pts >= pts - PTSMAP_THRESHOLD); + + if (pts < PTSMAP_THRESHOLD*2) + inDoubleRange = (iter->pts <= pts || + iter->pts >= (1LL<<33) - PTSMAP_THRESHOLD*2 + pts); + else + inDoubleRange = (iter->pts <= pts && + iter->pts >= pts - PTSMAP_THRESHOLD*2); + if (onTarget) { - if (!inRange) break; // We have hit the target + if (!inDoubleRange) break; // We have hit the target } else { - if (inRange) onTarget = true; // We are hot on the trail + if (inRange){ onTarget = true; // We are hot on the trail + Log::getInstance()->log("Demuxer", Log::DEBUG, "ON TARGET AT %d", iter->frame); } } ++iter; } @@ -276,9 +285,15 @@ ULONG DemuxerVDR::getFrameNumFromPTS(ULLONG pts) if (onTarget) ret = iter->frame; pthread_mutex_unlock(&pts_map_mutex); if (!onTarget) + { + Log::getInstance()->log("Demuxer", Log::DEBUG, "FAILED TO FIND FRAME NUMBER for %llu", pts); return 0; + } else + { + Log::getInstance()->log("Demuxer", Log::DEBUG, "FOUND FRAME NUMBER %d for %llu", ret, pts); return ret; + } } void DemuxerVDR::PESPacketVDR::parseDetails() -- 2.39.5