Author Topic: "Marker B is out of bounds" complaints from ADM_QSlider on paste  (Read 1346 times)

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3381
"Marker B is out of bounds" complaints from ADM_QSlider on paste
« on: September 22, 2016, 06:16:20 AM »
When pasting from clipboard, A_ResetMarkers() from avidemux/common/gui_main.cpp:1489 gets called, which correctly reports the new duration of the video, e.g.

Code: [Select]
  [pasteFromClipBoard]  Pasting from clipboard to 00:00:14,440
  [updateStartTime]  Using pts2=00:00:00,040 to get dts, as this video does not start at zero
  [A_ResetMarkers]  Video Total duration : 00:00:24,640 ms
 [ADM_QSlider] Marker B is out of bounds (9640000, 15040000)

followed by setMarkerB at avidemux/qt4/ADM_userInterfaces/ADM_gui/ADM_qslider.cpp:75 complaining about marker B being out of bounds as totalDuration obviously doesn't get updated to match the increased length of the video (ADM_QSlider prints the old value for markerBTime and totalDuration). I'm not sure that resetting markers after pasting is desirable from a user's POV, but it would be nice to tell ADM_QSlider that things have changed anyway.
« Last Edit: September 23, 2016, 11:59:53 AM by eumagga0x2a »

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3381
Keep markers A and B on paste
« Reply #1 on: September 22, 2016, 03:01:32 PM »
This is a total rewrite of the post and the topic (but the same patch with a new file name).

Currently, pasting video from clipboard discards existing markers A and B. This is probably done in assumption that the content of the clipboard is the part of the video between the current marker locations and the markers have no value. However, the first assumption must not be necessarily true: a user might have set markers to new positions after having copied a part of the video to the clipboard. The second one is almost never true: finding suitable places for markers can be time consuming and tedious.

The following patch modifies the paste function to keep markers A and B at their logical positions in the video, adjusting both of them or just the marker B accordingly if the content of the clipboard is pasted at a time in video prior to A or between A and B. Additionally, it ensures that the slider position reflects the currently displayed frame at the insertion point:

Code: [Select]
diff --git a/avidemux/common/gui_main.cpp b/avidemux/common/gui_main.cpp
index 873f35e..24ae7fd 100644
--- a/avidemux/common/gui_main.cpp
+++ b/avidemux/common/gui_main.cpp
@@ -481,10 +481,32 @@ void HandleAction (Action action)
     case ACT_Paste:
             {
               uint64_t currentPts=video_body->getCurrentFramePts();
+              uint64_t d=video_body->getVideoDuration();
+              uint64_t markA,markB;
+              markA=video_body->getMarkerAPts();               
+              markB=video_body->getMarkerBPts();
+              if(markA>markB)
+              {
+                  uint64_t p=markA;
+                  markA=markB;
+                  markB=p;
+              }
               video_body->pasteFromClipBoard(currentPts);
               video_body->getVideoInfo (avifileinfo);
-              A_ResetMarkers();
-            ReSync ();
+              d=video_body->getVideoDuration()-d;
+              if(markA>=currentPts)
+              {
+                  markA+=d;
+                  markB+=d;
+              }
+              if(markA<currentPts && currentPts<markB)
+              {
+                  markB+=d;
+              }
+              video_body->setMarkerAPts(markA);
+              video_body->setMarkerBPts(markB);
+            A_Resync();
+            GUI_GoToTime(currentPts);
             }
             break;
       break;

The patch solves also two minor cosmetic issues: as of now, ADM_QSlider doesn't get told about video getting longer and complains about marker B, positioned by A_ResetMarkers() at the new end of the video, being out of bounds, e.g.:

Code: [Select]
  [pasteFromClipBoard]  Pasting from clipboard to 00:00:14,440
  [updateStartTime]  Using pts2=00:00:00,040 to get dts, as this video does not start at zero
  [A_ResetMarkers]  Video Total duration : 00:00:24,640 ms
 [ADM_QSlider] Marker B is out of bounds (9640000, 15040000)

The second issue is the slider jumping to the start while the displayed video frame stays at the insertion point.

(I wonder what is the proper way to query the duration of the video stored in the clipboard?)
« Last Edit: September 23, 2016, 12:01:42 PM by eumagga0x2a »

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3381
Re: "Marker B is out of bounds" complaints from ADM_QSlider on paste
« Reply #2 on: September 26, 2016, 03:19:39 PM »