MCPcopy Create free account
hub / github.com/LibRaw/LibRaw / convert_to_rgb

Method convert_to_rgb

src/postprocessing/postprocessing_utils_dcrdefs.cpp:21–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include "../../internal/dcraw_defs.h"
20
21void LibRaw::convert_to_rgb()
22{
23 float out_cam[3][4];
24 double num, inverse[3][3];
25 static const double(*out_rgb[])[3] = {
26 LibRaw_constants::rgb_rgb, LibRaw_constants::adobe_rgb,
27 LibRaw_constants::wide_rgb, LibRaw_constants::prophoto_rgb,
28 LibRaw_constants::xyz_rgb, LibRaw_constants::aces_rgb,
29 LibRaw_constants::dcip3d65_rgb, LibRaw_constants::rec2020_rgb};
30 static const char *name[] = {"sRGB", "Adobe RGB (1998)",
31 "WideGamut D65", "ProPhoto D65",
32 "XYZ", "ACES",
33 "DCI-P3 D65", "Rec. 2020"};
34 static const unsigned phead[] = {
35 1024, 0, 0x2100000, 0x6d6e7472, 0x52474220, 0x58595a20, 0,
36 0, 0, 0x61637370, 0, 0, 0x6e6f6e65, 0,
37 0, 0, 0, 0xf6d6, 0x10000, 0xd32d};
38 unsigned pbody[] = {10, 0x63707274, 0, 36, /* cprt */
39 0x64657363, 0, 60, /* desc, len is strlen(longest_string) + 12 */
40 0x77747074, 0, 20, /* wtpt */
41 0x626b7074, 0, 20, /* bkpt */
42 0x72545243, 0, 14, /* rTRC */
43 0x67545243, 0, 14, /* gTRC */
44 0x62545243, 0, 14, /* bTRC */
45 0x7258595a, 0, 20, /* rXYZ */
46 0x6758595a, 0, 20, /* gXYZ */
47 0x6258595a, 0, 20}; /* bXYZ */
48 static const unsigned pwhite[] = {0xf351, 0x10000, 0x116cc};
49 unsigned pcurve[] = {0x63757276, 0, 1, 0x1000000};
50
51 RUN_CALLBACK(LIBRAW_PROGRESS_CONVERT_RGB, 0, 2);
52
53 gamma_curve(gamm[0], gamm[1], 0, 0);
54 memcpy(out_cam, rgb_cam, sizeof out_cam);
55 raw_color |= colors == 1 || output_color < 1 || output_color > 8;
56 if (!raw_color)
57 {
58 size_t prof_desc_len;
59 std::vector<char> prof_desc;
60 int i, j, k;
61 prof_desc_len = snprintf(NULL, 0, "%s gamma %g toe slope %g", name[output_color - 1],
62 floor(1000. / gamm[0] + .5) / 1000., floor(gamm[1] * 1000.0 + .5) / 1000.) +
63 1;
64 prof_desc.resize(prof_desc_len);
65 sprintf(prof_desc.data(), "%s gamma %g toe slope %g", name[output_color - 1], floor(1000. / gamm[0] + .5) / 1000.,
66 floor(gamm[1] * 1000.0 + .5) / 1000.);
67
68 oprof = (unsigned *)calloc(phead[0], 1);
69 memcpy(oprof, phead, sizeof phead);
70 if (output_color == 5)
71 oprof[4] = oprof[5];
72 oprof[0] = 132 + 12 * pbody[0];
73 for (i = 0; i < (int)pbody[0]; i++)
74 {
75 oprof[oprof[0] / 4] = i ? (i > 1 ? 0x58595a20 : 0x64657363) : 0x74657874;
76 pbody[i * 3 + 2] = oprof[0];
77 oprof[0] += (pbody[i * 3 + 3] + 3) & -4;
78 }

Callers

nothing calls this directly

Calls 4

gamma_curveFunction · 0.85
callocFunction · 0.85
dataMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected