jdk/src/java.desktop/share/native/libjavajpeg/jdphuff.c
author phh
Fri, 30 Jun 2017 16:42:49 +0200
changeset 46874 13b399635568
parent 25859 3317bb8137f4
permissions -rw-r--r--
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8 8182656: Make the required changes in GC code to build on OSX 10 + Xcode 8 8182657: Make the required changes in Runtime code to build on OSX 10 + Xcode 8 8182658: Make the required changes in Compiler code to build on OSX 10 + Xcode 8 Reviewed-by: jwilhelm, ehelin
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
 * jdphuff.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * Copyright (C) 1995-1997, 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 Huffman entropy decoding routines for progressive JPEG.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * Much of the complexity here has to do with supporting input suspension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * If the data source module demands suspension, we want to be able to back
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * up to the start of the current MCU.  To do this, we copy state variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * into local working storage, and update them back to the permanent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * storage only upon successful completion of an MCU.
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
#include "jdhuff.h"             /* Declarations shared with jdhuff.c */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#ifdef D_PROGRESSIVE_SUPPORTED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * Expanded entropy decoder object for progressive Huffman decoding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * The savable_state subrecord contains fields that change within an MCU,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * but must not be updated permanently until we complete the MCU.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  unsigned int EOBRUN;                  /* remaining EOBs in EOBRUN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  int last_dc_val[MAX_COMPS_IN_SCAN];   /* last DC coef for each component */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
} savable_state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
/* This macro is to work around compilers with missing or broken
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * structure assignment.  You'll need to fix this code if you have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * such a compiler and you change MAX_COMPS_IN_SCAN.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#ifndef NO_STRUCT_ASSIGN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define ASSIGN_STATE(dest,src)  ((dest) = (src))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#if MAX_COMPS_IN_SCAN == 4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define ASSIGN_STATE(dest,src)  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        ((dest).EOBRUN = (src).EOBRUN, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
         (dest).last_dc_val[0] = (src).last_dc_val[0], \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
         (dest).last_dc_val[1] = (src).last_dc_val[1], \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
         (dest).last_dc_val[2] = (src).last_dc_val[2], \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
         (dest).last_dc_val[3] = (src).last_dc_val[3])
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  struct jpeg_entropy_decoder pub; /* public fields */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  /* These fields are loaded into local variables at start of each MCU.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
   * In case of suspension, we exit WITHOUT updating them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  bitread_perm_state bitstate;  /* Bit buffer at start of MCU */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  savable_state saved;          /* Other state at start of MCU */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  /* These fields are NOT loaded into local working state. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  unsigned int restarts_to_go;  /* MCUs left in this restart interval */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  /* Pointers to derived tables (these workspaces have image lifespan) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  d_derived_tbl * derived_tbls[NUM_HUFF_TBLS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
  d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
} phuff_entropy_decoder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
typedef phuff_entropy_decoder * phuff_entropy_ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
/* Forward declarations */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                                            JBLOCKROW *MCU_data));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                                            JBLOCKROW *MCU_data));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                                             JBLOCKROW *MCU_data));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                                             JBLOCKROW *MCU_data));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * Initialize for a Huffman-compressed scan.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
METHODDEF(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
start_pass_phuff_decoder (j_decompress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  boolean is_DC_band, bad;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  int ci, coefi, tbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  int *coef_bit_ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  jpeg_component_info * compptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  is_DC_band = (cinfo->Ss == 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  /* Validate scan parameters */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  bad = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  if (is_DC_band) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    if (cinfo->Se != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
      bad = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /* need not check Ss/Se < 0 since they came from unsigned bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
      bad = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /* AC scans may have only one component */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    if (cinfo->comps_in_scan != 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
      bad = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  if (cinfo->Ah != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /* Successive approximation refinement scan: must have Al = Ah-1. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    if (cinfo->Al != cinfo->Ah-1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
      bad = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  if (cinfo->Al > 13)           /* need not check for < 0 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    bad = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  /* Arguably the maximum Al value should be less than 13 for 8-bit precision,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
   * but the spec doesn't say so, and we try to be liberal about what we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
   * accept.  Note: large Al values could result in out-of-range DC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
   * coefficients during early scans, leading to bizarre displays due to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
   * overflows in the IDCT math.  But we won't crash.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
  if (bad)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
             cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
  /* Update progression status, and verify that scan order is legal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
   * Note that inter-scan inconsistencies are treated as warnings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
   * not fatal errors ... not clear if this is right way to behave.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    int cindex = cinfo->cur_comp_info[ci]->component_index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    coef_bit_ptr = & cinfo->coef_bits[cindex][0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
      WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
      int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
      if (cinfo->Ah != expected)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
      coef_bit_ptr[coefi] = cinfo->Al;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
  /* Select MCU decoding routine */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
  if (cinfo->Ah == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    if (is_DC_band)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
      entropy->pub.decode_mcu = decode_mcu_DC_first;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
      entropy->pub.decode_mcu = decode_mcu_AC_first;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    if (is_DC_band)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
      entropy->pub.decode_mcu = decode_mcu_DC_refine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
      entropy->pub.decode_mcu = decode_mcu_AC_refine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    compptr = cinfo->cur_comp_info[ci];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /* Make sure requested tables are present, and compute derived tables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * We may build same derived table more than once, but it's not expensive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    if (is_DC_band) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
      if (cinfo->Ah == 0) {     /* DC refinement needs no table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        tbl = compptr->dc_tbl_no;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        jpeg_make_d_derived_tbl(cinfo, TRUE, tbl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                                & entropy->derived_tbls[tbl]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
      tbl = compptr->ac_tbl_no;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
      jpeg_make_d_derived_tbl(cinfo, FALSE, tbl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                              & entropy->derived_tbls[tbl]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
      /* remember the single active table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
      entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /* Initialize DC predictions to 0 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    entropy->saved.last_dc_val[ci] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
  /* Initialize bitread state variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
  entropy->bitstate.bits_left = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
  entropy->pub.insufficient_data = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
  /* Initialize private state variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
  entropy->saved.EOBRUN = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
  /* Initialize restart counter */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
  entropy->restarts_to_go = cinfo->restart_interval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * Figure F.12: extend sign bit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 * On some machines, a shift and add will be faster than a table lookup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
#ifdef AVOID_TABLES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
#define HUFF_EXTEND(x,s)  ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
#define HUFF_EXTEND(x,s)  ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
static const int extend_test[16] =   /* entry n is 2**(n-1) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
  { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
46874
13b399635568 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
phh
parents: 25859
diff changeset
   218
  { 0,
13b399635568 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
phh
parents: 25859
diff changeset
   219
    (int)(((unsigned)(~0)<<1)  + 1), (int)(((unsigned)(~0)<<2)  + 1),
13b399635568 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
phh
parents: 25859
diff changeset
   220
    (int)(((unsigned)(~0)<<3)  + 1), (int)(((unsigned)(~0)<<4)  + 1),
13b399635568 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
phh
parents: 25859
diff changeset
   221
    (int)(((unsigned)(~0)<<5)  + 1), (int)(((unsigned)(~0)<<6)  + 1),
13b399635568 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
phh
parents: 25859
diff changeset
   222
    (int)(((unsigned)(~0)<<7)  + 1), (int)(((unsigned)(~0)<<8)  + 1),
13b399635568 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
phh
parents: 25859
diff changeset
   223
    (int)(((unsigned)(~0)<<9)  + 1), (int)(((unsigned)(~0)<<10) + 1),
13b399635568 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
phh
parents: 25859
diff changeset
   224
    (int)(((unsigned)(~0)<<11) + 1), (int)(((unsigned)(~0)<<12) + 1),
13b399635568 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
phh
parents: 25859
diff changeset
   225
    (int)(((unsigned)(~0)<<13) + 1), (int)(((unsigned)(~0)<<14) + 1),
13b399635568 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
phh
parents: 25859
diff changeset
   226
    (int)(((unsigned)(~0)<<15) + 1) };
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
#endif /* AVOID_TABLES */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
 * Check for a restart marker & resynchronize decoder.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
 * Returns FALSE if must suspend.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
LOCAL(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
process_restart (j_decompress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
  int ci;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
  /* Throw away any unused bits remaining in bit buffer; */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
  /* include any full bytes in next_marker's count of discarded bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
  cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
  entropy->bitstate.bits_left = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
  /* Advance past the RSTn marker */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
  if (! (*cinfo->marker->read_restart_marker) (cinfo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
  /* Re-initialize DC predictions to 0 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
  for (ci = 0; ci < cinfo->comps_in_scan; ci++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    entropy->saved.last_dc_val[ci] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
  /* Re-init EOB run count, too */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
  entropy->saved.EOBRUN = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
  /* Reset restart counter */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
  entropy->restarts_to_go = cinfo->restart_interval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
  /* Reset out-of-data flag, unless read_restart_marker left us smack up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
   * against a marker.  In that case we will end up treating the next data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
   * segment as empty, and we can avoid producing bogus output pixels by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
   * leaving the flag set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
  if (cinfo->unread_marker == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    entropy->pub.insufficient_data = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
 * Huffman MCU decoding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
 * Each of these routines decodes and returns one MCU's worth of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
 * Huffman-compressed coefficients.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
 * The coefficients are reordered from zigzag order into natural array order,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
 * but are not dequantized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
 * The i'th block of the MCU is stored into the block pointed to by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
 * MCU_data[i].  WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
 * We return FALSE if data source requested suspension.  In that case no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 * changes have been made to permanent state.  (Exception: some output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
 * coefficients may already have been assigned.  This is harmless for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
 * spectral selection, since we'll just re-assign them on the next call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
 * Successive approximation AC refinement has to be more careful, however.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
 * MCU decoding for DC initial scan (either spectral selection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
 * or first pass of successive approximation).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
METHODDEF(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
  int Al = cinfo->Al;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
  register int s, r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
  int blkn, ci;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
  JBLOCKROW block;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
  BITREAD_STATE_VARS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
  savable_state state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
  d_derived_tbl * tbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
  jpeg_component_info * compptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
  /* Process restart marker if needed; may have to suspend */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
  if (cinfo->restart_interval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    if (entropy->restarts_to_go == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
      if (! process_restart(cinfo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
  /* If we've run out of data, just leave the MCU set to zeroes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
   * This way, we return uniform gray for the remainder of the segment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
  if (! entropy->pub.insufficient_data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /* Load up working state */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    ASSIGN_STATE(state, entropy->saved);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /* Outer loop handles each block in the MCU */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
      block = MCU_data[blkn];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
      ci = cinfo->MCU_membership[blkn];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
      compptr = cinfo->cur_comp_info[ci];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
      tbl = entropy->derived_tbls[compptr->dc_tbl_no];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
      /* Decode a single block's worth of coefficients */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
      /* Section F.2.2.1: decode the DC coefficient difference */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
      HUFF_DECODE(s, br_state, tbl, return FALSE, label1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
      if (s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        CHECK_BIT_BUFFER(br_state, s, return FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        r = GET_BITS(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        s = HUFF_EXTEND(r, s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
      /* Convert DC difference to actual value, update last_dc_val */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
      s += state.last_dc_val[ci];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
      state.last_dc_val[ci] = s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
      /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
      (*block)[0] = (JCOEF) (s << Al);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    /* Completed MCU, so update state */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    ASSIGN_STATE(entropy->saved, state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
  /* Account for restart interval (no-op if not using restarts) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
  entropy->restarts_to_go--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
  return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
 * MCU decoding for AC initial scan (either spectral selection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
 * or first pass of successive approximation).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
METHODDEF(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
  int Se = cinfo->Se;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
  int Al = cinfo->Al;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
  register int s, k, r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
  unsigned int EOBRUN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
  JBLOCKROW block;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
  BITREAD_STATE_VARS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
  d_derived_tbl * tbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
  /* Process restart marker if needed; may have to suspend */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
  if (cinfo->restart_interval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    if (entropy->restarts_to_go == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
      if (! process_restart(cinfo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
  /* If we've run out of data, just leave the MCU set to zeroes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
   * This way, we return uniform gray for the remainder of the segment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
  if (! entropy->pub.insufficient_data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    /* Load up working state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * We can avoid loading/saving bitread state if in an EOB run.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    EOBRUN = entropy->saved.EOBRUN;     /* only part of saved state we need */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    /* There is always only one block per MCU */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    if (EOBRUN > 0)             /* if it's a band of zeroes... */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
      EOBRUN--;                 /* ...process it now (we do nothing) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
      BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
      block = MCU_data[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
      tbl = entropy->ac_derived_tbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
      for (k = cinfo->Ss; k <= Se; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        r = s >> 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        s &= 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        if (s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
          k += r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
          CHECK_BIT_BUFFER(br_state, s, return FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
          r = GET_BITS(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
          s = HUFF_EXTEND(r, s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
          /* Scale and output coefficient in natural (dezigzagged) order */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
          (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
          if (r == 15) {        /* ZRL */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            k += 15;            /* skip 15 zeroes in band */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
          } else {              /* EOBr, run length is 2^r + appended bits */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            EOBRUN = 1 << r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            if (r) {            /* EOBr, r > 0 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
              CHECK_BIT_BUFFER(br_state, r, return FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
              r = GET_BITS(r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
              EOBRUN += r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            EOBRUN--;           /* this band is processed at this moment */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            break;              /* force end-of-band */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
      BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    /* Completed MCU, so update state */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    entropy->saved.EOBRUN = EOBRUN;     /* only part of saved state we need */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
  /* Account for restart interval (no-op if not using restarts) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
  entropy->restarts_to_go--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
  return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
 * MCU decoding for DC successive approximation refinement scan.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
 * Note: we assume such scans can be multi-component, although the spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
 * is not very clear on the point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
METHODDEF(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
  int p1 = 1 << cinfo->Al;      /* 1 in the bit position being coded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
  int blkn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
  JBLOCKROW block;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
  BITREAD_STATE_VARS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
  /* Process restart marker if needed; may have to suspend */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
  if (cinfo->restart_interval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    if (entropy->restarts_to_go == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
      if (! process_restart(cinfo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
  /* Not worth the cycles to check insufficient_data here,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
   * since we will not change the data anyway if we read zeroes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
  /* Load up working state */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
  /* Outer loop handles each block in the MCU */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    block = MCU_data[blkn];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    /* Encoded data is simply the next bit of the two's-complement DC value */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    CHECK_BIT_BUFFER(br_state, 1, return FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    if (GET_BITS(1))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
      (*block)[0] |= p1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    /* Note: since we use |=, repeating the assignment later is safe */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
  /* Completed MCU, so update state */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
  /* Account for restart interval (no-op if not using restarts) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
  entropy->restarts_to_go--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
  return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
 * MCU decoding for AC successive approximation refinement scan.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
METHODDEF(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
  int Se = cinfo->Se;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
  int p1 = 1 << cinfo->Al;      /* 1 in the bit position being coded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
  int m1 = (-1) << cinfo->Al;   /* -1 in the bit position being coded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
  register int s, k, r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
  unsigned int EOBRUN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
  JBLOCKROW block;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
  JCOEFPTR thiscoef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
  BITREAD_STATE_VARS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
  d_derived_tbl * tbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
  int num_newnz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
  int newnz_pos[DCTSIZE2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
  /* Process restart marker if needed; may have to suspend */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
  if (cinfo->restart_interval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    if (entropy->restarts_to_go == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
      if (! process_restart(cinfo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
  /* If we've run out of data, don't modify the MCU.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
  if (! entropy->pub.insufficient_data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    /* Load up working state */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    /* There is always only one block per MCU */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    block = MCU_data[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    tbl = entropy->ac_derived_tbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    /* If we are forced to suspend, we must undo the assignments to any newly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * nonzero coefficients in the block, because otherwise we'd get confused
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * next time about which coefficients were already nonzero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * But we need not undo addition of bits to already-nonzero coefficients;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * instead, we can test the current bit to see if we already did it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    num_newnz = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    /* initialize coefficient loop counter to start of band */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    k = cinfo->Ss;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    if (EOBRUN == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
      for (; k <= Se; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        HUFF_DECODE(s, br_state, tbl, goto undoit, label3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        r = s >> 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        s &= 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        if (s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
          if (s != 1)           /* size of new coef should always be 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
          CHECK_BIT_BUFFER(br_state, 1, goto undoit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
          if (GET_BITS(1))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            s = p1;             /* newly nonzero coef is positive */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
          else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            s = m1;             /* newly nonzero coef is negative */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
          if (r != 15) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
            EOBRUN = 1 << r;    /* EOBr, run length is 2^r + appended bits */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            if (r) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
              CHECK_BIT_BUFFER(br_state, r, goto undoit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
              r = GET_BITS(r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
              EOBRUN += r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            break;              /* rest of block is handled by EOB logic */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
          /* note s = 0 for processing ZRL */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        /* Advance over already-nonzero coefs and r still-zero coefs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
         * appending correction bits to the nonzeroes.  A correction bit is 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
         * if the absolute value of the coefficient must be increased.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
          thiscoef = *block + jpeg_natural_order[k];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
          if (*thiscoef != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            CHECK_BIT_BUFFER(br_state, 1, goto undoit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            if (GET_BITS(1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
              if ((*thiscoef & p1) == 0) { /* do nothing if already set it */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                if (*thiscoef >= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                  *thiscoef += p1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                  *thiscoef += m1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
          } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            if (--r < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
              break;            /* reached target zero coefficient */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
          k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        } while (k <= Se);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        if (s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
          int pos = jpeg_natural_order[k];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
          /* Output newly nonzero coefficient */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
          (*block)[pos] = (JCOEF) s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
          /* Remember its position in case we have to suspend */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
          newnz_pos[num_newnz++] = pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    if (EOBRUN > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
      /* Scan any remaining coefficient positions after the end-of-band
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
       * (the last newly nonzero coefficient, if any).  Append a correction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
       * bit to each already-nonzero coefficient.  A correction bit is 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
       * if the absolute value of the coefficient must be increased.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
      for (; k <= Se; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        thiscoef = *block + jpeg_natural_order[k];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        if (*thiscoef != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
          CHECK_BIT_BUFFER(br_state, 1, goto undoit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
          if (GET_BITS(1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
              if (*thiscoef >= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                *thiscoef += p1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
              else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                *thiscoef += m1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
      /* Count one block completed in EOB run */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
      EOBRUN--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    /* Completed MCU, so update state */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
  /* Account for restart interval (no-op if not using restarts) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
  entropy->restarts_to_go--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
  return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
undoit:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
  /* Re-zero any output coefficients that we made newly nonzero */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
  while (num_newnz > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    (*block)[newnz_pos[--num_newnz]] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
  return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
 * Module initialization routine for progressive Huffman entropy decoding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
GLOBAL(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
jinit_phuff_decoder (j_decompress_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
  phuff_entropy_ptr entropy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
  int *coef_bit_ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
  int ci, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
  entropy = (phuff_entropy_ptr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                                SIZEOF(phuff_entropy_decoder));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
  cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
  entropy->pub.start_pass = start_pass_phuff_decoder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
  /* Mark derived tables unallocated */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
  for (i = 0; i < NUM_HUFF_TBLS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    entropy->derived_tbls[i] = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
  /* Create progression status table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
  cinfo->coef_bits = (int (*)[DCTSIZE2])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                                cinfo->num_components*DCTSIZE2*SIZEOF(int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
  coef_bit_ptr = & cinfo->coef_bits[0][0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
  for (ci = 0; ci < cinfo->num_components; ci++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    for (i = 0; i < DCTSIZE2; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
      *coef_bit_ptr++ = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
#endif /* D_PROGRESSIVE_SUPPORTED */