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.20 2006/07/28 13:33:16 tjdwave 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): Thomas Davies (Original Author),
00024 *                 Scott R Ladd,
00025 *                 Tim Borer,
00026 *                 Andrew Kennedy
00027 *
00028 * Alternatively, the contents of this file may be used under the terms of
00029 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
00030 * Public License Version 2.1 (the "LGPL"), in which case the provisions of
00031 * the GPL or the LGPL are applicable instead of those above. If you wish to
00032 * allow use of your version of this file only under the terms of the either
00033 * the GPL or LGPL and not to allow others to use your version of this file
00034 * under the MPL, indicate your decision by deleting the provisions above
00035 * and replace them with the notice and other provisions required by the GPL
00036 * or LGPL. If you do not delete the provisions above, a recipient may use
00037 * your version of this file under the terms of any one of the MPL, the GPL
00038 * or the LGPL.
00039 * ***** END LICENSE BLOCK ***** */
00040 
00041 #ifndef _MV_CODEC_H_
00042 #define _MV_CODEC_H_
00043 
00045 //Class to do motion vector coding and decoding//
00046 //------using adaptive arithmetic coding-------//
00048 
00049 #include <libdirac_common/arith_codec.h>
00050 #include <libdirac_common/common.h>
00051 #include <libdirac_common/motion.h>
00052 #include <libdirac_common/wavelet_utils.h>
00053 #include <vector>
00054 
00055 namespace dirac
00056 {
00057 
00059 
00062     class MvDataCodec: public ArithCodec<MvData>
00063     {
00064     public:
00066 
00072         MvDataCodec(ByteIO* p_byteio,
00073                     size_t number_of_contexts,
00074                     const ChromaFormat & cf);
00075 
00076        
00077 
00079         void InitContexts();
00080     
00081     private:
00082 
00083         int m_MB_count;
00084        const int m_reset_num;
00085 
00086         const ChromaFormat & m_cformat;
00087 
00088         // Position of current block
00089         int m_b_xp, m_b_yp;
00090         // Position of current MB
00091         int m_mb_xp, m_mb_yp;
00092         // Position of top-left block of current MB
00093         int m_mb_tlb_x, m_mb_tlb_y;
00094 
00095     private:
00096 
00097         // functions   
00099         MvDataCodec(const MvDataCodec& cpy);
00101         MvDataCodec& operator=(const MvDataCodec& rhs);
00102 
00103         // coding functions   
00104         // Code the MB splitting mode
00105         void CodeMBSplit(const MvData& in_data);
00106         // Code the block prediction mode
00107         void CodePredmode(const MvData& in_data);
00108         // Code the first motion vector
00109         void CodeMv1(const MvData& in_data);
00110         // Code the second motion vector
00111         void CodeMv2(const MvData& in_data);
00112         // Code the dc value of intra blocks
00113         void CodeDC(const MvData& in_data);
00114 
00115         // decoding functions
00116         // Decode the MB splitting mode
00117         void DecodeMBSplit( MvData& out_data);
00118         // Decode the block prediction mode
00119         void DecodePredmode(MvData& out_data);
00120         // Decode the first motion vector
00121         void DecodeMv1( MvData& out_data);
00122         // Decode the second motion vector
00123         void DecodeMv2( MvData& out_data);
00124         // Decode the dc value of intra blocks  
00125         void DecodeDC( MvData& out_data);
00126 
00127         void DoWorkCode( MvData& in_data );
00128         void DoWorkDecode(MvData& out_data);
00129 
00130         // Context stuff   
00131         void ResetAll();
00132 
00133         //prediction stuff
00134         unsigned int MBSplitPrediction(const TwoDArray<int>& mbdata) const;
00135 
00136         unsigned int BlockModePrediction(const TwoDArray<PredMode>& preddata,
00137                                          const unsigned int num_refs) const;
00138 
00139         MVector Mv1Prediction( const MvArray& mvarray,
00140                                const TwoDArray<PredMode>& preddata) const;
00141 
00142         MVector Mv2Prediction( const MvArray& mvarray, 
00143                                const TwoDArray<PredMode>& preddata) const;
00144 
00145         ValueType DCPrediction( const TwoDArray<ValueType>& dcdata,
00146                                 const TwoDArray<PredMode>& preddata) const;
00147     };
00148 
00149 }// end namepace dirac
00150 
00151 #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.