From patchwork Sun Nov 20 11:57:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 1498 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp1028987vsb; Sun, 20 Nov 2016 03:58:13 -0800 (PST) X-Received: by 10.25.89.137 with SMTP id n131mr1902186lfb.75.1479643093380; Sun, 20 Nov 2016 03:58:13 -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 j21si6437300lfg.61.2016.11.20.03.58.13; Sun, 20 Nov 2016 03:58:13 -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 55A40689F30; Sun, 20 Nov 2016 13:57:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-3.mx.upcmail.net (vie01a-qmta-pe01-3.mx.upcmail.net [62.179.121.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8125D689ECD for ; Sun, 20 Nov 2016 13:57:50 +0200 (EET) Received: from [172.31.218.38] (helo=vie01a-dmta-pe03-2.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1c8Qkq-0003oN-Jb for ffmpeg-devel@ffmpeg.org; Sun, 20 Nov 2016 12:57:52 +0100 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1c8Qkj-0005qz-Hi for ffmpeg-devel@ffmpeg.org; Sun, 20 Nov 2016 12:57:45 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id ABxk1u00C0S5wYM01Bxla5; Sun, 20 Nov 2016 12:57:45 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 20 Nov 2016 12:57:42 +0100 Message-Id: <20161120115744.28351-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.10.2 Subject: [FFmpeg-devel] [PATCH 1/3] avutil/opt: Fix setting int64 to its maximum 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Found-by: Andreas Signed-off-by: Michael Niedermayer --- libavutil/opt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index cd16bd1..6669356 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -126,9 +126,11 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int break; case AV_OPT_TYPE_DURATION: case AV_OPT_TYPE_CHANNEL_LAYOUT: - case AV_OPT_TYPE_INT64: - *(int64_t *)dst = llrint(num / den) * intnum; - break; + case AV_OPT_TYPE_INT64:{ + double d = num / den; + if (intnum == 1 && d == (double)INT64_MAX) *(int64_t *)dst = INT64_MAX; + else *(int64_t *)dst = llrint(d) * intnum; + break;} case AV_OPT_TYPE_FLOAT: *(float *)dst = num * intnum / den; break;