Blame lib/nefcfaiterator.cpp

rpm-build d2b433
/* -*- mode:c++; tab-width:4; c-basic-offset:4 -*- */
rpm-build d2b433
/*
rpm-build d2b433
 * libopenraw - nefcfaiterator.h
rpm-build d2b433
 *
rpm-build d2b433
 * Copyright (C) 2008 Rafael Avila de Espindola.
rpm-build d2b433
 *
rpm-build d2b433
 * This library is free software: you can redistribute it and/or
rpm-build d2b433
 * modify it under the terms of the GNU Lesser General Public License
rpm-build d2b433
 * as published by the Free Software Foundation, either version 3 of
rpm-build d2b433
 * the License, or (at your option) any later version.
rpm-build d2b433
 *
rpm-build d2b433
 * This library is distributed in the hope that it will be useful,
rpm-build d2b433
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build d2b433
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build d2b433
 * Lesser General Public License for more details.
rpm-build d2b433
 *
rpm-build d2b433
 * You should have received a copy of the GNU Lesser General Public
rpm-build d2b433
 * License along with this library.  If not, see
rpm-build d2b433
 * <http://www.gnu.org/licenses/>.
rpm-build d2b433
 */
rpm-build d2b433
rpm-build d2b433
#include "nefcfaiterator.hpp"
rpm-build d2b433
rpm-build d2b433
namespace OpenRaw {
rpm-build d2b433
namespace Internals {
rpm-build d2b433
rpm-build d2b433
NefCfaIterator::NefCfaIterator(const NefDiffIterator& diffs, size_t rows,
rpm-build d2b433
							   size_t columns, const uint16_t init[2][2])
rpm-build d2b433
	: m_diffs(diffs), m_rows(rows),
rpm-build d2b433
	  m_columns(columns), m_row(0),
rpm-build d2b433
	  m_column(0)
rpm-build d2b433
{
rpm-build d2b433
	for (int i = 0; i < 2; ++i) {
rpm-build d2b433
		for (int j = 0; j < 2; ++j) {
rpm-build d2b433
			m_vpred[i][j] = init[i][j];
rpm-build d2b433
		}
rpm-build d2b433
		m_hpred[i] = 0x148;
rpm-build d2b433
	}
rpm-build d2b433
}
rpm-build d2b433
rpm-build d2b433
uint16_t NefCfaIterator::get()
rpm-build d2b433
{
rpm-build d2b433
	int diff = m_diffs.get();
rpm-build d2b433
	uint16_t ret;
rpm-build d2b433
	if (m_column < 2) {
rpm-build d2b433
		ret = m_vpred[m_row & 1][m_column] + diff;
rpm-build d2b433
		m_vpred[m_row & 1][m_column] = ret;
rpm-build d2b433
rpm-build d2b433
	} else {
rpm-build d2b433
		ret = m_hpred[m_column & 1] + diff;
rpm-build d2b433
	}
rpm-build d2b433
	m_hpred[m_column & 1] = ret;
rpm-build d2b433
rpm-build d2b433
	m_column++;
rpm-build d2b433
	if (m_column == m_columns) {
rpm-build d2b433
		m_column = 0;
rpm-build d2b433
		m_row++;
rpm-build d2b433
	}
rpm-build d2b433
	return ret;
rpm-build d2b433
}
rpm-build d2b433
rpm-build d2b433
}
rpm-build d2b433
}
rpm-build d2b433