On 12/23/17 4:59 AM, Steven Liu wrote:
> just use lrint(lrint(duration * 10.0) / 10.0)
> fix ticket: 6915
>
> Suggested-by: beloko
> Signed-off-by: Steven Liu <[email protected]>
> ---
> libavformat/dashenc.c | 2 +-
> libavformat/hlsenc.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 5368a2334c..102558d17e 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -358,7 +358,7 @@ static void output_segment_list(OutputStream *os,
> AVIOContext *out, DASHContext
> Segment *seg = os->segments[i];
> double duration = (double) seg->duration / timescale;
> if (target_duration <= duration)
> - target_duration = lrint(duration);
> + target_duration = lrint(lrint(duration * 10.0) / 10.0);
This will just move the move the corner case from x.5 to x.45(x.46 depending on
the double precision errors). Will not solve the original issue.
For example, right now 1.5 is a corner case, as lrint(1.5) = 2, and lrint(1.49)
= 1.
After this patch, 1.46 will become the corner case. For example
lrint(lrint(1.45 * 10.0) / 10.0) = 1 and lrint(lrint(1.46 * 10.0) / 10.0) = 2
When someone chooses a segment duration of 1.46, this issue will again
resurface.
Thanks and regards,
Karthick
> }
>
> ff_hls_write_playlist_header(out_hls, 6, -1, target_duration,
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 0095ca4339..bf6f1d9253 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1235,7 +1235,7 @@ static int hls_window(AVFormatContext *s, int last,
> VariantStream *vs)
>
> for (en = vs->segments; en; en = en->next) {
> if (target_duration <= en->duration)
> - target_duration = lrint(en->duration);
> + target_duration = lrint(lrint(en->duration * 10.0) / 10.0);
> }
>
> vs->discontinuity_set = 0;
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel