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

© 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.