8 template<
typename EntropyCodec>
10 size_t number_of_contexts,
14 EntropyCodec(subband_byteio,number_of_contexts),
17 m_node(band_list(band_num)),
18 m_last_qf_idx(m_node.QuantIndex())
26 template<
typename EntropyCodec>
34 bool code_skip = (block_list.LengthX() > 1 || block_list.LengthY() > 1);
36 for (
int j=block_list.FirstY() ; j<=block_list.LastY() ; ++j)
39 for (
int i=block_list.FirstX() ; i<=block_list.LastX() ; ++i)
43 if ( !block[i].Skipped() )
52 template<
typename EntropyCodec>
57 const int xbeg = code_block.
Xstart();
58 const int ybeg = code_block.
Ystart();
59 const int xend = code_block.
Xend();
60 const int yend = code_block.
Yend();
72 m_qf = dirac_quantiser_lists.QuantFactor4( qf_idx );
74 m_offset = dirac_quantiser_lists.IntraQuantOffset4( qf_idx );
76 m_offset = dirac_quantiser_lists.InterQuantOffset4( qf_idx );
78 for (
int ypos=ybeg; ypos<yend ;++ypos)
81 for (
int xpos=xbeg; xpos<xend ;++xpos)
105 template<
typename EntropyCodec>
108 CodeVal( in_data , xpos , ypos , in_data[ypos][xpos] );
130 template<
typename EntropyCodec>
136 unsigned int abs_val( std::abs(val) );
140 const int N = abs_val+1;
141 int num_follow_zeroes=0;
143 while ( N >= (1<<num_follow_zeroes) )
147 for (
int i=num_follow_zeroes-1, c=1; i>=0; --i, ++c )
154 in_data[ypos][xpos] =
static_cast<CoeffType>( abs_val );
159 in_data[ypos][xpos] *=
m_qf;
161 in_data[ypos][xpos] >>= 2;
170 in_data[ypos][xpos] = -in_data[ypos][xpos];
175 template<
typename EntropyCodec>
179 const int abs_val = std::abs( offset );
182 int num_follow_zeroes=0;
184 while ( N>= (1<<num_follow_zeroes) )
188 for (
int i=num_follow_zeroes-1, c=1; i>=0; --i, ++c )
204 template<
typename EntropyCodec>
211 bool decode_skip= (block_list.LengthX() > 1 || block_list.LengthY() > 1);
213 for (
int j=block_list.FirstY() ; j<=block_list.LastY() ; ++j)
216 for (
int i=block_list.FirstX() ; i<=block_list.LastX() ; ++i)
220 if ( !block[i].Skipped() )
230 template<
typename EntropyCodec>
235 const int xbeg = code_block.
Xstart();
236 const int ybeg = code_block.
Ystart();
237 const int xend = code_block.
Xend();
238 const int yend = code_block.
Yend();
250 if (qf_idx > (
int)dirac_quantiser_lists.MaxQuantIndex())
252 std::ostringstream errstr;
253 errstr <<
"Quantiser index out of range [0.." 254 << (int)dirac_quantiser_lists.MaxQuantIndex() <<
"]";
261 m_qf = dirac_quantiser_lists.QuantFactor4( qf_idx );
264 m_offset = dirac_quantiser_lists.IntraQuantOffset4( qf_idx );
266 m_offset = dirac_quantiser_lists.InterQuantOffset4( qf_idx );
270 for (
int ypos=ybeg; ypos<yend ;++ypos)
275 p_out_data = out_data[
m_pypos];
278 c_out_data_1 = out_data[ypos-1];
279 CoeffType *c_out_data_2 = out_data[ypos];
280 for (
int xpos=xbeg; xpos<xend ;++xpos)
305 template<
typename EntropyCodec>
329 template<
typename EntropyCodec>
333 CoeffType& out_pixel = out_data[ypos][xpos];
353 out_pixel = -out_pixel;
357 template<
typename EntropyCodec>
364 switch ( bin_number )
386 switch ( bin_number )
412 template<
typename EntropyCodec>
418 template<
typename EntropyCodec>
428 if (data[ypos-1][xpos]>0)
430 else if (data[ypos-1][xpos]<0)
443 if ( data[ypos][xpos-1] > 0 )
445 else if ( data[ypos][xpos-1] < 0 )
455 template<
typename EntropyCodec>
475 template<
typename EntropyCodec>
478 for (
int j=code_block.
Ystart() ; j<code_block.
Yend() ; j++)
480 for (
int i=code_block.
Xstart() ; i<code_block.
Xend() ; i++)
482 pic_data[j][i] = val;
487 template<
typename EntropyCodec>
490 for (
int j=code_block.
Ystart() ; j<code_block.
Yend() ; j++)
499 template<
typename EntropyCodec>
504 for (
int ypos=code_block.
Ystart() ; ypos<code_block.
Yend() ; ++ypos)
506 for (
int xpos=code_block.
Xstart() ; xpos<code_block.
Xend() ; ++xpos)
508 out_data[ypos][xpos] += GetPrediction( out_data , xpos , ypos );
517 template<
typename EntropyCodec>
520 for (
int ypos=code_block.
Ystart() ; ypos<code_block.
Yend() ; ++ypos)
522 for (
int xpos=code_block.
Xstart() ; xpos<code_block.
Xend() ; ++xpos)
525 coeff_data[ypos][xpos] = GetPrediction( coeff_data , xpos , ypos );
530 template<
typename EntropyCodec>
541 int sum = data[ypos][xpos-1] + data[ypos-1][xpos-1] + data[ypos-1][xpos] + 3/2;
548 return data[ypos - 1][0];
553 return data[0][xpos - 1];
A template class for two-dimensional arrays.
Definition: arrays.h:284
int Xend() const
Returns one past the last coefficient coord, horizontally.
Definition: wavelet_utils.h:88
CoeffType m_offset
reconstruction point
Definition: band_codec.h:142
int CoeffType
Type of wavelet coefficient data (should be larger than ValueType)
Definition: common.h:74
bool m_parent_notzero
True if the parent of a coeff is not zero.
Definition: band_codec.h:154
void SetToVal(const CodeBlock &code_block, CoeffArray &coeff_data, const CoeffType val)
Set a code block area to a given value.
Definition: band_codec_template.h:476
Subband m_pnode
the parent subband
Definition: band_codec.h:148
int ChooseSignContext(const CoeffArray &data, const int xpos, const int ypos) const
A function for choosing the context for sign bits.
Definition: band_codec_template.h:419
A class for wavelet coefficient data.
Definition: wavelet_utils.h:622
int QuantIndex() const
Return a quantisation index.
Definition: wavelet_utils.h:199
int Ystart() const
Returns the vertical start of the block.
Definition: wavelet_utils.h:85
void SetSkip(bool skip)
Sets whether the code block is skipped or not.
Definition: wavelet_utils.h:109
int m_pxpos
position of the parent coefficient
Definition: band_codec.h:151
virtual void ClearBlock(const CodeBlock &code_block, CoeffArray &coeff_data)
Set all block values to 0.
Definition: band_codec_template.h:488
bool m_nhood_nonzero
True if neighbours non-zero.
Definition: band_codec.h:145
CoeffType GetPrediction(const CoeffArray &data, const int xpos, const int ypos) const
Prediction of a DC value from its previously coded neighbours.
Definition: band_codec_template.h:531
int ChooseInfoContext() const
A function for choosing the context for "information bits".
Definition: band_codec_template.h:413
A class encapulating all the subbands produced by a transform.
Definition: wavelet_utils.h:279
void CodeVal(CoeffArray &in_data, const int xpos, const int ypos, const CoeffType val)
Code an individual quantised value and perform inverse-quantisation.
Definition: band_codec_template.h:131
bool m_is_intra
Flag indicating whether the band comes from an intra picture.
Definition: band_codec.h:127
int Yp() const
Return the vertical position of the subband.
Definition: wavelet_utils.h:184
GenericBandCodec(SubbandByteIO *subband_byteio, size_t number_of_contexts, const SubbandList &band_list, int band_num, const bool is_intra)
Constructor.
Definition: band_codec_template.h:9
int Xp() const
Return the horizontal position of the subband.
Definition: wavelet_utils.h:178
void CodeQuantIndexOffset(const int offset)
Encode the offset for a code block quantiser.
Definition: band_codec_template.h:176
int Xstart() const
Returns the horizontal start of the block.
Definition: wavelet_utils.h:82
void ClearBlock(const CodeBlock &code_block, CoeffArray &coeff_data)
When coding a skipped block, propegate the predicted values for future non skipped blocks...
Definition: band_codec_template.h:518
bool UsingMultiQuants() const
Return a flag indicating whether we have separate quantisers for each code block. ...
Definition: wavelet_utils.h:202
virtual void DecodeCoeff(CoeffArray &in_data, const int xpos, const int ypos)
Definition: band_codec_template.h:306
virtual void CodeCoeff(CoeffArray &in_data, const int xpos, const int ypos)
Definition: band_codec_template.h:106
Class for encapsulating metadata concerning a block of coefficients in a subband. ...
Definition: wavelet_utils.h:59
void DecodeCoeffBlock(const CodeBlock &code_block, CoeffArray &out_data)
Decode codeblock of coefficients and perform DC prediction.
Definition: band_codec_template.h:500
Definition: dirac_exception.h:78
TwoDArray< CodeBlock > & GetCodeBlocks()
Return the code blocks.
Definition: wavelet_utils.h:214
void DecodeVal(CoeffArray &out_data, const int xpos, const int ypos)
Decode an individual quantised value and perform inverse-quantisation.
Definition: band_codec_template.h:330
virtual void CodeCoeffBlock(const CodeBlock &code_block, CoeffArray &in_data)
Definition: band_codec_template.h:53
int m_qf
quantisation value
Definition: band_codec.h:139
Definition: dirac_exception.h:59
int ChooseFollowContext(const int bin_number) const
A function for choosing the context for "follow bits".
Definition: band_codec_template.h:358
int m_last_qf_idx
the quantisation index of the last codeblock
Definition: band_codec.h:136
Subband Dirac-bytestream input/output.
Definition: subband_byteio.h:56
const Subband m_node
the subband being coded
Definition: band_codec.h:133
Definition of class SequenceHeaderByteIO.
Definition: accessunit_byteio.h:51
int DecodeQuantIndexOffset()
Decode the offset for a code block quantiser.
Definition: band_codec_template.h:456
int Yend() const
Returns one past the last coefficient coord, vertically.
Definition: wavelet_utils.h:91
int m_pypos
Definition: band_codec.h:151
#define DIRAC_THROW_EXCEPTION(arg1, arg2, arg3)
Construct an exception from 3 arguments, log it, and throw it.
Definition: dirac_exception.h:196
virtual void DoWorkCode(CoeffArray &in_data)
Definition: band_codec_template.h:27
virtual void DoWorkDecode(CoeffArray &out_data)
Definition: band_codec_template.h:205
int Parent() const
Return the index of the parent subband.
Definition: wavelet_utils.h:205
int QuantIndex() const
Returns the quantisation index associated to the code block.
Definition: wavelet_utils.h:100
virtual void DecodeCoeffBlock(const CodeBlock &code_block, CoeffArray &out_data)
Definition: band_codec_template.h:231