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.22 2006/11/13 09:41:44 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 
00079         void InitContexts();
00080 
00081     protected:
00083         inline void CodeVal( PicArray& in_data , const int xpos , const int ypos , const ValueType val);
00084 
00086         inline void DecodeVal(PicArray& out_data , const int xpos , const int ypos );
00087 
00089         void CodeQIndexOffset( const int offset );
00090 
00092         int DecodeQIndexOffset();
00093 
00095         inline void SetToVal( const CodeBlock& code_block , PicArray& pic_data , const ValueType val);
00096 
00098         inline void ClearBlock( const CodeBlock& code_block , PicArray& pic_data);
00099 
00100     private:
00101         //functions
00102         // Overridden from the base class
00103         virtual void DoWorkCode(PicArray& in_data);
00104         // Ditto
00105         virtual void DoWorkDecode(PicArray& out_data);
00106 
00107         virtual void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data);
00108         virtual void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data);
00109 
00110         void ResetAll();
00111 
00113         inline int ChooseFollowContext( const int bin_number ) const;
00114 
00116         inline int ChooseInfoContext() const;
00117 
00119         inline int ChooseSignContext(const PicArray& data , const int xpos , const int ypos ) const;
00120 
00122         BandCodec(const BandCodec& cpy);
00124         BandCodec& operator=(const BandCodec& rhs);
00125 
00126     protected:
00127               
00129         bool m_is_intra;
00130     
00132         int m_bnum;
00133 
00135         const Subband m_node;
00136     
00138         int m_last_qf_idx;
00139 
00141         const int m_vol;
00142     
00144         const int m_reset_coeff_num;
00145     
00147         int m_coeff_count;
00148     
00150         int m_qf;
00151     
00153         ValueType m_offset;
00154 
00156         bool m_nhood_nonzero;
00157     
00159         Subband m_pnode;
00160     
00162         int m_pxp, m_pyp, m_pxl, m_pyl;
00163     
00165         int m_pxpos, m_pypos;
00166     
00168         bool m_parent_notzero;
00169     
00170     };
00171 
00173 
00177     class LFBandCodec: public BandCodec
00178     {
00179     public:
00181 
00188         LFBandCodec(SubbandByteIO* subband_byteio,
00189                     size_t number_of_contexts,
00190                     const SubbandList& band_list,
00191                     int band_num,
00192                     const bool is_intra)
00193                     : BandCodec(subband_byteio,number_of_contexts,band_list,
00194                                 band_num,is_intra){}
00195 
00196     private:
00197         // Overridden from the base class
00198         void DoWorkCode(PicArray& in_data);
00199         // Ditto
00200         void DoWorkDecode(PicArray& out_data);
00201 
00202         void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data);
00203         void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data);
00204 
00206         LFBandCodec(const LFBandCodec& cpy);
00208         LFBandCodec& operator=(const LFBandCodec& rhs);
00209 
00210     };
00211 
00212 
00214     //Finally,special class incorporating prediction for the DC band of intra frames//
00216 
00218 
00222     class IntraDCBandCodec: public BandCodec
00223     {
00224     public:
00226 
00232         IntraDCBandCodec(SubbandByteIO* subband_byteio,
00233                          size_t number_of_contexts,
00234                          const SubbandList& band_list)
00235           : BandCodec(subband_byteio,number_of_contexts,band_list,
00236                       band_list.Length(), true){}
00237 
00238     
00239     private:
00240         void DoWorkCode(PicArray& in_data);                    //overridden from the base class
00241         void DoWorkDecode(PicArray& out_data); //ditto
00242 
00243         void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data);
00244         void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data);
00245 
00247         IntraDCBandCodec(const IntraDCBandCodec& cpy); 
00248 
00250         IntraDCBandCodec& operator=(const IntraDCBandCodec& rhs);
00251 
00253         ValueType GetPrediction(const PicArray& data , const int xpos , const int ypos ) const;
00254 
00255     private:
00256         PicArray m_dc_pred_res;
00257     };
00258 
00259 
00260 }// end namespace dirac
00261 #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.