From patchwork Mon Apr 15 22:55:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 12761 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 9B55D448650 for ; Tue, 16 Apr 2019 01:55:11 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 81CEA68A703; Tue, 16 Apr 2019 01:55:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it1-f196.google.com (mail-it1-f196.google.com [209.85.166.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9629B689E21 for ; Tue, 16 Apr 2019 01:55:05 +0300 (EEST) Received: by mail-it1-f196.google.com with SMTP id f22so29584632ita.3 for ; Mon, 15 Apr 2019 15:55:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=JiXpbXm5uxoAw3eCW+uutsXfiDnAplf+SlLyHBFwM24=; b=gcFJ/Np0RB3itCkeC3Y+kN3sDl+LIyAGSgq7AEtZd61AtrNxh6Kew7EJP2SWUoBxuP wINfjq7A/i4ZQGfLPmTsQI4/nzYyvW0804vbpGCSn43CSfQJwiFWngAzOzDD6Bdg1FbW PzJveEeST/RnFEQoU0Azt5REyCbM8q60kbTY+cV6QxxUJ2RwQOKoWMHIIvK7T5qP+P3k oRhizrPaEu2Jf2kGBBGTwguFswrp4DE0O4hehcqHG/CHc+EPRv7Xv9new0+7iyEHJ0FM 6/g90U7Bni+agU+Uy83f65pw2FzuKyVfi2RYmAOWGAzc+2ybXpraRPjj3fL1XGnPrcKY oEAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=JiXpbXm5uxoAw3eCW+uutsXfiDnAplf+SlLyHBFwM24=; b=ewC6+IajyJxwmxakqlOOwru4LsH5jTw3fFpq4zEW8DFg6Z9IrqQdad8CGMFTa7lV5J bLwpvMQ3U6zyPXi9/CiUal9rCl2zfb2421DNvbVtSbKEJemEYtdSUNton6ABQd64dLn5 mHKhLjyk98aYfYX1gUY1OiB4fOm8sSqgXEt/A7k3ERbCXuHi9o9/+8HQpa0I1eBpJ9aC 9OFQwrdYo8006Lz3g8NQ9uemtyZPcnZ6CqGD01JHtg1I/LYdaNMPONr/fwhCR8E/Gvum aCnzUu8QwaKGIcWHstPmaOTVUxZrMEMxMAdMR21akyUj2O2gtJ75/CPonJ6evpBPYhA/ PPww== X-Gm-Message-State: APjAAAW1MnXe8pokIQ0O0UcwLLtcy4wE6VHhjgbecfVTY8w43c73DIvv 2ZJZBObUWEc1r4aYFUfe8Nr3twFXiiqpA5r1WFsYdw== X-Google-Smtp-Source: APXvYqxQo7wl2o4PRDJg4/n4T8EFi3Zuwr1QgwnEpbybRWoQULddg7DuYzINgbx6sTkU+FddimG5eiQGo6DD8RKgs1U= X-Received: by 2002:a24:57cf:: with SMTP id u198mr22278635ita.162.1555368903904; Mon, 15 Apr 2019 15:55:03 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:5503:0:0:0:0:0 with HTTP; Mon, 15 Apr 2019 15:55:03 -0700 (PDT) In-Reply-To: <20190413230238.GJ3501@michaelspb> References: <20190413230238.GJ3501@michaelspb> From: Carl Eugen Hoyos Date: Tue, 16 Apr 2019 00:55:03 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH]lavfi/fspp: Add a cast to silence a clang warning 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2019-04-14 1:02 GMT+02:00, Michael Niedermayer : > On Sat, Apr 13, 2019 at 07:25:54PM -0300, James Almer wrote: >> On 4/13/2019 7:04 PM, Carl Eugen Hoyos wrote: >> > Hi! >> > >> > Attached patch silences two warnings shown when compiling with clang: >> > libavfilter/vf_fspp.h:51:42: warning: implicit conversion from 'int' >> > to 'int16_t' (aka 'short') changes value from 44130 to -21406 >> > >> > Please comment, Carl Eugen >> > >> > >> > 0001-lavfi-vf_fspp-Use-the-intended-cast-to-int16_t.patch >> > >> > From d731e523d9c5854183d20d37fe921f49fb048498 Mon Sep 17 00:00:00 2001 >> > From: Carl Eugen Hoyos >> > Date: Sat, 13 Apr 2019 23:05:44 +0200 >> > Subject: [PATCH] lavfi/fspp: Add two casts to int16_t. >> > >> > Silences a warning with clang: >> > warning: implicit conversion from 'int' to 'int16_t' (aka 'short') >> > changes value from 44130 to -21406 >> > --- >> > libavfilter/vf_fspp.h | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> > >> > diff --git a/libavfilter/vf_fspp.h b/libavfilter/vf_fspp.h >> > index 74a3447..e346439 100644 >> > --- a/libavfilter/vf_fspp.h >> > +++ b/libavfilter/vf_fspp.h >> > @@ -31,7 +31,7 @@ >> > #define DCTSIZE 8 >> > #define DCTSIZE_S "8" >> > >> > -#define FIX(x,s) ((int) ((x) * (1 << s) + 0.5) & 0xffff) >> > +#define FIX(x,s) ((int16_t)((x) * (1 << s) + 0.5) & (int16_t)0xffff) >> >> The "& 0xffff" is turning -21406 into 44130 since it zeroes all the high >> bits, and then that value gets converted back to -21406 when stored into >> an int16_t variable. >> >> Change the int cast into int16_t if you want since it doesn't hurt (all >> the values are safely within the int16_t range anyway), but remove the >> "& 0xffff" altogether instead of casting it, to get rid of this warning. >> >> > #define C64(x) ((uint64_t)((x) | (x) << 16)) <<32 | (uint64_t)(x) | >> > (uint64_t)(x) << 16 >> > #define FIX64(x,s) C64(FIX(x,s)) > > i think the C64 / FIX64 macros depend on the & 0xFFFF. They are maybe > unused > and just referenced in comments but having them not give correct values > could still be confusing. The 0xFFFF if its removed should be added to the > code / comments that refer to it in a way that needs it New patch attached. Not sure if / where to add comments. Please comment, Carl Eugen From dfda9d8a6714649015f252e0e0bf5e3e52ce1b5c Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 16 Apr 2019 00:50:50 +0200 Subject: [PATCH] lavfi/fspp: Cast float values to int16_t instead of int. Silences a warning with clang: warning: implicit conversion from 'int' to 'int16_t' (aka 'short') changes value from 44130 to -21406 --- libavfilter/vf_fspp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_fspp.h b/libavfilter/vf_fspp.h index 802db14..bdafe8e 100644 --- a/libavfilter/vf_fspp.h +++ b/libavfilter/vf_fspp.h @@ -31,7 +31,7 @@ #define DCTSIZE 8 #define DCTSIZE_S "8" -#define FIX(x,s) ((int) ((x) * (1 << s) + 0.5) & 0xffff) +#define FIX(x,s) ((int16_t)((x) * (1 << s) + 0.5)) #define MULTIPLY16H(x,k) (((x) * (k)) >> 16) #define THRESHOLD(r,x,t) \ -- 1.7.10.4