Skip to content

Commit

Permalink
json: revise range "End" for time and frame ranges
Browse files Browse the repository at this point in the history
"End" was a duration.  It is now the actual "End" position in 90khz
ticks or frames.
  • Loading branch information
jstebbins committed Jan 11, 2017
1 parent 06b07f9 commit 5ed4dc7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
12 changes: 6 additions & 6 deletions gtk/src/callbacks.c
Expand Up @@ -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)
{
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
}
}

Expand Down
41 changes: 30 additions & 11 deletions libhb/hb_json.c
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}
}

Expand Down
11 changes: 9 additions & 2 deletions test/test.c
Expand Up @@ -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)
{
Expand Down

0 comments on commit 5ed4dc7

Please sign in to comment.