core/vil/file_formats/vil_jpeg_decompressor.h
Go to the documentation of this file.
00001 // This is core/vil/file_formats/vil_jpeg_decompressor.h
00002 #ifndef vil_jpeg_decompressor_h_
00003 #define vil_jpeg_decompressor_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author fsm
00010 // \verbatim
00011 //  Modifications
00012 //     11 Oct 2002 Ian Scott - converted to vil
00013 //\endverbatim
00014 
00015 #include <vil/file_formats/vil_jpeglib.h>
00016 class vil_stream;
00017 
00018 class vil_jpeg_decompressor
00019 {
00020  public:
00021   struct jpeg_error_mgr         jerr;
00022   struct jpeg_decompress_struct jobj;
00023   vil_stream *stream;
00024 
00025   vil_jpeg_decompressor(vil_stream *s);
00026 
00027   //:
00028   // NB. does not delete the stream.
00029   ~vil_jpeg_decompressor();
00030 
00031   //:
00032   // Do \e not delete the return value. Leave it alone.
00033   // The return value is zero on failure.
00034   // It should cost nothing to read the same scanline twice in succession.
00035   JSAMPLE const *read_scanline(unsigned line);
00036 
00037  private:
00038   bool ready; // true if decompression has started but not finished.
00039   bool valid; // true if last scanline read was successful.
00040 
00041   // It's not worth the effort using JPEG to allocate the buffer using the
00042   // jobj.mem->alloc_sarray method, because it would have to be reallocated
00043   // after each call to jpeg_finish_decompress(). The symptom of not doing
00044   // so is a nasty heap corruption which only shows up later in unrelated
00045   // code.
00046   JSAMPLE *biffer;   // pointer to scanline buffer.
00047 };
00048 
00049 #endif // vil_jpeg_decompressor_h_