Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/libjpeg/jdatasrc.c

    r2 r846  
    33 *
    44 * Copyright (C) 1994-1996, Thomas G. Lane.
     5 * Modified 2009 by Guido Vollbeding.
    56 * This file is part of the Independent JPEG Group's software.
    67 * For conditions of distribution and use, see the accompanying README file.
    78 *
    89 * This file contains decompression data source routines for the case of
    9  * reading JPEG data from a file (or any stdio stream).  While these routines
    10  * are sufficient for most applications, some will want to use a different
    11  * source manager.
     10 * reading JPEG data from memory or from a file (or any stdio stream).
     11 * While these routines are sufficient for most applications,
     12 * some will want to use a different source manager.
    1213 * IMPORTANT: we assume that fread() will correctly transcribe an array of
    1314 * JOCTETs from 8-bit-wide elements on external storage.  If char is wider
     
    5152   */
    5253  src->start_of_file = TRUE;
     54}
     55
     56METHODDEF(void)
     57init_mem_source (j_decompress_ptr cinfo)
     58{
     59  /* no work necessary here */
    5360}
    5461
     
    112119}
    113120
     121METHODDEF(boolean)
     122fill_mem_input_buffer (j_decompress_ptr cinfo)
     123{
     124  static JOCTET mybuffer[4];
     125
     126  /* The whole JPEG data is expected to reside in the supplied memory
     127   * buffer, so any request for more data beyond the given buffer size
     128   * is treated as an error.
     129   */
     130  WARNMS(cinfo, JWRN_JPEG_EOF);
     131  /* Insert a fake EOI marker */
     132  mybuffer[0] = (JOCTET) 0xFF;
     133  mybuffer[1] = (JOCTET) JPEG_EOI;
     134
     135  cinfo->src->next_input_byte = mybuffer;
     136  cinfo->src->bytes_in_buffer = 2;
     137
     138  return TRUE;
     139}
     140
    114141
    115142/*
     
    128155skip_input_data (j_decompress_ptr cinfo, long num_bytes)
    129156{
    130   my_src_ptr src = (my_src_ptr) cinfo->src;
     157  struct jpeg_source_mgr * src = cinfo->src;
    131158
    132159  /* Just a dumb implementation for now.  Could use fseek() except
     
    135162   */
    136163  if (num_bytes > 0) {
    137     while (num_bytes > (long) src->pub.bytes_in_buffer) {
    138       num_bytes -= (long) src->pub.bytes_in_buffer;
     164    while (num_bytes > (long) src->bytes_in_buffer) {
     165      num_bytes -= (long) src->bytes_in_buffer;
    139166      (void) fill_input_buffer(cinfo);
    140167      /* note we assume that fill_input_buffer will never return FALSE,
     
    142169       */
    143170    }
    144     src->pub.next_input_byte += (size_t) num_bytes;
    145     src->pub.bytes_in_buffer -= (size_t) num_bytes;
     171    src->next_input_byte += (size_t) num_bytes;
     172    src->bytes_in_buffer -= (size_t) num_bytes;
    146173  }
    147174}
     
    211238  src->pub.next_input_byte = NULL; /* until buffer loaded */
    212239}
     240
     241
     242/*
     243 * Prepare for input from a supplied memory buffer.
     244 * The buffer must contain the whole JPEG data.
     245 */
     246
     247GLOBAL(void)
     248jpeg_mem_src (j_decompress_ptr cinfo,
     249              unsigned char * inbuffer, unsigned long insize)
     250{
     251  struct jpeg_source_mgr * src;
     252
     253  if (inbuffer == NULL || insize == 0)  /* Treat empty input as fatal error */
     254    ERREXIT(cinfo, JERR_INPUT_EMPTY);
     255
     256  /* The source object is made permanent so that a series of JPEG images
     257   * can be read from the same buffer by calling jpeg_mem_src only before
     258   * the first one.
     259   */
     260  if (cinfo->src == NULL) {     /* first time for this JPEG object? */
     261    cinfo->src = (struct jpeg_source_mgr *)
     262      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
     263                                  SIZEOF(struct jpeg_source_mgr));
     264  }
     265
     266  src = cinfo->src;
     267  src->init_source = init_mem_source;
     268  src->fill_input_buffer = fill_mem_input_buffer;
     269  src->skip_input_data = skip_input_data;
     270  src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
     271  src->term_source = term_source;
     272  src->bytes_in_buffer = (size_t) insize;
     273  src->next_input_byte = (JOCTET *) inbuffer;
     274}
Note: See TracChangeset for help on using the changeset viewer.