Commit de9d2b95 for libheif
commit de9d2b951761ffcca2c835d190c52903c2a6bc26
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Thu May 14 20:59:34 2026 +0200
rename internal add_plane() to add_channel()
diff --git a/libheif/api/libheif/heif_image.cc b/libheif/api/libheif/heif_image.cc
index 63021fae..1bd870a5 100644
--- a/libheif/api/libheif/heif_image.cc
+++ b/libheif/api/libheif/heif_image.cc
@@ -157,7 +157,7 @@ const uint8_t* heif_image_get_plane_readonly(const heif_image* image,
}
size_t stride;
- const auto* p = image->image->get_plane(channel, &stride);
+ const auto* p = image->image->get_channel(channel, &stride);
// TODO: use C++20 std::cmp_greater()
if (stride > static_cast<uint32_t>(std::numeric_limits<int>::max())) {
@@ -183,7 +183,7 @@ uint8_t* heif_image_get_plane(heif_image* image,
}
size_t stride;
- uint8_t* p = image->image->get_plane(channel, &stride);
+ uint8_t* p = image->image->get_channel(channel, &stride);
// TODO: use C++20 std::cmp_greater()
if (stride > static_cast<uint32_t>(std::numeric_limits<int>::max())) {
@@ -208,7 +208,7 @@ const uint8_t* heif_image_get_plane_readonly2(const heif_image* image,
return nullptr;
}
- return image->image->get_plane(channel, out_stride);
+ return image->image->get_channel(channel, out_stride);
}
@@ -225,7 +225,7 @@ uint8_t* heif_image_get_plane2(heif_image* image,
return nullptr;
}
- return image->image->get_plane(channel, out_stride);
+ return image->image->get_channel(channel, out_stride);
}
@@ -359,7 +359,7 @@ heif_error heif_image_add_plane(heif_image* image,
heif_channel channel, int width, int height, int bit_depth)
{
// Note: no security limit, because this is explicitly requested by the user.
- if (auto err = image->image->add_plane(channel, width, height, bit_depth, nullptr)) {
+ if (auto err = image->image->add_channel(channel, width, height, bit_depth, nullptr)) {
return err.error_struct(image->image.get());
}
else {
@@ -372,7 +372,7 @@ heif_error heif_image_add_plane_safe(heif_image* image,
heif_channel channel, int width, int height, int bit_depth,
const heif_security_limits* limits)
{
- if (auto err = image->image->add_plane(channel, width, height, bit_depth, limits)) {
+ if (auto err = image->image->add_channel(channel, width, height, bit_depth, limits)) {
return err.error_struct(image->image.get());
}
else {
diff --git a/libheif/codecs/uncompressed/unc_decoder_block_component_interleave.cc b/libheif/codecs/uncompressed/unc_decoder_block_component_interleave.cc
index 8cf2525d..8a5354ae 100644
--- a/libheif/codecs/uncompressed/unc_decoder_block_component_interleave.cc
+++ b/libheif/codecs/uncompressed/unc_decoder_block_component_interleave.cc
@@ -104,7 +104,7 @@ Error unc_decoder_block_component_interleave::decode_tile(const std::vector<uint
heif_channel channel;
comp[i].use = map_uncompressed_component_to_channel(m_cmpd, c, &channel);
if (comp[i].use) {
- comp[i].dst_plane = img->get_plane(channel, &comp[i].dst_plane_stride);
+ comp[i].dst_plane = img->get_channel(channel, &comp[i].dst_plane_stride);
}
else {
comp[i].dst_plane = nullptr;
diff --git a/libheif/codecs/uncompressed/unc_decoder_block_pixel_interleave.cc b/libheif/codecs/uncompressed/unc_decoder_block_pixel_interleave.cc
index 9e75f6f1..462a3cc2 100644
--- a/libheif/codecs/uncompressed/unc_decoder_block_pixel_interleave.cc
+++ b/libheif/codecs/uncompressed/unc_decoder_block_pixel_interleave.cc
@@ -93,7 +93,7 @@ Error unc_decoder_block_pixel_interleave::decode_tile(const std::vector<uint8_t>
heif_channel channel;
comp[i].use = map_uncompressed_component_to_channel(m_cmpd, c, &channel);
if (comp[i].use) {
- comp[i].dst_plane = img->get_plane(channel, &comp[i].dst_plane_stride);
+ comp[i].dst_plane = img->get_channel(channel, &comp[i].dst_plane_stride);
}
else {
comp[i].dst_plane = nullptr;
diff --git a/libheif/codecs/uncompressed/unc_decoder_legacybase.cc b/libheif/codecs/uncompressed/unc_decoder_legacybase.cc
index 99920685..10707222 100644
--- a/libheif/codecs/uncompressed/unc_decoder_legacybase.cc
+++ b/libheif/codecs/uncompressed/unc_decoder_legacybase.cc
@@ -156,10 +156,10 @@ unc_decoder_legacybase::ChannelListEntry unc_decoder_legacybase::buildChannelLis
entry.tile_height /= 2;
}
if (entry.channel == heif_channel_Cb) {
- entry.other_chroma_dst_plane = img->get_plane(heif_channel_Cr, &(entry.other_chroma_dst_plane_stride));
+ entry.other_chroma_dst_plane = img->get_channel(heif_channel_Cr, &(entry.other_chroma_dst_plane_stride));
}
else if (entry.channel == heif_channel_Cr) {
- entry.other_chroma_dst_plane = img->get_plane(heif_channel_Cb, &(entry.other_chroma_dst_plane_stride));
+ entry.other_chroma_dst_plane = img->get_channel(heif_channel_Cb, &(entry.other_chroma_dst_plane_stride));
}
}
entry.bits_per_component_sample = component.component_bit_depth;
diff --git a/libheif/codecs/uncompressed/unc_encoder_rgb_block_pixel_interleave.cc b/libheif/codecs/uncompressed/unc_encoder_rgb_block_pixel_interleave.cc
index 6ccd037f..56092ff4 100644
--- a/libheif/codecs/uncompressed/unc_encoder_rgb_block_pixel_interleave.cc
+++ b/libheif/codecs/uncompressed/unc_encoder_rgb_block_pixel_interleave.cc
@@ -93,7 +93,7 @@ std::vector<uint8_t> unc_encoder_rgb_block_pixel_interleave::encode_tile(const s
uint16_t bpp = src_image->get_bits_per_pixel(heif_channel_interleaved);
size_t src_stride;
- const auto* src_data = reinterpret_cast<const uint16_t*>(src_image->get_plane(heif_channel_interleaved, &src_stride));
+ const auto* src_data = reinterpret_cast<const uint16_t*>(src_image->get_channel(heif_channel_interleaved, &src_stride));
src_stride /= 2;
uint64_t out_size = static_cast<uint64_t>(src_image->get_height()) * src_image->get_width() * m_bytes_per_pixel;
diff --git a/libheif/codecs/uncompressed/unc_encoder_rgb_bytealign_pixel_interleave.cc b/libheif/codecs/uncompressed/unc_encoder_rgb_bytealign_pixel_interleave.cc
index 2f4fa681..50d16fc6 100644
--- a/libheif/codecs/uncompressed/unc_encoder_rgb_bytealign_pixel_interleave.cc
+++ b/libheif/codecs/uncompressed/unc_encoder_rgb_bytealign_pixel_interleave.cc
@@ -118,7 +118,7 @@ std::vector<uint8_t> unc_encoder_rgb_bytealign_pixel_interleave::encode_tile(con
std::vector<uint8_t> data;
size_t src_stride;
- const uint8_t* src_data = src_image->get_plane(heif_channel_interleaved, &src_stride);
+ const uint8_t* src_data = src_image->get_channel(heif_channel_interleaved, &src_stride);
uint64_t out_size = static_cast<uint64_t>(src_image->get_height()) * src_image->get_width() * m_bytes_per_pixel;
data.resize(out_size);
diff --git a/libheif/codecs/uncompressed/unc_encoder_rgb_pixel_interleave.cc b/libheif/codecs/uncompressed/unc_encoder_rgb_pixel_interleave.cc
index ccc250d7..51188d7c 100644
--- a/libheif/codecs/uncompressed/unc_encoder_rgb_pixel_interleave.cc
+++ b/libheif/codecs/uncompressed/unc_encoder_rgb_pixel_interleave.cc
@@ -100,7 +100,7 @@ std::vector<uint8_t> unc_encoder_rgb_pixel_interleave::encode_tile(const std::sh
std::vector<uint8_t> data;
size_t src_stride;
- const uint8_t* src_data = src_image->get_plane(heif_channel_interleaved, &src_stride);
+ const uint8_t* src_data = src_image->get_channel(heif_channel_interleaved, &src_stride);
uint64_t out_size = static_cast<uint64_t>(src_image->get_height()) * src_image->get_width() * m_bytes_per_pixel;
data.resize(out_size);
diff --git a/libheif/color-conversion/alpha.cc b/libheif/color-conversion/alpha.cc
index 7a316a81..6aaa4412 100644
--- a/libheif/color-conversion/alpha.cc
+++ b/libheif/color-conversion/alpha.cc
@@ -82,7 +82,7 @@ Op_drop_alpha_plane::convert_colorspace(const std::shared_ptr<const HeifPixelIma
heif_channel_G,
heif_channel_B}) {
if (input->has_channel(channel)) {
- outimg->copy_new_plane_from(input, channel, channel, limits);
+ outimg->copy_new_channel_from(input, channel, channel, limits);
}
}
@@ -182,21 +182,21 @@ Op_flatten_alpha_plane<Pixel>::convert_colorspace(const std::shared_ptr<const He
for (heif_channel channel : {heif_channel_R,
heif_channel_G,
heif_channel_B}) {
- outimg->add_plane(channel, width, height, target_state.bits_per_pixel, limits);
+ outimg->add_channel(channel, width, height, target_state.bits_per_pixel, limits);
const Pixel* p_alpha;
size_t stride_alpha;
- p_alpha = (const Pixel*)input->get_plane(heif_channel_Alpha, &stride_alpha);
+ p_alpha = (const Pixel*)input->get_channel(heif_channel_Alpha, &stride_alpha);
int bpp_alpha = input->get_bits_per_pixel(heif_channel_Alpha);
Pixel alpha_max = (Pixel)((1 << bpp_alpha) - 1);
const Pixel* p_in;
size_t stride_in;
- p_in = (const Pixel*)input->get_plane(channel, &stride_in);
+ p_in = (const Pixel*)input->get_channel(channel, &stride_in);
Pixel* p_out;
size_t stride_out;
- p_out = (Pixel*)outimg->get_plane(channel, &stride_out);
+ p_out = (Pixel*)outimg->get_channel(channel, &stride_out);
if (sizeof(Pixel) == 2) {
stride_alpha /= 2;
@@ -340,7 +340,7 @@ Op_adjust_alpha_bit_depth::convert_colorspace(const std::shared_ptr<const HeifPi
for (heif_channel channel : {heif_channel_Y, heif_channel_Cb, heif_channel_Cr,
heif_channel_R, heif_channel_G, heif_channel_B}) {
if (input->has_channel(channel)) {
- outimg->copy_new_plane_from(input, channel, channel, limits);
+ outimg->copy_new_channel_from(input, channel, channel, limits);
}
}
@@ -354,7 +354,7 @@ Op_adjust_alpha_bit_depth::convert_colorspace(const std::shared_ptr<const HeifPi
uint32_t alpha_width = input->get_width(heif_channel_Alpha);
uint32_t alpha_height = input->get_height(heif_channel_Alpha);
- if (auto err = outimg->add_plane(heif_channel_Alpha, alpha_width, alpha_height, target_bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, alpha_width, alpha_height, target_bpp, limits)) {
return err;
}
@@ -362,11 +362,11 @@ Op_adjust_alpha_bit_depth::convert_colorspace(const std::shared_ptr<const HeifPi
// Upscale: 8-bit alpha -> HDR using pattern replication
const uint8_t* p_in;
size_t stride_in;
- p_in = input->get_plane(heif_channel_Alpha, &stride_in);
+ p_in = input->get_channel(heif_channel_Alpha, &stride_in);
uint16_t* p_out;
size_t stride_out;
- p_out = (uint16_t*) outimg->get_plane(heif_channel_Alpha, &stride_out);
+ p_out = (uint16_t*) outimg->get_channel(heif_channel_Alpha, &stride_out);
stride_out /= 2;
int shift1 = target_bpp - input_alpha_bpp;
@@ -382,12 +382,12 @@ Op_adjust_alpha_bit_depth::convert_colorspace(const std::shared_ptr<const HeifPi
// Downscale: HDR alpha -> 8-bit
const uint16_t* p_in;
size_t stride_in;
- p_in = (const uint16_t*) input->get_plane(heif_channel_Alpha, &stride_in);
+ p_in = (const uint16_t*) input->get_channel(heif_channel_Alpha, &stride_in);
stride_in /= 2;
uint8_t* p_out;
size_t stride_out;
- p_out = outimg->get_plane(heif_channel_Alpha, &stride_out);
+ p_out = outimg->get_channel(heif_channel_Alpha, &stride_out);
int shift = input_alpha_bpp - 8;
@@ -400,12 +400,12 @@ Op_adjust_alpha_bit_depth::convert_colorspace(const std::shared_ptr<const HeifPi
// HDR alpha -> different HDR: rescale within uint16_t
const uint16_t* p_in;
size_t stride_in;
- p_in = (const uint16_t*) input->get_plane(heif_channel_Alpha, &stride_in);
+ p_in = (const uint16_t*) input->get_channel(heif_channel_Alpha, &stride_in);
stride_in /= 2;
uint16_t* p_out;
size_t stride_out;
- p_out = (uint16_t*) outimg->get_plane(heif_channel_Alpha, &stride_out);
+ p_out = (uint16_t*) outimg->get_channel(heif_channel_Alpha, &stride_out);
stride_out /= 2;
if (target_bpp > input_alpha_bpp) {
@@ -429,11 +429,11 @@ Op_adjust_alpha_bit_depth::convert_colorspace(const std::shared_ptr<const HeifPi
// SDR alpha -> different SDR (both <= 8)
const uint8_t* p_in;
size_t stride_in;
- p_in = input->get_plane(heif_channel_Alpha, &stride_in);
+ p_in = input->get_channel(heif_channel_Alpha, &stride_in);
uint8_t* p_out;
size_t stride_out;
- p_out = outimg->get_plane(heif_channel_Alpha, &stride_out);
+ p_out = outimg->get_channel(heif_channel_Alpha, &stride_out);
if (target_bpp > input_alpha_bpp) {
int shift1 = target_bpp - input_alpha_bpp;
diff --git a/libheif/color-conversion/bayer_bilinear.cc b/libheif/color-conversion/bayer_bilinear.cc
index 6372ba74..3e3dd90d 100644
--- a/libheif/color-conversion/bayer_bilinear.cc
+++ b/libheif/color-conversion/bayer_bilinear.cc
@@ -109,15 +109,15 @@ Op_bayer_bilinear_to_RGB24_32::convert_colorspace(const std::shared_ptr<const He
outimg->create(width, height, heif_colorspace_RGB, out_chroma);
- if (auto err = outimg->add_plane(heif_channel_interleaved, width, height, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_interleaved, width, height, bpp, limits)) {
return err;
}
size_t in_stride = 0;
- const uint8_t* in_p = input->get_plane(heif_channel_filter_array, &in_stride);
+ const uint8_t* in_p = input->get_channel(heif_channel_filter_array, &in_stride);
size_t out_stride = 0;
- uint8_t* out_p = outimg->get_plane(heif_channel_interleaved, &out_stride);
+ uint8_t* out_p = outimg->get_channel(heif_channel_interleaved, &out_stride);
// Build a lookup table: for each pattern position, which RGB channel (0=R,1=G,2=B) does it provide?
std::vector<int> pattern_channel(pw * ph);
diff --git a/libheif/color-conversion/chroma_sampling.cc b/libheif/color-conversion/chroma_sampling.cc
index 2de71686..e52ba7f2 100644
--- a/libheif/color-conversion/chroma_sampling.cc
+++ b/libheif/color-conversion/chroma_sampling.cc
@@ -131,14 +131,14 @@ Op_YCbCr444_to_YCbCr420_average<Pixel>::convert_colorspace(const std::shared_ptr
uint32_t cwidth = (width + 1) / 2;
uint32_t cheight = (height + 1) / 2;
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, bpp_y, limits) ||
- outimg->add_plane(heif_channel_Cb, cwidth, cheight, bpp_cb, limits) ||
- outimg->add_plane(heif_channel_Cr, cwidth, cheight, bpp_cr, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, bpp_y, limits) ||
+ outimg->add_channel(heif_channel_Cb, cwidth, cheight, bpp_cb, limits) ||
+ outimg->add_channel(heif_channel_Cr, cwidth, cheight, bpp_cr, limits)) {
return err;
}
if (has_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp_a, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, bpp_a, limits)) {
return err;
}
}
@@ -149,12 +149,12 @@ Op_YCbCr444_to_YCbCr420_average<Pixel>::convert_colorspace(const std::shared_ptr
Pixel* out_y, * out_cb, * out_cr;
size_t out_y_stride = 0, out_cb_stride = 0, out_cr_stride = 0, out_a_stride = 0;
- in_y = (const Pixel*) input->get_plane(heif_channel_Y, &in_y_stride);
- in_cb = (const Pixel*) input->get_plane(heif_channel_Cb, &in_cb_stride);
- in_cr = (const Pixel*) input->get_plane(heif_channel_Cr, &in_cr_stride);
- out_y = (Pixel*) outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = (Pixel*) outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = (Pixel*) outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ in_y = (const Pixel*) input->get_channel(heif_channel_Y, &in_y_stride);
+ in_cb = (const Pixel*) input->get_channel(heif_channel_Cb, &in_cb_stride);
+ in_cr = (const Pixel*) input->get_channel(heif_channel_Cr, &in_cr_stride);
+ out_y = (Pixel*) outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = (Pixel*) outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = (Pixel*) outimg->get_channel(heif_channel_Cr, &out_cr_stride);
if (hdr) {
in_y_stride /= 2;
@@ -171,8 +171,8 @@ Op_YCbCr444_to_YCbCr420_average<Pixel>::convert_colorspace(const std::shared_ptr
uint8_t* out_a;
if (has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
else {
in_a = nullptr;
@@ -225,7 +225,7 @@ Op_YCbCr444_to_YCbCr420_average<Pixel>::convert_colorspace(const std::shared_ptr
}
}
- // TODO: check whether we can use HeifPixelImage::transfer_plane_from_image_as() instead of copying Y and Alpha
+ // TODO: check whether we can use HeifPixelImage::transfer_channel_from_image_as() instead of copying Y and Alpha
for (y = 0; y < height; y++) {
uint32_t copyWidth = (hdr ? width * 2 : width);
@@ -355,14 +355,14 @@ Op_YCbCr444_to_YCbCr422_average<Pixel>::convert_colorspace(const std::shared_ptr
uint32_t cwidth = (width + 1) / 2;
uint32_t cheight = height;
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, bpp_y, limits) ||
- outimg->add_plane(heif_channel_Cb, cwidth, cheight, bpp_cb, limits) ||
- outimg->add_plane(heif_channel_Cr, cwidth, cheight, bpp_cr, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, bpp_y, limits) ||
+ outimg->add_channel(heif_channel_Cb, cwidth, cheight, bpp_cb, limits) ||
+ outimg->add_channel(heif_channel_Cr, cwidth, cheight, bpp_cr, limits)) {
return err;
}
if (has_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp_a, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, bpp_a, limits)) {
return err;
}
}
@@ -373,19 +373,19 @@ Op_YCbCr444_to_YCbCr422_average<Pixel>::convert_colorspace(const std::shared_ptr
Pixel* out_y, * out_cb, * out_cr;
size_t out_y_stride = 0, out_cb_stride = 0, out_cr_stride = 0, out_a_stride = 0;
- in_y = (const Pixel*) input->get_plane(heif_channel_Y, &in_y_stride);
- in_cb = (const Pixel*) input->get_plane(heif_channel_Cb, &in_cb_stride);
- in_cr = (const Pixel*) input->get_plane(heif_channel_Cr, &in_cr_stride);
- out_y = (Pixel*) outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = (Pixel*) outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = (Pixel*) outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ in_y = (const Pixel*) input->get_channel(heif_channel_Y, &in_y_stride);
+ in_cb = (const Pixel*) input->get_channel(heif_channel_Cb, &in_cb_stride);
+ in_cr = (const Pixel*) input->get_channel(heif_channel_Cr, &in_cr_stride);
+ out_y = (Pixel*) outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = (Pixel*) outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = (Pixel*) outimg->get_channel(heif_channel_Cr, &out_cr_stride);
const uint8_t* in_a;
uint8_t* out_a;
if (has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
else {
in_a = nullptr;
@@ -427,7 +427,7 @@ Op_YCbCr444_to_YCbCr422_average<Pixel>::convert_colorspace(const std::shared_ptr
}
}
- // TODO: check whether we can use HeifPixelImage::transfer_plane_from_image_as() instead of copying Y and Alpha
+ // TODO: check whether we can use HeifPixelImage::transfer_channel_from_image_as() instead of copying Y and Alpha
for (y = 0; y < height; y++) {
uint32_t copyWidth = (hdr ? width * 2 : width);
@@ -550,14 +550,14 @@ Op_YCbCr420_bilinear_to_YCbCr444<Pixel>::convert_colorspace(const std::shared_pt
outimg->create(width, height, heif_colorspace_YCbCr, heif_chroma_444);
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, bpp_y, limits) ||
- outimg->add_plane(heif_channel_Cb, width, height, bpp_cb, limits) ||
- outimg->add_plane(heif_channel_Cr, width, height, bpp_cr, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, bpp_y, limits) ||
+ outimg->add_channel(heif_channel_Cb, width, height, bpp_cb, limits) ||
+ outimg->add_channel(heif_channel_Cr, width, height, bpp_cr, limits)) {
return err;
}
if (has_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp_a, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, bpp_a, limits)) {
return err;
}
}
@@ -568,19 +568,19 @@ Op_YCbCr420_bilinear_to_YCbCr444<Pixel>::convert_colorspace(const std::shared_pt
Pixel* out_y, * out_cb, * out_cr;
size_t out_y_stride = 0, out_cb_stride = 0, out_cr_stride = 0, out_a_stride = 0;
- in_y = (const Pixel*) input->get_plane(heif_channel_Y, &in_y_stride);
- in_cb = (const Pixel*) input->get_plane(heif_channel_Cb, &in_cb_stride);
- in_cr = (const Pixel*) input->get_plane(heif_channel_Cr, &in_cr_stride);
- out_y = (Pixel*) outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = (Pixel*) outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = (Pixel*) outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ in_y = (const Pixel*) input->get_channel(heif_channel_Y, &in_y_stride);
+ in_cb = (const Pixel*) input->get_channel(heif_channel_Cb, &in_cb_stride);
+ in_cr = (const Pixel*) input->get_channel(heif_channel_Cr, &in_cr_stride);
+ out_y = (Pixel*) outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = (Pixel*) outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = (Pixel*) outimg->get_channel(heif_channel_Cr, &out_cr_stride);
const uint8_t* in_a;
uint8_t* out_a;
if (has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
else {
in_a = nullptr;
@@ -707,7 +707,7 @@ Op_YCbCr420_bilinear_to_YCbCr444<Pixel>::convert_colorspace(const std::shared_pt
}
}
- // TODO: check whether we can use HeifPixelImage::transfer_plane_from_image_as() instead of copying Y and Alpha
+ // TODO: check whether we can use HeifPixelImage::transfer_channel_from_image_as() instead of copying Y and Alpha
for (y = 0; y < height; y++) {
uint32_t copyWidth = (hdr ? width * 2 : width);
@@ -831,14 +831,14 @@ Op_YCbCr422_bilinear_to_YCbCr444<Pixel>::convert_colorspace(const std::shared_pt
outimg->create(width, height, heif_colorspace_YCbCr, heif_chroma_444);
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, bpp_y, limits) ||
- outimg->add_plane(heif_channel_Cb, width, height, bpp_cb, limits) ||
- outimg->add_plane(heif_channel_Cr, width, height, bpp_cr, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, bpp_y, limits) ||
+ outimg->add_channel(heif_channel_Cb, width, height, bpp_cb, limits) ||
+ outimg->add_channel(heif_channel_Cr, width, height, bpp_cr, limits)) {
return err;
}
if (has_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp_a, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, bpp_a, limits)) {
return err;
}
}
@@ -849,19 +849,19 @@ Op_YCbCr422_bilinear_to_YCbCr444<Pixel>::convert_colorspace(const std::shared_pt
Pixel* out_y, * out_cb, * out_cr;
size_t out_y_stride = 0, out_cb_stride = 0, out_cr_stride = 0, out_a_stride = 0;
- in_y = (const Pixel*) input->get_plane(heif_channel_Y, &in_y_stride);
- in_cb = (const Pixel*) input->get_plane(heif_channel_Cb, &in_cb_stride);
- in_cr = (const Pixel*) input->get_plane(heif_channel_Cr, &in_cr_stride);
- out_y = (Pixel*) outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = (Pixel*) outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = (Pixel*) outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ in_y = (const Pixel*) input->get_channel(heif_channel_Y, &in_y_stride);
+ in_cb = (const Pixel*) input->get_channel(heif_channel_Cb, &in_cb_stride);
+ in_cr = (const Pixel*) input->get_channel(heif_channel_Cr, &in_cr_stride);
+ out_y = (Pixel*) outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = (Pixel*) outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = (Pixel*) outimg->get_channel(heif_channel_Cr, &out_cr_stride);
const uint8_t* in_a;
uint8_t* out_a;
if (has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
else {
in_a = nullptr;
@@ -934,7 +934,7 @@ Op_YCbCr422_bilinear_to_YCbCr444<Pixel>::convert_colorspace(const std::shared_pt
}
}
- // TODO: check whether we can use HeifPixelImage::transfer_plane_from_image_as() instead of copying Y and Alpha
+ // TODO: check whether we can use HeifPixelImage::transfer_channel_from_image_as() instead of copying Y and Alpha
for (y = 0; y < height; y++) {
uint32_t copyWidth = (hdr ? width * 2 : width);
diff --git a/libheif/color-conversion/hdr_sdr.cc b/libheif/color-conversion/hdr_sdr.cc
index fab0cd09..77b41397 100644
--- a/libheif/color-conversion/hdr_sdr.cc
+++ b/libheif/color-conversion/hdr_sdr.cc
@@ -77,7 +77,7 @@ Op_to_hdr_planes::convert_colorspace(const std::shared_ptr<const HeifPixelImage>
if (input->has_channel(channel)) {
uint32_t width = input->get_width(channel);
uint32_t height = input->get_height(channel);
- if (auto err = outimg->add_plane(channel, width, height, target_state.bits_per_pixel, limits)) {
+ if (auto err = outimg->add_channel(channel, width, height, target_state.bits_per_pixel, limits)) {
return err;
}
@@ -89,11 +89,11 @@ Op_to_hdr_planes::convert_colorspace(const std::shared_ptr<const HeifPixelImage>
const uint8_t* p_in;
size_t stride_in;
- p_in = input->get_plane(channel, &stride_in);
+ p_in = input->get_channel(channel, &stride_in);
uint16_t* p_out;
size_t stride_out;
- p_out = (uint16_t*) outimg->get_plane(channel, &stride_out);
+ p_out = (uint16_t*) outimg->get_channel(channel, &stride_out);
stride_out /= 2;
for (uint32_t y = 0; y < height; y++)
@@ -172,7 +172,7 @@ Op_to_sdr_planes::convert_colorspace(const std::shared_ptr<const HeifPixelImage>
if (input_bits > 8) {
uint32_t width = input->get_width(channel);
uint32_t height = input->get_height(channel);
- if (auto err = outimg->add_plane(channel, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(channel, width, height, 8, limits)) {
return err;
}
@@ -180,12 +180,12 @@ Op_to_sdr_planes::convert_colorspace(const std::shared_ptr<const HeifPixelImage>
const uint16_t* p_in;
size_t stride_in;
- p_in = (uint16_t*) input->get_plane(channel, &stride_in);
+ p_in = (uint16_t*) input->get_channel(channel, &stride_in);
stride_in /= 2;
uint8_t* p_out;
size_t stride_out;
- p_out = outimg->get_plane(channel, &stride_out);
+ p_out = outimg->get_channel(channel, &stride_out);
for (uint32_t y = 0; y < height; y++)
for (uint32_t x = 0; x < width; x++) {
@@ -195,7 +195,7 @@ Op_to_sdr_planes::convert_colorspace(const std::shared_ptr<const HeifPixelImage>
} else if (input_bits < 8) {
uint32_t width = input->get_width(channel);
uint32_t height = input->get_height(channel);
- if (auto err = outimg->add_plane(channel, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(channel, width, height, 8, limits)) {
return err;
}
@@ -224,10 +224,10 @@ Op_to_sdr_planes::convert_colorspace(const std::shared_ptr<const HeifPixelImage>
}
size_t stride_in;
- const uint8_t* p_in = input->get_plane(channel, &stride_in);
+ const uint8_t* p_in = input->get_channel(channel, &stride_in);
size_t stride_out;
- uint8_t* p_out = outimg->get_plane(channel, &stride_out);
+ uint8_t* p_out = outimg->get_channel(channel, &stride_out);
for (uint32_t y = 0; y < height; y++)
for (uint32_t x = 0; x < width; x++) {
@@ -235,7 +235,7 @@ Op_to_sdr_planes::convert_colorspace(const std::shared_ptr<const HeifPixelImage>
p_out[y * stride_out + x] = (uint8_t) ((in * mulFactor) >> 8);
}
} else {
- outimg->copy_new_plane_from(input, channel, channel, limits);
+ outimg->copy_new_channel_from(input, channel, channel, limits);
}
}
}
diff --git a/libheif/color-conversion/monochrome.cc b/libheif/color-conversion/monochrome.cc
index 1d22dafe..1747a50c 100644
--- a/libheif/color-conversion/monochrome.cc
+++ b/libheif/color-conversion/monochrome.cc
@@ -71,9 +71,9 @@ Op_mono_to_YCbCr420::convert_colorspace(const std::shared_ptr<const HeifPixelIma
uint32_t chroma_width = (width + 1) / 2;
uint32_t chroma_height = (height + 1) / 2;
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, input_bpp, limits) ||
- outimg->add_plane(heif_channel_Cb, chroma_width, chroma_height, input_bpp, limits) ||
- outimg->add_plane(heif_channel_Cr, chroma_width, chroma_height, input_bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, input_bpp, limits) ||
+ outimg->add_channel(heif_channel_Cb, chroma_width, chroma_height, input_bpp, limits) ||
+ outimg->add_channel(heif_channel_Cr, chroma_width, chroma_height, input_bpp, limits)) {
return err;
}
@@ -81,7 +81,7 @@ Op_mono_to_YCbCr420::convert_colorspace(const std::shared_ptr<const HeifPixelIma
bool has_alpha = input->has_channel(heif_channel_Alpha);
if (has_alpha) {
alpha_bpp = input->get_bits_per_pixel(heif_channel_Alpha);
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, alpha_bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, alpha_bpp, limits)) {
return err;
}
}
@@ -94,11 +94,11 @@ Op_mono_to_YCbCr420::convert_colorspace(const std::shared_ptr<const HeifPixelIma
const uint8_t* in_y;
size_t in_y_stride = 0;
- in_y = input->get_plane(heif_channel_Y, &in_y_stride);
+ in_y = input->get_channel(heif_channel_Y, &in_y_stride);
- out_y = outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ out_y = outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = outimg->get_channel(heif_channel_Cr, &out_cr_stride);
auto chroma_value = static_cast<uint8_t>(1 << (input_bpp - 1));
@@ -118,11 +118,11 @@ Op_mono_to_YCbCr420::convert_colorspace(const std::shared_ptr<const HeifPixelIma
const uint16_t* in_y;
size_t in_y_stride = 0;
- in_y = (const uint16_t*) input->get_plane(heif_channel_Y, &in_y_stride);
+ in_y = (const uint16_t*) input->get_channel(heif_channel_Y, &in_y_stride);
- out_y = (uint16_t*) outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = (uint16_t*) outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = (uint16_t*) outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ out_y = (uint16_t*) outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = (uint16_t*) outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = (uint16_t*) outimg->get_channel(heif_channel_Cr, &out_cr_stride);
in_y_stride /= 2;
out_y_stride /= 2;
@@ -148,8 +148,8 @@ Op_mono_to_YCbCr420::convert_colorspace(const std::shared_ptr<const HeifPixelIma
size_t in_a_stride = 0;
size_t out_a_stride = 0;
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
uint32_t memory_width = (alpha_bpp > 8 ? width * 2 : width);
@@ -235,7 +235,7 @@ Op_mono_to_RGB24_32::convert_colorspace(const std::shared_ptr<const HeifPixelIma
outimg->create(width, height, heif_colorspace_RGB, heif_chroma_interleaved_24bit);
}
- if (auto err = outimg->add_plane(heif_channel_interleaved, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_interleaved, width, height, 8, limits)) {
return err;
}
@@ -245,12 +245,12 @@ Op_mono_to_RGB24_32::convert_colorspace(const std::shared_ptr<const HeifPixelIma
uint8_t* out_p;
size_t out_p_stride = 0;
- in_y = input->get_plane(heif_channel_Y, &in_y_stride);
+ in_y = input->get_channel(heif_channel_Y, &in_y_stride);
if (has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
}
- out_p = outimg->get_plane(heif_channel_interleaved, &out_p_stride);
+ out_p = outimg->get_channel(heif_channel_interleaved, &out_p_stride);
uint32_t x, y;
for (y = 0; y < height; y++) {
diff --git a/libheif/color-conversion/rgb2rgb.cc b/libheif/color-conversion/rgb2rgb.cc
index 87ebfa8d..ac5983d2 100644
--- a/libheif/color-conversion/rgb2rgb.cc
+++ b/libheif/color-conversion/rgb2rgb.cc
@@ -97,7 +97,7 @@ Op_RGB_to_RGB24_32::convert_colorspace(const std::shared_ptr<const HeifPixelImag
outimg->create(width, height, heif_colorspace_RGB,
want_alpha ? heif_chroma_interleaved_32bit : heif_chroma_interleaved_24bit);
- if (auto err = outimg->add_plane(heif_channel_interleaved, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_interleaved, width, height, 8, limits)) {
return err;
}
@@ -107,13 +107,13 @@ Op_RGB_to_RGB24_32::convert_colorspace(const std::shared_ptr<const HeifPixelImag
uint8_t* out_p;
size_t out_p_stride = 0;
- in_r = input->get_plane(heif_channel_R, &in_r_stride);
- in_g = input->get_plane(heif_channel_G, &in_g_stride);
- in_b = input->get_plane(heif_channel_B, &in_b_stride);
- out_p = outimg->get_plane(heif_channel_interleaved, &out_p_stride);
+ in_r = input->get_channel(heif_channel_R, &in_r_stride);
+ in_g = input->get_channel(heif_channel_G, &in_g_stride);
+ in_b = input->get_channel(heif_channel_B, &in_b_stride);
+ out_p = outimg->get_channel(heif_channel_interleaved, &out_p_stride);
if (has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
}
uint32_t x, y;
@@ -235,7 +235,7 @@ Op_RGB_HDR_to_RRGGBBaa_BE::convert_colorspace(const std::shared_ptr<const HeifPi
outimg->create(width, height, heif_colorspace_RGB,
output_has_alpha ? heif_chroma_interleaved_RRGGBBAA_BE : heif_chroma_interleaved_RRGGBB_BE);
- if (auto err = outimg->add_plane(heif_channel_interleaved, width, height, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_interleaved, width, height, bpp, limits)) {
return err;
}
@@ -245,13 +245,13 @@ Op_RGB_HDR_to_RRGGBBaa_BE::convert_colorspace(const std::shared_ptr<const HeifPi
uint8_t* out_p;
size_t out_p_stride = 0;
- in_r = (uint16_t*) input->get_plane(heif_channel_R, &in_r_stride);
- in_g = (uint16_t*) input->get_plane(heif_channel_G, &in_g_stride);
- in_b = (uint16_t*) input->get_plane(heif_channel_B, &in_b_stride);
- out_p = outimg->get_plane(heif_channel_interleaved, &out_p_stride);
+ in_r = (uint16_t*) input->get_channel(heif_channel_R, &in_r_stride);
+ in_g = (uint16_t*) input->get_channel(heif_channel_G, &in_g_stride);
+ in_b = (uint16_t*) input->get_channel(heif_channel_B, &in_b_stride);
+ out_p = outimg->get_channel(heif_channel_interleaved, &out_p_stride);
if (input_has_alpha) {
- in_a = (uint16_t*) input->get_plane(heif_channel_Alpha, &in_a_stride);
+ in_a = (uint16_t*) input->get_channel(heif_channel_Alpha, &in_a_stride);
assert(in_a != nullptr);
// should never happen, but makes clang-tidy happy
@@ -370,7 +370,7 @@ Op_RGB_to_RRGGBBaa_BE::convert_colorspace(const std::shared_ptr<const HeifPixelI
outimg->create(width, height, heif_colorspace_RGB,
output_has_alpha ? heif_chroma_interleaved_RRGGBBAA_BE : heif_chroma_interleaved_RRGGBB_BE);
- if (auto err = outimg->add_plane(heif_channel_interleaved, width, height, input->get_bits_per_pixel(heif_channel_R), limits)) {
+ if (auto err = outimg->add_channel(heif_channel_interleaved, width, height, input->get_bits_per_pixel(heif_channel_R), limits)) {
return err;
}
@@ -380,13 +380,13 @@ Op_RGB_to_RRGGBBaa_BE::convert_colorspace(const std::shared_ptr<const HeifPixelI
uint8_t* out_p;
size_t out_p_stride = 0;
- in_r = input->get_plane(heif_channel_R, &in_r_stride);
- in_g = input->get_plane(heif_channel_G, &in_g_stride);
- in_b = input->get_plane(heif_channel_B, &in_b_stride);
- out_p = outimg->get_plane(heif_channel_interleaved, &out_p_stride);
+ in_r = input->get_channel(heif_channel_R, &in_r_stride);
+ in_g = input->get_channel(heif_channel_G, &in_g_stride);
+ in_b = input->get_channel(heif_channel_B, &in_b_stride);
+ out_p = outimg->get_channel(heif_channel_interleaved, &out_p_stride);
if (input_has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
}
const int pixelsize = (output_has_alpha ? 8 : 6);
@@ -480,14 +480,14 @@ Op_RRGGBBaa_BE_to_RGB_HDR::convert_colorspace(const std::shared_ptr<const HeifPi
outimg->create(width, height, heif_colorspace_RGB, heif_chroma_444);
- if (auto err = outimg->add_plane(heif_channel_R, width, height, bpp, limits) ||
- outimg->add_plane(heif_channel_G, width, height, bpp, limits) ||
- outimg->add_plane(heif_channel_B, width, height, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_R, width, height, bpp, limits) ||
+ outimg->add_channel(heif_channel_G, width, height, bpp, limits) ||
+ outimg->add_channel(heif_channel_B, width, height, bpp, limits)) {
return err;
}
if (want_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, bpp, limits)) {
return err;
}
}
@@ -499,14 +499,14 @@ Op_RRGGBBaa_BE_to_RGB_HDR::convert_colorspace(const std::shared_ptr<const HeifPi
uint16_t* out_r, * out_g, * out_b, * out_a = nullptr;
size_t out_r_stride = 0, out_g_stride = 0, out_b_stride = 0, out_a_stride = 0;
- in_p = input->get_plane(heif_channel_interleaved, &in_p_stride);
+ in_p = input->get_channel(heif_channel_interleaved, &in_p_stride);
- out_r = (uint16_t*) outimg->get_plane(heif_channel_R, &out_r_stride);
- out_g = (uint16_t*) outimg->get_plane(heif_channel_G, &out_g_stride);
- out_b = (uint16_t*) outimg->get_plane(heif_channel_B, &out_b_stride);
+ out_r = (uint16_t*) outimg->get_channel(heif_channel_R, &out_r_stride);
+ out_g = (uint16_t*) outimg->get_channel(heif_channel_G, &out_g_stride);
+ out_b = (uint16_t*) outimg->get_channel(heif_channel_B, &out_b_stride);
if (want_alpha) {
- out_a = (uint16_t*) outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ out_a = (uint16_t*) outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
out_r_stride /= 2;
@@ -595,14 +595,14 @@ Op_RGB24_32_to_RGB::convert_colorspace(const std::shared_ptr<const HeifPixelImag
outimg->create(width, height, heif_colorspace_RGB, heif_chroma_444);
- if (auto err = outimg->add_plane(heif_channel_R, width, height, 8, limits) ||
- outimg->add_plane(heif_channel_G, width, height, 8, limits) ||
- outimg->add_plane(heif_channel_B, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_R, width, height, 8, limits) ||
+ outimg->add_channel(heif_channel_G, width, height, 8, limits) ||
+ outimg->add_channel(heif_channel_B, width, height, 8, limits)) {
return err;
}
if (want_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, 8, limits)) {
return err;
}
}
@@ -614,14 +614,14 @@ Op_RGB24_32_to_RGB::convert_colorspace(const std::shared_ptr<const HeifPixelImag
uint8_t* out_r, * out_g, * out_b, * out_a = nullptr;
size_t out_r_stride = 0, out_g_stride = 0, out_b_stride = 0, out_a_stride = 0;
- in_p = input->get_plane(heif_channel_interleaved, &in_p_stride);
+ in_p = input->get_channel(heif_channel_interleaved, &in_p_stride);
- out_r = outimg->get_plane(heif_channel_R, &out_r_stride);
- out_g = outimg->get_plane(heif_channel_G, &out_g_stride);
- out_b = outimg->get_plane(heif_channel_B, &out_b_stride);
+ out_r = outimg->get_channel(heif_channel_R, &out_r_stride);
+ out_g = outimg->get_channel(heif_channel_G, &out_g_stride);
+ out_b = outimg->get_channel(heif_channel_B, &out_b_stride);
if (want_alpha) {
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
uint32_t x, y;
@@ -736,7 +736,7 @@ Op_RRGGBBaa_swap_endianness::convert_colorspace(const std::shared_ptr<const Heif
return Error::InternalError;
}
- if (auto err = outimg->add_plane(heif_channel_interleaved, width, height,
+ if (auto err = outimg->add_channel(heif_channel_interleaved, width, height,
input->get_bits_per_pixel(heif_channel_interleaved), limits)) {
return err;
}
@@ -747,8 +747,8 @@ Op_RRGGBBaa_swap_endianness::convert_colorspace(const std::shared_ptr<const Heif
uint8_t* out_p;
size_t out_p_stride = 0;
- in_p = input->get_plane(heif_channel_interleaved, &in_p_stride);
- out_p = outimg->get_plane(heif_channel_interleaved, &out_p_stride);
+ in_p = input->get_channel(heif_channel_interleaved, &in_p_stride);
+ out_p = outimg->get_channel(heif_channel_interleaved, &out_p_stride);
size_t n_bytes = std::min(in_p_stride, out_p_stride);
diff --git a/libheif/color-conversion/rgb2yuv.cc b/libheif/color-conversion/rgb2yuv.cc
index d8132b2f..ae854bd0 100644
--- a/libheif/color-conversion/rgb2yuv.cc
+++ b/libheif/color-conversion/rgb2yuv.cc
@@ -130,14 +130,14 @@ Op_RGB_to_YCbCr<Pixel>::convert_colorspace(const std::shared_ptr<const HeifPixel
uint32_t cwidth = (width + subH - 1) / subH;
uint32_t cheight = (height + subV - 1) / subV;
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, bpp, limits) ||
- outimg->add_plane(heif_channel_Cb, cwidth, cheight, bpp, limits) ||
- outimg->add_plane(heif_channel_Cr, cwidth, cheight, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, bpp, limits) ||
+ outimg->add_channel(heif_channel_Cb, cwidth, cheight, bpp, limits) ||
+ outimg->add_channel(heif_channel_Cr, cwidth, cheight, bpp, limits)) {
return err;
}
if (has_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, bpp, limits)) {
return err;
}
}
@@ -148,19 +148,19 @@ Op_RGB_to_YCbCr<Pixel>::convert_colorspace(const std::shared_ptr<const HeifPixel
Pixel* out_y, * out_cb, * out_cr;
size_t out_y_stride = 0, out_cb_stride = 0, out_cr_stride = 0, out_a_stride = 0;
- in_r = (const Pixel*) input->get_plane(heif_channel_R, &in_r_stride);
- in_g = (const Pixel*) input->get_plane(heif_channel_G, &in_g_stride);
- in_b = (const Pixel*) input->get_plane(heif_channel_B, &in_b_stride);
- out_y = (Pixel*) outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = (Pixel*) outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = (Pixel*) outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ in_r = (const Pixel*) input->get_channel(heif_channel_R, &in_r_stride);
+ in_g = (const Pixel*) input->get_channel(heif_channel_G, &in_g_stride);
+ in_b = (const Pixel*) input->get_channel(heif_channel_B, &in_b_stride);
+ out_y = (Pixel*) outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = (Pixel*) outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = (Pixel*) outimg->get_channel(heif_channel_Cr, &out_cr_stride);
const uint8_t* in_a;
uint8_t* out_a;
if (has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
else {
in_a = nullptr;
@@ -385,14 +385,14 @@ Op_RRGGBBxx_HDR_to_YCbCr420::convert_colorspace(const std::shared_ptr<const Heif
uint32_t cwidth = (width + 1) / 2;
uint32_t cheight = (height + 1) / 2;
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, bpp, limits) ||
- outimg->add_plane(heif_channel_Cb, cwidth, cheight, bpp, limits) ||
- outimg->add_plane(heif_channel_Cr, cwidth, cheight, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, bpp, limits) ||
+ outimg->add_channel(heif_channel_Cb, cwidth, cheight, bpp, limits) ||
+ outimg->add_channel(heif_channel_Cr, cwidth, cheight, bpp, limits)) {
return err;
}
if (has_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, bpp, limits)) {
return err;
}
}
@@ -403,13 +403,13 @@ Op_RRGGBBxx_HDR_to_YCbCr420::convert_colorspace(const std::shared_ptr<const Heif
uint16_t* out_y, * out_cb, * out_cr, * out_a = nullptr;
size_t out_y_stride = 0, out_cb_stride = 0, out_cr_stride = 0, out_a_stride = 0;
- in_p = input->get_plane(heif_channel_interleaved, &in_p_stride);
- out_y = (uint16_t*) outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = (uint16_t*) outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = (uint16_t*) outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ in_p = input->get_channel(heif_channel_interleaved, &in_p_stride);
+ out_y = (uint16_t*) outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = (uint16_t*) outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = (uint16_t*) outimg->get_channel(heif_channel_Cr, &out_cr_stride);
if (has_alpha) {
- out_a = (uint16_t*) outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ out_a = (uint16_t*) outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
@@ -594,14 +594,14 @@ Op_RGB24_32_to_YCbCr::convert_colorspace(const std::shared_ptr<const HeifPixelIm
const bool has_alpha = (input->get_chroma_format() == heif_chroma_interleaved_32bit);
const bool want_alpha = target_state.has_alpha;
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, 8, limits) ||
- outimg->add_plane(heif_channel_Cb, chroma_width, chroma_height, 8, limits) ||
- outimg->add_plane(heif_channel_Cr, chroma_width, chroma_height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, 8, limits) ||
+ outimg->add_channel(heif_channel_Cb, chroma_width, chroma_height, 8, limits) ||
+ outimg->add_channel(heif_channel_Cr, chroma_width, chroma_height, 8, limits)) {
return err;
}
if (want_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, 8, limits)) {
return err;
}
}
@@ -612,14 +612,14 @@ Op_RGB24_32_to_YCbCr::convert_colorspace(const std::shared_ptr<const HeifPixelIm
const uint8_t* in_p;
size_t in_stride = 0;
- in_p = input->get_plane(heif_channel_interleaved, &in_stride);
+ in_p = input->get_channel(heif_channel_interleaved, &in_stride);
- out_y = outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ out_y = outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = outimg->get_channel(heif_channel_Cr, &out_cr_stride);
if (want_alpha) {
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
else {
out_a = nullptr;
@@ -862,14 +862,14 @@ Op_RGB24_32_to_YCbCr444_GBR::convert_colorspace(const std::shared_ptr<const Heif
const bool has_alpha = (input->get_chroma_format() == heif_chroma_interleaved_32bit);
const bool want_alpha = target_state.has_alpha;
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, 8, limits) ||
- outimg->add_plane(heif_channel_Cb, width, height, 8, limits) ||
- outimg->add_plane(heif_channel_Cr, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, 8, limits) ||
+ outimg->add_channel(heif_channel_Cb, width, height, 8, limits) ||
+ outimg->add_channel(heif_channel_Cr, width, height, 8, limits)) {
return err;
}
if (want_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, 8, limits)) {
return err;
}
}
@@ -880,14 +880,14 @@ Op_RGB24_32_to_YCbCr444_GBR::convert_colorspace(const std::shared_ptr<const Heif
const uint8_t* in_p;
size_t in_stride = 0;
- in_p = input->get_plane(heif_channel_interleaved, &in_stride);
+ in_p = input->get_channel(heif_channel_interleaved, &in_stride);
- out_y = outimg->get_plane(heif_channel_Y, &out_y_stride);
- out_cb = outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- out_cr = outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ out_y = outimg->get_channel(heif_channel_Y, &out_y_stride);
+ out_cb = outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ out_cr = outimg->get_channel(heif_channel_Cr, &out_cr_stride);
if (want_alpha) {
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
diff --git a/libheif/color-conversion/rgb2yuv_sharp.cc b/libheif/color-conversion/rgb2yuv_sharp.cc
index d24b6608..aad638af 100644
--- a/libheif/color-conversion/rgb2yuv_sharp.cc
+++ b/libheif/color-conversion/rgb2yuv_sharp.cc
@@ -157,14 +157,14 @@ Op_Any_RGB_to_YCbCr_420_Sharp::convert_colorspace(
bool want_alpha = target_state.has_alpha;
int output_bits = target_state.bits_per_pixel;
- if (auto err = outimg->add_plane(heif_channel_Y, width, height, output_bits, limits) ||
- outimg->add_plane(heif_channel_Cb, chroma_width, chroma_height, output_bits, limits) ||
- outimg->add_plane(heif_channel_Cr, chroma_width, chroma_height, output_bits, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Y, width, height, output_bits, limits) ||
+ outimg->add_channel(heif_channel_Cb, chroma_width, chroma_height, output_bits, limits) ||
+ outimg->add_channel(heif_channel_Cr, chroma_width, chroma_height, output_bits, limits)) {
return err;
}
if (want_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, output_bits, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, output_bits, limits)) {
return err;
}
}
@@ -184,9 +184,9 @@ Op_Any_RGB_to_YCbCr_420_Sharp::convert_colorspace(
int input_bits = 0;
if (planar_input) {
size_t in_r_stride = 0, in_g_stride = 0, in_b_stride = 0;
- in_r = input->get_plane(heif_channel_R, &in_r_stride);
- in_g = input->get_plane(heif_channel_G, &in_g_stride);
- in_b = input->get_plane(heif_channel_B, &in_b_stride);
+ in_r = input->get_channel(heif_channel_R, &in_r_stride);
+ in_g = input->get_channel(heif_channel_G, &in_g_stride);
+ in_b = input->get_channel(heif_channel_B, &in_b_stride);
// The stride must be the same for all channels.
if (in_r_stride != in_g_stride || in_r_stride != in_b_stride) {
return Error::InternalError;
@@ -199,11 +199,11 @@ Op_Any_RGB_to_YCbCr_420_Sharp::convert_colorspace(
return Error::InternalError;
}
if (has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
}
}
else {
- const uint8_t* in_p = input->get_plane(heif_channel_interleaved, &in_stride);
+ const uint8_t* in_p = input->get_channel(heif_channel_interleaved, &in_stride);
input_bits = input->get_bits_per_pixel(heif_channel_interleaved);
in_r = &in_p[input_bytes_per_sample * 0];
in_g = &in_p[input_bytes_per_sample * 1];
@@ -215,9 +215,9 @@ Op_Any_RGB_to_YCbCr_420_Sharp::convert_colorspace(
}
size_t out_cb_stride = 0, out_cr_stride = 0, out_y_stride = 0;
- uint8_t* out_y = outimg->get_plane(heif_channel_Y, &out_y_stride);
- uint8_t* out_cb = outimg->get_plane(heif_channel_Cb, &out_cb_stride);
- uint8_t* out_cr = outimg->get_plane(heif_channel_Cr, &out_cr_stride);
+ uint8_t* out_y = outimg->get_channel(heif_channel_Y, &out_y_stride);
+ uint8_t* out_cb = outimg->get_channel(heif_channel_Cb, &out_cb_stride);
+ uint8_t* out_cr = outimg->get_channel(heif_channel_Cr, &out_cr_stride);
bool full_range_flag = true;
Kr_Kb kr_kb = Kr_Kb::defaults();
@@ -253,7 +253,7 @@ Op_Any_RGB_to_YCbCr_420_Sharp::convert_colorspace(
: 0;
size_t out_a_stride;
- uint8_t* out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ uint8_t* out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
uint16_t alpha_max = static_cast<uint16_t>((1 << input_bits) - 1);
for (uint32_t y = 0; y < height; y++) {
for (uint32_t x = 0; x < width; x++) {
diff --git a/libheif/color-conversion/yuv2rgb.cc b/libheif/color-conversion/yuv2rgb.cc
index b9d33190..de589b07 100644
--- a/libheif/color-conversion/yuv2rgb.cc
+++ b/libheif/color-conversion/yuv2rgb.cc
@@ -141,14 +141,14 @@ Op_YCbCr_to_RGB<Pixel>::convert_colorspace(const std::shared_ptr<const HeifPixel
outimg->create(width, height, heif_colorspace_RGB, heif_chroma_444);
- if (auto err = outimg->add_plane(heif_channel_R, width, height, bpp_y, limits) ||
- outimg->add_plane(heif_channel_G, width, height, bpp_y, limits) ||
- outimg->add_plane(heif_channel_B, width, height, bpp_y, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_R, width, height, bpp_y, limits) ||
+ outimg->add_channel(heif_channel_G, width, height, bpp_y, limits) ||
+ outimg->add_channel(heif_channel_B, width, height, bpp_y, limits)) {
return err;
}
if (has_alpha) {
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp_a, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, bpp_a, limits)) {
return err;
}
}
@@ -159,12 +159,12 @@ Op_YCbCr_to_RGB<Pixel>::convert_colorspace(const std::shared_ptr<const HeifPixel
Pixel* out_r, * out_g, * out_b;
size_t out_r_stride = 0, out_g_stride = 0, out_b_stride = 0, out_a_stride = 0;
- in_y = (const Pixel*) input->get_plane(heif_channel_Y, &in_y_stride);
- in_cb = (const Pixel*) input->get_plane(heif_channel_Cb, &in_cb_stride);
- in_cr = (const Pixel*) input->get_plane(heif_channel_Cr, &in_cr_stride);
- out_r = (Pixel*) outimg->get_plane(heif_channel_R, &out_r_stride);
- out_g = (Pixel*) outimg->get_plane(heif_channel_G, &out_g_stride);
- out_b = (Pixel*) outimg->get_plane(heif_channel_B, &out_b_stride);
+ in_y = (const Pixel*) input->get_channel(heif_channel_Y, &in_y_stride);
+ in_cb = (const Pixel*) input->get_channel(heif_channel_Cb, &in_cb_stride);
+ in_cr = (const Pixel*) input->get_channel(heif_channel_Cr, &in_cr_stride);
+ out_r = (Pixel*) outimg->get_channel(heif_channel_R, &out_r_stride);
+ out_g = (Pixel*) outimg->get_channel(heif_channel_G, &out_g_stride);
+ out_b = (Pixel*) outimg->get_channel(heif_channel_B, &out_b_stride);
// We only copy the alpha, do not access it as 16 bit
@@ -172,8 +172,8 @@ Op_YCbCr_to_RGB<Pixel>::convert_colorspace(const std::shared_ptr<const HeifPixel
uint8_t* out_a;
if (has_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
- out_a = outimg->get_plane(heif_channel_Alpha, &out_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
+ out_a = outimg->get_channel(heif_channel_Alpha, &out_a_stride);
}
else {
in_a = nullptr;
@@ -361,7 +361,7 @@ Op_YCbCr420_to_RGB24::convert_colorspace(const std::shared_ptr<const HeifPixelIm
outimg->create(width, height, heif_colorspace_RGB, heif_chroma_interleaved_24bit);
- if (auto err = outimg->add_plane(heif_channel_interleaved, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_interleaved, width, height, 8, limits)) {
return err;
}
@@ -383,10 +383,10 @@ Op_YCbCr420_to_RGB24::convert_colorspace(const std::shared_ptr<const HeifPixelIm
uint8_t* out_p;
size_t out_p_stride = 0;
- in_y = input->get_plane(heif_channel_Y, &in_y_stride);
- in_cb = input->get_plane(heif_channel_Cb, &in_cb_stride);
- in_cr = input->get_plane(heif_channel_Cr, &in_cr_stride);
- out_p = outimg->get_plane(heif_channel_interleaved, &out_p_stride);
+ in_y = input->get_channel(heif_channel_Y, &in_y_stride);
+ in_cb = input->get_channel(heif_channel_Cb, &in_cb_stride);
+ in_cr = input->get_channel(heif_channel_Cr, &in_cr_stride);
+ out_p = outimg->get_channel(heif_channel_interleaved, &out_p_stride);
uint32_t x, y;
for (y = 0; y < height; y++) {
@@ -497,7 +497,7 @@ Op_YCbCr420_to_RGB32::convert_colorspace(const std::shared_ptr<const HeifPixelIm
outimg->create(width, height, heif_colorspace_RGB, heif_chroma_interleaved_32bit);
- if (auto err = outimg->add_plane(heif_channel_interleaved, width, height, 8, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_interleaved, width, height, 8, limits)) {
return err;
}
@@ -525,14 +525,14 @@ Op_YCbCr420_to_RGB32::convert_colorspace(const std::shared_ptr<const HeifPixelIm
uint8_t* out_p;
size_t out_p_stride = 0;
- in_y = input->get_plane(heif_channel_Y, &in_y_stride);
- in_cb = input->get_plane(heif_channel_Cb, &in_cb_stride);
- in_cr = input->get_plane(heif_channel_Cr, &in_cr_stride);
+ in_y = input->get_channel(heif_channel_Y, &in_y_stride);
+ in_cb = input->get_channel(heif_channel_Cb, &in_cb_stride);
+ in_cr = input->get_channel(heif_channel_Cr, &in_cr_stride);
if (with_alpha) {
- in_a = input->get_plane(heif_channel_Alpha, &in_a_stride);
+ in_a = input->get_channel(heif_channel_Alpha, &in_a_stride);
}
- out_p = outimg->get_plane(heif_channel_interleaved, &out_p_stride);
+ out_p = outimg->get_channel(heif_channel_interleaved, &out_p_stride);
uint32_t x, y;
for (y = 0; y < height; y++) {
@@ -639,7 +639,7 @@ Op_YCbCr420_to_RRGGBBaa::convert_colorspace(const std::shared_ptr<const HeifPixe
int bytesPerPixel = has_alpha ? 8 : 6;
- if (auto err = outimg->add_plane(heif_channel_interleaved, width, height, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_interleaved, width, height, bpp, limits)) {
return err;
}
@@ -661,7 +661,7 @@ Op_YCbCr420_to_RRGGBBaa::convert_colorspace(const std::shared_ptr<const HeifPixe
};
}
- if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp, limits)) {
+ if (auto err = outimg->add_channel(heif_channel_Alpha, width, height, bpp, limits)) {
return err;
}
}
@@ -672,13 +672,13 @@ Op_YCbCr420_to_RRGGBBaa::convert_colorspace(const std::shared_ptr<const HeifPixe
const uint16_t* in_y, * in_cb, * in_cr, * in_a = nullptr;
size_t in_y_stride = 0, in_cb_stride = 0, in_cr_stride = 0, in_a_stride = 0;
- out_p = outimg->get_plane(heif_channel_interleaved, &out_p_stride);
- in_y = (uint16_t*) input->get_plane(heif_channel_Y, &in_y_stride);
- in_cb = (uint16_t*) input->get_plane(heif_channel_Cb, &in_cb_stride);
- in_cr = (uint16_t*) input->get_plane(heif_channel_Cr, &in_cr_stride);
+ out_p = outimg->get_channel(heif_channel_interleaved, &out_p_stride);
+ in_y = (uint16_t*) input->get_channel(heif_channel_Y, &in_y_stride);
+ in_cb = (uint16_t*) input->get_channel(heif_channel_Cb, &in_cb_stride);
+ in_cr = (uint16_t*) input->get_channel(heif_channel_Cr, &in_cr_stride);
if (has_alpha) {
- in_a = (uint16_t*) input->get_plane(heif_channel_Alpha, &in_a_stride);
+ in_a = (uint16_t*) input->get_channel(heif_channel_Alpha, &in_a_stride);
}
int maxval = (1 << bpp) - 1;
diff --git a/libheif/context.cc b/libheif/context.cc
index d7ae2584..7ccca778 100644
--- a/libheif/context.cc
+++ b/libheif/context.cc
@@ -1550,7 +1550,7 @@ create_alpha_image_from_image_alpha_channel(const std::shared_ptr<HeifPixelImage
heif_colorspace_monochrome, heif_chroma_monochrome);
if (image->has_channel(heif_channel_Alpha)) {
- alpha_image->copy_new_plane_from(image, heif_channel_Alpha, heif_channel_Y, limits);
+ alpha_image->copy_new_channel_from(image, heif_channel_Alpha, heif_channel_Y, limits);
}
else if (image->get_chroma_format() == heif_chroma_interleaved_RGBA) {
if (auto err = alpha_image->extract_alpha_from_RGBA(image, limits)) {
diff --git a/libheif/image-items/grid.cc b/libheif/image-items/grid.cc
index a0c25e51..cf22d877 100644
--- a/libheif/image-items/grid.cc
+++ b/libheif/image-items/grid.cc
@@ -552,7 +552,7 @@ Error ImageItem_Grid::decode_and_paste_tile_image(heif_item_id tileID, uint32_t
assert(alpha_bpp <= 16);
auto alpha_default_value = static_cast<uint16_t>((1UL << alpha_bpp) - 1UL);
- grid_image->fill_plane(heif_channel_Alpha, alpha_default_value);
+ grid_image->fill_channel(heif_channel_Alpha, alpha_default_value);
}
grid_image->copy_metadata_from(*tile_img);
diff --git a/libheif/image-items/image_item.cc b/libheif/image-items/image_item.cc
index de56d7f1..f8b66498 100644
--- a/libheif/image-items/image_item.cc
+++ b/libheif/image-items/image_item.cc
@@ -1018,7 +1018,7 @@ Result<std::shared_ptr<HeifPixelImage>> ImageItem::decode_image(const heif_decod
}
alpha = std::move(scaled_alpha);
}
- img->transfer_plane_from_image_as(alpha, channel, heif_channel_Alpha);
+ img->transfer_channel_from_image_as(alpha, channel, heif_channel_Alpha);
if (is_premultiplied_alpha()) {
img->set_premultiplied_alpha(true);
diff --git a/libheif/image-items/image_item.h b/libheif/image-items/image_item.h
index 1ba32594..de4401cb 100644
--- a/libheif/image-items/image_item.h
+++ b/libheif/image-items/image_item.h
@@ -115,7 +115,7 @@ public:
// Idempotent: skips work if m_components is already populated.
// Alpha-from-aux (separate alpha item linked via auxl) is *not* emitted
// here; the alpha plane is attached at decode time via
- // transfer_plane_from_image_as, which mints its own component on the
+ // transfer_channel_from_image_as, which mints its own component on the
// destination.
virtual void populate_component_descriptions();
diff --git a/libheif/image-items/mask_image.cc b/libheif/image-items/mask_image.cc
index ae783da1..146c6a6b 100644
--- a/libheif/image-items/mask_image.cc
+++ b/libheif/image-items/mask_image.cc
@@ -102,14 +102,14 @@ Error MaskImageCodec::decode_mask_image(const HeifContext* context,
img = std::make_shared<HeifPixelImage>();
img->create(width, height, heif_colorspace_monochrome, heif_chroma_monochrome);
- auto err = img->add_plane(heif_channel_Y, width, height, mskC->get_bits_per_pixel(),
+ auto err = img->add_channel(heif_channel_Y, width, height, mskC->get_bits_per_pixel(),
context->get_security_limits());
if (err) {
return err;
}
size_t stride;
- uint8_t* dst = img->get_plane(heif_channel_Y, &stride);
+ uint8_t* dst = img->get_channel(heif_channel_Y, &stride);
if (stride == static_cast<size_t>(width) * bytes_per_pixel) {
memcpy(dst, data.data(), static_cast<size_t>(width) * bytes_per_pixel * height);
}
@@ -176,7 +176,7 @@ Result<Encoder::CodedImageData> ImageItem_mask::encode(const std::shared_ptr<Hei
// TODO: we could add an option to lossless-compress this data
std::vector<uint8_t> data;
size_t src_stride;
- uint8_t* src_data = image->get_plane(heif_channel_Y, &src_stride);
+ uint8_t* src_data = image->get_channel(heif_channel_Y, &src_stride);
uint32_t w = image->get_width();
uint32_t h = image->get_height();
diff --git a/libheif/image-items/overlay.cc b/libheif/image-items/overlay.cc
index dfbf68aa..5073c92f 100644
--- a/libheif/image-items/overlay.cc
+++ b/libheif/image-items/overlay.cc
@@ -307,13 +307,13 @@ Result<std::shared_ptr<HeifPixelImage>> ImageItem_Overlay::decode_overlay_image(
img->create(w, h,
heif_colorspace_RGB,
heif_chroma_444);
- if (auto error = img->add_plane(heif_channel_R, w, h, 8, get_context()->get_security_limits())) { // TODO: other bit depths
+ if (auto error = img->add_channel(heif_channel_R, w, h, 8, get_context()->get_security_limits())) { // TODO: other bit depths
return error;
}
- if (auto error = img->add_plane(heif_channel_G, w, h, 8, get_context()->get_security_limits())) { // TODO: other bit depths
+ if (auto error = img->add_channel(heif_channel_G, w, h, 8, get_context()->get_security_limits())) { // TODO: other bit depths
return error;
}
- if (auto error = img->add_plane(heif_channel_B, w, h, 8, get_context()->get_security_limits())) { // TODO: other bit depths
+ if (auto error = img->add_channel(heif_channel_B, w, h, 8, get_context()->get_security_limits())) { // TODO: other bit depths
return error;
}
diff --git a/libheif/image/image_description.h b/libheif/image/image_description.h
index e3cec27d..fd15fdb6 100644
--- a/libheif/image/image_description.h
+++ b/libheif/image/image_description.h
@@ -131,7 +131,7 @@ heif_channel map_uncompressed_component_to_channel(uint16_t component_type);
// and HeifPixelImage (decoded side) can carry the same structural view.
struct ComponentDescription
{
- uint32_t component_id = 0; // stable id, matches HeifPixelImage::m_planes ids
+ 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_*
@@ -289,7 +289,7 @@ public:
// Append a ComponentDescription. The caller is expected to have set
// component_id, either from a fresh mint_component_id() call or by
// matching an id already used by a parallel structure (e.g.
- // HeifPixelImage::ImageComponent::m_component_ids).
+ // HeifPixelImage::ComponentStorage::m_component_ids).
void add_component_description(ComponentDescription desc)
{
m_components.push_back(std::move(desc));
@@ -423,7 +423,7 @@ public:
// id, bayer pattern, polarization patterns, sensor maps, sensor nuc, chroma
// location, omaf projection). Per-component descriptions
// (m_components / m_next_component_id) are intentionally not copied; those
- // are managed separately by callers (via add_plane / add_component, or
+ // are managed separately by callers (via add_channel / add_component, or
// set_component_descriptions on the destination).
//
// Bayer / polarization / sensor-map metadata refers to image geometry;
diff --git a/libheif/image/pixelimage.cc b/libheif/image/pixelimage.cc
index 62c0a2cb..0182c820 100644
--- a/libheif/image/pixelimage.cc
+++ b/libheif/image/pixelimage.cc
@@ -154,15 +154,15 @@ static std::vector<uint16_t> map_channel_to_component_type(heif_channel channel,
HeifPixelImage::~HeifPixelImage()
{
- for (auto& component : m_planes) {
+ for (auto& component : m_storage) {
delete[] component.allocated_mem;
}
}
-HeifPixelImage::ImageComponent* HeifPixelImage::find_component_for_channel(heif_channel channel)
+HeifPixelImage::ComponentStorage* HeifPixelImage::find_storage_for_channel(heif_channel channel)
{
- for (auto& component : m_planes) {
+ for (auto& component : m_storage) {
if (component.m_channel == channel) {
return &component;
}
@@ -170,9 +170,9 @@ HeifPixelImage::ImageComponent* HeifPixelImage::find_component_for_channel(heif_
return nullptr;
}
-const HeifPixelImage::ImageComponent* HeifPixelImage::find_component_for_channel(heif_channel channel) const
+const HeifPixelImage::ComponentStorage* HeifPixelImage::find_storage_for_channel(heif_channel channel) const
{
- for (const auto& component : m_planes) {
+ for (const auto& component : m_storage) {
if (component.m_channel == channel) {
return &component;
}
@@ -295,7 +295,7 @@ static uint32_t rounded_size(uint32_t s)
return s;
}
-void HeifPixelImage::register_plane_descriptions(ImageComponent& plane,
+void HeifPixelImage::register_component_descriptions(ComponentStorage& plane,
const std::vector<uint16_t>& component_types)
{
for (uint16_t type : component_types) {
@@ -316,7 +316,7 @@ void HeifPixelImage::register_plane_descriptions(ImageComponent& plane,
}
-void HeifPixelImage::register_plane_descriptions(ImageComponent& plane,
+void HeifPixelImage::register_component_descriptions(ComponentStorage& plane,
const std::vector<const ComponentDescription*>& source_descriptions)
{
for (const ComponentDescription* src : source_descriptions) {
@@ -342,7 +342,7 @@ void HeifPixelImage::register_plane_descriptions(ImageComponent& plane,
}
-Error HeifPixelImage::add_plane(heif_channel channel, uint32_t width, uint32_t height, int bit_depth,
+Error HeifPixelImage::add_channel(heif_channel channel, uint32_t width, uint32_t height, int bit_depth,
const heif_security_limits* limits,
heif_component_datatype datatype)
{
@@ -358,20 +358,20 @@ Error HeifPixelImage::add_plane(heif_channel channel, uint32_t width, uint32_t h
int num_interleaved_pixels = num_interleaved_components_per_plane(m_chroma);
- ImageComponent plane;
+ ComponentStorage plane;
plane.m_channel = channel;
if (auto err = plane.alloc(width, height, datatype, bit_depth, num_interleaved_pixels, limits, m_memory_handle)) {
return err;
}
- register_plane_descriptions(plane, map_channel_to_component_type(channel, m_chroma));
- m_planes.push_back(std::move(plane));
+ register_component_descriptions(plane, map_channel_to_component_type(channel, m_chroma));
+ m_storage.push_back(std::move(plane));
return Error::Ok;
}
-Error HeifPixelImage::ImageComponent::alloc(uint32_t width, uint32_t height, heif_component_datatype datatype, int bit_depth,
+Error HeifPixelImage::ComponentStorage::alloc(uint32_t width, uint32_t height, heif_component_datatype datatype, int bit_depth,
int num_interleaved_components,
const heif_security_limits* limits,
MemoryHandle& memory_handle)
@@ -487,7 +487,7 @@ Error HeifPixelImage::ImageComponent::alloc(uint32_t width, uint32_t height, hei
Error HeifPixelImage::extend_padding_to_size(uint32_t width, uint32_t height, bool adjust_size,
const heif_security_limits* limits)
{
- for (auto& component : m_planes) {
+ for (auto& component : m_storage) {
uint32_t subsampled_width, subsampled_height;
get_subsampled_size(width, height, component.m_channel, m_chroma,
&subsampled_width, &subsampled_height);
@@ -500,7 +500,7 @@ Error HeifPixelImage::extend_padding_to_size(uint32_t width, uint32_t height, bo
if (component.m_mem_width < subsampled_width ||
component.m_mem_height < subsampled_height) {
- ImageComponent newPlane;
+ ComponentStorage newPlane;
newPlane.m_channel = component.m_channel;
newPlane.m_component_ids = component.m_component_ids;
if (auto err = newPlane.alloc(subsampled_width, subsampled_height, component.m_datatype, component.m_bit_depth,
@@ -564,7 +564,7 @@ Error HeifPixelImage::extend_padding_to_size(uint32_t width, uint32_t height, bo
Error HeifPixelImage::extend_to_size_with_zero(uint32_t width, uint32_t height, const heif_security_limits* limits)
{
- for (auto& component : m_planes) {
+ for (auto& component : m_storage) {
uint32_t subsampled_width, subsampled_height;
get_subsampled_size(width, height, component.m_channel, m_chroma,
&subsampled_width, &subsampled_height);
@@ -577,7 +577,7 @@ Error HeifPixelImage::extend_to_size_with_zero(uint32_t width, uint32_t height,
if (component.m_mem_width < subsampled_width ||
component.m_mem_height < subsampled_height) {
- ImageComponent newPlane;
+ ComponentStorage newPlane;
newPlane.m_channel = component.m_channel;
newPlane.m_component_ids = component.m_component_ids;
if (auto err = newPlane.alloc(subsampled_width, subsampled_height, component.m_datatype, component.m_bit_depth, num_interleaved_components_per_plane(m_chroma), limits, m_memory_handle)) {
@@ -640,7 +640,7 @@ Error HeifPixelImage::extend_to_size_with_zero(uint32_t width, uint32_t height,
bool HeifPixelImage::has_channel(heif_channel channel) const
{
- return find_component_for_channel(channel) != nullptr;
+ return find_storage_for_channel(channel) != nullptr;
}
@@ -655,7 +655,7 @@ bool HeifPixelImage::has_alpha() const
uint32_t HeifPixelImage::get_width(heif_channel channel) const
{
- auto* comp = find_component_for_channel(channel);
+ auto* comp = find_storage_for_channel(channel);
if (!comp) {
return 0;
}
@@ -666,7 +666,7 @@ uint32_t HeifPixelImage::get_width(heif_channel channel) const
uint32_t HeifPixelImage::get_height(heif_channel channel) const
{
- auto* comp = find_component_for_channel(channel);
+ auto* comp = find_storage_for_channel(channel);
if (!comp) {
return 0;
}
@@ -677,7 +677,7 @@ uint32_t HeifPixelImage::get_height(heif_channel channel) const
uint32_t HeifPixelImage::get_width(uint32_t component_id) const
{
- auto* comp = find_component_by_id(component_id);
+ auto* comp = find_storage_for_component(component_id);
if (!comp) {
return 0;
}
@@ -688,7 +688,7 @@ uint32_t HeifPixelImage::get_width(uint32_t component_id) const
uint32_t HeifPixelImage::get_height(uint32_t component_id) const
{
- auto* comp = find_component_by_id(component_id);
+ auto* comp = find_storage_for_component(component_id);
if (!comp) {
return 0;
}
@@ -701,15 +701,15 @@ uint32_t HeifPixelImage::get_primary_component_id() const
{
// first pass: search for a visual channel
- for (uint32_t idx=0; idx<m_planes.size(); idx++) {
- switch (m_planes[idx].m_channel) {
+ for (uint32_t idx=0; idx<m_storage.size(); idx++) {
+ switch (m_storage[idx].m_channel) {
case heif_channel_interleaved:
case heif_channel_Y:
case heif_channel_R:
case heif_channel_G:
case heif_channel_B:
case heif_channel_filter_array:
- return m_planes[idx].m_component_ids[0];
+ return m_storage[idx].m_component_ids[0];
default:
; // NOP
}
@@ -717,8 +717,8 @@ uint32_t HeifPixelImage::get_primary_component_id() const
// second pass: if we have a cmpd table, use component types
- for (uint32_t idx = 0; idx < m_planes.size(); idx++) {
- uint16_t comp_type = get_component_type(m_planes[idx].m_component_ids[0]);
+ for (uint32_t idx = 0; idx < m_storage.size(); idx++) {
+ uint16_t comp_type = get_component_type(m_storage[idx].m_component_ids[0]);
switch (comp_type) {
case heif_unci_component_type_Y:
case heif_unci_component_type_monochrome:
@@ -731,7 +731,7 @@ uint32_t HeifPixelImage::get_primary_component_id() const
case heif_unci_component_type_key_black:
case heif_unci_component_type_filter_array:
case heif_unci_component_type_palette:
- return m_planes[idx].m_component_ids[0];
+ return m_storage[idx].m_component_ids[0];
default:
; // NOP
@@ -740,8 +740,8 @@ uint32_t HeifPixelImage::get_primary_component_id() const
// third pass: allow anything
- if (!m_planes.empty()) {
- return m_planes[0].m_component_ids[0];
+ if (!m_storage.empty()) {
+ return m_storage[0].m_component_ids[0];
}
return 0; // invalid component ID
@@ -784,7 +784,7 @@ std::set<heif_channel> HeifPixelImage::get_channel_set() const
{
std::set<heif_channel> channels;
- for (const auto& component : m_planes) {
+ for (const auto& component : m_storage) {
channels.insert(component.m_channel);
}
@@ -794,7 +794,7 @@ std::set<heif_channel> HeifPixelImage::get_channel_set() const
uint16_t HeifPixelImage::get_storage_bits_per_pixel(enum heif_channel channel) const
{
- auto* comp = find_component_for_channel(channel);
+ auto* comp = find_storage_for_channel(channel);
if (!comp) {
return -1;
}
@@ -807,7 +807,7 @@ uint16_t HeifPixelImage::get_storage_bits_per_pixel(enum heif_channel channel) c
uint16_t HeifPixelImage::get_bits_per_pixel(enum heif_channel channel) const
{
- auto* comp = find_component_for_channel(channel);
+ auto* comp = find_storage_for_channel(channel);
if (!comp) {
return -1;
}
@@ -854,7 +854,7 @@ uint16_t HeifPixelImage::get_visual_image_bits_per_pixel() const
heif_component_datatype HeifPixelImage::get_datatype(heif_channel channel) const
{
- auto* comp = find_component_for_channel(channel);
+ auto* comp = find_storage_for_channel(channel);
if (!comp) {
return heif_component_datatype_undefined;
}
@@ -865,7 +865,7 @@ heif_component_datatype HeifPixelImage::get_datatype(heif_channel channel) const
int HeifPixelImage::get_number_of_interleaved_components(heif_channel channel) const
{
- auto* comp = find_component_for_channel(channel);
+ auto* comp = find_storage_for_channel(channel);
if (!comp) {
return 0;
}
@@ -874,7 +874,7 @@ int HeifPixelImage::get_number_of_interleaved_components(heif_channel channel) c
}
-Error HeifPixelImage::copy_new_plane_from(const std::shared_ptr<const HeifPixelImage>& src_image,
+Error HeifPixelImage::copy_new_channel_from(const std::shared_ptr<const HeifPixelImage>& src_image,
heif_channel src_channel,
heif_channel dst_channel,
const heif_security_limits* limits)
@@ -885,11 +885,11 @@ Error HeifPixelImage::copy_new_plane_from(const std::shared_ptr<const HeifPixelI
uint32_t width = src_image->get_width(src_channel);
uint32_t height = src_image->get_height(src_channel);
- const auto* src_plane_ptr = src_image->find_component_for_channel(src_channel);
+ const auto* src_plane_ptr = src_image->find_storage_for_channel(src_channel);
assert(src_plane_ptr != nullptr);
const auto& src_plane = *src_plane_ptr;
- auto err = add_plane(dst_channel, width, height,
+ auto err = add_channel(dst_channel, width, height,
src_image->get_bits_per_pixel(src_channel), limits,
src_plane.m_datatype);
if (err) {
@@ -902,8 +902,8 @@ Error HeifPixelImage::copy_new_plane_from(const std::shared_ptr<const HeifPixelI
const uint8_t* src;
size_t src_stride = 0;
- src = src_image->get_plane(src_channel, &src_stride);
- dst = get_plane(dst_channel, &dst_stride);
+ src = src_image->get_channel(src_channel, &src_stride);
+ dst = get_channel(dst_channel, &dst_stride);
uint32_t bpl = width * (src_image->get_storage_bits_per_pixel(src_channel) / 8);
@@ -921,7 +921,7 @@ Error HeifPixelImage::extract_alpha_from_RGBA(const std::shared_ptr<const HeifPi
uint32_t width = src_image->get_width();
uint32_t height = src_image->get_height();
- if (Error err = add_plane(heif_channel_Y, width, height, src_image->get_bits_per_pixel(heif_channel_interleaved), limits)) {
+ if (Error err = add_channel(heif_channel_Y, width, height, src_image->get_bits_per_pixel(heif_channel_interleaved), limits)) {
return err;
}
@@ -931,8 +931,8 @@ Error HeifPixelImage::extract_alpha_from_RGBA(const std::shared_ptr<const HeifPi
const uint8_t* src;
size_t src_stride = 0;
- src = src_image->get_plane(heif_channel_interleaved, &src_stride);
- dst = get_plane(heif_channel_Y, &dst_stride);
+ src = src_image->get_channel(heif_channel_interleaved, &src_stride);
+ dst = get_channel(heif_channel_Y, &dst_stride);
//int bpl = width * (src_image->get_storage_bits_per_pixel(src_channel) / 8);
@@ -946,20 +946,20 @@ Error HeifPixelImage::extract_alpha_from_RGBA(const std::shared_ptr<const HeifPi
}
-Error HeifPixelImage::fill_new_plane(heif_channel dst_channel, uint16_t value, int width, int height, int bpp,
+Error HeifPixelImage::fill_new_channel(heif_channel dst_channel, uint16_t value, int width, int height, int bpp,
const heif_security_limits* limits)
{
- if (Error err = add_plane(dst_channel, width, height, bpp, limits)) {
+ if (Error err = add_channel(dst_channel, width, height, bpp, limits)) {
return err;
}
- fill_plane(dst_channel, value);
+ fill_channel(dst_channel, value);
return Error::Ok;
}
-void HeifPixelImage::fill_plane(heif_channel dst_channel, uint16_t value)
+void HeifPixelImage::fill_channel(heif_channel dst_channel, uint16_t value)
{
int num_interleaved = num_interleaved_components_per_plane(m_chroma);
@@ -970,7 +970,7 @@ void HeifPixelImage::fill_plane(heif_channel dst_channel, uint16_t value)
if (bpp <= 8) {
uint8_t* dst;
size_t dst_stride = 0;
- dst = get_plane(dst_channel, &dst_stride);
+ dst = get_channel(dst_channel, &dst_stride);
uint32_t width_bytes = width * num_interleaved;
for (uint32_t y = 0; y < height; y++) {
@@ -992,18 +992,18 @@ void HeifPixelImage::fill_plane(heif_channel dst_channel, uint16_t value)
}
-void HeifPixelImage::transfer_plane_from_image_as(const std::shared_ptr<HeifPixelImage>& source,
+void HeifPixelImage::transfer_channel_from_image_as(const std::shared_ptr<HeifPixelImage>& source,
heif_channel src_channel,
heif_channel dst_channel)
{
// TODO: check that dst_channel does not exist yet
// Find and remove the component from source
- ImageComponent plane;
- for (auto it = source->m_planes.begin(); it != source->m_planes.end(); ++it) {
+ ComponentStorage plane;
+ for (auto it = source->m_storage.begin(); it != source->m_storage.end(); ++it) {
if (it->m_channel == src_channel) {
plane = *it;
- source->m_planes.erase(it);
+ source->m_storage.erase(it);
break;
}
}
@@ -1041,7 +1041,7 @@ void HeifPixelImage::transfer_plane_from_image_as(const std::shared_ptr<HeifPixe
}
plane.m_component_ids = std::move(new_ids);
plane.m_channel = dst_channel;
- m_planes.push_back(plane);
+ m_storage.push_back(plane);
// Note: we assume that image planes are never transferred between heif_contexts
m_memory_handle.alloc(plane.allocation_size,
@@ -1086,10 +1086,10 @@ Error HeifPixelImage::copy_image_to(const std::shared_ptr<const HeifPixelImage>&
for (heif_channel channel : channels) {
size_t tile_stride;
- const uint8_t* tile_data = source->get_plane(channel, &tile_stride);
+ const uint8_t* tile_data = source->get_channel(channel, &tile_stride);
size_t out_stride;
- uint8_t* out_data = get_plane(channel, &out_stride);
+ uint8_t* out_data = get_channel(channel, &out_stride);
if (w <= x0 || h <= y0) {
return {heif_error_Invalid_input,
@@ -1151,7 +1151,7 @@ void HeifPixelImage::zero_region(uint32_t x0, uint32_t y0, uint32_t w, uint32_t
ch = std::min(ch, plane_h - cy0);
size_t stride = 0;
- uint8_t* data = get_plane(channel, &stride);
+ uint8_t* data = get_channel(channel, &stride);
uint32_t bytes_per_pixel = get_storage_bits_per_pixel(channel) / 8;
uint32_t width_bytes = cw * bytes_per_pixel;
@@ -1231,7 +1231,7 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::rotate_ccw(int angle_deg
// --- rotate all channels
- for (const auto &component: m_planes) {
+ for (const auto &component: m_storage) {
uint32_t out_plane_width = component.m_width;
uint32_t out_plane_height = component.m_height;
@@ -1239,7 +1239,7 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::rotate_ccw(int angle_deg
std::swap(out_plane_width, out_plane_height);
}
- ImageComponent out_component;
+ ComponentStorage out_component;
out_component.m_channel = component.m_channel;
if (Error err = out_component.alloc(out_plane_width, out_plane_height,
@@ -1258,7 +1258,7 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::rotate_ccw(int angle_deg
for (uint32_t cid : component.m_component_ids) {
src_descs.push_back(find_component_description(cid));
}
- out_img->register_plane_descriptions(out_component, src_descs);
+ out_img->register_component_descriptions(out_component, src_descs);
if (component.m_bit_depth <= 8) {
component.rotate_ccw<uint8_t>(angle_degrees, out_component);
@@ -1276,7 +1276,7 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::rotate_ccw(int angle_deg
component.rotate_ccw<heif_complex64>(angle_degrees, out_component);
}
- out_img->m_planes.push_back(std::move(out_component));
+ out_img->m_storage.push_back(std::move(out_component));
}
out_img->add_warnings(get_warnings());
@@ -1285,8 +1285,8 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::rotate_ccw(int angle_deg
}
template<typename T>
-void HeifPixelImage::ImageComponent::rotate_ccw(int angle_degrees,
- ImageComponent& out_plane) const
+void HeifPixelImage::ComponentStorage::rotate_ccw(int angle_degrees,
+ ComponentStorage& out_plane) const
{
uint32_t w = m_width;
uint32_t h = m_height;
@@ -1317,7 +1317,7 @@ void HeifPixelImage::ImageComponent::rotate_ccw(int angle_degrees,
template<typename T>
-void HeifPixelImage::ImageComponent::mirror_inplace(heif_transform_mirror_direction direction)
+void HeifPixelImage::ComponentStorage::mirror_inplace(heif_transform_mirror_direction direction)
{
uint32_t w = m_width;
uint32_t h = m_height;
@@ -1378,7 +1378,7 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::mirror_inplace(heif_tran
}
- for (auto& component : m_planes) {
+ for (auto& component : m_storage) {
if (component.m_bit_depth <= 8) {
component.mirror_inplace<uint8_t>(direction);
}
@@ -1407,7 +1407,7 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::mirror_inplace(heif_tran
}
-int HeifPixelImage::ImageComponent::get_bytes_per_pixel() const
+int HeifPixelImage::ComponentStorage::get_bytes_per_pixel() const
{
return m_bytes_per_pixel;
}
@@ -1461,7 +1461,7 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::crop(uint32_t left, uint
// --- crop all channels
- for (const auto& component : m_planes) {
+ for (const auto& component : m_storage) {
heif_channel channel = component.m_channel;
uint32_t plane_left = get_subsampled_size_h(left, channel, m_chroma, scaling_mode::is_divisible); // is always divisible
@@ -1469,7 +1469,7 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::crop(uint32_t left, uint
uint32_t plane_top = get_subsampled_size_v(top, channel, m_chroma, scaling_mode::is_divisible);
uint32_t plane_bottom = get_subsampled_size_v(bottom, channel, m_chroma, scaling_mode::round_down);
- ImageComponent out_plane;
+ ComponentStorage out_plane;
out_plane.m_channel = channel;
if (Error err = out_plane.alloc(plane_right - plane_left + 1,
@@ -1489,12 +1489,12 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::crop(uint32_t left, uint
for (uint32_t cid : component.m_component_ids) {
src_descs.push_back(find_component_description(cid));
}
- out_img->register_plane_descriptions(out_plane, src_descs);
+ out_img->register_component_descriptions(out_plane, src_descs);
int bytes_per_pixel = component.get_bytes_per_pixel();
component.crop(plane_left, plane_right, plane_top, plane_bottom, bytes_per_pixel, out_plane);
- out_img->m_planes.push_back(std::move(out_plane));
+ out_img->m_storage.push_back(std::move(out_plane));
}
out_img->add_warnings(get_warnings());
@@ -1503,8 +1503,8 @@ Result<std::shared_ptr<HeifPixelImage>> HeifPixelImage::crop(uint32_t left, uint
}
-void HeifPixelImage::ImageComponent::crop(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom,
- int bytes_per_pixel, ImageComponent& out_plane) const
+void HeifPixelImage::ComponentStorage::crop(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom,
+ int bytes_per_pixel, ComponentStorage& out_plane) const
{
size_t in_stride = stride;
auto* in_data = static_cast<const uint8_t*>(mem);
@@ -1524,7 +1524,7 @@ Error HeifPixelImage::fill_RGB_16bit(uint16_t r, uint16_t g, uint16_t b, uint16_
{
for (const auto& channel : {heif_channel_R, heif_channel_G, heif_channel_B, heif_channel_Alpha}) {
- auto* comp = find_component_for_channel(channel);
+ auto* comp = find_storage_for_channel(channel);
if (!comp) {
// alpha channel is optional, R,G,B is required
@@ -1537,7 +1537,7 @@ Error HeifPixelImage::fill_RGB_16bit(uint16_t r, uint16_t g, uint16_t b, uint16_
}
- ImageComponent& plane = *comp;
+ ComponentStorage& plane = *comp;
if (plane.m_bit_depth != 8) {
return {heif_error_Unsupported_feature,
@@ -1567,7 +1567,7 @@ Error HeifPixelImage::fill_RGB_16bit(uint16_t r, uint16_t g, uint16_t b, uint16_
default:
// initialization only to avoid warning of uninitialized variable.
val16 = 0;
- // Should already be detected by the check above ("find_component_for_channel").
+ // Should already be detected by the check above ("find_storage_for_channel").
assert(false);
}
@@ -1617,7 +1617,7 @@ Error HeifPixelImage::overlay(std::shared_ptr<HeifPixelImage>& overlay, int32_t
size_t alpha_stride = 0;
uint8_t* alpha_p;
- alpha_p = overlay->get_plane(heif_channel_Alpha, &alpha_stride);
+ alpha_p = overlay->get_channel(heif_channel_Alpha, &alpha_stride);
for (heif_channel channel : channels) {
if (!has_channel(channel)) {
@@ -1630,8 +1630,8 @@ Error HeifPixelImage::overlay(std::shared_ptr<HeifPixelImage>& overlay, int32_t
size_t out_stride = 0;
uint8_t* out_p;
- in_p = overlay->get_plane(channel, &in_stride);
- out_p = get_plane(channel, &out_stride);
+ in_p = overlay->get_channel(channel, &in_stride);
+ out_p = get_channel(channel, &out_stride);
uint32_t in_w = overlay->get_width(channel);
uint32_t in_h = overlay->get_height(channel);
@@ -1746,7 +1746,7 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr<HeifPixelImage>& ou
// --- create output image with scaled planes
if (has_channel(heif_channel_interleaved)) {
- if (auto err = out_img->add_plane(heif_channel_interleaved, width, height, get_bits_per_pixel(heif_channel_interleaved), limits)) {
+ if (auto err = out_img->add_channel(heif_channel_interleaved, width, height, get_bits_per_pixel(heif_channel_interleaved), limits)) {
return err;
}
}
@@ -1758,13 +1758,13 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr<HeifPixelImage>& ou
return {heif_error_Invalid_input, heif_suberror_Unspecified, "RGB input without R,G,B, planes"};
}
- if (auto err = out_img->add_plane(heif_channel_R, width, height, get_bits_per_pixel(heif_channel_R), limits)) {
+ if (auto err = out_img->add_channel(heif_channel_R, width, height, get_bits_per_pixel(heif_channel_R), limits)) {
return err;
}
- if (auto err = out_img->add_plane(heif_channel_G, width, height, get_bits_per_pixel(heif_channel_G), limits)) {
+ if (auto err = out_img->add_channel(heif_channel_G, width, height, get_bits_per_pixel(heif_channel_G), limits)) {
return err;
}
- if (auto err = out_img->add_plane(heif_channel_B, width, height, get_bits_per_pixel(heif_channel_B), limits)) {
+ if (auto err = out_img->add_channel(heif_channel_B, width, height, get_bits_per_pixel(heif_channel_B), limits)) {
return err;
}
}
@@ -1773,7 +1773,7 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr<HeifPixelImage>& ou
return {heif_error_Invalid_input, heif_suberror_Unspecified, "monochrome input with no Y plane"};
}
- if (auto err = out_img->add_plane(heif_channel_Y, width, height, get_bits_per_pixel(heif_channel_Y), limits)) {
+ if (auto err = out_img->add_channel(heif_channel_Y, width, height, get_bits_per_pixel(heif_channel_Y), limits)) {
return err;
}
}
@@ -1786,13 +1786,13 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr<HeifPixelImage>& ou
uint32_t cw, ch;
get_subsampled_size(width, height, heif_channel_Cb, get_chroma_format(), &cw, &ch);
- if (auto err = out_img->add_plane(heif_channel_Y, width, height, get_bits_per_pixel(heif_channel_Y), limits)) {
+ if (auto err = out_img->add_channel(heif_channel_Y, width, height, get_bits_per_pixel(heif_channel_Y), limits)) {
return err;
}
- if (auto err = out_img->add_plane(heif_channel_Cb, cw, ch, get_bits_per_pixel(heif_channel_Cb), limits)) {
+ if (auto err = out_img->add_channel(heif_channel_Cb, cw, ch, get_bits_per_pixel(heif_channel_Cb), limits)) {
return err;
}
- if (auto err = out_img->add_plane(heif_channel_Cr, cw, ch, get_bits_per_pixel(heif_channel_Cr), limits)) {
+ if (auto err = out_img->add_channel(heif_channel_Cr, cw, ch, get_bits_per_pixel(heif_channel_Cr), limits)) {
return err;
}
}
@@ -1801,7 +1801,7 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr<HeifPixelImage>& ou
}
if (has_channel(heif_channel_Alpha)) {
- if (auto err = out_img->add_plane(heif_channel_Alpha, width, height, get_bits_per_pixel(heif_channel_Alpha), limits)) {
+ if (auto err = out_img->add_channel(heif_channel_Alpha, width, height, get_bits_per_pixel(heif_channel_Alpha), limits)) {
return err;
}
}
@@ -1812,9 +1812,9 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr<HeifPixelImage>& ou
int nInterleaved = num_interleaved_components_per_plane(m_chroma);
if (nInterleaved > 1) {
- const auto* comp = find_component_for_channel(heif_channel_interleaved);
+ const auto* comp = find_storage_for_channel(heif_channel_interleaved);
assert(comp != nullptr); // the plane must exist since we have an interleaved chroma format
- const ImageComponent& plane = *comp;
+ const ComponentStorage& plane = *comp;
uint32_t out_w = out_img->get_width(heif_channel_interleaved);
uint32_t out_h = out_img->get_height(heif_channel_interleaved);
@@ -1826,7 +1826,7 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr<HeifPixelImage>& ou
const auto* in_data = static_cast<const uint8_t*>(plane.mem);
size_t out_stride = 0;
- auto* out_data = out_img->get_plane(heif_channel_interleaved, &out_stride);
+ auto* out_data = out_img->get_channel(heif_channel_interleaved, &out_stride);
for (uint32_t y = 0; y < out_h; y++) {
uint32_t iy = y * m_height / height;
@@ -1867,9 +1867,9 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr<HeifPixelImage>& ou
}
}
else {
- for (const auto& component : m_planes) {
+ for (const auto& component : m_storage) {
heif_channel channel = component.m_channel;
- const ImageComponent& plane = component;
+ const ComponentStorage& plane = component;
if (!out_img->has_channel(channel)) {
return {heif_error_Invalid_input, heif_suberror_Unspecified, "scaling input has extra color plane"};
@@ -1886,7 +1886,7 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr<HeifPixelImage>& ou
const auto* in_data = static_cast<const uint8_t*>(plane.mem);
size_t out_stride = 0;
- auto* out_data = out_img->get_plane(channel, &out_stride);
+ auto* out_data = out_img->get_channel(channel, &out_stride);
for (uint32_t y = 0; y < out_h; y++) {
uint32_t iy = y * m_height / height;
@@ -1932,7 +1932,7 @@ void HeifPixelImage::debug_dump() const
auto channels = get_channel_set();
for (auto c : channels) {
size_t stride = 0;
- const uint8_t* p = get_plane(c, &stride);
+ const uint8_t* p = get_channel(c, &stride);
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 8; x++) {
@@ -1951,13 +1951,13 @@ Error HeifPixelImage::create_clone_image_at_new_size(const std::shared_ptr<const
create(w, h, colorspace, chroma);
- for (const auto& src_plane : source->m_planes) {
+ for (const auto& src_plane : source->m_storage) {
// TODO: do we also support images where some planes (e.g. the alpha-plane) have a different size than the main image?
// We could do this by scaling all planes proportionally. This would also handle chroma channels implicitly.
uint32_t plane_w = channel_width(w, chroma, src_plane.m_channel);
uint32_t plane_h = channel_height(h, chroma, src_plane.m_channel);
- ImageComponent plane;
+ ComponentStorage plane;
plane.m_channel = src_plane.m_channel;
plane.m_component_ids = src_plane.m_component_ids;
@@ -1966,7 +1966,7 @@ Error HeifPixelImage::create_clone_image_at_new_size(const std::shared_ptr<const
return err;
}
- m_planes.push_back(plane);
+ m_storage.push_back(plane);
}
set_component_descriptions(source->get_component_descriptions(),
@@ -1997,10 +1997,10 @@ HeifPixelImage::extract_image_area(uint32_t x0, uint32_t y0, uint32_t w, uint32_
for (heif_channel channel : channels) {
size_t src_stride;
- const uint8_t* src_data = get_plane(channel, &src_stride);
+ const uint8_t* src_data = get_channel(channel, &src_stride);
size_t out_stride;
- uint8_t* out_data = areaImg->get_plane(channel, &out_stride);
+ uint8_t* out_data = areaImg->get_channel(channel, &out_stride);
if (areaImg->get_bits_per_pixel(channel) != get_bits_per_pixel(channel)) {
return Error{
@@ -2039,9 +2039,9 @@ HeifPixelImage::extract_image_area(uint32_t x0, uint32_t y0, uint32_t w, uint32_
// --- index-based component access methods
-HeifPixelImage::ImageComponent* HeifPixelImage::find_component_by_id(uint32_t component_id)
+HeifPixelImage::ComponentStorage* HeifPixelImage::find_storage_for_component(uint32_t component_id)
{
- for (auto& plane : m_planes) {
+ for (auto& plane : m_storage) {
// we search through all indices in case we have an interleaved plane
if (std::find(plane.m_component_ids.begin(),
plane.m_component_ids.end(),
@@ -2053,9 +2053,9 @@ HeifPixelImage::ImageComponent* HeifPixelImage::find_component_by_id(uint32_t co
}
-const HeifPixelImage::ImageComponent* HeifPixelImage::find_component_by_id(uint32_t component_id) const
+const HeifPixelImage::ComponentStorage* HeifPixelImage::find_storage_for_component(uint32_t component_id) const
{
- return const_cast<HeifPixelImage*>(this)->find_component_by_id(component_id);
+ return const_cast<HeifPixelImage*>(this)->find_storage_for_component(component_id);
}
@@ -2094,8 +2094,8 @@ uint16_t HeifPixelImage::get_component_bits_per_pixel(uint32_t component_id) con
uint16_t HeifPixelImage::get_component_storage_bits_per_pixel(uint32_t component_id) const
{
// Storage is a buffer-layout concern (alignment / padding), so this stays
- // routed through ImageComponent rather than the description.
- auto* comp = find_component_by_id(component_id);
+ // routed through ComponentStorage rather than the description.
+ auto* comp = find_storage_for_component(component_id);
assert(comp);
uint32_t bpp = comp->get_bytes_per_pixel() * 8;
assert(bpp);
@@ -2122,7 +2122,7 @@ uint16_t HeifPixelImage::get_component_type(uint32_t component_id) const
std::vector<uint32_t> HeifPixelImage::get_component_ids_interleaved() const
{
- const ImageComponent* comp = find_component_for_channel(heif_channel_interleaved);
+ const ComponentStorage* comp = find_storage_for_channel(heif_channel_interleaved);
assert(comp);
return comp->m_component_ids;
}
@@ -2135,16 +2135,16 @@ Result<uint32_t> HeifPixelImage::add_component(uint32_t width, uint32_t height,
{
heif_channel channel = map_uncompressed_component_to_channel(component_type);
- ImageComponent plane;
+ ComponentStorage plane;
plane.m_channel = channel;
if (Error err = plane.alloc(width, height, datatype, bit_depth, 1, limits, m_memory_handle)) {
return {err};
}
- register_plane_descriptions(plane, std::vector<uint16_t>{component_type});
+ register_component_descriptions(plane, std::vector<uint16_t>{component_type});
uint32_t component_id = plane.m_component_ids.front();
- m_planes.push_back(std::move(plane));
+ m_storage.push_back(std::move(plane));
return component_id;
}
@@ -2212,7 +2212,7 @@ void HeifPixelImage::apply_descriptions_from(const ImageDescription& src)
// allocated at tile size; the description we publish should match what
// the buffer actually contains.
std::map<heif_channel, std::pair<uint32_t, uint32_t>> plane_dims_by_channel;
- for (const auto& plane : m_planes) {
+ for (const auto& plane : m_storage) {
plane_dims_by_channel[plane.m_channel] = {plane.m_width, plane.m_height};
}
@@ -2241,7 +2241,7 @@ void HeifPixelImage::apply_descriptions_from(const ImageDescription& src)
// Remap each plane's m_component_ids by channel match against src; for
// channels not in src, re-add the auto-minted description with a fresh id.
- for (auto& plane : m_planes) {
+ for (auto& plane : m_storage) {
if (plane.m_component_ids.empty()) continue;
heif_channel ch = plane.m_channel;
@@ -2276,7 +2276,7 @@ Error HeifPixelImage::allocate_buffer_for_component(uint32_t component_id,
return Error::Ok; // reference component (e.g. cpat); no buffer needed
}
- ImageComponent plane;
+ ComponentStorage plane;
plane.m_channel = desc->channel;
plane.m_component_ids = std::vector{component_id};
if (Error err = plane.alloc(desc->width, desc->height,
@@ -2284,7 +2284,7 @@ Error HeifPixelImage::allocate_buffer_for_component(uint32_t component_id,
1, limits, m_memory_handle)) {
return err;
}
- m_planes.push_back(plane);
+ m_storage.push_back(plane);
return Error::Ok;
}
@@ -2302,14 +2302,14 @@ Result<uint32_t> HeifPixelImage::add_component_for_index(uint32_t component_inde
uint16_t component_type = m_cmpd_component_types[component_index];
- ImageComponent plane;
+ ComponentStorage plane;
plane.m_channel = map_uncompressed_component_to_channel(component_type);
plane.m_component_index = std::vector{component_index};
if (Error err = plane.alloc(width, height, datatype, bit_depth, 1, limits, m_memory_handle)) {
return err;
}
- m_planes.push_back(plane);
+ m_storage.push_back(plane);
return component_index;
}
#endif
@@ -2333,7 +2333,7 @@ std::vector<uint32_t> HeifPixelImage::get_used_planar_component_ids() const
{
std::vector<uint32_t> indices;
- for (const auto& plane : m_planes) {
+ for (const auto& plane : m_storage) {
if (plane.m_component_ids.size() == 1) {
indices.push_back(plane.m_component_ids[0]);
}
diff --git a/libheif/image/pixelimage.h b/libheif/image/pixelimage.h
index 89b369ee..e62b6406 100644
--- a/libheif/image/pixelimage.h
+++ b/libheif/image/pixelimage.h
@@ -71,7 +71,7 @@ public:
Error create_clone_image_at_new_size(const std::shared_ptr<const HeifPixelImage>& source, uint32_t w, uint32_t h,
const heif_security_limits* limits);
- Error add_plane(heif_channel channel, uint32_t width, uint32_t height, int bit_depth,
+ Error add_channel(heif_channel channel, uint32_t width, uint32_t height, int bit_depth,
const heif_security_limits* limits,
heif_component_datatype datatype = heif_component_datatype_unsigned_integer);
@@ -124,14 +124,14 @@ public:
// Note: we are using size_t as stride type since the stride is usually involved in a multiplication with the line number.
// For very large images (e.g. >2 GB), this can result in an integer overflow and corresponding illegal memory access.
// (see https://github.com/strukturag/libheif/issues/1419)
- uint8_t* get_plane(heif_channel channel, size_t* out_stride) { return get_channel<uint8_t>(channel, out_stride); }
+ uint8_t* get_channel(heif_channel channel, size_t* out_stride) { return get_channel<uint8_t>(channel, out_stride); }
- const uint8_t* get_plane(heif_channel channel, size_t* out_stride) const { return get_channel<uint8_t>(channel, out_stride); }
+ const uint8_t* get_channel(heif_channel channel, size_t* out_stride) const { return get_channel<uint8_t>(channel, out_stride); }
template <typename T>
T* get_channel(heif_channel channel, size_t* out_stride)
{
- auto* comp = find_component_for_channel(channel);
+ auto* comp = find_storage_for_channel(channel);
if (!comp) {
if (out_stride)
*out_stride = 0;
@@ -233,7 +233,7 @@ public:
template <typename T>
T* get_component_data(uint32_t component_id, size_t* out_stride)
{
- auto* comp = find_component_by_id(component_id);
+ auto* comp = find_storage_for_component(component_id);
if (!comp) {
if (out_stride) *out_stride = 0;
return nullptr;
@@ -251,18 +251,18 @@ public:
return const_cast<HeifPixelImage*>(this)->get_component_data<T>(component_id, out_stride);
}
- Error copy_new_plane_from(const std::shared_ptr<const HeifPixelImage>& src_image,
+ Error copy_new_channel_from(const std::shared_ptr<const HeifPixelImage>& src_image,
heif_channel src_channel,
heif_channel dst_channel,
const heif_security_limits* limits);
Error extract_alpha_from_RGBA(const std::shared_ptr<const HeifPixelImage>& srcimage, const heif_security_limits* limits);
- void fill_plane(heif_channel dst_channel, uint16_t value);
+ void fill_channel(heif_channel dst_channel, uint16_t value);
- Error fill_new_plane(heif_channel dst_channel, uint16_t value, int width, int height, int bpp, const heif_security_limits* limits);
+ Error fill_new_channel(heif_channel dst_channel, uint16_t value, int width, int height, int bpp, const heif_security_limits* limits);
- void transfer_plane_from_image_as(const std::shared_ptr<HeifPixelImage>& source,
+ void transfer_channel_from_image_as(const std::shared_ptr<HeifPixelImage>& source,
heif_channel src_channel,
heif_channel dst_channel);
@@ -305,7 +305,7 @@ public:
const std::vector<Error>& get_warnings() const { return m_warnings; }
private:
- struct ImageComponent
+ struct ComponentStorage
{
heif_channel m_channel = heif_channel_Y;
@@ -350,16 +350,16 @@ private:
template <typename T> void mirror_inplace(heif_transform_mirror_direction);
template<typename T>
- void rotate_ccw(int angle_degrees, ImageComponent& out_plane) const;
+ void rotate_ccw(int angle_degrees, ComponentStorage& out_plane) const;
- void crop(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom, int bytes_per_pixel, ImageComponent& out_plane) const;
+ void crop(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom, int bytes_per_pixel, ComponentStorage& out_plane) const;
};
- ImageComponent* find_component_for_channel(heif_channel channel);
- const ImageComponent* find_component_for_channel(heif_channel channel) const;
+ ComponentStorage* find_storage_for_channel(heif_channel channel);
+ const ComponentStorage* find_storage_for_channel(heif_channel channel) const;
- ImageComponent* find_component_by_id(uint32_t component_id);
- const ImageComponent* find_component_by_id(uint32_t component_id) const;
+ ComponentStorage* find_storage_for_component(uint32_t component_id);
+ const ComponentStorage* find_storage_for_component(uint32_t component_id) const;
// After plane.alloc() has succeeded, mints fresh component ids, appends
// them to plane.m_component_ids, and pushes fully-populated
@@ -367,7 +367,7 @@ private:
// bit_depth, width and height are read from `plane`. Must only be called
// once allocation has succeeded so that no descriptions are registered for
// a plane that failed to materialize.
- void register_plane_descriptions(ImageComponent& plane,
+ void register_component_descriptions(ComponentStorage& plane,
const std::vector<uint16_t>& component_types);
// Overload that clones existing ComponentDescriptions (preserving
@@ -376,7 +376,7 @@ private:
// from `plane`; component_ids are freshly minted on this image. Use this
// when allocating a new plane that mirrors an existing one (e.g.
// geometry-preserving transforms like rotation and crop).
- void register_plane_descriptions(ImageComponent& plane,
+ void register_component_descriptions(ComponentStorage& plane,
const std::vector<const ComponentDescription*>& source_descriptions);
uint32_t m_width = 0;
@@ -384,7 +384,7 @@ private:
heif_colorspace m_colorspace = heif_colorspace_undefined;
heif_chroma m_chroma = heif_chroma_undefined;
- std::vector<ImageComponent> m_planes;
+ std::vector<ComponentStorage> m_storage;
//std::vector<uint16_t> m_cmpd_component_types; // indexed by cmpd index
MemoryHandle m_memory_handle;
diff --git a/libheif/sequences/track_visual.cc b/libheif/sequences/track_visual.cc
index 7818f37b..c5374605 100644
--- a/libheif/sequences/track_visual.cc
+++ b/libheif/sequences/track_visual.cc
@@ -297,7 +297,7 @@ Result<std::shared_ptr<HeifPixelImage> > Track_Visual::decode_next_image_sample(
}
auto alphaImage = *alphaResult;
- image->transfer_plane_from_image_as(alphaImage, heif_channel_Y, heif_channel_Alpha);
+ image->transfer_channel_from_image_as(alphaImage, heif_channel_Y, heif_channel_Alpha);
}
diff --git a/tests/conversion.cc b/tests/conversion.cc
index b5e76773..434cfcbb 100644
--- a/tests/conversion.cc
+++ b/tests/conversion.cc
@@ -76,7 +76,7 @@ std::string PrintChannel(const HeifPixelImage& image, heif_channel channel) {
uint32_t width = std::min(image.get_width(channel), max_cols);
uint32_t height = std::min(image.get_height(channel), max_rows);
size_t stride;
- const T* p = (T*)image.get_plane(channel, &stride);
+ const T* p = (T*)image.get_channel(channel, &stride);
stride /= (int)sizeof(T);
int bpp = image.get_bits_per_pixel(channel);
int digits = (int)std::ceil(std::log10(1 << bpp)) + 1;
@@ -129,8 +129,8 @@ double GetPsnr(const HeifPixelImage& original, const HeifPixelImage& compressed,
size_t orig_stride;
size_t compressed_stride;
- const T* orig_p = (T*)original.get_plane(channel, &orig_stride);
- const T* compressed_p = (T*)compressed.get_plane(channel, &compressed_stride);
+ const T* orig_p = (T*)original.get_channel(channel, &orig_stride);
+ const T* compressed_p = (T*)compressed.get_channel(channel, &compressed_stride);
orig_stride /= (int)sizeof(T);
compressed_stride /= (int)sizeof(T);
double mse = 0.0;
@@ -239,7 +239,7 @@ bool MakeTestImage(const ColorState& state, int width, int height,
int half_max = (1 << (plane.bit_depth -1));
uint16_t value = SwapBytesIfNeeded(
static_cast<uint16_t>(half_max + i * 10 + i), state.chroma);
- auto err = image->fill_new_plane(plane.channel, value, plane.width, plane.height,
+ auto err = image->fill_new_channel(plane.channel, value, plane.width, plane.height,
plane.bit_depth, nullptr);
if (err) {
return false;
@@ -324,7 +324,7 @@ void TestConversion(const std::string& test_name, ColorState input_state,
for (const Plane& plane : GetPlanes(target_state, width, height)) {
INFO("Channel: " << plane.channel);
size_t stride;
- CHECK(out_image->get_plane(plane.channel, &stride) != nullptr);
+ CHECK(out_image->get_channel(plane.channel, &stride) != nullptr);
CHECK(out_image->get_bits_per_pixel(plane.channel) ==
target_state.bits_per_pixel);
// If an alpha plane was created from nothing, check that it's filled
@@ -649,11 +649,11 @@ TEST_CASE("Sharp yuv conversion", "[heif_image]") {
static void fill_plane(std::shared_ptr<HeifPixelImage>& img, heif_channel channel, int w, int h, const std::vector<uint8_t>& pixels)
{
- auto error = img->add_plane(channel, w, h, 8, nullptr);
+ auto error = img->add_channel(channel, w, h, 8, nullptr);
REQUIRE(!error);
size_t stride;
- uint8_t* p = img->get_plane(channel, &stride);
+ uint8_t* p = img->get_channel(channel, &stride);
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
@@ -670,7 +670,7 @@ static void assert_plane(std::shared_ptr<HeifPixelImage>& img, heif_channel chan
uint32_t h = img->get_height(channel);
size_t stride;
- uint8_t* p = img->get_plane(channel, &stride);
+ uint8_t* p = img->get_channel(channel, &stride);
for (uint32_t y = 0; y < h; y++) {
INFO("row: " << y);
@@ -691,7 +691,7 @@ TEST_CASE("Bilinear upsampling", "[heif_image]")
std::shared_ptr<HeifPixelImage> img = std::make_shared<HeifPixelImage>();
img->create(4, 4, heif_colorspace_YCbCr, heif_chroma_420);
- auto error = img->fill_new_plane(heif_channel_Y, 128, 4,4, 8, nullptr);
+ auto error = img->fill_new_channel(heif_channel_Y, 128, 4,4, 8, nullptr);
REQUIRE(!error);
fill_plane(img, heif_channel_Cb, 2,2,
@@ -733,20 +733,20 @@ TEST_CASE("RGB 5-6-5 to RGB")
const uint32_t height = 2;
img->create(width, height, heif_colorspace_RGB, heif_chroma_444);
Error err;
- err = img->add_plane(heif_channel_R, width, height, 5, heif_get_disabled_security_limits());
+ err = img->add_channel(heif_channel_R, width, height, 5, heif_get_disabled_security_limits());
REQUIRE(!err);
REQUIRE(img->get_bits_per_pixel(heif_channel_R) == 5);
- err = img->add_plane(heif_channel_G, width, height, 6, heif_get_disabled_security_limits());
+ err = img->add_channel(heif_channel_G, width, height, 6, heif_get_disabled_security_limits());
REQUIRE(!err);
REQUIRE(img->get_bits_per_pixel(heif_channel_G) == 6);
- err = img->add_plane(heif_channel_B, width, height, 5, heif_get_disabled_security_limits());
+ err = img->add_channel(heif_channel_B, width, height, 5, heif_get_disabled_security_limits());
REQUIRE(!err);
REQUIRE(img->get_bits_per_pixel(heif_channel_B) == 5);
uint8_t v = 1;
for (heif_channel plane: {heif_channel_R, heif_channel_G, heif_channel_B}) {
size_t dst_stride = 0;
- uint8_t *dst = img->get_plane(plane, &dst_stride);
+ uint8_t *dst = img->get_channel(plane, &dst_stride);
for (uint32_t y = 0; y < height; y++) {
for (uint32_t x = 0; x < width; x++) {
dst[y * dst_stride + x] = v;
@@ -827,11 +827,11 @@ TEST_CASE("Mismatched alpha bit depth - conversion correctness") {
img->create(width, height, heif_colorspace_RGB, heif_chroma_444);
// Create 10-bit color planes filled with a known value (512 = mid-range for 10-bit)
- img->fill_new_plane(heif_channel_R, 512, width, height, 10, nullptr);
- img->fill_new_plane(heif_channel_G, 256, width, height, 10, nullptr);
- img->fill_new_plane(heif_channel_B, 768, width, height, 10, nullptr);
+ img->fill_new_channel(heif_channel_R, 512, width, height, 10, nullptr);
+ img->fill_new_channel(heif_channel_G, 256, width, height, 10, nullptr);
+ img->fill_new_channel(heif_channel_B, 768, width, height, 10, nullptr);
// Create 8-bit alpha plane filled with 200
- img->fill_new_plane(heif_channel_Alpha, 200, width, height, 8, nullptr);
+ img->fill_new_channel(heif_channel_Alpha, 200, width, height, 8, nullptr);
// Verify the mismatch
REQUIRE(img->get_bits_per_pixel(heif_channel_R) == 10);
@@ -848,7 +848,7 @@ TEST_CASE("Mismatched alpha bit depth - conversion correctness") {
// Verify the output has correct interleaved pixel values
size_t stride;
- const uint8_t* p = out->get_plane(heif_channel_interleaved, &stride);
+ const uint8_t* p = out->get_channel(heif_channel_interleaved, &stride);
REQUIRE(p != nullptr);
// Check first pixel: R=512>>2=128, G=256>>2=64, B=768>>2=192, A=200
@@ -866,11 +866,11 @@ TEST_CASE("Mismatched alpha bit depth - conversion correctness") {
img->create(width, height, heif_colorspace_RGB, heif_chroma_444);
// Create 8-bit color planes
- img->fill_new_plane(heif_channel_R, 128, width, height, 8, nullptr);
- img->fill_new_plane(heif_channel_G, 64, width, height, 8, nullptr);
- img->fill_new_plane(heif_channel_B, 192, width, height, 8, nullptr);
+ img->fill_new_channel(heif_channel_R, 128, width, height, 8, nullptr);
+ img->fill_new_channel(heif_channel_G, 64, width, height, 8, nullptr);
+ img->fill_new_channel(heif_channel_B, 192, width, height, 8, nullptr);
// Create 10-bit alpha plane (value 800 -> 800>>2 = 200 when converted to 8-bit)
- img->fill_new_plane(heif_channel_Alpha, 800, width, height, 10, nullptr);
+ img->fill_new_channel(heif_channel_Alpha, 800, width, height, 10, nullptr);
REQUIRE(img->get_bits_per_pixel(heif_channel_R) == 8);
REQUIRE(img->get_bits_per_pixel(heif_channel_Alpha) == 10);
@@ -885,7 +885,7 @@ TEST_CASE("Mismatched alpha bit depth - conversion correctness") {
CHECK(out->get_chroma_format() == heif_chroma_interleaved_RGBA);
size_t stride;
- const uint8_t* p = out->get_plane(heif_channel_interleaved, &stride);
+ const uint8_t* p = out->get_channel(heif_channel_interleaved, &stride);
REQUIRE(p != nullptr);
CHECK(p[0] == 128); // R (unchanged)
diff --git a/tests/pixel_data_types.cc b/tests/pixel_data_types.cc
index 6f3299c9..1f4b1945 100644
--- a/tests/pixel_data_types.cc
+++ b/tests/pixel_data_types.cc
@@ -33,7 +33,7 @@ TEST_CASE( "uint32_t" )
auto* limits = heif_get_global_security_limits();
image.create(3,2, heif_colorspace_custom, heif_chroma_planar);
- image.add_plane(heif_channel_Y, 3,2, 32, limits, heif_component_datatype_unsigned_integer);
+ image.add_channel(heif_channel_Y, 3,2, 32, limits, heif_component_datatype_unsigned_integer);
size_t stride;
uint32_t* data = image.get_channel<uint32_t>(heif_channel_Y, &stride);
@@ -132,7 +132,7 @@ TEST_CASE( "complex64_t" )
auto* limits = heif_get_global_security_limits();
image.create(3,2, heif_colorspace_custom, heif_chroma_planar);
- image.add_plane(heif_channel_Y, 3,2, 128, limits, heif_component_datatype_complex_number);
+ image.add_channel(heif_channel_Y, 3,2, 128, limits, heif_component_datatype_complex_number);
size_t stride;
heif_complex64* data = image.get_channel<heif_complex64>(heif_channel_Y, &stride);
@@ -187,13 +187,13 @@ TEST_CASE( "image datatype through public API" )
// Verify that an interleaved RGB plane produces THREE ComponentDescription
// entries (one per cmpd component: red, green, blue) all sharing
-// channel=heif_channel_interleaved, while m_planes has a single buffer.
+// channel=heif_channel_interleaved, while m_storage has a single buffer.
TEST_CASE( "interleaved RGB component descriptions" )
{
HeifPixelImage image;
auto* limits = heif_get_global_security_limits();
image.create(100, 100, heif_colorspace_RGB, heif_chroma_interleaved_RGB);
- REQUIRE(image.add_plane(heif_channel_interleaved, 100, 100, 8, limits).error_code == heif_error_Ok);
+ REQUIRE(image.add_channel(heif_channel_interleaved, 100, 100, 8, limits).error_code == heif_error_Ok);
REQUIRE(image.get_number_of_used_components() == 3);
@@ -232,7 +232,7 @@ TEST_CASE( "interleaved RGBA component descriptions" )
HeifPixelImage image;
auto* limits = heif_get_global_security_limits();
image.create(50, 50, heif_colorspace_RGB, heif_chroma_interleaved_RGBA);
- REQUIRE(image.add_plane(heif_channel_interleaved, 50, 50, 8, limits).error_code == heif_error_Ok);
+ REQUIRE(image.add_channel(heif_channel_interleaved, 50, 50, 8, limits).error_code == heif_error_Ok);
REQUIRE(image.get_number_of_used_components() == 4);
auto ids = image.get_used_component_ids();