Copy to clipboard: Weird negative offsets printed for markers with long videos

Started by eumagga0x2a, October 07, 2016, 05:40:38 PM

Previous topic - Next topic

eumagga0x2a

We get negative values for offset printed for markers A and B in ADM_EditorSegment::copyToClipBoard in sufficiently long videos like

  [copyToClipBoard]  Copy to clipboard from 00:35:06,424  [copyToClipBoard]  to 00:39:14,584
  [convertLinearTimeToSeg]  End of last segment
Segment :0/1
Reference    :0    00:00:00,000
startLinear  :00000000 00:00:00,000
duration     :2354584655 00:39:14,584
refStartPts  :00000000 00:00:00,000
refStartDts  :00000000 00:00:00,000
Adding segment 0 to clipboard
Marker A is here offset=2106424655
Marker B is here offset=-1940382641
Segment :0/1
Reference    :0    00:00:00,000
startLinear  :2106424655 00:35:06,424
duration     :248160000 00:04:08,160
refStartPts  :2106424655 00:35:06,424
refStartDts  :00000000 00:00:00,000


The following patch uses PRIu64 and drops casting uint64_t to int:

diff --git a/avidemux/common/ADM_editor/src/ADM_segment.cpp b/avidemux/common/ADM_editor/src/ADM_segment.cpp
index fbfd4e1..f5f3c12 100644
--- a/avidemux/common/ADM_editor/src/ADM_segment.cpp
+++ b/avidemux/common/ADM_editor/src/ADM_segment.cpp
@@ -821,14 +821,14 @@ bool        ADM_EditorSegment::copyToClipBoard(uint64_t startTime, uint64_t endT
             s._refStartTimeUs+=offset;
             s._durationUs-=offset;         // take into account the part we chopped
             s._startTimeUs+=offset;
-            aprintf("Marker A is here offset=%d\n",(int)offset);
+            aprintf("Marker A is here offset=%" PRIu64"\n",offset);
         }
         if(s2._startTimeUs<=endTime && (s2._startTimeUs+s2._durationUs)>=endTime)
         {           
             // need to refine last seg           
             uint64_t offset=endTime-s2._startTimeUs;
             s._durationUs=endTime-s._startTimeUs;
-            aprintf("Marker B is here offset=%d\n",(int)offset);
+            aprintf("Marker B is here offset=%" PRIu64"\n",offset);
         }
         // TODO refine timing for 1st/last/duration/...
         clipboard.push_back(s);