Skip to content

Commit

Permalink
Fix heif_image_handle_get_depth_image_representation_info() parameter (
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Feb 1, 2021
1 parent b7caef9 commit cdcb3a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/heif_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ int main(int argc, char** argv)
heif_image_handle_get_height(depth_handle));

const struct heif_depth_representation_info* depth_info;
if (heif_image_handle_get_depth_image_representation_info(depth_handle, depth_id, &depth_info)) {
if (heif_image_handle_get_depth_image_representation_info(handle, depth_id, &depth_info)) {

printf(" z-near: ");
if (depth_info->has_z_near) printf("%f\n", depth_info->z_near); else printf("undefined\n");
Expand Down
14 changes: 12 additions & 2 deletions libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,20 @@ int heif_image_handle_get_depth_image_representation_info(const struct heif_imag
heif_item_id depth_image_id,
const struct heif_depth_representation_info** out)
{
std::shared_ptr<HeifContext::Image> depth_image;

if (out) {
if (handle->image->has_depth_representation_info()) {
if (handle->image->is_depth_channel()) {
// Because of an API bug before v1.11.0, the input handle may be the depth image (#422).
depth_image = handle->image;
}
else {
depth_image = handle->image->get_depth_channel();
}

if (depth_image->has_depth_representation_info()) {
auto info = new heif_depth_representation_info;
*info = handle->image->get_depth_representation_info();
*info = depth_image->get_depth_representation_info();
*out = info;
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions libheif/heif.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ LIBHEIF_API
void heif_depth_representation_info_free(const struct heif_depth_representation_info* info);

// Returns true when there is depth_representation_info available
// Note 1: depth_image_id is currently unused because we support only one depth channel per image, but
// you should still provide the correct ID for future compatibility.
// Note 2: Because of an API bug before v1.11.0, the function also works when 'handle' is the handle of the depth image.
// However, you should pass the handle of the main image. Please adapt your code if needed.
LIBHEIF_API
int heif_image_handle_get_depth_image_representation_info(const struct heif_image_handle* handle,
heif_item_id depth_image_id,
Expand Down

0 comments on commit cdcb3a6

Please sign in to comment.