diff mbox series

[FFmpeg-devel] avformat/dashdec: Also fetch final partial segment

Message ID 20210405174504.11477-1-git@nerdoftheherd.com
State New
Headers show
Series [FFmpeg-devel] avformat/dashdec: Also fetch final partial segment
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Matt Robinson April 5, 2021, 5:45 p.m. UTC
Currently, the DASH demuxer omits the final segment for a non-live
stream (using SegmentTemplate) if it is shorter than the other segments.

Correct calc_max_seg_no to round up when calulating the number of
segments instead of rounding down to resolve this issue.

Signed-off-by: Matt Robinson <git@nerdoftheherd.com>
---
 libavformat/dashdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Liu April 6, 2021, 1:36 a.m. UTC | #1
> 2021年4月6日 上午1:45,Matt Robinson <git@nerdoftheherd.com> 写道:
> 
> Currently, the DASH demuxer omits the final segment for a non-live
> stream (using SegmentTemplate) if it is shorter than the other segments.
> 
> Correct calc_max_seg_no to round up when calulating the number of
> segments instead of rounding down to resolve this issue.
> 
> Signed-off-by: Matt Robinson <git@nerdoftheherd.com>
> ---
> libavformat/dashdec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 6f3f28dcc7..73effd85db 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -1445,7 +1445,7 @@ static int64_t calc_max_seg_no(struct representation *pls, DASHContext *c)
>     } else if (c->is_live && pls->fragment_duration) {
>         num = pls->first_seq_no + (((get_current_time_in_sec() - c->availability_start_time)) * pls->fragment_timescale)  / pls->fragment_duration;
>     } else if (pls->fragment_duration) {
> -        num = pls->first_seq_no + (c->media_presentation_duration * pls->fragment_timescale) / pls->fragment_duration;
> +        num = pls->first_seq_no + av_rescale_rnd(1, c->media_presentation_duration * pls->fragment_timescale, pls->fragment_duration, AV_ROUND_UP);
>     }
> 
>     return num;
> -- 
> 2.25.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

LGTM


Thanks

Steven Liu
Matt Robinson April 13, 2021, 7:42 p.m. UTC | #2
On Tue, 6 Apr 2021 at 02:36, Steven Liu <lq@chinaffmpeg.org> wrote:
>
> > 2021年4月6日 上午1:45,Matt Robinson <git@nerdoftheherd.com> 写道:
> >
> > Currently, the DASH demuxer omits the final segment for a non-live
> > stream (using SegmentTemplate) if it is shorter than the other segments.
> >
> > Correct calc_max_seg_no to round up when calulating the number of
> > segments instead of rounding down to resolve this issue.
> >
> > Signed-off-by: Matt Robinson <git@nerdoftheherd.com>
> > ---
> > libavformat/dashdec.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> > index 6f3f28dcc7..73effd85db 100644
> > --- a/libavformat/dashdec.c
> > +++ b/libavformat/dashdec.c
> > @@ -1445,7 +1445,7 @@ static int64_t calc_max_seg_no(struct representation *pls, DASHContext *c)
> >     } else if (c->is_live && pls->fragment_duration) {
> >         num = pls->first_seq_no + (((get_current_time_in_sec() - c->availability_start_time)) * pls->fragment_timescale)  / pls->fragment_duration;
> >     } else if (pls->fragment_duration) {
> > -        num = pls->first_seq_no + (c->media_presentation_duration * pls->fragment_timescale) / pls->fragment_duration;
> > +        num = pls->first_seq_no + av_rescale_rnd(1, c->media_presentation_duration * pls->fragment_timescale, pls->fragment_duration, AV_ROUND_UP);
> >     }
> >
> >     return num;
> > --
> > 2.25.1
>
> LGTM
>
>
> Thanks
>
> Steven Liu

Perfect, thank you Steven.

Does anyone else have any comments on the patch, or would somebody be
okay to commit it?

Many Thanks,

Matt
diff mbox series

Patch

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 6f3f28dcc7..73effd85db 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1445,7 +1445,7 @@  static int64_t calc_max_seg_no(struct representation *pls, DASHContext *c)
     } else if (c->is_live && pls->fragment_duration) {
         num = pls->first_seq_no + (((get_current_time_in_sec() - c->availability_start_time)) * pls->fragment_timescale)  / pls->fragment_duration;
     } else if (pls->fragment_duration) {
-        num = pls->first_seq_no + (c->media_presentation_duration * pls->fragment_timescale) / pls->fragment_duration;
+        num = pls->first_seq_no + av_rescale_rnd(1, c->media_presentation_duration * pls->fragment_timescale, pls->fragment_duration, AV_ROUND_UP);
     }
 
     return num;