|
@@ -15,6 +15,7 @@
|
|
|
#include <sys/mman.h>
|
|
|
|
|
|
#define TIFFTAG_FORWARDMATRIX1 50964
|
|
|
+#define TIFFTAG_FORWARDMATRIX2 50965
|
|
|
|
|
|
static const float colormatrix_srgb[] = { 3.2409, -1.5373, -0.4986, -0.9692, 1.8759,
|
|
|
0.0415, 0.0556, -0.2039, 1.0569 };
|
|
@@ -46,6 +47,7 @@ static int output_buffer_height = -1;
|
|
|
// static bool gain_is_manual;
|
|
|
static int gain;
|
|
|
static int gain_max;
|
|
|
+static float balance[3] = { 1.0f, 1.0f, 1.0f };
|
|
|
|
|
|
static bool exposure_is_manual;
|
|
|
static int exposure;
|
|
@@ -68,6 +70,46 @@ register_custom_tiff_tags(TIFF *tif)
|
|
|
1,
|
|
|
1,
|
|
|
"ForwardMatrix1" },
|
|
|
+ { TIFFTAG_FORWARDMATRIX2,
|
|
|
+ -1,
|
|
|
+ -1,
|
|
|
+ TIFF_SRATIONAL,
|
|
|
+ FIELD_CUSTOM,
|
|
|
+ 1,
|
|
|
+ 1,
|
|
|
+ "ForwardMatrix2" },
|
|
|
+ { DCPTAG_PROFILE_TONE_CURVE,
|
|
|
+ -1,
|
|
|
+ -1,
|
|
|
+ TIFF_FLOAT,
|
|
|
+ FIELD_CUSTOM,
|
|
|
+ 1,
|
|
|
+ 1,
|
|
|
+ "ProfileToneCurve" },
|
|
|
+ { DCPTAG_PROFILE_HUE_SAT_MAP_DIMS,
|
|
|
+ -1,
|
|
|
+ -1,
|
|
|
+ TIFF_FLOAT,
|
|
|
+ FIELD_CUSTOM,
|
|
|
+ 1,
|
|
|
+ 1,
|
|
|
+ "ProfileHueSatMapDims" },
|
|
|
+ { DCPTAG_PROFILE_HUE_SAT_MAP_DATA_1,
|
|
|
+ -1,
|
|
|
+ -1,
|
|
|
+ TIFF_FLOAT,
|
|
|
+ FIELD_CUSTOM,
|
|
|
+ 1,
|
|
|
+ 1,
|
|
|
+ "ProfileHueSatMapData1" },
|
|
|
+ { DCPTAG_PROFILE_HUE_SAT_MAP_DATA_2,
|
|
|
+ -1,
|
|
|
+ -1,
|
|
|
+ TIFF_FLOAT,
|
|
|
+ FIELD_CUSTOM,
|
|
|
+ 1,
|
|
|
+ 1,
|
|
|
+ "ProfileHueSatMapData2" },
|
|
|
};
|
|
|
|
|
|
// Add missing dng fields
|
|
@@ -529,17 +571,88 @@ process_image_for_capture(const uint8_t *image, int count)
|
|
|
mp_get_device_make(),
|
|
|
mp_get_device_model());
|
|
|
TIFFSetField(tif, TIFFTAG_UNIQUECAMERAMODEL, uniquecameramodel);
|
|
|
- if (camera->colormatrix[0]) {
|
|
|
+
|
|
|
+ // Color matrices
|
|
|
+ if (camera->calibration.color_matrix_1[0]) {
|
|
|
+ TIFFSetField(tif,
|
|
|
+ TIFFTAG_COLORMATRIX1,
|
|
|
+ 9,
|
|
|
+ camera->calibration.color_matrix_1);
|
|
|
+ } else if (camera->colormatrix[0]) {
|
|
|
TIFFSetField(tif, TIFFTAG_COLORMATRIX1, 9, camera->colormatrix);
|
|
|
} else {
|
|
|
TIFFSetField(tif, TIFFTAG_COLORMATRIX1, 9, colormatrix_srgb);
|
|
|
}
|
|
|
- if (camera->forwardmatrix[0]) {
|
|
|
+ if (camera->calibration.color_matrix_2[0]) {
|
|
|
+ TIFFSetField(tif,
|
|
|
+ TIFFTAG_COLORMATRIX2,
|
|
|
+ 9,
|
|
|
+ camera->calibration.color_matrix_2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (camera->calibration.forward_matrix_1[0]) {
|
|
|
+ TIFFSetField(tif,
|
|
|
+ TIFFTAG_FORWARDMATRIX1,
|
|
|
+ 9,
|
|
|
+ camera->calibration.forward_matrix_1);
|
|
|
+ } else if (camera->forwardmatrix[0]) {
|
|
|
TIFFSetField(tif, TIFFTAG_FORWARDMATRIX1, 9, camera->forwardmatrix);
|
|
|
}
|
|
|
+
|
|
|
+ if (camera->calibration.forward_matrix_2[0]) {
|
|
|
+ TIFFSetField(tif,
|
|
|
+ TIFFTAG_FORWARDMATRIX2,
|
|
|
+ 9,
|
|
|
+ camera->calibration.forward_matrix_2);
|
|
|
+ }
|
|
|
+
|
|
|
static const float neutral[] = { 1.0, 1.0, 1.0 };
|
|
|
TIFFSetField(tif, TIFFTAG_ASSHOTNEUTRAL, 3, neutral);
|
|
|
- TIFFSetField(tif, TIFFTAG_CALIBRATIONILLUMINANT1, 21);
|
|
|
+ if (camera->calibration.illuminant_1) {
|
|
|
+ TIFFSetField(tif,
|
|
|
+ TIFFTAG_CALIBRATIONILLUMINANT1,
|
|
|
+ camera->calibration.illuminant_1);
|
|
|
+ } else {
|
|
|
+ TIFFSetField(tif, TIFFTAG_CALIBRATIONILLUMINANT1, 21);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (camera->calibration.illuminant_2) {
|
|
|
+ TIFFSetField(tif,
|
|
|
+ TIFFTAG_CALIBRATIONILLUMINANT2,
|
|
|
+ camera->calibration.illuminant_2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (camera->calibration.tone_curve_length) {
|
|
|
+ TIFFSetField(tif,
|
|
|
+ DCPTAG_PROFILE_TONE_CURVE,
|
|
|
+ camera->calibration.tone_curve_length,
|
|
|
+ camera->calibration.tone_curve);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (camera->calibration.hue_sat_map_dims[0]) {
|
|
|
+ TIFFSetField(tif,
|
|
|
+ DCPTAG_PROFILE_HUE_SAT_MAP_DIMS,
|
|
|
+ 3,
|
|
|
+ camera->calibration.hue_sat_map_dims);
|
|
|
+ TIFFSetField(tif,
|
|
|
+ DCPTAG_PROFILE_HUE_SAT_MAP_DATA_1,
|
|
|
+ camera->calibration.hue_sat_map_dims[0] *
|
|
|
+ camera->calibration.hue_sat_map_dims[1] *
|
|
|
+ camera->calibration.hue_sat_map_dims[2] * 3,
|
|
|
+ camera->calibration.hue_sat_map_data_1);
|
|
|
+ if (camera->calibration.hue_sat_map_data_2 != NULL) {
|
|
|
+ TIFFSetField(
|
|
|
+ tif,
|
|
|
+ DCPTAG_PROFILE_HUE_SAT_MAP_DATA_2,
|
|
|
+ camera->calibration.hue_sat_map_dims[0] *
|
|
|
+ camera->calibration.hue_sat_map_dims[1] *
|
|
|
+ camera->calibration.hue_sat_map_dims[2] * 3,
|
|
|
+ camera->calibration.hue_sat_map_data_2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ TIFFSetField(tif, TIFFTAG_ANALOGBALANCE, 3, balance);
|
|
|
+
|
|
|
// Write black thumbnail, only windows uses this
|
|
|
{
|
|
|
unsigned char *buf =
|
|
@@ -932,6 +1045,8 @@ update_state(MPPipeline *pipeline, const struct mp_process_pipeline_state *state
|
|
|
// gain_is_manual = state->gain_is_manual;
|
|
|
gain = state->gain;
|
|
|
gain_max = state->gain_max;
|
|
|
+ balance[0] = state->balance_red;
|
|
|
+ balance[2] = state->balance_blue;
|
|
|
|
|
|
exposure_is_manual = state->exposure_is_manual;
|
|
|
exposure = state->exposure;
|