libopenraw
nefcfaiterator.cpp
1/* -*- mode:c++; tab-width:4; c-basic-offset:4 -*- */
2/*
3 * libopenraw - nefcfaiterator.h
4 *
5 * Copyright (C) 2008 Rafael Avila de Espindola.
6 *
7 * This library is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see
19 * <http://www.gnu.org/licenses/>.
20 */
21
22#include "nefcfaiterator.hpp"
23
24namespace OpenRaw {
25namespace Internals {
26
27NefCfaIterator::NefCfaIterator(const NefDiffIterator& diffs, size_t rows,
28 size_t columns, const uint16_t init[2][2])
29 : m_diffs(diffs), m_rows(rows),
30 m_columns(columns), m_row(0),
31 m_column(0)
32{
33 for (int i = 0; i < 2; ++i) {
34 for (int j = 0; j < 2; ++j) {
35 m_vpred[i][j] = init[i][j];
36 }
37 m_hpred[i] = 0x148;
38 }
39}
40
41uint16_t NefCfaIterator::get()
42{
43 int diff = m_diffs.get();
44 uint16_t ret;
45 if (m_column < 2) {
46 ret = m_vpred[m_row & 1][m_column] + diff;
47 m_vpred[m_row & 1][m_column] = ret;
48
49 } else {
50 ret = m_hpred[m_column & 1] + diff;
51 }
52 m_hpred[m_column & 1] = ret;
53
54 m_column++;
55 if (m_column == m_columns) {
56 m_column = 0;
57 m_row++;
58 }
59 return ret;
60}
61
62}
63}
64
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard....
Definition arwfile.cpp:30