1 /*****************************************************************************
2 
3         TransOpInterface.h
4         Author: Laurent de Soras, 2015
5 
6 --- Legal stuff ---
7 
8 This program is free software. It comes without any warranty, to
9 the extent permitted by applicable law. You can redistribute it
10 and/or modify it under the terms of the Do What The Fuck You Want
11 To Public License, Version 2, as published by Sam Hocevar. See
12 http://sam.zoy.org/wtfpl/COPYING for more details.
13 
14 *Tab=3***********************************************************************/
15 
16 
17 
18 #pragma once
19 #if ! defined (fmtcl_TransOpInterface_HEADER_INCLUDED)
20 #define	fmtcl_TransOpInterface_HEADER_INCLUDED
21 
22 #if defined (_MSC_VER)
23 	#pragma warning (4 : 4250)
24 #endif
25 
26 
27 
28 /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
29 
30 
31 
32 namespace fmtcl
33 {
34 
35 
36 
37 class TransOpInterface
38 {
39 
40 /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
41 
42 public:
43 
44 	enum class Type
45 	{
46 		UNDEF = 0, // Unknown, unspecified or not applicable (but still valid)
47 		OETF,
48 		EOTF
49 	};
50 
51 	enum class Range
52 	{
53 		UNDEF = 0,
54 		SDR,
55 		HDR
56 	};
57 
58 	// Information about the linear scale
59 	class LinInfo
60 	{
61 	public:
62 		Type           _type       = Type::UNDEF;
63 		Range          _range      = Range::UNDEF;
64 
65 		// Maximum supported linear value, for 16-bit coding. Should be >= 1.0.
66 		double         _vmax       = 1.0;
67 
68 		// Reference white level, linear scale. > 0. Set to 1.0 when unknown.
69 		double         _wref       = 1.0;
70 
71 		// Luminance corresponding to linear 1.0, in cd/m^2.
72 		// Not necessarily the peak white nor the reference white.
73 		// Dedicated to EOTFs, but not mandatory. 0 = unknown/unspecified
74 		double         _scale_cdm2 = 0;
75 
76 		// Peak white, in cd/m^2.
77 		// Dedicated to EOTFs, but not mandatory. 0 = unknown/unspecified
78 		double         _wpeak_cdm2 = 0;
79 	};
80 
81 	// Return this if nothing is known (modifiers)
82 	static constexpr LinInfo   _unbounded { Type::UNDEF, Range::UNDEF, 1e9, 1, 0, 0 };
83 
~TransOpInterface()84 	virtual        ~TransOpInterface () {}
85 
86 	// It is the operator responsibility to clip the input and output
87 	// (input domain or spec requirement).
88 	double         operator () (double x) const;
89 
90 	LinInfo        get_info () const;
91 
92 
93 
94 /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
95 
96 protected:
97 
98 	virtual double do_convert (double x) const = 0;
99 	virtual LinInfo
do_get_info()100 	               do_get_info () const { return { }; }
101 
102 
103 
104 };	// class TransOpInterface
105 
106 
107 
108 }	// namespace fmtcl
109 
110 
111 
112 //#include "fmtcl/TransOpInterface.hpp"
113 
114 
115 
116 #endif	// fmtcl_TransOpInterface_HEADER_INCLUDED
117 
118 
119 
120 /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
121