Sun Jul 30 07:55:45 2023 UTC ()
xv: add webp support.
Taken from https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
and several fixes by me (see patch comments for details).
Bump PKGREVISION.
(tsutsui)
diff -r1.96 -r1.97 pkgsrc/graphics/xv/Makefile
diff -r1.25 -r1.26 pkgsrc/graphics/xv/distinfo
diff -r1.1 -r1.2 pkgsrc/graphics/xv/patches/patch-Imakefile
diff -r1.1 -r1.2 pkgsrc/graphics/xv/patches/patch-xv.h
diff -r0 -r1.1 pkgsrc/graphics/xv/patches/patch-bits_br__webp
diff -r0 -r1.1 pkgsrc/graphics/xv/patches/patch-xv.c
diff -r0 -r1.1 pkgsrc/graphics/xv/patches/patch-xvbrowse.c
diff -r0 -r1.1 pkgsrc/graphics/xv/patches/patch-xvdir.c
diff -r0 -r1.1 pkgsrc/graphics/xv/patches/patch-xvevent.c
diff -r0 -r1.1 pkgsrc/graphics/xv/patches/patch-xvmisc.c
diff -r0 -r1.1 pkgsrc/graphics/xv/patches/patch-xvwebp.c
--- pkgsrc/graphics/xv/Makefile 2023/01/03 17:37:33 1.96
+++ pkgsrc/graphics/xv/Makefile 2023/07/30 07:55:44 1.97
| @@ -1,17 +1,17 @@ | | | @@ -1,17 +1,17 @@ |
1 | # $NetBSD: Makefile,v 1.96 2023/01/03 17:37:33 wiz Exp $ | | 1 | # $NetBSD: Makefile,v 1.97 2023/07/30 07:55:44 tsutsui Exp $ |
2 | | | 2 | |
3 | DISTNAME= xv-3.10a | | 3 | DISTNAME= xv-3.10a |
4 | PKGREVISION= 26 | | 4 | PKGREVISION= 27 |
5 | CATEGORIES= graphics x11 | | 5 | CATEGORIES= graphics x11 |
6 | MASTER_SITES= ftp://ftp.cis.upenn.edu/pub/xv/ | | 6 | MASTER_SITES= ftp://ftp.cis.upenn.edu/pub/xv/ |
7 | DISTFILES= ${DEFAULT_DISTFILES} ${JUMBO_PATCHES} | | 7 | DISTFILES= ${DEFAULT_DISTFILES} ${JUMBO_PATCHES} |
8 | | | 8 | |
9 | PATCHFILES= ${JUMBO_PATCHES} | | 9 | PATCHFILES= ${JUMBO_PATCHES} |
10 | JUMBO_PATCHES= xv-3.10a-jumbo-patches-20070520.tar.gz | | 10 | JUMBO_PATCHES= xv-3.10a-jumbo-patches-20070520.tar.gz |
11 | PATCH_DIST_CAT.${JUMBO_PATCHES}= ${CAT} ${WRKDIR}/*-patch-* | | 11 | PATCH_DIST_CAT.${JUMBO_PATCHES}= ${CAT} ${WRKDIR}/*-patch-* |
12 | PATCH_DIST_STRIP.${JUMBO_PATCHES}= -p1 | | 12 | PATCH_DIST_STRIP.${JUMBO_PATCHES}= -p1 |
13 | SITES.${JUMBO_PATCHES}= ${MASTER_SITE_SOURCEFORGE:=png-mng/} | | 13 | SITES.${JUMBO_PATCHES}= ${MASTER_SITE_SOURCEFORGE:=png-mng/} |
14 | PATCHFILES+= xv-3.10a-enhancements.20070520-20081216.diff | | 14 | PATCHFILES+= xv-3.10a-enhancements.20070520-20081216.diff |
15 | PATCH_SITES= http://www.gregroelofs.com/code/ | | 15 | PATCH_SITES= http://www.gregroelofs.com/code/ |
16 | | | 16 | |
17 | MAINTAINER= tsutsui@NetBSD.org | | 17 | MAINTAINER= tsutsui@NetBSD.org |
| @@ -54,18 +54,19 @@ SUBST_SED.ccflags+= -e 's| CDEBUGFLAGS = | | | @@ -54,18 +54,19 @@ SUBST_SED.ccflags+= -e 's| CDEBUGFLAGS = |
54 | SUBST_STAGE.ccflags= post-configure | | 54 | SUBST_STAGE.ccflags= post-configure |
55 | SUBST_MESSAGE.ccflags= Fixing compiler flags for Solaris. | | 55 | SUBST_MESSAGE.ccflags= Fixing compiler flags for Solaris. |
56 | | | 56 | |
57 | .if ${OPSYS} == "SunOS" || !empty(MACHINE_PLATFORM:MIRIX-5*) | | 57 | .if ${OPSYS} == "SunOS" || !empty(MACHINE_PLATFORM:MIRIX-5*) |
58 | CPPFLAGS+= -DNEED_ALLOCA_H | | 58 | CPPFLAGS+= -DNEED_ALLOCA_H |
59 | .endif | | 59 | .endif |
60 | | | 60 | |
61 | post-install: | | 61 | post-install: |
62 | ${INSTALL_DATA} ${WRKSRC}/README ${DESTDIR}${PREFIX}/share/doc/xv | | 62 | ${INSTALL_DATA} ${WRKSRC}/README ${DESTDIR}${PREFIX}/share/doc/xv |
63 | ${INSTALL_DATA} ${WRKSRC}/docs/xvdocs.ps ${DESTDIR}${PREFIX}/share/doc/xv | | 63 | ${INSTALL_DATA} ${WRKSRC}/docs/xvdocs.ps ${DESTDIR}${PREFIX}/share/doc/xv |
64 | | | 64 | |
65 | BUILDLINK_DEPMETHOD.libXt?= build | | 65 | BUILDLINK_DEPMETHOD.libXt?= build |
66 | | | 66 | |
| | | 67 | .include "../../graphics/libwebp/buildlink3.mk" |
67 | .include "../../graphics/png/buildlink3.mk" | | 68 | .include "../../graphics/png/buildlink3.mk" |
68 | .include "../../graphics/tiff/buildlink3.mk" | | 69 | .include "../../graphics/tiff/buildlink3.mk" |
69 | .include "../../x11/libXext/buildlink3.mk" | | 70 | .include "../../x11/libXext/buildlink3.mk" |
70 | .include "../../x11/libXt/buildlink3.mk" | | 71 | .include "../../x11/libXt/buildlink3.mk" |
71 | .include "../../mk/bsd.pkg.mk" | | 72 | .include "../../mk/bsd.pkg.mk" |
--- pkgsrc/graphics/xv/distinfo 2021/10/26 10:47:25 1.25
+++ pkgsrc/graphics/xv/distinfo 2023/07/30 07:55:44 1.26
| @@ -1,18 +1,25 @@ | | | @@ -1,18 +1,25 @@ |
1 | $NetBSD: distinfo,v 1.25 2021/10/26 10:47:25 nia Exp $ | | 1 | $NetBSD: distinfo,v 1.26 2023/07/30 07:55:44 tsutsui Exp $ |
2 | | | 2 | |
3 | BLAKE2s (xv-3.10a-enhancements.20070520-20081216.diff) = 1333e3066444f6adf64e83c33a129a46143678d4b2c805f3740baae1320d3449 | | 3 | BLAKE2s (xv-3.10a-enhancements.20070520-20081216.diff) = 1333e3066444f6adf64e83c33a129a46143678d4b2c805f3740baae1320d3449 |
4 | SHA512 (xv-3.10a-enhancements.20070520-20081216.diff) = d7152799f6ec65404496b8d83a93681122fe1280741ffe4d20d7dc1b3791873081c778b3d9806f1217b9d45f5b5bfce6fdbfb655c26ed5e87388a6f517c4f2f7 | | 4 | SHA512 (xv-3.10a-enhancements.20070520-20081216.diff) = d7152799f6ec65404496b8d83a93681122fe1280741ffe4d20d7dc1b3791873081c778b3d9806f1217b9d45f5b5bfce6fdbfb655c26ed5e87388a6f517c4f2f7 |
5 | Size (xv-3.10a-enhancements.20070520-20081216.diff) = 8847 bytes | | 5 | Size (xv-3.10a-enhancements.20070520-20081216.diff) = 8847 bytes |
6 | BLAKE2s (xv-3.10a-jumbo-patches-20070520.tar.gz) = da5ab5eba0823abbe5e0842348c1bf0f4c3bbcfb58135cde1d537e1f65c3502d | | 6 | BLAKE2s (xv-3.10a-jumbo-patches-20070520.tar.gz) = da5ab5eba0823abbe5e0842348c1bf0f4c3bbcfb58135cde1d537e1f65c3502d |
7 | SHA512 (xv-3.10a-jumbo-patches-20070520.tar.gz) = e2ac5a3b4d743bf142c162b00815dd9d8dcaf345d0649016b2c6441fe2329879471b19453808e677c1a0b8eeb3468295dba160b1f30eacb2a7a9d8524ce03e75 | | 7 | SHA512 (xv-3.10a-jumbo-patches-20070520.tar.gz) = e2ac5a3b4d743bf142c162b00815dd9d8dcaf345d0649016b2c6441fe2329879471b19453808e677c1a0b8eeb3468295dba160b1f30eacb2a7a9d8524ce03e75 |
8 | Size (xv-3.10a-jumbo-patches-20070520.tar.gz) = 1363802 bytes | | 8 | Size (xv-3.10a-jumbo-patches-20070520.tar.gz) = 1363802 bytes |
9 | BLAKE2s (xv-3.10a.tar.gz) = 1a48a6b641074c1fc1c51a01d6516024489ed0fab550abdd708f7d12aef8d292 | | 9 | BLAKE2s (xv-3.10a.tar.gz) = 1a48a6b641074c1fc1c51a01d6516024489ed0fab550abdd708f7d12aef8d292 |
10 | SHA512 (xv-3.10a.tar.gz) = 5b8c5890503e2796638921cabae8967e458c73e332acea8561b1025ed13c771bc44c0e309b4592852e33726eeaa9784f933d1312073b0ba2e0b8c0cedabcaa3f | | 10 | SHA512 (xv-3.10a.tar.gz) = 5b8c5890503e2796638921cabae8967e458c73e332acea8561b1025ed13c771bc44c0e309b4592852e33726eeaa9784f933d1312073b0ba2e0b8c0cedabcaa3f |
11 | Size (xv-3.10a.tar.gz) = 2259124 bytes | | 11 | Size (xv-3.10a.tar.gz) = 2259124 bytes |
12 | SHA1 (patch-Imakefile) = e27d7d2f110d4edbce9a5d236e45a556714b5be0 | | 12 | SHA1 (patch-Imakefile) = ea44bbda2a848a81fceac78d2f581269a053fb7f |
| | | 13 | SHA1 (patch-bits_br__webp) = 47f2495f0e8d443e0e20b718593de331cf319dea |
13 | SHA1 (patch-config.h) = fd0ef6bbf774a57dd0bb94676927dcc6eeef1014 | | 14 | SHA1 (patch-config.h) = fd0ef6bbf774a57dd0bb94676927dcc6eeef1014 |
14 | SHA1 (patch-vdcomp.c) = 4c603cdc2c01925fed283b2aa6030d1933cdaddc | | 15 | SHA1 (patch-vdcomp.c) = 4c603cdc2c01925fed283b2aa6030d1933cdaddc |
15 | SHA1 (patch-xv.h) = 894c5a9d4e1cb5fb18a9914c75408b67f1e6e5d4 | | 16 | SHA1 (patch-xv.c) = 6f42b3cfa60fc724b9022b61794201252161e60a |
| | | 17 | SHA1 (patch-xv.h) = abe4ae7018bc62b983274c47c31741f0474d48ac |
| | | 18 | SHA1 (patch-xvbrowse.c) = f15e6e8e4db2776f072f34355ecad7844a764c2a |
| | | 19 | SHA1 (patch-xvdir.c) = 070714b588bc28f5d6e8974a88c960c6ab9df94f |
| | | 20 | SHA1 (patch-xvevent.c) = bfb7fd815b8ff86f68c09098c74ab0adc8a36a32 |
16 | SHA1 (patch-xvinfo.c) = 33b2392de259f1380e5be180f8e7293a9551fc52 | | 21 | SHA1 (patch-xvinfo.c) = 33b2392de259f1380e5be180f8e7293a9551fc52 |
| | | 22 | SHA1 (patch-xvmisc.c) = ad326175632736e2d6dd257972d8cba5b24635a3 |
17 | SHA1 (patch-xvpcd.c) = 1825015f441b9af91916f9a62e8d1dee6ddfdef9 | | 23 | SHA1 (patch-xvpcd.c) = 1825015f441b9af91916f9a62e8d1dee6ddfdef9 |
18 | SHA1 (patch-xvpng.c) = 2bda08bae67fcf127c49b9ed780b7a247579c088 | | 24 | SHA1 (patch-xvpng.c) = 2bda08bae67fcf127c49b9ed780b7a247579c088 |
| | | 25 | SHA1 (patch-xvwebp.c) = ad2a1a87176ab099c8d3f51bf5d20e2bbe2faf2a |
--- pkgsrc/graphics/xv/patches/patch-Imakefile 2019/02/21 14:32:32 1.1
+++ pkgsrc/graphics/xv/patches/patch-Imakefile 2023/07/30 07:55:45 1.2
| @@ -1,50 +1,78 @@ | | | @@ -1,50 +1,78 @@ |
1 | $NetBSD: patch-Imakefile,v 1.1 2019/02/21 14:32:32 tsutsui Exp $ | | 1 | $NetBSD: patch-Imakefile,v 1.2 2023/07/30 07:55:45 tsutsui Exp $ |
2 | | | 2 | |
3 | - use jpeg, png, tiff, and zlib from pkgsrc | | 3 | - use jpeg, png, tiff, and zlib from pkgsrc |
4 | - make ghostscript support optional | | 4 | - make ghostscript support optional |
| | | 5 | - add webp support from forked upstream |
| | | 6 | https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e |
| | | 7 | and use libwebp from pkgsrc |
5 | | | 8 | |
6 | --- Imakefile.orig 2019-02-21 14:07:37.512579350 +0000 | | 9 | --- Imakefile.orig 2023-07-30 04:38:19.657014071 +0000 |
7 | +++ Imakefile | | 10 | +++ Imakefile |
8 | @@ -6,13 +6,15 @@ | | 11 | @@ -6,13 +6,20 @@ |
9 | /* if, for whatever reason, you're unable to get the JPEG library to compile | | 12 | /* if, for whatever reason, you're unable to get the JPEG library to compile |
10 | * on your machine, *COMMENT OUT* the following line | | 13 | * on your machine, *COMMENT OUT* the following line |
11 | */ | | 14 | */ |
12 | -#define HaveJpeg | | 15 | -#define HaveJpeg |
13 | +/* #define HaveJpeg */ | | 16 | +/* #define HaveJpeg */ |
14 | +#define UseInstalledJpeg | | 17 | +#define UseInstalledJpeg |
15 | | | 18 | |
| | | 19 | +/* if, for whatever reason, you're unable to get the WEBP library to compile |
| | | 20 | + * on your machine, *COMMENT OUT* the following line |
| | | 21 | + */ |
| | | 22 | +/* #define HaveWEBP */ |
| | | 23 | +#define UseInstalledWEBP |
16 | | | 24 | |
17 | /* if, for whatever reason, you're unable to get the TIFF library to compile | | 25 | /* if, for whatever reason, you're unable to get the TIFF library to compile |
18 | * on your machine, *COMMENT OUT* the following line | | 26 | * on your machine, *COMMENT OUT* the following line |
19 | */ | | 27 | */ |
20 | -#define HaveTiff | | 28 | -#define HaveTiff |
21 | +/* #define HaveTiff */ | | 29 | +/* #define HaveTiff */ |
22 | +#define UseInstalledTiff | | 30 | +#define UseInstalledTiff |
23 | | | 31 | |
24 | | | 32 | |
25 | /* if, for whatever reason, you're unable to get the PDS/VICAR support | | 33 | /* if, for whatever reason, you're unable to get the PDS/VICAR support |
26 | @@ -21,6 +23,10 @@ | | 34 | @@ -21,6 +28,10 @@ |
27 | #define HavePDS | | 35 | #define HavePDS |
28 | | | 36 | |
29 | | | 37 | |
30 | +/* #define UseInstalledGhostScript */ | | 38 | +/* #define UseInstalledGhostScript */ |
31 | +#define UseInstalledPng | | 39 | +#define UseInstalledPng |
32 | +#define UseInstalledZlib | | 40 | +#define UseInstalledZlib |
33 | + | | 41 | + |
34 | /* | | 42 | /* |
35 | * if you are running on a SysV-based machine, such as HP, Silicon Graphics, | | 43 | * if you are running on a SysV-based machine, such as HP, Silicon Graphics, |
36 | * etc, uncomment one of the following lines to get you *most* of the way | | 44 | * etc, uncomment one of the following lines to get you *most* of the way |
37 | @@ -124,20 +130,66 @@ MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\" | | 45 | @@ -116,28 +127,84 @@ MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\" |
| | | 46 | |
| | | 47 | /* This marks the end of the configuration parameters */ |
| | | 48 | |
| | | 49 | +#ifdef HaveWEBP |
| | | 50 | +WEBP = -DDOWEBP |
| | | 51 | +WEBPDIR = /usr |
| | | 52 | +LIBWEBP = $(WEBPDIR)/lib/libwebp.so |
| | | 53 | +DEPLIBWEBP = $(LIBWEBP) |
| | | 54 | +WEBPINCLUDE = -I$(WEBPDIR)/include |
| | | 55 | +#endif |
| | | 56 | |
| | | 57 | - |
| | | 58 | - |
| | | 59 | +#ifdef UseInstalledWEBP |
| | | 60 | +WEBP = -DDOWEBP |
| | | 61 | +LIBWEBP = $(LDFLAGS) -L$(PREFIX)/lib -Wl,-R$(PREFIX)/lib -lwebp |
| | | 62 | +WEBPINCLUDE = -I$(PREFIX)/include |
| | | 63 | +#endif |
| | | 64 | |
| | | 65 | #ifdef HaveJpeg |
38 | JPEG = -DDOJPEG | | 66 | JPEG = -DDOJPEG |
39 | JPEGDIR = jpeg | | 67 | JPEGDIR = jpeg |
40 | LIBJPEG = $(JPEGDIR)/libjpeg.a | | 68 | LIBJPEG = $(JPEGDIR)/libjpeg.a |
41 | +DEPLIBJPEG = $(LIBJPEG) | | 69 | +DEPLIBJPEG = $(LIBJPEG) |
42 | JPEGINCLUDE = -I$(JPEGDIR) | | 70 | JPEGINCLUDE = -I$(JPEGDIR) |
43 | #endif | | 71 | #endif |
44 | | | 72 | |
45 | +#ifdef UseInstalledJpeg | | 73 | +#ifdef UseInstalledJpeg |
46 | +JPEG = -DDOJPEG | | 74 | +JPEG = -DDOJPEG |
47 | +LIBJPEG = $(LDFLAGS) -L$(PREFIX)/lib -Wl,-R$(PREFIX)/lib -ljpeg | | 75 | +LIBJPEG = $(LDFLAGS) -L$(PREFIX)/lib -Wl,-R$(PREFIX)/lib -ljpeg |
48 | +JPEGINCLUDE = -I$(PREFIX)/include | | 76 | +JPEGINCLUDE = -I$(PREFIX)/include |
49 | +#endif | | 77 | +#endif |
50 | + | | 78 | + |
| @@ -91,32 +119,51 @@ $NetBSD: patch-Imakefile,v 1.1 2019/02/2 | | | @@ -91,32 +119,51 @@ $NetBSD: patch-Imakefile,v 1.1 2019/02/2 |
91 | +### on your machine, *COMMENT OUT* the following lines | | 119 | +### on your machine, *COMMENT OUT* the following lines |
92 | +### | | 120 | +### |
93 | +*/ | | 121 | +*/ |
94 | +#ifdef UseInstalledZlib | | 122 | +#ifdef UseInstalledZlib |
95 | +ZLIBDIR = $(PREFIX) | | 123 | +ZLIBDIR = $(PREFIX) |
96 | +ZLIBINC = -I$(ZLIBDIR)/include | | 124 | +ZLIBINC = -I$(ZLIBDIR)/include |
97 | +ZLIBLIB = -L$(ZLIBDIR)/lib -lz | | 125 | +ZLIBLIB = -L$(ZLIBDIR)/lib -lz |
98 | +LIBZLIB = ${ZLIB} | | 126 | +LIBZLIB = ${ZLIB} |
99 | +ZLIBINCLUDE = ${ZLIBINC} | | 127 | +ZLIBINCLUDE = ${ZLIBINC} |
100 | +#endif | | 128 | +#endif |
101 | | | 129 | |
102 | #if defined(SCOArchitecture) | | 130 | #if defined(SCOArchitecture) |
103 | SCO= -Dsco -DPOSIX -DNO_RANDOM | | 131 | SCO= -Dsco -DPOSIX -DNO_RANDOM |
104 | @@ -149,14 +201,14 @@ SYS_LIBRARIES= -lm | | 132 | @@ -149,14 +216,15 @@ SYS_LIBRARIES= -lm |
105 | #endif | | 133 | #endif |
106 | | | 134 | |
107 | | | 135 | |
108 | -DEPLIBS = $(LIBJPEG) $(LIBTIFF) | | 136 | -DEPLIBS = $(LIBJPEG) $(LIBTIFF) |
109 | -LOCAL_LIBRARIES = $(XLIB) $(DEPLIBS) | | 137 | -LOCAL_LIBRARIES = $(XLIB) $(DEPLIBS) |
110 | +DEPLIBS = $(DEPLIBJPEG) $(DEPLIBTIFF) $(DEPLIBPNG) $(DEPLIBZLIB) | | 138 | +DEPLIBS = $(DEPLIBJPEG) $(DEPLIBTIFF) $(DEPLIBPNG) $(DEPLIBWEBP) $(DEPLIBZLIB) |
111 | +LOCAL_LIBRARIES = $(XLIB) $(LIBJPEG) $(LIBTIFF) $(LIBPNG) $(LIBZLIB) | | 139 | +LOCAL_LIBRARIES = $(XLIB) $(LIBJPEG) $(LIBTIFF) $(LIBPNG) $(LIBWEBP) $(LIBZLIB) |
112 | | | 140 | |
113 | DEFINES= $(SCO) $(UNIX) $(NODIRENT) $(VPRINTF) $(TIMERS) \ | | 141 | DEFINES= $(SCO) $(UNIX) $(NODIRENT) $(VPRINTF) $(TIMERS) \ |
114 | - $(HPUX7) $(JPEG) $(TIFF) $(PDS) $(DXWM) $(RAND) \ | | 142 | - $(HPUX7) $(JPEG) $(TIFF) $(PDS) $(DXWM) $(RAND) \ |
115 | + $(HPUX7) $(JPEG) $(TIFF) $(GS) $(PNG) $(PDS) $(DXWM) $(RAND) \ | | 143 | + $(HPUX7) $(JPEG) $(TIFF) $(GS) $(PNG) $(WEBP) $(PDS) $(DXWM) $(RAND) \ |
116 | $(BACKING_STORE) $(BSDTYPES) $(SGI) $(MGCSFX) | | 144 | $(BACKING_STORE) $(BSDTYPES) $(SGI) $(MGCSFX) |
117 | | | 145 | |
118 | -INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) | | 146 | -INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) |
119 | +INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) $(PNGINCLUDE) $(ZLIBINCLUDE) | | 147 | +INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) $(PNGINCLUDE) $(WEBPINCLUDE) \ |
| | | 148 | + $(ZLIBINCLUDE) |
120 | | | 149 | |
121 | SRCS1 = xv.c xvevent.c xvroot.c xvmisc.c xvimage.c xvcolor.c xvsmooth.c \ | | 150 | SRCS1 = xv.c xvevent.c xvroot.c xvmisc.c xvimage.c xvcolor.c xvsmooth.c \ |
122 | xv24to8.c xvgif.c xvpm.c xvinfo.c xvctrl.c xvscrl.c xvalg.c \ | | 151 | xv24to8.c xvgif.c xvpm.c xvinfo.c xvctrl.c xvscrl.c xvalg.c \ |
| | | 152 | @@ -166,7 +234,7 @@ SRCS1 = xv.c xvevent.c xvroot.c xvmisc.c |
| | | 153 | xvbrowse.c xvtext.c xvpcx.c xviff.c xvtarga.c xvxpm.c xvcut.c \ |
| | | 154 | xvxwd.c xvfits.c xvpng.c xvzx.c xvwbmp.c xvpcd.c \ |
| | | 155 | xvmag.c xvpic.c xvmaki.c xvpi.c xvpic2.c xvvd.c xvmgcsfx.c \ |
| | | 156 | - xvml.c |
| | | 157 | + xvml.c xvwebp.c |
| | | 158 | |
| | | 159 | OBJS1 = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \ |
| | | 160 | xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \ |
| | | 161 | @@ -176,7 +244,7 @@ OBJS1 = xv.o xvevent.o xvroot.o xvmisc.o |
| | | 162 | xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \ |
| | | 163 | xvxwd.o xvfits.o xvpng.o xvzx.o xvwbmp.o xvpcd.o \ |
| | | 164 | xvmag.o xvpic.o xvmaki.o xvpi.o xvpic2.o xvvd.o xvmgcsfx.o \ |
| | | 165 | - xvml.o |
| | | 166 | + xvml.o xvwebp.o |
| | | 167 | |
| | | 168 | SRCS2= bggen.c |
| | | 169 | OBJS2= bggen.o |
--- pkgsrc/graphics/xv/patches/patch-xv.h 2019/02/21 14:32:32 1.1
+++ pkgsrc/graphics/xv/patches/patch-xv.h 2023/07/30 07:55:45 1.2
| @@ -1,20 +1,22 @@ | | | @@ -1,20 +1,22 @@ |
1 | $NetBSD: patch-xv.h,v 1.1 2019/02/21 14:32:32 tsutsui Exp $ | | 1 | $NetBSD: patch-xv.h,v 1.2 2023/07/30 07:55:45 tsutsui Exp $ |
2 | | | 2 | |
3 | - don't declare errno and sys_errlist | | 3 | - don't declare errno and sys_errlist |
4 | - use strerror | | 4 | - use strerror |
5 | - use getcwd, not getwd | | 5 | - use getcwd, not getwd |
| | | 6 | - add webp support from forked upstream |
| | | 7 | https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e |
6 | | | 8 | |
7 | --- xv.h.orig 2019-02-21 14:07:38.801848956 +0000 | | 9 | --- xv.h.orig 2023-07-30 04:38:20.907901851 +0000 |
8 | +++ xv.h | | 10 | +++ xv.h |
9 | @@ -139,9 +139,7 @@ | | 11 | @@ -139,9 +139,7 @@ |
10 | #endif | | 12 | #endif |
11 | | | 13 | |
12 | | | 14 | |
13 | -#if defined(__FreeBSD__) | | 15 | -#if defined(__FreeBSD__) |
14 | -# include <sys/param.h> | | 16 | -# include <sys/param.h> |
15 | -#endif | | 17 | -#endif |
16 | +#include <sys/param.h> | | 18 | +#include <sys/param.h> |
17 | | | 19 | |
18 | | | 20 | |
19 | /* include files */ | | 21 | /* include files */ |
20 | @@ -160,7 +158,7 @@ | | 22 | @@ -160,7 +158,7 @@ |
| @@ -45,13 +47,81 @@ $NetBSD: patch-xv.h,v 1.1 2019/02/21 14: | | | @@ -45,13 +47,81 @@ $NetBSD: patch-xv.h,v 1.1 2019/02/21 14: |
45 | +# endif | | 47 | +# endif |
46 | # endif | | 48 | # endif |
47 | #endif | | 49 | #endif |
48 | | | 50 | |
49 | @@ -392,7 +392,7 @@ | | 51 | @@ -392,7 +392,7 @@ |
50 | # endif | | 52 | # endif |
51 | #endif | | 53 | #endif |
52 | | | 54 | |
53 | -#if (defined(SYSV) || defined(SVR4) || defined(linux)) && !defined(USE_GETCWD) | | 55 | -#if (defined(SYSV) || defined(SVR4) || defined(linux)) && !defined(USE_GETCWD) |
54 | +#if (defined(SYSV) || defined(SVR4) || defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)) && !defined(USE_GETCWD) | | 56 | +#if (defined(SYSV) || defined(SVR4) || defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)) && !defined(USE_GETCWD) |
55 | # define USE_GETCWD | | 57 | # define USE_GETCWD |
56 | #endif | | 58 | #endif |
57 | | | 59 | |
| | | 60 | @@ -411,6 +411,9 @@ |
| | | 61 | /* END OF CONFIGURATION INFO */ |
| | | 62 | /*****************************/ |
| | | 63 | |
| | | 64 | +#ifdef DOWEBP |
| | | 65 | +# define HAVE_WEBP |
| | | 66 | +#endif |
| | | 67 | |
| | | 68 | #ifdef DOJPEG |
| | | 69 | # define HAVE_JPEG |
| | | 70 | @@ -568,6 +571,12 @@ |
| | | 71 | # define F_TIFINC 0 |
| | | 72 | #endif |
| | | 73 | |
| | | 74 | +#ifdef HAVE_WEBP |
| | | 75 | +# define F_WEBPINC 1 |
| | | 76 | +#else |
| | | 77 | +# define F_WEBPINC 0 |
| | | 78 | +#endif |
| | | 79 | + |
| | | 80 | #ifdef HAVE_PNG |
| | | 81 | # define F_PNGINC 1 |
| | | 82 | #else |
| | | 83 | @@ -621,7 +630,8 @@ |
| | | 84 | #define F_JPC ( 0 + F_PNGINC + F_JPGINC) |
| | | 85 | #define F_JP2 ( 0 + F_PNGINC + F_JPGINC + F_JP2INC) |
| | | 86 | #define F_GIF ( 0 + F_PNGINC + F_JPGINC + F_JP2INC + F_JP2INC) /* always avail; index varies */ |
| | | 87 | -#define F_TIFF ( 0 + F_PNGINC + F_JPGINC + F_JP2INC + F_JP2INC + F_TIFINC) |
| | | 88 | +#define F_WEBP ( 0 + F_PNGINC + F_JPGINC + F_JP2INC + F_JP2INC + F_WEBPINC) |
| | | 89 | +#define F_TIFF ( 0 + F_PNGINC + F_JPGINC + F_JP2INC + F_JP2INC + F_WEBPINC + F_TIFINC) |
| | | 90 | #define F_PS ( 1 + F_TIFF) |
| | | 91 | #define F_PBMRAW ( 2 + F_TIFF) |
| | | 92 | #define F_PBMASCII ( 3 + F_TIFF) |
| | | 93 | @@ -691,6 +701,7 @@ |
| | | 94 | #define RFT_PI (JP_EXT_RFT + 4) |
| | | 95 | #define RFT_PIC2 (JP_EXT_RFT + 5) |
| | | 96 | #define RFT_MGCSFX (JP_EXT_RFT + 6) |
| | | 97 | +#define RFT_WEBP (JP_EXT_RFT + 7) |
| | | 98 | |
| | | 99 | /* definitions for page up/down, arrow up/down list control */ |
| | | 100 | #define LS_PAGEUP 0 |
| | | 101 | @@ -1404,6 +1415,11 @@ WHERE Window pngW; |
| | | 102 | WHERE int pngUp; /* is pngW mapped, or what? */ |
| | | 103 | #endif |
| | | 104 | |
| | | 105 | +#ifdef HAVE_WEBP |
| | | 106 | +/* stuff used for 'webp' box */ |
| | | 107 | +WHERE Window webpW; |
| | | 108 | +WHERE int webpUp; /* is webpW mapped, or what? */ |
| | | 109 | +#endif |
| | | 110 | |
| | | 111 | #ifdef ENABLE_FIXPIX_SMOOTH |
| | | 112 | WHERE int do_fixpix_smooth; /* GRR 19980607: runtime FS dithering */ |
| | | 113 | @@ -2094,6 +2110,14 @@ int LoadSunRas PARM((char *, |
| | | 114 | int WriteSunRas PARM((FILE *, byte *, int, int, int, byte *, |
| | | 115 | byte *, byte*, int, int, int)); |
| | | 116 | |
| | | 117 | +/**************************** XVWEBP.C ***************************/ |
| | | 118 | +int LoadWEBP PARM((char *, PICINFO *)); |
| | | 119 | +void CreateWEBPW PARM((void)); |
| | | 120 | +void WEBPDialog PARM((int)); |
| | | 121 | +int WEBPCheckEvent PARM((XEvent *)); |
| | | 122 | +void WEBPSaveParams PARM((char *)); |
| | | 123 | +void VersionInfoWEBP PARM((void)); |
| | | 124 | + |
| | | 125 | /**************************** XVTARGA.C ***************************/ |
| | | 126 | int LoadTarga PARM((char *, PICINFO *)); |
| | | 127 | int WriteTarga PARM((FILE *, byte *, int, int, int, byte *, |
$NetBSD: patch-bits_br__webp,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
- add webp support from forked upstream
https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
--- bits/br_webp.orig 2023-07-30 04:38:21.013694459 +0000
+++ bits/br_webp
@@ -0,0 +1,23 @@
+#define br_webp_width 48
+#define br_webp_height 48
+static char br_webp_bits[] = {
+ 0xe0,0xff,0xff,0xff,0x01,0x00,0x20,0x00,0x00,0x00,0x03,0x00,0x20,0x00,0x00,
+ 0x00,0x05,0x00,0x20,0x00,0x00,0x00,0x09,0x00,0x20,0x00,0x00,0x00,0x11,0x00,
+ 0x20,0x00,0x00,0x00,0x21,0x00,0x20,0x00,0x00,0x00,0x41,0x00,0x20,0x00,0x00,
+ 0x00,0x81,0x00,0x20,0x00,0x00,0x00,0x01,0x01,0x20,0x00,0x00,0x00,0xff,0x03,
+ 0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x00,0x00,
+ 0x00,0x00,0x02,0x20,0xff,0xff,0xff,0x7f,0x02,0x20,0x00,0x00,0x00,0x00,0x02,
+ 0x20,0xff,0xff,0xff,0x7f,0x02,0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x83,0x7d,
+ 0x3f,0x3f,0x02,0x20,0x83,0x7d,0x7f,0x7f,0x02,0x20,0x83,0x0d,0x63,0x63,0x02,
+ 0x20,0x93,0x0d,0x63,0x63,0x02,0x20,0x93,0x0d,0x63,0x63,0x02,0x20,0xbb,0x7d,
+ 0x7f,0x73,0x02,0x20,0xbb,0x7d,0x3f,0x3f,0x02,0x20,0xef,0x0d,0x63,0x1f,0x02,
+ 0x20,0xef,0x0d,0x63,0x03,0x02,0x20,0xc7,0x0d,0x63,0x03,0x02,0x20,0xc7,0x0d,
+ 0x63,0x03,0x02,0x20,0x83,0x7d,0x7f,0x03,0x02,0x20,0x83,0x7d,0x3f,0x03,0x02,
+ 0x20,0x00,0x00,0x00,0x00,0x02,0x20,0xff,0xff,0xff,0x7f,0x02,0x20,0x00,0x00,
+ 0x00,0x00,0x02,0x20,0xff,0xff,0xff,0x7f,0x02,0x20,0x00,0x00,0x00,0x00,0x02,
+ 0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x00,0x00,
+ 0x00,0x00,0x02,0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x00,0x00,0x00,0x00,0x02,
+ 0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x00,0x00,
+ 0x00,0x00,0x02,0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x00,0x00,0x00,0x00,0x02,
+ 0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x00,0x00,0x00,0x00,0x02,0xe0,0xff,0xff,
+ 0xff,0xff,0x03};
$NetBSD: patch-xv.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
- add webp support from forked upstream
https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
--- xv.c.orig 2023-07-30 04:38:20.015663071 +0000
+++ xv.c
@@ -337,6 +337,10 @@ int main(argc, argv)
pngW = (Window) NULL; pngUp = 0;
#endif
+#ifdef HAVE_WEBP
+ webpW = (Window) NULL; webpUp = 0;
+#endif
+
pcdW = (Window) NULL; pcdUp = 0;
#ifdef HAVE_PIC2
@@ -980,6 +984,11 @@ int main(argc, argv)
XSetTransientForHint(theDisp, pngW, dirW);
#endif
+#ifdef HAVE_WEBP
+ CreateWEBPW();
+ XSetTransientForHint(theDisp, webpW, dirW);
+#endif
+
#ifdef HAVE_PCD
CreatePCDW();
XSetTransientForHint(theDisp, pcdW, dirW);
@@ -1870,6 +1879,9 @@ static void cmdSyntax()
#ifdef HAVE_PNG
VersionInfoPNG();
#endif
+#ifdef HAVE_WEBP
+ VersionInfoWEBP();
+#endif
/* pbm/pgm/ppm support is native, not via pbmplus/netpbm libraries */
fprintf(stderr, "\n");
@@ -3121,6 +3133,15 @@ int ReadFileType(fname)
magicno[2]=='N' && magicno[3]=='G') rv = RFT_PNG;
#endif
+#ifdef HAVE_WEBP
+ else if (magicno[0]==0x52 && magicno[1]==0x49 &&
+ magicno[2]==0x46 && magicno[3]==0x46 &&
+ magicno[8]==0x57 && magicno[9]==0x45 &&
+ magicno[10]==0x42 && magicno[11]==0x50 &&
+ magicno[12]==0x56 && magicno[13]==0x50 &&
+ magicno[14]==0x38) rv = RFT_WEBP;
+#endif
+
#ifdef HAVE_PDS
else if (strncmp((char *) magicno, "NJPL1I00", (size_t) 8)==0 ||
strncmp((char *) magicno+2,"NJPL1I", (size_t) 6)==0 ||
@@ -3258,6 +3279,10 @@ int ReadPicFile(fname, ftype, pinfo, qui
case RFT_PNG: rv = LoadPNG (fname, pinfo); break;
#endif
+#ifdef HAVE_WEBP
+ case RFT_WEBP: rv = LoadWEBP (fname, pinfo); break;
+#endif
+
#ifdef HAVE_PDS
case RFT_PDSVICAR: rv = LoadPDS (fname, pinfo); break;
#endif
$NetBSD: patch-xvbrowse.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
- add webp support from forked upstream
https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
--- xvbrowse.c.orig 2023-07-30 04:38:20.155639398 +0000
+++ xvbrowse.c
@@ -69,6 +69,7 @@ typedef unsigned int mode_t; /* file mo
#include "bits/br_targa"
#include "bits/br_tiff"
#include "bits/br_utah"
+#include "bits/br_webp"
#include "bits/br_xbm"
#include "bits/br_xpm"
#include "bits/br_xwd"
@@ -117,7 +118,8 @@ typedef unsigned int mode_t; /* file mo
#define BF_PCD 30
#define BF_BZIP2 31
#define BF_JP2 32
-#define BF_JPC 33
+#define BF_WEBP 33
+#define BF_JPC 34
#define JP_EXT_BF (BF_JPC)
#define BF_MAG (JP_EXT_BF + 1)
#define BF_MAKI (JP_EXT_BF + 2)
@@ -605,6 +607,7 @@ void CreateBrowse(geom, fgstr, bgstr, hi
bfIcons[BF_PS] =MakePix1(br->win,br_ps_bits, br_ps_width, br_ps_height);
bfIcons[BF_TGA] =MakePix1(br->win,br_tga_bits, br_tga_width, br_tga_height);
bfIcons[BF_TIFF]=MakePix1(br->win,br_tiff_bits,br_tiff_width,br_tiff_height);
+ bfIcons[BF_WEBP]=MakePix1(br->win,br_webp_bits,br_webp_width,br_webp_height);
bfIcons[BF_XBM] =MakePix1(br->win,br_xbm_bits, br_xbm_width, br_xbm_height);
bfIcons[BF_XPM] =MakePix1(br->win,br_xpm_bits, br_xpm_width, br_xpm_height);
bfIcons[BF_XWD] =MakePix1(br->win,br_xwd_bits, br_xwd_width, br_xwd_height);
@@ -3351,6 +3354,7 @@ static void scanFile(br, bf, name)
case RFT_PI: bf->ftype = BF_PI; break;
case RFT_PIC2: bf->ftype = BF_PIC2; break;
case RFT_MGCSFX: bf->ftype = BF_MGCSFX; break;
+ case RFT_WEBP: bf->ftype = BF_WEBP; break;
}
}
}
@@ -3975,6 +3979,7 @@ ms_auto_no:
case RFT_PI: strcat(str,"PI file"); break;
case RFT_PIC2: strcat(str,"PIC2 file"); break;
case RFT_MGCSFX: strcat(str,"Magic Suffix file"); break;
+ case RFT_WEBP: strcat(str,"WEBP file"); break;
default: strcat(str,"file of unknown type"); break;
}
$NetBSD: patch-xvdir.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
- add webp support from forked upstream
https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
--- xvdir.c.orig 2023-07-30 04:38:20.909134802 +0000
+++ xvdir.c
@@ -65,8 +65,11 @@ static const char *saveFormats[] = {
#ifdef HAVE_JP2K
"JPEG 2000",
"JP2",
-#endif
+#endif
"GIF",
+#ifdef HAVE_WEBP
+ "WEBP",
+#endif
#ifdef HAVE_TIFF
"TIFF",
#endif
@@ -1235,6 +1238,16 @@ int DoSave()
}
#endif
+
+#ifdef HAVE_WEBP
+ else if (fmt == F_WEBP) { /* WEBP */
+ WEBPSaveParams(fullname);
+ WEBPDialog(1); /* open WEBP Dialog box */
+ dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]);
+ return 0; /* always 'succeeds' */
+ }
+#endif
+
#ifdef HAVE_PIC2
else if (fmt == F_PIC2) { /* PIC2 */
if (PIC2SaveParams(fullname, col) < 0)
@@ -1488,7 +1501,15 @@ void SetDirSaveMode(group, bnum)
colMB.dim[F_REDUCED] = 1;
MBSelect(&colMB, F_BWDITHER);
}
-
+#ifdef HAVE_WEBP
+ else if (MBWhich(&fmtMB) == F_WEBP) { /* turn off all but FULLCOLOR */
+ colMB.dim[F_FULLCOLOR] = 0;
+ colMB.dim[F_GREYSCALE] = 1;
+ colMB.dim[F_BWDITHER] = 1;
+ colMB.dim[F_REDUCED] = 1;
+ MBSelect(&colMB, F_FULLCOLOR);
+ }
+#endif
else if (MBWhich(&fmtMB) == F_FITS) { /* turn off 'color' modes */
colMB.dim[F_FULLCOLOR] = 1;
colMB.dim[F_GREYSCALE] = 0;
@@ -1578,6 +1599,9 @@ static void changeSuffix()
#ifdef HAVE_PNG
(strcmp(lowsuf,"png" )==0) ||
#endif
+#ifdef HAVE_WEBP
+ (strcmp(lowsuf,"webp")==0) ||
+#endif
(strcmp(lowsuf,"wbmp")==0) ||
(strcmp(lowsuf,"xpm" )==0) ||
(strcmp(lowsuf,"tiff")==0) ||
@@ -1645,6 +1669,10 @@ static void changeSuffix()
case F_MAKI: strcpy(lowsuf,"mki"); break;
#endif
+#ifdef HAVE_WEBP
+ case F_WEBP: strcpy(lowsuf,"webp"); break;
+#endif
+
#ifdef HAVE_PI
case F_PI: strcpy(lowsuf,"pi"); break;
#endif
$NetBSD: patch-xvevent.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
- add webp support using pkgsrc libwebp, from forked upstream
https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
- a pasto of a comment is also fixed
--- xvevent.c.orig 2023-07-30 04:38:20.332206971 +0000
+++ xvevent.c
@@ -212,6 +212,9 @@ int HandleEvent(event, donep)
#ifdef HAVE_PNG
static int wasPngUp=0;
#endif
+#ifdef HAVE_WEBP
+ static int wasWebpUp=0;
+#endif
#ifdef HAVE_PCD
static int wasPcdUp=0;
#endif
@@ -307,6 +310,10 @@ int HandleEvent(event, donep)
if (PNGCheckEvent (event)) break; /* event has been processed */
#endif
+#ifdef HAVE_WEBP
+ if (WEBPCheckEvent(event)) break; /* event has been processed */
+#endif
+
if (PCDCheckEvent(event)) break; /* event has been processed */
#ifdef HAVE_PIC2
@@ -462,6 +469,10 @@ int HandleEvent(event, donep)
else if (client_event->window == pngW) PNGDialog(0);
#endif
+#ifdef HAVE_WEBP
+ else if (client_event->window == webpW) WEBPDialog(0);
+#endif
+
else if (client_event->window == pcdW) PCDDialog(0);
#ifdef HAVE_PIC2
@@ -664,6 +675,9 @@ int HandleEvent(event, donep)
#ifdef HAVE_PNG
if (wasPngUp) { PNGDialog(wasPngUp); wasPngUp=0; }
#endif
+#ifdef HAVE_WEBP
+ if (wasWebpUp) { WEBPDialog(wasWebpUp); wasWebpUp=0; }
+#endif
#ifdef HAVE_PCD
if (wasPcdUp) { PCDDialog(wasPcdUp); wasPcdUp=0; }
#endif
@@ -716,6 +730,9 @@ int HandleEvent(event, donep)
#ifdef HAVE_PNG
if (pngUp) { wasPngUp = pngUp; PNGDialog(0); }
#endif
+#ifdef HAVE_WEBP
+ if (webpUp) { wasWebpUp = webpUp; WEBPDialog(0); }
+#endif
#ifdef HAVE_PCD
if (pcdUp) { wasPcdUp = pcdUp; PCDDialog(0); }
#endif
@@ -1338,6 +1355,10 @@ static void handleButtonEvent(event, don
if (PNGCheckEvent (event)) break;
#endif
+#ifdef HAVE_WEBP
+ if (WEBPCheckEvent(event)) break;
+#endif
+
#ifdef HAVE_PCD
if (PCDCheckEvent (event)) break; /* event has been processed */
#endif
@@ -1621,6 +1642,10 @@ static void handleKeyEvent(event, donep,
if (PNGCheckEvent (event)) break;
#endif
+#ifdef HAVE_WEBP
+ if (WEBPCheckEvent (event)) break;
+#endif
+
if (PCDCheckEvent (event)) break;
#ifdef HAVE_PIC2
@@ -2704,6 +2729,10 @@ static void onInterrupt(i)
if (pngUp) PNGDialog(0); /* close png window */
#endif
+#ifdef HAVE_WEBP
+ if (webpUp) WEBPDialog(0); /* close webp window */
+#endif
+
if (pcdUp) PCDDialog(0); /* close pcd window */
#ifdef HAVE_PIC2
$NetBSD: patch-xvmisc.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
- add webp support from forked upstream
https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
--- xvmisc.c.orig 2023-07-30 04:38:20.941982982 +0000
+++ xvmisc.c
@@ -549,6 +549,10 @@ void Quit(i)
if (pngW) XDestroyWindow(theDisp, pngW);
#endif
+#ifdef HAVE_WEBP
+ if (webpW) XDestroyWindow(theDisp, webpW);
+#endif
+
#ifdef HAVE_PCD
if (pcdW) XDestroyWindow(theDisp, pcdW);
#endif
@@ -770,6 +774,10 @@ static void set_cursors(mainc, otherc)
if (pngW) XDefineCursor(theDisp, pngW, otherc);
#endif
+#ifdef HAVE_WEBP
+ if (webpW) XDefineCursor(theDisp, webpW, otherc);
+#endif
+
#ifdef HAVE_PCD
if (pcdW) XDefineCursor(theDisp, pcdW, otherc);
#endif
$NetBSD: patch-xvwebp.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
- add webp support from forked upstream
https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
- the default quality value is changed to 75 as the original libwebp
- the default "page" of quality qDial is changed to 5.0 as jpeg
- fix a bug of wrong quality value (almost 0) passed to WebPEncodeRGB()
--- xvwebp.c.orig 2023-07-30 06:56:45.683695531 +0000
+++ xvwebp.c
@@ -0,0 +1,420 @@
+/*
+ * xvwebp.c - load routine for 'webp' format pictures
+ *
+ * written and submitted by:
+ * Rainer Canavan (xv@canavan.de)
+ *
+ * LoadWEBP(fname, pinfo)
+ * WriteWEBP(fp, pic, ptype, w,h, rmap,gmap,bmap,numcols, cstyle, comment)
+ */
+
+
+#include "xv.h"
+
+#ifdef HAVE_WEBP
+
+#include <webp/types.h>
+#include <webp/encode.h>
+#include <webp/decode.h>
+
+static char *filename;
+static const char *bname;
+
+static void drawWEBPD PARM((int, int, int, int));
+static void clickWEBPD PARM((int, int));
+static void doCmd PARM((int));
+static void writeWEBP PARM((void));
+static int WriteWEBP PARM((FILE *, byte *, int, int, int,
+ byte *, byte *, byte *));
+
+
+/*** Stuff for WEBP Dialog box ***/
+#define WEBPWIDE 288
+#define WEBPHIGH 185
+
+#define QUALITY 75 /* default quality */
+
+#define DWIDE 86
+#define DHIGH 104
+
+#define P_BOK 0
+#define P_BCANC 1
+#define P_NBUTTS 2
+
+#define BUTTH 24
+
+static DIAL qDial;
+static BUTT pbut[P_NBUTTS];
+static CBUTT FlosslessCB;
+
+
+/*******************************************/
+void CreateWEBPW()
+{
+ webpW = CreateWindow("xv webp", "XVWEBP", NULL,
+ WEBPWIDE, WEBPHIGH, infofg, infobg, 0);
+ if (!webpW) FatalError("can't create WEBP window!");
+
+ XSelectInput(theDisp, webpW, ExposureMask | ButtonPressMask | KeyPressMask);
+
+ DCreate(&qDial, webpW, 12, 25, DWIDE, DHIGH, 0.0,
+ 100.0, QUALITY, 1.0, 5.0,
+ infofg, infobg, hicol, locol, "Quality", NULL);
+
+ CBCreate(&FlosslessCB, webpW, 110, 6+qDial.y+ASCENT+4*LINEHIGH, "Lossless",
+ infofg, infobg, hicol, locol);
+ FlosslessCB.val = 0;
+
+ BTCreate(&pbut[P_BOK], webpW, WEBPWIDE-180-1, WEBPHIGH-10-BUTTH-1, 80, BUTTH,
+ "Ok", infofg, infobg, hicol, locol);
+ BTCreate(&pbut[P_BCANC], webpW, WEBPWIDE-90-1, WEBPHIGH-10-BUTTH-1, 80, BUTTH,
+ "Cancel", infofg, infobg, hicol, locol);
+
+ XMapSubwindows(theDisp, webpW);
+}
+
+
+/*******************************************/
+void WEBPDialog(vis)
+ int vis;
+{
+ if (vis) {
+ CenterMapWindow(webpW, pbut[P_BOK].x + (int) pbut[P_BOK].w/2,
+ pbut[P_BOK].y + (int) pbut[P_BOK].h/2,
+ WEBPWIDE, WEBPHIGH);
+ }
+ else XUnmapWindow(theDisp, webpW);
+ webpUp = vis;
+}
+
+
+/*******************************************/
+int WEBPCheckEvent(xev)
+ XEvent *xev;
+{
+ /* check event to see if it's for one of our subwindows. If it is,
+ deal accordingly, and return '1'. Otherwise, return '0' */
+
+ int rv;
+ rv = 1;
+
+ if (!webpUp) return 0;
+ if (xev->type == Expose) {
+ int x,y,w,h;
+ XExposeEvent *e = (XExposeEvent *) xev;
+ x = e->x; y = e->y; w = e->width; h = e->height;
+
+ /* throw away excess expose events for 'dumb' windows */
+ if (e->count > 0 && (e->window == qDial.win)) {}
+
+ else if (e->window == webpW) drawWEBPD(x, y, w, h);
+ else if (e->window == qDial.win) DRedraw(&qDial);
+ else rv = 0;
+ }
+
+ else if (xev->type == ButtonPress) {
+ XButtonEvent *e = (XButtonEvent *) xev;
+ int x,y;
+ x = e->x; y = e->y;
+
+ if (e->button == Button1) {
+ if (e->window == webpW) clickWEBPD(x,y);
+ else if (e->window == qDial.win) DTrack(&qDial, x, y);
+ else rv = 0;
+ } /* button1 */
+ else rv = 0;
+ } /* button press */
+
+ else if (xev->type == KeyPress) {
+ XKeyEvent *e = (XKeyEvent *) xev;
+ char buf[128]; KeySym ks;
+ int stlen;
+
+ stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL);
+ buf[stlen] = '\0';
+
+ RemapKeyCheck(ks, buf, &stlen);
+
+ if (e->window == webpW) {
+ if (stlen) {
+ if (buf[0] == '\r' || buf[0] == '\n') { /* enter */
+ FakeButtonPress(&pbut[P_BOK]);
+ }
+ else if (buf[0] == '\033') { /* ESC */
+ FakeButtonPress(&pbut[P_BCANC]);
+ }
+ }
+ }
+ else rv = 0;
+ }
+ else rv = 0;
+
+ if (rv==0 && (xev->type == ButtonPress || xev->type == KeyPress)) {
+ XBell(theDisp, 50);
+ rv = 1; /* eat it */
+ }
+
+ return rv;
+}
+
+
+/*******************************************/
+void WEBPSaveParams(fname)
+ char *fname;
+{
+ filename = fname;
+}
+
+
+/*******************************************/
+static void drawWEBPD(x, y, w, h)
+ int x, y, w, h;
+{
+ const char *title = "Save WEBP file...";
+
+ char ctitle1[20];
+ const char *ctitle2 = "Quality value determines";
+ const char *ctitle3 = "compression rate: higher";
+ const char *ctitle4 = "quality = bigger file.";
+
+ int i;
+ XRectangle xr;
+
+ xr.x = x; xr.y = y; xr.width = w; xr.height = h;
+ XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted);
+
+ XSetForeground(theDisp, theGC, infofg);
+ XSetBackground(theDisp, theGC, infobg);
+
+ for (i=0; i<P_NBUTTS; i++) BTRedraw(&pbut[i]);
+
+ DrawString(webpW, 15, 6+ASCENT, title);
+
+ sprintf(ctitle1, "Default = %d", QUALITY);
+ DrawString(webpW, 110, 6+qDial.y+ASCENT, ctitle1);
+ DrawString(webpW, 110, 6+qDial.y+ASCENT+LINEHIGH, ctitle2);
+ DrawString(webpW, 110, 6+qDial.y+ASCENT+2*LINEHIGH, ctitle3);
+ DrawString(webpW, 110, 6+qDial.y+ASCENT+3*LINEHIGH, ctitle4);
+
+ CBRedraw(&FlosslessCB);
+
+ XSetClipMask(theDisp, theGC, None);
+}
+
+
+/*******************************************/
+static void clickWEBPD(x,y)
+ int x,y;
+{
+ int i;
+ BUTT *bp;
+
+ /* check BUTTs */
+
+ for (i=0; i<P_NBUTTS; i++) {
+ bp = &pbut[i];
+ if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
+ }
+
+ if (i<P_NBUTTS) { /* found one */
+ if (BTTrack(bp)) doCmd(i);
+ }
+
+ /* check CBUTTs */
+
+ else if (CBClick(&FlosslessCB,x,y)) {
+ int oldval = FlosslessCB.val;
+
+ CBTrack(&FlosslessCB);
+
+ if (oldval != FlosslessCB.val)
+ {
+ DSetActive(&qDial, !FlosslessCB.val);
+ DRedraw(&qDial); /* necessary? */
+ }
+ }
+}
+
+
+/*******************************************/
+static void doCmd(cmd)
+ int cmd;
+{
+ switch (cmd) {
+ case P_BOK:
+ {
+ char *fullname;
+
+ writeWEBP();
+ WEBPDialog(0);
+
+ fullname = GetDirFullName();
+ if (!ISPIPE(fullname[0])) {
+ XVCreatedFile(fullname);
+ StickInCtrlList(0);
+ }
+ }
+ break;
+
+ case P_BCANC:
+ WEBPDialog(0);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*******************************************/
+int LoadWEBP(fname, pinfo)
+ char *fname;
+ PICINFO *pinfo;
+/*******************************************/
+{
+ /* returns '1' on success */
+
+ FILE *fp;
+ int c, w, h;
+ size_t filesize;
+ byte *filebuf, *pic24;
+
+ bname = BaseName(fname);
+
+ pinfo->pic = (byte *) NULL;
+ pinfo->comment = (char *) NULL;
+
+ fp = xv_fopen(fname,"r");
+ if (!fp) {
+ SetISTR(ISTR_WARNING,"%s: %s", bname, "can't open file");
+ return 0;
+ }
+
+ /* compute file length */
+ fseek(fp, 0L, 2);
+ filesize = ftell(fp);
+ fseek(fp, 0L, 0);
+
+ if (filesize < 24) {
+ fclose(fp);
+ SetISTR(ISTR_WARNING,"%s: %s", bname, "file is too short");
+ return 0;
+ }
+
+ /* read in the entire file */
+
+ filebuf = (byte *) calloc((size_t) filesize, (size_t) 1);
+ if (!filebuf) FatalError("couldn't malloc 'file buffer'");
+ c = fread(filebuf, (size_t) 1, (size_t) filesize, fp);
+ if (c != filesize) {
+ SetISTR(ISTR_WARNING,"%s: %s", bname, "file read error");
+ }
+ fclose(fp);
+ pic24 = WebPDecodeRGB(filebuf, (size_t)filesize, &w, &h);
+ free(filebuf);
+ if (pic24 == NULL) {
+ SetISTR(ISTR_WARNING,"%s: %s", bname, "WebP decode failed");
+ return 0;
+ }
+
+ pinfo->pic = pic24;
+ pinfo->type = PIC24;
+ pinfo->w = w;
+ pinfo->h = h;
+ pinfo->normw = pinfo->w; pinfo->normh = pinfo->h;
+ pinfo->frmType = F_WEBP;
+ sprintf(pinfo->fullInfo,"WEBP, RGB. (%ld bytes)", filesize);
+ sprintf(pinfo->shrtInfo,"%dx%d WEBP.", w,h);
+ pinfo->colType = F_FULLCOLOR;
+
+ return 1;
+}
+
+/*******************************************/
+static void writeWEBP()
+{
+ FILE *fp;
+ int w, h, nc, rv, ptype, pfree;
+ byte *inpix, *rmap, *gmap, *bmap;
+
+ fp = OpenOutFile(filename);
+ if (!fp) return;
+
+ bname = BaseName(filename);
+
+ WaitCursor();
+ inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
+
+ rv = WriteWEBP(fp, inpix, ptype, w, h, rmap, gmap, bmap);
+
+ SetCursors(-1);
+
+ if (CloseOutFile(fp, filename, rv) == 0) DirBox(0);
+
+ if (pfree) free(inpix);
+}
+
+
+/*******************************************/
+int WriteWEBP(fp,pic,ptype,w,h,rmap,gmap,bmap)
+ FILE *fp;
+ byte *pic;
+ int ptype, w,h;
+ byte *rmap, *gmap, *bmap;
+
+/*******************************************/
+{
+ int i;
+ byte *xpic;
+ size_t imagesize;
+ size_t outsize;
+ int pfree;
+
+ imagesize = w*h*3;
+ WaitCursor();
+ pfree = 0;
+ if (ptype == PIC8) {
+ byte *last = pic + w*h;
+ register byte *from, *to;
+
+ from = pic;
+
+ if (!(pic = (byte *)malloc(imagesize))) FatalError("out of memory\n");
+ to = pic;
+ pfree = 1; /* Let the modified buffer be released later */
+
+ do {
+ i = *from;
+ *to++ = rmap[i];
+ *to++ = gmap[i];
+ *to++ = bmap[i];
+ } while (++from < last);
+
+ }
+ if (FlosslessCB.val == 0) {
+ outsize = WebPEncodeRGB(pic, w, h, w*3, (float)qDial.val, &xpic);
+ } else {
+ outsize = WebPEncodeLosslessRGB(pic, w, h, w*3, &xpic);
+ }
+ if (pfree == 1) { free(pic); }
+ if (outsize <= 0) {
+ free(xpic);
+ return -1;
+ }
+ fwrite(xpic, outsize, 1, fp);
+ SetCursors(-1);
+ free(xpic);
+ if (ferror(fp)) return -1;
+ return 0;
+}
+
+/*******************************************/
+void
+VersionInfoWEBP() /* GRR 19980605 */
+{
+ int ver;
+ ver = WebPGetDecoderVersion();
+ fprintf(stderr, " Compiled with libwebp; using libwebp %i.%i.%i.\n",
+ (ver >> 16) & 255, (ver >> 8 ) & 255, ver & 255);
+}
+
+#endif