libopenraw
tiffepfile.cpp
1 /*
2  * libopenraw - tiffepfile.cpp
3  *
4  * Copyright (C) 2007-2017 Hubert Figuière
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <vector>
22 
23 #include <algorithm>
24 #include <memory>
25 
26 #include <libopenraw/debug.h>
27 
28 #include "rawfile.hpp"
29 #include "trace.hpp"
30 #include "tiffepfile.hpp"
31 #include "ifddir.hpp"
32 #include "ifdfilecontainer.hpp"
33 
34 using namespace Debug;
35 
36 namespace OpenRaw {
37 namespace Internals {
38 
39 TiffEpFile::TiffEpFile(const IO::Stream::Ptr &s,
40  Type _type)
41  : IfdFile(s, _type)
42 {
43 }
44 
45 
46 IfdDir::Ref TiffEpFile::_locateCfaIfd()
47 {
48  const IfdDir::Ref & _mainIfd = mainIfd();
49 
50  if (!_mainIfd) {
51  LOGDBG1("couldn't find main ifd\n");
52  return IfdDir::Ref();
53  }
54  if (_mainIfd->isPrimary()) {
55  return _mainIfd;
56  }
57  auto result = _mainIfd->getSubIFDs();
58  if (result.empty()) {
59  // error
60  LOGDBG1("couldn't find main ifd nor subifds\n");
61  return IfdDir::Ref();
62  }
63 
64  std::vector<IfdDir::Ref> subdirs = result.unwrap();
65  auto i = find_if(subdirs.cbegin(),
66  subdirs.cend(),
67  [] (const IfdDir::Ref& e) {
68  return e->isPrimary();
69  });
70  if (i != subdirs.cend()) {
71  return *i;
72  }
73  LOGDBG1("couldn't find a primary subifd\n");
74  return IfdDir::Ref();
75 }
76 
77 IfdDir::Ref TiffEpFile::_locateMainIfd()
78 {
79  return m_container->setDirectory(0);
80 }
81 
82 }
83 }
84 /*
85  Local Variables:
86  mode:c++
87  c-file-style:"stroustrup"
88  c-file-offsets:((innamespace . 0))
89  indent-tabs-mode:nil
90  fill-column:80
91  End:
92 */
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.
Definition: arwfile.cpp:30
Definition: trace.cpp:30