forked from cameramanben/LUTCalc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlutcamerabox.js
233 lines (232 loc) · 10.1 KB
/
lutcamerabox.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/* lutcamerabox.js
* Camera and ISO options UI object for the LUTCalc Web App.
* 7th October 2014
*
* LUTCalc generates 1D and 3D Lookup Tables (LUTs) for video cameras that shoot log gammas,
* principally the Sony CineAlta line.
*
* By Ben Turley, http://turley.tv
* First License: GPLv2
* Github: https://github.com/cameramanben/LUTCalc
*/
function LUTCameraBox(fieldset, inputs, messages) {
this.inputs = inputs;
this.messages = messages;
this.p = 1;
this.messages.addUI(this.p,this);
this.box = document.createElement('fieldset');
fieldset.appendChild(this.box);
this.build();
lutcalcReady(this.p);
}
LUTCameraBox.prototype.build = function() {
this.io();
this.ui();
};
LUTCameraBox.prototype.io = function() {
this.cameras = [];
this.cameraList();
this.current = 0;
this.cameraSelect = document.createElement('select');
this.cameraOptions();
this.inputs.addInput('bclip',this.cameras[this.current].bclip);
this.inputs.addInput('wclip',this.cameras[this.current].wclip);
this.cameraSelect.options[this.current].selected = true;
this.inputs.addInput('camera',this.cameraSelect);
this.cameraType = document.createElement('input');
this.cameraType.setAttribute('type','hidden');
this.cameraType.value = this.cameras[this.current].type.toString();
this.inputs.addInput('cameraType',this.cameraType);
this.nativeLabel = document.createElement('label');
this.inputs.addInput('nativeISO',this.nativeLabel);
this.cineeiInput = document.createElement('input');
this.cineeiInput.setAttribute('type','number');
this.cineeiInput.setAttribute('class','isoinput');
this.cineeiInput.value = this.cameras[this.current].iso.toString();
this.inputs.addInput('cineEI',this.cineeiInput);
this.shiftInput = document.createElement('input');
this.shiftInput.setAttribute('type','number');
this.shiftInput.setAttribute('step','any');
this.shiftInput.setAttribute('class','shiftinput');
this.shiftInput.value = '0';
this.inputs.addInput('stopShift',this.shiftInput);
this.inputs.addInput('defGammaIn',this.cameras[this.current].defgamma);
this.inputs.addInput('defGamutIn',this.cameras[this.current].defgamut);
};
LUTCameraBox.prototype.ui = function() {
this.box.appendChild(document.createElement('label').appendChild(document.createTextNode('Camera')));
this.box.appendChild(this.cameraSelect);
this.box.appendChild(this.cameraType);
this.box.appendChild(document.createElement('label').appendChild(document.createTextNode('Native ISO:')));
this.nativeLabel.innerHTML = this.cameras[this.current].iso.toString();
this.box.appendChild(this.nativeLabel);
this.recorded = document.createElement('div');
this.cineeiLabel = document.createElement('label');
this.cineeiLabel.innerHTML = 'CineEI ISO';
this.recorded.appendChild(this.cineeiLabel);
this.recorded.appendChild(this.cineeiInput);
this.box.appendChild(this.recorded);
this.shifted = document.createElement('div');
this.shifted.appendChild(document.createElement('label').appendChild(document.createTextNode('Stop Correction')));
this.shifted.appendChild(this.shiftInput);
this.box.appendChild(this.shifted);
};
LUTCameraBox.prototype.events = function() {
this.cameraSelect.onchange = function(here){ return function(){
here.changeCamera();
here.messages.changeCamera();
};}(this);
this.cineeiInput.onchange = function(here){ return function(){
here.changeCineEI();
here.messages.gaSetParams();
};}(this);
this.shiftInput.onchange = function(here){ return function(){
here.changeShift();
here.messages.gaSetParams();
};}(this);
};
// Set Up Data
LUTCameraBox.prototype.cameraList = function() {
// Type: 0 == CineEI, 1 == Variable Parameters (Arri), 2 == Baked In Gain (Canon)
this.cameras.push({make:"",model:"Generic",iso:800,type:2,defgamma:"Cineon",defgamut:"Rec709",bclip:-10,wclip:10});
this.cameras.push({make:"Sony",model:"PMW-F55",iso:1250,type:0,defgamma:"S-Log3",defgamut:"Sony S-Gamut3.cine",bclip:-8,wclip:6});
this.cameras.push({make:"Sony",model:"PMW-F5",iso:2000,type:0,defgamma:"S-Log3",defgamut:"Sony S-Gamut3.cine",bclip:-8,wclip:6});
this.cameras.push({make:"Sony",model:"PXW-FS7",iso:2000,type:0,defgamma:"S-Log3",defgamut:"Sony S-Gamut3.cine",bclip:-8,wclip:6});
this.cameras.push({make:"Sony",model:"a7s mkII",iso:1600,type:2,defgamma:"S-Log3",defgamut:"Sony S-Gamut3.cine",bclip:-8,wclip:6});
this.cameras.push({make:"Sony",model:"a7s",iso:3200,type:2,defgamma:"S-Log2",defgamut:"Sony S-Gamut",bclip:-8,wclip:6});
this.cameras.push({make:"Sony",model:"F65",iso:800,type:0,defgamma:"S-Log3",defgamut:"Sony S-Gamut3",bclip:-8,wclip:6});
this.cameras.push({make:"Sony",model:"PMW-F3",iso:800,type:0,defgamma:"S-Log",defgamut:"Sony S-Gamut",bclip:-6.6,wclip:5.5});
this.cameras.push({make:"Sony",model:"F35",iso:500,type:0,defgamma:"S-Log",defgamut:"Sony S-Gamut",bclip:-6.6,wclip:5.5});
this.cameras.push({make:"Arri",model:"Alexa / Amira",iso:800,type:1,defgamma:"LogC (Sup 3.x & 4.x)",defgamut:"Alexa Wide Gamut",bclip:-6.6,wclip:7.4});
this.cameras.push({make:"RED",model:"Epic DRAGON",iso:800,type:0,defgamma:"REDLogFilm",defgamut:"DRAGONColor2",bclip:-10,wclip:6.3});
this.cameras.push({make:"Canon",model:"C500",iso:850,type:2,defgamma:"C-Log",defgamut:"Canon Cinema Gamut",bclip:-6.7,wclip:5.3});
this.cameras.push({make:"Canon",model:"C300",iso:850,type:2,defgamma:"C-Log",defgamut:"Canon CP IDT (Daylight)",bclip:-6.7,wclip:5.3});
this.cameras.push({make:"Canon",model:"C300mkII",iso:800,type:2,defgamma:"Canon C-Log2",defgamut:"Canon Cinema Gamut",bclip:-8.7,wclip:6.3});
this.cameras.push({make:"Panasonic",model:"Varicam 35",iso:800,type:2,defgamma:"Panasonic V-Log",defgamut:"Panasonic V-Gamut",bclip:-7.5,wclip:6.5});
this.cameras.push({make:"GoPro",model:"Hero4",iso:400,type:2,defgamma:"Protune",defgamut:"Protune Native",bclip:-9,wclip:3.3});
this.cameras.push({make:"Nikon",model:"D800",iso:100,type:2,defgamma:"Nikon Neutral",defgamut:"Rec709",bclip:-10.9,wclip:3.5});
};
LUTCameraBox.prototype.cameraOptions = function() {
var max = this.cameras.length;
for (var i=0; i<max; i++) {
var option = document.createElement('option');
option.value = i;
option.appendChild(document.createTextNode(this.cameras[i].make + ' ' + this.cameras[i].model));
if (this.cameras[i].model === 'PMW-F55') {
this.current = i;
}
this.cameraSelect.appendChild(option);
}
};
// Event Responses
LUTCameraBox.prototype.changeCamera = function() {
this.current = this.cameraSelect.options.selectedIndex;
this.inputs.defGammaIn = this.cameras[this.current].defgamma;
this.inputs.defGamutIn = this.cameras[this.current].defgamut;
var m = this.inputs.inGammaSubs.options.length;
var found = false;
var allIdx = m-1;
for (var j=0; j<m; j++) {
if (this.inputs.inGammaSubs.options[j].lastChild.nodeValue === this.cameras[this.current].make) {
this.inputs.inGammaSubs.options[j].selected = true;
found = true;
break;
} else if (this.inputs.inGammaSubs.options[j].lastChild.nodeValue === 'All') {
allIdx = j;
}
}
if (!found) {
this.inputs.inGammaSubs.options[allIdx].selected = true;
}
found = false;
allIdx = m-1;
m = this.inputs.inGamutSubs.options.length;
for (var j=0; j<m; j++) {
if (this.inputs.inGamutSubs.options[j].lastChild.nodeValue === this.cameras[this.current].make) {
this.inputs.inGamutSubs.options[j].selected = true;
found = true;
break;
} else if (this.inputs.inGamutSubs.options[j].lastChild.nodeValue === 'All') {
allIdx = j;
}
}
if (!found) {
this.inputs.inGamutSubs.options[allIdx].selected = true;
}
this.inputs.bclip = this.cameras[this.current].bclip;
this.inputs.wclip = this.cameras[this.current].wclip;
if (this.cameras[this.current].model === 'Generic') {
this.nativeLabel.innerHTML = 'N/A';
} else {
this.nativeLabel.innerHTML = this.cameras[this.current].iso.toString();
}
this.cineeiInput.value = this.cameras[this.current].iso.toString();
this.shiftInput.value = '0';
this.cameraType.value = this.cameras[this.current].type.toString();
if (this.cameras[this.current].type === 2) {
this.recorded.style.display = 'none';
this.shifted.style.display = 'block';
} else if (this.cameras[this.current].type === 1) {
this.recorded.style.display = 'block';
this.shifted.style.display = 'block';
this.cineeiLabel.innerHTML = 'Recorded ISO';
} else {
this.recorded.style.display = 'block';
this.shifted.style.display = 'block';
this.cineeiLabel.innerHTML = 'CineEI ISO';
}
this.cameraType.value = this.cameras[this.current].type;
};
LUTCameraBox.prototype.changeCineEI = function(){
if (/^([1-9]\d*)$/.test(this.cineeiInput.value)) {
} else {
this.cineeiInput.value = this.cameras[this.current].iso.toString();
}
if (this.cameras[this.current].type === 0) {
var stopShift = (Math.log(parseFloat(this.cineeiInput.value)/parseFloat(this.nativeLabel.innerHTML))/Math.LN2);
this.shiftInput.value = stopShift.toFixed(4).toString();
}
};
LUTCameraBox.prototype.changeShift = function() {
if (!isNaN(parseFloat(this.shiftInput.value)) && isFinite(this.shiftInput.value)) {
} else {
this.shiftInput.value = '0';
}
if (this.cameras[this.current].type === 0) {
this.cineeiInput.value = Math.round((Math.pow(2,parseFloat(this.shiftInput.value)))*parseFloat(this.nativeLabel.innerHTML)).toString();
}
};
LUTCameraBox.prototype.getInfo = function(info) {
info.camera = this.cameraSelect.options[this.cameraSelect.selectedIndex].lastChild.nodeValue;
info.cineEI = parseFloat(this.shiftInput.value);
};
LUTCameraBox.prototype.getSettings = function(data) {
var camIdx = this.cameraSelect.selectedIndex;
data.cameraBox = {
make: this.cameras[camIdx].make,
model: this.cameras[camIdx].model,
shift: parseFloat(this.shiftInput.value)
};
};
LUTCameraBox.prototype.setSettings = function(settings) {
if (typeof settings.cameraBox !== 'undefined') {
var data = settings.cameraBox;
if (typeof data.model === 'string') {
var m = this.cameras.length;
for (var j=0; j<m; j++) {
if (this.cameras[j].model === data.model) {
this.cameraSelect.options[j].selected = true;
break;
}
}
this.changeCamera();
}
if (typeof data.shift === 'number') {
this.shiftInput.value = data.shift.toString();
this.changeShift();
}
}
};
LUTCameraBox.prototype.getHeight = function() {
return this.box.clientHeight;
};