mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +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 stts_samples;
|
||||||
guint32 n_sample_times;
|
guint32 n_sample_times;
|
||||||
guint32 stts_sample_index;
|
guint32 stts_sample_index;
|
||||||
guint32 stts_time;
|
guint64 stts_time;
|
||||||
guint32 stts_duration;
|
guint32 stts_duration;
|
||||||
/* stss */
|
/* stss */
|
||||||
gboolean stss_present;
|
gboolean stss_present;
|
||||||
|
@ -5623,8 +5623,8 @@ done2:
|
||||||
|
|
||||||
for (i = stream->stts_index; i < n_sample_times; i++) {
|
for (i = stream->stts_index; i < n_sample_times; i++) {
|
||||||
guint32 stts_samples;
|
guint32 stts_samples;
|
||||||
guint32 stts_duration;
|
gint32 stts_duration;
|
||||||
guint32 stts_time;
|
gint64 stts_time;
|
||||||
|
|
||||||
if (stream->stts_sample_index >= stream->stts_samples
|
if (stream->stts_sample_index >= stream->stts_samples
|
||||||
|| !stream->stts_sample_index) {
|
|| !stream->stts_sample_index) {
|
||||||
|
@ -5654,7 +5654,9 @@ done2:
|
||||||
cur->timestamp = stts_time;
|
cur->timestamp = stts_time;
|
||||||
cur->duration = stts_duration;
|
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++;
|
cur++;
|
||||||
|
|
||||||
if (G_UNLIKELY (cur > last)) {
|
if (G_UNLIKELY (cur > last)) {
|
||||||
|
|
Loading…
Reference in a new issue