From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#51296: [PATCH] Add WebP format support Date: Thu, 21 Oct 2021 11:19:44 +0300 Message-ID: <8335ouaixr.fsf@gnu.org> References: <837de7bzy0.fsf@gnu.org> <83y26nac3e.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15566"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 51296@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 21 10:20:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdTJ5-0003qN-Rn for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Oct 2021 10:20:11 +0200 Original-Received: from localhost ([::1]:57734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdTJ4-0007V4-A3 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Oct 2021 04:20:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdTIw-0007Uq-ID for bug-gnu-emacs@gnu.org; Thu, 21 Oct 2021 04:20:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdTIw-00006U-9B for bug-gnu-emacs@gnu.org; Thu, 21 Oct 2021 04:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mdTIw-00046r-0L for bug-gnu-emacs@gnu.org; Thu, 21 Oct 2021 04:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Oct 2021 08:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51296 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51296-submit@debbugs.gnu.org id=B51296.163480438215768 (code B ref 51296); Thu, 21 Oct 2021 08:20:01 +0000 Original-Received: (at 51296) by debbugs.gnu.org; 21 Oct 2021 08:19:42 +0000 Original-Received: from localhost ([127.0.0.1]:56229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mdTIb-00046G-OP for submit@debbugs.gnu.org; Thu, 21 Oct 2021 04:19:42 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mdTIW-00045v-3w for 51296@debbugs.gnu.org; Thu, 21 Oct 2021 04:19:40 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:43412) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdTIQ-00087c-Cc; Thu, 21 Oct 2021 04:19:30 -0400 Original-Received: from [87.69.77.57] (port=4771 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdTIP-0006Sl-W1; Thu, 21 Oct 2021 04:19:30 -0400 In-Reply-To: (message from Stefan Kangas on Wed, 20 Oct 2021 17:45:28 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:217759 Archived-At: > From: Stefan Kangas > Date: Wed, 20 Oct 2021 17:45:28 -0700 > Cc: 51296@debbugs.gnu.org > > > Also fixed. > > I spotted a typo, fixed in the attached patch. Thanks, now only a few minor issues remain: > +### mingw32 doesn't use -lwebp, since it loads the library dynamically. > +HAVE_WEBP=no > +if test "${with_webp}" != "no"; then > + if test "$opsys" = mingw32; then > + AC_CHECK_HEADER([webp/decode.h], [HAVE_WEBP=yes]) > + elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes" \ > + || test "${HAVE_NS}" = "yes"; then > + WEBP_REQUIRED=0.6.0 > + WEBP_MODULE="libwebp >= $WEBP_REQUIRED" > + > + EMACS_CHECK_MODULES([WEBP], [$WEBP_MODULE]) > + AC_SUBST(WEBP_CFLAGS) > + AC_SUBST(WEBP_LIBS) > + > + if test $HAVE_WEBP = yes; then > + AC_DEFINE(HAVE_WEBP, 1, [Define to 1 if using libwebp.]) > + CFLAGS="$CFLAGS $WEBP_CFLAGS" > + fi > + fi > +fi That's OK, but I believe you should also add WEBP to the list of Emacs configuration features around line 5885 in configure.ac, so that WebP support could be reported by system-configuration-features. > +DEF_DLL_FN (int, WebPGetInfo, (const uint8_t* data, size_t data_size, int* width, int* height)); Our style is to separate the '*' from the type, like this: DEF_DLL_FN (int, WebPGetInfo, (const uint8_t *, size_t, int *, int *)); ^^ ^^ ^^ Also note that there's no need to use names of parameters in prototypes, they just make the code longer, but don't add anything useful. So I removed them in the above. > +static bool > +init_webp_functions (void) > +{ > + HMODULE library; > + > + if (!(library = w32_delayed_load (Qwebp))) > + return 0; ^^^^^^^^ "return false" is more consistent. > + contents = (uint8_t*) SSDATA (specified_data); Space before '*' again. Also, is the type cast really needed? If not, it is better to drop it. > + /* Validate the WebP image header. */ > + if (!WebPGetInfo (contents, size, NULL, NULL)) > + { > + if (!NILP (specified_data)) > + image_error ("Not a WebP file: `%s'", file); > + else > + image_error ("Invalid WebP data"); This last error message could IMO be more useful, if it said something like "Non-WebP header in WebP image data". > + image_error ("Error when interpreting WebP data: `%s'", file); Suggest to say "Error when interpreting WebP data from file `%s'" instead, otherwise it may not be clear to the user what is that string after the colon. > + image_error ("Error when interpreting WebP data"); I'd suggest "Error when interpreting WebP image data".