Dirac - A Video Codec

Created by the British Broadcasting Corporation.


band_codec.h
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2 *
3 * $Id: band_codec.h,v 1.36 2009/01/21 05:18:09 asuraparaju Exp $ $Name: Dirac_1_0_2 $
4 *
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 *
7 * The contents of this file are subject to the Mozilla Public License
8 * Version 1.1 (the "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14 * the specific language governing rights and limitations under the License.
15 *
16 * The Original Code is BBC Research and Development code.
17 *
18 * The Initial Developer of the Original Code is the British Broadcasting
19 * Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2004.
21 * All Rights Reserved.
22 *
23 * Contributor(s): Thomas Davies (Original Author),
24 * Scott R Ladd,
25 * Steve Bearcroft
26 * Andrew Kennedy
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
30 * Public License Version 2.1 (the "LGPL"), in which case the provisions of
31 * the GPL or the LGPL are applicable instead of those above. If you wish to
32 * allow use of your version of this file only under the terms of the either
33 * the GPL or LGPL and not to allow others to use your version of this file
34 * under the MPL, indicate your decision by deleting the provisions above
35 * and replace them with the notice and other provisions required by the GPL
36 * or LGPL. If you do not delete the provisions above, a recipient may use
37 * your version of this file under the terms of any one of the MPL, the GPL
38 * or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
40 
41 #ifndef _BAND_CODEC_H_
42 #define _BAND_CODEC_H_
43 
46 
47 
48 namespace dirac
49 {
50 
51  class SubbandByteIO;
52 
53  //Subclasses the arithmetic codec to produce a coding/decoding tool for subbands
54 
55 
57  template<typename EntropyCodec>
58  class GenericBandCodec: public EntropyCodec
59  {
60  public:
61 
63 
71  GenericBandCodec(SubbandByteIO* subband_byteio,
72  size_t number_of_contexts,
73  const SubbandList& band_list,
74  int band_num,
75  const bool is_intra);
76 
77  protected:
79  inline void CodeVal( CoeffArray& in_data , const int xpos , const int ypos , const CoeffType val);
80 
82  inline void DecodeVal(CoeffArray& out_data , const int xpos , const int ypos );
83 
85  void CodeQuantIndexOffset( const int offset );
86 
89 
91  inline void SetToVal( const CodeBlock& code_block , CoeffArray& coeff_data , const CoeffType val);
92 
94  virtual void ClearBlock( const CodeBlock& code_block , CoeffArray& coeff_data);
95 
96  protected:
97  //functions
98  // Overridden from the base class
99  virtual void DoWorkCode(CoeffArray& in_data);
100  // Ditto
101  virtual void DoWorkDecode(CoeffArray& out_data);
102 
103  virtual void CodeCoeffBlock(const CodeBlock& code_block , CoeffArray& in_data);
104  virtual void DecodeCoeffBlock(const CodeBlock& code_block , CoeffArray& out_data);
105 
106  virtual void CodeCoeff(CoeffArray& in_data, const int xpos, const int ypos);
107 
108  virtual void DecodeCoeff(CoeffArray& in_data, const int xpos, const int ypos);
110  inline int ChooseFollowContext( const int bin_number ) const;
111 
113  inline int ChooseInfoContext() const;
114 
116  inline int ChooseSignContext(const CoeffArray& data , const int xpos , const int ypos ) const;
117 
118  private:
123 
124  protected:
125 
128 
130  int m_bnum;
131 
134 
137 
139  int m_qf;
140 
143 
146 
149 
152 
155 
156  };
157 
159 
164 
166  //Finally,special class incorporating prediction for the DC band of intra frames//
168 
170  template<typename EntropyCodec>
171  class GenericIntraDCBandCodec : public GenericBandCodec<EntropyCodec>
172  {
173  public:
175 
182  size_t number_of_contexts,
183  const SubbandList& band_list)
184  : GenericBandCodec<EntropyCodec>(subband_byteio,number_of_contexts,
185  band_list, band_list.Length(),
186  true){}
187 
188  protected:
190  void ClearBlock( const CodeBlock& code_block , CoeffArray& coeff_data);
191 
193  CoeffType GetPrediction(const CoeffArray& data , const int xpos , const int ypos ) const;
194 
196  void DecodeCoeffBlock(const CodeBlock& code_block , CoeffArray& out_data);
197  };
198 
199 
201 
206  class IntraDCBandCodec: public GenericIntraDCBandCodec<ArithCodec<CoeffArray> >
207  {
208  public:
210 
217  size_t number_of_contexts,
218  const SubbandList& band_list)
219  : GenericIntraDCBandCodec<ArithCodec<CoeffArray> >(subband_byteio,
220  number_of_contexts,
221  band_list){}
222 
223 
224  private:
226  void DoWorkCode(CoeffArray& in_data); //overridden from the base class
227 
229  void DoWorkDecode(CoeffArray& out_data);
230 
232  void CodeCoeff(CoeffArray& in_data, const int xpos, const int ypos);
233 
235  void DecodeCoeff(CoeffArray& out_data, const int xpos, const int ypos);
236 
239 
242 
243  private:
245  };
246 
247 }// end namespace dirac
248 #endif
IntraDCBandCodec(SubbandByteIO *subband_byteio, size_t number_of_contexts, const SubbandList &band_list)
Constructor.
Definition: band_codec.h:216
Class encapsulating all the metadata relating to a wavelet subband.
Definition: wavelet_utils.h:139
BandCodec LFBandCodec
Definition: band_codec.h:163
GenericBandCodec< ArithCodec< CoeffArray > > BandCodec
A general class for coding and decoding wavelet subband data.
Definition: band_codec.h:162
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
Abstract binary arithmetic coding class.
Definition: arith_codec.h:374
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
void CodeCoeff(CoeffArray &in_data, const int xpos, const int ypos)
Encode a single coefficient using error-feedback DC quantization.
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 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
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 m_bnum
variables
Definition: band_codec.h:130
void CodeQuantIndexOffset(const int offset)
Encode the offset for a code block quantiser.
Definition: band_codec_template.h:176
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
GenericBandCodec & operator=(const GenericBandCodec &rhs)
Private, bodyless copy operator=: class should not be assigned.
virtual void DecodeCoeff(CoeffArray &in_data, const int xpos, const int ypos)
Definition: band_codec_template.h:306
CoeffArray m_dc_pred_res
Definition: band_codec.h:244
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 DoWorkCode(CoeffArray &in_data)
Initialize extra data required for error-feedback DC quantization.
void DecodeCoeffBlock(const CodeBlock &code_block, CoeffArray &out_data)
Decode codeblock of coefficients and perform DC prediction.
Definition: band_codec_template.h:500
void DoWorkDecode(CoeffArray &out_data)
Ditto.
A class specially for coding the DC subband of Intra frames.
Definition: band_codec.h:206
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
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
A template class specially for coding the DC subband of Intra frames.
Definition: band_codec.h:171
void DecodeCoeff(CoeffArray &out_data, const int xpos, const int ypos)
Decode a single coefficient using error-feedback DC quantization.
int DecodeQuantIndexOffset()
Decode the offset for a code block quantiser.
Definition: band_codec_template.h:456
int m_pypos
Definition: band_codec.h:151
IntraDCBandCodec & operator=(const IntraDCBandCodec &rhs)
Private, bodyless copy operator=: class should not be assigned.
GenericIntraDCBandCodec(SubbandByteIO *subband_byteio, size_t number_of_contexts, const SubbandList &band_list)
Constructor.
Definition: band_codec.h:181
virtual void DoWorkCode(CoeffArray &in_data)
Definition: band_codec_template.h:27
A template class for coding and decoding wavelet subband data.
Definition: band_codec.h:58
virtual void DoWorkDecode(CoeffArray &out_data)
Definition: band_codec_template.h:205
virtual void DecodeCoeffBlock(const CodeBlock &code_block, CoeffArray &out_data)
Definition: band_codec_template.h:231

© 2004 British Broadcasting Corporation. Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.