libopenraw
|
00001 /* -*- mode:c++; tab-width:4; c-basic-offset:4 -*- */ 00002 /* 00003 * libopenraw - nefcfaiterator.h 00004 * 00005 * Copyright (C) 2008 Rafael Avila de Espindola. 00006 * 00007 * This library is free software: you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License 00009 * as published by the Free Software Foundation, either version 3 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library. If not, see 00019 * <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 #include "nefcfaiterator.h" 00023 00024 namespace OpenRaw { 00025 namespace Internals { 00026 00027 NefCfaIterator::NefCfaIterator(const NefDiffIterator& diffs, size_t rows, 00028 size_t columns, const uint16_t init[2][2]) 00029 : m_diffs(diffs), m_rows(rows), 00030 m_columns(columns), m_row(0), 00031 m_column(0) 00032 { 00033 for (int i = 0; i < 2; ++i) { 00034 for (int j = 0; j < 2; ++j) { 00035 m_vpred[i][j] = init[i][j]; 00036 } 00037 m_hpred[i] = 0x148; 00038 } 00039 } 00040 00041 uint16_t NefCfaIterator::get() 00042 { 00043 int diff = m_diffs.get(); 00044 uint16_t ret; 00045 if (m_column < 2) { 00046 ret = m_vpred[m_row & 1][m_column] + diff; 00047 m_vpred[m_row & 1][m_column] = ret; 00048 00049 } else { 00050 ret = m_hpred[m_column & 1] + diff; 00051 } 00052 m_hpred[m_column & 1] = ret; 00053 00054 m_column++; 00055 if (m_column == m_columns) { 00056 m_column = 0; 00057 m_row++; 00058 } 00059 return ret; 00060 } 00061 00062 } 00063 } 00064