Dirac - A Video Codec

Created by the British Broadcasting Corporation.


band_codec.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002 *
00003 * $Id: band_codec.h,v 1.26 2007/07/26 12:46:35 tjdwave Exp $ $Name: Dirac_0_9_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 *                 Steve Bearcroft
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 _BAND_CODEC_H_
00042 #define _BAND_CODEC_H_
00043 
00044 #include <libdirac_common/arith_codec.h>
00045 #include <libdirac_common/wavelet_utils.h>
00046 
00047 
00048 namespace dirac
00049 {
00050 
00051    class SubbandByteIO;
00052 
00053     //Subclasses the arithmetic codec to produce a coding/decoding tool for subbands
00054 
00055 
00057 
00060     class BandCodec: public ArithCodec<CoeffArray>
00061     {
00062     public:
00063 
00065 
00073         BandCodec(SubbandByteIO* subband_byteio,
00074                   size_t number_of_contexts,
00075                   const SubbandList& band_list,
00076                   int band_num,
00077                   const bool is_intra);
00078 
00079     protected:
00081         inline void CodeVal( CoeffArray& in_data , const int xpos , const int ypos , const CoeffType val);
00082 
00084         inline void DecodeVal(CoeffArray& out_data , const int xpos , const int ypos );
00085 
00087         void CodeQIndexOffset( const int offset );
00088 
00090         int DecodeQIndexOffset();
00091 
00093         inline void SetToVal( const CodeBlock& code_block , CoeffArray& coeff_data , const CoeffType val);
00094 
00096         inline void ClearBlock( const CodeBlock& code_block , CoeffArray& coeff_data);
00097 
00098     private:
00099         //functions
00100         // Overridden from the base class
00101         virtual void DoWorkCode(CoeffArray& in_data);
00102         // Ditto
00103         virtual void DoWorkDecode(CoeffArray& out_data);
00104 
00105         virtual void CodeCoeffBlock(const CodeBlock& code_block , CoeffArray& in_data);
00106         virtual void DecodeCoeffBlock(const CodeBlock& code_block , CoeffArray& out_data);
00107 
00109         inline int ChooseFollowContext( const int bin_number ) const;
00110 
00112         inline int ChooseInfoContext() const;
00113 
00115         inline int ChooseSignContext(const CoeffArray& data , const int xpos , const int ypos ) const;
00116 
00118         BandCodec(const BandCodec& cpy);
00120         BandCodec& operator=(const BandCodec& rhs);
00121 
00122     protected:
00123               
00125         bool m_is_intra;
00126     
00128         int m_bnum;
00129 
00131         const Subband m_node;
00132     
00134         int m_last_qf_idx;
00135             
00137         int m_qf;
00138     
00140         CoeffType m_offset;
00141 
00143         bool m_nhood_nonzero;
00144     
00146         Subband m_pnode;
00147     
00149         int m_pxp, m_pyp, m_pxl, m_pyl;
00150     
00152         int m_pxpos, m_pypos;
00153     
00155         bool m_parent_notzero;
00156     
00157     };
00158 
00160 
00164     class LFBandCodec: public BandCodec
00165     {
00166     public:
00168 
00176         LFBandCodec(SubbandByteIO* subband_byteio,
00177                     size_t number_of_contexts,
00178                     const SubbandList& band_list,
00179                     int band_num,
00180                     const bool is_intra)
00181                     : BandCodec(subband_byteio,number_of_contexts,band_list,
00182                                 band_num,is_intra){}
00183 
00184     private:
00185         // Overridden from the base class
00186         void DoWorkCode(CoeffArray& in_data);
00187         // Ditto
00188         void DoWorkDecode(CoeffArray& out_data);
00189 
00190         void CodeCoeffBlock(const CodeBlock& code_block , CoeffArray& in_data);
00191         void DecodeCoeffBlock(const CodeBlock& code_block , CoeffArray& out_data);
00192 
00194         LFBandCodec(const LFBandCodec& cpy);
00196         LFBandCodec& operator=(const LFBandCodec& rhs);
00197 
00198     };
00199 
00200 
00202     //Finally,special class incorporating prediction for the DC band of intra frames//
00204 
00206 
00210     class IntraDCBandCodec: public BandCodec
00211     {
00212     public:
00214 
00220         IntraDCBandCodec(SubbandByteIO* subband_byteio,
00221                          size_t number_of_contexts,
00222                          const SubbandList& band_list)
00223           : BandCodec(subband_byteio,number_of_contexts,band_list,
00224                       band_list.Length(), true){}
00225 
00226     
00227     private:
00228         void DoWorkCode(CoeffArray& in_data);                    //overridden from the base class
00229         void DoWorkDecode(CoeffArray& out_data); //ditto
00230 
00231         void CodeCoeffBlock(const CodeBlock& code_block , CoeffArray& in_data);
00232         void DecodeCoeffBlock(const CodeBlock& code_block , CoeffArray& out_data);
00233 
00235         IntraDCBandCodec(const IntraDCBandCodec& cpy); 
00236 
00238         IntraDCBandCodec& operator=(const IntraDCBandCodec& rhs);
00239 
00241         CoeffType GetPrediction(const CoeffArray& data , const int xpos , const int ypos ) const;
00242 
00243     private:
00244         CoeffArray m_dc_pred_res;
00245     };
00246 
00247 
00248 }// end namespace dirac
00249 #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.