G4RTJpegCoder.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 //
00030 
00031 // class description:
00032 //
00033 //  This class converts 8 bit unsighned ints array to JPEG code.
00034 //
00035 
00036 #ifndef G4RTJpegCoder_H
00037 #define G4RTJpegCoder_H 1
00038 #include "G4RTJpeg.hh"
00039 
00040 //HuffmanTable
00041 struct
00042 G4HuffmanCodeTable
00043 {
00044         int     numOfElement;
00045         int*    SizeT;
00046         int*    CodeT;
00047 };
00048 
00049 class G4OutBitStream;
00050 
00051 class G4JpegCoder
00052 {
00053   public:
00054     G4JpegCoder(u_char* colorR,u_char* colorG,u_char* colorB);
00055     ~G4JpegCoder(void);
00056 
00057     void GetJpegData(char** aJpegData,int& size);
00058 
00059     void SetJpegProperty(const G4JpegProperty& aProperty);
00060 
00061     int DoCoding(void);
00062 
00063 
00064   protected:
00065         u_char* mRgb[3];
00066         int mYBlock[4][64];
00067         int mCbBlock[64];
00068         int mCrBlock[64];
00069         double mCosT[8][8];
00070         int mDCTData[64];
00071         int mPreDC[3];
00072 
00073         G4JpegProperty mProperty;
00074         int mNumVUnits;
00075         int mNumHUnits;
00076 
00077         G4OutBitStream *mOBSP;
00078 
00079         void CodeMCU();
00080 
00081         void makeYCC(int ux,int uy);
00082 
00083         void CodeHuffman(int cs);
00084 
00085         void ForwardDCT(int* picData);
00086 
00087         void Quantization(int cs);
00088 
00089         void WriteHeader(void);
00090         void WriteEOI(void);
00091 };
00092 
00093 const u_int JFIFLength = 16;
00094 const u_int JFIFVersion = 0x0102;     //JFIF Ver 1.02
00095 const u_char YSampleF = 0x22;
00096 const u_char CSampleF = 0x11;
00097 
00098 #endif

Generated on Mon May 27 17:49:46 2013 for Geant4 by  doxygen 1.4.7