Dirac - A Video Codec

Created by the British Broadcasting Corporation.


mv_codec.h
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2 *
3 * $Id: mv_codec.h,v 1.25 2008/10/01 01:26:47 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 * Tim Borer,
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 _MV_CODEC_H_
42 #define _MV_CODEC_H_
43 
45 //Class to do motion vector coding and decoding//
46 //------using adaptive arithmetic coding-------//
48 
50 #include <libdirac_common/common.h>
51 #include <libdirac_common/motion.h>
53 #include <vector>
54 
55 namespace dirac
56 {
58 
61  class SplitModeCodec: public ArithCodec<MvData>
62  {
63  public:
65 
70  SplitModeCodec(ByteIO* p_byteio, size_t number_of_contexts);
71 
72 
73 
75  void InitContexts();
76 
77  private:
78 
79  // Position of current SB
81 
82  private:
83 
84  // functions
86  SplitModeCodec(const SplitModeCodec& cpy);
89 
90  // coding functions
91  // Code the SB splitting mode
92  void CodeVal(const MvData& in_data);
93 
94  // decoding functions
95  // Decode the SB splitting mode
96  void DecodeVal( MvData& out_data);
97 
98  void DoWorkCode( MvData& in_data );
99  void DoWorkDecode(MvData& out_data);
100 
101  // Context stuff
102  void ResetAll();
103 
104  //prediction stuff
105  unsigned int Prediction(const TwoDArray<int>& mbdata) const;
106 
107  };
108 
109 /******************************************************************************/
110 
112 
115  class PredModeCodec: public ArithCodec<MvData>
116  {
117  public:
119 
125  PredModeCodec(ByteIO* p_byteio, size_t number_of_contexts, const int num_refs);
126 
128  void InitContexts();
129 
130  private:
131 
132  // Position of current block
134  // Position of current SB
136  // Position of top-left block of current SB
138  // Number of reference pictures
140 
141  private:
142 
143  // functions
145  PredModeCodec(const PredModeCodec& cpy);
148 
149  // coding functions
150  // Code the block prediction mode
151  void CodeVal(const MvData& in_data);
152 
153  // decoding functions
154  // Decode the block prediction mode
155  void DecodeVal(MvData& out_data);
156 
157  void DoWorkCode( MvData& in_data );
158  void DoWorkDecode(MvData& out_data);
159 
160  // Context stuff
161  void ResetAll();
162 
163  //prediction stuff
164  unsigned int Prediction(const TwoDArray<PredMode>& preddata) const;
165 
166  };
167 
168 /******************************************************************************/
169 
171 
175  class VectorElementCodec: public ArithCodec<MvData>
176  {
177  public:
179 
186  VectorElementCodec(ByteIO* p_byteio, int ref_id, MvElement horvert,
187  size_t number_of_contexts);
188 
189 
191  void InitContexts();
192 
193  private:
194 
195  // Position of current block
197 
198  // Position of current SB
200 
201  // Position of top-left block of current SB
203 
204  // The identity of the reference (1 or 2)
205  const int m_ref;
206 
207  // Whether it's the vertical or horizontal MV element
209 
210  private:
211 
212  // functions
217 
218  // coding functions
219  // Code the motion vector element
220  void CodeVal(const MvData& in_data);
221 
222  // decoding functions
223  // Decode the motion vector element
224  void DecodeVal( MvData& out_data);
225 
226  void DoWorkCode( MvData& in_data );
227  void DoWorkDecode(MvData& out_data);
228 
229  // Context stuff
230  void ResetAll();
231 
232  //prediction stuff
233  int Prediction( const MvArray& mvarray,
234  const TwoDArray<PredMode>& preddata) const;
235 
236  };
237 
238 /******************************************************************************/
240 
244  class DCCodec: public ArithCodec<MvData>
245  {
246  public:
248 
254  DCCodec(ByteIO* p_byteio, const CompSort csort, size_t number_of_contexts);
255 
257  void InitContexts();
258 
259  private:
260 
261  // The component being coded
263  // Position of current block
265  // Position of current SB
267  // Position of top-left block of current SB
269 
270  private:
271 
272  // functions
274  DCCodec(const DCCodec& cpy);
276  DCCodec& operator=(const DCCodec& rhs);
277 
278  // coding functions
279  // Code the dc value of intra blocks
280  void CodeVal(const MvData& in_data);
281 
282  // decoding functions
283  // Decode the dc value of intra blocks
284  void DecodeVal( MvData& out_data);
285 
286  void DoWorkCode( MvData& in_data );
287  void DoWorkDecode(MvData& out_data);
288 
289  // Context stuff
290  void ResetAll();
291 
292  //prediction stuff
294  const TwoDArray<PredMode>& preddata) const;
295  };
296 
297 
298 }// end namepace dirac
299 
300 
301 #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.