Dirac - A Video Codec

Created by the British Broadcasting Corporation.


mot_comp.h
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2 *
3 * $Id: mot_comp.h,v 1.22 2008/08/27 00:17:11 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): Richard Felton (Original Author),
24 * Thomas Davies
25 * Anuradha Suraparaju
26 *
27 * Alternatively, the contents of this file may be used under the terms of
28 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
29 * Public License Version 2.1 (the "LGPL"), in which case the provisions of
30 * the GPL or the LGPL are applicable instead of those above. If you wish to
31 * allow use of your version of this file only under the terms of the either
32 * the GPL or LGPL and not to allow others to use your version of this file
33 * under the MPL, indicate your decision by deleting the provisions above
34 * and replace them with the notice and other provisions required by the GPL
35 * or LGPL. If you do not delete the provisions above, a recipient may use
36 * your version of this file under the terms of any one of the MPL, the GPL
37 * or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
39 
40 // Motion Compensation routines.
41 // Supports different sizes of blocks as long as the parameters
42 // describing them are 'legal'. Blocks overlap the edge of the image
43 // being written to but blocks in the reference image are forced to
44 // lie completely within the image bounds.
45 
46 #ifndef _INCLUDED_MOT_COMP
47 #define _INCLUDED_MOT_COMP
48 
49 #include <cstdlib>
50 #include <ctime>
51 #include <iostream>
52 #include <vector>
53 #include <libdirac_common/common.h>
55 #include <libdirac_common/motion.h>
57 
58 namespace dirac
59 {
60  class PictureBuffer;
61  class Picture;
62 
64 
71  {
72 
73  public:
75 
80  virtual ~MotionCompensator();
81 
83 
93  static void CompensatePicture ( const PicturePredParams &ppp,
94  const AddOrSub direction ,
95  const MvData& mv_data,
96  Picture* in_pic ,
97  Picture* refptr[2]);
98 
100 
108  void CompensatePicture( const AddOrSub direction ,
109  const MvData& mv_data,
110  Picture* in_pic ,
111  Picture* refsptr[2] );
112 
113  private:
114  //private, body-less copy constructor: this class should not be copied
115  MotionCompensator( const MotionCompensator& cpy );
116  //private, body-less assignment=: this class should not be assigned
118 
119  //functions
120 
122  void CompensateComponent( Picture* pic ,
123  Picture* refsptr[2] ,
124  const MvData& mv_data , const CompSort cs);
125 
128  void DCBlock( TwoDArray<ValueType> &block_data ,
129  const ValueType dc);
130  void ReConfig();
131 
132  // Calculates a weighting arrays blocks.
133  void CalculateWeights(int xbsep, int ybsep, TwoDArray<ValueType>* wt_array);
134 
136 
147  void CreateBlock(int xbsep, int ybsep, bool FullX, bool FullY, TwoDArray<ValueType>& WeightArray);
148 
150  void FlipX(const TwoDArray<ValueType>& Original, TwoDArray<ValueType>& Flipped);
151 
153  void FlipY(const TwoDArray<ValueType>& Original, TwoDArray<ValueType>& Flipped);
154 
155  virtual void CompensateBlock( TwoDArray<ValueType>& pic_data ,
156  const ImageCoords& pos ,
157  const ImageCoords &orig_pic_size,
158  PredMode block_mode,
159  ValueType dc,
160  const PicArray& ref1up_data ,
161  const MVector& mv1 ,
162  const PicArray& ref2up_data ,
163  const MVector& mv2 ,
164  const TwoDArray<ValueType>& Weights );
166  virtual void BlockPixelPred( TwoDArray<ValueType>& block_data ,
167  const ImageCoords& pos,
168  const ImageCoords &orig_pic_size,
169  const PicArray& refup_data ,
170  const MVector& mv) = 0;
171 
172  // Adjust the block value based on reference weights
173  /*
174  * Adjust the block value based on reference weights of each
175  * reference picture.
176  * val1_block - Block predicted from a single reference picture
177  * val2_block - Block predicted from second reference picture
178  * mode is REF1AND2
179  * block_mode - Block prediction mode.
180  *
181  * On return, val1_block will contain the weight reference weight
182  * adjusted block values
183  */
185  TwoDArray<ValueType>& val2_block,
186  PredMode block_mode);
187 
188  // Adjust the block value based spatial weighting matrix
189  /*
190  * Adjust the block value based on spatial weighting matrix
191  * val_block - Predicted block
192  * pos - position of top lef corner of block in picture
193  * wt_array - spatial weighting matrix
194  *
195  * On return, val_block will contain the spatial weight adjusted block
196  * values
197  */
199  const ImageCoords &pos,
200  const TwoDArray<ValueType> &wt_array);
201  protected:
202  //variables
203 
206 
209  bool luma_or_chroma; //true if we're doing luma, false if we're coding chroma
210 
211  // A marker saying whether we're doing MC addition or subtraction
213 
214  // Block information
216  // Arrays of block weights
218  // Arrays of super block weights
220  // Arrays of sub super block weights
222  };
223 
226  {
227 
228  public:
230 
234 
235  private:
237  virtual void BlockPixelPred( TwoDArray<ValueType>& block_data ,
238  const ImageCoords& pos,
239  const ImageCoords &orig_pic_size,
240  const PicArray& refup_data ,
241  const MVector& mv);
242  };
243 
246  {
247  public:
249 
253  private:
255  virtual void BlockPixelPred( TwoDArray<ValueType>& block_data ,
256  const ImageCoords& pos,
257  const ImageCoords &orig_pic_size,
258  const PicArray& refup_data ,
259  const MVector& mv);
260  };
261 
264  {
265  public:
267 
271  private:
273  virtual void BlockPixelPred( TwoDArray<ValueType>& block_data ,
274  const ImageCoords& pos,
275  const ImageCoords &orig_pic_size,
276  const PicArray& refup_data ,
277  const MVector& mv);
278  };
279 
282  {
283  public:
285 
289  private:
291  virtual void BlockPixelPred( TwoDArray<ValueType>& block_data ,
292  const ImageCoords& pos,
293  const ImageCoords &orig_pic_size,
294  const PicArray& refup_data ,
295  const MVector& mv);
296  };
297 
298 
299 } // namespace dirac
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.