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.13 2005/04/06 14:31:10 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 _BAND_CODEC_H_
00039 #define _BAND_CODEC_H_
00040 
00041 #include <libdirac_common/arith_codec.h>
00042 #include <libdirac_common/wavelet_utils.h>
00043 
00044 namespace dirac
00045 {
00046 
00047     //Subclasses the arithmetic codec to produce a coding/decoding tool for subbands
00048 
00049 
00051 
00054     class BandCodec: public ArithCodec<PicArray >
00055     {
00056     public:
00057 
00059 
00066         BandCodec(BasicOutputManager* bits_out,
00067                   size_t number_of_contexts,
00068                   const SubbandList& band_list,
00069                   int band_num);
00070 
00072 
00079         BandCodec(BitInputManager* bits_in,
00080                   size_t number_of_contexts,
00081                   const SubbandList& band_list,
00082                   int band_num);
00083 
00085         void InitContexts();
00086 
00087     protected:
00089         void CodeVal( PicArray& in_data , const int xpos , const int ypos , const ValueType val);
00090 
00092         void DecodeVal(PicArray& out_data , const int xpos , const int ypos );
00093 
00095         void SetToVal( const CodeBlock& code_block , PicArray& pic_data , const ValueType val);
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 
00107         void ResetAll();
00108     
00109         int ChooseContext( const int bin_number) const;
00110         int ChooseSignContext(const PicArray& data , const int xpos , const int ypos ) const;
00111 
00113         BandCodec(const BandCodec& cpy);
00115         BandCodec& operator=(const BandCodec& rhs);
00116 
00117     protected:
00119         int m_bnum;
00120 
00122         const Subband m_node;
00123     
00125         int m_vol;
00126     
00128         int m_reset_coeff_num;
00129     
00131         int m_coeff_count;
00132     
00134         int m_qf, m_qfinv;
00135     
00137         ValueType m_offset;
00138     
00140         ValueType m_nhood_sum;
00141     
00143         Subband m_pnode;
00144     
00146         int m_pxp, m_pyp, m_pxl, m_pyl;
00147     
00149         int m_pxpos, m_pypos;
00150     
00152         bool m_parent_notzero;
00153     
00155         ValueType m_cut_off_point;
00156     };
00157 
00159 
00163     class LFBandCodec: public BandCodec
00164     {
00165     public:
00167 
00174         LFBandCodec(BasicOutputManager* bits_out,
00175                     size_t number_of_contexts,
00176                     const SubbandList& band_list,
00177                     int band_num)
00178               : BandCodec(bits_out,number_of_contexts,band_list,band_num){}
00179 
00181 
00188         LFBandCodec(BitInputManager* bits_in,
00189                     size_t number_of_contexts,
00190                     const SubbandList& band_list,
00191                     int band_num)
00192           : BandCodec(bits_in,number_of_contexts,band_list,band_num){}
00193 
00194     private:
00195         // Overridden from the base class
00196         void DoWorkCode(PicArray& in_data);
00197         // Ditto
00198         void DoWorkDecode(PicArray& out_data);
00199 
00200         void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data);
00201         void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data);
00202 
00204         LFBandCodec(const LFBandCodec& cpy);
00206         LFBandCodec& operator=(const LFBandCodec& rhs);
00207 
00208     };
00209 
00210 
00212     //Finally,special class incorporating prediction for the DC band of intra frames//
00214 
00216 
00220     class IntraDCBandCodec: public BandCodec
00221     {
00222     public:
00224 
00230         IntraDCBandCodec(BasicOutputManager* bits_out,
00231                          size_t number_of_contexts,
00232                          const SubbandList& band_list)
00233           : BandCodec(bits_out,number_of_contexts,band_list,band_list.Length()){}
00234 
00236 
00242         IntraDCBandCodec(BitInputManager* bits_in,
00243                          size_t number_of_contexts,
00244                          const SubbandList& band_list)
00245           : BandCodec(bits_in,number_of_contexts,band_list,band_list.Length()){}
00246 
00247     private:
00248         void DoWorkCode(PicArray& in_data);                    //overridden from the base class
00249         void DoWorkDecode(PicArray& out_data); //ditto
00250 
00251         void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data);
00252         void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data);
00253 
00255         IntraDCBandCodec(const IntraDCBandCodec& cpy); 
00256 
00258         IntraDCBandCodec& operator=(const IntraDCBandCodec& rhs);
00259 
00261         ValueType GetPrediction(const PicArray& data , const int xpos , const int ypos ) const;
00262 
00263     private:
00264         PicArray m_dc_pred_res;
00265     };
00266 
00267 
00268 }// end namespace dirac
00269 #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.