# 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
49#include <libdirac_common/arith_codec.h>
50#include <libdirac_common/common.h>
51#include <libdirac_common/motion.h>
52#include <libdirac_common/wavelet_utils.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
80 int m_sb_xp, m_sb_yp;
81
82 private:
83
84 // functions
86 SplitModeCodec(const SplitModeCodec& cpy);
88 SplitModeCodec& operator=(const SplitModeCodec& rhs);
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
133 int m_b_xp, m_b_yp;
134 // Position of current SB
135 int m_sb_xp, m_sb_yp;
136 // Position of top-left block of current SB
137 int m_sb_tlb_x, m_sb_tlb_y;
138 // Number of reference pictures
139 int m_num_refs;
140
141 private:
142
143 // functions
145 PredModeCodec(const PredModeCodec& cpy);
147 PredModeCodec& operator=(const PredModeCodec& rhs);
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
196 int m_b_xp, m_b_yp;
197
198 // Position of current SB
199 int m_sb_xp, m_sb_yp;
200
201 // Position of top-left block of current SB
202 int m_sb_tlb_x, m_sb_tlb_y;
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
208 const MvElement m_hv;
209
210 private:
211
212 // functions
214 VectorElementCodec(const VectorElementCodec& cpy);
216 VectorElementCodec& operator=(const VectorElementCodec& rhs);
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
262 const CompSort m_csort;
263 // Position of current block
264 int m_b_xp, m_b_yp;
265 // Position of current SB
266 int m_sb_xp, m_sb_yp;
267 // Position of top-left block of current SB
268 int m_sb_tlb_x, m_sb_tlb_y;
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
293 ValueType Prediction( const TwoDArray<ValueType>& dcdata,
294 const TwoDArray<PredMode>& preddata) const;
295 };
296
297
298}// end namepace dirac
299
300
301#endif
wavelet_utils.h
common.h
arith_codec.h
motion.h
dirac
Definition of class SequenceHeaderByteIO.
Definition: accessunit_byteio.h:52
dirac::CompSort
CompSort
Types of picture component.
Definition: common.h:87
dirac::ValueType
short ValueType
Type of picture data (including motion compensated residuals)
Definition: common.h:70
dirac::MvElement
MvElement
Horizontal or vertical.
Definition: motion.h:54
dirac::ByteIO
Class ByteIO - top-level class for reading/writing bytes to a stream.
Definition: byteio.h:73
dirac::ArithCodec
Abstract binary arithmetic coding class.
Definition: arith_codec.h:376
dirac::TwoDArray< int >
dirac::MvData
Class for all the motion vector data.
Definition: motion.h:220
dirac::SplitModeCodec
Codes and decodes the split mode.
Definition: mv_codec.h:62
dirac::SplitModeCodec::SplitModeCodec
SplitModeCodec(ByteIO *p_byteio, size_t number_of_contexts)
Constructor.
dirac::SplitModeCodec::DoWorkDecode
void DoWorkDecode(MvData &out_data)
virtual decode-only functions
dirac::SplitModeCodec::operator=
SplitModeCodec & operator=(const SplitModeCodec &rhs)
Private, bodyless copy operator=: class should not be assigned.
dirac::SplitModeCodec::Prediction
unsigned int Prediction(const TwoDArray< int > &mbdata) const
dirac::SplitModeCodec::DecodeVal
void DecodeVal(MvData &out_data)
dirac::SplitModeCodec::CodeVal
void CodeVal(const MvData &in_data)
dirac::SplitModeCodec::ResetAll
void ResetAll()
dirac::SplitModeCodec::DoWorkCode
void DoWorkCode(MvData &in_data)
Does the work of actually coding the data.
dirac::SplitModeCodec::InitContexts
void InitContexts()
Initialises the contexts
dirac::SplitModeCodec::SplitModeCodec
SplitModeCodec(const SplitModeCodec &cpy)
Private, bodyless copy constructor: class should not be copied.
dirac::SplitModeCodec::m_sb_yp
int m_sb_yp
Definition: mv_codec.h:80
dirac::SplitModeCodec::m_sb_xp
int m_sb_xp
Definition: mv_codec.h:80
dirac::PredModeCodec
Codes and decodes the prediction modes.
Definition: mv_codec.h:116
dirac::PredModeCodec::Prediction
unsigned int Prediction(const TwoDArray< PredMode > &preddata) const
dirac::PredModeCodec::InitContexts
void InitContexts()
Initialises the contexts.
dirac::PredModeCodec::CodeVal
void CodeVal(const MvData &in_data)
dirac::PredModeCodec::DoWorkCode
void DoWorkCode(MvData &in_data)
Does the work of actually coding the data.
dirac::PredModeCodec::DecodeVal
void DecodeVal(MvData &out_data)
dirac::PredModeCodec::PredModeCodec
PredModeCodec(const PredModeCodec &cpy)
Private, bodyless copy constructor: class should not be copied.
dirac::PredModeCodec::PredModeCodec
PredModeCodec(ByteIO *p_byteio, size_t number_of_contexts, const int num_refs)
Constructor.
dirac::PredModeCodec::ResetAll
void ResetAll()
dirac::PredModeCodec::operator=
PredModeCodec & operator=(const PredModeCodec &rhs)
Private, bodyless copy operator=: class should not be assigned.
dirac::PredModeCodec::m_b_yp
int m_b_yp
Definition: mv_codec.h:133
dirac::PredModeCodec::m_sb_tlb_y
int m_sb_tlb_y
Definition: mv_codec.h:137
dirac::PredModeCodec::DoWorkDecode
void DoWorkDecode(MvData &out_data)
virtual decode-only functions
dirac::PredModeCodec::m_num_refs
int m_num_refs
Definition: mv_codec.h:139
dirac::PredModeCodec::m_sb_yp
int m_sb_yp
Definition: mv_codec.h:135
dirac::PredModeCodec::m_sb_tlb_x
int m_sb_tlb_x
Definition: mv_codec.h:137
dirac::PredModeCodec::m_sb_xp
int m_sb_xp
Definition: mv_codec.h:135
dirac::PredModeCodec::m_b_xp
int m_b_xp
Definition: mv_codec.h:133
dirac::VectorElementCodec
Codes and decodes an array of motion vectors.
Definition: mv_codec.h:176
dirac::VectorElementCodec::InitContexts
void InitContexts()
Initialises the contexts
dirac::VectorElementCodec::m_sb_yp
int m_sb_yp
Definition: mv_codec.h:199
dirac::VectorElementCodec::operator=
VectorElementCodec & operator=(const VectorElementCodec &rhs)
Private, bodyless copy operator=: class should not be assigned.
dirac::VectorElementCodec::m_ref
const int m_ref
Definition: mv_codec.h:205
dirac::VectorElementCodec::VectorElementCodec
VectorElementCodec(ByteIO *p_byteio, int ref_id, MvElement horvert, size_t number_of_contexts)
Constructor.
dirac::VectorElementCodec::VectorElementCodec
VectorElementCodec(const VectorElementCodec &cpy)
Private, bodyless copy constructor: class should not be copied.
dirac::VectorElementCodec::m_sb_xp
int m_sb_xp
Definition: mv_codec.h:199
dirac::VectorElementCodec::m_sb_tlb_y
int m_sb_tlb_y
Definition: mv_codec.h:202
dirac::VectorElementCodec::m_b_yp
int m_b_yp
Definition: mv_codec.h:196
dirac::VectorElementCodec::m_hv
const MvElement m_hv
Definition: mv_codec.h:208
dirac::VectorElementCodec::ResetAll
void ResetAll()
dirac::VectorElementCodec::Prediction
int Prediction(const MvArray &mvarray, const TwoDArray< PredMode > &preddata) const
dirac::VectorElementCodec::m_b_xp
int m_b_xp
Definition: mv_codec.h:196
dirac::VectorElementCodec::DecodeVal
void DecodeVal(MvData &out_data)
dirac::VectorElementCodec::CodeVal
void CodeVal(const MvData &in_data)
dirac::VectorElementCodec::DoWorkDecode
void DoWorkDecode(MvData &out_data)
virtual decode-only functions
dirac::VectorElementCodec::DoWorkCode
void DoWorkCode(MvData &in_data)
Does the work of actually coding the data.
dirac::VectorElementCodec::m_sb_tlb_x
int m_sb_tlb_x
Definition: mv_codec.h:202
dirac::DCCodec
Codes and decodes a set of DC values.
Definition: mv_codec.h:245
dirac::DCCodec::m_sb_xp
int m_sb_xp
Definition: mv_codec.h:266
dirac::DCCodec::InitContexts
void InitContexts()
Initialises the contexts
dirac::DCCodec::DCCodec
DCCodec(const DCCodec &cpy)
Private, bodyless copy constructor: class should not be copied.
dirac::DCCodec::operator=
DCCodec & operator=(const DCCodec &rhs)
Private, bodyless copy operator=: class should not be assigned.
dirac::DCCodec::DecodeVal
void DecodeVal(MvData &out_data)
dirac::DCCodec::m_csort
const CompSort m_csort
Definition: mv_codec.h:262
dirac::DCCodec::DoWorkDecode
void DoWorkDecode(MvData &out_data)
virtual decode-only functions
dirac::DCCodec::ResetAll
void ResetAll()
dirac::DCCodec::m_sb_tlb_x
int m_sb_tlb_x
Definition: mv_codec.h:268
dirac::DCCodec::m_sb_yp
int m_sb_yp
Definition: mv_codec.h:266
dirac::DCCodec::m_b_yp
int m_b_yp
Definition: mv_codec.h:264
dirac::DCCodec::DoWorkCode
void DoWorkCode(MvData &in_data)
Does the work of actually coding the data.
dirac::DCCodec::DCCodec
DCCodec(ByteIO *p_byteio, const CompSort csort, size_t number_of_contexts)
Constructor.
dirac::DCCodec::Prediction
ValueType Prediction(const TwoDArray< ValueType > &dcdata, const TwoDArray< PredMode > &preddata) const
dirac::DCCodec::CodeVal
void CodeVal(const MvData &in_data)
dirac::DCCodec::m_b_xp
int m_b_xp
Definition: mv_codec.h:264
dirac::DCCodec::m_sb_tlb_y
int m_sb_tlb_y
Definition: mv_codec.h:268

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