From patchwork Fri Dec 22 23:29:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 6915 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.79.195 with SMTP id r64csp2933813jad; Fri, 22 Dec 2017 15:30:24 -0800 (PST) X-Google-Smtp-Source: ACJfBou0LQtEV5wFt9XOvUjoPqezQJvz9rMseizqAKYlldidR3ZOZp1duO/0XeDg0Jl76x9qHnPi X-Received: by 10.223.130.36 with SMTP id 33mr16192931wrb.131.1513985424248; Fri, 22 Dec 2017 15:30:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513985424; cv=none; d=google.com; s=arc-20160816; b=ZolJU79HyiWj/wBOtftOF9obo1WkK8DzXvju2qG+qYLUwQdussvL0ktobKx/Qbuv3F mwBBaxv3dZsHBNj091qHmOvKhWrltzrQHw+Q58iqP3ceKui7gZGnQxUZGNfSRNG5kXT3 rE2IMqqibotejSkFHyn6V/7+SpCeUGJrk6SSZnyMwkOws669m8G3eaoqpjpRC681ZRBV jHAndRGbIeCOz57j18W+9Qu7UTIozudSE3NQb266ct6DPYy+2ihkTJXvsxp0sNf8IMcS dAsGYPQ4M0H0BOVzG61amKXzTyM8ZCBLXXpl4PWeRWRSPegO/OcCgzgCdChVZhbP6EJU GtkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:message-id:date:to:from :delivered-to:arc-authentication-results; bh=CUJ+Holf5O9QTR/Yd6+BNqOZFOJviRyOZyvB99790So=; b=M4DQdPjZvuWUXtxGQYmKYZCRWB/jyPk2clvyTfMnwletJQ2+wyKFYVpjLu28kCJV6Q grIMKoUeuoIDQCknVq0NVDQ+Zr6NYfdv7l7kPlqyyT6vNyQkhqLHPmzkYFIGY1EE970b YlrEWeN3/W1Hz3WJ72LSQlYik/QzMKWZevCBlv5ztzF8kb5zA6m+H2qhvVb6aB8DYXyB kTIya1A358+ANAE5AbIMU1aCf9v54LygmrFojTNo2DwFTLaikFdBxhqAd9j/2O1doZNv EHq7EkWTaXY+qM/J4CSqO6MZIetphQhz7x/nBCFNW4ZEKQ4N3iOq7PbTd4VVmUlvDSdB 91lg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m81si7185704wmi.236.2017.12.22.15.30.23; Fri, 22 Dec 2017 15:30:24 -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 965F8680A18; Sat, 23 Dec 2017 01:30:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C2FFC6808B8 for ; Sat, 23 Dec 2017 01:30:03 +0200 (EET) X-QQ-mid: bizesmtp3t1513985397t09wdxj31 Received: from localhost (unknown [221.216.239.70]) by esmtp4.qq.com (ESMTP) with id ; Sat, 23 Dec 2017 07:29:57 +0800 (CST) X-QQ-SSF: 01100000008000F0FKF0B00A0000000 X-QQ-FEAT: r8geFCKg7nbngTaqicWrAn5ohKvq27yGymI/TqD2x5y34XfjacqP8y3taiKou e7JPKI9hTE8a786NHMOgWHyi1vDgX5KutOMMxWvhm2Muzq9bl0D/E/o+ZTEsL0aW/hRAIfq wSOR6GAUFzSZKQL/jhM+8id333UdZFs6yIdBbCr0q7E7Gyy9Hh8hDzsI1kMpL7l0EiKm6WZ xPMEcbeUbr90P8nxKafXcRYZ38d2AlK/TsXD9scYKM9BvsjXzPAHQDxtgtwPMwwBtH4S0JB 7jTUwgwhtqF7ojtzolTM0uiJ803YsQzZNVuQ== X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Dec 2017 07:29:56 +0800 Message-Id: <20171222232956.60998-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.11.0 (Apple Git-81) X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: improve compute target_duration way 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" just use lrint(lrint(duration * 10.0) / 10.0) fix ticket: 6915 Suggested-by: beloko Signed-off-by: Steven Liu --- 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); } 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;