From 66d3e774f98beca9d133130efb29b11ef3aa4f19 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 1 Apr 2024 17:39:53 +0200 Subject: [PATCH] heifsave: disable HBR support i.e. limit it to a bitdepth of 8, since we compile libaom with `-DCONFIG_AV1_HIGHBITDEPTH=0`. Upstream-Status: Inappropriate [disable feature] This is specific to libvips' prebuilt binaries. --- libvips/foreign/heifsave.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/libvips/foreign/heifsave.c b/libvips/foreign/heifsave.c index 5dc931025..bf3b80117 100644 --- a/libvips/foreign/heifsave.c +++ b/libvips/foreign/heifsave.c @@ -532,20 +532,9 @@ vips_foreign_save_heif_build(VipsObject *object) !vips_object_argument_isset(object, "subsample_mode")) heif->subsample_mode = VIPS_FOREIGN_SUBSAMPLE_OFF; - /* Default 12 bit save for 16-bit images. + /* Prebuilt binaries support a bitdepth of 8 only. */ - if (!vips_object_argument_isset(object, "bitdepth")) - heif->bitdepth = - save->ready->Type == VIPS_INTERPRETATION_RGB16 || - save->ready->Type == VIPS_INTERPRETATION_GREY16 - ? 12 - : 8; - - /* HEIC and AVIF only implements 8 / 10 / 12 bit depth. - */ - if (heif->bitdepth != 12 && - heif->bitdepth != 10 && - heif->bitdepth != 8) { + if (heif->bitdepth != 8) { vips_error("heifsave", _("%d-bit colour depth not supported"), heif->bitdepth); return -1; @@ -691,14 +680,10 @@ vips_foreign_save_heif_build(VipsObject *object) } #define UC VIPS_FORMAT_UCHAR -#define US VIPS_FORMAT_USHORT -/* Except for 8-bit inputs, we send everything else to 16. We decide on 8-bit - * vs. 12 bit save based on Type in_build(), see above. - */ static VipsBandFormat vips_heif_bandfmt[10] = { /* Band format: UC C US S UI I F X D DX */ - /* Promotion: */ UC, UC, US, US, US, US, US, US, US, US + /* Promotion: */ UC, UC, UC, UC, UC, UC, UC, UC, UC, UC }; static void @@ -733,7 +718,7 @@ vips_foreign_save_heif_class_init(VipsForeignSaveHeifClass *class) _("Number of bits per pixel"), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET(VipsForeignSaveHeif, bitdepth), - 8, 12, 12); + 8, 12, 8); VIPS_ARG_BOOL(class, "lossless", 13, _("Lossless"), @@ -786,7 +771,7 @@ vips_foreign_save_heif_init(VipsForeignSaveHeif *heif) { heif->ctx = heif_context_alloc(); heif->Q = 50; - heif->bitdepth = 12; + heif->bitdepth = 8; heif->compression = VIPS_FOREIGN_HEIF_COMPRESSION_HEVC; heif->effort = 4; heif->subsample_mode = VIPS_FOREIGN_SUBSAMPLE_AUTO;