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>
57
58namespace dirac
59{
60 class PictureBuffer;
61 class Picture;
62
64
71 {
72
73 public:
75
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
116 //private, body-less assignment=: this class should not be assigned
118
119 //functions
120
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
ChromaFormat
Definition common_types.h:58
Definition of class SequenceHeaderByteIO.
Definition accessunit_byteio.h:52
CompSort
Types of picture component.
Definition common.h:87
AddOrSub
Addition or subtraction.
Definition common.h:90
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
PredMode
Prediction modes for blocks.
Definition common.h:84
MotionVector< int > ImageCoords
ImageCoords class is a vector of ints.
Definition motion.h:183
A template class for two-dimensional arrays.
Definition arrays.h:285
A class for picture component data.
Definition common.h:719
Parameters for overlapped block motion compensation.
Definition common.h:818
Structure to hold motion parameters when motion comp is used.
Definition common.h:968
void AdjustBlockBySpatialWeights(TwoDArray< ValueType > &val_block, const ImageCoords &pos, const TwoDArray< ValueType > &wt_array)
virtual void CompensateBlock(TwoDArray< ValueType > &pic_data, const ImageCoords &pos, const ImageCoords &orig_pic_size, PredMode block_mode, ValueType dc, const PicArray &ref1up_data, const MVector &mv1, const PicArray &ref2up_data, const MVector &mv2, const TwoDArray< ValueType > &Weights)
void FlipY(const TwoDArray< ValueType > &Original, TwoDArray< ValueType > &Flipped)
Flips the values in an array in the y direction.
virtual void BlockPixelPred(TwoDArray< ValueType > &block_data, const ImageCoords &pos, const ImageCoords &orig_pic_size, const PicArray &refup_data, const MVector &mv)=0
Predict pixels in a block. Pure virtual. SubClasses need to define it.
TwoDArray< ValueType > * m_macro_block_weights
Definition mot_comp.h:219
ChromaFormat m_cformat
The chroma format.
Definition mot_comp.h:208
AddOrSub m_add_or_sub
Definition mot_comp.h:212
virtual ~MotionCompensator()
Destructor.
TwoDArray< ValueType > * m_sub_block_weights
Definition mot_comp.h:221
void CompensatePicture(const AddOrSub direction, const MvData &mv_data, Picture *in_pic, Picture *refsptr[2])
Compensate a picture.
MotionCompensator(const PicturePredParams &ppp)
Constructor.
static void CompensatePicture(const PicturePredParams &ppp, const AddOrSub direction, const MvData &mv_data, Picture *in_pic, Picture *refptr[2])
Convenience function to perform motion compensation on a picture.
bool luma_or_chroma
Definition mot_comp.h:209
PicturePredParams m_predparams
The codec parameters.
Definition mot_comp.h:205
void CreateBlock(int xbsep, int ybsep, bool FullX, bool FullY, TwoDArray< ValueType > &WeightArray)
Calculates a weighting block.
void FlipX(const TwoDArray< ValueType > &Original, TwoDArray< ValueType > &Flipped)
Flips the values in an array in the x direction.
OLBParams m_bparams
Definition mot_comp.h:215
TwoDArray< ValueType > * m_block_weights
Definition mot_comp.h:217
void CalculateWeights(int xbsep, int ybsep, TwoDArray< ValueType > *wt_array)
void CompensateComponent(Picture *pic, Picture *refsptr[2], const MvData &mv_data, const CompSort cs)
Motion-compensate a component.
void AdjustBlockByRefWeights(TwoDArray< ValueType > &val1_block, TwoDArray< ValueType > &val2_block, PredMode block_mode)
MotionCompensator(const MotionCompensator &cpy)
void DCBlock(TwoDArray< ValueType > &block_data, const ValueType dc)
MotionCompensator & operator=(const MotionCompensator &rhs)
virtual void BlockPixelPred(TwoDArray< ValueType > &block_data, const ImageCoords &pos, const ImageCoords &orig_pic_size, const PicArray &refup_data, const MVector &mv)
Motion-compensate a block.
MotionCompensator_Pixel(const PicturePredParams &ppp)
Constructor.
MotionCompensator_HalfPixel(const PicturePredParams &ppp)
Constructor.
virtual void BlockPixelPred(TwoDArray< ValueType > &block_data, const ImageCoords &pos, const ImageCoords &orig_pic_size, const PicArray &refup_data, const MVector &mv)
Motion-compensate a block.
MotionCompensator_QuarterPixel(const PicturePredParams &ppp)
Constructor.
virtual void BlockPixelPred(TwoDArray< ValueType > &block_data, const ImageCoords &pos, const ImageCoords &orig_pic_size, const PicArray &refup_data, const MVector &mv)
Motion-compensate a block.
virtual void BlockPixelPred(TwoDArray< ValueType > &block_data, const ImageCoords &pos, const ImageCoords &orig_pic_size, const PicArray &refup_data, const MVector &mv)
Motion-compensate a block.
MotionCompensator_EighthPixel(const PicturePredParams &ppp)
Constructor.
Class for all the motion vector data.
Definition motion.h:220
A class for encapsulating all the data relating to a picture.
Definition picture.h:52
Holds pictures both for reference and to overcome reordering delay.
Definition picture_buffer.h:59

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