Commit 313fef79 for libheif
commit 313fef79126dabf0003577b4ff843fbfcb47d08f
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Mon Feb 9 00:39:58 2026 +0100
unci: simplify map_uncompressed_component_to_channel()
diff --git a/libheif/codecs/uncompressed/unc_codec.cc b/libheif/codecs/uncompressed/unc_codec.cc
index 73de7112..e864d06d 100644
--- a/libheif/codecs/uncompressed/unc_codec.cc
+++ b/libheif/codecs/uncompressed/unc_codec.cc
@@ -158,58 +158,10 @@ Error UncompressedImageCodec::get_heif_chroma_uncompressed(const std::shared_ptr
}
bool map_uncompressed_component_to_channel(const std::shared_ptr<const Box_cmpd>& cmpd,
- const std::shared_ptr<const Box_uncC>& uncC,
Box_uncC::Component component,
heif_channel* channel)
{
uint16_t component_index = component.component_index;
- if (isKnownUncompressedFrameConfigurationBoxProfile(uncC)) {
- if (uncC->get_profile() == fourcc("rgb3")) {
- switch (component_index) {
- case 0:
- *channel = heif_channel_R;
- return true;
- case 1:
- *channel = heif_channel_G;
- return true;
- case 2:
- *channel = heif_channel_B;
- return true;
- }
- }
- else if (uncC->get_profile() == fourcc("rgba")) {
- switch (component_index) {
- case 0:
- *channel = heif_channel_R;
- return true;
- case 1:
- *channel = heif_channel_G;
- return true;
- case 2:
- *channel = heif_channel_B;
- return true;
- case 3:
- *channel = heif_channel_Alpha;
- return true;
- }
- }
- else if (uncC->get_profile() == fourcc("abgr")) {
- switch (component_index) {
- case 0:
- *channel = heif_channel_Alpha;
- return true;
- case 1:
- *channel = heif_channel_B;
- return true;
- case 2:
- *channel = heif_channel_G;
- return true;
- case 3:
- *channel = heif_channel_R;
- return true;
- }
- }
- }
uint16_t component_type = cmpd->get_components()[component_index].component_type;
switch (component_type) {
@@ -270,7 +222,7 @@ Result<std::shared_ptr<HeifPixelImage>> UncompressedImageCodec::create_image(con
for (Box_uncC::Component component : uncC->get_components()) {
heif_channel channel;
- if (map_uncompressed_component_to_channel(cmpd, uncC, component, &channel)) {
+ if (map_uncompressed_component_to_channel(cmpd, component, &channel)) {
if (img->has_channel(channel)) {
return Error{heif_error_Unsupported_feature,
heif_suberror_Unspecified,
diff --git a/libheif/codecs/uncompressed/unc_codec.h b/libheif/codecs/uncompressed/unc_codec.h
index bdb233b7..66645b79 100644
--- a/libheif/codecs/uncompressed/unc_codec.h
+++ b/libheif/codecs/uncompressed/unc_codec.h
@@ -43,7 +43,6 @@ class HeifContext;
bool isKnownUncompressedFrameConfigurationBoxProfile(const std::shared_ptr<const Box_uncC>& uncC);
bool map_uncompressed_component_to_channel(const std::shared_ptr<const Box_cmpd> &cmpd,
- const std::shared_ptr<const Box_uncC> &uncC,
Box_uncC::Component component,
heif_channel *channel);
diff --git a/libheif/codecs/uncompressed/unc_decoder_legacybase.cc b/libheif/codecs/uncompressed/unc_decoder_legacybase.cc
index 21aef652..37fec032 100644
--- a/libheif/codecs/uncompressed/unc_decoder_legacybase.cc
+++ b/libheif/codecs/uncompressed/unc_decoder_legacybase.cc
@@ -138,7 +138,7 @@ unc_decoder_legacybase::ChannelListEntry unc_decoder_legacybase::buildChannelLis
std::shared_ptr<HeifPixelImage>& img)
{
ChannelListEntry entry;
- entry.use_channel = map_uncompressed_component_to_channel(m_cmpd, m_uncC, component, &(entry.channel));
+ entry.use_channel = map_uncompressed_component_to_channel(m_cmpd, component, &(entry.channel));
entry.dst_plane = img->get_plane(entry.channel, &(entry.dst_plane_stride));
entry.tile_width = m_tile_width;
entry.tile_height = m_tile_height;