1 /* -*- C++ -*-
2  * Copyright 2019-2021 LibRaw LLC (info@libraw.org)
3  *
4 
5  LibRaw is free software; you can redistribute it and/or modify
6  it under the terms of the one of two licenses as you choose:
7 
8 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
9    (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
10 
11 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
12    (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
13 
14  */
15 #include "../../internal/libraw_cxx_defs.h"
16 
unpack_function_name()17 const char *LibRaw::unpack_function_name()
18 {
19   libraw_decoder_info_t decoder_info;
20   get_decoder_info(&decoder_info);
21   return decoder_info.decoder_name;
22 }
23 
get_decoder_info(libraw_decoder_info_t * d_info)24 int LibRaw::get_decoder_info(libraw_decoder_info_t *d_info)
25 {
26   if (!d_info)
27     return LIBRAW_UNSPECIFIED_ERROR;
28   d_info->decoder_name = 0;
29   d_info->decoder_flags = 0;
30   if (!load_raw)
31     return LIBRAW_OUT_OF_ORDER_CALL;
32 
33   // dcraw.c names order
34   if (load_raw == &LibRaw::android_tight_load_raw)
35   {
36     d_info->decoder_name = "android_tight_load_raw()";
37     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
38   }
39   else if (load_raw == &LibRaw::android_loose_load_raw)
40   {
41     d_info->decoder_name = "android_loose_load_raw()";
42     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
43   }
44   else if (load_raw == &LibRaw::vc5_dng_load_raw_placeholder)
45   {
46       d_info->decoder_name = "vc5_dng_load_raw_placeholder()";
47   }
48   else if (load_raw == &LibRaw::canon_600_load_raw)
49   {
50     d_info->decoder_name = "canon_600_load_raw()";
51     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
52   }
53   else if (load_raw == &LibRaw::fuji_compressed_load_raw)
54   {
55     d_info->decoder_name = "fuji_compressed_load_raw()";
56   }
57   else if (load_raw == &LibRaw::fuji_14bit_load_raw)
58   {
59     d_info->decoder_name = "fuji_14bit_load_raw()";
60   }
61   else if (load_raw == &LibRaw::canon_load_raw)
62   {
63     d_info->decoder_name = "canon_load_raw()";
64   }
65   else if (load_raw == &LibRaw::lossless_jpeg_load_raw)
66   {
67     d_info->decoder_name = "lossless_jpeg_load_raw()";
68     d_info->decoder_flags =
69         LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_TRYRAWSPEED;
70   }
71   else if (load_raw == &LibRaw::canon_sraw_load_raw)
72   {
73     d_info->decoder_name = "canon_sraw_load_raw()";
74     // d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
75   }
76   else if (load_raw == &LibRaw::crxLoadRaw)
77   {
78     d_info->decoder_name = "crxLoadRaw()";
79   }
80   else if (load_raw == &LibRaw::lossless_dng_load_raw)
81   {
82     d_info->decoder_name = "lossless_dng_load_raw()";
83     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE |
84                             LIBRAW_DECODER_TRYRAWSPEED |
85                             LIBRAW_DECODER_ADOBECOPYPIXEL;
86   }
87   else if (load_raw == &LibRaw::packed_dng_load_raw)
88   {
89     d_info->decoder_name = "packed_dng_load_raw()";
90     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE |
91                             LIBRAW_DECODER_TRYRAWSPEED |
92                             LIBRAW_DECODER_ADOBECOPYPIXEL;
93   }
94   else if (load_raw == &LibRaw::pentax_load_raw)
95   {
96     d_info->decoder_name = "pentax_load_raw()";
97     d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
98   }
99   else if (load_raw == &LibRaw::nikon_load_raw)
100   {
101     d_info->decoder_name = "nikon_load_raw()";
102     d_info->decoder_flags =
103         LIBRAW_DECODER_TRYRAWSPEED | LIBRAW_DECODER_HASCURVE;
104   }
105   else if (load_raw == &LibRaw::nikon_coolscan_load_raw)
106   {
107     d_info->decoder_name = "nikon_coolscan_load_raw()";
108     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
109   }
110   else if (load_raw == &LibRaw::nikon_load_sraw)
111   {
112     d_info->decoder_name = "nikon_load_sraw()";
113     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_FIXEDMAXC;
114   }
115   else if (load_raw == &LibRaw::nikon_yuv_load_raw)
116   {
117     d_info->decoder_name = "nikon_load_yuv_load_raw()";
118     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_FIXEDMAXC;
119   }
120   else if (load_raw == &LibRaw::rollei_load_raw)
121   {
122     // UNTESTED
123     d_info->decoder_name = "rollei_load_raw()";
124     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
125   }
126   else if (load_raw == &LibRaw::phase_one_load_raw)
127   {
128     d_info->decoder_name = "phase_one_load_raw()";
129   }
130   else if (load_raw == &LibRaw::phase_one_load_raw_c)
131   {
132     d_info->decoder_name = "phase_one_load_raw_c()";
133   }
134   else if (load_raw == &LibRaw::hasselblad_load_raw)
135   {
136     d_info->decoder_name = "hasselblad_load_raw()";
137   }
138   else if (load_raw == &LibRaw::leaf_hdr_load_raw)
139   {
140     d_info->decoder_name = "leaf_hdr_load_raw()";
141   }
142   else if (load_raw == &LibRaw::unpacked_load_raw)
143   {
144     d_info->decoder_name = "unpacked_load_raw()";
145 	d_info->decoder_flags = LIBRAW_DECODER_FLATDATA;
146   }
147   else if (load_raw == &LibRaw::unpacked_load_raw_reversed)
148   {
149     d_info->decoder_name = "unpacked_load_raw_reversed()";
150     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
151   }
152   else if (load_raw == &LibRaw::sinar_4shot_load_raw)
153   {
154     // UNTESTED
155     d_info->decoder_name = "sinar_4shot_load_raw()";
156     d_info->decoder_flags = LIBRAW_DECODER_SINAR4SHOT;
157   }
158   else if (load_raw == &LibRaw::imacon_full_load_raw)
159   {
160     d_info->decoder_name = "imacon_full_load_raw()";
161   }
162   else if (load_raw == &LibRaw::hasselblad_full_load_raw)
163   {
164     d_info->decoder_name = "hasselblad_full_load_raw()";
165   }
166   else if (load_raw == &LibRaw::packed_load_raw)
167   {
168     d_info->decoder_name = "packed_load_raw()";
169     d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
170   }
171   else if (load_raw == &LibRaw::broadcom_load_raw)
172   {
173     // UNTESTED
174     d_info->decoder_name = "broadcom_load_raw()";
175     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
176   }
177   else if (load_raw == &LibRaw::nokia_load_raw)
178   {
179     // UNTESTED
180     d_info->decoder_name = "nokia_load_raw()";
181     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
182   }
183 #ifdef LIBRAW_OLD_VIDEO_SUPPORT
184   else if (load_raw == &LibRaw::canon_rmf_load_raw)
185   {
186     // UNTESTED
187     d_info->decoder_name = "canon_rmf_load_raw()";
188   }
189 #endif
190   else if (load_raw == &LibRaw::panasonic_load_raw)
191   {
192     d_info->decoder_name = "panasonic_load_raw()";
193     d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
194   }
195   else if (load_raw == &LibRaw::panasonicC6_load_raw)
196   {
197     d_info->decoder_name = "panasonicC6_load_raw()";
198   }
199   else if (load_raw == &LibRaw::panasonicC7_load_raw)
200   {
201     d_info->decoder_name = "panasonicC7_load_raw()";
202   }
203   else if (load_raw == &LibRaw::olympus_load_raw)
204   {
205     d_info->decoder_name = "olympus_load_raw()";
206     d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
207   }
208   else if (load_raw == &LibRaw::minolta_rd175_load_raw)
209   {
210     // UNTESTED
211     d_info->decoder_name = "minolta_rd175_load_raw()";
212   }
213   else if (load_raw == &LibRaw::quicktake_100_load_raw)
214   {
215     // UNTESTED
216     d_info->decoder_name = "quicktake_100_load_raw()";
217   }
218   else if (load_raw == &LibRaw::kodak_radc_load_raw)
219   {
220     d_info->decoder_name = "kodak_radc_load_raw()";
221   }
222   else if (load_raw == &LibRaw::kodak_jpeg_load_raw)
223   {
224     // UNTESTED + RBAYER
225     d_info->decoder_name = "kodak_jpeg_load_raw()";
226   }
227   else if (load_raw == &LibRaw::lossy_dng_load_raw)
228   {
229     // Check rbayer
230     d_info->decoder_name = "lossy_dng_load_raw()";
231     d_info->decoder_flags =
232         LIBRAW_DECODER_TRYRAWSPEED | LIBRAW_DECODER_HASCURVE;
233   }
234   else if (load_raw == &LibRaw::kodak_dc120_load_raw)
235   {
236     d_info->decoder_name = "kodak_dc120_load_raw()";
237   }
238   else if (load_raw == &LibRaw::eight_bit_load_raw)
239   {
240     d_info->decoder_name = "eight_bit_load_raw()";
241     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_FIXEDMAXC;
242   }
243   else if (load_raw == &LibRaw::kodak_c330_load_raw)
244   {
245     d_info->decoder_name = "kodak_yrgb_load_raw()";
246     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_FIXEDMAXC;
247   }
248   else if (load_raw == &LibRaw::kodak_c603_load_raw)
249   {
250     d_info->decoder_name = "kodak_yrgb_load_raw()";
251     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_FIXEDMAXC;
252   }
253   else if (load_raw == &LibRaw::kodak_262_load_raw)
254   {
255     d_info->decoder_name = "kodak_262_load_raw()"; // UNTESTED!
256     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_FIXEDMAXC;
257   }
258   else if (load_raw == &LibRaw::kodak_65000_load_raw)
259   {
260     d_info->decoder_name = "kodak_65000_load_raw()";
261     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
262   }
263   else if (load_raw == &LibRaw::kodak_ycbcr_load_raw)
264   {
265     // UNTESTED
266     d_info->decoder_name = "kodak_ycbcr_load_raw()";
267     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_FIXEDMAXC;
268   }
269   else if (load_raw == &LibRaw::kodak_rgb_load_raw)
270   {
271     // UNTESTED
272     d_info->decoder_name = "kodak_rgb_load_raw()";
273     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
274   }
275   else if (load_raw == &LibRaw::sony_load_raw)
276   {
277     d_info->decoder_name = "sony_load_raw()";
278   }
279   else if (load_raw == &LibRaw::sony_ljpeg_load_raw)
280   {
281     d_info->decoder_name = "sony_ljpeg_load_raw()";
282   }
283   else if (load_raw == &LibRaw::sony_arw_load_raw)
284   {
285     d_info->decoder_name = "sony_arw_load_raw()";
286     d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
287   }
288   else if (load_raw == &LibRaw::sony_arw2_load_raw)
289   {
290     d_info->decoder_name = "sony_arw2_load_raw()";
291     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE |
292                             LIBRAW_DECODER_TRYRAWSPEED |
293                             LIBRAW_DECODER_SONYARW2;
294   }
295   else if (load_raw == &LibRaw::sony_arq_load_raw)
296   {
297     d_info->decoder_name = "sony_arq_load_raw()";
298     d_info->decoder_flags = LIBRAW_DECODER_LEGACY_WITH_MARGINS | LIBRAW_DECODER_FLATDATA | LIBRAW_DECODER_FLAT_BG2_SWAPPED;
299   }
300   else if (load_raw == &LibRaw::samsung_load_raw)
301   {
302     d_info->decoder_name = "samsung_load_raw()";
303     d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
304   }
305   else if (load_raw == &LibRaw::samsung2_load_raw)
306   {
307     d_info->decoder_name = "samsung2_load_raw()";
308   }
309   else if (load_raw == &LibRaw::samsung3_load_raw)
310   {
311     d_info->decoder_name = "samsung3_load_raw()";
312   }
313   else if (load_raw == &LibRaw::smal_v6_load_raw)
314   {
315     // UNTESTED
316     d_info->decoder_name = "smal_v6_load_raw()";
317     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
318   }
319   else if (load_raw == &LibRaw::smal_v9_load_raw)
320   {
321     // UNTESTED
322     d_info->decoder_name = "smal_v9_load_raw()";
323     d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
324   }
325 #ifdef LIBRAW_OLD_VIDEO_SUPPORT
326   else if (load_raw == &LibRaw::redcine_load_raw)
327   {
328     d_info->decoder_name = "redcine_load_raw()";
329     d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
330   }
331 #endif
332   else if (load_raw == &LibRaw::x3f_load_raw)
333   {
334     d_info->decoder_name = "x3f_load_raw()";
335     d_info->decoder_flags = LIBRAW_DECODER_OWNALLOC | LIBRAW_DECODER_FIXEDMAXC |
336                             LIBRAW_DECODER_LEGACY_WITH_MARGINS;
337   }
338   else if (load_raw == &LibRaw::pentax_4shot_load_raw)
339   {
340     d_info->decoder_name = "pentax_4shot_load_raw()";
341     d_info->decoder_flags = LIBRAW_DECODER_OWNALLOC;
342   }
343   else if (load_raw == &LibRaw::deflate_dng_load_raw)
344   {
345     d_info->decoder_name = "deflate_dng_load_raw()";
346     d_info->decoder_flags = LIBRAW_DECODER_OWNALLOC;
347   }
348   else if (load_raw == &LibRaw::uncompressed_fp_dng_load_raw)
349   {
350     d_info->decoder_name = "uncompressed_fp_dng_load_raw()";
351     d_info->decoder_flags = LIBRAW_DECODER_OWNALLOC;
352   }
353   else if (load_raw == &LibRaw::nikon_load_striped_packed_raw)
354   {
355     d_info->decoder_name = "nikon_load_striped_packed_raw()";
356   }
357   else if (load_raw == &LibRaw::nikon_load_padded_packed_raw)
358   {
359     d_info->decoder_name = "nikon_load_padded_packed_raw()";
360   }
361   else if (load_raw == &LibRaw::nikon_14bit_load_raw)
362   {
363     d_info->decoder_name = "nikon_14bit_load_raw()";
364   }
365   /* -- added 07/02/18 -- */
366   else if (load_raw == &LibRaw::unpacked_load_raw_fuji_f700s20)
367   {
368     d_info->decoder_name = "unpacked_load_raw_fuji_f700s20()";
369   }
370   else if (load_raw == &LibRaw::unpacked_load_raw_FujiDBP)
371   {
372     d_info->decoder_name = "unpacked_load_raw_FujiDBP()";
373   }
374 #ifdef USE_6BY9RPI
375   else if (load_raw == &LibRaw::rpi_load_raw8)
376   {
377 	d_info->decoder_name = "rpi_load_raw8";
378   }
379   else if (load_raw == &LibRaw::rpi_load_raw12)
380   {
381 	d_info->decoder_name = "rpi_load_raw12";
382   }
383   else if (load_raw == &LibRaw::rpi_load_raw14)
384   {
385 	d_info->decoder_name = "rpi_load_raw14";
386   }
387   else if (load_raw == &LibRaw::rpi_load_raw16)
388   {
389 	d_info->decoder_name = "rpi_load_raw16";
390   }
391 #endif
392   else
393   {
394     d_info->decoder_name = "Unknown unpack function";
395     d_info->decoder_flags = LIBRAW_DECODER_NOTSET;
396   }
397   return LIBRAW_SUCCESS;
398 }
399