Skip to content

Commit

Permalink
heif-enc: encode tiled unci images
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 12, 2024
1 parent 8361c6a commit 8fd9d90
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions examples/heif_enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -818,12 +818,27 @@ heif_image_handle* encode_tiled(heif_context* ctx, heif_encoder* encoder, heif_e

error = heif_context_add_tiled_image(ctx, &tiled_params, options, encoder, &tiled_image);
if (error.code != 0) {
std::cerr << "Could not generate grid image: " << error.message << "\n";
std::cerr << "Could not generate tili image: " << error.message << "\n";
return nullptr;
}
}
else if (tiling_method == "unci") {
// TODO
heif_unci_image_parameters params{};
params.version = 1;
params.image_width = tiling.image_width;
params.image_height = tiling.image_height;
params.tile_width = tiling.tile_width;
params.tile_height = tiling.tile_height;
params.compression = heif_metadata_compression_brotli;

std::string input_filename = tile_generator.filename(0,0);
InputImage prototype_image = load_image(input_filename, output_bit_depth);

error = heif_context_add_unci_image(ctx, &params, options, prototype_image.image.get(), &tiled_image);
if (error.code != 0) {
std::cerr << "Could not generate unci image: " << error.message << "\n";
return nullptr;
}
}
else {
assert(false);
Expand Down Expand Up @@ -1279,6 +1294,11 @@ int main(int argc, char** argv)
}
}

if (handle==nullptr) {
std::cerr << "Could not encode image\n";
return 1;
}

if (is_primary_image) {
heif_context_set_primary_image(context.get(), handle);
}
Expand Down

0 comments on commit 8fd9d90

Please sign in to comment.