24#define CMS_NO_REGISTER_KEYWORD 1
39constexpr uint32_t
GRK_CIE_DAY = ((((uint32_t)
'C') << 24) + (((uint32_t)
'T') << 16));
129 void allocPalette(uint8_t num_channels, uint16_t num_entries);
130 uint32_t
width(
void)
const;
131 uint32_t
height(
void)
const;
132 void print(
void)
const;
134 bool componentsEqual(uint16_t firstNComponents,
bool checkPrecision)
const;
154 switch(comps[0].data_type)
172 switch(comps[0].data_type)
191 switch(comps[0].data_type)
306 void sycc_to_rgb(T offset, T upb, T y, T cb, T cr, T* out_r, T* out_g, T* out_b);
340 grklog.warn(
"cieLabToRGB: there must be at least three components");
344 grklog.warn(
"cieLabToRGB: there are more than three components : extra components will be "
348 if(comps[0].sgnd || comps[1].sgnd || comps[2].sgnd)
350 grklog.warn(
"cieLabToRGB: components must be unsigned");
354 for(i = 1U; i < numcomps; ++i)
357 auto compi = comps + i;
359 if(comp0->stride != compi->stride)
362 if(comp0->w != compi->w)
365 if(comp0->h != compi->h)
370 grklog.warn(
"cieLabToRGB: all components must have same dimensions, precision and sign");
374 auto row = (uint32_t*)meta->color.icc_profile_buf;
378 grklog.warn(
"enumCS %d not handled. Ignoring.", enumcs);
382 bool defaultType =
true;
385 T *L, *a, *b, *red, *green, *blue;
387 double r_L, o_L, r_a, o_a, r_b, o_b, prec_L, prec_a, prec_b;
388 double minL, maxL, mina, maxa, minb, maxb;
389 cmsUInt16Number RGB[3];
390 prec_L = (double)comps[0].prec;
391 prec_a = (double)comps[1].prec;
392 prec_b = (double)comps[2].prec;
401 o_a = pow(2, prec_a - 1);
402 o_b = 3 * pow(2, prec_b - 3);
414 cmsCIExyY WhitePoint;
420 cmsWhitePointFromTemp(&WhitePoint, 6504);
423 cmsWhitePointFromTemp(&WhitePoint, 7500);
426 cmsWhitePointFromTemp(&WhitePoint, 2856);
429 cmsWhitePointFromTemp(&WhitePoint, 6774);
432 cmsWhitePointFromTemp(&WhitePoint, 4100);
435 cmsWhitePointFromTemp(&WhitePoint, 6500);
438 cmsWhitePointFromTemp(&WhitePoint, 4000);
441 grklog.warn(
"Unrecognized illuminant %d in CIELab colour space. "
442 "Setting to default Daylight50",
449 auto in = cmsCreateLab4Profile(illuminant ==
GRK_CIE_D50 ?
nullptr : &WhitePoint);
451 auto out = cmsCreate_sRGBProfile();
452 auto transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, INTENT_PERCEPTUAL, 0);
455 cmsCloseProfile(out);
456 if(transform ==
nullptr)
459 L = (T*)comps[0].data;
460 a = (T*)comps[1].data;
461 b = (T*)comps[2].data;
465 grklog.warn(
"color_cielab_to_rgb: null L*a*b component");
469 auto dest_img =
createRGB(3, comps[0].w, comps[0].h, comps[0].prec);
473 red = (T*)dest_img->comps[0].data;
474 green = (T*)dest_img->comps[1].data;
475 blue = (T*)dest_img->comps[2].data;
477 uint32_t src_stride_diff = comps[0].stride - comps[0].w;
478 uint32_t dest_stride_diff = dest_img->comps[0].stride - dest_img->comps[0].w;
480 minL = -(r_L * o_L) / (pow(2, prec_L) - 1);
483 mina = -(r_a * o_a) / (pow(2, prec_a) - 1);
486 minb = -(r_b * o_b) / (pow(2, prec_b) - 1);
489 size_t dest_index = 0;
490 for(uint32_t j = 0; j < comps[0].h; ++j)
492 for(uint32_t k = 0; k < comps[0].w; ++k)
495 Lab.L = minL + (double)(*L) * (maxL - minL) / (pow(2, prec_L) - 1);
497 Lab.a = mina + (double)(*a) * (maxa - mina) / (pow(2, prec_a) - 1);
499 Lab.b = minb + (double)(*b) * (maxb - minb) / (pow(2, prec_b) - 1);
502 cmsDoTransform(transform, &Lab, RGB, 1);
504 red[dest_index] = (T)RGB[0];
505 green[dest_index] = (T)RGB[1];
506 blue[dest_index] = (T)RGB[2];
509 dest_index += dest_stride_diff;
510 L += src_stride_diff;
511 a += src_stride_diff;
512 b += src_stride_diff;
514 cmsDeleteTransform(transform);
516 for(i = 0; i < numcomps; ++i)
520 for(i = 0; i < numcomps; ++i)
522 auto srcComp = comps + i;
523 auto destComp = dest_img->comps + i;
526 srcComp->stride = destComp->stride;
527 srcComp->data = destComp->data;
543 uint32_t stride_diff = component->stride - component->w;
545 auto data = (T*)component->data;
550 if constexpr(std::is_floating_point_v<T>)
569 minimum =
static_cast<T
>(-(1LL << (precision - 1)));
570 maximum =
static_cast<T
>((1LL << (precision - 1)) - 1);
574 minimum =
static_cast<T
>(0);
575 maximum =
static_cast<T
>((1ULL << precision) - 1);
580 if constexpr(std::is_same_v<T, int32_t>)
582 hwy_clip_i32(data, component->w, component->h, component->stride, (int32_t)minimum,
587 for(uint32_t j = 0; j < component->h; ++j)
589 for(uint32_t i = 0; i < component->w; ++i)
591 data[index] = std::clamp<T>(data[index], minimum, maximum);
594 index += stride_diff;
597 component->prec = precision;
605 for(uint16_t compno = 0; compno < numcomps; ++compno)
607 uint32_t precisionno = compno;
608 if(precisionno >= num_precision)
609 precisionno = num_precision - 1U;
610 uint8_t prec = precision[precisionno].prec;
611 auto comp = comps + compno;
614 switch(precision[precisionno].mode)
629 uint8_t prec = comps[0].prec;
630 if(prec < 8 && numcomps > 1)
632 for(uint16_t i = 0; i < numcomps; ++i)
635 else if((prec > 1) && (prec < 8) && ((prec == 6) || ((prec & 1) == 1)))
637 if((prec == 5) || (prec == 6))
641 for(uint16_t i = 0; i < numcomps; ++i)
647 uint16_t nr_comp = numcomps;
650 grklog.warn(
"PNG: number of components %d is "
651 "greater than 4. Truncating to 4",
655 uint8_t prec = comps[0].prec;
656 if(prec > 8 && prec < 16)
660 else if(prec < 8 && nr_comp > 1)
664 else if((prec > 1) && (prec < 8) && ((prec == 6) || ((prec & 1) == 1)))
666 if((prec == 5) || (prec == 6))
671 for(uint16_t i = 0; i < nr_comp; ++i)
682 if(comps[0].sgnd || comps[1].sgnd || comps[2].sgnd)
684 grklog.warn(
"color_esycc_to_rgb: components must be unsigned");
688 T flip_value = (T)((1ULL << (comps[0].prec - 1)));
689 T max_value = (T)((1ULL << comps[0].prec) - 1);
691 uint32_t w = comps[0].w;
692 uint32_t h = comps[0].h;
694 bool sign1 = comps[1].sgnd;
695 bool sign2 = comps[2].sgnd;
697 uint32_t stride_diff = comps[0].stride - w;
698 size_t dest_index = 0;
699 auto yd = (T*)comps[0].data;
700 auto bd = (T*)comps[1].data;
701 auto rd = (T*)comps[2].data;
703 if constexpr(std::is_same_v<T, int32_t>)
709 for(uint32_t j = 0; j < h; ++j)
711 for(uint32_t i = 0; i < w; ++i)
713 T y = yd[dest_index];
714 T cb = bd[dest_index];
715 T cr = rd[dest_index];
722 T val = (T)(y - 0.0000368 * cb + 1.40199 * cr + 0.5);
728 yd[dest_index] = val;
730 val = (T)(1.0003 * y - 0.344125 * cb - 0.7141128 * cr + 0.5);
736 bd[dest_index] = val;
738 val = (T)(0.999823 * y + 1.77204 * cb - 0.000008 * cr + 0.5);
744 rd[dest_index] = val;
747 dest_index += stride_diff;
759 uint32_t w = comps[0].w;
760 uint32_t h = comps[0].h;
764 if(comps[0].sgnd || comps[1].sgnd || comps[2].sgnd || comps[3].sgnd)
766 grklog.warn(
"color_cmyk_to_rgb: components must be unsigned");
770 float sC = 1.0F / (float)((1ULL << comps[0].prec) - 1);
771 float sM = 1.0F / (float)((1ULL << comps[1].prec) - 1);
772 float sY = 1.0F / (float)((1ULL << comps[2].prec) - 1);
773 float sK = 1.0F / (float)((1ULL << comps[3].prec) - 1);
775 uint32_t stride_diff = comps[0].stride - w;
776 size_t dest_index = 0;
777 auto cd = (T*)comps[0].data;
778 auto md = (T*)comps[1].data;
779 auto yd = (T*)comps[2].data;
780 auto kd = (T*)comps[3].data;
782 for(uint32_t j = 0; j < h; ++j)
784 for(uint32_t i = 0; i < w; ++i)
787 float C = std::clamp((
float)(cd[dest_index]) * sC, 0.0f, 1.0f);
788 float M = std::clamp((
float)(md[dest_index]) * sM, 0.0f, 1.0f);
789 float Y = std::clamp((
float)(yd[dest_index]) * sY, 0.0f, 1.0f);
790 float K = std::clamp((
float)(kd[dest_index]) * sK, 0.0f, 1.0f);
799 cd[dest_index] = (T)(255.0F * C * K);
800 md[dest_index] = (T)(255.0F * M * K);
801 yd[dest_index] = (T)(255.0F * Y * K);
804 dest_index += stride_diff;
811 numcomps = (uint16_t)(numcomps - 1U);
814 for(uint16_t i = 3; i < numcomps; ++i)
815 memcpy(&(comps[i]), &(comps[i + 1]),
sizeof(comps[i]));
826 grklog.warn(
"color_sycc_to_rgb: number of components %d is not equal to 3."
827 " Unable to convert",
831 if(comps[0].sgnd || comps[1].sgnd || comps[2].sgnd)
833 grklog.warn(
"color_sycc_to_rgb: components must be unsigned");
839 if((comps[0].dx == 1) && (comps[1].dx == 2) && (comps[2].dx == 2) && (comps[0].dy == 1) &&
840 (comps[1].dy == 2) && (comps[2].dy == 2))
844 else if((comps[0].dx == 1) && (comps[1].dx == 2) && (comps[2].dx == 2) && (comps[0].dy == 1) &&
845 (comps[1].dy == 1) && (comps[2].dy == 1))
849 else if((comps[0].dx == 1) && (comps[1].dx == 1) && (comps[2].dx == 1) && (comps[0].dy == 1) &&
850 (comps[1].dy == 1) && (comps[2].dy == 1))
856 grklog.warn(
"color_sycc_to_rgb: Invalid sub-sampling: (%d,%d), (%d,%d), (%d,%d)."
857 " Unable to convert.",
858 comps[0].dx, comps[0].dy, comps[1].dx, comps[1].dy, comps[2].dx, comps[2].dy);
871 if(component->prec == precision)
874 (precision > component->prec) ? (precision - component->prec) : (component->prec - precision);
877 grklog.error(
"scaleComponent: precision difference %u too large", diff);
880 uint32_t stride_diff = component->stride - component->w;
881 auto data = (T*)component->data;
882 if(component->prec < precision)
884 T
scale = (T)(1ULL << diff);
885 if constexpr(std::is_same_v<T, int32_t>)
892 for(uint32_t j = 0; j < component->h; ++j)
894 for(uint32_t i = 0; i < component->w; ++i)
895 data[index++] *=
scale;
896 index += stride_diff;
902 T
scale = (T)(1ULL << diff);
903 if constexpr(std::is_same_v<T, int32_t>)
910 for(uint32_t j = 0; j < component->h; ++j)
912 for(uint32_t i = 0; i < component->w; ++i)
913 data[index++] /=
scale;
914 index += stride_diff;
918 component->prec = precision;
930 for(uint16_t compno = 0; compno < srcNumComps; compno++)
932 auto destComp = comps + compno;
936 auto srcComp = srcComps + compno;
939 grklog.warn(
"GrkImage::compositePlanar: cannot generate composite bounds for component %u",
945 grklog.warn(
"GrkImage::compositePlanar: null data for source component %u", compno);
949 auto destIndex = (size_t)destWin.
x0 + (
size_t)destWin.
y0 * destComp->stride;
950 size_t destLineOffset = (size_t)destComp->stride - (
size_t)destWin.
width();
951 uint32_t srcLineOffset = srcComp->stride - srcComp->w;
954 if(srcComp->data_type == destComp->data_type)
956 auto src_ptr = (T*)srcComp->data;
957 for(uint32_t j = 0; j < destWin.
height(); ++j)
959 memcpy((T*)destComp->data + destIndex, src_ptr + srcIndex,
960 (
size_t)destWin.
width() *
sizeof(T));
961 destIndex += destLineOffset + destWin.
width();
962 srcIndex += srcLineOffset + destWin.
width();
968 auto src16 = (int16_t*)srcComp->data;
969 auto dest32 = (int32_t*)destComp->data;
970 for(uint32_t j = 0; j < destWin.
height(); ++j)
972 for(uint32_t x = 0; x < destWin.
width(); ++x)
973 dest32[destIndex + x] = src16[srcIndex + x];
974 destIndex += destLineOffset + destWin.
width();
975 srcIndex += srcLineOffset + destWin.
width();
980 auto src_ptr = (T*)srcComp->data;
981 for(uint32_t j = 0; j < destWin.
height(); ++j)
983 memcpy((T*)destComp->data + destIndex, src_ptr + srcIndex,
984 (
size_t)destWin.
width() *
sizeof(T));
985 destIndex += destLineOffset + destWin.
width();
986 srcIndex += srcLineOffset + destWin.
width();
1015 r = y + (T)(1.402 * cr);
1022 g = y - (T)(0.344 * cb + 0.714 * cr);
1029 b = y + (T)(1.772 * cb);
1040 T *d0, *d1, *d2, *r, *g, *b;
1041 auto dst =
createRGB(3, comps[0].w, comps[0].h, comps[0].prec);
1045 T offset = (T)(1ULL << (comps[0].prec - 1));
1046 T upb = (T)((1ULL << comps[0].prec) - 1);
1048 uint32_t w = comps[0].w;
1049 uint32_t src_stride_diff = comps[0].stride - w;
1050 uint32_t dst_stride_diff = dst->comps[0].stride - dst->comps[0].w;
1051 uint32_t h = comps[0].h;
1053 auto y = (T*)comps[0].data;
1054 auto cb = (T*)comps[1].data;
1055 auto cr = (T*)comps[2].data;
1057 d0 = r = (T*)dst->comps[0].data;
1058 d1 = g = (T*)dst->comps[1].data;
1059 d2 = b = (T*)dst->comps[2].data;
1061 dst->comps[0].data =
nullptr;
1062 dst->comps[1].data =
nullptr;
1063 dst->comps[2].data =
nullptr;
1065 if constexpr(std::is_same_v<T, int32_t>)
1067 hwy_sycc444_to_rgb_i32(y, cb, cr, r, g, b, w, h, comps[0].stride, dst->comps[0].stride, offset,
1072 for(uint32_t j = 0; j < h; ++j)
1074 for(uint32_t i = 0; i < w; ++i)
1076 y += src_stride_diff;
1077 cb += src_stride_diff;
1078 cr += src_stride_diff;
1079 r += dst_stride_diff;
1080 g += dst_stride_diff;
1081 b += dst_stride_diff;
1091 for(uint16_t i = 0; i < numcomps; ++i)
1093 comps[i].stride = dst->comps[i].stride;
1094 comps[i].owns_data =
true;
1105 uint32_t w = comps[0].w;
1106 uint32_t h = comps[0].h;
1107 uint32_t loopWidth = w;
1111 if((loopWidth + 1) / 2 != comps[1].w)
1113 grklog.warn(
"incorrect subsampled width %u", comps[1].w);
1117 auto dst =
createRGB(3, w, h, comps[0].prec);
1121 T offset = (T)(1ULL << (comps[0].prec - 1));
1122 T upb = (T)((1ULL << comps[0].prec) - 1);
1124 uint32_t dst_stride_diff = dst->comps[0].stride - dst->comps[0].w;
1125 uint32_t src_stride_diff = comps[0].stride - w;
1126 uint32_t src_stride_diff_chroma = comps[1].stride - comps[1].w;
1128 T *d0, *d1, *d2, *r, *g, *b;
1130 auto y = (T*)comps[0].data;
1133 grklog.warn(
"sycc422_to_rgb: null luma channel");
1136 auto cb = (T*)comps[1].data;
1137 auto cr = (T*)comps[2].data;
1140 grklog.warn(
"sycc422_to_rgb: null chroma channel");
1144 d0 = r = (T*)dst->comps[0].data;
1145 d1 = g = (T*)dst->comps[1].data;
1146 d2 = b = (T*)dst->comps[2].data;
1148 dst->comps[0].data =
nullptr;
1149 dst->comps[1].data =
nullptr;
1150 dst->comps[2].data =
nullptr;
1152 for(uint32_t i = 0U; i < h; ++i)
1158 for(j = 0U; j < (loopWidth & ~(size_t)1U); j += 2U)
1166 y += src_stride_diff;
1167 cb += src_stride_diff_chroma;
1168 cr += src_stride_diff_chroma;
1169 r += dst_stride_diff;
1170 g += dst_stride_diff;
1171 b += dst_stride_diff;
1179 comps[1].w = comps[2].w = w;
1180 comps[1].h = comps[2].h = h;
1181 comps[1].dx = comps[2].dx = comps[0].dx;
1182 comps[1].dy = comps[2].dy = comps[0].dy;
1185 for(uint32_t i = 0; i < numcomps; ++i)
1187 comps[i].stride = dst->comps[i].stride;
1188 comps[i].owns_data =
true;
1199 uint32_t w = comps[0].w;
1200 uint32_t h = comps[0].h;
1201 uint32_t loopWidth = w;
1206 uint32_t loopHeight = h;
1212 if((loopWidth + 1) / 2 != comps[1].w)
1214 grklog.warn(
"incorrect subsampled width %u", comps[1].w);
1217 if((loopHeight + 1) / 2 != comps[1].h)
1219 grklog.warn(
"incorrect subsampled height %u", comps[1].h);
1223 auto rgbImg =
createRGB(3, w, h, comps[0].prec);
1227 T offset = (T)(1ULL << (comps[0].prec - 1));
1228 T upb = (T)((1ULL << comps[0].prec) - 1);
1230 uint32_t stride_src[3];
1231 uint32_t stride_src_diff[3];
1233 uint32_t stride_dest = rgbImg->comps[0].stride;
1234 uint32_t stride_dest_diff = rgbImg->comps[0].stride - w;
1238 for(uint32_t i = 0; i < 3; ++i)
1240 auto srcComp = comps + i;
1241 src[i] = (T*)srcComp->data;
1242 stride_src[i] = srcComp->stride;
1243 stride_src_diff[i] = srcComp->stride - srcComp->w;
1245 dest_ptr[i] = (T*)rgbImg->comps[i].data;
1250 for(
size_t j = 0U; j < w; ++j)
1251 sycc_to_rgb<T>(offset, upb, *src[0]++, 0, 0, dest_ptr[0]++, dest_ptr[1]++, dest_ptr[2]++);
1252 src[0] += stride_src_diff[0];
1253 for(uint32_t i = 0; i < 3; ++i)
1254 dest_ptr[i] += stride_dest_diff;
1258 for(i = 0U; i < (loopHeight & ~(size_t)1U); i += 2U)
1260 auto nextY = src[0] + stride_src[0];
1261 auto nextRed = dest_ptr[0] + stride_dest;
1262 auto nextGreen = dest_ptr[1] + stride_dest;
1263 auto nextBlue = dest_ptr[2] + stride_dest;
1267 sycc_to_rgb<T>(offset, upb, *src[0]++, 0, 0, dest_ptr[0]++, dest_ptr[1]++, dest_ptr[2]++);
1268 sycc_to_rgb<T>(offset, upb, *nextY++, *src[1], *src[2], nextRed++, nextGreen++, nextBlue++);
1271 for(j = 0U; j < (loopWidth & ~(size_t)1U); j += 2U)
1273 sycc_to_rgb<T>(offset, upb, *src[0]++, *src[1], *src[2], dest_ptr[0]++, dest_ptr[1]++,
1275 sycc_to_rgb<T>(offset, upb, *nextY++, *src[1], *src[2], nextRed++, nextGreen++, nextBlue++);
1277 sycc_to_rgb<T>(offset, upb, *src[0]++, *src[1], *src[2], dest_ptr[0]++, dest_ptr[1]++,
1279 sycc_to_rgb<T>(offset, upb, *nextY++, *src[1]++, *src[2]++, nextRed++, nextGreen++,
1284 sycc_to_rgb<T>(offset, upb, *src[0]++, *src[1], *src[2], dest_ptr[0]++, dest_ptr[1]++,
1286 sycc_to_rgb<T>(offset, upb, *nextY++, *src[1]++, *src[2]++, nextRed++, nextGreen++,
1289 for(uint32_t k = 0; k < 3; ++k)
1291 dest_ptr[k] += stride_dest_diff + stride_dest;
1292 src[k] += stride_src_diff[k];
1294 src[0] += stride_src[0];
1301 sycc_to_rgb<T>(offset, upb, *src[0]++, 0, 0, dest_ptr[0]++, dest_ptr[1]++, dest_ptr[2]++);
1303 for(j = 0U; j < (loopWidth & ~(size_t)1U); j += 2U)
1305 sycc_to_rgb<T>(offset, upb, *src[0]++, *src[1], *src[2], dest_ptr[0]++, dest_ptr[1]++,
1307 sycc_to_rgb<T>(offset, upb, *src[0]++, *src[1]++, *src[2]++, dest_ptr[0]++, dest_ptr[1]++,
1311 sycc_to_rgb<T>(offset, upb, *src[0], *src[1], *src[2], dest_ptr[0], dest_ptr[1], dest_ptr[2]);
1315 for(uint32_t k = 0; k < 3; ++k)
1317 comps[k].data = rgbImg->comps[k].data;
1318 comps[k].stride = rgbImg->comps[k].stride;
1319 comps[k].owns_data =
true;
1320 rgbImg->comps[k].data =
nullptr;
1324 comps[1].w = comps[2].w = comps[0].w;
1325 comps[1].h = comps[2].h = comps[0].h;
1326 comps[1].dx = comps[2].dx = comps[0].dx;
1327 comps[1].dy = comps[2].dy = comps[0].dy;
1340 auto clr = &meta->color;
1341 auto pal = clr->palette;
1342 auto channel_prec = pal->channel_prec;
1343 auto channel_sign = pal->channel_sign;
1344 auto lut = pal->lut;
1345 auto component_mapping = pal->component_mapping;
1346 uint16_t num_channels = pal->num_channels;
1349 for(uint16_t channel = 0; channel < num_channels; ++channel)
1351 auto mapping = component_mapping + channel;
1352 uint16_t compno = mapping->component;
1353 auto comp = comps + compno;
1354 if(compno >= numcomps)
1356 grklog.error(
"apply_palette_clr: component mapping component number %u for channel %u "
1357 "must be less than number of image components %u",
1358 compno, channel, numcomps);
1361 if(comp->data ==
nullptr)
1363 grklog.error(
"comps[%u].data == nullptr"
1364 " in apply_palette_clr().",
1368 if((1ULL << comp->prec) > pal->num_entries)
1370 grklog.error(
"Precision %u of component %u implies max value greater than "
1371 "number of palette entries %u",
1372 comp->prec, compno, pal->num_entries);
1375 uint16_t paletteColumn = mapping->palette_column;
1376 switch(mapping->mapping_type)
1379 if(paletteColumn != 0)
1381 grklog.error(
"apply_palette_clr: channel %u with direct component mapping: "
1382 "non-zero palette column %u not allowed",
1383 channel, paletteColumn);
1390 grklog.error(
"apply_palette_clr: channel %u with non-direct component mapping: "
1400 std::set<uint16_t> usedColumns;
1401 for(uint16_t channel = 0; channel < num_channels; ++channel)
1403 auto mapping = component_mapping + channel;
1404 if(mapping->mapping_type == 1)
1406 uint16_t paletteColumn = mapping->palette_column;
1407 if(usedColumns.count(paletteColumn))
1409 grklog.error(
"apply_palette_clr: duplicate palette column %u in mappings", paletteColumn);
1412 usedColumns.insert(paletteColumn);
1416 auto oldComps = comps;
1419 for(uint16_t channel = 0; channel < num_channels; ++channel)
1421 auto mapping = component_mapping + channel;
1422 uint16_t compno = mapping->component;
1423 newComps[channel] = oldComps[compno];
1424 newComps[channel].data =
nullptr;
1428 for(uint16_t ch = 0; ch < channel; ++ch)
1433 grklog.error(
"Memory allocation failure in apply_palette_clr().");
1436 newComps[channel].prec = channel_prec[channel];
1437 newComps[channel].sgnd = channel_sign[channel];
1439 uint32_t top_k = pal->num_entries - 1;
1440 for(uint16_t channel = 0; channel < num_channels; ++channel)
1443 auto mapping = component_mapping + channel;
1444 uint16_t compno = mapping->component;
1445 auto src = (T*)oldComps[compno].data;
1446 auto dst = (T*)newComps[channel].data;
1447 size_t num_pixels = (size_t)newComps[channel].stride * newComps[channel].h;
1448 uint32_t diff = (uint32_t)(newComps[channel].stride - newComps[channel].w);
1451 switch(mapping->mapping_type)
1454 memcpy(dst, src, num_pixels *
sizeof(T));
1458 uint16_t palette_column = mapping->palette_column;
1460 for(uint32_t n = 0; n < newComps[channel].h; ++n)
1462 for(uint32_t m = 0; m < newComps[channel].w; ++m)
1464 uint32_t k =
static_cast<uint32_t
>(src[ind]);
1467 dst[ind++] = (T)lut[k * num_channels + palette_column];
1475 for(uint16_t i = 0; i < numcomps; ++i)
1479 numcomps = num_channels;
1480 palette_applied =
true;
1495 bool upsampleNeeded =
false;
1497 for(uint16_t compno = 0U; compno < numcomps; ++compno)
1499 if((comps[compno].dx > 1U) || (comps[compno].dy > 1U))
1501 upsampleNeeded =
true;
1510 for(uint16_t compno = 0U; compno < numcomps; ++compno)
1512 auto new_cmp = new_components + compno;
1516 new_cmp->w = x1 - x0;
1517 new_cmp->h = y1 - y0;
1520 delete[] new_components;
1524 for(uint16_t compno = 0U; compno < numcomps; ++compno)
1526 auto new_cmp = new_components + compno;
1527 auto org_cmp = comps + compno;
1528 if((org_cmp->dx > 1U) || (org_cmp->dy > 1U))
1530 auto src = (T*)org_cmp->data;
1531 auto dst = (T*)new_cmp->data;
1534 uint32_t xoff = org_cmp->dx * org_cmp->x0 - x0;
1535 uint32_t yoff = org_cmp->dy * org_cmp->y0 - y0;
1536 if((xoff >= org_cmp->dx) || (yoff >= org_cmp->dy))
1538 grklog.error(
"upsample: Invalid image/component parameters found when upsampling");
1539 delete[] new_components;
1544 for(y = 0U; y < yoff; ++y)
1546 memset(dst, 0U, (
size_t)new_cmp->w *
sizeof(T));
1547 dst += new_cmp->stride;
1550 if(new_cmp->h > (org_cmp->dy - 1U))
1552 for(; y < new_cmp->h - (org_cmp->dy - 1U); y += org_cmp->dy)
1556 for(x = 0U; x < xoff; ++x)
1559 if(new_cmp->w > (org_cmp->dx - 1U))
1561 for(; x < new_cmp->w - (org_cmp->dx - 1U); x += org_cmp->dx, ++xorg)
1563 for(uint32_t dx = 0U; dx < org_cmp->dx; ++dx)
1564 dst[x + dx] = src[xorg];
1567 for(; x < new_cmp->w; ++x)
1569 dst += new_cmp->stride;
1571 for(dy = 1U; dy < org_cmp->dy; ++dy)
1573 memcpy(dst, dst - new_cmp->stride, (
size_t)new_cmp->w *
sizeof(T));
1574 dst += new_cmp->stride;
1576 src += org_cmp->stride;
1583 for(x = 0U; x < xoff; ++x)
1586 if(new_cmp->w > (org_cmp->dx - 1U))
1588 for(; x < new_cmp->w - (org_cmp->dx - 1U); x += org_cmp->dx, ++xorg)
1590 for(uint32_t dx = 0U; dx < org_cmp->dx; ++dx)
1591 dst[x + dx] = src[xorg];
1594 for(; x < new_cmp->w; ++x)
1596 dst += new_cmp->stride;
1598 for(; y < new_cmp->h; ++y)
1600 memcpy(dst, dst - new_cmp->stride, (
size_t)new_cmp->w *
sizeof(T));
1601 dst += new_cmp->stride;
1607 memcpy(new_cmp->data, org_cmp->data, (
size_t)org_cmp->stride * org_cmp->h *
sizeof(T));
1612 comps = new_components;
1627 auto srcComp = srcComps;
1628 auto destComp = comps;
1630 for(uint16_t i = 0; i < srcNumComps; ++i)
1632 if(!(srcComps + i)->data)
1634 grklog.warn(
"GrkImage::compositeInterleaved: null data for source component %u", i);
1640 grklog.warn(
"GrkImage::compositeInterleaved: cannot generate composite bounds");
1643 uint8_t prec = destComp->prec;
1644 switch(decompress_fmt)
1649 prec = prec > 8 ? 16 : 8;
1655 auto destStride = grk::PlanarToInterleaved<T>::getPackedBytes(srcNumComps, destComp->w, prec);
1656 auto destx0 = grk::PlanarToInterleaved<T>::getPackedBytes(srcNumComps, destWin.
x0, prec);
1657 auto destIndex = (uint64_t)destWin.
y0 * destStride + (uint64_t)destx0;
1658 auto iter = InterleaverFactory<T>::makeInterleaver(
1659 prec == 16 && decompress_fmt !=
GRK_FMT_TIF ? packer16BitBE : prec);
1662 auto planes = std::make_unique<T*[]>(numcomps);
1663 for(uint16_t i = 0; i < srcNumComps; ++i)
1664 planes[i] = (T*)(srcComps + i)->data;
1665 iter->interleave(
const_cast<T**
>(planes.get()), srcNumComps, interleaved_data.data + destIndex,
1666 destWin.
width(), srcComp->stride, destStride, destWin.
height(), 0);
1677 cmsUInt32Number out_space;
1678 cmsUInt32Number intent = 0;
1679 cmsHTRANSFORM transform =
nullptr;
1680 cmsHPROFILE in_prof =
nullptr;
1681 cmsHPROFILE out_prof =
nullptr;
1682 cmsUInt32Number in_type, out_type;
1683 size_t nr_samples, componentSize;
1684 uint32_t prec, w, stride_diff, h;
1693 for(uint16_t i = 0; i < numcomps; ++i)
1697 grklog.warn(
"applyICC: components must be unsigned");
1701 if(!meta || !meta->color.icc_profile_buf || !meta->color.icc_profile_len)
1703 in_prof = cmsOpenProfileFromMem(meta->color.icc_profile_buf, meta->color.icc_profile_len);
1708 out_space = cmsGetColorSpace(in_prof);
1709 intent = cmsGetHeaderRenderingIntent(in_prof);
1712 stride_diff = comps[0].stride - w;
1716 componentSize = (size_t)w * h;
1718 prec = comps[0].prec;
1719 oldspace = color_space;
1721 if(out_space == cmsSigRgbData)
1723 uint16_t i, nr_comp = numcomps;
1727 for(i = 1; i < nr_comp; ++i)
1729 if(comps[0].dx != comps[i].dx)
1731 if(comps[0].dy != comps[i].dy)
1733 if(comps[0].prec != comps[i].prec)
1735 if(comps[0].sgnd != comps[i].sgnd)
1743 in_type = TYPE_RGB_8;
1744 out_type = TYPE_RGB_8;
1748 in_type = TYPE_RGB_16;
1749 out_type = TYPE_RGB_16;
1751 out_prof = cmsCreate_sRGBProfile();
1754 else if(out_space == cmsSigGrayData)
1758 in_type = TYPE_GRAY_8;
1759 out_type = TYPE_RGB_8;
1763 in_type = TYPE_GRAY_16;
1764 out_type = TYPE_RGB_16;
1766 out_prof = cmsCreate_sRGBProfile();
1772 else if(out_space == cmsSigYCbCrData)
1776 in_type = TYPE_YCbCr_8;
1777 out_type = TYPE_RGB_8;
1781 in_type = TYPE_YCbCr_16;
1782 out_type = TYPE_RGB_16;
1784 out_prof = cmsCreate_sRGBProfile();
1789 grklog.warn(
"Apply ICC profile has unknown "
1790 "output color space (%#x)\nICC profile ignored.",
1794 transform = cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
1797 color_space = oldspace;
1805 nr_samples = componentSize * 3U;
1806 if(nr_samples / 3U != componentSize)
1808 grklog.error(
"nr_samples overflow in applyICC");
1811 if(w > UINT32_MAX / 3)
1813 grklog.error(
"Image width of {} converted to sample size 3 will overflow.", w);
1816 auto inbuf =
new uint8_t[nr_samples];
1817 auto outbuf =
new uint8_t[nr_samples];
1819 auto r = (T*)comps[0].data;
1820 auto g = (T*)comps[1].data;
1821 auto b = (T*)comps[2].data;
1823 if constexpr(std::is_same_v<T, int32_t>)
1829 size_t src_index = 0;
1830 size_t dest_index = 0;
1831 for(uint32_t j = 0; j < h; ++j)
1833 for(uint32_t i = 0; i < w; ++i)
1835 inbuf[dest_index++] = (uint8_t)r[src_index];
1836 inbuf[dest_index++] = (uint8_t)g[src_index];
1837 inbuf[dest_index++] = (uint8_t)b[src_index];
1840 src_index += stride_diff;
1844 cmsDoTransformLineStride(transform, inbuf, outbuf, w, h, 3 * w, 3 * w, 0, 0);
1846 if constexpr(std::is_same_v<T, int32_t>)
1852 size_t src_index = 0;
1853 size_t dest_index = 0;
1854 for(uint32_t j = 0; j < h; ++j)
1856 for(uint32_t i = 0; i < w; ++i)
1858 r[dest_index] = (T)outbuf[src_index++];
1859 g[dest_index] = (T)outbuf[src_index++];
1860 b[dest_index] = (T)outbuf[src_index++];
1863 dest_index += stride_diff;
1871 if(componentSize > (
SIZE_MAX / 3) /
sizeof(uint16_t))
1873 grklog.error(
"nr_samples overflow in applyICC");
1876 if(w > UINT32_MAX / (3 *
sizeof(uint16_t)))
1878 grklog.error(
"Image width of {} converted to sample size 3 @ 16 bits will overflow.", w);
1881 nr_samples = componentSize * 3U *
sizeof(uint16_t);
1882 auto inbuf =
new uint16_t[nr_samples /
sizeof(uint16_t)];
1883 auto outbuf =
new uint16_t[nr_samples /
sizeof(uint16_t)];
1885 auto r = (T*)comps[0].data;
1886 auto g = (T*)comps[1].data;
1887 auto b = (T*)comps[2].data;
1889 if constexpr(std::is_same_v<T, int32_t>)
1895 size_t src_index = 0;
1896 size_t dest_index = 0;
1897 for(uint32_t j = 0; j < h; ++j)
1899 for(uint32_t i = 0; i < w; ++i)
1901 inbuf[dest_index++] = (uint16_t)r[src_index];
1902 inbuf[dest_index++] = (uint16_t)g[src_index];
1903 inbuf[dest_index++] = (uint16_t)b[src_index];
1906 src_index += stride_diff;
1910 cmsDoTransformLineStride(transform, inbuf, outbuf, w, h, 3 * w *
sizeof(uint16_t),
1911 3 * w *
sizeof(uint16_t), 0, 0);
1912 if constexpr(std::is_same_v<T, int32_t>)
1918 size_t src_index = 0;
1919 size_t dest_index = 0;
1920 for(uint32_t j = 0; j < h; ++j)
1922 for(uint32_t i = 0; i < w; ++i)
1924 r[dest_index] = (T)outbuf[src_index++];
1925 g[dest_index] = (T)outbuf[src_index++];
1926 b[dest_index] = (T)outbuf[src_index++];
1929 dest_index += stride_diff;
1938 nr_samples = componentSize * 3U;
1939 if(nr_samples / 3U != componentSize)
1941 grklog.error(
"nr_samples overflow in applyICC");
1947 grklog.error(
"Memory allocation failure in applyICC");
1950 for(uint16_t i = 0; i < numcomps + 2U; ++i)
1953 newComps[i] = comps[i];
1961 if(w > UINT32_MAX / 3)
1963 grklog.error(
"Image width of {} converted to sample size 3 will overflow.", w);
1966 auto inbuf =
new uint8_t[componentSize];
1967 auto outbuf =
new uint8_t[nr_samples];
1969 auto r = (T*)comps[0].data;
1970 size_t src_index = 0;
1971 size_t dest_index = 0;
1972 for(uint32_t j = 0; j < h; ++j)
1974 for(uint32_t i = 0; i < w; ++i)
1975 inbuf[dest_index++] = (uint8_t)r[src_index++];
1976 src_index += stride_diff;
1978 cmsDoTransformLineStride(transform, inbuf, outbuf, w, h, w, 3 * w, 0, 0);
1979 T *g =
nullptr, *b =
nullptr;
1983 comps[3] = comps[1];
1984 comps[1] = comps[0];
1987 comps[2] = comps[0];
1990 numcomps = (uint16_t)(2 + numcomps);
1991 g = (T*)comps[1].data;
1992 b = (T*)comps[2].data;
1996 for(uint32_t j = 0; j < h; ++j)
1998 for(uint32_t i = 0; i < w; ++i)
2000 r[dest_index] = (T)outbuf[src_index++];
2003 g[dest_index] = (T)outbuf[src_index++];
2004 b[dest_index] = (T)outbuf[src_index++];
2012 dest_index += stride_diff;
2019 if(componentSize >
SIZE_MAX /
sizeof(uint16_t))
2021 grklog.error(
"componentSize overflow in applyICC");
2024 if(componentSize * 3U >
SIZE_MAX /
sizeof(uint16_t))
2026 grklog.error(
"nr_samples overflow in applyICC");
2029 if(w > UINT32_MAX / (3 *
sizeof(uint16_t)))
2031 grklog.error(
"Image width of {} converted to sample size 3 @ 16 bits will overflow.", w);
2034 auto inbuf =
new uint16_t[componentSize];
2035 auto outbuf =
new uint16_t[componentSize * 3U];
2037 auto r = (T*)comps[0].data;
2038 size_t src_index = 0;
2039 size_t dest_index = 0;
2040 for(uint32_t j = 0; j < h; ++j)
2042 for(uint32_t i = 0; i < w; ++i)
2043 inbuf[dest_index++] = (uint16_t)r[src_index++];
2044 src_index += stride_diff;
2046 cmsDoTransformLineStride(transform, inbuf, outbuf, w, h, w *
sizeof(uint16_t),
2047 3 * w *
sizeof(uint16_t), 0, 0);
2048 T *g =
nullptr, *b =
nullptr;
2052 comps[3] = comps[1];
2053 comps[1] = comps[0];
2056 comps[2] = comps[0];
2059 numcomps = (uint16_t)(2 + numcomps);
2060 g = (T*)comps[1].data;
2061 b = (T*)comps[2].data;
2065 for(uint32_t j = 0; j < h; ++j)
2067 for(uint32_t i = 0; i < w; ++i)
2069 r[dest_index] = (T)outbuf[src_index++];
2072 g[dest_index] = (T)outbuf[src_index++];
2073 b[dest_index] = (T)outbuf[src_index++];
2081 dest_index += stride_diff;
2088 delete[] meta->color.icc_profile_buf;
2089 meta->color.icc_profile_buf =
nullptr;
2090 meta->color.icc_profile_len = 0;
2093 cmsCloseProfile(in_prof);
2095 cmsCloseProfile(out_prof);
2097 cmsDeleteTransform(transform);
2111 grklog.error(
"grk_decompress: YCC: number of components %d "
2118 bool oddFirstX = x0 & 1;
2119 bool oddFirstY = y0 & 1;
2129 grklog.warn(
"grk_decompress: sYCC to RGB colour conversion failed");
2135 grklog.error(
"grk_decompress: YCC: number of components %d "
2141 grklog.warn(
"grk_decompress: eYCC to RGB colour conversion failed");
2146 grklog.error(
"grk_decompress: CMYK: number of components %d "
2152 grklog.warn(
"grk_decompress: CMYK to RGB colour conversion failed");
2164 if(!meta || !meta->color.icc_profile_buf)
2173 bool shouldApplyColourManagement =
2174 force_rgb || (decompress_fmt !=
GRK_FMT_UNK && meta->color.icc_profile_buf &&
2175 ((isCIE && !canStoreCIE) || !canStoreICC));
2176 if(!shouldApplyColourManagement)
2182 grklog.warn(
" Input image is in CIE colour space,\n"
2183 "but the codec is unable to store this information in the "
2185 "The output image will therefore be converted to sRGB before saving.");
2188 grklog.error(
"Unable to convert L*a*b image to sRGB");
2199 grklog.warn(
"The input image contains an ICC profile");
2200 grklog.warn(
"but the codec is unable to store this profile"
2201 " in the output file.");
2202 grklog.warn(
"The profile will therefore be applied to the output"
2203 " image before saving.");
2208 grklog.warn(
"Unable to apply ICC profile");
2237 if(meta->color.palette)
2240 if(!meta->color.palette->component_mapping)
2245 if(meta->color.channel_definition)
#define SIZE_MAX
Definition MemManager.h:37
bool cieLabToRGB(void)
Definition GrkImage.h:333
bool subsampleAndReduce(uint8_t reduce)
Generates subsampled and reduced bounds for components.
Definition GrkImage.cpp:258
bool sycc444_to_rgb(void)
Definition GrkImage.h:1038
bool compositePlanar(uint16_t srcNumComps, grk_image_comp *srcComps)
Copy planar image data to planar composite image.
Definition GrkImage.h:928
void apply_channel_definition(void)
Definition GrkImage.cpp:647
void convertPrecision(void)
Definition GrkImage.h:601
GrkImage()
Constructs a GrkImage.
Definition GrkImage.cpp:55
bool postProcess_T(void)
Definition GrkImage.h:2218
bool apply_palette_clr()
Definition GrkImage.h:1335
bool sycc420_to_rgb(bool oddFirstX, bool oddFirstY)
Definition GrkImage.h:1197
static GrkImage * create(grk_image *src, uint16_t numcmpts, grk_image_comp *cmptparms, GRK_COLOR_SPACE clrspc, bool doAllocation)
Creates a GrkImage.
Definition GrkImage.cpp:158
std::string getColourSpaceString(void) const
Definition GrkImage.cpp:1127
bool needsChannelDefinitionSwap(void) const
Definition GrkImage.cpp:609
bool convertToRGB_T()
Definition GrkImage.h:2103
void applyChannelDefinitionTypes(void)
Definition GrkImage.cpp:632
bool isValidICCColourSpace(uint32_t signature) const
Definition GrkImage.cpp:1190
void print(void) const
Definition GrkImage.cpp:85
void scaleComponent(grk_image_comp *component, uint8_t precision)
Definition GrkImage.h:869
void transferDataFrom_T(const Tile *tile_src_data)
Definition GrkImage.cpp:1360
bool color_cmyk_to_rgb(void)
Definition GrkImage.h:757
bool validateICC(void)
Definition GrkImage.cpp:1215
static size_t sizeOfDataType(grk_data_type type)
Definition GrkImage.cpp:95
bool sycc422_to_rgb(bool oddFirstX)
Definition GrkImage.h:1102
bool allocCompositeData(void)
Allocate data for tile compositing.
Definition GrkImage.cpp:859
bool allComponentsSanityCheck(bool equalPrecision) const
return false if :
Definition GrkImage.cpp:1040
bool greyToRGB(void)
Convert to sRGB.
Definition GrkImage.cpp:1317
GrkImage * extractFrom(const Tile *tile_src) const
Create new image and transfer tile buffer data.
Definition GrkImage.cpp:951
bool compositeInterleaved_T(const Tile *src, uint32_t yBegin, uint32_t yEnd)
bool color_sycc_to_rgb(bool oddFirstX, bool oddFirstY)
Definition GrkImage.h:822
bool isPostProcessNoOp(void) const
Check if postProcess would be a no-op for the current image.
Definition GrkImage.cpp:447
void validateColourSpace(void)
Definition GrkImage.cpp:429
static void copyComponent(grk_image_comp *src, grk_image_comp *dest)
Definition GrkImage.cpp:114
static void setDataToNull(grk_image_comp *comp)
Definition GrkImage.cpp:314
void sycc_to_rgb(T offset, T upb, T y, T cb, T cr, T *out_r, T *out_g, T *out_b)
Definition GrkImage.h:1009
bool generateCompositeBounds(const grk_image_comp *srcComp, uint16_t destCompno, Rect32 *destWin)
Definition GrkImage.cpp:1010
void copyHeaderTo(GrkImage *dest) const
Copies only header of image and its component header.
Definition GrkImage.cpp:329
uint32_t height(void) const
Definition GrkImage.cpp:75
Rect32 getBounds(void) const
Gets unreduced, non-subsampled image bounds.
Definition GrkImage.cpp:80
bool applyICC(void)
Definition GrkImage.h:1675
bool applyColourManagement(void)
Definition GrkImage.h:2162
void transferDataFrom(const Tile *tile_src_data)
Definition GrkImage.cpp:1378
static bool allocData(grk_image_comp *imageComp, bool clear)
Allocate data for single image component.
Definition GrkImage.cpp:395
bool postProcess(void)
Definition GrkImage.h:170
void filterComponents(const std::vector< uint16_t > &compsToKeep)
Definition GrkImage.cpp:920
bool applyColour_T(void)
Definition GrkImage.h:2233
bool applyColour(void)
Definition GrkImage.h:189
bool componentsEqual(bool checkPrecision) const
Definition GrkImage.cpp:144
bool isSubsampled() const
Definition GrkImage.cpp:419
void postReadHeader(CodingParams *cp)
Definition GrkImage.cpp:510
bool check_color(uint16_t signalledNumComps)
Definition GrkImage.cpp:703
~GrkImage()
Destroys a GrkImage.
Definition GrkImage.cpp:61
void transferDataTo(GrkImage *dest)
Transfer data to dest for each component, and null out "this" data.
Definition GrkImage.cpp:893
bool isOpacity(uint16_t compno) const
Definition GrkImage.cpp:438
std::string getICCColourSpaceString(cmsColorSpaceSignature color_space) const
Definition GrkImage.cpp:1163
bool composite(const GrkImage *src)
Definition GrkImage.cpp:978
static void single_component_data_free(grk_image_comp *comp)
Definition GrkImage.cpp:1018
uint32_t width(void) const
Definition GrkImage.cpp:71
bool compositeInterleaved(const Tile *src, uint32_t yBegin, uint32_t yEnd)
Definition GrkImage.h:152
void all_components_data_free(void)
Definition GrkImage.cpp:239
void allocPalette(uint8_t num_channels, uint16_t num_entries)
Definition GrkImage.cpp:604
bool needsConversionToRGB(void) const
Definition GrkImage.cpp:250
grk_image * createRGB(uint16_t numcmpts, uint32_t w, uint32_t h, uint8_t prec)
Definition GrkImage.cpp:1105
bool execUpsample(void)
Definition GrkImage.h:1486
bool color_esycc_to_rgb(void)
Definition GrkImage.h:678
Definition GrkObjectWrapper.h:31
enum _grk_data_type grk_data_type
Grok Data types Used to specify the actual data type of Grok image components.
@ GRK_FMT_BMP
Definition grok.h:307
@ GRK_FMT_PNG
Definition grok.h:310
@ GRK_FMT_UNK
Definition grok.h:301
@ GRK_FMT_TIF
Definition grok.h:308
@ GRK_FMT_JPG
Definition grok.h:312
@ GRK_FMT_PXM
Definition grok.h:304
enum _GRK_ENUM_COLOUR_SPACE GRK_ENUM_COLOUR_SPACE
JPEG 2000 enumerated color spaces.
#define GRK_MAX_SUPPORTED_IMAGE_PRECISION
maximum Grok supported precision
Definition grok.h:150
@ GRK_INT_32
Definition grok.h:768
@ GRK_INT_16
Definition grok.h:769
@ GRK_CLRSPC_SRGB
unknown
Definition grok.h:90
@ GRK_CLRSPC_EYCC
standard YCC (YUV)
Definition grok.h:93
@ GRK_CLRSPC_SYCC
grayscale
Definition grok.h:92
@ GRK_CLRSPC_DEFAULT_CIE
CMYK.
Definition grok.h:95
@ GRK_CLRSPC_CMYK
extended YCC
Definition grok.h:94
@ GRK_CLRSPC_GRAY
sRGB
Definition grok.h:91
@ GRK_CLRSPC_CUSTOM_CIE
default CIE LAB
Definition grok.h:96
@ GRK_PREC_MODE_SCALE
Definition grok.h:435
@ GRK_PREC_MODE_CLIP
Definition grok.h:434
enum _GRK_COLOR_SPACE GRK_COLOR_SPACE
Grok supported color spaces.
#define GRK_DEFAULT_CIELAB_SPACE
Definition grok.h:2092
@ GRK_ENUM_CLRSPC_CIE
Definition grok.h:114
ResWindow.
Definition CompressedChunkCache.h:36
T clip(int64_t val)
Definition geometry.h:70
constexpr uint32_t GRK_CIE_D75
Definition GrkImage.h:42
void hwy_scale_mul_i32(int32_t *data, uint32_t w, uint32_t h, uint32_t stride, int32_t scale)
constexpr uint32_t GRK_CIE_D50
Definition GrkImage.h:40
void hwy_planar_to_packed_8(const int32_t *r, const int32_t *g, const int32_t *b, uint8_t *out, uint32_t w, uint32_t h, uint32_t src_stride)
constexpr uint32_t GRK_CIE_F11
Definition GrkImage.h:47
ILogger & grklog
Definition Logger.cpp:24
void hwy_planar_to_packed_16(const int32_t *r, const int32_t *g, const int32_t *b, uint16_t *out, uint32_t w, uint32_t h, uint32_t src_stride)
void hwy_sycc444_to_rgb_i32(const int32_t *y, const int32_t *cb, const int32_t *cr, int32_t *r, int32_t *g, int32_t *b, uint32_t w, uint32_t h, uint32_t src_stride, uint32_t dst_stride, int32_t offset, int32_t upb)
void hwy_packed_to_planar_8(const uint8_t *in, int32_t *r, int32_t *g, int32_t *b, uint32_t w, uint32_t h, uint32_t dst_stride)
constexpr uint32_t GRK_CIE_D65
Definition GrkImage.h:41
constexpr uint32_t GRK_CIE_F2
Definition GrkImage.h:45
void hwy_packed_to_planar_16(const uint16_t *in, int32_t *r, int32_t *g, int32_t *b, uint32_t w, uint32_t h, uint32_t dst_stride)
const double scale
Definition RateControl.cpp:167
void hwy_clip_i32(int32_t *data, uint32_t w, uint32_t h, uint32_t stride, int32_t minVal, int32_t maxVal)
Rect< uint32_t > Rect32
Definition geometry.h:64
T * grk_unref(T *w)
Definition RefCounted.h:31
constexpr uint32_t GRK_CIE_F7
Definition GrkImage.h:46
const uint32_t singleTileRowsPerStrip
Definition GrkImage.h:37
constexpr uint32_t GRK_CIE_DAY
Definition GrkImage.h:39
constexpr uint32_t GRK_CIE_SA
Definition GrkImage.h:43
void hwy_esycc_to_rgb_i32(int32_t *yd, int32_t *bd, int32_t *rd, uint32_t w, uint32_t h, uint32_t stride, int32_t max_value, int32_t flip_value, bool sign1, bool sign2)
constexpr uint32_t GRK_CIE_SC
Definition GrkImage.h:44
void hwy_scale_div_i32(int32_t *data, uint32_t w, uint32_t h, uint32_t stride, int32_t scale)
void grk_aligned_free(void *ptr)
Definition MemManager.h:324
Coding parameters.
Definition CodingParams.h:402
T width() const
Definition geometry.h:411
T height() const
Definition geometry.h:415
T x0
Definition geometry.h:192
T y0
Definition geometry.h:192
Grok image Note: do not directly create a grk_image object.