1 /* 2 This file is part of darktable, 3 Copyright (C) 2011-2020 darktable developers. 4 5 darktable is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 darktable is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with darktable. If not, see <http://www.gnu.org/licenses/>. 17 18 part of this file is based on nikon_curve.h from UFraw 19 Copyright 2004-2008 by Shawn Freeman, Udi Fuchs 20 */ 21 22 #pragma once 23 24 // Curve Types 25 #define CUBIC_SPLINE 0 26 #define CATMULL_ROM 1 27 #define MONOTONE_HERMITE 2 28 29 // Maximum resolution allowed due to space considerations. 30 #define MAX_RESOLUTION 65536 31 #define MAX_ANCHORS 20 32 33 // ERROR CODES 34 #define CT_SUCCESS 0 35 #define CT_ERROR 100 36 #define CT_WARNING 104 37 #define CT_SET_ERROR 200 38 39 40 ////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////// 42 // DATA STRUCTURES 43 ////////////////////////////////////////////////////////////////////////////// 44 ////////////////////////////////////////////////////////////////////////////// 45 /********************************************************** 46 CurveData: 47 Structure for the curve data inside a NTC/NCV file. 48 ***********************************************************/ 49 typedef struct 50 { 51 float x; 52 float y; 53 } CurveAnchorPoint; 54 55 typedef struct 56 { 57 // Type for this curve 58 unsigned int m_spline_type; 59 60 // Box data 61 float m_min_x; 62 float m_max_x; 63 float m_min_y; 64 float m_max_y; 65 66 // Number of anchor points 67 unsigned char m_numAnchors; 68 69 // contains a list of anchors, 2 floats per each point, x-y format 70 // max is 20 points 71 CurveAnchorPoint m_anchors[MAX_ANCHORS]; 72 73 } CurveData; 74 75 typedef struct 76 { 77 // Number of samples to use for the curve. 78 unsigned int m_samplingRes; 79 unsigned int m_outputRes; 80 81 // Sampling array 82 unsigned short int *m_Samples; // jo: changed to short int to save memory 83 84 } CurveSample; 85 86 /********************************************* 87 CurveDataSample: 88 Samples from a spline curve constructed from 89 the curve data. 90 91 curve - Pointer to curve struct to hold the data. 92 sample - Pointer to sample struct to hold the data. 93 **********************************************/ 94 int CurveDataSample(CurveData *curve, CurveSample *sample); 95 96 /*************************************************************** 97 * interpolate_set: 98 * 99 * convenience function for calculating the necessary parameters for 100 * interpolation. 101 * 102 * input: 103 * n - length of data arrays 104 * x - x axis of the data array 105 * y - y axis of the data array 106 * type - type of interpolation currently either CUBIC or HERMITE 107 * output: 108 * ypp - pointer to array of parameters 109 *******************************************************************/ 110 float *interpolate_set(int n, float x[], float y[], unsigned int type); 111 112 /*************************************************************** 113 * interpolate_val: 114 * 115 * convenience function for piecewise interpolation 116 * 117 * input: 118 * n - length of data arrays 119 * x - x axis of the data array 120 * xval - point where to interpolate 121 * y - y axis of the data array 122 * tangents - parameters calculated with interpolate_set 123 * type - type of interpolation currently either CUBIC or HERMITE 124 * output: 125 * yval - interpolated value at xval 126 *******************************************************************/ 127 float interpolate_val(int n, float x[], float xval, float y[], float tangents[], unsigned int type); 128 129 // modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh 130 // vim: shiftwidth=2 expandtab tabstop=2 cindent 131 // kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified; 132