src/java.desktop/share/native/libjavajpeg/jdapistd.c
author jiefu
Fri, 15 Nov 2019 20:39:26 +0800
changeset 59110 8c4c358272a9
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234232: [TESTBUG] gc/shenandoah/jvmti/TestHeapDump.java fails with -Xcomp Reviewed-by: zgu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * jdapistd.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * Copyright (C) 1994-1996, Thomas G. Lane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This file is part of the Independent JPEG Group's software.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * For conditions of distribution and use, see the accompanying README file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * This file contains application interface code for the decompression half
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * of the JPEG library.  These are the "standard" API routines that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * used in the normal full-decompression case.  They are not used by a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * transcoding-only application.  Note that if an application links in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * jpeg_start_decompress, it will end up linking in the entire decompressor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * We thus must separate this file from jdapimin.c to avoid linking the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * whole decompression library into a transcoder.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
#define JPEG_INTERNALS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
#include "jinclude.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
#include "jpeglib.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/* Forward declarations */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Decompression initialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * jpeg_read_header must be completed before calling this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * If a multipass operating mode was selected, this will do all but the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * last pass, and thus may take a great deal of time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Returns FALSE if suspended.  The return value need be inspected only if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * a suspending data source is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
GLOBAL(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
jpeg_start_decompress (j_decompress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
  if (cinfo->global_state == DSTATE_READY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    /* First call: initialize master control, select active modules */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    jinit_master_decompress(cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    if (cinfo->buffered_image) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
      /* No more work here; expecting jpeg_start_output next */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
      cinfo->global_state = DSTATE_BUFIMAGE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
      return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    cinfo->global_state = DSTATE_PRELOAD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  if (cinfo->global_state == DSTATE_PRELOAD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /* If file has multiple scans, absorb them all into the coef buffer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    if (cinfo->inputctl->has_multiple_scans) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#ifdef D_MULTISCAN_FILES_SUPPORTED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
      for (;;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        int retcode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        /* Call progress monitor hook if present */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        if (cinfo->progress != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
          (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        /* Absorb some more input */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        retcode = (*cinfo->inputctl->consume_input) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        if (retcode == JPEG_SUSPENDED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
          return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        if (retcode == JPEG_REACHED_EOI)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        /* Advance progress counter if appropriate */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        if (cinfo->progress != NULL &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
          if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            /* jdmaster underestimated number of scans; ratchet up one scan */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
      ERREXIT(cinfo, JERR_NOT_COMPILED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#endif /* D_MULTISCAN_FILES_SUPPORTED */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    cinfo->output_scan_number = cinfo->input_scan_number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  } else if (cinfo->global_state != DSTATE_PRESCAN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  /* Perform any dummy output passes, and set up for the final pass */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  return output_pass_setup(cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * Set up for an output pass, and perform any dummy pass(es) needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * Common subroutine for jpeg_start_decompress and jpeg_start_output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * Entry: global_state = DSTATE_PRESCAN only if previously suspended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * Exit: If done, returns TRUE and sets global_state for proper output mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *       If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
LOCAL(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
output_pass_setup (j_decompress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  if (cinfo->global_state != DSTATE_PRESCAN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /* First call: do pass setup */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    (*cinfo->master->prepare_for_output_pass) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    cinfo->output_scanline = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    cinfo->global_state = DSTATE_PRESCAN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  /* Loop over any required dummy passes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  while (cinfo->master->is_dummy_pass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#ifdef QUANT_2PASS_SUPPORTED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /* Crank through the dummy pass */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    while (cinfo->output_scanline < cinfo->output_height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
      JDIMENSION last_scanline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
      /* Call progress monitor hook if present */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
      if (cinfo->progress != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        cinfo->progress->pass_counter = (long) cinfo->output_scanline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        cinfo->progress->pass_limit = (long) cinfo->output_height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
      /* Process some data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      last_scanline = cinfo->output_scanline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
      (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                                    &cinfo->output_scanline, (JDIMENSION) 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
      if (cinfo->output_scanline == last_scanline)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        return FALSE;           /* No progress made, must suspend */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /* Finish up dummy pass, and set up for another one */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    (*cinfo->master->finish_output_pass) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    (*cinfo->master->prepare_for_output_pass) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    cinfo->output_scanline = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    ERREXIT(cinfo, JERR_NOT_COMPILED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
#endif /* QUANT_2PASS_SUPPORTED */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  /* Ready for application to drive output pass through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
   * jpeg_read_scanlines or jpeg_read_raw_data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
  cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
  return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * Read some scanlines of data from the JPEG decompressor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 * The return value will be the number of lines actually read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 * This may be less than the number requested in several cases,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 * including bottom of image, data source suspension, and operating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 * modes that emit multiple scanlines at a time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 * Note: we warn about excess calls to jpeg_read_scanlines() since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * this likely signals an application programmer error.  However,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * an oversize buffer (max_lines > scanlines remaining) is not an error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
GLOBAL(JDIMENSION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                     JDIMENSION max_lines)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  JDIMENSION row_ctr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  if (cinfo->global_state != DSTATE_SCANNING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  if (cinfo->output_scanline >= cinfo->output_height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
  /* Call progress monitor hook if present */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
  if (cinfo->progress != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    cinfo->progress->pass_counter = (long) cinfo->output_scanline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    cinfo->progress->pass_limit = (long) cinfo->output_height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  /* Process some data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  row_ctr = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  cinfo->output_scanline += row_ctr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  return row_ctr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 * Alternate entry point to read raw data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 * Processes exactly one iMCU row per call, unless suspended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
GLOBAL(JDIMENSION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    JDIMENSION max_lines)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
  JDIMENSION lines_per_iMCU_row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
  if (cinfo->global_state != DSTATE_RAW_OK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
  if (cinfo->output_scanline >= cinfo->output_height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
  /* Call progress monitor hook if present */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
  if (cinfo->progress != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    cinfo->progress->pass_counter = (long) cinfo->output_scanline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    cinfo->progress->pass_limit = (long) cinfo->output_height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
  /* Verify that at least one iMCU row can be returned. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
  lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
  if (max_lines < lines_per_iMCU_row)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    ERREXIT(cinfo, JERR_BUFFER_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  /* Decompress directly into user's buffer. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
  if (! (*cinfo->coef->decompress_data) (cinfo, data))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    return 0;                   /* suspension forced, can do nothing more */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
  /* OK, we processed one iMCU row. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
  cinfo->output_scanline += lines_per_iMCU_row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
  return lines_per_iMCU_row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
/* Additional entry points for buffered-image mode. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
#ifdef D_MULTISCAN_FILES_SUPPORTED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
 * Initialize for an output pass in buffered-image mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
GLOBAL(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
  if (cinfo->global_state != DSTATE_BUFIMAGE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
      cinfo->global_state != DSTATE_PRESCAN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
  /* Limit scan number to valid range */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
  if (scan_number <= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    scan_number = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
  if (cinfo->inputctl->eoi_reached &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
      scan_number > cinfo->input_scan_number)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    scan_number = cinfo->input_scan_number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
  cinfo->output_scan_number = scan_number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
  /* Perform any dummy output passes, and set up for the real pass */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
  return output_pass_setup(cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
 * Finish up after an output pass in buffered-image mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
 * Returns FALSE if suspended.  The return value need be inspected only if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
 * a suspending data source is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
GLOBAL(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
jpeg_finish_output (j_decompress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
  if ((cinfo->global_state == DSTATE_SCANNING ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
       cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /* Terminate this pass. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    /* We do not require the whole pass to have been completed. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    (*cinfo->master->finish_output_pass) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    cinfo->global_state = DSTATE_BUFPOST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
  } else if (cinfo->global_state != DSTATE_BUFPOST) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    /* BUFPOST = repeat call after a suspension, anything else is error */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
  /* Read markers looking for SOS or EOI */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
         ! cinfo->inputctl->eoi_reached) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
      return FALSE;             /* Suspend, come back later */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
  cinfo->global_state = DSTATE_BUFIMAGE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
  return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
#endif /* D_MULTISCAN_FILES_SUPPORTED */