src/java.desktop/share/native/libjavajpeg/jcapimin.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
 * jcapimin.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * Copyright (C) 1994-1998, 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 compression half
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * of the JPEG library.  These are the "minimum" API routines that may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * needed in either the normal full-compression case or the transcoding-only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * case.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Most of the routines intended to be called directly by an application
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * are in this file or in jcapistd.c.  But also see jcparam.c for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * parameter-setup helper routines, jcomapi.c for routines shared by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * compression and decompression, and jctrans.c for the transcoding case.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
#define JPEG_INTERNALS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
#include "jinclude.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
#include "jpeglib.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * Initialization of a JPEG compression object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * The error manager must already be set up (in case memory manager fails).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  /* Guard against version mismatches between library and caller. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  cinfo->mem = NULL;            /* so jpeg_destroy knows mem mgr not called */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  if (version != JPEG_LIB_VERSION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  if (structsize != SIZEOF(struct jpeg_compress_struct))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
             (int) SIZEOF(struct jpeg_compress_struct), (int) structsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  /* For debugging purposes, we zero the whole master structure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
   * But the application has already set the err pointer, and may have set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
   * client_data, so we have to save and restore those fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
   * Note: if application hasn't set client_data, tools like Purify may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
   * complain here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    struct jpeg_error_mgr * err = cinfo->err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    void * client_data = cinfo->client_data; /* ignore Purify complaint here */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    cinfo->err = err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    cinfo->client_data = client_data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
  cinfo->is_decompressor = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  /* Initialize a memory manager instance for this object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  jinit_memory_mgr((j_common_ptr) cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
  /* Zero out pointers to permanent structures. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  cinfo->progress = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  cinfo->dest = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  cinfo->comp_info = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  for (i = 0; i < NUM_QUANT_TBLS; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    cinfo->quant_tbl_ptrs[i] = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  for (i = 0; i < NUM_HUFF_TBLS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    cinfo->dc_huff_tbl_ptrs[i] = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    cinfo->ac_huff_tbl_ptrs[i] = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  cinfo->script_space = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  cinfo->input_gamma = 1.0;     /* in case application forgets */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  /* OK, I'm ready */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  cinfo->global_state = CSTATE_START;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * Destruction of a JPEG compression object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
jpeg_destroy_compress (j_compress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
  jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * Abort processing of a JPEG compression operation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * but don't destroy the object itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
jpeg_abort_compress (j_compress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  jpeg_abort((j_common_ptr) cinfo); /* use common routine */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * Forcibly suppress or un-suppress all quantization and Huffman tables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * Marks all currently defined tables as already written (if suppress)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * or not written (if !suppress).  This will control whether they get emitted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * by a subsequent jpeg_start_compress call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * This routine is exported for use by applications that want to produce
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * abbreviated JPEG datastreams.  It logically belongs in jcparam.c, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * since it is called by jpeg_start_compress, we put it here --- otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * jcparam.o would be linked whether the application used it or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
  int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  JQUANT_TBL * qtbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  JHUFF_TBL * htbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  for (i = 0; i < NUM_QUANT_TBLS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
      qtbl->sent_table = suppress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  for (i = 0; i < NUM_HUFF_TBLS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
      htbl->sent_table = suppress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
      htbl->sent_table = suppress;
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
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * Finish JPEG compression.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 * If a multipass operating mode was selected, this may do a great deal of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 * work including most of the actual output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
jpeg_finish_compress (j_compress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
  JDIMENSION iMCU_row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
  if (cinfo->global_state == CSTATE_SCANNING ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
      cinfo->global_state == CSTATE_RAW_OK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /* Terminate first pass */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    if (cinfo->next_scanline < cinfo->image_height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
      ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    (*cinfo->master->finish_pass) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  } else if (cinfo->global_state != CSTATE_WRCOEFS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  /* Perform any remaining passes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
  while (! cinfo->master->is_last_pass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    (*cinfo->master->prepare_for_pass) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
      if (cinfo->progress != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        cinfo->progress->pass_counter = (long) iMCU_row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
      /* We bypass the main controller and invoke coef controller directly;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
       * all work is being done from the coefficient buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
      if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        ERREXIT(cinfo, JERR_CANT_SUSPEND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    (*cinfo->master->finish_pass) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
  /* Write EOI, do final cleanup */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  (*cinfo->marker->write_file_trailer) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  (*cinfo->dest->term_destination) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
  /* We can use jpeg_abort to release memory and reset global_state */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
  jpeg_abort((j_common_ptr) cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * Write a special marker.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * This is only recommended for writing COM or APPn markers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * Must be called after jpeg_start_compress() and before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 * first call to jpeg_write_scanlines() or jpeg_write_raw_data().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
jpeg_write_marker (j_compress_ptr cinfo, int marker,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                   const JOCTET *dataptr, unsigned int datalen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
  if (cinfo->next_scanline != 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
      (cinfo->global_state != CSTATE_SCANNING &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
       cinfo->global_state != CSTATE_RAW_OK &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
       cinfo->global_state != CSTATE_WRCOEFS))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
  write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
  while (datalen--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    (*write_marker_byte) (cinfo, *dataptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    dataptr++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
/* Same, but piecemeal. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
  if (cinfo->next_scanline != 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
      (cinfo->global_state != CSTATE_SCANNING &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
       cinfo->global_state != CSTATE_RAW_OK &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
       cinfo->global_state != CSTATE_WRCOEFS))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
  (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
jpeg_write_m_byte (j_compress_ptr cinfo, int val)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
  (*cinfo->marker->write_marker_byte) (cinfo, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
 * Alternate compression function: just write an abbreviated table file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
 * Before calling this, all parameters and a data destination must be set up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
 * To produce a pair of files containing abbreviated tables and abbreviated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
 * image data, one would proceed as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
 *              initialize JPEG object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
 *              set JPEG parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 *              set destination to table file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
 *              jpeg_write_tables(cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
 *              set destination to image file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
 *              jpeg_start_compress(cinfo, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
 *              write data...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
 *              jpeg_finish_compress(cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
 * jpeg_write_tables has the side effect of marking all tables written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
 * (same as jpeg_suppress_tables(..., TRUE)).  Thus a subsequent start_compress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
 * will not re-emit the tables unless it is passed write_all_tables=TRUE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
jpeg_write_tables (j_compress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
  if (cinfo->global_state != CSTATE_START)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
  /* (Re)initialize error mgr and destination modules */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
  (*cinfo->dest->init_destination) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
  /* Initialize the marker writer ... bit of a crock to do it here. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
  jinit_marker_writer(cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  /* Write them tables! */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
  (*cinfo->marker->write_tables_only) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
  /* And clean up. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
  (*cinfo->dest->term_destination) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
  /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
   * In library releases up through v6a, we called jpeg_abort() here to free
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
   * any working memory allocated by the destination manager and marker
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
   * writer.  Some applications had a problem with that: they allocated space
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
   * of their own from the library memory manager, and didn't want it to go
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
   * away during write_tables.  So now we do nothing.  This will cause a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
   * memory leak if an app calls write_tables repeatedly without doing a full
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
   * compression cycle or otherwise resetting the JPEG object.  However, that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
   * seems less bad than unexpectedly freeing memory in the normal case.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
   * An app that prefers the old behavior can call jpeg_abort for itself after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
   * each call to jpeg_write_tables().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
}