Browse Source

Write WB gains to the DNG file

Martijn Braam 1 year ago
parent
commit
e964b923c7
1 changed files with 23 additions and 19 deletions
  1. 23 19
      src/process_pipeline.c

+ 23 - 19
src/process_pipeline.c

@@ -389,11 +389,12 @@ mp_process_pipeline_init_gl(GdkSurface *surface)
 }
 
 float
-clamp_float(float value, float min, float max) {
-        if(value > max)
+clamp_float(float value, float min, float max)
+{
+        if (value > max)
                 return max;
 
-        if(value < min)
+        if (value < min)
                 return min;
 
         return value;
@@ -475,25 +476,26 @@ process_image_for_preview(const uint8_t *image)
                 int width = output_buffer_width;
                 int height = output_buffer_height / 3;
                 uint32_t *center = g_malloc_n(width * height * sizeof(uint32_t), 1);
-                glReadPixels(0,
-                             height,
-                             width,
-                             height,
-                             GL_RGBA,
-                             GL_UNSIGNED_BYTE,
-                             center);
+                glReadPixels(
+                        0, height, width, height, GL_RGBA, GL_UNSIGNED_BYTE, center);
                 libmegapixels_aaa_software_statistics(
                         center, width, height, &state_proc.stats);
 
-		float w_gain = 0.02f;
-		float t_gain = 0.01f;
-                state_proc.red += (state_proc.stats.temp * +w_gain) + (state_proc.stats.tint * t_gain);
-                state_proc.blue += (state_proc.stats.temp * -w_gain) + (state_proc.stats.tint * t_gain);
+                float w_gain = 0.02f;
+                float t_gain = 0.01f;
+                state_proc.red += (state_proc.stats.temp * +w_gain) +
+                                  (state_proc.stats.tint * t_gain);
+                state_proc.blue += (state_proc.stats.temp * -w_gain) +
+                                   (state_proc.stats.tint * t_gain);
                 state_proc.blacklevel -= state_proc.stats.blacklevel * 0.001f;
-		state_proc.blacklevel = clamp_float(state_proc.blacklevel, 0.0f, 0.07f);
-		state_proc.red = clamp_float(state_proc.red, 0.5f, 3.0f);
-		state_proc.blue = clamp_float(state_proc.blue, 0.5f, 3.0f);
-                gles2_debayer_set_shading(gles2_debayer, state_proc.red, state_proc.blue, state_proc.blacklevel);
+                state_proc.blacklevel =
+                        clamp_float(state_proc.blacklevel, 0.0f, 0.07f);
+                state_proc.red = clamp_float(state_proc.red, 0.5f, 3.0f);
+                state_proc.blue = clamp_float(state_proc.blue, 0.5f, 3.0f);
+                gles2_debayer_set_shading(gles2_debayer,
+                                          state_proc.red,
+                                          state_proc.blue,
+                                          state_proc.blacklevel);
         }
 
         // Create a thumbnail from the preview for the last capture
@@ -597,7 +599,9 @@ process_image_for_capture(const uint8_t *image, int count)
                 state_proc.configuration->model);
         TIFFSetField(tif, TIFFTAG_UNIQUECAMERAMODEL, uniquecameramodel);
 
-        static const float neutral[] = { 1.0, 1.0, 1.0 };
+        static float neutral[] = { 1.0f, 1.0f, 1.0f };
+        neutral[0] = state_proc.red;
+        neutral[2] = state_proc.blue;
         TIFFSetField(tif, TIFFTAG_ASSHOTNEUTRAL, 3, neutral);
         TIFFSetField(tif, TIFFTAG_ANALOGBALANCE, 3, state_proc.balance);