Commit d74e4ecd for libheif
commit d74e4ecdba7dacab0e707a39833332f71c408606
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Sun May 17 20:02:54 2026 +0200
move iso23001-17 properties into heif_properties.h
diff --git a/examples/heif_gen_bayer.cc b/examples/heif_gen_bayer.cc
index f07265b2..a5eb98c4 100644
--- a/examples/heif_gen_bayer.cc
+++ b/examples/heif_gen_bayer.cc
@@ -50,7 +50,7 @@ struct PatternDefinition
std::string name;
uint16_t width;
uint16_t height;
- std::vector<heif_unci_component_type> cpat;
+ std::vector<heif_cmpd_component_type> cpat;
};
@@ -61,10 +61,10 @@ static const PatternDefinition patterns[] = {
{
"rggb", 2, 2,
{
- heif_unci_component_type_red,
- heif_unci_component_type_green,
- heif_unci_component_type_green,
- heif_unci_component_type_blue,
+ heif_cmpd_component_type_red,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_blue,
}
},
@@ -77,25 +77,25 @@ static const PatternDefinition patterns[] = {
{
"rgbw", 4, 4,
{
- heif_unci_component_type_Y,
- heif_unci_component_type_green,
- heif_unci_component_type_Y,
- heif_unci_component_type_red,
-
- heif_unci_component_type_green,
- heif_unci_component_type_Y,
- heif_unci_component_type_blue,
- heif_unci_component_type_Y,
-
- heif_unci_component_type_Y,
- heif_unci_component_type_blue,
- heif_unci_component_type_Y,
- heif_unci_component_type_green,
-
- heif_unci_component_type_red,
- heif_unci_component_type_Y,
- heif_unci_component_type_green,
- heif_unci_component_type_Y,
+ heif_cmpd_component_type_Y,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_Y,
+ heif_cmpd_component_type_red,
+
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_Y,
+ heif_cmpd_component_type_blue,
+ heif_cmpd_component_type_Y,
+
+ heif_cmpd_component_type_Y,
+ heif_cmpd_component_type_blue,
+ heif_cmpd_component_type_Y,
+ heif_cmpd_component_type_green,
+
+ heif_cmpd_component_type_red,
+ heif_cmpd_component_type_Y,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_Y,
}
},
@@ -107,25 +107,25 @@ static const PatternDefinition patterns[] = {
{
"qbc", 4, 4,
{
- heif_unci_component_type_green,
- heif_unci_component_type_green,
- heif_unci_component_type_red,
- heif_unci_component_type_red,
-
- heif_unci_component_type_green,
- heif_unci_component_type_green,
- heif_unci_component_type_red,
- heif_unci_component_type_red,
-
- heif_unci_component_type_blue,
- heif_unci_component_type_blue,
- heif_unci_component_type_green,
- heif_unci_component_type_green,
-
- heif_unci_component_type_blue,
- heif_unci_component_type_blue,
- heif_unci_component_type_green,
- heif_unci_component_type_green,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_red,
+ heif_cmpd_component_type_red,
+
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_red,
+ heif_cmpd_component_type_red,
+
+ heif_cmpd_component_type_blue,
+ heif_cmpd_component_type_blue,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_green,
+
+ heif_cmpd_component_type_blue,
+ heif_cmpd_component_type_blue,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_green,
}
},
};
@@ -153,14 +153,14 @@ static std::optional<PatternDefinition> parse_pattern_string(const char* str)
}
uint16_t dim = (len == 4) ? 2 : 4;
- std::vector<heif_unci_component_type> cpat;
+ std::vector<heif_cmpd_component_type> cpat;
cpat.reserve(len);
for (char c : s) {
switch (std::tolower(c)) {
- case 'r': cpat.push_back(heif_unci_component_type_red); break;
- case 'g': cpat.push_back(heif_unci_component_type_green); break;
- case 'b': cpat.push_back(heif_unci_component_type_blue); break;
+ case 'r': cpat.push_back(heif_cmpd_component_type_red); break;
+ case 'g': cpat.push_back(heif_cmpd_component_type_green); break;
+ case 'b': cpat.push_back(heif_cmpd_component_type_blue); break;
default: return {};
}
}
@@ -311,7 +311,7 @@ static heif_image* create_bayer_image_from_png(const char* png_filename,
uint32_t filter_array_component_id;
- err = heif_image_add_component(bayer_img, width, height, heif_unci_component_type_filter_array, heif_component_datatype_unsigned_integer, output_bit_depth, &filter_array_component_id);
+ err = heif_image_add_component(bayer_img, width, height, heif_cmpd_component_type_filter_array, heif_component_datatype_unsigned_integer, output_bit_depth, &filter_array_component_id);
if (err.code != heif_error_Ok) {
std::cerr << "Cannot add plane: " << err.message << "\n";
heif_image_release(bayer_img);
@@ -337,10 +337,10 @@ static heif_image* create_bayer_image_from_png(const char* png_filename,
auto comp_type = pat->cpat[py * pat->width + px];
switch (comp_type) {
- case heif_unci_component_type_red: dst_row[x] = r; break;
- case heif_unci_component_type_green: dst_row[x] = g; break;
- case heif_unci_component_type_blue: dst_row[x] = b; break;
- case heif_unci_component_type_Y: dst_row[x] = static_cast<uint8_t>((r + g + b) / 3); break;
+ case heif_cmpd_component_type_red: dst_row[x] = r; break;
+ case heif_cmpd_component_type_green: dst_row[x] = g; break;
+ case heif_cmpd_component_type_blue: dst_row[x] = b; break;
+ case heif_cmpd_component_type_Y: dst_row[x] = static_cast<uint8_t>((r + g + b) / 3); break;
default:
assert(false);
}
@@ -368,10 +368,10 @@ static heif_image* create_bayer_image_from_png(const char* png_filename,
auto comp_type = pat->cpat[py * pat->width + px];
switch (comp_type) {
- case heif_unci_component_type_red: dst_row[x] = r; break;
- case heif_unci_component_type_green: dst_row[x] = g; break;
- case heif_unci_component_type_blue: dst_row[x] = b; break;
- case heif_unci_component_type_Y: dst_row[x] = static_cast<uint16_t>((r + g + b) / 3); break;
+ case heif_cmpd_component_type_red: dst_row[x] = r; break;
+ case heif_cmpd_component_type_green: dst_row[x] = g; break;
+ case heif_cmpd_component_type_blue: dst_row[x] = b; break;
+ case heif_cmpd_component_type_Y: dst_row[x] = static_cast<uint16_t>((r + g + b) / 3); break;
default:
assert(false);
}
diff --git a/heifio/decoder_raw.cc b/heifio/decoder_raw.cc
index 8c4dcea4..a2ed77ae 100644
--- a/heifio/decoder_raw.cc
+++ b/heifio/decoder_raw.cc
@@ -187,7 +187,7 @@ heif_error loadRAW(const char* filename, const RawImageParameters& params, Input
uint32_t component_idx = 0;
err = heif_image_add_component(image, width, height,
- heif_unci_component_type_monochrome,
+ heif_cmpd_component_type_monochrome,
params.datatype, params.bit_depth,
&component_idx);
if (err.code != heif_error_Ok) {
diff --git a/heifio/decoder_tiff.cc b/heifio/decoder_tiff.cc
index 5d112606..ef18f617 100644
--- a/heifio/decoder_tiff.cc
+++ b/heifio/decoder_tiff.cc
@@ -693,7 +693,7 @@ static heif_error readMonoFloat(TIFF* tif, heif_image** image)
uint32_t component_idx;
err = heif_image_add_component(*image, (int)width, (int)height,
- heif_unci_component_type_monochrome,
+ heif_cmpd_component_type_monochrome,
heif_component_datatype_floating_point, 32, &component_idx);
if (err.code != heif_error_Ok) {
heif_image_release(*image);
@@ -740,7 +740,7 @@ static heif_error readMonoSignedInt(TIFF* tif, uint16_t bps, heif_image** image)
uint32_t component_idx;
err = heif_image_add_component(*image, (int)width, (int)height,
- heif_unci_component_type_monochrome,
+ heif_cmpd_component_type_monochrome,
heif_component_datatype_signed_integer, bps, &component_idx);
if (err.code != heif_error_Ok) {
heif_image_release(*image);
@@ -1032,7 +1032,7 @@ static heif_error readTiledContiguous(TIFF* tif, uint32_t width, uint32_t height
uint32_t component_idx;
err = heif_image_add_component(*out_image, (int)width, (int)height,
- heif_unci_component_type_monochrome,
+ heif_cmpd_component_type_monochrome,
heif_component_datatype_floating_point, 32, &component_idx);
if (err.code != heif_error_Ok) {
heif_image_release(*out_image);
@@ -1092,7 +1092,7 @@ static heif_error readTiledContiguous(TIFF* tif, uint32_t width, uint32_t height
uint32_t component_idx;
err = heif_image_add_component(*out_image, (int)width, (int)height,
- heif_unci_component_type_monochrome,
+ heif_cmpd_component_type_monochrome,
heif_component_datatype_signed_integer, bps, &component_idx);
if (err.code != heif_error_Ok) {
heif_image_release(*out_image);
@@ -1639,7 +1639,7 @@ heif_error TiledTiffReader::readTile(uint32_t tx, uint32_t ty, int output_bit_de
uint32_t component_idx;
err = heif_image_add_component(*out_image, (int)actual_w, (int)actual_h,
- heif_unci_component_type_monochrome,
+ heif_cmpd_component_type_monochrome,
heif_component_datatype_floating_point, 32, &component_idx);
if (err.code != heif_error_Ok) {
heif_image_release(*out_image);
@@ -1686,7 +1686,7 @@ heif_error TiledTiffReader::readTile(uint32_t tx, uint32_t ty, int output_bit_de
uint32_t component_idx;
err = heif_image_add_component(*out_image, (int)actual_w, (int)actual_h,
- heif_unci_component_type_monochrome,
+ heif_cmpd_component_type_monochrome,
heif_component_datatype_signed_integer, m_bits_per_sample, &component_idx);
if (err.code != heif_error_Ok) {
heif_image_release(*out_image);
diff --git a/libheif/api/libheif/heif_properties.cc b/libheif/api/libheif/heif_properties.cc
index bc18e416..cfb3e7bd 100644
--- a/libheif/api/libheif/heif_properties.cc
+++ b/libheif/api/libheif/heif_properties.cc
@@ -22,6 +22,7 @@
#include "context.h"
#include "api_structs.h"
#include "file.h"
+#include "image/pixelimage.h"
#include <array>
#include <cstring>
@@ -458,3 +459,549 @@ heif_error heif_camera_extrinsic_matrix_get_rotation_matrix(const heif_camera_ex
return heif_error_success;
}
+
+// ====================== ISO/IEC 23001-17 properties ======================
+
+
+heif_error heif_image_set_bayer_pattern(heif_image* image,
+ uint32_t bayer_component_id,
+ uint16_t pattern_width,
+ uint16_t pattern_height,
+ const struct heif_bayer_pattern_pixel* patternPixels)
+{
+ if (image == nullptr || patternPixels == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (pattern_width == 0 || pattern_height == 0) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Bayer pattern dimensions must be non-zero."};
+ }
+
+ BayerPattern pattern;
+ pattern.pattern_width = pattern_width;
+ pattern.pattern_height = pattern_height;
+
+ size_t num_pixels = size_t{pattern_width} * pattern_height;
+ pattern.pixels.assign(patternPixels, patternPixels + num_pixels);
+
+ image->image->set_bayer_pattern(pattern);
+
+ return heif_error_success;
+}
+
+
+heif_error heif_image_add_bayer_component(heif_image* image,
+ uint16_t component_type,
+ uint32_t* out_component_id)
+{
+ if (image == nullptr || out_component_id == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ *out_component_id = image->image->add_component_without_data(component_type);
+
+ return heif_error_success;
+}
+
+
+int heif_image_has_bayer_pattern(const heif_image* image,
+ uint32_t bayer_component_id,
+ uint16_t* out_pattern_width,
+ uint16_t* out_pattern_height)
+{
+ if (image == nullptr || !image->image->has_bayer_pattern(bayer_component_id)) {
+ if (out_pattern_width) {
+ *out_pattern_width = 0;
+ }
+ if (out_pattern_height) {
+ *out_pattern_height = 0;
+ }
+ return 0;
+ }
+
+ const BayerPattern& pattern = image->image->get_bayer_pattern(bayer_component_id);
+
+ if (out_pattern_width) {
+ *out_pattern_width = pattern.pattern_width;
+ }
+ if (out_pattern_height) {
+ *out_pattern_height = pattern.pattern_height;
+ }
+
+ return 1;
+}
+
+
+heif_error heif_image_get_bayer_pattern(const heif_image* image,
+ uint32_t bayer_component_id,
+ struct heif_bayer_pattern_pixel* out_patternPixels)
+{
+ if (image == nullptr || out_patternPixels == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (!image->image->has_bayer_pattern(bayer_component_id)) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Image does not have a Bayer pattern."};
+ }
+
+ const BayerPattern& pattern = image->image->get_bayer_pattern(bayer_component_id);
+ size_t num_pixels = size_t{pattern.pattern_width} * pattern.pattern_height;
+ std::copy(pattern.pixels.begin(), pattern.pixels.begin() + num_pixels, out_patternPixels);
+
+ return heif_error_success;
+}
+
+
+float heif_polarization_angle_no_filter()
+{
+ uint32_t bits = 0xFFFFFFFF;
+ float f;
+ memcpy(&f, &bits, sizeof(f));
+ return f;
+}
+
+
+int heif_polarization_angle_is_no_filter(float angle)
+{
+ uint32_t bits;
+ memcpy(&bits, &angle, sizeof(bits));
+ return bits == 0xFFFFFFFF;
+}
+
+
+heif_error heif_image_add_polarization_pattern(heif_image* image,
+ uint32_t num_component_ids,
+ const uint32_t* component_ids,
+ uint16_t pattern_width,
+ uint16_t pattern_height,
+ const float* polarization_angles)
+{
+ if (image == nullptr || polarization_angles == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (num_component_ids > 0 && component_ids == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (pattern_width == 0 || pattern_height == 0) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Polarization pattern dimensions must be non-zero."};
+ }
+
+ PolarizationPattern pattern;
+ pattern.component_ids.assign(component_ids, component_ids + num_component_ids);
+ pattern.pattern_width = pattern_width;
+ pattern.pattern_height = pattern_height;
+
+ size_t num_pixels = size_t{pattern_width} * pattern_height;
+ pattern.polarization_angles.assign(polarization_angles, polarization_angles + num_pixels);
+
+ image->image->add_polarization_pattern(pattern);
+
+ return heif_error_success;
+}
+
+
+int heif_image_get_number_of_polarization_patterns(const heif_image* image)
+{
+ if (image == nullptr) {
+ return 0;
+ }
+
+ return static_cast<int>(image->image->get_polarization_patterns().size());
+}
+
+
+heif_error heif_image_get_polarization_pattern_info(const heif_image* image,
+ int pattern_index,
+ uint32_t* out_num_component_ids,
+ uint16_t* out_pattern_width,
+ uint16_t* out_pattern_height)
+{
+ if (image == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ const auto& patterns = image->image->get_polarization_patterns();
+ if (pattern_index < 0 || static_cast<size_t>(pattern_index) >= patterns.size()) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Polarization pattern index out of range."};
+ }
+
+ const auto& p = patterns[pattern_index];
+ if (out_num_component_ids) {
+ *out_num_component_ids = static_cast<uint32_t>(p.component_ids.size());
+ }
+ if (out_pattern_width) {
+ *out_pattern_width = p.pattern_width;
+ }
+ if (out_pattern_height) {
+ *out_pattern_height = p.pattern_height;
+ }
+
+ return heif_error_success;
+}
+
+
+heif_error heif_image_get_polarization_pattern_data(const heif_image* image,
+ int pattern_index,
+ uint32_t* out_component_ids,
+ float* out_polarization_angles)
+{
+ if (image == nullptr || out_polarization_angles == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ const auto& patterns = image->image->get_polarization_patterns();
+ if (pattern_index < 0 || static_cast<size_t>(pattern_index) >= patterns.size()) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Polarization pattern index out of range."};
+ }
+
+ const auto& p = patterns[pattern_index];
+
+ if (out_component_ids && !p.component_ids.empty()) {
+ std::copy(p.component_ids.begin(), p.component_ids.end(), out_component_ids);
+ }
+
+ size_t num_pixels = size_t{p.pattern_width} * p.pattern_height;
+ std::copy(p.polarization_angles.begin(), p.polarization_angles.begin() + num_pixels, out_polarization_angles);
+
+ return heif_error_success;
+}
+
+
+int heif_image_get_polarization_pattern_index_for_component(const heif_image* image,
+ uint32_t component_id)
+{
+ if (image == nullptr) {
+ return -1;
+ }
+
+ const auto& patterns = image->image->get_polarization_patterns();
+ for (size_t i = 0; i < patterns.size(); i++) {
+ const auto& p = patterns[i];
+ if (p.component_ids.empty()) {
+ // Empty component list means pattern applies to all components.
+ return static_cast<int>(i);
+ }
+ for (uint32_t idx : p.component_ids) {
+ if (idx == component_id) {
+ return static_cast<int>(i);
+ }
+ }
+ }
+
+ return -1;
+}
+
+
+heif_error heif_image_add_sensor_bad_pixels_map(heif_image* image,
+ uint32_t num_component_ids,
+ const uint32_t* component_ids,
+ int correction_applied,
+ uint32_t num_bad_rows,
+ const uint32_t* bad_rows,
+ uint32_t num_bad_columns,
+ const uint32_t* bad_columns,
+ uint32_t num_bad_pixels,
+ const struct heif_bad_pixel* bad_pixels)
+{
+ if (image == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (num_component_ids > 0 && component_ids == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (num_bad_rows > 0 && bad_rows == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (num_bad_columns > 0 && bad_columns == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (num_bad_pixels > 0 && bad_pixels == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ SensorBadPixelsMap map;
+ map.component_ids.assign(component_ids, component_ids + num_component_ids);
+ map.correction_applied = (correction_applied != 0);
+
+ map.bad_rows.assign(bad_rows, bad_rows + num_bad_rows);
+ map.bad_columns.assign(bad_columns, bad_columns + num_bad_columns);
+
+ map.bad_pixels.resize(num_bad_pixels);
+ for (uint32_t i = 0; i < num_bad_pixels; i++) {
+ map.bad_pixels[i].row = bad_pixels[i].row;
+ map.bad_pixels[i].column = bad_pixels[i].column;
+ }
+
+ image->image->add_sensor_bad_pixels_map(map);
+
+ return heif_error_success;
+}
+
+
+int heif_image_get_number_of_sensor_bad_pixels_maps(const heif_image* image)
+{
+ if (image == nullptr) {
+ return 0;
+ }
+
+ return static_cast<int>(image->image->get_sensor_bad_pixels_maps().size());
+}
+
+
+heif_error heif_image_get_sensor_bad_pixels_map_info(const heif_image* image,
+ int map_index,
+ uint32_t* out_num_component_ids,
+ int* out_correction_applied,
+ uint32_t* out_num_bad_rows,
+ uint32_t* out_num_bad_columns,
+ uint32_t* out_num_bad_pixels)
+{
+ if (image == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ const auto& maps = image->image->get_sensor_bad_pixels_maps();
+ if (map_index < 0 || static_cast<size_t>(map_index) >= maps.size()) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Sensor bad pixels map index out of range."};
+ }
+
+ const auto& m = maps[map_index];
+ if (out_num_component_ids) {
+ *out_num_component_ids = static_cast<uint32_t>(m.component_ids.size());
+ }
+ if (out_correction_applied) {
+ *out_correction_applied = m.correction_applied ? 1 : 0;
+ }
+ if (out_num_bad_rows) {
+ *out_num_bad_rows = static_cast<uint32_t>(m.bad_rows.size());
+ }
+ if (out_num_bad_columns) {
+ *out_num_bad_columns = static_cast<uint32_t>(m.bad_columns.size());
+ }
+ if (out_num_bad_pixels) {
+ *out_num_bad_pixels = static_cast<uint32_t>(m.bad_pixels.size());
+ }
+
+ return heif_error_success;
+}
+
+
+heif_error heif_image_get_sensor_bad_pixels_map_data(const heif_image* image,
+ int map_index,
+ uint32_t* out_component_ids,
+ uint32_t* out_bad_rows,
+ uint32_t* out_bad_columns,
+ struct heif_bad_pixel* out_bad_pixels)
+{
+ if (image == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ const auto& maps = image->image->get_sensor_bad_pixels_maps();
+ if (map_index < 0 || static_cast<size_t>(map_index) >= maps.size()) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Sensor bad pixels map index out of range."};
+ }
+
+ const auto& m = maps[map_index];
+
+ if (out_component_ids && !m.component_ids.empty()) {
+ std::copy(m.component_ids.begin(), m.component_ids.end(), out_component_ids);
+ }
+
+ if (out_bad_rows && !m.bad_rows.empty()) {
+ std::copy(m.bad_rows.begin(), m.bad_rows.end(), out_bad_rows);
+ }
+
+ if (out_bad_columns && !m.bad_columns.empty()) {
+ std::copy(m.bad_columns.begin(), m.bad_columns.end(), out_bad_columns);
+ }
+
+ if (out_bad_pixels && !m.bad_pixels.empty()) {
+ for (size_t i = 0; i < m.bad_pixels.size(); i++) {
+ out_bad_pixels[i].row = m.bad_pixels[i].row;
+ out_bad_pixels[i].column = m.bad_pixels[i].column;
+ }
+ }
+
+ return heif_error_success;
+}
+
+
+heif_error heif_image_add_sensor_nuc(heif_image* image,
+ uint32_t num_component_ids,
+ const uint32_t* component_ids,
+ int nuc_is_applied,
+ uint32_t image_width,
+ uint32_t image_height,
+ const float* nuc_gains,
+ const float* nuc_offsets)
+{
+ if (image == nullptr || nuc_gains == nullptr || nuc_offsets == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (num_component_ids > 0 && component_ids == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (image_width == 0 || image_height == 0) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "NUC image dimensions must be non-zero."};
+ }
+
+ SensorNonUniformityCorrection nuc;
+ nuc.component_ids.assign(component_ids, component_ids + num_component_ids);
+ nuc.nuc_is_applied = (nuc_is_applied != 0);
+ nuc.image_width = image_width;
+ nuc.image_height = image_height;
+
+ size_t num_pixels = size_t{image_width} * image_height;
+ nuc.nuc_gains.assign(nuc_gains, nuc_gains + num_pixels);
+ nuc.nuc_offsets.assign(nuc_offsets, nuc_offsets + num_pixels);
+
+ image->image->add_sensor_nuc(nuc);
+
+ return heif_error_success;
+}
+
+
+int heif_image_get_number_of_sensor_nucs(const heif_image* image)
+{
+ if (image == nullptr) {
+ return 0;
+ }
+
+ return static_cast<int>(image->image->get_sensor_nuc().size());
+}
+
+
+heif_error heif_image_get_sensor_nuc_info(const heif_image* image,
+ int nuc_index,
+ uint32_t* out_num_component_ids,
+ int* out_nuc_is_applied,
+ uint32_t* out_image_width,
+ uint32_t* out_image_height)
+{
+ if (image == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ const auto& nucs = image->image->get_sensor_nuc();
+ if (nuc_index < 0 || static_cast<size_t>(nuc_index) >= nucs.size()) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Sensor NUC index out of range."};
+ }
+
+ const auto& n = nucs[nuc_index];
+ if (out_num_component_ids) {
+ *out_num_component_ids = static_cast<uint32_t>(n.component_ids.size());
+ }
+ if (out_nuc_is_applied) {
+ *out_nuc_is_applied = n.nuc_is_applied ? 1 : 0;
+ }
+ if (out_image_width) {
+ *out_image_width = n.image_width;
+ }
+ if (out_image_height) {
+ *out_image_height = n.image_height;
+ }
+
+ return heif_error_success;
+}
+
+
+heif_error heif_image_get_sensor_nuc_data(const heif_image* image,
+ int nuc_index,
+ uint32_t* out_component_ids,
+ float* out_nuc_gains,
+ float* out_nuc_offsets)
+{
+ if (image == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ const auto& nucs = image->image->get_sensor_nuc();
+ if (nuc_index < 0 || static_cast<size_t>(nuc_index) >= nucs.size()) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Sensor NUC index out of range."};
+ }
+
+ const auto& n = nucs[nuc_index];
+
+ if (out_component_ids && !n.component_ids.empty()) {
+ std::copy(n.component_ids.begin(), n.component_ids.end(), out_component_ids);
+ }
+
+ size_t num_pixels = size_t{n.image_width} * n.image_height;
+
+ if (out_nuc_gains && !n.nuc_gains.empty()) {
+ std::copy(n.nuc_gains.begin(), n.nuc_gains.begin() + num_pixels, out_nuc_gains);
+ }
+
+ if (out_nuc_offsets && !n.nuc_offsets.empty()) {
+ std::copy(n.nuc_offsets.begin(), n.nuc_offsets.begin() + num_pixels, out_nuc_offsets);
+ }
+
+ return heif_error_success;
+}
+
+
+heif_error heif_image_set_chroma_location(heif_image* image, uint8_t chroma_location)
+{
+ if (image == nullptr) {
+ return heif_error_null_pointer_argument;
+ }
+
+ if (chroma_location > 6) {
+ return {heif_error_Usage_error,
+ heif_suberror_Invalid_parameter_value,
+ "Chroma location must be in the range 0-6."};
+ }
+
+ image->image->set_chroma_location(chroma_location);
+
+ return heif_error_success;
+}
+
+
+int heif_image_has_chroma_location(const heif_image* image)
+{
+ if (image == nullptr) {
+ return 0;
+ }
+
+ return image->image->has_chroma_location() ? 1 : 0;
+}
+
+
+uint8_t heif_image_get_chroma_location(const heif_image* image)
+{
+ if (image == nullptr) {
+ return 0;
+ }
+
+ return image->image->get_chroma_location();
+}
diff --git a/libheif/api/libheif/heif_properties.h b/libheif/api/libheif/heif_properties.h
index ceda2aa2..9432bd46 100644
--- a/libheif/api/libheif/heif_properties.h
+++ b/libheif/api/libheif/heif_properties.h
@@ -192,6 +192,253 @@ heif_error heif_item_get_property_uuid_type(const heif_context* context,
uint8_t out_extended_type[16]);
+// ------------------------- ISO/IEC 23001-17 properties -------------------------
+//
+// Imaging-metadata properties defined by ISO/IEC 23001-17 (uncompressed-image
+// format) and currently surfaced on uncompressed images. They operate on a
+// heif_image (the in-memory pixel image) rather than on (context, item_id) like
+// the box-level property API above.
+
+
+// --- Bayer / filter array pattern (cpat box)
+
+typedef struct heif_bayer_pattern_pixel
+{
+ uint32_t component_id;
+ float component_gain;
+} heif_bayer_pattern_pixel;
+
+
+// Set a Bayer / filter array pattern on an image.
+// The pattern is a 2D array of component indices with dimensions pattern_width x pattern_height.
+// The number of entries in patternPixels must be pattern_width * pattern_height.
+// The component_index values are indices into the cmpd component definition table.
+// On the encoder path, these indices are generated by heif_image_add_component() and the
+// encoder adds reference components to cmpd for pattern entries that don't have image planes.
+// On the decoder path, they come directly from the cpat box.
+LIBHEIF_API
+heif_error heif_image_set_bayer_pattern(heif_image*,
+ uint32_t bayer_component_id,
+ uint16_t pattern_width,
+ uint16_t pattern_height,
+ const heif_bayer_pattern_pixel* patternPixels);
+
+// Add a reference-only component to the image's component description table for use as
+// a Bayer pattern entry. The component is registered (its component_type appears in the
+// cmpd box) but carries no pixel plane of its own — the actual pixel data lives in the
+// single combined Bayer component (added with heif_image_add_component()).
+//
+// Use this for the per-cell colors that the Bayer pattern references (e.g. red, green,
+// blue) when those colors have no standalone plane. Pass the returned component_id in
+// heif_bayer_pattern_pixel::component_id of the patternPixels array given to
+// heif_image_set_bayer_pattern().
+//
+// component_type: one of heif_cmpd_component_type_* (e.g. _red, _green, _blue).
+// out_component_id: receives the minted component id. Must not be NULL.
+LIBHEIF_API
+heif_error heif_image_add_bayer_component(heif_image*,
+ uint16_t component_type,
+ uint32_t* out_component_id);
+
+// Returns whether the image has a Bayer / filter array pattern.
+// If the image has a pattern, out_pattern_width and out_pattern_height are set.
+// Either output pointer may be NULL if the caller does not need that value.
+LIBHEIF_API
+int heif_image_get_bayer_pattern_size(const heif_image*,
+ uint32_t bayer_component_id,
+ uint16_t* out_pattern_width,
+ uint16_t* out_pattern_height);
+
+// Get the Bayer / filter array pattern pixels.
+// The caller must provide an array large enough for pattern_width * pattern_height entries
+// (use heif_image_get_bayer_pattern_size() to query the dimensions first).
+// Returns heif_error_Ok on success, or an error if no pattern is set.
+LIBHEIF_API
+heif_error heif_image_get_bayer_pattern(const heif_image*,
+ uint32_t bayer_component_id,
+ heif_bayer_pattern_pixel* out_patternPixels);
+
+
+// --- Polarization pattern (ISO 23001-17, Section 6.1.5)
+
+// Special float value indicating "no polarization filter" at a pattern position.
+// On the wire this is the IEEE 754 bit pattern 0xFFFFFFFF (a signaling NaN).
+// Test with heif_polarization_angle_is_no_filter() below, or with isnan()/std::isnan().
+
+// Returns a float with the 0xFFFFFFFF bit pattern (NaN) representing "no polarization filter".
+LIBHEIF_API
+float heif_polarization_angle_no_filter(void);
+
+// Returns non-zero if the given angle has the "no filter" bit pattern (0xFFFFFFFF).
+LIBHEIF_API
+int heif_polarization_angle_is_no_filter(float angle);
+
+// Add a polarization pattern to an image.
+// component_indices: array of component indices this pattern applies to (may be NULL if num_component_indices == 0,
+// meaning the pattern applies to all components).
+// polarization_angles: array of pattern_width * pattern_height float values.
+// Each is an angle in degrees [0.0, 360.0), or heif_polarization_angle_no_filter() for "no filter".
+// Multiple patterns can be added (one per distinct component group).
+LIBHEIF_API
+heif_error heif_image_add_polarization_pattern(heif_image*,
+ uint32_t num_component_indices,
+ const uint32_t* component_indices,
+ uint16_t pattern_width,
+ uint16_t pattern_height,
+ const float* polarization_angles);
+
+// Returns the number of polarization patterns on this image (0 if none).
+LIBHEIF_API
+int heif_image_get_number_of_polarization_patterns(const heif_image*);
+
+// Get the sizes/dimensions of a polarization pattern (to allocate arrays for the data query).
+LIBHEIF_API
+heif_error heif_image_get_polarization_pattern_info(const heif_image*,
+ int pattern_index,
+ uint32_t* out_num_component_indices,
+ uint16_t* out_pattern_width,
+ uint16_t* out_pattern_height);
+
+// Get the actual data of a polarization pattern.
+// Caller must provide pre-allocated arrays:
+// out_component_indices: num_component_indices entries (may be NULL if num_component_indices == 0)
+// out_polarization_angles: pattern_width * pattern_height entries
+LIBHEIF_API
+heif_error heif_image_get_polarization_pattern_data(const heif_image*,
+ int pattern_index,
+ uint32_t* out_component_indices,
+ float* out_polarization_angles);
+
+// Find the polarization pattern index that applies to a given component index.
+// Returns the pattern index (>= 0), or -1 if no pattern matches.
+// A pattern with an empty component list (component_count == 0) matches all components.
+LIBHEIF_API
+int heif_image_get_polarization_pattern_index_for_component(const heif_image*,
+ uint32_t component_index);
+
+
+// --- Sensor bad pixels map (ISO 23001-17, Section 6.1.7)
+
+struct heif_bad_pixel { uint32_t row; uint32_t column; };
+
+// Add a sensor bad pixels map to an image.
+// component_indices: array of component indices this map applies to (may be NULL if num_component_indices == 0,
+// meaning the map applies to all components).
+// Multiple maps can be added (one per distinct component group with different defects).
+LIBHEIF_API
+heif_error heif_image_add_sensor_bad_pixels_map(heif_image*,
+ uint32_t num_component_indices,
+ const uint32_t* component_indices,
+ int correction_applied,
+ uint32_t num_bad_rows,
+ const uint32_t* bad_rows,
+ uint32_t num_bad_columns,
+ const uint32_t* bad_columns,
+ uint32_t num_bad_pixels,
+ const heif_bad_pixel* bad_pixels);
+
+// Returns the number of sensor bad pixels maps on this image (0 if none).
+LIBHEIF_API
+int heif_image_get_number_of_sensor_bad_pixels_maps(const heif_image*);
+
+// Get the sizes of a sensor bad pixels map (to allocate arrays for the data query).
+LIBHEIF_API
+heif_error heif_image_get_sensor_bad_pixels_map_info(const heif_image*,
+ int map_index,
+ uint32_t* out_num_component_indices,
+ int* out_correction_applied,
+ uint32_t* out_num_bad_rows,
+ uint32_t* out_num_bad_columns,
+ uint32_t* out_num_bad_pixels);
+
+// Get the actual data of a sensor bad pixels map.
+// Caller must provide pre-allocated arrays:
+// out_component_indices: num_component_indices entries (may be NULL if num_component_indices == 0)
+// out_bad_rows: num_bad_rows entries (may be NULL if num_bad_rows == 0)
+// out_bad_columns: num_bad_columns entries (may be NULL if num_bad_columns == 0)
+// out_bad_pixels: num_bad_pixels entries (may be NULL if num_bad_pixels == 0)
+LIBHEIF_API
+heif_error heif_image_get_sensor_bad_pixels_map_data(const heif_image*,
+ int map_index,
+ uint32_t* out_component_indices,
+ uint32_t* out_bad_rows,
+ uint32_t* out_bad_columns,
+ struct heif_bad_pixel* out_bad_pixels);
+
+
+// --- Sensor non-uniformity correction (ISO 23001-17, Section 6.1.6)
+
+// Add a sensor non-uniformity correction table to an image.
+// component_indices: array of component indices this NUC applies to (may be NULL if num_component_indices == 0,
+// meaning it applies to all components).
+// nuc_gains and nuc_offsets: arrays of image_width * image_height float values.
+// Correction equation: y = nuc_gain * x + nuc_offset.
+// Multiple NUC tables can be added (one per distinct component group).
+LIBHEIF_API
+heif_error heif_image_add_sensor_nuc(heif_image*,
+ uint32_t num_component_indices,
+ const uint32_t* component_indices,
+ int nuc_is_applied,
+ uint32_t image_width,
+ uint32_t image_height,
+ const float* nuc_gains,
+ const float* nuc_offsets);
+
+// Returns the number of sensor NUC tables on this image (0 if none).
+LIBHEIF_API
+int heif_image_get_number_of_sensor_nucs(const heif_image*);
+
+// Get the sizes of a sensor NUC table (to allocate arrays for the data query).
+LIBHEIF_API
+heif_error heif_image_get_sensor_nuc_info(const heif_image*,
+ int nuc_index,
+ uint32_t* out_num_component_indices,
+ int* out_nuc_is_applied,
+ uint32_t* out_image_width,
+ uint32_t* out_image_height);
+
+// Get the actual data of a sensor NUC table.
+// Caller must provide pre-allocated arrays:
+// out_component_indices: num_component_indices entries (may be NULL if num_component_indices == 0)
+// out_nuc_gains: image_width * image_height entries
+// out_nuc_offsets: image_width * image_height entries
+LIBHEIF_API
+heif_error heif_image_get_sensor_nuc_data(const heif_image*,
+ int nuc_index,
+ uint32_t* out_component_indices,
+ float* out_nuc_gains,
+ float* out_nuc_offsets);
+
+
+// --- Chroma sample location (ISO 23091-2 / ITU-T H.273 + ISO 23001-17, Section 6.1.4) [cloc box]
+
+typedef enum heif_chroma420_sample_location {
+ // values 0-5 according to ISO 23091-2 / ITU-T H.273
+ heif_chroma420_sample_location_00_05 = 0,
+ heif_chroma420_sample_location_05_05 = 1,
+ heif_chroma420_sample_location_00_00 = 2,
+ heif_chroma420_sample_location_05_00 = 3,
+ heif_chroma420_sample_location_00_10 = 4,
+ heif_chroma420_sample_location_05_10 = 5,
+
+ // value 6 according to ISO 23001-17
+ heif_chroma420_sample_location_00_00_01_00 = 6
+} heif_chroma420_sample_location;
+
+// Set the chroma sample location on an image.
+// chroma_location must be in the range 0-6 (see heif_chroma420_sample_location).
+LIBHEIF_API
+heif_error heif_image_set_chroma_location(heif_image*, uint8_t chroma_location);
+
+// Returns non-zero if the image has a chroma sample location set.
+LIBHEIF_API
+int heif_image_has_chroma_location(const heif_image*);
+
+// Returns the chroma sample location (0-6), or 0 if none is set.
+LIBHEIF_API
+uint8_t heif_image_get_chroma_location(const heif_image*);
+
+
// ------------------------- intrinsic and extrinsic matrices -------------------------
typedef struct heif_camera_intrinsic_matrix
diff --git a/libheif/api/libheif/heif_uncompressed.cc b/libheif/api/libheif/heif_uncompressed.cc
index 6ef18996..72667187 100644
--- a/libheif/api/libheif/heif_uncompressed.cc
+++ b/libheif/api/libheif/heif_uncompressed.cc
@@ -30,548 +30,8 @@
#include <algorithm>
-heif_error heif_image_set_bayer_pattern(heif_image* image,
- uint32_t bayer_component_id,
- uint16_t pattern_width,
- uint16_t pattern_height,
- const struct heif_bayer_pattern_pixel* patternPixels)
-{
- if (image == nullptr || patternPixels == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (pattern_width == 0 || pattern_height == 0) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Bayer pattern dimensions must be non-zero."};
- }
-
- BayerPattern pattern;
- pattern.pattern_width = pattern_width;
- pattern.pattern_height = pattern_height;
-
- size_t num_pixels = size_t{pattern_width} * pattern_height;
- pattern.pixels.assign(patternPixels, patternPixels + num_pixels);
-
- image->image->set_bayer_pattern(pattern);
-
- return heif_error_success;
-}
-
-
-heif_error heif_image_add_bayer_component(heif_image* image,
- uint16_t component_type,
- uint32_t* out_component_id)
-{
- if (image == nullptr || out_component_id == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- *out_component_id = image->image->add_component_without_data(component_type);
-
- return heif_error_success;
-}
-
-
-int heif_image_has_bayer_pattern(const heif_image* image,
- uint32_t bayer_component_id,
- uint16_t* out_pattern_width,
- uint16_t* out_pattern_height)
-{
- if (image == nullptr || !image->image->has_bayer_pattern(bayer_component_id)) {
- if (out_pattern_width) {
- *out_pattern_width = 0;
- }
- if (out_pattern_height) {
- *out_pattern_height = 0;
- }
- return 0;
- }
-
- const BayerPattern& pattern = image->image->get_bayer_pattern(bayer_component_id);
-
- if (out_pattern_width) {
- *out_pattern_width = pattern.pattern_width;
- }
- if (out_pattern_height) {
- *out_pattern_height = pattern.pattern_height;
- }
-
- return 1;
-}
-
-
-heif_error heif_image_get_bayer_pattern(const heif_image* image,
- uint32_t bayer_component_id,
- struct heif_bayer_pattern_pixel* out_patternPixels)
-{
- if (image == nullptr || out_patternPixels == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (!image->image->has_bayer_pattern(bayer_component_id)) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Image does not have a Bayer pattern."};
- }
-
- const BayerPattern& pattern = image->image->get_bayer_pattern(bayer_component_id);
- size_t num_pixels = size_t{pattern.pattern_width} * pattern.pattern_height;
- std::copy(pattern.pixels.begin(), pattern.pixels.begin() + num_pixels, out_patternPixels);
-
- return heif_error_success;
-}
-
-
-float heif_polarization_angle_no_filter()
-{
- uint32_t bits = 0xFFFFFFFF;
- float f;
- memcpy(&f, &bits, sizeof(f));
- return f;
-}
-
-
-int heif_polarization_angle_is_no_filter(float angle)
-{
- uint32_t bits;
- memcpy(&bits, &angle, sizeof(bits));
- return bits == 0xFFFFFFFF;
-}
-
-
-heif_error heif_image_add_polarization_pattern(heif_image* image,
- uint32_t num_component_ids,
- const uint32_t* component_ids,
- uint16_t pattern_width,
- uint16_t pattern_height,
- const float* polarization_angles)
-{
- if (image == nullptr || polarization_angles == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (num_component_ids > 0 && component_ids == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (pattern_width == 0 || pattern_height == 0) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Polarization pattern dimensions must be non-zero."};
- }
-
- PolarizationPattern pattern;
- pattern.component_ids.assign(component_ids, component_ids + num_component_ids);
- pattern.pattern_width = pattern_width;
- pattern.pattern_height = pattern_height;
-
- size_t num_pixels = size_t{pattern_width} * pattern_height;
- pattern.polarization_angles.assign(polarization_angles, polarization_angles + num_pixels);
-
- image->image->add_polarization_pattern(pattern);
-
- return heif_error_success;
-}
-
-
-int heif_image_get_number_of_polarization_patterns(const heif_image* image)
-{
- if (image == nullptr) {
- return 0;
- }
-
- return static_cast<int>(image->image->get_polarization_patterns().size());
-}
-
-
-heif_error heif_image_get_polarization_pattern_info(const heif_image* image,
- int pattern_index,
- uint32_t* out_num_component_ids,
- uint16_t* out_pattern_width,
- uint16_t* out_pattern_height)
-{
- if (image == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- const auto& patterns = image->image->get_polarization_patterns();
- if (pattern_index < 0 || static_cast<size_t>(pattern_index) >= patterns.size()) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Polarization pattern index out of range."};
- }
-
- const auto& p = patterns[pattern_index];
- if (out_num_component_ids) {
- *out_num_component_ids = static_cast<uint32_t>(p.component_ids.size());
- }
- if (out_pattern_width) {
- *out_pattern_width = p.pattern_width;
- }
- if (out_pattern_height) {
- *out_pattern_height = p.pattern_height;
- }
-
- return heif_error_success;
-}
-
-
-heif_error heif_image_get_polarization_pattern_data(const heif_image* image,
- int pattern_index,
- uint32_t* out_component_ids,
- float* out_polarization_angles)
-{
- if (image == nullptr || out_polarization_angles == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- const auto& patterns = image->image->get_polarization_patterns();
- if (pattern_index < 0 || static_cast<size_t>(pattern_index) >= patterns.size()) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Polarization pattern index out of range."};
- }
-
- const auto& p = patterns[pattern_index];
-
- if (out_component_ids && !p.component_ids.empty()) {
- std::copy(p.component_ids.begin(), p.component_ids.end(), out_component_ids);
- }
-
- size_t num_pixels = size_t{p.pattern_width} * p.pattern_height;
- std::copy(p.polarization_angles.begin(), p.polarization_angles.begin() + num_pixels, out_polarization_angles);
-
- return heif_error_success;
-}
-
-
-int heif_image_get_polarization_pattern_index_for_component(const heif_image* image,
- uint32_t component_id)
-{
- if (image == nullptr) {
- return -1;
- }
-
- const auto& patterns = image->image->get_polarization_patterns();
- for (size_t i = 0; i < patterns.size(); i++) {
- const auto& p = patterns[i];
- if (p.component_ids.empty()) {
- // Empty component list means pattern applies to all components.
- return static_cast<int>(i);
- }
- for (uint32_t idx : p.component_ids) {
- if (idx == component_id) {
- return static_cast<int>(i);
- }
- }
- }
-
- return -1;
-}
-
-
-heif_error heif_image_add_sensor_bad_pixels_map(heif_image* image,
- uint32_t num_component_ids,
- const uint32_t* component_ids,
- int correction_applied,
- uint32_t num_bad_rows,
- const uint32_t* bad_rows,
- uint32_t num_bad_columns,
- const uint32_t* bad_columns,
- uint32_t num_bad_pixels,
- const struct heif_bad_pixel* bad_pixels)
-{
- if (image == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (num_component_ids > 0 && component_ids == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (num_bad_rows > 0 && bad_rows == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (num_bad_columns > 0 && bad_columns == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (num_bad_pixels > 0 && bad_pixels == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- SensorBadPixelsMap map;
- map.component_ids.assign(component_ids, component_ids + num_component_ids);
- map.correction_applied = (correction_applied != 0);
-
- map.bad_rows.assign(bad_rows, bad_rows + num_bad_rows);
- map.bad_columns.assign(bad_columns, bad_columns + num_bad_columns);
-
- map.bad_pixels.resize(num_bad_pixels);
- for (uint32_t i = 0; i < num_bad_pixels; i++) {
- map.bad_pixels[i].row = bad_pixels[i].row;
- map.bad_pixels[i].column = bad_pixels[i].column;
- }
-
- image->image->add_sensor_bad_pixels_map(map);
-
- return heif_error_success;
-}
-
-
-int heif_image_get_number_of_sensor_bad_pixels_maps(const heif_image* image)
-{
- if (image == nullptr) {
- return 0;
- }
-
- return static_cast<int>(image->image->get_sensor_bad_pixels_maps().size());
-}
-
-
-heif_error heif_image_get_sensor_bad_pixels_map_info(const heif_image* image,
- int map_index,
- uint32_t* out_num_component_ids,
- int* out_correction_applied,
- uint32_t* out_num_bad_rows,
- uint32_t* out_num_bad_columns,
- uint32_t* out_num_bad_pixels)
-{
- if (image == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- const auto& maps = image->image->get_sensor_bad_pixels_maps();
- if (map_index < 0 || static_cast<size_t>(map_index) >= maps.size()) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Sensor bad pixels map index out of range."};
- }
-
- const auto& m = maps[map_index];
- if (out_num_component_ids) {
- *out_num_component_ids = static_cast<uint32_t>(m.component_ids.size());
- }
- if (out_correction_applied) {
- *out_correction_applied = m.correction_applied ? 1 : 0;
- }
- if (out_num_bad_rows) {
- *out_num_bad_rows = static_cast<uint32_t>(m.bad_rows.size());
- }
- if (out_num_bad_columns) {
- *out_num_bad_columns = static_cast<uint32_t>(m.bad_columns.size());
- }
- if (out_num_bad_pixels) {
- *out_num_bad_pixels = static_cast<uint32_t>(m.bad_pixels.size());
- }
-
- return heif_error_success;
-}
-
-
-heif_error heif_image_get_sensor_bad_pixels_map_data(const heif_image* image,
- int map_index,
- uint32_t* out_component_ids,
- uint32_t* out_bad_rows,
- uint32_t* out_bad_columns,
- struct heif_bad_pixel* out_bad_pixels)
-{
- if (image == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- const auto& maps = image->image->get_sensor_bad_pixels_maps();
- if (map_index < 0 || static_cast<size_t>(map_index) >= maps.size()) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Sensor bad pixels map index out of range."};
- }
-
- const auto& m = maps[map_index];
-
- if (out_component_ids && !m.component_ids.empty()) {
- std::copy(m.component_ids.begin(), m.component_ids.end(), out_component_ids);
- }
-
- if (out_bad_rows && !m.bad_rows.empty()) {
- std::copy(m.bad_rows.begin(), m.bad_rows.end(), out_bad_rows);
- }
-
- if (out_bad_columns && !m.bad_columns.empty()) {
- std::copy(m.bad_columns.begin(), m.bad_columns.end(), out_bad_columns);
- }
-
- if (out_bad_pixels && !m.bad_pixels.empty()) {
- for (size_t i = 0; i < m.bad_pixels.size(); i++) {
- out_bad_pixels[i].row = m.bad_pixels[i].row;
- out_bad_pixels[i].column = m.bad_pixels[i].column;
- }
- }
-
- return heif_error_success;
-}
-
-
-heif_error heif_image_add_sensor_nuc(heif_image* image,
- uint32_t num_component_ids,
- const uint32_t* component_ids,
- int nuc_is_applied,
- uint32_t image_width,
- uint32_t image_height,
- const float* nuc_gains,
- const float* nuc_offsets)
-{
- if (image == nullptr || nuc_gains == nullptr || nuc_offsets == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (num_component_ids > 0 && component_ids == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (image_width == 0 || image_height == 0) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "NUC image dimensions must be non-zero."};
- }
-
- SensorNonUniformityCorrection nuc;
- nuc.component_ids.assign(component_ids, component_ids + num_component_ids);
- nuc.nuc_is_applied = (nuc_is_applied != 0);
- nuc.image_width = image_width;
- nuc.image_height = image_height;
-
- size_t num_pixels = size_t{image_width} * image_height;
- nuc.nuc_gains.assign(nuc_gains, nuc_gains + num_pixels);
- nuc.nuc_offsets.assign(nuc_offsets, nuc_offsets + num_pixels);
-
- image->image->add_sensor_nuc(nuc);
-
- return heif_error_success;
-}
-
-
-int heif_image_get_number_of_sensor_nucs(const heif_image* image)
-{
- if (image == nullptr) {
- return 0;
- }
-
- return static_cast<int>(image->image->get_sensor_nuc().size());
-}
-
-
-heif_error heif_image_get_sensor_nuc_info(const heif_image* image,
- int nuc_index,
- uint32_t* out_num_component_ids,
- int* out_nuc_is_applied,
- uint32_t* out_image_width,
- uint32_t* out_image_height)
-{
- if (image == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- const auto& nucs = image->image->get_sensor_nuc();
- if (nuc_index < 0 || static_cast<size_t>(nuc_index) >= nucs.size()) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Sensor NUC index out of range."};
- }
-
- const auto& n = nucs[nuc_index];
- if (out_num_component_ids) {
- *out_num_component_ids = static_cast<uint32_t>(n.component_ids.size());
- }
- if (out_nuc_is_applied) {
- *out_nuc_is_applied = n.nuc_is_applied ? 1 : 0;
- }
- if (out_image_width) {
- *out_image_width = n.image_width;
- }
- if (out_image_height) {
- *out_image_height = n.image_height;
- }
-
- return heif_error_success;
-}
-
-
-heif_error heif_image_get_sensor_nuc_data(const heif_image* image,
- int nuc_index,
- uint32_t* out_component_ids,
- float* out_nuc_gains,
- float* out_nuc_offsets)
-{
- if (image == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- const auto& nucs = image->image->get_sensor_nuc();
- if (nuc_index < 0 || static_cast<size_t>(nuc_index) >= nucs.size()) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Sensor NUC index out of range."};
- }
-
- const auto& n = nucs[nuc_index];
-
- if (out_component_ids && !n.component_ids.empty()) {
- std::copy(n.component_ids.begin(), n.component_ids.end(), out_component_ids);
- }
-
- size_t num_pixels = size_t{n.image_width} * n.image_height;
-
- if (out_nuc_gains && !n.nuc_gains.empty()) {
- std::copy(n.nuc_gains.begin(), n.nuc_gains.begin() + num_pixels, out_nuc_gains);
- }
-
- if (out_nuc_offsets && !n.nuc_offsets.empty()) {
- std::copy(n.nuc_offsets.begin(), n.nuc_offsets.begin() + num_pixels, out_nuc_offsets);
- }
-
- return heif_error_success;
-}
-
-
-heif_error heif_image_set_chroma_location(heif_image* image, uint8_t chroma_location)
-{
- if (image == nullptr) {
- return heif_error_null_pointer_argument;
- }
-
- if (chroma_location > 6) {
- return {heif_error_Usage_error,
- heif_suberror_Invalid_parameter_value,
- "Chroma location must be in the range 0-6."};
- }
-
- image->image->set_chroma_location(chroma_location);
-
- return heif_error_success;
-}
-
-
-int heif_image_has_chroma_location(const heif_image* image)
-{
- if (image == nullptr) {
- return 0;
- }
-
- return image->image->has_chroma_location() ? 1 : 0;
-}
-
-
-uint8_t heif_image_get_chroma_location(const heif_image* image)
-{
- if (image == nullptr) {
- return 0;
- }
-
- return image->image->get_chroma_location();
-}
+// ISO/IEC 23001-17 property functions (Bayer / polarization / sensor bad
+// pixels / NUC / chroma sample location) live in heif_properties.cc.
heif_unci_image_parameters* heif_unci_image_parameters_alloc()
diff --git a/libheif/api/libheif/heif_uncompressed.h b/libheif/api/libheif/heif_uncompressed.h
index a3ac8f65..32f93d5b 100644
--- a/libheif/api/libheif/heif_uncompressed.h
+++ b/libheif/api/libheif/heif_uncompressed.h
@@ -23,6 +23,7 @@
#include "libheif/heif_uncompressed_types.h"
#include "libheif/heif_components.h"
+#include "libheif/heif_properties.h"
#include "libheif/heif.h"
#ifdef __cplusplus
@@ -34,227 +35,12 @@ extern "C" {
* Despite its name, this is not limited to uncompressed images.
* It is also possible to add images with lossless compression methods.
* See heif_metadata_compression for more information.
+ *
+ * ISO/IEC 23001-17 metadata properties (Bayer / polarization / sensor bad
+ * pixels / NUC / chroma sample location) live in heif_properties.h, which is
+ * included above for back-compat.
*/
-// heif_uncompressed_component_type and heif_bayer_pattern_pixel are defined in heif_uncompressed_types.h.
-
-// Set a Bayer / filter array pattern on an image.
-// The pattern is a 2D array of component indices with dimensions pattern_width x pattern_height.
-// The number of entries in patternPixels must be pattern_width * pattern_height.
-// The component_index values are indices into the cmpd component definition table.
-// On the encoder path, these indices are generated by heif_image_add_component() and the
-// encoder adds reference components to cmpd for pattern entries that don't have image planes.
-// On the decoder path, they come directly from the cpat box.
-LIBHEIF_API
-heif_error heif_image_set_bayer_pattern(heif_image*,
- uint32_t bayer_component_id,
- uint16_t pattern_width,
- uint16_t pattern_height,
- const heif_bayer_pattern_pixel* patternPixels);
-
-// Add a reference-only component to the image's component description table for use as
-// a Bayer pattern entry. The component is registered (its component_type appears in the
-// cmpd box) but carries no pixel plane of its own — the actual pixel data lives in the
-// single combined Bayer component (added with heif_image_add_component()).
-//
-// Use this for the per-cell colors that the Bayer pattern references (e.g. red, green,
-// blue) when those colors have no standalone plane. Pass the returned component_id in
-// heif_bayer_pattern_pixel::component_id of the patternPixels array given to
-// heif_image_set_bayer_pattern().
-//
-// component_type: one of heif_unci_component_type_* (e.g. _red, _green, _blue).
-// out_component_id: receives the minted component id. Must not be NULL.
-LIBHEIF_API
-heif_error heif_image_add_bayer_component(heif_image*,
- uint16_t component_type,
- uint32_t* out_component_id);
-
-// Returns whether the image has a Bayer / filter array pattern.
-// If the image has a pattern, out_pattern_width and out_pattern_height are set.
-// Either output pointer may be NULL if the caller does not need that value.
-LIBHEIF_API
-int heif_image_get_bayer_pattern_size(const heif_image*,
- uint32_t bayer_component_id,
- uint16_t* out_pattern_width,
- uint16_t* out_pattern_height);
-
-// Get the Bayer / filter array pattern pixels.
-// The caller must provide an array large enough for pattern_width * pattern_height entries
-// (use heif_image_get_bayer_pattern_size() to query the dimensions first).
-// Returns heif_error_Ok on success, or an error if no pattern is set.
-LIBHEIF_API
-heif_error heif_image_get_bayer_pattern(const heif_image*,
- uint32_t bayer_component_id,
- heif_bayer_pattern_pixel* out_patternPixels);
-
-// --- Polarization pattern (ISO 23001-17, Section 6.1.5)
-
-// Special float value indicating "no polarization filter" at a pattern position.
-// On the wire this is the IEEE 754 bit pattern 0xFFFFFFFF (a signaling NaN).
-// Test with heif_polarization_angle_is_no_filter() below, or with isnan()/std::isnan().
-
-// Returns a float with the 0xFFFFFFFF bit pattern (NaN) representing "no polarization filter".
-LIBHEIF_API
-float heif_polarization_angle_no_filter(void);
-
-// Returns non-zero if the given angle has the "no filter" bit pattern (0xFFFFFFFF).
-LIBHEIF_API
-int heif_polarization_angle_is_no_filter(float angle);
-
-// Add a polarization pattern to an image.
-// component_indices: array of component indices this pattern applies to (may be NULL if num_component_indices == 0,
-// meaning the pattern applies to all components).
-// polarization_angles: array of pattern_width * pattern_height float values.
-// Each is an angle in degrees [0.0, 360.0), or heif_polarization_angle_no_filter() for "no filter".
-// Multiple patterns can be added (one per distinct component group).
-LIBHEIF_API
-heif_error heif_image_add_polarization_pattern(heif_image*,
- uint32_t num_component_indices,
- const uint32_t* component_indices,
- uint16_t pattern_width,
- uint16_t pattern_height,
- const float* polarization_angles);
-
-// Returns the number of polarization patterns on this image (0 if none).
-LIBHEIF_API
-int heif_image_get_number_of_polarization_patterns(const heif_image*);
-
-// Get the sizes/dimensions of a polarization pattern (to allocate arrays for the data query).
-LIBHEIF_API
-heif_error heif_image_get_polarization_pattern_info(const heif_image*,
- int pattern_index,
- uint32_t* out_num_component_indices,
- uint16_t* out_pattern_width,
- uint16_t* out_pattern_height);
-
-// Get the actual data of a polarization pattern.
-// Caller must provide pre-allocated arrays:
-// out_component_indices: num_component_indices entries (may be NULL if num_component_indices == 0)
-// out_polarization_angles: pattern_width * pattern_height entries
-LIBHEIF_API
-heif_error heif_image_get_polarization_pattern_data(const heif_image*,
- int pattern_index,
- uint32_t* out_component_indices,
- float* out_polarization_angles);
-
-// Find the polarization pattern index that applies to a given component index.
-// Returns the pattern index (>= 0), or -1 if no pattern matches.
-// A pattern with an empty component list (component_count == 0) matches all components.
-LIBHEIF_API
-int heif_image_get_polarization_pattern_index_for_component(const heif_image*,
- uint32_t component_index);
-
-
-// --- Sensor bad pixels map (ISO 23001-17, Section 6.1.7)
-
-// struct heif_bad_pixel is defined in heif_uncompressed_types.h.
-
-// Add a sensor bad pixels map to an image.
-// component_indices: array of component indices this map applies to (may be NULL if num_component_indices == 0,
-// meaning the map applies to all components).
-// Multiple maps can be added (one per distinct component group with different defects).
-LIBHEIF_API
-heif_error heif_image_add_sensor_bad_pixels_map(heif_image*,
- uint32_t num_component_indices,
- const uint32_t* component_indices,
- int correction_applied,
- uint32_t num_bad_rows,
- const uint32_t* bad_rows,
- uint32_t num_bad_columns,
- const uint32_t* bad_columns,
- uint32_t num_bad_pixels,
- const heif_bad_pixel* bad_pixels);
-
-// Returns the number of sensor bad pixels maps on this image (0 if none).
-LIBHEIF_API
-int heif_image_get_number_of_sensor_bad_pixels_maps(const heif_image*);
-
-// Get the sizes of a sensor bad pixels map (to allocate arrays for the data query).
-LIBHEIF_API
-heif_error heif_image_get_sensor_bad_pixels_map_info(const heif_image*,
- int map_index,
- uint32_t* out_num_component_indices,
- int* out_correction_applied,
- uint32_t* out_num_bad_rows,
- uint32_t* out_num_bad_columns,
- uint32_t* out_num_bad_pixels);
-
-// Get the actual data of a sensor bad pixels map.
-// Caller must provide pre-allocated arrays:
-// out_component_indices: num_component_indices entries (may be NULL if num_component_indices == 0)
-// out_bad_rows: num_bad_rows entries (may be NULL if num_bad_rows == 0)
-// out_bad_columns: num_bad_columns entries (may be NULL if num_bad_columns == 0)
-// out_bad_pixels: num_bad_pixels entries (may be NULL if num_bad_pixels == 0)
-LIBHEIF_API
-heif_error heif_image_get_sensor_bad_pixels_map_data(const heif_image*,
- int map_index,
- uint32_t* out_component_indices,
- uint32_t* out_bad_rows,
- uint32_t* out_bad_columns,
- struct heif_bad_pixel* out_bad_pixels);
-
-
-// --- Sensor non-uniformity correction (ISO 23001-17, Section 6.1.6)
-
-// Add a sensor non-uniformity correction table to an image.
-// component_indices: array of component indices this NUC applies to (may be NULL if num_component_indices == 0,
-// meaning it applies to all components).
-// nuc_gains and nuc_offsets: arrays of image_width * image_height float values.
-// Correction equation: y = nuc_gain * x + nuc_offset.
-// Multiple NUC tables can be added (one per distinct component group).
-LIBHEIF_API
-heif_error heif_image_add_sensor_nuc(heif_image*,
- uint32_t num_component_indices,
- const uint32_t* component_indices,
- int nuc_is_applied,
- uint32_t image_width,
- uint32_t image_height,
- const float* nuc_gains,
- const float* nuc_offsets);
-
-// Returns the number of sensor NUC tables on this image (0 if none).
-LIBHEIF_API
-int heif_image_get_number_of_sensor_nucs(const heif_image*);
-
-// Get the sizes of a sensor NUC table (to allocate arrays for the data query).
-LIBHEIF_API
-heif_error heif_image_get_sensor_nuc_info(const heif_image*,
- int nuc_index,
- uint32_t* out_num_component_indices,
- int* out_nuc_is_applied,
- uint32_t* out_image_width,
- uint32_t* out_image_height);
-
-// Get the actual data of a sensor NUC table.
-// Caller must provide pre-allocated arrays:
-// out_component_indices: num_component_indices entries (may be NULL if num_component_indices == 0)
-// out_nuc_gains: image_width * image_height entries
-// out_nuc_offsets: image_width * image_height entries
-LIBHEIF_API
-heif_error heif_image_get_sensor_nuc_data(const heif_image*,
- int nuc_index,
- uint32_t* out_component_indices,
- float* out_nuc_gains,
- float* out_nuc_offsets);
-
-
-// heif_chroma420_sample_location is defined in heif_uncompressed_types.h.
-
-// --- Chroma sample location (ISO 23001-17, Section 6.1.4)
-
-// Set the chroma sample location on an image.
-// chroma_location must be in the range 0-6 (see heif_chroma420_sample_location).
-LIBHEIF_API
-heif_error heif_image_set_chroma_location(heif_image*, uint8_t chroma_location);
-
-// Returns non-zero if the image has a chroma sample location set.
-LIBHEIF_API
-int heif_image_has_chroma_location(const heif_image*);
-
-// Returns the chroma sample location (0-6), or 0 if none is set.
-LIBHEIF_API
-uint8_t heif_image_get_chroma_location(const heif_image*);
-
// --- 'unci' images
diff --git a/libheif/api/libheif/heif_uncompressed_types.h b/libheif/api/libheif/heif_uncompressed_types.h
index 8de23297..23f0295f 100644
--- a/libheif/api/libheif/heif_uncompressed_types.h
+++ b/libheif/api/libheif/heif_uncompressed_types.h
@@ -31,56 +31,26 @@ extern "C" {
// --- ISO 23001-17 component types (Table 1)
-typedef enum heif_unci_component_type
+typedef enum heif_cmpd_component_type
{
- heif_unci_component_type_monochrome = 0,
- heif_unci_component_type_Y = 1,
- heif_unci_component_type_Cb = 2,
- heif_unci_component_type_Cr = 3,
- heif_unci_component_type_red = 4,
- heif_unci_component_type_green = 5,
- heif_unci_component_type_blue = 6,
- heif_unci_component_type_alpha = 7,
- heif_unci_component_type_depth = 8,
- heif_unci_component_type_disparity = 9,
- heif_unci_component_type_palette = 10,
- heif_unci_component_type_filter_array = 11,
- heif_unci_component_type_padded = 12,
- heif_unci_component_type_cyan = 13,
- heif_unci_component_type_magenta = 14,
- heif_unci_component_type_yellow = 15,
- heif_unci_component_type_key_black = 16
-} heif_unci_component_type;
-
-
-// --- Bayer / filter array pattern
-
-typedef struct heif_bayer_pattern_pixel
-{
- uint32_t component_id;
- float component_gain;
-} heif_bayer_pattern_pixel;
-
-
-// --- Sensor bad pixels map (ISO 23001-17, Section 6.1.7)
-
-struct heif_bad_pixel { uint32_t row; uint32_t column; };
-
-
-// --- Chroma sample location (ISO 23091-2 / ITU-T H.273 + ISO 23001-17)
-
-typedef enum heif_chroma420_sample_location {
- // values 0-5 according to ISO 23091-2 / ITU-T H.273
- heif_chroma420_sample_location_00_05 = 0,
- heif_chroma420_sample_location_05_05 = 1,
- heif_chroma420_sample_location_00_00 = 2,
- heif_chroma420_sample_location_05_00 = 3,
- heif_chroma420_sample_location_00_10 = 4,
- heif_chroma420_sample_location_05_10 = 5,
-
- // value 6 according to ISO 23001-17
- heif_chroma420_sample_location_00_00_01_00 = 6
-} heif_chroma420_sample_location;
+ heif_cmpd_component_type_monochrome = 0,
+ heif_cmpd_component_type_Y = 1,
+ heif_cmpd_component_type_Cb = 2,
+ heif_cmpd_component_type_Cr = 3,
+ heif_cmpd_component_type_red = 4,
+ heif_cmpd_component_type_green = 5,
+ heif_cmpd_component_type_blue = 6,
+ heif_cmpd_component_type_alpha = 7,
+ heif_cmpd_component_type_depth = 8,
+ heif_cmpd_component_type_disparity = 9,
+ heif_cmpd_component_type_palette = 10,
+ heif_cmpd_component_type_filter_array = 11,
+ heif_cmpd_component_type_padded = 12,
+ heif_cmpd_component_type_cyan = 13,
+ heif_cmpd_component_type_magenta = 14,
+ heif_cmpd_component_type_yellow = 15,
+ heif_cmpd_component_type_key_black = 16
+} heif_cmpd_component_type;
// Compression methods for 'unci' (ISO 23001-17) images.
@@ -117,10 +87,6 @@ typedef struct heif_unci_image_parameters
} heif_unci_image_parameters;
-// heif_component_datatype, heif_complex32, heif_complex64 are defined in
-// heif_components.h (included above).
-
-
#ifdef __cplusplus
}
#endif
diff --git a/libheif/codecs/uncompressed/unc_boxes.cc b/libheif/codecs/uncompressed/unc_boxes.cc
index 77343cbf..7b69f089 100644
--- a/libheif/codecs/uncompressed/unc_boxes.cc
+++ b/libheif/codecs/uncompressed/unc_boxes.cc
@@ -96,27 +96,27 @@ bool is_predefined_component_type(uint16_t type)
{
// check whether the component type can be mapped to heif_uncompressed_component_type and we have a name defined for
// it in sNames_uncompressed_component_type.
- return type <= heif_unci_component_type_max_valid;
+ return type <= heif_cmpd_component_type_max_valid;
}
-static std::map<heif_unci_component_type, const char*> sNames_uncompressed_component_type{
- {heif_unci_component_type_monochrome, "monochrome"},
- {heif_unci_component_type_Y, "Y"},
- {heif_unci_component_type_Cb, "Cb"},
- {heif_unci_component_type_Cr, "Cr"},
- {heif_unci_component_type_red, "red"},
- {heif_unci_component_type_green, "green"},
- {heif_unci_component_type_blue, "blue"},
- {heif_unci_component_type_alpha, "alpha"},
- {heif_unci_component_type_depth, "depth"},
- {heif_unci_component_type_disparity, "disparity"},
- {heif_unci_component_type_palette, "palette"},
- {heif_unci_component_type_filter_array, "filter-array"},
- {heif_unci_component_type_padded, "padded"},
- {heif_unci_component_type_cyan, "cyan"},
- {heif_unci_component_type_magenta, "magenta"},
- {heif_unci_component_type_yellow, "yellow"},
- {heif_unci_component_type_key_black, "key (black)"}
+static std::map<heif_cmpd_component_type, const char*> sNames_uncompressed_component_type{
+ {heif_cmpd_component_type_monochrome, "monochrome"},
+ {heif_cmpd_component_type_Y, "Y"},
+ {heif_cmpd_component_type_Cb, "Cb"},
+ {heif_cmpd_component_type_Cr, "Cr"},
+ {heif_cmpd_component_type_red, "red"},
+ {heif_cmpd_component_type_green, "green"},
+ {heif_cmpd_component_type_blue, "blue"},
+ {heif_cmpd_component_type_alpha, "alpha"},
+ {heif_cmpd_component_type_depth, "depth"},
+ {heif_cmpd_component_type_disparity, "disparity"},
+ {heif_cmpd_component_type_palette, "palette"},
+ {heif_cmpd_component_type_filter_array, "filter-array"},
+ {heif_cmpd_component_type_padded, "padded"},
+ {heif_cmpd_component_type_cyan, "cyan"},
+ {heif_cmpd_component_type_magenta, "magenta"},
+ {heif_cmpd_component_type_yellow, "yellow"},
+ {heif_cmpd_component_type_key_black, "key (black)"}
};
template <typename T> const char* get_name(T val, const std::map<T, const char*>& table)
@@ -186,7 +186,7 @@ std::string Box_cmpd::Component::get_component_type_name(uint16_t component_type
std::stringstream sstr;
if (is_predefined_component_type(component_type)) {
- sstr << get_name(heif_unci_component_type(component_type), sNames_uncompressed_component_type) << "\n";
+ sstr << get_name(heif_cmpd_component_type(component_type), sNames_uncompressed_component_type) << "\n";
}
else {
sstr << "0x" << std::hex << component_type << std::dec << "\n";
@@ -196,7 +196,7 @@ std::string Box_cmpd::Component::get_component_type_name(uint16_t component_type
}
-bool Box_cmpd::has_component(heif_unci_component_type type) const
+bool Box_cmpd::has_component(heif_cmpd_component_type type) const
{
return std::any_of(m_components.begin(), m_components.end(),
[type](const auto& cmp) { return cmp.component_type == type; });
@@ -457,9 +457,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_red});
- cmpd->add_component({heif_unci_component_type_green});
- cmpd->add_component({heif_unci_component_type_blue});
+ cmpd->add_component({heif_cmpd_component_type_red});
+ cmpd->add_component({heif_cmpd_component_type_green});
+ cmpd->add_component({heif_cmpd_component_type_blue});
uncC->set_sampling_type(sampling_mode_no_subsampling);
uncC->set_interleave_type(interleave_mode_pixel);
}
@@ -469,10 +469,10 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
uncC->add_component({3, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_red});
- cmpd->add_component({heif_unci_component_type_green});
- cmpd->add_component({heif_unci_component_type_blue});
- cmpd->add_component({heif_unci_component_type_alpha});
+ cmpd->add_component({heif_cmpd_component_type_red});
+ cmpd->add_component({heif_cmpd_component_type_green});
+ cmpd->add_component({heif_cmpd_component_type_blue});
+ cmpd->add_component({heif_cmpd_component_type_alpha});
uncC->set_sampling_type(sampling_mode_no_subsampling);
uncC->set_interleave_type(interleave_mode_pixel);
}
@@ -482,10 +482,10 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
uncC->add_component({3, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_alpha});
- cmpd->add_component({heif_unci_component_type_blue});
- cmpd->add_component({heif_unci_component_type_green});
- cmpd->add_component({heif_unci_component_type_red});
+ cmpd->add_component({heif_cmpd_component_type_alpha});
+ cmpd->add_component({heif_cmpd_component_type_blue});
+ cmpd->add_component({heif_cmpd_component_type_green});
+ cmpd->add_component({heif_cmpd_component_type_red});
uncC->set_sampling_type(sampling_mode_no_subsampling);
uncC->set_interleave_type(interleave_mode_pixel);
}
@@ -496,9 +496,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
uncC->set_sampling_type(sampling_mode_422);
uncC->set_interleave_type(interleave_mode_multi_y);
}
@@ -509,9 +509,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
uncC->set_sampling_type(sampling_mode_422);
uncC->set_interleave_type(interleave_mode_multi_y);
}
@@ -522,9 +522,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cr});
- cmpd->add_component({heif_unci_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
uncC->set_sampling_type(sampling_mode_422);
uncC->set_interleave_type(interleave_mode_multi_y);
}
@@ -535,9 +535,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Cr});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
uncC->set_sampling_type(sampling_mode_422);
uncC->set_interleave_type(interleave_mode_multi_y);
}
@@ -550,9 +550,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
uncC->set_sampling_type(sampling_mode_411);
uncC->set_interleave_type(interleave_mode_multi_y);
}
@@ -562,9 +562,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Cr});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
uncC->set_sampling_type(sampling_mode_no_subsampling);
uncC->set_interleave_type(interleave_mode_pixel);
}
@@ -575,10 +575,10 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
uncC->add_component({3, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cr});
- cmpd->add_component({heif_unci_component_type_alpha});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_alpha});
uncC->set_sampling_type(sampling_mode_no_subsampling);
uncC->set_interleave_type(interleave_mode_pixel);
}
@@ -590,9 +590,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({1, 10, component_format_unsigned, 0});
uncC->add_component({0, 10, component_format_unsigned, 0});
uncC->add_component({2, 10, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
uncC->set_sampling_type(sampling_mode_422);
uncC->set_interleave_type(interleave_mode_multi_y);
uncC->set_block_size(2);
@@ -606,9 +606,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 10, component_format_unsigned, 0});
uncC->add_component({1, 10, component_format_unsigned, 0});
uncC->add_component({2, 10, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
uncC->set_sampling_type(sampling_mode_no_subsampling);
uncC->set_interleave_type(interleave_mode_pixel);
uncC->set_block_size(4);
@@ -624,9 +624,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({1, 10, component_format_unsigned, 0});
uncC->add_component({2, 10, component_format_unsigned, 0});
uncC->add_component({1, 10, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
uncC->set_sampling_type(sampling_mode_422);
uncC->set_interleave_type(interleave_mode_multi_y);
uncC->set_block_size(4);
@@ -639,9 +639,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
uncC->set_sampling_type(sampling_mode_420);
uncC->set_interleave_type(interleave_mode_component);
}
@@ -651,9 +651,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
uncC->set_sampling_type(sampling_mode_420);
uncC->set_interleave_type(interleave_mode_mixed);
}
@@ -663,9 +663,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cr});
- cmpd->add_component({heif_unci_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
uncC->set_sampling_type(sampling_mode_420);
uncC->set_interleave_type(interleave_mode_mixed);
}
@@ -675,9 +675,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cb});
- cmpd->add_component({heif_unci_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
uncC->set_sampling_type(sampling_mode_422);
uncC->set_interleave_type(interleave_mode_component);
}
@@ -687,9 +687,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cr});
- cmpd->add_component({heif_unci_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
uncC->set_sampling_type(sampling_mode_422);
uncC->set_interleave_type(interleave_mode_component);
}
@@ -699,9 +699,9 @@ void fill_uncC_and_cmpd_from_profile(const std::shared_ptr<Box_uncC>& uncC,
uncC->add_component({0, 8, component_format_unsigned, 0});
uncC->add_component({1, 8, component_format_unsigned, 0});
uncC->add_component({2, 8, component_format_unsigned, 0});
- cmpd->add_component({heif_unci_component_type_Y});
- cmpd->add_component({heif_unci_component_type_Cr});
- cmpd->add_component({heif_unci_component_type_Cb});
+ cmpd->add_component({heif_cmpd_component_type_Y});
+ cmpd->add_component({heif_cmpd_component_type_Cr});
+ cmpd->add_component({heif_cmpd_component_type_Cb});
uncC->set_sampling_type(sampling_mode_420);
uncC->set_interleave_type(interleave_mode_component);
}
diff --git a/libheif/codecs/uncompressed/unc_boxes.h b/libheif/codecs/uncompressed/unc_boxes.h
index 35f84741..ed99d6bf 100644
--- a/libheif/codecs/uncompressed/unc_boxes.h
+++ b/libheif/codecs/uncompressed/unc_boxes.h
@@ -64,7 +64,7 @@ public:
const std::vector<Component>& get_components() const { return m_components; }
- bool has_component(heif_unci_component_type) const;
+ bool has_component(heif_cmpd_component_type) const;
uint16_t add_component(const Component& component)
{
diff --git a/libheif/codecs/uncompressed/unc_codec.cc b/libheif/codecs/uncompressed/unc_codec.cc
index 57891a1c..de4200c3 100644
--- a/libheif/codecs/uncompressed/unc_codec.cc
+++ b/libheif/codecs/uncompressed/unc_codec.cc
@@ -88,27 +88,27 @@ Error UncompressedImageCodec::get_heif_chroma_uncompressed(const std::shared_ptr
uint32_t component_index = component.component_index;
uint16_t component_type = cmpd->get_components()[component_index].component_type;
- if (component_type > heif_unci_component_type_max_valid) {
+ if (component_type > heif_cmpd_component_type_max_valid) {
std::stringstream sstr;
- sstr << "a component_type > " << heif_unci_component_type_max_valid << " is not supported";
+ sstr << "a component_type > " << heif_cmpd_component_type_max_valid << " is not supported";
return {heif_error_Unsupported_feature, heif_suberror_Invalid_parameter_value, sstr.str()};
}
- if (component_type == heif_unci_component_type_padded) {
+ if (component_type == heif_cmpd_component_type_padded) {
// not relevant for determining chroma
continue;
}
componentSet |= (1 << component_type);
}
- *out_has_alpha = (componentSet & (1 << heif_unci_component_type_alpha)) != 0;
+ *out_has_alpha = (componentSet & (1 << heif_cmpd_component_type_alpha)) != 0;
- if (componentSet == ((1 << heif_unci_component_type_red) | (1 << heif_unci_component_type_green) | (1 << heif_unci_component_type_blue)) ||
- componentSet == ((1 << heif_unci_component_type_red) | (1 << heif_unci_component_type_green) | (1 << heif_unci_component_type_blue) | (1 << heif_unci_component_type_alpha))) {
+ if (componentSet == ((1 << heif_cmpd_component_type_red) | (1 << heif_cmpd_component_type_green) | (1 << heif_cmpd_component_type_blue)) ||
+ componentSet == ((1 << heif_cmpd_component_type_red) | (1 << heif_cmpd_component_type_green) | (1 << heif_cmpd_component_type_blue) | (1 << heif_cmpd_component_type_alpha))) {
*out_chroma = heif_chroma_444;
*out_colourspace = heif_colorspace_RGB;
}
- if (componentSet == ((1 << heif_unci_component_type_Y) | (1 << heif_unci_component_type_Cb) | (1 << heif_unci_component_type_Cr))) {
+ if (componentSet == ((1 << heif_cmpd_component_type_Y) | (1 << heif_cmpd_component_type_Cb) | (1 << heif_cmpd_component_type_Cr))) {
switch (uncC->get_sampling_type()) {
case sampling_mode_no_subsampling:
*out_chroma = heif_chroma_444;
@@ -123,14 +123,14 @@ Error UncompressedImageCodec::get_heif_chroma_uncompressed(const std::shared_ptr
*out_colourspace = heif_colorspace_YCbCr;
}
- if (componentSet == (1 << heif_unci_component_type_monochrome) || componentSet == ((1 << heif_unci_component_type_monochrome) | (1 << heif_unci_component_type_alpha)) ||
- componentSet == (1 << heif_unci_component_type_Y) || componentSet == ((1 << heif_unci_component_type_Y) | (1 << heif_unci_component_type_alpha))) {
+ if (componentSet == (1 << heif_cmpd_component_type_monochrome) || componentSet == ((1 << heif_cmpd_component_type_monochrome) | (1 << heif_cmpd_component_type_alpha)) ||
+ componentSet == (1 << heif_cmpd_component_type_Y) || componentSet == ((1 << heif_cmpd_component_type_Y) | (1 << heif_cmpd_component_type_alpha))) {
// mono or mono + alpha input, mono output.
*out_chroma = heif_chroma_monochrome;
*out_colourspace = heif_colorspace_monochrome;
}
- if (componentSet == (1 << heif_unci_component_type_filter_array)) {
+ if (componentSet == (1 << heif_cmpd_component_type_filter_array)) {
// TODO - we should look up the components
*out_chroma = heif_chroma_planar;
*out_colourspace = heif_colorspace_filter_array;
@@ -257,8 +257,8 @@ Result<std::shared_ptr<HeifPixelImage>> UncompressedImageCodec::create_image(con
auto component_type = components[component.component_index].component_type;
uint32_t plane_w = width;
uint32_t plane_h = height;
- if (component_type == heif_unci_component_type_Cb ||
- component_type == heif_unci_component_type_Cr) {
+ if (component_type == heif_cmpd_component_type_Cb ||
+ component_type == heif_cmpd_component_type_Cr) {
plane_w = width / chroma_h_subsampling(chroma);
plane_h = height / chroma_v_subsampling(chroma);
}
@@ -464,7 +464,7 @@ Error UncompressedImageCodec::check_header_validity(std::optional<const std::sha
}
uint16_t component_type = cmpd->get_components()[comp.component_index].component_type;
- if (component_type > 7 && component_type != heif_unci_component_type_padded && component_type != heif_unci_component_type_filter_array) {
+ if (component_type > 7 && component_type != heif_cmpd_component_type_padded && component_type != heif_cmpd_component_type_filter_array) {
std::stringstream sstr;
sstr << "Uncompressed image with component_type " << ((int) component_type) << " is not implemented yet";
return {heif_error_Unsupported_feature,
diff --git a/libheif/codecs/uncompressed/unc_dec.cc b/libheif/codecs/uncompressed/unc_dec.cc
index 23a60e15..38421a44 100644
--- a/libheif/codecs/uncompressed/unc_dec.cc
+++ b/libheif/codecs/uncompressed/unc_dec.cc
@@ -65,14 +65,14 @@ int Decoder_uncompressed::get_luma_bits_per_pixel() const
}
auto component_type = m_cmpd->get_components()[component_index].component_type;
switch (component_type) {
- case heif_unci_component_type_monochrome:
- case heif_unci_component_type_red:
- case heif_unci_component_type_green:
- case heif_unci_component_type_blue:
- case heif_unci_component_type_filter_array:
+ case heif_cmpd_component_type_monochrome:
+ case heif_cmpd_component_type_red:
+ case heif_cmpd_component_type_green:
+ case heif_cmpd_component_type_blue:
+ case heif_cmpd_component_type_filter_array:
alternate_channel_bits = std::max(alternate_channel_bits, (int) component.component_bit_depth);
break;
- case heif_unci_component_type_Y:
+ case heif_cmpd_component_type_Y:
luma_bits = std::max(luma_bits, (int) component.component_bit_depth);
break;
// TODO: there are other things we'll need to handle eventually, like palette.
@@ -109,15 +109,15 @@ int Decoder_uncompressed::get_chroma_bits_per_pixel() const
}
auto component_type = m_cmpd->get_components()[component_index].component_type;
switch (component_type) {
- case heif_unci_component_type_monochrome:
- case heif_unci_component_type_red:
- case heif_unci_component_type_green:
- case heif_unci_component_type_blue:
- case heif_unci_component_type_filter_array:
+ case heif_cmpd_component_type_monochrome:
+ case heif_cmpd_component_type_red:
+ case heif_cmpd_component_type_green:
+ case heif_cmpd_component_type_blue:
+ case heif_cmpd_component_type_filter_array:
alternate_channel_bits = std::max(alternate_channel_bits, (int) component.component_bit_depth);
break;
- case heif_unci_component_type_Cb:
- case heif_unci_component_type_Cr:
+ case heif_cmpd_component_type_Cb:
+ case heif_cmpd_component_type_Cr:
chroma_bits = std::max(chroma_bits, (int) component.component_bit_depth);
break;
// TODO: there are other things we'll need to handle eventually, like palette.
diff --git a/libheif/codecs/uncompressed/unc_encoder.cc b/libheif/codecs/uncompressed/unc_encoder.cc
index 2cf50a81..8d33763a 100644
--- a/libheif/codecs/uncompressed/unc_encoder.cc
+++ b/libheif/codecs/uncompressed/unc_encoder.cc
@@ -37,25 +37,25 @@
#include <algorithm>
-heif_unci_component_type heif_channel_to_component_type(heif_channel channel)
+heif_cmpd_component_type heif_channel_to_component_type(heif_channel channel)
{
switch (channel) {
- case heif_channel_Y: return heif_unci_component_type_Y;
- case heif_channel_Cb: return heif_unci_component_type_Cb;
- case heif_channel_Cr: return heif_unci_component_type_Cr;
- case heif_channel_R: return heif_unci_component_type_red;
- case heif_channel_G: return heif_unci_component_type_green;
- case heif_channel_B: return heif_unci_component_type_blue;
- case heif_channel_Alpha: return heif_unci_component_type_alpha;
+ case heif_channel_Y: return heif_cmpd_component_type_Y;
+ case heif_channel_Cb: return heif_cmpd_component_type_Cb;
+ case heif_channel_Cr: return heif_cmpd_component_type_Cr;
+ case heif_channel_R: return heif_cmpd_component_type_red;
+ case heif_channel_G: return heif_cmpd_component_type_green;
+ case heif_channel_B: return heif_cmpd_component_type_blue;
+ case heif_channel_Alpha: return heif_cmpd_component_type_alpha;
case heif_channel_interleaved: assert(false);
break;
- case heif_channel_filter_array: return heif_unci_component_type_filter_array;
- case heif_channel_depth: return heif_unci_component_type_depth;
- case heif_channel_disparity: return heif_unci_component_type_disparity;
- case heif_channel_unknown: return heif_unci_component_type_padded;
+ case heif_channel_filter_array: return heif_cmpd_component_type_filter_array;
+ case heif_channel_depth: return heif_cmpd_component_type_depth;
+ case heif_channel_disparity: return heif_cmpd_component_type_disparity;
+ case heif_channel_unknown: return heif_cmpd_component_type_padded;
}
- return heif_unci_component_type_padded;
+ return heif_cmpd_component_type_padded;
}
diff --git a/libheif/codecs/uncompressed/unc_encoder.h b/libheif/codecs/uncompressed/unc_encoder.h
index c613926f..3ef245f7 100644
--- a/libheif/codecs/uncompressed/unc_encoder.h
+++ b/libheif/codecs/uncompressed/unc_encoder.h
@@ -39,7 +39,7 @@ class Box_snuc;
class Box_cloc;
class HeifPixelImage;
-heif_unci_component_type heif_channel_to_component_type(heif_channel channel);
+heif_cmpd_component_type heif_channel_to_component_type(heif_channel channel);
heif_uncompressed_component_format to_unc_component_format(heif_component_datatype channel_datatype);
diff --git a/libheif/codecs/uncompressed/unc_encoder_component_interleave.cc b/libheif/codecs/uncompressed/unc_encoder_component_interleave.cc
index d055ca15..4c88d71d 100644
--- a/libheif/codecs/uncompressed/unc_encoder_component_interleave.cc
+++ b/libheif/codecs/uncompressed/unc_encoder_component_interleave.cc
@@ -97,16 +97,16 @@ unc_encoder_component_interleave::unc_encoder_component_interleave(const std::sh
auto componentIds = image->get_used_planar_component_ids();
for (uint32_t id : componentIds) {
- heif_unci_component_type comp_type;
+ heif_cmpd_component_type comp_type;
heif_channel ch = heif_channel_Y; // default for nonvisual
if (is_custom) {
- comp_type = static_cast<heif_unci_component_type>(image->get_component_type(id));
+ comp_type = static_cast<heif_cmpd_component_type>(image->get_component_type(id));
}
else {
ch = image->get_component_channel(id);
if (ch == heif_channel_Y && !image->has_channel(heif_channel_Cb)) {
- comp_type = heif_unci_component_type_monochrome;
+ comp_type = heif_cmpd_component_type_monochrome;
}
else {
comp_type = heif_channel_to_component_type(ch);
diff --git a/libheif/codecs/uncompressed/unc_encoder_component_interleave.h b/libheif/codecs/uncompressed/unc_encoder_component_interleave.h
index 481a2945..e7d7aa3c 100644
--- a/libheif/codecs/uncompressed/unc_encoder_component_interleave.h
+++ b/libheif/codecs/uncompressed/unc_encoder_component_interleave.h
@@ -42,7 +42,7 @@ private:
{
uint32_t component_id;
heif_channel channel;
- heif_unci_component_type component_type;
+ heif_cmpd_component_type component_type;
heif_uncompressed_component_format component_format;
uint16_t bpp;
bool byte_aligned;
diff --git a/libheif/codecs/uncompressed/unc_types.h b/libheif/codecs/uncompressed/unc_types.h
index f5de9fef..60f30aa5 100644
--- a/libheif/codecs/uncompressed/unc_types.h
+++ b/libheif/codecs/uncompressed/unc_types.h
@@ -26,7 +26,7 @@
#include <libheif/heif_uncompressed.h>
// Update this when adding new values to heif_uncompressed_component_type.
-#define heif_unci_component_type_max_valid heif_unci_component_type_key_black
+#define heif_cmpd_component_type_max_valid heif_cmpd_component_type_key_black
/**
* HEIF uncompressed component format.
diff --git a/libheif/color-conversion/bayer_bilinear.cc b/libheif/color-conversion/bayer_bilinear.cc
index db4f79c0..4ce307c1 100644
--- a/libheif/color-conversion/bayer_bilinear.cc
+++ b/libheif/color-conversion/bayer_bilinear.cc
@@ -65,11 +65,11 @@ Op_bayer_bilinear_to_RGB24_32::state_after_conversion(const ColorState& input_st
static int component_type_to_rgb_index(uint16_t component_type)
{
switch (component_type) {
- case heif_unci_component_type_red:
+ case heif_cmpd_component_type_red:
return 0;
- case heif_unci_component_type_green:
+ case heif_cmpd_component_type_green:
return 1;
- case heif_unci_component_type_blue:
+ case heif_cmpd_component_type_blue:
return 2;
default:
return -1;
diff --git a/libheif/image-items/image_item.cc b/libheif/image-items/image_item.cc
index c8aa47fd..fe6a3fea 100644
--- a/libheif/image-items/image_item.cc
+++ b/libheif/image-items/image_item.cc
@@ -577,7 +577,7 @@ void ImageItem::set_alpha_channel(std::shared_ptr<ImageItem> img)
ComponentDescription desc;
desc.component_id = mint_component_id();
desc.channel = heif_channel_Alpha;
- desc.component_type = heif_unci_component_type_alpha;
+ desc.component_type = heif_cmpd_component_type_alpha;
desc.datatype = heif_component_datatype_unsigned_integer;
desc.bit_depth = static_cast<uint16_t>(alpha_bpp);
desc.width = get_ispe_width();
@@ -632,22 +632,22 @@ void ImageItem::populate_component_descriptions()
switch (colorspace) {
case heif_colorspace_monochrome:
- emit(heif_channel_Y, heif_unci_component_type_monochrome, luma_bpp, img_w, img_h);
+ emit(heif_channel_Y, heif_cmpd_component_type_monochrome, luma_bpp, img_w, img_h);
break;
case heif_colorspace_YCbCr: {
uint32_t cw = channel_width(img_w, chroma, heif_channel_Cb);
uint32_t ch_ = channel_height(img_h, chroma, heif_channel_Cb);
- emit(heif_channel_Y, heif_unci_component_type_Y, luma_bpp, img_w, img_h);
- emit(heif_channel_Cb, heif_unci_component_type_Cb, chroma_bpp, cw, ch_);
- emit(heif_channel_Cr, heif_unci_component_type_Cr, chroma_bpp, cw, ch_);
+ emit(heif_channel_Y, heif_cmpd_component_type_Y, luma_bpp, img_w, img_h);
+ emit(heif_channel_Cb, heif_cmpd_component_type_Cb, chroma_bpp, cw, ch_);
+ emit(heif_channel_Cr, heif_cmpd_component_type_Cr, chroma_bpp, cw, ch_);
break;
}
case heif_colorspace_RGB:
- emit(heif_channel_R, heif_unci_component_type_red, luma_bpp, img_w, img_h);
- emit(heif_channel_G, heif_unci_component_type_green, luma_bpp, img_w, img_h);
- emit(heif_channel_B, heif_unci_component_type_blue, luma_bpp, img_w, img_h);
+ emit(heif_channel_R, heif_cmpd_component_type_red, luma_bpp, img_w, img_h);
+ emit(heif_channel_G, heif_cmpd_component_type_green, luma_bpp, img_w, img_h);
+ emit(heif_channel_B, heif_cmpd_component_type_blue, luma_bpp, img_w, img_h);
break;
default:
diff --git a/libheif/image-items/overlay.cc b/libheif/image-items/overlay.cc
index 3e01075c..4fe25786 100644
--- a/libheif/image-items/overlay.cc
+++ b/libheif/image-items/overlay.cc
@@ -456,9 +456,9 @@ void ImageItem_Overlay::populate_component_descriptions()
add_component_description(std::move(d));
};
- emit(heif_channel_R, heif_unci_component_type_red);
- emit(heif_channel_G, heif_unci_component_type_green);
- emit(heif_channel_B, heif_unci_component_type_blue);
+ emit(heif_channel_R, heif_cmpd_component_type_red);
+ emit(heif_channel_G, heif_cmpd_component_type_green);
+ emit(heif_channel_B, heif_cmpd_component_type_blue);
}
diff --git a/libheif/image/image_description.cc b/libheif/image/image_description.cc
index f87c8c1c..d2beae21 100644
--- a/libheif/image/image_description.cc
+++ b/libheif/image/image_description.cc
@@ -33,29 +33,29 @@
heif_channel map_uncompressed_component_to_channel(uint16_t component_type)
{
switch (component_type) {
- case heif_unci_component_type_monochrome:
- case heif_unci_component_type_Y:
+ case heif_cmpd_component_type_monochrome:
+ case heif_cmpd_component_type_Y:
return heif_channel_Y;
- case heif_unci_component_type_Cb:
+ case heif_cmpd_component_type_Cb:
return heif_channel_Cb;
- case heif_unci_component_type_Cr:
+ case heif_cmpd_component_type_Cr:
return heif_channel_Cr;
- case heif_unci_component_type_red:
+ case heif_cmpd_component_type_red:
return heif_channel_R;
- case heif_unci_component_type_green:
+ case heif_cmpd_component_type_green:
return heif_channel_G;
- case heif_unci_component_type_blue:
+ case heif_cmpd_component_type_blue:
return heif_channel_B;
- case heif_unci_component_type_alpha:
+ case heif_cmpd_component_type_alpha:
return heif_channel_Alpha;
- case heif_unci_component_type_filter_array:
+ case heif_cmpd_component_type_filter_array:
return heif_channel_filter_array;
- case heif_unci_component_type_depth:
+ case heif_cmpd_component_type_depth:
return heif_channel_depth;
- case heif_unci_component_type_disparity:
+ case heif_cmpd_component_type_disparity:
return heif_channel_disparity;
- case heif_unci_component_type_padded:
+ case heif_cmpd_component_type_padded:
default:
return heif_channel_unknown;
}
diff --git a/libheif/image/image_description.h b/libheif/image/image_description.h
index 6d2f3b3b..7f29afd0 100644
--- a/libheif/image/image_description.h
+++ b/libheif/image/image_description.h
@@ -133,7 +133,7 @@ struct ComponentDescription
uint32_t component_id = 0; // stable id, matches HeifPixelImage::m_storage ids
heif_channel channel = heif_channel_unknown;
- uint16_t component_type = 0; // heif_unci_component_type_*
+ uint16_t component_type = 0; // heif_cmpd_component_type_*
// The numeric values of heif_component_datatype are aligned with the
// ISO 23001-17 Table 2 component_format byte (from the uncC box), so on
diff --git a/libheif/image/pixelimage.cc b/libheif/image/pixelimage.cc
index 6d220f8b..a824182c 100644
--- a/libheif/image/pixelimage.cc
+++ b/libheif/image/pixelimage.cc
@@ -99,43 +99,43 @@ static std::vector<uint16_t> map_channel_to_component_type(heif_channel channel,
{
switch (channel) {
case heif_channel_Y:
- return {heif_unci_component_type_Y};
+ return {heif_cmpd_component_type_Y};
case heif_channel_Cb:
- return {heif_unci_component_type_Cb};
+ return {heif_cmpd_component_type_Cb};
case heif_channel_Cr:
- return {heif_unci_component_type_Cr};
+ return {heif_cmpd_component_type_Cr};
case heif_channel_R:
- return {heif_unci_component_type_red};
+ return {heif_cmpd_component_type_red};
case heif_channel_G:
- return {heif_unci_component_type_green};
+ return {heif_cmpd_component_type_green};
case heif_channel_B:
- return {heif_unci_component_type_blue};
+ return {heif_cmpd_component_type_blue};
case heif_channel_Alpha:
- return {heif_unci_component_type_alpha};
+ return {heif_cmpd_component_type_alpha};
case heif_channel_filter_array:
- return {heif_unci_component_type_filter_array};
+ return {heif_cmpd_component_type_filter_array};
case heif_channel_depth:
- return {heif_unci_component_type_depth};
+ return {heif_cmpd_component_type_depth};
case heif_channel_disparity:
- return {heif_unci_component_type_disparity};
+ return {heif_cmpd_component_type_disparity};
case heif_channel_interleaved:
switch (chroma) {
case heif_chroma_interleaved_RGB:
case heif_chroma_interleaved_RRGGBB_BE:
case heif_chroma_interleaved_RRGGBB_LE:
return {
- heif_unci_component_type_red,
- heif_unci_component_type_green,
- heif_unci_component_type_blue
+ heif_cmpd_component_type_red,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_blue
};
case heif_chroma_interleaved_RGBA:
case heif_chroma_interleaved_RRGGBBAA_BE:
case heif_chroma_interleaved_RRGGBBAA_LE:
return {
- heif_unci_component_type_red,
- heif_unci_component_type_green,
- heif_unci_component_type_blue,
- heif_unci_component_type_alpha
+ heif_cmpd_component_type_red,
+ heif_cmpd_component_type_green,
+ heif_cmpd_component_type_blue,
+ heif_cmpd_component_type_alpha
};
default:
assert(false);
@@ -2184,7 +2184,7 @@ uint16_t HeifPixelImage::get_component_type(uint32_t component_id) const
if (const auto* desc = find_component_description(component_id)) {
return desc->component_type;
}
- return heif_unci_component_type_UNDEFINED;
+ return heif_cmpd_component_type_UNDEFINED;
}
diff --git a/libheif/image/pixelimage.h b/libheif/image/pixelimage.h
index 8ffa3bfd..8f1bbdf3 100644
--- a/libheif/image/pixelimage.h
+++ b/libheif/image/pixelimage.h
@@ -31,7 +31,7 @@
#include <utility>
#include <cassert>
-constexpr uint16_t heif_unci_component_type_UNDEFINED = 0x7FFF;
+constexpr uint16_t heif_cmpd_component_type_UNDEFINED = 0x7FFF;
heif_chroma chroma_from_subsampling(int h, int v);
diff --git a/libheif/sequences/track_visual.cc b/libheif/sequences/track_visual.cc
index c5374605..a36659f1 100644
--- a/libheif/sequences/track_visual.cc
+++ b/libheif/sequences/track_visual.cc
@@ -158,7 +158,7 @@ bool Track_Visual::has_alpha_channel() const
if (sampleEntry) {
if (auto box_uncv = std::dynamic_pointer_cast<const Box_uncv>(sampleEntry)) {
if (auto cmpd = box_uncv->get_child_box<const Box_cmpd>()) {
- if (cmpd->has_component(heif_unci_component_type_alpha)) {
+ if (cmpd->has_component(heif_cmpd_component_type_alpha)) {
return true;
}
}
diff --git a/tests/component_descriptions.cc b/tests/component_descriptions.cc
index b6f45b2b..42603aa9 100644
--- a/tests/component_descriptions.cc
+++ b/tests/component_descriptions.cc
@@ -119,7 +119,7 @@ TEST_CASE("unci with cpat: handle and decoded image agree on component IDs")
uint32_t fa_id = 0;
err = heif_image_add_component(image, W, H,
- heif_unci_component_type_filter_array,
+ heif_cmpd_component_type_filter_array,
heif_component_datatype_unsigned_integer, 8,
&fa_id);
REQUIRE(err.code == heif_error_Ok);
@@ -137,9 +137,9 @@ TEST_CASE("unci with cpat: handle and decoded image agree on component IDs")
// Reference components for R, G, B (one each — G appears twice in the
// pattern but they share a single cmpd entry).
uint32_t r_id = 0, g_id = 0, b_id = 0;
- err = heif_image_add_bayer_component(image, heif_unci_component_type_red, &r_id); REQUIRE(err.code == heif_error_Ok);
- err = heif_image_add_bayer_component(image, heif_unci_component_type_green, &g_id); REQUIRE(err.code == heif_error_Ok);
- err = heif_image_add_bayer_component(image, heif_unci_component_type_blue, &b_id); REQUIRE(err.code == heif_error_Ok);
+ err = heif_image_add_bayer_component(image, heif_cmpd_component_type_red, &r_id); REQUIRE(err.code == heif_error_Ok);
+ err = heif_image_add_bayer_component(image, heif_cmpd_component_type_green, &g_id); REQUIRE(err.code == heif_error_Ok);
+ err = heif_image_add_bayer_component(image, heif_cmpd_component_type_blue, &b_id); REQUIRE(err.code == heif_error_Ok);
// 2x2 RGGB pattern; pixels[1] and pixels[2] both point at g_id.
heif_bayer_pattern_pixel pattern[4] = {
@@ -186,10 +186,10 @@ TEST_CASE("unci with cpat: handle and decoded image agree on component IDs")
uint32_t handle_ids[4];
heif_image_handle_get_used_component_ids(handle, handle_ids);
- REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[0]) == heif_unci_component_type_filter_array);
- REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[1]) == heif_unci_component_type_red);
- REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[2]) == heif_unci_component_type_green);
- REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[3]) == heif_unci_component_type_blue);
+ REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[0]) == heif_cmpd_component_type_filter_array);
+ REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[1]) == heif_cmpd_component_type_red);
+ REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[2]) == heif_cmpd_component_type_green);
+ REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[3]) == heif_cmpd_component_type_blue);
REQUIRE(heif_image_handle_get_component_bits_per_pixel(handle, handle_ids[0]) == 8);
@@ -235,9 +235,9 @@ TEST_CASE("HEVC YUV 4:2:0 component IDs match between handle and decoded image")
heif_image_handle_get_used_component_ids(handle, ids);
// Canonical ordering.
- REQUIRE(heif_image_handle_get_component_type(handle, ids[0]) == heif_unci_component_type_Y);
- REQUIRE(heif_image_handle_get_component_type(handle, ids[1]) == heif_unci_component_type_Cb);
- REQUIRE(heif_image_handle_get_component_type(handle, ids[2]) == heif_unci_component_type_Cr);
+ REQUIRE(heif_image_handle_get_component_type(handle, ids[0]) == heif_cmpd_component_type_Y);
+ REQUIRE(heif_image_handle_get_component_type(handle, ids[1]) == heif_cmpd_component_type_Cb);
+ REQUIRE(heif_image_handle_get_component_type(handle, ids[2]) == heif_cmpd_component_type_Cr);
// 8 bits per channel.
for (uint32_t id : ids) {
@@ -268,9 +268,9 @@ TEST_CASE("AVIF YUV 4:4:4 component IDs match between handle and decoded image")
uint32_t ids[3];
heif_image_handle_get_used_component_ids(handle, ids);
- REQUIRE(heif_image_handle_get_component_type(handle, ids[0]) == heif_unci_component_type_Y);
- REQUIRE(heif_image_handle_get_component_type(handle, ids[1]) == heif_unci_component_type_Cb);
- REQUIRE(heif_image_handle_get_component_type(handle, ids[2]) == heif_unci_component_type_Cr);
+ REQUIRE(heif_image_handle_get_component_type(handle, ids[0]) == heif_cmpd_component_type_Y);
+ REQUIRE(heif_image_handle_get_component_type(handle, ids[1]) == heif_cmpd_component_type_Cb);
+ REQUIRE(heif_image_handle_get_component_type(handle, ids[2]) == heif_cmpd_component_type_Cr);
for (uint32_t id : ids) {
REQUIRE(heif_image_handle_get_component_bits_per_pixel(handle, id) == 8);
@@ -307,9 +307,9 @@ TEST_CASE("HEIC YUV 4:2:0 (rainbow-451x461) component IDs match")
uint32_t ids[3];
heif_image_handle_get_used_component_ids(handle, ids);
- REQUIRE(heif_image_handle_get_component_type(handle, ids[0]) == heif_unci_component_type_Y);
- REQUIRE(heif_image_handle_get_component_type(handle, ids[1]) == heif_unci_component_type_Cb);
- REQUIRE(heif_image_handle_get_component_type(handle, ids[2]) == heif_unci_component_type_Cr);
+ REQUIRE(heif_image_handle_get_component_type(handle, ids[0]) == heif_cmpd_component_type_Y);
+ REQUIRE(heif_image_handle_get_component_type(handle, ids[1]) == heif_cmpd_component_type_Cb);
+ REQUIRE(heif_image_handle_get_component_type(handle, ids[2]) == heif_cmpd_component_type_Cr);
for (uint32_t id : ids) {
REQUIRE(heif_image_handle_get_component_bits_per_pixel(handle, id) == 8);
@@ -340,10 +340,10 @@ static void check_alpha_handle_matches_decoded_image(const char* fixture,
uint32_t handle_ids[4];
heif_image_handle_get_used_component_ids(handle, handle_ids);
- REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[0]) == heif_unci_component_type_Y);
- REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[1]) == heif_unci_component_type_Cb);
- REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[2]) == heif_unci_component_type_Cr);
- REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[3]) == heif_unci_component_type_alpha);
+ REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[0]) == heif_cmpd_component_type_Y);
+ REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[1]) == heif_cmpd_component_type_Cb);
+ REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[2]) == heif_cmpd_component_type_Cr);
+ REQUIRE(heif_image_handle_get_component_type(handle, handle_ids[3]) == heif_cmpd_component_type_alpha);
// The whole point of this round of fixes: the post-decode image carries
// the same four IDs the handle reports, including the alpha id.
diff --git a/tests/image_description_metadata.cc b/tests/image_description_metadata.cc
index b898a319..51050652 100644
--- a/tests/image_description_metadata.cc
+++ b/tests/image_description_metadata.cc
@@ -105,12 +105,12 @@ build_image(MetadataFixture& fix, uint32_t& comp1, uint32_t& comp2)
const heif_security_limits* limits = heif_get_global_security_limits();
- auto r1 = img->add_component(8, 4, heif_unci_component_type_monochrome,
+ auto r1 = img->add_component(8, 4, heif_cmpd_component_type_monochrome,
heif_component_datatype_unsigned_integer, 8, limits);
REQUIRE(r1);
comp1 = *r1;
- auto r2 = img->add_component(8, 4, heif_unci_component_type_monochrome,
+ auto r2 = img->add_component(8, 4, heif_cmpd_component_type_monochrome,
heif_component_datatype_unsigned_integer, 8, limits);
REQUIRE(r2);
comp2 = *r2;
@@ -221,7 +221,7 @@ static void check_metadata(const std::shared_ptr<HeifPixelImage>& img,
// them. In both cases the order in m_components is preserved.
std::vector<std::string> mono_gimi_ids;
for (const auto& c : img->get_component_descriptions()) {
- if (c.component_type == heif_unci_component_type_monochrome) {
+ if (c.component_type == heif_cmpd_component_type_monochrome) {
mono_gimi_ids.push_back(c.gimi_content_id);
}
}
diff --git a/tests/pixel_data_types.cc b/tests/pixel_data_types.cc
index 1e86a621..761620e9 100644
--- a/tests/pixel_data_types.cc
+++ b/tests/pixel_data_types.cc
@@ -206,9 +206,9 @@ TEST_CASE( "interleaved RGB component descriptions" )
REQUIRE(ids[1] == 2);
REQUIRE(ids[2] == 3);
- REQUIRE(image.get_component_type(ids[0]) == heif_unci_component_type_red);
- REQUIRE(image.get_component_type(ids[1]) == heif_unci_component_type_green);
- REQUIRE(image.get_component_type(ids[2]) == heif_unci_component_type_blue);
+ REQUIRE(image.get_component_type(ids[0]) == heif_cmpd_component_type_red);
+ REQUIRE(image.get_component_type(ids[1]) == heif_cmpd_component_type_green);
+ REQUIRE(image.get_component_type(ids[2]) == heif_cmpd_component_type_blue);
// All three descriptions share channel=interleaved, identical dims/bpp.
for (uint32_t id : ids) {
@@ -237,10 +237,10 @@ TEST_CASE( "interleaved RGBA component descriptions" )
REQUIRE(image.get_number_of_used_components() == 4);
auto ids = image.get_used_component_ids();
REQUIRE(ids.size() == 4);
- REQUIRE(image.get_component_type(ids[0]) == heif_unci_component_type_red);
- REQUIRE(image.get_component_type(ids[1]) == heif_unci_component_type_green);
- REQUIRE(image.get_component_type(ids[2]) == heif_unci_component_type_blue);
- REQUIRE(image.get_component_type(ids[3]) == heif_unci_component_type_alpha);
+ REQUIRE(image.get_component_type(ids[0]) == heif_cmpd_component_type_red);
+ REQUIRE(image.get_component_type(ids[1]) == heif_cmpd_component_type_green);
+ REQUIRE(image.get_component_type(ids[2]) == heif_cmpd_component_type_blue);
+ REQUIRE(image.get_component_type(ids[3]) == heif_cmpd_component_type_alpha);
for (uint32_t id : ids) {
REQUIRE(image.get_component_channel(id) == heif_channel_interleaved);
@@ -260,14 +260,14 @@ TEST_CASE( "Bayer pattern shares component id for same cmpd" )
image.create(4, 4, heif_colorspace_filter_array, heif_chroma_planar);
// 1) The data plane: a 14-bit filter-array component.
- auto fa_result = image.add_component(4, 4, heif_unci_component_type_filter_array,
+ auto fa_result = image.add_component(4, 4, heif_cmpd_component_type_filter_array,
heif_component_datatype_unsigned_integer, 14, limits);
REQUIRE(fa_result.error().error_code == heif_error_Ok);
// 2) Reference (no-data-plane) components for R, G, B.
- uint32_t r_id = image.add_component_without_data(heif_unci_component_type_red);
- uint32_t g_id = image.add_component_without_data(heif_unci_component_type_green);
- uint32_t b_id = image.add_component_without_data(heif_unci_component_type_blue);
+ uint32_t r_id = image.add_component_without_data(heif_cmpd_component_type_red);
+ uint32_t g_id = image.add_component_without_data(heif_cmpd_component_type_green);
+ uint32_t b_id = image.add_component_without_data(heif_cmpd_component_type_blue);
REQUIRE(image.get_number_of_used_components() == 4);
diff --git a/tests/uncompressed_encode_multicomponent.cc b/tests/uncompressed_encode_multicomponent.cc
index a8fc754b..9af614b4 100644
--- a/tests/uncompressed_encode_multicomponent.cc
+++ b/tests/uncompressed_encode_multicomponent.cc
@@ -253,7 +253,7 @@ static heif_image* create_and_fill_image(heif_component_datatype datatype, int b
for (uint32_t c = 0; c < kNumComponents; c++) {
uint32_t id = 0;
err = heif_image_add_component(image, kWidth, kHeight,
- heif_unci_component_type_monochrome, datatype, bit_depth, &id);
+ heif_cmpd_component_type_monochrome, datatype, bit_depth, &id);
REQUIRE(err.code == heif_error_Ok);
//REQUIRE(idx == c);
@@ -316,7 +316,7 @@ static void verify_image_data(const heif_image* image)
for (uint32_t c : components) {
REQUIRE(heif_image_get_component_width(image, c) == kWidth);
REQUIRE(heif_image_get_component_height(image, c) == kHeight);
- REQUIRE(heif_image_get_component_type(image, c) == heif_unci_component_type_monochrome);
+ REQUIRE(heif_image_get_component_type(image, c) == heif_cmpd_component_type_monochrome);
size_t stride = 0;
const T* data = get_component_ptr_readonly<T>(image, c, &stride);
@@ -456,13 +456,13 @@ TEST_CASE("Mixed bpp: 16-bit and 14-bit components")
// Add 16-bit component (byte-aligned)
uint32_t idx0 = 0;
- err = heif_image_add_component(image, kW, kH, heif_unci_component_type_monochrome,
+ err = heif_image_add_component(image, kW, kH, heif_cmpd_component_type_monochrome,
heif_component_datatype_unsigned_integer, kBpp16, &idx0);
REQUIRE(err.code == heif_error_Ok);
// Add 14-bit component (non-byte-aligned)
uint32_t idx1 = 0;
- err = heif_image_add_component(image, kW, kH, heif_unci_component_type_monochrome,
+ err = heif_image_add_component(image, kW, kH, heif_cmpd_component_type_monochrome,
heif_component_datatype_unsigned_integer, kBpp14, &idx1);
REQUIRE(err.code == heif_error_Ok);