libopenraw
peffile.cpp
1 /*
2  * libopenraw - peffile.cpp
3  *
4  * Copyright (C) 2006-2008, 2010 Hubert Figuiere
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 
22 #include <iostream>
23 #include <libopenraw++/thumbnail.h>
24 #include <libopenraw++/rawdata.h>
25 
26 #include "trace.h"
27 #include "ifd.h"
28 #include "ifdfilecontainer.h"
29 #include "ifddir.h"
30 #include "ifdentry.h"
31 #include "io/file.h"
32 #include "peffile.h"
33 
34 using namespace Debug;
35 
36 namespace OpenRaw {
37 
38 
39  namespace Internals {
40  const struct IFDFile::camera_ids_t PEFFile::s_def[] = {
41  { "PENTAX *ist D ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
42  OR_TYPEID_PENTAX_IST_D) },
43  { "PENTAX *ist DL ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
44  OR_TYPEID_PENTAX_IST_DL) },
45  { "PENTAX K10D ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
46  OR_TYPEID_PENTAX_K10D_PEF) },
47  { "PENTAX K100D ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
48  OR_TYPEID_PENTAX_K100D_PEF) },
49  { "PENTAX K100D Super ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
50  OR_TYPEID_PENTAX_K100D_PEF) },
51  { "PENTAX K20D ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
52  OR_TYPEID_PENTAX_K20D_PEF) },
53  { 0, 0 }
54  };
55 
56 
57  RawFile *PEFFile::factory(IO::Stream *s)
58  {
59  return new PEFFile(s);
60  }
61 
62  PEFFile::PEFFile(IO::Stream *s)
63  : IFDFile(s, OR_RAWFILE_TYPE_PEF)
64  {
65  _setIdMap(s_def);
66  }
67 
68 
69  PEFFile::~PEFFile()
70  {
71  }
72 
73  IFDDir::Ref PEFFile::_locateCfaIfd()
74  {
75  // in PEF the CFA IFD is the main IFD
76  if(!m_mainIfd) {
77  m_mainIfd = _locateMainIfd();
78  }
79  return m_mainIfd;
80  }
81 
82 
83  IFDDir::Ref PEFFile::_locateMainIfd()
84  {
85  return m_container->setDirectory(0);
86  }
87 
88  ::or_error PEFFile::_getRawData(RawData & data, uint32_t options)
89  {
90  ::or_error err;
91  if(!m_cfaIfd) {
92  m_cfaIfd = _locateCfaIfd();
93  }
94  err = _getRawDataFromDir(data, m_cfaIfd);
95  if(err == OR_ERROR_NONE) {
96  uint16_t compression = data.compression();
97  switch(compression) {
98  case 65535:
99  if((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) {
100  // TODO decompress
101  }
102  break;
103  default:
104  break;
105  }
106  }
107  return err;
108  }
109  }
110 }
111 
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:33
IFDFileContainer * m_container
Definition: ifdfile.h:95
Definition: trace.cpp:28
base virtual class for IO
Definition: stream.h:40
virtual ::or_error _getRawData(RawData &data, uint32_t options)
Definition: peffile.cpp:88
::or_error _getRawDataFromDir(RawData &data, IFDDir::Ref &dir)
Definition: ifdfile.cpp:477