No-op; Fix GPL address and mention libdcp by name.
[libdcp.git] / src / transfer_function.cc
1 /*
2     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     libdcp is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "transfer_function.h"
22 #include <cmath>
23
24 using std::pow;
25 using std::map;
26 using std::pair;
27 using std::make_pair;
28 using boost::shared_ptr;
29 using namespace dcp;
30
31 TransferFunction::~TransferFunction ()
32 {
33         boost::mutex::scoped_lock lm (_mutex);
34
35         for (map<pair<int, bool>, double*>::const_iterator i = _luts.begin(); i != _luts.end(); ++i) {
36                 delete[] i->second;
37         }
38
39         _luts.clear ();
40 }
41
42 double const *
43 TransferFunction::lut (int bit_depth, bool inverse) const
44 {
45         boost::mutex::scoped_lock lm (_mutex);
46
47         map<pair<int, bool>, double*>::const_iterator i = _luts.find (make_pair (bit_depth, inverse));
48         if (i != _luts.end ()) {
49                 return i->second;
50         }
51
52         _luts[make_pair(bit_depth, inverse)] = make_lut (bit_depth, inverse);
53         return _luts[make_pair(bit_depth, inverse)];
54 }