OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Functions
ossimJpegMemSrc.h File Reference
#include <ossim/base/ossimConstants.h>
#include <cstdlib>

Go to the source code of this file.

Functions

OSSIM_DLL void ossimJpegErrorExit (jpeg_common_struct *cinfo)
 Error routine that will replace jpeg's standard error_exit method. More...
 
OSSIM_DLL void ossimJpegMemorySrc (jpeg_decompress_struct *cinfo, const ossim_uint8 *buffer, std::size_t bufsize)
 Method which uses memory instead of a FILE* to read from. More...
 

Function Documentation

◆ ossimJpegErrorExit()

OSSIM_DLL void ossimJpegErrorExit ( jpeg_common_struct *  cinfo)

Error routine that will replace jpeg's standard error_exit method.

Definition at line 32 of file ossimJpegCodec.cpp.

References ossimJpegErrorMgr::setjmp_buffer.

Referenced by ossimJpegCodec::decodeJpeg(), and ossimJpegCodec::getColorSpace().

33 {
34  /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
35  ossimJpegErrorPtr myerr = (ossimJpegErrorPtr) cinfo->err;
36 
37  /* Always display the message. */
38  /* We could postpone this until after returning, if we chose. */
39  (*cinfo->err->output_message) (cinfo);
40 
41  /* Return control to the setjmp point */
42  longjmp(myerr->setjmp_buffer, 1);
43 }
struct ossimJpegErrorMgr * ossimJpegErrorPtr

◆ ossimJpegMemorySrc()

OSSIM_DLL void ossimJpegMemorySrc ( jpeg_decompress_struct *  cinfo,
const ossim_uint8 buffer,
std::size_t  bufsize 
)

Method which uses memory instead of a FILE* to read from.

Note
Used in place of "jpeg_stdio_src(&cinfo, infile)".
"unsigned char = JOCTET

Definition at line 148 of file ossimJpegMemSrc.cpp.

References fill_input_buffer(), init_source(), ossimJpegSourceMgr::pub, skip_input_data(), and term_source().

Referenced by ossimJpegCodec::decodeJpeg(), and ossimJpegCodec::getColorSpace().

151 {
153 
154  /* The source object is made permanent so that a series of JPEG images
155  * can be read from a single buffer by calling jpeg_memory_src
156  * only before the first one.
157  * This makes it unsafe to use this manager and a different source
158  * manager serially with the same JPEG object. Caveat programmer.
159  */
160  if (cinfo->src == NULL) { /* first time for this JPEG object? */
161  cinfo->src = (struct jpeg_source_mgr *)
162  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
163  sizeof(ossimJpegSourceMgr));
164  }
165 
166  src = (ossimJpegSourceMgrPtr) cinfo->src;
167  src->pub.init_source = init_source;
168  src->pub.fill_input_buffer = fill_input_buffer;
169  src->pub.skip_input_data = skip_input_data;
170  src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
171  src->pub.term_source = term_source;
172 
173  src->pub.next_input_byte = buffer;
174  src->pub.bytes_in_buffer = bufsize;
175 }
ossimJpegSourceMgr * ossimJpegSourceMgrPtr
void init_source(j_decompress_ptr)
void term_source(j_decompress_ptr)
boolean fill_input_buffer(j_decompress_ptr cinfo)
void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
struct jpeg_source_mgr pub