static bool map_uncompressed_component_to_channel()

in libheif/codecs/uncompressed_image.cc [372:453]


static bool map_uncompressed_component_to_channel(const std::shared_ptr<Box_cmpd> &cmpd, const std::shared_ptr<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_Alpha;
        return true;
      case 1:
        *channel = heif_channel_R;
        return true;
      case 2:
        *channel = heif_channel_G;
        return true;
        case 3:
        *channel = heif_channel_B;
        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) {
  case component_type_monochrome:
    *channel = heif_channel_Y;
    return true;
  case component_type_Y:
    *channel = heif_channel_Y;
    return true;
  case component_type_Cb:
    *channel = heif_channel_Cb;
    return true;
  case component_type_Cr:
    *channel = heif_channel_Cr;
    return true;
  case component_type_red:
    *channel = heif_channel_R;
    return true;
  case component_type_green:
    *channel = heif_channel_G;
    return true;
  case component_type_blue:
    *channel = heif_channel_B;
    return true;
  case component_type_alpha:
    *channel = heif_channel_Alpha;
    return true;
  case component_type_padded:
    return false;
  default:
    printf("unmapped component_type: %d\n", component_type);
    return false;
  }
}