Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: mot_comp.h,v 1.22 2008/08/27 00:17:11 asuraparaju Exp $ $Name: Dirac_1_0_2 $ 00004 * 00005 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 00006 * 00007 * The contents of this file are subject to the Mozilla Public License 00008 * Version 1.1 (the "License"); you may not use this file except in compliance 00009 * with the License. You may obtain a copy of the License at 00010 * http://www.mozilla.org/MPL/ 00011 * 00012 * Software distributed under the License is distributed on an "AS IS" basis, 00013 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 00014 * the specific language governing rights and limitations under the License. 00015 * 00016 * The Original Code is BBC Research and Development code. 00017 * 00018 * The Initial Developer of the Original Code is the British Broadcasting 00019 * Corporation. 00020 * Portions created by the Initial Developer are Copyright (C) 2004. 00021 * All Rights Reserved. 00022 * 00023 * Contributor(s): Richard Felton (Original Author), 00024 * Thomas Davies 00025 * Anuradha Suraparaju 00026 * 00027 * Alternatively, the contents of this file may be used under the terms of 00028 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser 00029 * Public License Version 2.1 (the "LGPL"), in which case the provisions of 00030 * the GPL or the LGPL are applicable instead of those above. If you wish to 00031 * allow use of your version of this file only under the terms of the either 00032 * the GPL or LGPL and not to allow others to use your version of this file 00033 * under the MPL, indicate your decision by deleting the provisions above 00034 * and replace them with the notice and other provisions required by the GPL 00035 * or LGPL. If you do not delete the provisions above, a recipient may use 00036 * your version of this file under the terms of any one of the MPL, the GPL 00037 * or the LGPL. 00038 * ***** END LICENSE BLOCK ***** */ 00039 00040 // Motion Compensation routines. 00041 // Supports different sizes of blocks as long as the parameters 00042 // describing them are 'legal'. Blocks overlap the edge of the image 00043 // being written to but blocks in the reference image are forced to 00044 // lie completely within the image bounds. 00045 00046 #ifndef _INCLUDED_MOT_COMP 00047 #define _INCLUDED_MOT_COMP 00048 00049 #include <cstdlib> 00050 #include <ctime> 00051 #include <iostream> 00052 #include <vector> 00053 #include <libdirac_common/common.h> 00054 #include <libdirac_common/upconvert.h> 00055 #include <libdirac_common/motion.h> 00056 #include <libdirac_common/picture_buffer.h> 00057 00058 namespace dirac 00059 { 00060 class PictureBuffer; 00061 class Picture; 00062 00064 00070 class MotionCompensator 00071 { 00072 00073 public: 00075 00078 MotionCompensator( const PicturePredParams &ppp ); 00080 virtual ~MotionCompensator(); 00081 00083 00093 static void CompensatePicture ( const PicturePredParams &ppp, 00094 const AddOrSub direction , 00095 const MvData& mv_data, 00096 Picture* in_pic , 00097 Picture* refptr[2]); 00098 00100 00108 void CompensatePicture( const AddOrSub direction , 00109 const MvData& mv_data, 00110 Picture* in_pic , 00111 Picture* refsptr[2] ); 00112 00113 private: 00114 //private, body-less copy constructor: this class should not be copied 00115 MotionCompensator( const MotionCompensator& cpy ); 00116 //private, body-less assignment=: this class should not be assigned 00117 MotionCompensator& operator=( const MotionCompensator& rhs ); 00118 00119 //functions 00120 00122 void CompensateComponent( Picture* pic , 00123 Picture* refsptr[2] , 00124 const MvData& mv_data , const CompSort cs); 00125 00128 void DCBlock( TwoDArray<ValueType> &block_data , 00129 const ValueType dc); 00130 void ReConfig(); 00131 00132 // Calculates a weighting arrays blocks. 00133 void CalculateWeights(int xbsep, int ybsep, TwoDArray<ValueType>* wt_array); 00134 00136 00147 void CreateBlock(int xbsep, int ybsep, bool FullX, bool FullY, TwoDArray<ValueType>& WeightArray); 00148 00150 void FlipX(const TwoDArray<ValueType>& Original, TwoDArray<ValueType>& Flipped); 00151 00153 void FlipY(const TwoDArray<ValueType>& Original, TwoDArray<ValueType>& Flipped); 00154 00155 virtual void CompensateBlock( TwoDArray<ValueType>& pic_data , 00156 const ImageCoords& pos , 00157 const ImageCoords &orig_pic_size, 00158 PredMode block_mode, 00159 ValueType dc, 00160 const PicArray& ref1up_data , 00161 const MVector& mv1 , 00162 const PicArray& ref2up_data , 00163 const MVector& mv2 , 00164 const TwoDArray<ValueType>& Weights ); 00166 virtual void BlockPixelPred( TwoDArray<ValueType>& block_data , 00167 const ImageCoords& pos, 00168 const ImageCoords &orig_pic_size, 00169 const PicArray& refup_data , 00170 const MVector& mv) = 0; 00171 00172 // Adjust the block value based on reference weights 00173 /* 00174 * Adjust the block value based on reference weights of each 00175 * reference picture. 00176 * val1_block - Block predicted from a single reference picture 00177 * val2_block - Block predicted from second reference picture 00178 * mode is REF1AND2 00179 * block_mode - Block prediction mode. 00180 * 00181 * On return, val1_block will contain the weight reference weight 00182 * adjusted block values 00183 */ 00184 void AdjustBlockByRefWeights (TwoDArray<ValueType>& val1_block, 00185 TwoDArray<ValueType>& val2_block, 00186 PredMode block_mode); 00187 00188 // Adjust the block value based spatial weighting matrix 00189 /* 00190 * Adjust the block value based on spatial weighting matrix 00191 * val_block - Predicted block 00192 * pos - position of top lef corner of block in picture 00193 * wt_array - spatial weighting matrix 00194 * 00195 * On return, val_block will contain the spatial weight adjusted block 00196 * values 00197 */ 00198 void AdjustBlockBySpatialWeights (TwoDArray<ValueType>& val_block, 00199 const ImageCoords &pos, 00200 const TwoDArray<ValueType> &wt_array); 00201 protected: 00202 //variables 00203 00205 PicturePredParams m_predparams; 00206 00208 ChromaFormat m_cformat; 00209 bool luma_or_chroma; //true if we're doing luma, false if we're coding chroma 00210 00211 // A marker saying whether we're doing MC addition or subtraction 00212 AddOrSub m_add_or_sub; 00213 00214 // Block information 00215 OLBParams m_bparams; 00216 // Arrays of block weights 00217 TwoDArray<ValueType>* m_block_weights; 00218 // Arrays of super block weights 00219 TwoDArray<ValueType>* m_macro_block_weights; 00220 // Arrays of sub super block weights 00221 TwoDArray<ValueType>* m_sub_block_weights; 00222 }; 00223 00225 class MotionCompensator_Pixel : public MotionCompensator 00226 { 00227 00228 public: 00230 00233 MotionCompensator_Pixel (const PicturePredParams &ppp); 00234 00235 private: 00237 virtual void BlockPixelPred( TwoDArray<ValueType>& block_data , 00238 const ImageCoords& pos, 00239 const ImageCoords &orig_pic_size, 00240 const PicArray& refup_data , 00241 const MVector& mv); 00242 }; 00243 00245 class MotionCompensator_HalfPixel : public MotionCompensator 00246 { 00247 public: 00249 00252 MotionCompensator_HalfPixel (const PicturePredParams &ppp); 00253 private: 00255 virtual void BlockPixelPred( TwoDArray<ValueType>& block_data , 00256 const ImageCoords& pos, 00257 const ImageCoords &orig_pic_size, 00258 const PicArray& refup_data , 00259 const MVector& mv); 00260 }; 00261 00263 class MotionCompensator_QuarterPixel : public MotionCompensator 00264 { 00265 public: 00267 00270 MotionCompensator_QuarterPixel (const PicturePredParams &ppp); 00271 private: 00273 virtual void BlockPixelPred( TwoDArray<ValueType>& block_data , 00274 const ImageCoords& pos, 00275 const ImageCoords &orig_pic_size, 00276 const PicArray& refup_data , 00277 const MVector& mv); 00278 }; 00279 00281 class MotionCompensator_EighthPixel : public MotionCompensator 00282 { 00283 public: 00285 00288 MotionCompensator_EighthPixel (const PicturePredParams &ppp); 00289 private: 00291 virtual void BlockPixelPred( TwoDArray<ValueType>& block_data , 00292 const ImageCoords& pos, 00293 const ImageCoords &orig_pic_size, 00294 const PicArray& refup_data , 00295 const MVector& mv); 00296 }; 00297 00298 00299 } // namespace dirac 00300 00301 #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.