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`.

See:
lovell/sharp#3358
kleisauke/net-vips#217
libvips#3910

Upstream-Status: Inappropriate [disable feature]
This is specific to libvips' prebuilt binaries.
  • Loading branch information
kleisauke committed Apr 1, 2024
1 parent 597d225 commit 79c3cc7
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions libvips/foreign/heifsave.c
Expand Up @@ -501,15 +501,10 @@ vips_foreign_save_heif_build(VipsObject *object)
!vips_object_argument_isset(object, "effort"))
heif->effort = 9 - heif->speed;

/* Default 12 bit save for 16-bit images. HEIC (for example) implements
* 8 / 10 / 12.
*/
if (!vips_object_argument_isset(object, "bitdepth"))
heif->bitdepth =
save->ready->Type == VIPS_INTERPRETATION_RGB16 ||
save->ready->Type == VIPS_INTERPRETATION_GREY16
? 12
: 8;
if (heif->bitdepth != 8) {
g_warning("heifsave: prebuilt binaries support a bitdepth of 8 only");
heif->bitdepth = 8;
}

/* Try to find the selected encoder.
*/
Expand Down Expand Up @@ -651,14 +646,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 @@ -691,9 +682,9 @@ vips_foreign_save_heif_class_init(VipsForeignSaveHeifClass *class)
VIPS_ARG_INT(class, "bitdepth", 11,
_("Bit depth"),
_("Number of bits per pixel"),
VIPS_ARGUMENT_OPTIONAL_INPUT,
VIPS_ARGUMENT_OPTIONAL_INPUT | VIPS_ARGUMENT_DEPRECATED,
G_STRUCT_OFFSET(VipsForeignSaveHeif, bitdepth),
1, 16, 12);
1, 16, 8);

VIPS_ARG_BOOL(class, "lossless", 13,
_("Lossless"),
Expand Down Expand Up @@ -746,7 +737,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 79c3cc7

Please sign in to comment.