Files
FFmpeg/libavformat
Steven Liu 02edc0f612 avformat/dashdec: fix integer truncation in calc_max_seg_no()
When computing the segment count for a SegmentTimeline entry with
repeat="-1" (indefinite repeat, typical for live streams), the
expression:

  length_of_each_segment = pls->timelines[i]->duration /
                           pls->fragment_timescale;
  num = c->period_duration / length_of_each_segment;

performs two successive integer divisions.  The first division
truncates toward zero; if the segment duration in timescale ticks
is smaller than the timescale (duration < fragment_timescale),
length_of_each_segment becomes 0, and the second division triggers
a division by zero.

Fix this by using av_rescale(), which computes

  period_duration * fragment_timescale / duration

with 64-bit intermediate precision, avoiding both the truncation
and the zero-division risk.  If duration is 0 (invalid manifest),
explicitly fall back to first_seq_no instead of crashing.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
(cherry picked from commit 0c0dd61b8f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-02 06:03:03 +02:00
..
2026-06-23 19:15:57 +02:00
2026-06-23 19:15:57 +02:00
2026-06-23 19:15:57 +02:00
2026-05-08 09:34:52 +02:00
2026-06-23 19:15:57 +02:00
2026-06-23 19:15:57 +02:00
2026-06-23 19:15:57 +02:00
2026-05-29 01:49:20 +00:00
2026-06-16 09:18:24 -03:00
2026-04-28 12:29:37 +00:00
2026-06-23 19:15:57 +02:00
2026-05-23 10:16:38 -05:00
2026-05-23 10:16:38 -05:00
2026-05-22 08:20:13 -05:00
2026-05-03 13:26:34 +00:00
2026-06-23 19:13:06 +02:00
2026-05-03 18:22:46 +02:00
2026-06-23 19:15:57 +02:00
2026-06-23 19:15:57 +02:00
2026-06-26 02:43:34 +02:00