src/share/native/sun/awt/splashscreen/splashscreen_jpeg.c

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include "splashscreen_impl.h"
  27 
  28 #include "jinclude.h"
  29 #include "jpeglib.h"
  30 #include "jerror.h"
  31 
  32 #include <setjmp.h>
  33 
  34 /* stream input handling */
  35 
  36 typedef struct
  37 {
  38     struct jpeg_source_mgr pub; /* public fields */
  39     SplashStream * stream;      /* source stream */
  40     JOCTET *buffer;             /* start of buffer */
  41     boolean start_of_file;      /* have we gotten any data yet? */
  42 } stream_source_mgr;
  43 
  44 typedef stream_source_mgr *stream_src_ptr;
  45 
  46 #define INPUT_BUF_SIZE  4096    /* choose an efficiently fread'able size */
  47 
  48 METHODDEF(void)


  90             (void) stream_fill_input_buffer(cinfo);
  91         }
  92         src->pub.next_input_byte += (size_t) num_bytes;
  93         src->pub.bytes_in_buffer -= (size_t) num_bytes;
  94     }
  95 }
  96 
  97 METHODDEF(void)
  98 stream_term_source(j_decompress_ptr cinfo)
  99 {
 100 }
 101 
 102 static void
 103 set_stream_src(j_decompress_ptr cinfo, SplashStream * stream)
 104 {
 105     stream_src_ptr src;
 106 
 107     if (cinfo->src == NULL) {   /* first time for this JPEG object? */
 108         cinfo->src = (struct jpeg_source_mgr *)
 109             (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
 110             JPOOL_PERMANENT, SIZEOF(stream_source_mgr));
 111         src = (stream_src_ptr) cinfo->src;
 112         src->buffer = (JOCTET *)
 113             (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
 114             JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET));
 115     }
 116 
 117     src = (stream_src_ptr) cinfo->src;
 118     src->pub.init_source = stream_init_source;
 119     src->pub.fill_input_buffer = stream_fill_input_buffer;
 120     src->pub.skip_input_data = stream_skip_input_data;
 121     src->pub.resync_to_restart = jpeg_resync_to_restart;        /* use default method */
 122     src->pub.term_source = stream_term_source;
 123     src->stream = stream;
 124     src->pub.bytes_in_buffer = 0;       /* forces fill_input_buffer on first read */
 125     src->pub.next_input_byte = NULL;    /* until buffer loaded */
 126 }
 127 
 128 int
 129 SplashDecodeJpeg(Splash * splash, struct jpeg_decompress_struct *cinfo)
 130 {
 131     int rowStride, stride;
 132     JSAMPARRAY buffer;
 133     ImageFormat srcFormat;
 134 




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include "splashscreen_impl.h"
  27 

  28 #include "jpeglib.h"
  29 #include "jerror.h"
  30 
  31 #include <setjmp.h>
  32 
  33 /* stream input handling */
  34 
  35 typedef struct
  36 {
  37     struct jpeg_source_mgr pub; /* public fields */
  38     SplashStream * stream;      /* source stream */
  39     JOCTET *buffer;             /* start of buffer */
  40     boolean start_of_file;      /* have we gotten any data yet? */
  41 } stream_source_mgr;
  42 
  43 typedef stream_source_mgr *stream_src_ptr;
  44 
  45 #define INPUT_BUF_SIZE  4096    /* choose an efficiently fread'able size */
  46 
  47 METHODDEF(void)


  89             (void) stream_fill_input_buffer(cinfo);
  90         }
  91         src->pub.next_input_byte += (size_t) num_bytes;
  92         src->pub.bytes_in_buffer -= (size_t) num_bytes;
  93     }
  94 }
  95 
  96 METHODDEF(void)
  97 stream_term_source(j_decompress_ptr cinfo)
  98 {
  99 }
 100 
 101 static void
 102 set_stream_src(j_decompress_ptr cinfo, SplashStream * stream)
 103 {
 104     stream_src_ptr src;
 105 
 106     if (cinfo->src == NULL) {   /* first time for this JPEG object? */
 107         cinfo->src = (struct jpeg_source_mgr *)
 108             (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
 109             JPOOL_PERMANENT, sizeof(stream_source_mgr));
 110         src = (stream_src_ptr) cinfo->src;
 111         src->buffer = (JOCTET *)
 112             (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
 113             JPOOL_PERMANENT, INPUT_BUF_SIZE * sizeof(JOCTET));
 114     }
 115 
 116     src = (stream_src_ptr) cinfo->src;
 117     src->pub.init_source = stream_init_source;
 118     src->pub.fill_input_buffer = stream_fill_input_buffer;
 119     src->pub.skip_input_data = stream_skip_input_data;
 120     src->pub.resync_to_restart = jpeg_resync_to_restart;        /* use default method */
 121     src->pub.term_source = stream_term_source;
 122     src->stream = stream;
 123     src->pub.bytes_in_buffer = 0;       /* forces fill_input_buffer on first read */
 124     src->pub.next_input_byte = NULL;    /* until buffer loaded */
 125 }
 126 
 127 int
 128 SplashDecodeJpeg(Splash * splash, struct jpeg_decompress_struct *cinfo)
 129 {
 130     int rowStride, stride;
 131     JSAMPARRAY buffer;
 132     ImageFormat srcFormat;
 133