From patchwork Thu Dec 31 08:15:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 24728 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id EA30744AA60 for ; Thu, 31 Dec 2020 10:16:31 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B48F468A765; Thu, 31 Dec 2020 10:16:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from qq.com (out203-205-221-233.mail.qq.com [203.205.221.233]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D06A0689F20 for ; Thu, 31 Dec 2020 10:16:24 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1609402579; bh=lioYzi4hmAvfbcxAlj18tX56044LIuR12W4NlBvSc9s=; h=From:To:Cc:Subject:Date; b=MBFvA+4FxRMc3rE1Zedm6vwR7Z8WEFzqnab3DRgvAm1oJKjiJ9lAgjb42XfcLldmo VYfQ/jIuOiGwp/FI7lUITkjhkepm5FuKA1e7VLVzsbVUKe6xJo0yJvjgYdpY0xGKDz zoSOGwSyfZjS/NEZMHy72QcQMjOzqBeHWHUwCp/8= Received: from ZHILIZHAO-MB2.tencent.com ([59.37.125.48]) by newxmesmtplogicsvrszb6.qq.com (NewEsmtp) with SMTP id 3CE994C8; Thu, 31 Dec 2020 16:15:14 +0800 X-QQ-mid: xmsmtpt1609402514tme5gcklo Message-ID: X-QQ-XMAILINFO: MVouSTiGyVbjbUmSp+eGZPG08leA1+VEPU6K/oUmxn2cSyHi2I7I+UbYqs3gvX HbFEHWMBrW6dxpF5xTZO9p+ltcOQW/yP9qIDReRX6wLRK4jrq7V1e+PouIAD3/rNnikazcg2Osme JnTd0JRWziQKkzul0dTbhoeeZ7HJDifqJJKel3SB+aNDsxZtFkpoZBfFbXLqbp6xWJseOxeJTuCa ilIlf1R2otXNxGN0x+2mzq+3+tJkDFfE3S8JMfTHeR85jRsW8HfaNuHXegDs+cu3KFDnul4unwKm /Yt//u8ZEy3lOJa2dvitCWpn4BavBAfH/xMOk30DXRTN2IMdZogdAMZvs4SgXx5bNYJt+COsfiln C6z1004YzYu1KKnmto3aEkHEoo+OZIkJKqheaDojI4K/b2i1bGVMK8yWGSvHhQER0Pg01E2+79tq aNqlN1CK9QQTDeXpKyeDVy2TfqjTcWgDLpA/h0dVsOLf0qTBmOHewFpOGnAcOLl4S5l+4CPzsFWe TWc64C4MYmY7YaLpIN8+HmiY2WFpmvHu/oklRFFBC+n1bPAnL0R3iv6DaiRu3/sPrIj29wXPaGV8 6hpCApSZ85wCi6AUWSvno+0CBbULmeBWXy4S4Fi3dfYD13zdsrymp4AXS/cU9vxaHwUfY5cx9uYU 5iA+fJGYLs8QvWde+JyttiCFMs1fjLQ68b3a/gdpbalsiP/gqMngGsUfULmXzyuJfAiX6szZgVPI ZQ4ACTbPqFiOOQyJyz/uUHndsAglur1JTriUot7SayS+ZPGXUAqwddYI/uFgfrLHnF From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Thu, 31 Dec 2020 16:15:03 +0800 X-OQ-MSGID: <20201231081503.47496-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/utils: fix seek failed 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Rounding min_ts towards +infinity and max_ts towards -infinity can make ts out of the [min_ts, max_ts] range, and then leads to seek failure. For example, max_ts = ts = -25057 time_base = (num = 1, den = 14112000) After rescale, ts = -353604, and max_ts = -353605. --- libavformat/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 503e583ad0..69a0f901b2 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2500,10 +2500,10 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, ts = av_rescale_q(ts, AV_TIME_BASE_Q, time_base); min_ts = av_rescale_rnd(min_ts, time_base.den, time_base.num * (int64_t)AV_TIME_BASE, - AV_ROUND_UP | AV_ROUND_PASS_MINMAX); + AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX); max_ts = av_rescale_rnd(max_ts, time_base.den, time_base.num * (int64_t)AV_TIME_BASE, - AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX); + AV_ROUND_UP | AV_ROUND_PASS_MINMAX); stream_index = 0; }