00001
00038 #ifndef __VETLIB_VETCODEC_IMG_H__
00039 #define __VETLIB_VETCODEC_IMG_H__
00040
00041 #include "../vetDefs.h"
00042 #include "../vetCodec.h"
00043
00044 #include "../vetFrameYUV420.h"
00045 #include "../vetFrameRGB24.h"
00046 #include "../vetFrameT.h"
00047
00048
00049 #define VETRET_CODER_FILEOUT_ER 1010
00050 #define VETRET_CODER_SIZE_ER 1011
00051 #define VETRET_CODER_WRITE_ER 1012
00052 #define VETRET_CODER_PALETTE_ER 1013
00053
00054
00055
00056
00057
00058
00059 class vetCodec_IMGParameters : public vetCodecParameters
00060 {
00061 protected:
00062
00063 int fileNameIndex;
00064 char fileNameBase[128];
00065 bool fileNameProgression;
00066 bool autoOuput;
00067 bool autoInput;
00068 bool doBuffering;
00069
00070
00071 friend class vetCodec_IMG;
00072
00073
00074 public:
00075
00076 vetCodec_IMGParameters();
00077 vetCodec_IMGParameters(char* filename);
00078 ~vetCodec_IMGParameters() { }
00079
00080 void reset();
00081
00082
00095 void setFileNameIndex(int base = -1) { fileNameIndex = base; };
00096
00105 void setFileNameProgression(bool value = true) { fileNameProgression = value; };
00106
00119 void setAutoOutputEnabled(bool value = true) { autoOuput = value; };
00120
00133 void setAutoInputEnabled(bool value = true) { autoInput = value; };
00134
00147 void setDoBuffering(bool value = true) { doBuffering = value; };
00148
00158 void setFileName(const char *filename);
00159
00171 int getFileNameIndex() { return fileNameIndex;};
00180 bool isFileNameProgressionEnabled() { return fileNameProgression; };
00181
00192 bool isAutoInputEnabled() { return autoInput;};
00193
00206 bool isAutoOutputEnabled() { return autoOuput;};
00207
00220 bool isBufferingEnabled() { return doBuffering;};
00221
00234 void getFileName(char *filename);
00235
00244 void getFileNameCurrent(char *filename);
00245
00246
00247
00248 VETRESULT saveToStreamXML(FILE *fp);
00249 VETRESULT loadFromStreamXML(FILE *fp);
00250
00251 };
00252
00253
00254
00255
00256 class vetCodec_IMG : public vetCodec
00257 {
00258 public:
00259
00260
00261 protected:
00262
00263 vetCodec_IMGParameters* myParams;
00264
00265 unsigned int width ;
00266 unsigned int height ;
00267 void *img ;
00268 bool ok ;
00269
00270
00271 char fileNameIndexBuffer[16];
00272 char fileNameBuffer[80];
00273
00274 void doFileNameCurrent();
00275
00276
00277 static void* im_load(char *filename, unsigned int &w, unsigned int &h, char* prog_path) ;
00278 static void im_get_data(void *image, int *rgb) ;
00279 static void im_get_data(void *img, unsigned char *rgb);
00280
00281 static void im_get_data_grey(void *image, int *d) ;
00282 static void im_free(void *img) ;
00283
00284
00285 public:
00286
00287
00291 vetCodec_IMG(vetCodec_IMGParameters* initParams = NULL);
00292
00300 vetCodec_IMG(char* filename);
00301
00302
00303
00311 VETRESULT save();
00312
00322 VETRESULT save(char *filename);
00323
00331 VETRESULT load();
00332
00342 VETRESULT load(char *filename);
00343
00344
00354 VETRESULT setParameters(vetCodec_IMGParameters* initParams);
00355
00361 vetCodec_IMGParameters& getParameters() { return *myParams; };
00362
00363
00364 VETRESULT setFilterParameters (vetFilterParameters* initParams) { return setParameters(static_cast<vetCodec_IMGParameters*>(initParams)); };
00365 vetFilterParameters* getFilterParameters () { return static_cast<vetFilterParameters*>(myParams); };
00366
00373 bool EoF();
00374
00383 void setFileNameProgression(bool value);
00384
00397 void setAutoOutputEnabled(bool value = true);
00398
00411 void setAutoInputEnabled(bool value = true);
00412
00425 void setDoBuffering(bool value = true);
00426
00436 void setFileName(const char *filename);
00437
00438
00450 int getFileNameIndex();
00459 bool isFileNameProgressionEnabled();
00460
00471 bool isAutoInputEnabled();
00472
00485 bool isAutoOutputEnabled();
00486
00499 bool isBufferingEnabled();
00500
00513 void getFileName(char *filename);
00514
00523 void getFileNameCurrent(char *filename);
00524
00525
00532 VETRESULT reset();
00533
00534
00540
00541
00547
00548
00554 VETRESULT setHeight(unsigned int value) { return VETRET_NOT_IMPLEMENTED; };
00555
00561 VETRESULT setWidth(unsigned int value) { return VETRET_NOT_IMPLEMENTED; };
00562
00563
00564 long getVideoStreamLength(int stream = -1) { return -1; };
00565 long getAudioStreamLength(int stream = -1) { return -1; };
00566
00567 int getAudioStreamCount() { return -1; };
00568 int getVideoStreamCount() { return -1; };
00569
00570 bool hasAudio() { return false; };
00571 bool hasVideo() { return false; };
00572
00586 VETRESULT extractTo(vetFrameYUV420& img);
00587
00601 VETRESULT extractTo(vetFrameRGB24& img);
00602
00603
00617 VETRESULT extractTo(vetFrameT<unsigned char>& img);
00618
00619
00620
00633 VETRESULT importFrom(vetFrameYUV420& img );
00634
00647 VETRESULT importFrom(vetFrameRGB24& img);
00648
00649
00662 VETRESULT importFrom(vetFrameT<unsigned char>& img);
00663
00664
00665
00666
00677 static VETRESULT save(vetFrameYUV420 &source, const char *filename);
00678
00689 static VETRESULT save(vetFrameRGB24 &source, const char *filename);
00690
00701 static VETRESULT save(vetFrameT<unsigned char> &source, const char *filename);
00702
00703
00714 static VETRESULT load(vetFrameYUV420 &source, const char *filename);
00715
00726 static VETRESULT load(vetFrameRGB24& source, const char *filename);
00727
00738 static VETRESULT load(vetFrameT<unsigned char>& source, const char *filename);
00739
00740
00741 bool isEncodingAvailable() { return false; };
00742 bool isDecodingAvailable() { return true; };
00743
00744 };
00745
00746
00747
00748
00749
00750
00751 #endif //__VETLIB_VETCODEC_IMG_H__