Dirac Video Codec

# 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.24 2008/08/14 02:30:50 asuraparaju Exp $ $Name: Dirac_1_0_0 $
    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 {
    00058
    00061     class SplitModeCodec: public ArithCodec<MvData>
    00062     {
    00063     public:
    00065
    00070         SplitModeCodec(ByteIO* p_byteio, size_t number_of_contexts);
    00071
    00072
    00073
    00075         void InitContexts();
    00076
    00077     private:
    00078
    00079         // Position of current MB
    00080         int m_mb_xp, m_mb_yp;
    00081
    00082     private:
    00083
    00084         // functions
    00086         SplitModeCodec(const SplitModeCodec& cpy);
    00088         SplitModeCodec& operator=(const SplitModeCodec& rhs);
    00089
    00090         // coding functions
    00091         // Code the MB splitting mode
    00092         void CodeVal(const MvData& in_data);
    00093
    00094         // decoding functions
    00095         // Decode the MB splitting mode
    00096         void DecodeVal( MvData& out_data);
    00097
    00098         void DoWorkCode( MvData& in_data );
    00099         void DoWorkDecode(MvData& out_data);
    00100
    00101         // Context stuff
    00102         void ResetAll();
    00103
    00104         //prediction stuff
    00105         unsigned int Prediction(const TwoDArray<int>& mbdata) const;
    00106
    00107     };
    00108
    00109 /******************************************************************************/
    00110
    00112
    00115     class PredModeCodec: public ArithCodec<MvData>
    00116     {
    00117     public:
    00119
    00125         PredModeCodec(ByteIO* p_byteio, size_t number_of_contexts, const int num_refs);
    00126
    00128         void InitContexts();
    00129
    00130     private:
    00131
    00132         // Position of current block
    00133         int m_b_xp, m_b_yp;
    00134         // Position of current MB
    00135         int m_mb_xp, m_mb_yp;
    00136         // Position of top-left block of current MB
    00137         int m_mb_tlb_x, m_mb_tlb_y;
    00138         // Number of reference pictures
    00139     int m_num_refs;
    00140
    00141     private:
    00142
    00143         // functions
    00145         PredModeCodec(const PredModeCodec& cpy);
    00147         PredModeCodec& operator=(const PredModeCodec& rhs);
    00148
    00149         // coding functions
    00150         // Code the block prediction mode
    00151         void CodeVal(const MvData& in_data);
    00152
    00153         // decoding functions
    00154         // Decode the block prediction mode
    00155         void DecodeVal(MvData& out_data);
    00156
    00157         void DoWorkCode( MvData& in_data );
    00158         void DoWorkDecode(MvData& out_data);
    00159
    00160         // Context stuff
    00161         void ResetAll();
    00162
    00163         //prediction stuff
    00164         unsigned int Prediction(const TwoDArray<PredMode>& preddata) const;
    00165
    00166     };
    00167
    00168 /******************************************************************************/
    00169
    00171
    00175     class VectorElementCodec: public ArithCodec<MvData>
    00176     {
    00177     public:
    00179
    00186         VectorElementCodec(ByteIO* p_byteio, int ref_id, MvElement horvert,
    00187                          size_t number_of_contexts);
    00188
    00189
    00191         void InitContexts();
    00192
    00193     private:
    00194
    00195         // Position of current block
    00196         int m_b_xp, m_b_yp;
    00197
    00198         // Position of current MB
    00199         int m_mb_xp, m_mb_yp;
    00200
    00201         // Position of top-left block of current MB
    00202         int m_mb_tlb_x, m_mb_tlb_y;
    00203
    00204         // The identity of the reference (1 or 2)
    00205         const int m_ref;
    00206
    00207         // Whether it's the vertical or horizontal MV element
    00208         const MvElement m_hv;
    00209
    00210     private:
    00211
    00212         // functions
    00214         VectorElementCodec(const VectorElementCodec& cpy);
    00216         VectorElementCodec& operator=(const VectorElementCodec& rhs);
    00217
    00218         // coding functions
    00219         // Code the motion vector element
    00220         void CodeVal(const MvData& in_data);
    00221
    00222         // decoding functions
    00223         // Decode the motion vector element
    00224         void DecodeVal( MvData& out_data);
    00225
    00226         void DoWorkCode( MvData& in_data );
    00227         void DoWorkDecode(MvData& out_data);
    00228
    00229         // Context stuff
    00230         void ResetAll();
    00231
    00232         //prediction stuff
    00233         int Prediction( const MvArray& mvarray,
    00234                         const TwoDArray<PredMode>& preddata) const;
    00235
    00236     };
    00237
    00238 /******************************************************************************/
    00240
    00244     class DCCodec: public ArithCodec<MvData>
    00245     {
    00246     public:
    00248
    00254         DCCodec(ByteIO* p_byteio, const CompSort csort, size_t number_of_contexts);
    00255
    00257         void InitContexts();
    00258
    00259     private:
    00260
    00261         // The component being coded
    00262         const CompSort m_csort;
    00263         // Position of current block
    00264         int m_b_xp, m_b_yp;
    00265         // Position of current MB
    00266         int m_mb_xp, m_mb_yp;
    00267         // Position of top-left block of current MB
    00268         int m_mb_tlb_x, m_mb_tlb_y;
    00269
    00270     private:
    00271
    00272         // functions
    00274         DCCodec(const DCCodec& cpy);
    00276         DCCodec& operator=(const DCCodec& rhs);
    00277
    00278         // coding functions
    00279         // Code the dc value of intra blocks
    00280         void CodeVal(const MvData& in_data);
    00281
    00282         // decoding functions
    00283         // Decode the dc value of intra blocks
    00284         void DecodeVal( MvData& out_data);
    00285
    00286         void DoWorkCode( MvData& in_data );
    00287         void DoWorkDecode(MvData& out_data);
    00288
    00289         // Context stuff
    00290         void ResetAll();
    00291
    00292         //prediction stuff
    00293         ValueType Prediction( const TwoDArray<ValueType>& dcdata,
    00294                               const TwoDArray<PredMode>& preddata) const;
    00295     };
    00296
    00297
    00298 }// end namepace dirac
    00299
    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.