JPEGEncoder.h

Go to the documentation of this file.
00001 //
00002 // Copyright 2003 Sony Corporation 
00003 //
00004 // Permission to use, copy, modify, and redistribute this software for
00005 // non-commercial use is hereby granted.
00006 //
00007 // This software is provided "as is" without warranty of any kind,
00008 // either expressed or implied, including but not limited to the
00009 // implied warranties of fitness for a particular purpose.
00010 //
00011 
00012 #ifndef JPEGEncoder_h_DEFINED
00013 #define JPEGEncoder_h_DEFINED
00014 
00015 #include <list>
00016 using std::list;
00017 #include <OPENR/ODataFormats.h>
00018 #include <ant.h>
00019 
00020 class JPEGEncoder {
00021 public:
00022     JPEGEncoder();
00023     ~JPEGEncoder() {}
00024 
00025     bool Init(const antStackRef& ipstack);
00026     bool GetJPEG(OFbkImageVectorData* imageVec,
00027                  OFbkImageLayer layer, bool reconstruction,
00028                  int quality, byte** jpeg, int* size);
00029     void FreeJPEG(byte* jpeg);
00030     
00031     // for libjpeg test
00032     void Save(OFbkImageVectorData* imageVec,
00033               OFbkImageLayer layer, int quality, char* path);
00034 
00035     static const int NUM_JPEG_BUF  = 4;
00036 
00037 private:
00038     //
00039     // [ERS-210/220]
00040     // bytes/pixel : 3
00041     // width       : 176 x 2
00042     // height      : 144 x 2
00043     //
00044     // [ERS-7]
00045     // bytes/pixel : 3
00046     // width       : 208 x 2
00047     // height      : 160 x 2
00048     //
00049     static const int IMAGE_BUFSIZE = 3*(2*208)*(2*160);
00050     static const int JPEG_BUFSIZE  = 64*1024;
00051     byte* Allocate();
00052     void  Free(byte* buf);
00053 
00054     void ConvertYCbCr(OFbkImageVectorData* imageVec,
00055                       OFbkImageLayer layer, byte* image,
00056                       int* width, int* height);
00057     void ReconstructAndConvertYCbCr(OFbkImageVectorData* imageVec,
00058                                     OFbkImageLayer layer, byte* image,
00059                                     int* width, int* height);
00060     
00061     void PutYCbCrPixel(byte* img, int w,
00062                        int x, int y, byte ypix, byte cb, byte cr) {
00063         byte* ptr = img + 3 * (w * y + x);
00064         ptr[0] = ypix;
00065         ptr[1] = cb;
00066         ptr[2] = cr;
00067     }
00068 
00069     byte ClipRange(int val) {
00070         if (val < 0)        { return 0;         }
00071         else if (val > 255) { return 255;       }
00072         else                { return (byte)val; }
00073     }
00074 
00075     antStackRef     ipstackRef;
00076     byte*           pixelInterleavedYCbCr;
00077     antSharedBuffer jpegBuf[NUM_JPEG_BUF];
00078     list<byte*>     freeJpegBufList;
00079 };
00080 
00081 #endif // JPEGEncoder_h_DEFINED

Generated on Sun Dec 2 23:04:28 2007 for openSDK by  doxygen 1.3.9.1