~ubuntu-branches/ubuntu/vivid/rawstudio/vivid

« back to all changes in this revision

Viewing changes to plugins/load-rawspeed/rawspeed/PefDecoder.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2011-07-28 17:36:32 UTC
  • mfrom: (2.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20110728173632-5czluz9ye3c83zc5
Tags: 2.0-1
* [3750b2cf] Merge commit 'upstream/2.0'
* [63637468] Removing Patch, not necessary anymore.
* [2fb580dc] Add new build-dependencies.
* [c57d953b] Run dh_autoreconf due to patches in configure.in
* [13febe39] Add patch to remove the libssl requirement.
* [5ae773fe] Replace libjpeg62-dev by libjpeg8-dev :)
* [1969d755] Don't build static libraries.
* [7cfe0a2e] Add a patch to fix the plugin directory path.
  As plugins are shared libraries, they need to go into /usr/lib,
  not into /usr/share.
  Thanks to Andrew McMillan
* [c1d0d9dd] Don't install .la files for all plugins and libraries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "StdAfx.h"
 
2
#include "PefDecoder.h"
 
3
/*
 
4
    RawSpeed - RAW file decoder.
 
5
 
 
6
    Copyright (C) 2009 Klaus Post
 
7
 
 
8
    This library is free software; you can redistribute it and/or
 
9
    modify it under the terms of the GNU Lesser General Public
 
10
    License as published by the Free Software Foundation; either
 
11
    version 2 of the License, or (at your option) any later version.
 
12
 
 
13
    This library is distributed in the hope that it will be useful,
 
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
    Lesser General Public License for more details.
 
17
 
 
18
    You should have received a copy of the GNU Lesser General Public
 
19
    License along with this library; if not, write to the Free Software
 
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
21
 
 
22
    http://www.klauspost.com
 
23
*/
 
24
 
 
25
namespace RawSpeed {
 
26
 
 
27
PefDecoder::PefDecoder(TiffIFD *rootIFD, FileMap* file) :
 
28
    RawDecoder(file), mRootIFD(rootIFD) {
 
29
      decoderVersion = 2;
 
30
}
 
31
 
 
32
PefDecoder::~PefDecoder(void) {
 
33
}
 
34
 
 
35
RawImage PefDecoder::decodeRaw() {
 
36
  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(STRIPOFFSETS);
 
37
 
 
38
  if (data.empty())
 
39
    ThrowRDE("PEF Decoder: No image data found");
 
40
 
 
41
  TiffIFD* raw = data[0];
 
42
 
 
43
  int compression = raw->getEntry(COMPRESSION)->getInt();
 
44
 
 
45
  if (1 == compression) {
 
46
    decodeUncompressed(raw, true);
 
47
    return mRaw;
 
48
  }
 
49
 
 
50
  if (65535 != compression)
 
51
    ThrowRDE("PEF Decoder: Unsupported compression");
 
52
 
 
53
  TiffEntry *offsets = raw->getEntry(STRIPOFFSETS);
 
54
  TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS);
 
55
 
 
56
  if (offsets->count != 1) {
 
57
    ThrowRDE("PEF Decoder: Multiple Strips found: %u", offsets->count);
 
58
  }
 
59
  if (counts->count != offsets->count) {
 
60
    ThrowRDE("PEF Decoder: Byte count number does not match strip size: count:%u, strips:%u ", counts->count, offsets->count);
 
61
  }
 
62
  if (!mFile->isValid(offsets->getInt() + counts->getInt()))
 
63
    ThrowRDE("PEF Decoder: Truncated file.");
 
64
 
 
65
  uint32 width = raw->getEntry(IMAGEWIDTH)->getInt();
 
66
  uint32 height = raw->getEntry(IMAGELENGTH)->getInt();
 
67
 
 
68
  mRaw->dim = iPoint2D(width, height);
 
69
  mRaw->createData();
 
70
  try {
 
71
    PentaxDecompressor l(mFile, mRaw);
 
72
    l.decodePentax(mRootIFD, offsets->getInt(), counts->getInt());
 
73
  } catch (IOException e) {
 
74
    errors.push_back(_strdup(e.what()));
 
75
    // Let's ignore it, it may have delivered somewhat useful data.
 
76
  }
 
77
 
 
78
  return mRaw;
 
79
}
 
80
 
 
81
void PefDecoder::checkSupport(CameraMetaData *meta) {
 
82
  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
 
83
  if (data.empty())
 
84
    ThrowRDE("PEF Support check: Model name found");
 
85
 
 
86
  string make = data[0]->getEntry(MAKE)->getString();
 
87
  string model = data[0]->getEntry(MODEL)->getString();
 
88
  this->checkCameraSupported(meta, make, model, "");
 
89
}
 
90
 
 
91
void PefDecoder::decodeMetaData(CameraMetaData *meta) {
 
92
  mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
 
93
  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
 
94
 
 
95
  if (data.empty())
 
96
    ThrowRDE("PEF Meta Decoder: Model name found");
 
97
 
 
98
  TiffIFD* raw = data[0];
 
99
 
 
100
  string make = raw->getEntry(MAKE)->getString();
 
101
  string model = raw->getEntry(MODEL)->getString();
 
102
 
 
103
  setMetaData(meta, make, model, "");
 
104
}
 
105
 
 
106
} // namespace RawSpeed