File: peffile.cpp

package info (click to toggle)
libopenraw 0.0.8-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,964 kB
  • ctags: 1,936
  • sloc: sh: 10,199; cpp: 9,279; ansic: 1,466; makefile: 544; xml: 465; perl: 42
file content (111 lines) | stat: -rw-r--r-- 2,887 bytes parent folder | download
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
/*
 * libopenraw - peffile.cpp
 *
 * Copyright (C) 2006-2008, 2010 Hubert Figuiere
 *
 * This library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <http://www.gnu.org/licenses/>.
 */


#include <iostream>
#include <libopenraw++/thumbnail.h>
#include <libopenraw++/rawdata.h>

#include "debug.h"
#include "ifd.h"
#include "ifdfilecontainer.h"
#include "ifddir.h"
#include "ifdentry.h"
#include "io/file.h"
#include "peffile.h"

using namespace Debug;

namespace OpenRaw {


	namespace Internals {
		const struct IFDFile::camera_ids_t PEFFile::s_def[] = {
			{ "PENTAX *ist D      ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 
														 OR_TYPEID_PENTAX_IST_D) },
			{ "PENTAX *ist DL     ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 
														 OR_TYPEID_PENTAX_IST_DL) },
			{ "PENTAX K10D        ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 
														 OR_TYPEID_PENTAX_K10D_PEF) },
			{ "PENTAX K100D       ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 
														 OR_TYPEID_PENTAX_K100D_PEF) },
			{ "PENTAX K100D Super ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 
														 OR_TYPEID_PENTAX_K100D_PEF) },
			{ "PENTAX K20D        ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
														 OR_TYPEID_PENTAX_K20D_PEF) },
			{ 0, 0 }
		};


		RawFile *PEFFile::factory(IO::Stream *s)
		{
			return new PEFFile(s);
		}

		PEFFile::PEFFile(IO::Stream *s)
			: IFDFile(s, OR_RAWFILE_TYPE_PEF)
		{
			_setIdMap(s_def);
		}


		PEFFile::~PEFFile()
		{
		}

		IFDDir::Ref  PEFFile::_locateCfaIfd()
		{
			// in PEF the CFA IFD is the main IFD
			if(!m_mainIfd) {
				m_mainIfd = _locateMainIfd();
			}
			return m_mainIfd;
		}


		IFDDir::Ref  PEFFile::_locateMainIfd()
		{
			return m_container->setDirectory(0);
		}

		::or_error PEFFile::_getRawData(RawData & data, uint32_t options)
		{
			::or_error err;
			if(!m_cfaIfd) {
				m_cfaIfd = _locateCfaIfd();
			}
			err = _getRawDataFromDir(data, m_cfaIfd);
			if(err == OR_ERROR_NONE) {
                uint16_t compression = data.compression();
                switch(compression) {
                case 65535:
                    if((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) {
                        // TODO decompress
                    }
					break;
				default:
					break;
				}
			}
			return err;
		}
	}
}