Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members

mxcpcFramewiseMxPEGDecoder.h

00001 //           ///          //
00002 //          /////        ////
00003 //         /// XXX     XXX ///
00004 //        ///    XXX XXX    ///     $RCSfile: mxcpcFramewiseMxPEGDecoder.h,v $  
00005 //       ///       XXX       ///     $Revision: 1.6 $
00006 //      ///      XXX XXX      ///     $Date: 2005/08/09 13:57:26 $
00007 //     ////    XXX     XXX    ////     $Author: cvs-steve $
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems ///////////////////////////////////////////////
00011 
00012 
00013 
00014 #ifndef __MXCPC_FRAMEWISEMXPEGDECODER_H__
00015 #define __MXCPC_FRAMEWISEMXPEGDECODER_H__
00016 
00017 
00018 
00019 #include <mxcpcMxPEGDecoder.h>
00020 
00021 
00022 
00023 class mxcpcFramewiseMxPEGScanDecoder;
00024 
00025 
00026 
00028 //           ///          //
00029 //          /////        ////
00030 //         /// XXX     XXX ///
00031 //        ///    XXX XXX    ///     $RCSfile: mxcpcFramewiseMxPEGDecoder.h,v $  
00032 //       ///       XXX       ///     $Revision: 1.6 $
00033 //      ///      XXX XXX      ///     $Date: 2005/08/09 13:57:26 $
00034 //     ////    XXX     XXX    ////     $Author: cvs-steve $
00035 //    ////                     ////
00036 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00037 //  //// Security Vision Systems ///////////////////////////////////////////////
00038 
00039 // Copyright (c) 2005, MOBOTIX AG.
00040 // This software is made available under the BSD licence. Please refer 
00041 // to the file LICENCE.TXT contained in this distribution for details.
00042 
00049 class mxcpcFramewiseMxPEGDecoder : public mxcpcMxPEGDecoder {
00050 
00051  public:
00052   class UndecodedFrameDescriptor {
00053    
00054    public:
00055     int Width, Height;
00056     int TileNumX, TileNumY;
00057     unsigned char *ScanBytes;
00058     int ScanLength;
00059     unsigned char *TileBits;
00060     
00061    public:
00062     
00063     UndecodedFrameDescriptor() { reset(640, 480); }
00064     
00065     void setResolution(int width, int height) {
00066       
00067       if(width < 1)  width = 640;
00068       if(height < 1) height = 480;
00069     
00070       Width  = width;
00071       Height = height;
00072       
00073       TileNumX = width/16;
00074       if(width % 16) TileNumX++;
00075       TileNumY = height/16;
00076       if(height % 16) TileNumY++;
00077     }
00078     
00079     void reset(int width, int height) {
00080     
00081       setResolution(width, height);
00082      
00083       ScanBytes  = 0;
00084       ScanLength = 0;
00085       
00086       TileBits   = 0;
00087     }
00088   };
00089 
00090  private:
00091   enum DecoderState { AwaitSOI,
00092                       AwaitAPP0,
00093                       APP0,
00094                       Determine_FingerPrint_Or_FrameHeader,
00095                       Determine_FingerPrint_Or_FrameHeader2,
00096                       FingerPrint,
00097                       AwaitFrameHeader,
00098                       AwaitFrameHeader2,
00099                       FrameHeader,
00100                       BitMask_Or_Tables,
00101                       QuantizationTable1,
00102                       AwaitQuantizationTable2,
00103                       QuantizationTable2,
00104                       Huffman_Or_SOF,
00105                       SOF,
00106                       HuffmanTable,
00107                       Huffman_Or_Scan,
00108                       Scan,
00109                       Scan2,
00110                       BitMask,
00111                       Tables_Or_Scan,
00112                       Audio_Or_SOI,
00113                       Audio,
00114                       No_Good_State
00115                     };
00116 
00117  private:
00118   
00119   // state machine datafields...
00120   DecoderState State;
00121   unsigned char *CurrentBytePtr;
00122   int BytesLeft;
00123   int AwaitMarkerStage;
00124   int ReadMarkerStage;
00125   unsigned char ReadMarkerFirstLenByte;
00126   int MarkerBytesNeeded;    
00127   int ScanStage;
00128   unsigned char *MarkerPayload;
00129   
00130   UndecodedFrameDescriptor FrameDescriptor;
00131   int Width, Height;
00132   mxcpcFramewiseMxPEGScanDecoder *ScanDecoder;
00133   
00134   unsigned char *PrefetchBuffer;
00135   int PrefetchBuffSize;
00136   int PrefetchedBytes;
00137   
00138  public: 
00140   mxcpcFramewiseMxPEGDecoder(mxcpcStreamSource *source,
00141                              mxcpcMxPEGDecoderBackEnd *backend,
00142                              mxcpcFramewiseMxPEGScanDecoder *scan_decoder);
00143   ~mxcpcFramewiseMxPEGDecoder();
00144   
00145  public:
00147   int decode(int num);
00148   
00149  private:
00152   void feedBytes(unsigned char *buffer, int num);
00154   bool awaitMarker(unsigned char *marker_type);
00156   bool readMarkerPayload(void);
00158   bool doScan(void);
00159 };
00160 
00161 
00162 
00163 #endif   // __MXCPC_FRAMEWISEMXPEGDECODER_H__
00164  

Generated on Mon Aug 15 03:39:29 2005 for mxcpc by  doxygen 1.4.2-20050421