Dirac - A Video Codec

Created by the British Broadcasting Corporation.


mv_codec.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002 *
00003 * $Id: mv_codec.h,v 1.14 2005/04/06 14:31:11 tjdwave Exp $ $Name: Dirac_0_5_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): Thomas Davies (Original Author), Scott R Ladd
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 #ifndef _MV_CODEC_H_
00039 #define _MV_CODEC_H_
00040 
00042 //Class to do motion vector coding and decoding//
00043 //------using adaptive arithmetic coding-------//
00045 
00046 #include <libdirac_common/arith_codec.h>
00047 #include <libdirac_common/common.h>
00048 #include <libdirac_common/motion.h>
00049 #include <libdirac_common/wavelet_utils.h>
00050 #include <vector>
00051 
00052 namespace dirac
00053 {
00054 
00056 
00059     class MvDataCodec: public ArithCodec<MvData>
00060     {
00061     public:
00063 
00069         MvDataCodec(BasicOutputManager* bits_out,
00070                     size_t number_of_contexts,
00071                     const ChromaFormat & cf);
00072 
00074 
00080         MvDataCodec(BitInputManager* bits_in,
00081                     size_t number_of_contexts,
00082                     const ChromaFormat & cf); 
00083 
00085         void InitContexts();
00086     
00087     private:
00088 
00089         int m_MB_count;
00090        const int m_reset_num;
00091 
00092         const ChromaFormat & m_cformat;
00093 
00094         // Position of current block
00095         int m_b_xp, m_b_yp;
00096         // Position of current MB
00097         int m_mb_xp, m_mb_yp;
00098         // Position of top-left block of current MB
00099         int m_mb_tlb_x, m_mb_tlb_y;
00100 
00101     private:
00102 
00103         // functions    
00105         MvDataCodec(const MvDataCodec& cpy);
00107         MvDataCodec& operator=(const MvDataCodec& rhs);
00108 
00109         // coding functions    
00110         // Code the MB splitting mode
00111         void CodeMBSplit(const MvData& in_data);
00112         // Code the MB common ref mode
00113         void CodeMBCom(const MvData& in_data);
00114         // Code the block prediction mode
00115         void CodePredmode(const MvData& in_data);
00116         // Code the first motion vector
00117         void CodeMv1(const MvData& in_data);
00118         // Code the second motion vector
00119         void CodeMv2(const MvData& in_data);
00120         // Code the dc value of intra blocks
00121         void CodeDC(const MvData& in_data);
00122 
00123         // decoding functions
00124         // Decode the MB splitting mode
00125         void DecodeMBSplit( MvData& out_data);
00126         // Decode the MB common ref mode
00127         void DecodeMBCom( MvData& out_data);
00128         // Decode the block prediction mode
00129         void DecodePredmode(MvData& out_data);
00130         // Decode the first motion vector
00131         void DecodeMv1( MvData& out_data);
00132         // Decode the second motion vector
00133         void DecodeMv2( MvData& out_data);
00134         // Decode the dc value of intra blocks    
00135         void DecodeDC( MvData& out_data);
00136 
00137         void DoWorkCode( MvData& in_data );
00138         void DoWorkDecode(MvData& out_data);
00139 
00140         // Context stuff    
00141         void ResetAll();
00142 
00143         int ChooseMBSContext(const MvData& data, const int BinNumber) const;
00144         int ChooseMBCContext(const MvData& data) const;
00145         int ChooseREF1xContext(const MvData& data, const int BinNumber) const;
00146         int ChooseREF1xSignContext(const MvData& data) const;
00147         int ChooseREF1yContext(const MvData& data, const int BinNumber) const;
00148         int ChooseREF1ySignContext(const MvData& data) const;
00149         int ChooseREF2xContext(const MvData& data, const int BinNumber) const;
00150         int ChooseREF2xSignContext(const MvData& data) const;
00151         int ChooseREF2yContext(const MvData& data, const int BinNumber) const;
00152         int ChooseREF2ySignContext(const MvData& data) const;
00153         int ChooseYDCContext(const MvData& data, const int BinNumber) const;
00154         int ChooseUDCContext(const MvData& data, const int BinNumber) const;
00155         int ChooseVDCContext(const MvData& data, const int BinNumber) const;
00156         int ChooseYDCSignContext(const MvData& data) const;
00157         int ChooseUDCSignContext(const MvData& data) const;
00158         int ChooseVDCSignContext(const MvData& data) const;
00159 
00160         //prediction stuff
00161         unsigned int MBSplitPrediction(const TwoDArray<int>& mbdata) const;
00162         bool MBCBModePrediction(const TwoDArray<bool>& mbdata) const;
00163         unsigned int BlockModePrediction(const TwoDArray<PredMode>& preddata) const;
00164         MVector Mv1Prediction(const MvArray& mvarray,const TwoDArray<PredMode>& preddata) const;
00165         MVector Mv2Prediction(const MvArray& mvarray,const TwoDArray<PredMode>& preddata) const;
00166         ValueType DCPrediction(const TwoDArray<ValueType>& dcdata,const TwoDArray<PredMode>& preddata) const;
00167     };
00168 
00169 }// end namepace dirac
00170 
00171 #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.