Skip to content

Commit

Permalink
uncompressed: use more specific options
Browse files Browse the repository at this point in the history
  • Loading branch information
bradh committed Jun 26, 2024
1 parent 230e9d4 commit 6b1fd79
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2748,14 +2748,16 @@ static void set_default_options(heif_encoding_options& options)
options.color_conversion_options.preferred_chroma_upsampling_algorithm = heif_chroma_upsampling_bilinear;
options.color_conversion_options.only_use_preferred_chroma_algorithm = false;

options.prefer_minimised = false;
options.prefer_minimised_boxes_everywhere = false;
options.prefer_uncC_short_form = false;
}

static void copy_options(heif_encoding_options& options, const heif_encoding_options& input_options)
{
switch (input_options.version) {
case 7:
options.prefer_minimised = input_options.prefer_minimised;
options.prefer_minimised_boxes_everywhere = input_options.prefer_minimised_boxes_everywhere;
options.prefer_uncC_short_form = input_options.prefer_uncC_short_form;
// fallthrough
case 6:
options.color_conversion_options = input_options.color_conversion_options;
Expand Down
5 changes: 4 additions & 1 deletion libheif/heif.h
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,10 @@ struct heif_encoding_options
// version 7 options

// Set this to true to used minimised versions of boxes where possible
uint8_t prefer_minimised;
uint8_t prefer_minimised_boxes_everywhere;

// Set this to true to use compressed form of uncC where possible
uint8_t prefer_uncC_short_form;
};

LIBHEIF_API
Expand Down
2 changes: 1 addition & 1 deletion libheif/uncompressed_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ Error UncompressedImageCodec::encode_uncompressed_image(const std::shared_ptr<He
std::shared_ptr<HeifContext::Image>& out_image)
{
std::shared_ptr<Box_uncC> uncC = std::make_shared<Box_uncC>();
if (options.prefer_minimised) {
if (options.prefer_uncC_short_form) {
maybe_make_minimised_uncC(uncC, src_image);
}
if (uncC->get_version() == 1) {
Expand Down
4 changes: 2 additions & 2 deletions tests/uncompressed_encode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ struct heif_image *createImage_RGBA_planar()
return image;
}

static void do_encode(heif_image* input_image, const char* filename, bool check_decode, uint8_t preferMinimised = 0)
static void do_encode(heif_image* input_image, const char* filename, bool check_decode, uint8_t prefer_uncC_short_form = 0)
{
REQUIRE(input_image != nullptr);

Expand All @@ -580,7 +580,7 @@ static void do_encode(heif_image* input_image, const char* filename, bool check_
options->macOS_compatibility_workaround = false;
options->macOS_compatibility_workaround_no_nclx_profile = true;
options->image_orientation = heif_orientation_normal;
options->prefer_minimised = preferMinimised;
options->prefer_uncC_short_form = prefer_uncC_short_form;
heif_image_handle *output_image_handle;

err = heif_context_encode_image(ctx, input_image, encoder, options, &output_image_handle);
Expand Down

0 comments on commit 6b1fd79

Please sign in to comment.