mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
codectimestamper: Fix gint wraparound in pts_compare_func
The diff between compared timestamps might be outside the gint range resulting in wrong sorting results. This patch corrects that by comparing the timestamps and then returning -1, 0 or 1 depending on the result. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7726>
This commit is contained in:
parent
e8ab9349f5
commit
06d4629521
2 changed files with 9 additions and 1 deletions
|
@ -506,7 +506,12 @@ gst_codec_timestamper_drain (GstCodecTimestamper * self)
|
|||
static gint
|
||||
pts_compare_func (const GstClockTime * a, const GstClockTime * b)
|
||||
{
|
||||
return (*a) - (*b);
|
||||
if (*a < *b)
|
||||
return -1;
|
||||
else if (*a > *b)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
|
|
@ -128,6 +128,9 @@ GST_START_TEST (test_input_pts_none)
|
|||
GST_BUFFER_PTS (buffer) = 0;
|
||||
fail_unless_equals_int (gst_harness_push (h, buffer), GST_FLOW_OK);;
|
||||
buffer = gst_buffer_new_memdup (h264_idrframe, G_N_ELEMENTS (h264_idrframe));
|
||||
GST_BUFFER_PTS (buffer) = 3 * GST_SECOND;
|
||||
fail_unless_equals_int (gst_harness_push (h, buffer), GST_FLOW_OK);;
|
||||
buffer = gst_buffer_new_memdup (h264_idrframe, G_N_ELEMENTS (h264_idrframe));
|
||||
GST_BUFFER_PTS (buffer) = GST_CLOCK_TIME_NONE;
|
||||
fail_unless_equals_int (gst_harness_push (h, buffer), GST_FLOW_OK);;
|
||||
buffer = gst_buffer_new_memdup (h264_idrframe, G_N_ELEMENTS (h264_idrframe));
|
||||
|
|
Loading…
Reference in a new issue