commit 3a3b6556d77cf0aa3539356dac169eb65edca55e
parent 04855e6c1cf5a06864b6e62493e047bcd4af5510
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date: Tue, 24 Jan 2023 14:30:09 +0800
webp(encode): use libc for bool -> int32 conversion
Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Diffstat:
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/webp/encode.go b/webp/encode.go
@@ -88,7 +88,7 @@ func (enc *Encoder) encode(w io.Writer, m *image.RGBA) error {
)),
// quality for libwebp is [0,100].
float32(enc.Quality*100),
- boolToInt32(enc.Lossless),
+ libc.Bool32(enc.Lossless),
uintptr(unsafe.Pointer(&out)),
)
defer lib.WebPFree(tls, uintptr(unsafe.Pointer(out)))
@@ -104,13 +104,6 @@ func (enc *Encoder) encode(w io.Writer, m *image.RGBA) error {
return nil
}
-func boolToInt32(b bool) int32 {
- if b {
- return 1
- }
- return 0
-}
-
// unmanage takes a Go byte slice and returns a copy of it backed by
// unmanaged memory, alongside a function that will free it.
func unmanage(tls *libc.TLS, src []byte) (handle uintptr, free func()) {