From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#28400: 26.0.50; lcms2 bindings Date: Tue, 12 Sep 2017 18:53:00 +0300 Message-ID: <834ls7rk0z.fsf@gnu.org> References: <877ex7yiph.fsf@holos> <83shfvvkme.fsf@gnu.org> <20170910220422.GA14577@holos.localdomain> <831sndth2e.fsf@gnu.org> <20170911231006.GA5455@holos.localdomain> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1505231668 11662 195.159.176.226 (12 Sep 2017 15:54:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 12 Sep 2017 15:54:28 +0000 (UTC) Cc: 28400@debbugs.gnu.org To: Mark Oteiza Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 12 17:54:20 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drnVp-00022O-C7 for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Sep 2017 17:54:09 +0200 Original-Received: from localhost ([::1]:36619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drnVu-00008L-VU for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Sep 2017 11:54:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drnVm-00007H-16 for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2017 11:54:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drnVi-000762-19 for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2017 11:54:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55604) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1drnVh-00075x-Ub for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2017 11:54:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1drnVh-00041d-NR for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2017 11:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Sep 2017 15:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28400 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28400-submit@debbugs.gnu.org id=B28400.150523160115424 (code B ref 28400); Tue, 12 Sep 2017 15:54:01 +0000 Original-Received: (at 28400) by debbugs.gnu.org; 12 Sep 2017 15:53:21 +0000 Original-Received: from localhost ([127.0.0.1]:36052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drnV2-00040h-7J for submit@debbugs.gnu.org; Tue, 12 Sep 2017 11:53:21 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34086) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drnV0-00040T-37 for 28400@debbugs.gnu.org; Tue, 12 Sep 2017 11:53:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drnUr-0006ao-1v for 28400@debbugs.gnu.org; Tue, 12 Sep 2017 11:53:13 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:38077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drnUq-0006ai-UO; Tue, 12 Sep 2017 11:53:08 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2038 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1drnUp-0001w4-LW; Tue, 12 Sep 2017 11:53:08 -0400 In-reply-to: <20170911231006.GA5455@holos.localdomain> (message from Mark Oteiza on Mon, 11 Sep 2017 19:10:06 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136840 Archived-At: > Date: Mon, 11 Sep 2017 19:10:06 -0400 > From: Mark Oteiza > Cc: 28400@debbugs.gnu.org > > > Oh, I see. But in that case, I think adding a new file and the > > configure.ac business is actually quite easy. > > Humble beginnings attached. Thanks, it looks good. A few comments: > diff --git a/src/lcms.c b/src/lcms.c > new file mode 100644 > index 0000000000..560b262818 > --- /dev/null > +++ b/src/lcms.c > @@ -0,0 +1,157 @@ > +/* Interface to Little CMS > + Copyright (C) 2017 Mark Oteiza > + > +This file is NOT part of GNU Emacs. This will have to change to our standard preamble, of course. > +DEFUN ("lcms-cie-de2000", Flcms_cie_de2000, Slcms_cie_de2000, 2, 2, 0, > + doc: /* Compute CIEDE2000 metric distance between COLOR1 and COLOR2. > +Each color is a list of L*a*b* coordinates, where the L* channel ranges from > +0 to 100, and the a* and b* channels range from -128 to 128. > +Optional arguments KL, KC, KH are weighting parameters for lightness, > +chroma, and hue, respectively. */) > + (Lisp_Object color1, Lisp_Object color2) I don't see any optional arguments. > +DEFUN ("lcms-cam02-ucs", Flcms-cam02-ucs, Slcms_cam02_ucs, 2, 2, 0, > + doc: /* Compute CAM02-UCS metric distance between COLOR1 and COLOR2. > +Each color is a list of XYZ coordinates. > +Optional argument is the XYZ white point, which defaults to D65. */) > + (Lisp_Object color1, Lisp_Object color2) Likewise. > + k = 1.0f / (1.0f + (5.0f * vc.La)); Any reason why you use float constants, as opposed to double? > + FL = pow(k, 4) * vc.La + > + 0.1f * pow(1 - pow(k, 4), 2) * pow(5.0f * vc.La, 1.0f / 3.0f); > + Mp1 = 43.86f * log(1.0f + 0.0228f * (jch1.C * pow(FL, 0.25))); > + Mp2 = 43.86f * log(1.0f + 0.0228f * (jch2.C * pow(FL, 0.25))); > + Jp1 = 1.7f * jch1.J / (1.0f + (0.007f * jch1.J)); > + Jp2 = 1.7f * jch2.J / (1.0f + (0.007f * jch2.J)); > + ap1 = Mp1 * cos(jch1.h); > + ap2 = Mp2 * cos(jch2.h); > + bp1 = Mp1 * sin(jch1.h); > + bp2 = Mp2 * sin(jch2.h); > + return make_float(sqrt(pow(Jp2 - Jp1, 2) + > + pow(ap2 - ap1, 2) + > + pow(bp2 - bp1, 2))); I generally dislike 'pow', where simpler functions will do. 'pow' is expensive and less accurate numerically than the alternatives (where they exist); it also makes the code slightly harder to read and understand. Granted, this code is unlikely to run in the inner-most loops of some Lisp program, or to require last-ulp accuracy, so some of these arguments are admittedly weak. But still... So I'd replace: pow (SOMETHING, 2) with SOMETHING*SOMETHING pow (SOMETHING, 1./3.) with cubrt (SOMETHING) pow (k, 4) with k * k * k * k pow (FL, 0.25) with sqrt (sqrt (FL)) etc. Also, a nit: we leave a blank between the function name and the following left paren. I think this will also need a NEWS entry, under "Installation Changes". Thanks again for working on this.