Dirac - A Video Codec

Created by the British Broadcasting Corporation.


me_utils.h
Go to the documentation of this file.
1/* ***** BEGIN LICENSE BLOCK *****
2*
3* $Id: me_utils.h,v 1.14 2008/08/14 00:58:24 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*
25* Alternatively, the contents of this file may be used under the terms of
26* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
27* Public License Version 2.1 (the "LGPL"), in which case the provisions of
28* the GPL or the LGPL are applicable instead of those above. If you wish to
29* allow use of your version of this file only under the terms of the either
30* the GPL or LGPL and not to allow others to use your version of this file
31* under the MPL, indicate your decision by deleting the provisions above
32* and replace them with the notice and other provisions required by the GPL
33* or LGPL. If you do not delete the provisions above, a recipient may use
34* your version of this file under the terms of any one of the MPL, the GPL
35* or the LGPL.
36* ***** END LICENSE BLOCK ***** */
37
38#ifndef _ME_UTILS_H_
39#define _ME_UTILS_H_
40
41#include <algorithm>
44namespace dirac
45{
46
48 //Utilities for motion estimation//
49 //-------------------------------//
51
54 {
55
56 public:
59
61 BlockDiffParams( const int x_p , const int y_p , const int x_l , const int y_l):
62 m_xp(x_p),
63 m_yp(y_p),
64 m_xl(x_l),
65 m_yl(y_l),
66 m_xend(x_l+x_p),
67 m_yend(y_l+y_p)
68 {}
69
71 //NB: Assume default copy constructor, assignment = and destructor//
73
74 // Sets ...
75
76
78
79 void SetBlockLimits( const OLBParams& bparams ,
80 const PicArray& pic_data ,
81 const int xbpos , const int ybpos);
82
83 // ... and gets
84
86 int Xp() const {return m_xp;}
87
89 int Yp() const {return m_yp;}
90
92 int Xl() const {return m_xl;}
93
95 int Yl() const {return m_yl;}
96
98 int Xend() const {return m_xend;}
99
101 int Yend() const {return m_yend;}
102
103 private:
104
105 int m_xp;
106 int m_yp;
107 int m_xl;
108 int m_yl;
111 };
112
114 //----Different difference classes, so that-----//
115 //bounds-checking need only be done as necessary//
117
120 {
121 public:
123 /*
124 Constructor, initialising the reference and picture data
125 \param ref the reference picture
126 \param pic the picture being matched
127 */
128 BlockDiff( const PicArray& ref , const PicArray& pic );
129
131 virtual ~BlockDiff(){}
132
134
139 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv )=0;
140
141 protected:
142
145
146 private:
148 BlockDiff( const BlockDiff& cpy );
149
152 };
153
156 {
157 public:
159 /*
160 Constructor, initialising the reference and picture data
161 \param ref the reference picture
162 \param pic the picture being matched
163 */
164 PelBlockDiff( const PicArray& ref , const PicArray& pic );
165
167
172 float Diff( const BlockDiffParams& dparams , const MVector& mv );
173
175
183 void Diff( const BlockDiffParams& dparams ,
184 const MVector& mv ,
185 float& best_sum ,
186 MVector& best_mv );
187
188 private:
191
194 };
195
196
199 {
200 public:
202 /*
203 Constructor, initialising the picture data
204 \param pic the picture being matched
205 */
207
209
214 float Diff( const BlockDiffParams& dparams , ValueType& dc_val );
215
218
219 private:
222
225
227 };
228
231 {
232 public:
234 /*
235 Constructor, initialising the references and picture data
236 \param ref1 the first reference picture
237 \param ref2 the second reference picture
238 \param pic the picture being matched
239 */
240 BiBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic);
241
243 virtual ~BiBlockDiff( ) {}
244
246
252 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 )=0;
253
254 protected:
258
259 private:
262
265 };
266
267 // Classes where the reference is upconverted //
270 class BlockDiffUp: public BlockDiff
271 {
272
273 public:
274
276 /*
277 Constructor, initialising the reference and picture data
278 \param ref the reference picture
279 \param pic the picture being matched
280 */
281 BlockDiffUp( const PicArray& ref , const PicArray& pic );
282
284 virtual ~BlockDiffUp(){}
285
287
292 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv )=0;
293
295
305 virtual void Diff( const BlockDiffParams& dparams,
306 const MVector& mv ,
307 const float mvcost,
308 const float lambda,
309 MvCostData& best_costs ,
310 MVector& best_mv)=0;
311 private:
314
317 };
318
321 {
322
323 public:
325 /*
326 Constructor, initialising the reference and picture data
327 \param ref the reference picture
328 \param pic the picture being matched
329 */
330 BlockDiffHalfPel( const PicArray& ref , const PicArray& pic );
331
334
336
341 float Diff( const BlockDiffParams& dparams , const MVector& mv );
342
344
354 void Diff( const BlockDiffParams& dparams,
355 const MVector& mv ,
356 const float mvcost,
357 const float lambda,
358 MvCostData& best_costs ,
359 MVector& best_mv);
360
361 private:
364
367
368 };
369
372 {
373 public:
375 /*
376 Constructor, initialising the reference and picture data
377 \param ref the reference picture
378 \param pic the picture being matched
379 */
380 BlockDiffQuarterPel( const PicArray& ref , const PicArray& pic );
381
384
386
391 float Diff( const BlockDiffParams& dparams , const MVector& mv );
392
394
404 void Diff( const BlockDiffParams& dparams,
405 const MVector& mv ,
406 const float mvcost,
407 const float lambda,
408 MvCostData& best_costs ,
409 MVector& best_mv);
410
411 private:
414
417 };
418
421 {
422 public:
424 /*
425 Constructor, initialising the reference and picture data
426 \param ref the reference picture
427 \param pic the picture being matched
428 */
429 BlockDiffEighthPel( const PicArray& ref , const PicArray& pic );
430
433
435
440 float Diff( const BlockDiffParams& dparams , const MVector& mv );
441
443
453 void Diff( const BlockDiffParams& dparams,
454 const MVector& mv ,
455 const float mvcost,
456 const float lambda,
457 MvCostData& best_costs ,
458 MVector& best_mv);
459
460 private:
463
466 };
467
470 {
471 public:
473 /*
474 Constructor, initialising the reference and picture data
475 \param ref1 the first reference picture
476 \param ref2 the second reference picture
477 \param pic the picture being matched
478 */
479 BiBlockHalfPel( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
480
482
488 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
489 private:
492
495 };
496
499 {
500 public:
502 /*
503 Constructor, initialising the reference and picture data
504 \param ref1 the first reference picture
505 \param ref2 the second reference picture
506 \param pic the picture being matched
507 */
508 BiBlockQuarterPel( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
509
511
517 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
518
519 private:
522
525 };
526
529 {
530 public:
532 /*
533 Constructor, initialising the reference and picture data
534 \param ref1 the first reference picture
535 \param ref2 the second reference picture
536 \param pic the picture being matched
537 */
538 BiBlockEighthPel( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
539
541
547 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
548 private:
551
554 };
555
556} // namespace dirac
557#endif
Definition of class SequenceHeaderByteIO.
Definition accessunit_byteio.h:52
short ValueType
Type of picture data (including motion compensated residuals)
Definition common.h:70
MotionVector< int > MVector
MVector class is a vector of ints.
Definition motion.h:180
A class for picture component data.
Definition common.h:719
Parameters for overlapped block motion compensation.
Definition common.h:818
Class for recording costs derived in motion estimation.
Definition motion.h:193
A class encapsulating parameters for calculating a block difference value (a single instance of match...
Definition me_utils.h:54
int Yp() const
Return the y-position of the top-left block corner.
Definition me_utils.h:89
BlockDiffParams(const int x_p, const int y_p, const int x_l, const int y_l)
Constructor.
Definition me_utils.h:61
int Yend() const
Return the block vertical endpoint.
Definition me_utils.h:101
int m_yend
Definition me_utils.h:110
int m_yp
Definition me_utils.h:106
int Xp() const
Return the x-position of the top-left block corner.
Definition me_utils.h:86
int m_xp
Definition me_utils.h:105
int Xend() const
Return the block horizontal endpoint.
Definition me_utils.h:98
BlockDiffParams()
Constructor.
Definition me_utils.h:58
int Xl() const
Return the block width.
Definition me_utils.h:92
void SetBlockLimits(const OLBParams &bparams, const PicArray &pic_data, const int xbpos, const int ybpos)
Set the limits of the block to fit in a picture.
int m_xl
Definition me_utils.h:107
int Yl() const
Return the block height.
Definition me_utils.h:95
int m_yl
Definition me_utils.h:108
int m_xend
Definition me_utils.h:109
virtual float Diff(const BlockDiffParams &dparams, const MVector &mv)=0
Do the difference, returning SAD.
virtual ~BlockDiff()
Destructor.
Definition me_utils.h:131
const PicArray & m_pic_data
Definition me_utils.h:143
BlockDiff(const PicArray &ref, const PicArray &pic)
Constructor, initialising the reference and picture data.
BlockDiff(const BlockDiff &cpy)
Private, bodyless copy-constructor: class should not be copied.
BlockDiff & operator=(const BlockDiff &rhs)
Private, bodyless assignment=: class should not be assigned.
const PicArray & m_ref_data
Definition me_utils.h:144
PelBlockDiff(const PicArray &ref, const PicArray &pic)
Constructor, initialising the reference and picture data.
PelBlockDiff(const PelBlockDiff &cpy)
Private, bodyless copy-constructor: class should not be copied.
float Diff(const BlockDiffParams &dparams, const MVector &mv)
Do the difference, returning SAD.
PelBlockDiff & operator=(const PelBlockDiff &rhs)
Private, bodyless assignment=: class should not be assigned.
void Diff(const BlockDiffParams &dparams, const MVector &mv, float &best_sum, MVector &best_mv)
Do the difference, overwriting the best MV so far if appropriate.
const PicArray & m_pic_data
Definition me_utils.h:226
IntraBlockDiff & operator=(const IntraBlockDiff &rhs)
Private, bodyless assignment=: class should not be assigned.
IntraBlockDiff(const IntraBlockDiff &cpy)
Private, bodyless copy-constructor: class should not be copied.
float Diff(const BlockDiffParams &dparams, ValueType &dc_val)
Do the difference, calculating the DC value and returning SAD.
ValueType CalcDC(const BlockDiffParams &dparams)
Calculate a DC value.
IntraBlockDiff(const PicArray &pic)
Constructor, initialising the picture data.
BiBlockDiff & operator=(const BiBlockDiff &rhs)
Private, bodyless assignment=: class should not be assigned.
const PicArray & m_pic_data
Definition me_utils.h:255
virtual float Diff(const BlockDiffParams &dparams, const MVector &mv1, const MVector &mv2)=0
Do the difference, returning SAD.
const PicArray & m_ref_data1
Definition me_utils.h:256
const PicArray & m_ref_data2
Definition me_utils.h:257
virtual ~BiBlockDiff()
Virtual destructor.
Definition me_utils.h:243
BiBlockDiff(const PicArray &ref1, const PicArray &ref2, const PicArray &pic)
Constructor, initialising the references and picture data.
BiBlockDiff(const BiBlockDiff &cpy)
Private, bodyless copy-constructor: class should not be copied.
virtual ~BlockDiffUp()
Destructor.
Definition me_utils.h:284
BlockDiffUp(const PicArray &ref, const PicArray &pic)
Constructor, initialising the reference and picture data.
virtual void Diff(const BlockDiffParams &dparams, const MVector &mv, const float mvcost, const float lambda, MvCostData &best_costs, MVector &best_mv)=0
Do the actual difference, overwriting the best MV so far if appropriate.
BlockDiffUp & operator=(const BlockDiffUp &rhs)
Private, bodyless assignment=: class should not be assigned.
virtual float Diff(const BlockDiffParams &dparams, const MVector &mv)=0
Do the difference, returning SAD.
BlockDiffUp(const BlockDiffUp &cpy)
Private, bodyless copy-constructor: class should not be copied.
BlockDiffHalfPel & operator=(const BlockDiffHalfPel &rhs)
Private, bodyless assignment=: class should not be assigned.
BlockDiffHalfPel(const BlockDiffHalfPel &cpy)
Private, bodyless copy-constructor: class should not be copied.
void Diff(const BlockDiffParams &dparams, const MVector &mv, const float mvcost, const float lambda, MvCostData &best_costs, MVector &best_mv)
Do the actual difference, overwriting the best MV so far if appropriate.
~BlockDiffHalfPel()
Destructor.
Definition me_utils.h:333
BlockDiffHalfPel(const PicArray &ref, const PicArray &pic)
Constructor, initialising the reference and picture data.
float Diff(const BlockDiffParams &dparams, const MVector &mv)
Do the difference, returning SAD.
float Diff(const BlockDiffParams &dparams, const MVector &mv)
Do the difference, returning SAD.
BlockDiffQuarterPel & operator=(const BlockDiffQuarterPel &rhs)
Private, bodyless assignment=: class should not be assigned.
~BlockDiffQuarterPel()
Destructor.
Definition me_utils.h:383
BlockDiffQuarterPel(const PicArray &ref, const PicArray &pic)
Constructor, initialising the reference and picture data.
void Diff(const BlockDiffParams &dparams, const MVector &mv, const float mvcost, const float lambda, MvCostData &best_costs, MVector &best_mv)
Do the actual difference, overwriting the best MV so far if appropriate.
BlockDiffQuarterPel(const BlockDiffQuarterPel &cpy)
Private, bodyless copy-constructor: class should not be copied.
float Diff(const BlockDiffParams &dparams, const MVector &mv)
Do the difference, returning SAD.
void Diff(const BlockDiffParams &dparams, const MVector &mv, const float mvcost, const float lambda, MvCostData &best_costs, MVector &best_mv)
Do the actual difference, overwriting the best MV so far if appropriate.
BlockDiffEighthPel(const PicArray &ref, const PicArray &pic)
Constructor, initialising the reference and picture data.
BlockDiffEighthPel(const BlockDiffEighthPel &cpy)
Private, bodyless copy-constructor: class should not be copied.
~BlockDiffEighthPel()
Destructor.
Definition me_utils.h:432
BlockDiffEighthPel & operator=(const BlockDiffEighthPel &rhs)
Private, bodyless assignment=: class should not be assigned.
BiBlockHalfPel & operator=(const BiBlockHalfPel &rhs)
Private, bodyless assignment=: class should not be assigned.
BiBlockHalfPel(const BiBlockHalfPel &cpy)
Private, bodyless copy-constructor: class should not be copied.
float Diff(const BlockDiffParams &dparams, const MVector &mv1, const MVector &mv2)
Do the difference, returning SAD.
BiBlockHalfPel(const PicArray &ref1, const PicArray &ref2, const PicArray &pic)
Constructor, initialising the references and picture data.
BiBlockQuarterPel(const BiBlockQuarterPel &cpy)
Private, bodyless copy-constructor: class should not be copied.
BiBlockQuarterPel(const PicArray &ref1, const PicArray &ref2, const PicArray &pic)
Constructor, initialising the references and picture data.
float Diff(const BlockDiffParams &dparams, const MVector &mv1, const MVector &mv2)
Do the difference, returning SAD.
BiBlockQuarterPel & operator=(const BiBlockQuarterPel &rhs)
Private, bodyless assignment=: class should not be assigned.
BiBlockEighthPel(const BiBlockEighthPel &cpy)
Private, bodyless copy-constructor: class should not be copied.
float Diff(const BlockDiffParams &dparams, const MVector &mv1, const MVector &mv2)
Do the difference, returning SAD.
BiBlockEighthPel & operator=(const BiBlockEighthPel &rhs)
Private, bodyless assignment=: class should not be assigned.
BiBlockEighthPel(const PicArray &ref1, const PicArray &ref2, const PicArray &pic)
Constructor, initialising the references and picture data.

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