mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
qtdemux: avoid overflow wraparound in timestamp when adding durations
Do some type juggling to avoid overflow, while still allowing for 'negative' durations (which would need a wraparound effect).
This commit is contained in:
parent
3968dc7688
commit
5ea19b0696
1 changed files with 6 additions and 4 deletions
|
@ -317,7 +317,7 @@ struct _QtDemuxStream
|
|||
guint32 stts_samples;
|
||||
guint32 n_sample_times;
|
||||
guint32 stts_sample_index;
|
||||
guint32 stts_time;
|
||||
guint64 stts_time;
|
||||
guint32 stts_duration;
|
||||
/* stss */
|
||||
gboolean stss_present;
|
||||
|
@ -5623,8 +5623,8 @@ done2:
|
|||
|
||||
for (i = stream->stts_index; i < n_sample_times; i++) {
|
||||
guint32 stts_samples;
|
||||
guint32 stts_duration;
|
||||
guint32 stts_time;
|
||||
gint32 stts_duration;
|
||||
gint64 stts_time;
|
||||
|
||||
if (stream->stts_sample_index >= stream->stts_samples
|
||||
|| !stream->stts_sample_index) {
|
||||
|
@ -5654,7 +5654,9 @@ done2:
|
|||
cur->timestamp = stts_time;
|
||||
cur->duration = stts_duration;
|
||||
|
||||
stts_time += stts_duration;
|
||||
/* avoid 32-bit wrap-around,
|
||||
* but still mind possible 'negative' duration */
|
||||
stts_time += (gint64) stts_duration;
|
||||
cur++;
|
||||
|
||||
if (G_UNLIKELY (cur > last)) {
|
||||
|
|
Loading…
Reference in a new issue