]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Fix to PTS/frame mapping in demuxer
authorMark Calderbank <mark@vomp.tv>
Sun, 11 Jun 2006 21:46:52 +0000 (21:46 +0000)
committerMark Calderbank <mark@vomp.tv>
Sun, 11 Jun 2006 21:46:52 +0000 (21:46 +0000)
demuxervdr.cc

index 9bdf7bace8e8d4f636c7ebbe97e54e0f52a683ad..526b300ec199699dff9e538a08d3f60f06ac8a3e 100644 (file)
@@ -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()