From patchwork Tue Jan 10 15:28:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 2172 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp312123vsb; Tue, 10 Jan 2017 07:28:51 -0800 (PST) X-Received: by 10.28.173.4 with SMTP id w4mr2119915wme.70.1484062131502; Tue, 10 Jan 2017 07:28:51 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d21si1757223wrc.113.2017.01.10.07.28.51; Tue, 10 Jan 2017 07:28:51 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 111AE68A4B2; Tue, 10 Jan 2017 17:28:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgau2.qq.com (smtpbgau2.qq.com [54.206.34.216]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 281FC68081C for ; Tue, 10 Jan 2017 17:28:32 +0200 (EET) X-QQ-mid: bizesmtp14t1484062112t6n8j6cw Received: from localhost (unknown [47.90.47.25]) by esmtp4.qq.com (ESMTP) with id ; Tue, 10 Jan 2017 23:28:31 +0800 (CST) X-QQ-SSF: 01100000008000F0F621000A0000000 X-QQ-FEAT: NviVax2pLsU5iJipiahfHZPWUmy7tal6ILOL+prJKriE/hv43OzrnaYgZOrCy 4bPBQW+yjowrbhGbkJdWW7Z14PNvb72P57/TRdA32GLcdiU90udCRf7+qbdu00ev5cLFY7l IZS0Oa+jVeyDrTzaLOSF4uvpzhybPvnSCbbzcivaYg/fWrvZ+flaABbVglHEZAVGyy2+07P GnOjv+7hGEvlh8049RHI3B8ZrDDpxO2KRL/tG65nO3CKIYORrlok9j3VKM/aeosmSWSHMho 5mhZVQ4UrzlsP2 X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Jan 2017 23:28:29 +0800 Message-Id: <20170110152829.14039-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix the bug when the largest segment duration pointer right value is 0 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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: Steven Liu --- libavformat/hlsenc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 3d2d41a..a2c606c 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -141,6 +141,11 @@ typedef struct HLSContext { char current_segment_final_filename_fmt[1024]; // when renaming segments } 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) { int ret = 0; char *temp = av_strdup(path); @@ -668,8 +673,8 @@ static int hls_window(AVFormatContext *s, int last) goto fail; for (en = hls->segments; en; en = en->next) { - if (target_duration < en->duration) - target_duration = ceil(en->duration); + if (target_duration <= en->duration) + target_duration = get_int_from_double(en->duration); } hls->discontinuity_set = 0;