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.24 2007/03/01 09:24:32 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 *                 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<PicArray>
00061     {
00062     public:
00063 
00065 
00072         BandCodec(SubbandByteIO* subband_byteio,
00073                   size_t number_of_contexts,
00074                   const SubbandList& band_list,
00075                   int band_num,
00076                   const bool is_intra);
00077 
00078     protected:
00080         inline void CodeVal( PicArray& in_data , const int xpos , const int ypos , const ValueType val);
00081 
00083         inline void DecodeVal(PicArray& out_data , const int xpos , const int ypos );
00084 
00086         void CodeQIndexOffset( const int offset );
00087 
00089         int DecodeQIndexOffset();
00090 
00092         inline void SetToVal( const CodeBlock& code_block , PicArray& pic_data , const ValueType val);
00093 
00095         inline void ClearBlock( const CodeBlock& code_block , PicArray& pic_data);
00096 
00097     private:
00098         //functions
00099         // Overridden from the base class
00100         virtual void DoWorkCode(PicArray& in_data);
00101         // Ditto
00102         virtual void DoWorkDecode(PicArray& out_data);
00103 
00104         virtual void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data);
00105         virtual void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data);
00106 
00108         inline int ChooseFollowContext( const int bin_number ) const;
00109 
00111         inline int ChooseInfoContext() const;
00112 
00114         inline int ChooseSignContext(const PicArray& data , const int xpos , const int ypos ) const;
00115 
00117         BandCodec(const BandCodec& cpy);
00119         BandCodec& operator=(const BandCodec& rhs);
00120 
00121     protected:
00122               
00124         bool m_is_intra;
00125     
00127         int m_bnum;
00128 
00130         const Subband m_node;
00131     
00133         int m_last_qf_idx;
00134             
00136         int m_qf;
00137     
00139         ValueType m_offset;
00140 
00142         bool m_nhood_nonzero;
00143     
00145         Subband m_pnode;
00146     
00148         int m_pxp, m_pyp, m_pxl, m_pyl;
00149     
00151         int m_pxpos, m_pypos;
00152     
00154         bool m_parent_notzero;
00155     
00156     };
00157 
00159 
00163     class LFBandCodec: public BandCodec
00164     {
00165     public:
00167 
00174         LFBandCodec(SubbandByteIO* subband_byteio,
00175                     size_t number_of_contexts,
00176                     const SubbandList& band_list,
00177                     int band_num,
00178                     const bool is_intra)
00179                     : BandCodec(subband_byteio,number_of_contexts,band_list,
00180                                 band_num,is_intra){}
00181 
00182     private:
00183         // Overridden from the base class
00184         void DoWorkCode(PicArray& in_data);
00185         // Ditto
00186         void DoWorkDecode(PicArray& out_data);
00187 
00188         void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data);
00189         void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data);
00190 
00192         LFBandCodec(const LFBandCodec& cpy);
00194         LFBandCodec& operator=(const LFBandCodec& rhs);
00195 
00196     };
00197 
00198 
00200     //Finally,special class incorporating prediction for the DC band of intra frames//
00202 
00204 
00208     class IntraDCBandCodec: public BandCodec
00209     {
00210     public:
00212 
00218         IntraDCBandCodec(SubbandByteIO* subband_byteio,
00219                          size_t number_of_contexts,
00220                          const SubbandList& band_list)
00221           : BandCodec(subband_byteio,number_of_contexts,band_list,
00222                       band_list.Length(), true){}
00223 
00224     
00225     private:
00226         void DoWorkCode(PicArray& in_data);                    //overridden from the base class
00227         void DoWorkDecode(PicArray& out_data); //ditto
00228 
00229         void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data);
00230         void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data);
00231 
00233         IntraDCBandCodec(const IntraDCBandCodec& cpy); 
00234 
00236         IntraDCBandCodec& operator=(const IntraDCBandCodec& rhs);
00237 
00239         ValueType GetPrediction(const PicArray& data , const int xpos , const int ypos ) const;
00240 
00241     private:
00242         PicArray m_dc_pred_res;
00243     };
00244 
00245 
00246 }// end namespace dirac
00247 #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.