00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: mot_comp.h,v 1.2 2005/01/30 05:11:40 gabest Exp $ $Name: $ 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), Thomas Davies 00024 * 00025 * Alternatively, the contents of this file may be used under the terms of 00026 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser 00027 * Public License Version 2.1 (the "LGPL"), in which case the provisions of 00028 * the GPL or the LGPL are applicable instead of those above. If you wish to 00029 * allow use of your version of this file only under the terms of the either 00030 * the GPL or LGPL and not to allow others to use your version of this file 00031 * under the MPL, indicate your decision by deleting the provisions above 00032 * and replace them with the notice and other provisions required by the GPL 00033 * or LGPL. If you do not delete the provisions above, a recipient may use 00034 * your version of this file under the terms of any one of the MPL, the GPL 00035 * or the LGPL. 00036 * ***** END LICENSE BLOCK ***** */ 00037 00038 // Motion Compensation routines. 00039 // Supports different sizes of blocks as long as the parameters 00040 // describing them are 'legal'. Blocks overlap the edge of the image 00041 // being written to but blocks in the reference image are forced to 00042 // lie completely within the image bounds. 00043 00044 #ifndef _INCLUDED_MOT_COMP 00045 #define _INCLUDED_MOT_COMP 00046 00047 #include <cstdlib> 00048 #include <ctime> 00049 #include <iostream> 00050 #include <libdirac_common/common.h> 00051 #include <libdirac_common/upconvert.h> 00052 #include <libdirac_common/motion.h> 00053 00054 namespace dirac 00055 { 00056 class FrameBuffer; 00057 class Frame; 00058 00060 00064 class MotionCompensator 00065 { 00066 00067 public: 00069 00072 MotionCompensator( const CodecParams &cp , const AddOrSub direction ); 00074 ~MotionCompensator(); 00075 00077 00084 void CompensateFrame( FrameBuffer& my_buffer , int fnum , const MvData& mv_data ); 00085 00086 private: 00087 //private, body-less copy constructor: this class should not be copied 00088 MotionCompensator( const MotionCompensator& cpy ); 00089 //private, body-less assignment=: this class should not be assigned 00090 MotionCompensator& operator=( const MotionCompensator& rhs ); 00091 00092 //functions 00093 00095 void CompensateComponent( Frame& picframe , const Frame& ref1frame , 00096 const Frame& ref2frame , 00097 const MvData& mv_data , const CompSort cs); 00098 00100 void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00101 const PicArray& refup_data , const MVector& Vec , 00102 const ImageCoords& Pos , const TwoDArray<CalcValueType>& Weights ); 00103 00105 void DCBlock( TwoDArray<CalcValueType> &pic_data , const ValueType dc , 00106 const ImageCoords& Pos , const TwoDArray<CalcValueType>& Weights); 00107 00109 void ReConfig(); 00110 00111 // Overlapping blocks are acheived by applying a 2D raised cosine shape 00112 // to them. This function facilitates the calculations 00113 float RaisedCosine(float t, float B); 00114 00116 00127 void CreateBlock(const OLBParams &bparams, bool FullX, bool FullY, TwoDArray<CalcValueType>& WeightArray); 00128 00130 void FlipX(const TwoDArray<CalcValueType>& Original, const OLBParams &bparams, TwoDArray<CalcValueType>& Flipped); 00131 00133 void FlipY(const TwoDArray<CalcValueType>& Original, const OLBParams &bparams, TwoDArray<CalcValueType>& Flipped); 00134 00135 private: 00136 //variables 00137 00139 CodecParams m_cparams; 00140 00142 ChromaFormat m_cformat; 00143 bool luma_or_chroma; //true if we're doing luma, false if we're coding chroma 00144 00145 // A marker saying whether we're doing MC addition or subtraction 00146 AddOrSub m_add_or_sub; 00147 00148 // Block information 00149 OLBParams m_bparams; 00150 TwoDArray<CalcValueType>* m_block_weights; 00151 TwoDArray<CalcValueType>* m_half_block_weights; 00152 00153 }; 00154 00155 } // namespace dirac 00156 00157 #endif