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

mxcpcFramewiseMxPEGDecoder.h

00001 //           ///          //                                        Mx clientSDK
00002 //          /////        ////                    Mx Crossplatform Client Library
00003 //         /// XXX     XXX ///
00004 //        ///    XXX XXX    ///     $RCSfile: mxcpcFramewiseMxPEGDecoder.h,v $
00005 //       ///       XXX       ///     $Revision: 1.3 $
00006 //      ///      XXX XXX      ///     $Date: 2005/12/09 15:33:45 $
00007 //     ////    XXX     XXX    ////     $Author: cvs-kai $
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems //////////////////////////////////////////////
00011 //                                                                          //
00012 //  Copyright (C) 2005 - 2006, MOBOTIX AG, Germany                         //
00013 //  This software is made available under the BSD licence. Please refer   //
00014 //  to the file LICENCE.TXT contained in this distribution for details.  //
00015 //                                                                      //
00016 //  /////////////////////////////////////////////////////////////////////
00017 
00018 
00019 
00020 #ifndef __MXCPC_FRAMEWISEMXPEGDECODER_H__
00021 #define __MXCPC_FRAMEWISEMXPEGDECODER_H__
00022 
00023 
00024 
00025 #include <mxcpcMxPEGDecoder.h>
00026 
00027 
00028 
00029 class mxcpcFramewiseMxPEGScanDecoder;
00030 
00031 
00032 
00033 //! Decoder implementation using the classic Mx approach.
00034 /*!
00035  *  \ingroup mxcpc_core
00036  *
00037  *  \note <tt>MXCPC_FRAMEWISEMXPEGDECODER_MAXTILENUM</tt> possibly needs to be
00038  *        adapted 
00039  */
00040 class mxcpcFramewiseMxPEGDecoder : public mxcpcMxPEGDecoder {
00041 
00042  public:
00043   class UndecodedFrameDescriptor {
00044    
00045    public:
00046     int Width, Height;
00047     int TileNumX, TileNumY;
00048     unsigned char *ScanBytes;
00049     int ScanLength;
00050     unsigned char *TileBits;
00051     
00052    public:
00053     
00054     UndecodedFrameDescriptor() { reset(640, 480); }
00055     
00056     void setResolution(int width, int height) {
00057       
00058       if(width < 1)  width = 640;
00059       if(height < 1) height = 480;
00060     
00061       Width  = width;
00062       Height = height;
00063       
00064       TileNumX = width/16;
00065       if(width % 16) TileNumX++;
00066       TileNumY = height/16;
00067       if(height % 16) TileNumY++;
00068     }
00069     
00070     void reset(int width, int height) {
00071     
00072       setResolution(width, height);
00073      
00074       ScanBytes  = 0;
00075       ScanLength = 0;
00076       
00077       TileBits   = 0;
00078     }
00079   };
00080 
00081  private:
00082   enum DecoderState { AwaitSOI,
00083                       AwaitAPP0,
00084                       APP0,
00085                       Determine_FingerPrint_Or_FrameHeader,
00086                       Determine_FingerPrint_Or_FrameHeader2,
00087                       FingerPrint,
00088                       AwaitFrameHeader,
00089                       AwaitFrameHeader2,
00090                       FrameHeader,
00091                       BitMask_Or_Tables,
00092                       QuantizationTable1,
00093                       AwaitQuantizationTable2,
00094                       QuantizationTable2,
00095                       Huffman_Or_SOF,
00096                       SOF,
00097                       HuffmanTable,
00098                       Huffman_Or_Scan,
00099                       Scan,
00100                       Scan2,
00101                       BitMask,
00102                       Tables_Or_Scan,
00103                       Audio_Or_SOI,
00104                       Audio,
00105                       No_Good_State
00106                     };
00107 
00108  private:
00109   
00110   // state machine datafields...
00111   DecoderState State;
00112   unsigned char *CurrentBytePtr;
00113   int BytesLeft;
00114   int AwaitMarkerStage;
00115   int ReadMarkerStage;
00116   unsigned char ReadMarkerFirstLenByte;
00117   int MarkerBytesNeeded;    
00118   int ScanStage;
00119   unsigned char *MarkerPayload;
00120   
00121   UndecodedFrameDescriptor FrameDescriptor;
00122   int Width, Height;
00123   mxcpcFramewiseMxPEGScanDecoder *ScanDecoder;
00124   
00125   unsigned char *PrefetchBuffer;
00126   int PrefetchBuffSize;
00127   int PrefetchedBytes;
00128   
00129  public: 
00130   //! The decoder assumes ownership over all three subcomponents.
00131   mxcpcFramewiseMxPEGDecoder(mxcpcStreamSource *source,
00132                              mxcpcMxPEGDecoderBackEnd *backend,
00133                              mxcpcFramewiseMxPEGScanDecoder *scan_decoder);
00134   ~mxcpcFramewiseMxPEGDecoder();
00135   
00136  public:
00137   //! Reimplemented.
00138   int decode(int num);
00139   
00140  private:
00141   //! Internally used to pump raw MxPEG stream data into the decoder's state
00142   //! machine.
00143   void feedBytes(unsigned char *buffer, int num);
00144   //! Private helper method.
00145   bool awaitMarker(unsigned char *marker_type);
00146   //! Private helper method.
00147   bool readMarkerPayload(void);
00148   //! Private helper method.
00149   bool doScan(void);
00150 };
00151 
00152 
00153 
00154 #endif   // __MXCPC_FRAMEWISEMXPEGDECODER_H__
00155  

Generated on Mon Jan 30 15:52:42 2006 for mxcpc by  doxygen 1.4.4