Commit daff04bd authored by Steven Liu's avatar Steven Liu

avformat/hlsenc: fix the bug when the largest segment duration pointer right value is 0

when the segments largest duration value is look like 4.000000, the
EXT-X-TARGETDURATION value should equ 4.
it's wrong when hlsenc use ceil, so fix it.
Signed-off-by: 's avatarSteven Liu <lq@chinaffmpeg.org>
parent 2deafd98
...@@ -141,6 +141,11 @@ typedef struct HLSContext { ...@@ -141,6 +141,11 @@ typedef struct HLSContext {
char current_segment_final_filename_fmt[1024]; // when renaming segments char current_segment_final_filename_fmt[1024]; // when renaming segments
} HLSContext; } HLSContext;
static int get_int_from_double(double val)
{
return (int)((val - (int)val) >= 0.001) ? (int)(val + 1) : (int)val;
}
static int mkdir_p(const char *path) { static int mkdir_p(const char *path) {
int ret = 0; int ret = 0;
char *temp = av_strdup(path); char *temp = av_strdup(path);
...@@ -668,8 +673,8 @@ static int hls_window(AVFormatContext *s, int last) ...@@ -668,8 +673,8 @@ static int hls_window(AVFormatContext *s, int last)
goto fail; goto fail;
for (en = hls->segments; en; en = en->next) { for (en = hls->segments; en; en = en->next) {
if (target_duration < en->duration) if (target_duration <= en->duration)
target_duration = ceil(en->duration); target_duration = get_int_from_double(en->duration);
} }
hls->discontinuity_set = 0; hls->discontinuity_set = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment