Since AVIF computation was awfully slow, this exposes the CPU effort setting "speed".

This commit is contained in:
Lars Fronius 2020-10-14 13:29:32 +02:00
parent 2cba482a06
commit e87ff245c1
No known key found for this signature in database
GPG key ID: 9799DF92255C2D0C
6 changed files with 19 additions and 4 deletions

View file

@ -45,6 +45,7 @@ type VipsMemoryInfo struct {
// vipsSaveOptions represents the internal option used to talk with libvips.
type vipsSaveOptions struct {
Speed int
Quality int
Compression int
Type ImageType
@ -493,6 +494,7 @@ func vipsSave(image *C.VipsImage, o vipsSaveOptions) ([]byte, error) {
strip := C.int(boolToInt(o.StripMetadata))
lossless := C.int(boolToInt(o.Lossless))
palette := C.int(boolToInt(o.Palette))
speed := C.int(o.Speed)
if o.Type != 0 && !IsTypeSupportedSave(o.Type) {
return nil, fmt.Errorf("VIPS cannot save to %#v", ImageTypes[o.Type])
@ -508,7 +510,7 @@ func vipsSave(image *C.VipsImage, o vipsSaveOptions) ([]byte, error) {
case HEIF:
saveErr = C.vips_heifsave_bridge(tmpImage, &ptr, &length, strip, quality, lossless)
case AVIF:
saveErr = C.vips_avifsave_bridge(tmpImage, &ptr, &length, strip, quality, lossless)
saveErr = C.vips_avifsave_bridge(tmpImage, &ptr, &length, strip, quality, lossless, speed)
default:
saveErr = C.vips_jpegsave_bridge(tmpImage, &ptr, &length, strip, quality, interlace)
}