25
25
26
26
const dt_noiseprofile_t dt_noiseprofile_generic = {N_ ("generic poissonian" ), "" , "" , 0 , {0.0001f , 0.0001f , 0.0001 }, {0.0f , 0.0f , 0.0f }};
27
27
28
- static gboolean dt_noiseprofile_verify (JsonParser * parser );
28
+ static gboolean _noiseprofile_verify (JsonParser * parser );
29
29
30
30
JsonParser * dt_noiseprofile_init (const char * alternative )
31
31
{
@@ -42,8 +42,11 @@ JsonParser *dt_noiseprofile_init(const char *alternative)
42
42
else
43
43
g_strlcpy (filename , alternative , sizeof (filename ));
44
44
45
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] loading noiseprofiles from `%s'" , filename );
46
- if (!g_file_test (filename , G_FILE_TEST_EXISTS )) return NULL ;
45
+ if (!g_file_test (filename , G_FILE_TEST_EXISTS ))
46
+ {
47
+ dt_print (DT_DEBUG_CONTROL , "[noiseprofile] can't load noiseprofiles from `%s'" , filename );
48
+ return NULL ;
49
+ }
47
50
48
51
// TODO: shall we cache the content? for now this looks fast enough(TM)
49
52
JsonParser * parser = json_parser_new ();
@@ -56,7 +59,7 @@ JsonParser *dt_noiseprofile_init(const char *alternative)
56
59
}
57
60
58
61
// run over the file once to verify that it is sane
59
- if (!dt_noiseprofile_verify (parser ))
62
+ if (!_noiseprofile_verify (parser ))
60
63
{
61
64
dt_control_log (_ ("noiseprofile file `%s' is not valid" ), filename );
62
65
dt_print (DT_DEBUG_ALWAYS , "[noiseprofile] error: `%s' is not a valid noiseprofile file. run with -d control for details" , filename );
@@ -92,12 +95,12 @@ static gint _sort_by_iso(gconstpointer a, gconstpointer b)
92
95
goto end;\
93
96
}
94
97
95
- static gboolean dt_noiseprofile_verify (JsonParser * parser )
98
+ static gboolean _noiseprofile_verify (JsonParser * parser )
96
99
{
97
100
JsonReader * reader = NULL ;
98
101
gboolean valid = TRUE;
99
102
100
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] verifying noiseprofile file" );
103
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] verifying noiseprofile file" );
101
104
102
105
JsonNode * root = json_parser_get_root (parser );
103
106
if (!root ) _ERROR ("can't get the root node" );
@@ -120,35 +123,35 @@ static gboolean dt_noiseprofile_verify(JsonParser *parser)
120
123
121
124
// go through all makers
122
125
const int n_makers = json_reader_count_elements (reader );
123
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found %d makers" , n_makers );
126
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found %d makers" , n_makers );
124
127
for (int i = 0 ; i < n_makers ; i ++ )
125
128
{
126
129
if (!json_reader_read_element (reader , i )) _ERROR ("can't access maker at position %d / %d" , i + 1 , n_makers );
127
130
128
131
if (!json_reader_read_member (reader , "maker" )) _ERROR ("missing `maker`" );
129
132
130
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found maker `%s'" , json_reader_get_string_value (reader ));
133
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found maker `%s'" , json_reader_get_string_value (reader ));
131
134
// go through all models and check those
132
135
json_reader_end_member (reader );
133
136
134
137
if (!json_reader_read_member (reader , "models" )) _ERROR ("missing `models`" );
135
138
136
139
const int n_models = json_reader_count_elements (reader );
137
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found %d models" , n_models );
140
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found %d models" , n_models );
138
141
n_profiles_total += n_models ;
139
142
for (int j = 0 ; j < n_models ; j ++ )
140
143
{
141
144
if (!json_reader_read_element (reader , j )) _ERROR ("can't access model at position %d / %d" , j + 1 , n_models );
142
145
143
146
if (!json_reader_read_member (reader , "model" )) _ERROR ("missing `model`" );
144
147
145
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found %s" , json_reader_get_string_value (reader ));
148
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found %s" , json_reader_get_string_value (reader ));
146
149
json_reader_end_member (reader );
147
150
148
151
if (!json_reader_read_member (reader , "profiles" )) _ERROR ("missing `profiles`" );
149
152
150
153
const int n_profiles = json_reader_count_elements (reader );
151
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found %d profiles" , n_profiles );
154
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found %d profiles" , n_profiles );
152
155
for (int k = 0 ; k < n_profiles ; k ++ )
153
156
{
154
157
if (!json_reader_read_element (reader , k )) _ERROR ("can't access profile at position %d / %d" , k + 1 , n_profiles );
@@ -212,8 +215,8 @@ static gboolean dt_noiseprofile_verify(JsonParser *parser)
212
215
213
216
json_reader_end_member (reader );
214
217
215
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] verifying noiseprofile completed" );
216
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found %zu profiles total" , n_profiles_total );
218
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] verifying noiseprofile completed" );
219
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found %zu profiles total" , n_profiles_total );
217
220
218
221
end :
219
222
if (reader ) g_object_unref (reader );
@@ -229,7 +232,7 @@ GList *dt_noiseprofile_get_matching(const dt_image_t *cimg)
229
232
230
233
if (!parser ) goto end ;
231
234
232
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] looking for maker `%s', model `%s'" , cimg -> camera_maker , cimg -> camera_model );
235
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] looking for maker `%s', model `%s'" , cimg -> camera_maker , cimg -> camera_model );
233
236
234
237
JsonNode * root = json_parser_get_root (parser );
235
238
@@ -239,7 +242,7 @@ GList *dt_noiseprofile_get_matching(const dt_image_t *cimg)
239
242
240
243
// go through all makers
241
244
const int n_makers = json_reader_count_elements (reader );
242
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found %d makers" , n_makers );
245
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found %d makers" , n_makers );
243
246
for (int i = 0 ; i < n_makers ; i ++ )
244
247
{
245
248
json_reader_read_element (reader , i );
@@ -248,14 +251,14 @@ GList *dt_noiseprofile_get_matching(const dt_image_t *cimg)
248
251
249
252
if (g_strstr_len (cimg -> camera_maker , -1 , json_reader_get_string_value (reader )))
250
253
{
251
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found `%s' as `%s'" , cimg -> camera_maker , json_reader_get_string_value (reader ));
254
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found `%s' as `%s'" , cimg -> camera_maker , json_reader_get_string_value (reader ));
252
255
// go through all models and check those
253
256
json_reader_end_member (reader );
254
257
255
258
json_reader_read_member (reader , "models" );
256
259
257
260
const int n_models = json_reader_count_elements (reader );
258
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found %d models" , n_models );
261
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found %d models" , n_models );
259
262
for (int j = 0 ; j < n_models ; j ++ )
260
263
{
261
264
json_reader_read_element (reader , j );
@@ -264,7 +267,7 @@ GList *dt_noiseprofile_get_matching(const dt_image_t *cimg)
264
267
265
268
if (!g_strcmp0 (cimg -> camera_model , json_reader_get_string_value (reader )))
266
269
{
267
- dt_print (DT_DEBUG_CONTROL , "[noiseprofile] found %s" , cimg -> camera_model );
270
+ dt_print (DT_DEBUG_CONTROL | DT_DEBUG_VERBOSE , "[noiseprofile] found %s" , cimg -> camera_model );
268
271
// we got a match, return at most bufsize elements
269
272
json_reader_end_member (reader );
270
273
0 commit comments