20#include "kis_tiff_stream.h"
22TIFFStreamContigBase::TIFFStreamContigBase( uint8* src, uint16 depth, uint32 lineSize ) : TIFFStreamBase(depth), m_src(src), m_lineSize(lineSize) { restart(); }
24void TIFFStreamContigBase::restart()
30void TIFFStreamContigBase::moveToLine(uint32 lineNumber)
32 m_srcit = m_src + lineNumber * m_lineSize;
36uint32 TIFFStreamContigBelow16::nextValue()
46 if (toread > m_posinc) toread = m_posinc;
49 value = (value << toread) | (( (*m_srcit) >> (m_posinc) ) & ( ( 1 << toread ) - 1 ) );
59uint32 TIFFStreamContigBelow32::nextValue()
69 if (toread > m_posinc) toread = m_posinc;
72 value = (value) | ( (( (*m_srcit) >> (m_posinc) ) & ( ( 1 << toread ) - 1 ) ) << ( m_depth - 8 - remain ) );
82uint32 TIFFStreamContigAbove32::nextValue()
92 if (toread > m_posinc) toread = m_posinc;
97 value = (value) | ( (( (*m_srcit) >> (m_posinc) ) & ( ( 1 << toread ) - 1 ) ) << ( 24 - remain ) );
108TIFFStreamSeperate::TIFFStreamSeperate( uint8** srcs, uint8 nb_samples ,uint16 depth, uint32* lineSize) : TIFFStreamBase(depth), m_nb_samples(nb_samples)
110 streams =
new TIFFStreamContigBase*[nb_samples];
113 for(uint8 i = 0; i < m_nb_samples; i++)
115 streams[i] =
new TIFFStreamContigBelow16(srcs[i], depth, lineSize[i]);
117 }
else if( depth < 32 )
119 for(uint8 i = 0; i < m_nb_samples; i++)
121 streams[i] =
new TIFFStreamContigBelow32(srcs[i], depth, lineSize[i]);
124 for(uint8 i = 0; i < m_nb_samples; i++)
126 streams[i] =
new TIFFStreamContigAbove32(srcs[i], depth, lineSize[i]);
132TIFFStreamSeperate::~TIFFStreamSeperate()
134 for(uint8 i = 0; i < m_nb_samples; i++)
141uint32 TIFFStreamSeperate::nextValue()
143 uint32 value = streams[ m_current_sample ]->nextValue();
144 if( (++m_current_sample) >= m_nb_samples)
145 m_current_sample = 0;
149void TIFFStreamSeperate::restart()
151 m_current_sample = 0;
152 for(uint8 i = 0; i < m_nb_samples; i++)
154 streams[i]->restart();
158void TIFFStreamSeperate::moveToLine(uint32 lineNumber)
160 for(uint8 i = 0; i < m_nb_samples; i++)
162 streams[i]->moveToLine(lineNumber);