]> granicus.if.org Git - handbrake/commitdiff
json: revise range "End" for time and frame ranges
authorJohn Stebbins <jstebbins.hb@gmail.com>
Wed, 11 Jan 2017 21:25:07 +0000 (14:25 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Wed, 11 Jan 2017 21:26:48 +0000 (14:26 -0700)
"End" was a duration.  It is now the actual "End" position in 90khz
ticks or frames.

gtk/src/callbacks.c
libhb/hb_json.c
test/test.c

index a83e5495ec46c3f1dadf2f8c9851057bd04f990f..62e8f236375076c554f5c9c2d458cfaffa63ed27 100644 (file)
@@ -2478,7 +2478,7 @@ start_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
         update_title_duration(ud);
 
         ghb_dict_set_int(range, "Start", start * 90000);
-        ghb_dict_set_int(range, "End", (end - start) * 90000);
+        ghb_dict_set_int(range, "End", end * 90000);
     }
     else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2)
     {
@@ -2492,8 +2492,8 @@ start_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
         ghb_check_dependency(ud, widget, NULL);
         update_title_duration(ud);
 
-        ghb_dict_set_int(range, "Start", start - 1);
-        ghb_dict_set_int(range, "End", end - start + 1);
+        ghb_dict_set_int(range, "Start", start);
+        ghb_dict_set_int(range, "End", end);
     }
 }
 
@@ -2542,7 +2542,7 @@ end_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
         update_title_duration(ud);
 
         ghb_dict_set_int(range, "Start", start * 90000);
-        ghb_dict_set_int(range, "End", (end - start) * 90000);
+        ghb_dict_set_int(range, "End", end * 90000);
     }
     else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2)
     {
@@ -2556,8 +2556,8 @@ end_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
         ghb_check_dependency(ud, widget, NULL);
         update_title_duration(ud);
 
-        ghb_dict_set_int(range, "Start", start - 1);
-        ghb_dict_set_int(range, "End", end - start + 1);
+        ghb_dict_set_int(range, "Start", start);
+        ghb_dict_set_int(range, "End", end);
     }
 }
 
index 296cd9d2492acd9046daf28e272c4006ad77f934..32975785d4737f7ca2c382bab4eabee78a91d866 100644 (file)
@@ -468,19 +468,38 @@ hb_dict_t* hb_job_to_dict( const hb_job_t * job )
             "End",        hb_value_int(job->pts_to_stop),
             "SeekPoints", hb_value_int(job->seek_points));
     }
-    else if (job->pts_to_start != 0)
+    else if (job->pts_to_start != 0 || job->pts_to_stop != 0)
     {
         range_dict = json_pack_ex(&error, 0, "{s:o, s:o, s:o}",
             "Type",  hb_value_string("time"),
             "Start", hb_value_int(job->pts_to_start),
             "End",   hb_value_int(job->pts_to_stop));
+        range_dict = hb_dict_init();
+        hb_dict_set(source_dict, "Type", hb_value_string("time"));
+        if (job->pts_to_start > 0)
+        {
+            hb_dict_set(source_dict, "Start", hb_value_int(job->pts_to_start));
+        }
+        if (job->pts_to_stop > 0)
+        {
+            hb_dict_set(source_dict, "End",
+                        hb_value_int(job->pts_to_start + job->pts_to_stop));
+        }
     }
-    else if (job->frame_to_start != 0)
+    else if (job->frame_to_start != 0 || job->frame_to_stop != 0)
     {
-        range_dict = json_pack_ex(&error, 0, "{s:o, s:o, s:o}",
-            "Type",  hb_value_string("frame"),
-            "Start", hb_value_int(job->frame_to_start),
-            "End",   hb_value_int(job->frame_to_stop));
+        range_dict = hb_dict_init();
+        hb_dict_set(source_dict, "Type", hb_value_string("frame"));
+        if (job->frame_to_start > 0)
+        {
+            hb_dict_set(source_dict, "Start",
+                        hb_value_int(job->frame_to_start + 1));
+        }
+        if (job->frame_to_stop > 0)
+        {
+            hb_dict_set(source_dict, "End",
+                        hb_value_int(job->frame_to_start + job->frame_to_stop));
+        }
     }
     else
     {
@@ -970,14 +989,14 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict )
             if (range_start >= 0)
                 job->pts_to_start = range_start;
             if (range_end >= 0)
-                job->pts_to_stop = range_end;
+                job->pts_to_stop = range_end - job->pts_to_start;
         }
         else if (!strcasecmp(range_type, "frame"))
         {
-            if (range_start >= 0)
-                job->frame_to_start = range_start;
-            if (range_end >= 0)
-                job->frame_to_stop = range_end;
+            if (range_start > 0)
+                job->frame_to_start = range_start - 1;
+            if (range_end > 0)
+                job->frame_to_stop = range_end - job->frame_to_start;
         }
     }
 
index 2d21d153b1cdb92d2fe0c1015df5669cb5955185..d48e88a8b71f869b5fba671dea64b09f438cd22d 100644 (file)
@@ -4026,13 +4026,20 @@ PrepareJob(hb_handle_t *h, hb_title_t *title, hb_dict_t *preset_dict)
     {
         range_type = "time";
         range_start = start_at_pts;
-        range_end = stop_at_pts;
+        if (stop_at_pts > 0)
+            range_end = start_at_pts + stop_at_pts;
     }
     else if (start_at_frame || stop_at_frame)
     {
         range_type = "frame";
         range_start = start_at_frame;
-        range_end = stop_at_frame;
+        if (stop_at_frame > 0)
+        {
+            if (start_at_frame > 0)
+                range_end = start_at_frame + stop_at_frame - 1;
+            else
+                range_end = stop_at_frame;
+        }
     }
     if (range_start || range_end)
     {