1 /*****************************************************************************
2 
3         TransOpLogC.h
4         Author: Laurent de Soras, 2015
5 
6 Source:
7 Harald Brendel,
8 ALEXA Log C Curve Usage in VFX,
9 ARRI, 2011-10-05
10 
11 --- Legal stuff ---
12 
13 This program is free software. It comes without any warranty, to
14 the extent permitted by applicable law. You can redistribute it
15 and/or modify it under the terms of the Do What The Fuck You Want
16 To Public License, Version 2, as published by Sam Hocevar. See
17 http://sam.zoy.org/wtfpl/COPYING for more details.
18 
19 *Tab=3***********************************************************************/
20 
21 
22 
23 #pragma once
24 #if ! defined (fmtcl_TransOpLogC_HEADER_INCLUDED)
25 #define	fmtcl_TransOpLogC_HEADER_INCLUDED
26 
27 #if defined (_MSC_VER)
28 	#pragma warning (4 : 4250)
29 #endif
30 
31 
32 
33 /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
34 
35 #include "fmtcl/TransOpInterface.h"
36 
37 #include <array>
38 
39 
40 
41 namespace fmtcl
42 {
43 
44 
45 
46 class TransOpLogC
47 :	public TransOpInterface
48 {
49 
50 /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
51 
52 public:
53 
54 	enum LType
55 	{
56 		LType_LOGC_V3 = 0,
57 		LType_LOGC_V2,
58 		LType_VLOG,
59 
60 		LType_NBR_ELT
61 	};
62 
63 	// Exposure Index (EI)
64 	enum ExpIdx
65 	{
66 		ExpIdx_INVALID = -1,
67 
68 		ExpIdx_160 = 0,
69 		ExpIdx_200,
70 		ExpIdx_250,
71 		ExpIdx_320,
72 		ExpIdx_400,
73 		ExpIdx_500,
74 		ExpIdx_640,
75 		ExpIdx_800,
76 		ExpIdx_1000,
77 		ExpIdx_1280,
78 		ExpIdx_1600,
79 
80 		ExpIdx_NBR_ELT
81 	};
82 
83 	explicit       TransOpLogC (bool inv_flag, LType type, ExpIdx ei = ExpIdx_800);
~TransOpLogC()84 	virtual        ~TransOpLogC () {}
85 
86 	static ExpIdx  conv_logc_ei (int val_raw);
87 
88 
89 
90 /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
91 
92 protected:
93 
94 	// TransOpInterface
95 	double         do_convert (double x) const override;
96 	LinInfo        do_get_info () const override;
97 
98 
99 
100 /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
101 
102 private:
103 
104 	class CurveData
105 	{
106 	public:
107 		double         _cut;
108 		double         _a;
109 		double         _b;
110 		double         _c;
111 		double         _d;
112 		double         _e;
113 		double         _f;
114 		double         _cut_i; // _e * _cut + _f
115 	};
116 
117 	double         compute_direct (double x) const;
118 	double         compute_inverse (double x) const;
119 
120 	const bool     _inv_flag;
121 	const double   _n;
122 	const CurveData
123 	               _curve;
124 
125 	static const double
126 		            _noise_margin;
127 	static const CurveData
128 	               _vlog;
129 	static const std::array <CurveData, ExpIdx_NBR_ELT>
130 	               _v2_table;
131 	static const std::array <CurveData, ExpIdx_NBR_ELT>
132 	               _v3_table;
133 
134 
135 
136 /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
137 
138 private:
139 
140 	               TransOpLogC ()                               = delete;
141 	               TransOpLogC (const TransOpLogC &other)       = delete;
142 	TransOpLogC &  operator = (const TransOpLogC &other)        = delete;
143 	bool           operator == (const TransOpLogC &other) const = delete;
144 	bool           operator != (const TransOpLogC &other) const = delete;
145 
146 };	// class TransOpLogC
147 
148 
149 
150 }	// namespace fmtcl
151 
152 
153 
154 //#include "fmtcl/TransOpLogC.hpp"
155 
156 
157 
158 #endif	// fmtcl_TransOpLogC_HEADER_INCLUDED
159 
160 
161 
162 /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
163