Skip to content

Commit

Permalink
heifsave: disable HBR support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kleisauke committed Sep 9, 2024
1 parent b76599d commit 66d3e77
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions libvips/foreign/heifsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 66d3e77

Please sign in to comment.