Skip to content

Commit

Permalink
cleanup heif_image in libde265 decoder with strict mode (#1006)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 24, 2023
1 parent fe8d6b2 commit f69ca4d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions libheif/plugins/decoder_libde265.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,25 @@ static struct heif_error libde265_v1_decode_image(void* decoder_raw,

struct heif_color_profile_nclx* nclx = heif_nclx_color_profile_alloc();
#if LIBDE265_NUMERIC_VERSION >= 0x01000700
HEIF_WARN_OR_FAIL(decoder->strict_decoding, *out_img, heif_nclx_color_profile_set_color_primaries(nclx, static_cast<uint16_t>(de265_get_image_colour_primaries(image))), { heif_nclx_color_profile_free(nclx);});
HEIF_WARN_OR_FAIL(decoder->strict_decoding, *out_img, heif_nclx_color_profile_set_transfer_characteristics(nclx, static_cast<uint16_t>(de265_get_image_transfer_characteristics(image))), { heif_nclx_color_profile_free(nclx);});
HEIF_WARN_OR_FAIL(decoder->strict_decoding, *out_img, heif_nclx_color_profile_set_matrix_coefficients(nclx, static_cast<uint16_t>(de265_get_image_matrix_coefficients(image))), { heif_nclx_color_profile_free(nclx);});
nclx->full_range_flag = (bool)de265_get_image_full_range_flag(image);
HEIF_WARN_OR_FAIL(decoder->strict_decoding, *out_img, heif_nclx_color_profile_set_color_primaries(nclx, static_cast<uint16_t>(de265_get_image_colour_primaries(image))),
{
heif_nclx_color_profile_free(nclx);
heif_image_release(*out_img);
*out_img = nullptr;
});
HEIF_WARN_OR_FAIL(decoder->strict_decoding, *out_img, heif_nclx_color_profile_set_transfer_characteristics(nclx, static_cast<uint16_t>(de265_get_image_transfer_characteristics(image))),
{
heif_nclx_color_profile_free(nclx);
heif_image_release(*out_img);
*out_img = nullptr;
});
HEIF_WARN_OR_FAIL(decoder->strict_decoding, *out_img, heif_nclx_color_profile_set_matrix_coefficients(nclx, static_cast<uint16_t>(de265_get_image_matrix_coefficients(image))),
{
heif_nclx_color_profile_free(nclx);
heif_image_release(*out_img);
*out_img = nullptr;
});
nclx->full_range_flag = (bool) de265_get_image_full_range_flag(image);
#endif
heif_image_set_nclx_color_profile(*out_img, nclx);
heif_nclx_color_profile_free(nclx);
Expand Down

0 comments on commit f69ca4d

Please sign in to comment.