ReactOS  0.4.14-dev-317-g96040ec
jdhuff.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jdhuff.c:

Go to the source code of this file.

Classes

struct  d_derived_tbl
 
struct  bitread_perm_state
 
struct  bitread_working_state
 
struct  savable_state
 
struct  huff_entropy_decoder
 

Macros

#define JPEG_INTERNALS
 
#define HUFF_LOOKAHEAD   8 /* # of bits of lookahead */
 
#define BIT_BUF_SIZE   32 /* size of buffer in bits */
 
#define BITREAD_STATE_VARS
 
#define BITREAD_LOAD_STATE(cinfop, permstate)
 
#define BITREAD_SAVE_STATE(cinfop, permstate)
 
#define CHECK_BIT_BUFFER(state, nbits, action)
 
#define GET_BITS(nbits)   (((int) (get_buffer >> (bits_left -= (nbits)))) & BIT_MASK(nbits))
 
#define PEEK_BITS(nbits)   (((int) (get_buffer >> (bits_left - (nbits)))) & BIT_MASK(nbits))
 
#define DROP_BITS(nbits)   (bits_left -= (nbits))
 
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
 
#define ASSIGN_STATE(dest, src)   ((dest) = (src))
 
#define MIN_GET_BITS   (BIT_BUF_SIZE-7)
 
#define BIT_MASK(nbits)   bmask[nbits]
 
#define HUFF_EXTEND(x, s)   ((x) <= bmask[(s) - 1] ? (x) - bmask[s] : (x))
 

Typedefs

typedef INT32 bit_buf_type
 
typedef huff_entropy_decoderhuff_entropy_ptr
 

Functions

 jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno, d_derived_tbl **pdtbl)
 
 jpeg_fill_bit_buffer (bitread_working_state *state, register bit_buf_type get_buffer, register int bits_left, int nbits)
 
 jpeg_huff_decode (bitread_working_state *state, register bit_buf_type get_buffer, register int bits_left, d_derived_tbl *htbl, int min_bits)
 
 finish_pass_huff (j_decompress_ptr cinfo)
 
 process_restart (j_decompress_ptr cinfo)
 
 decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
 
 decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
 
 decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
 
 decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
 
 decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
 
 decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
 
 start_pass_huff_decoder (j_decompress_ptr cinfo)
 
 jinit_huff_decoder (j_decompress_ptr cinfo)
 

Variables

static const int jpeg_zigzag_order [8][8]
 
static const int jpeg_zigzag_order7 [7][7]
 
static const int jpeg_zigzag_order6 [6][6]
 
static const int jpeg_zigzag_order5 [5][5]
 
static const int jpeg_zigzag_order4 [4][4]
 
static const int jpeg_zigzag_order3 [3][3]
 
static const int jpeg_zigzag_order2 [2][2]
 
static const int bmask [16]
 

Macro Definition Documentation

◆ ASSIGN_STATE

#define ASSIGN_STATE (   dest,
  src 
)    ((dest) = (src))

Definition at line 209 of file jdhuff.c.

◆ BIT_BUF_SIZE

#define BIT_BUF_SIZE   32 /* size of buffer in bits */

Definition at line 70 of file jdhuff.c.

◆ BIT_MASK

#define BIT_MASK (   nbits)    bmask[nbits]

Definition at line 577 of file jdhuff.c.

◆ BITREAD_LOAD_STATE

#define BITREAD_LOAD_STATE (   cinfop,
  permstate 
)
Value:
br_state.cinfo = cinfop; \
br_state.next_input_byte = cinfop->src->next_input_byte; \
br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
get_buffer = permstate.get_buffer; \
bits_left = permstate.bits_left;

Definition at line 104 of file jdhuff.c.

◆ BITREAD_SAVE_STATE

#define BITREAD_SAVE_STATE (   cinfop,
  permstate 
)
Value:
cinfop->src->next_input_byte = br_state.next_input_byte; \
cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
permstate.get_buffer = get_buffer; \
permstate.bits_left = bits_left
NTSTATUS get_buffer(LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
Definition: libsupp.c:645

Definition at line 111 of file jdhuff.c.

◆ BITREAD_STATE_VARS

#define BITREAD_STATE_VARS
Value:
register int bits_left; \
bitread_working_state br_state
NTSTATUS get_buffer(LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
Definition: libsupp.c:645
INT32 bit_buf_type
Definition: jdhuff.c:69

Definition at line 99 of file jdhuff.c.

◆ CHECK_BIT_BUFFER

#define CHECK_BIT_BUFFER (   state,
  nbits,
  action 
)
Value:
{ if (bits_left < (nbits)) { \
if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \
{ action; } \
get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }
static int state
Definition: maze.c:121
jpeg_fill_bit_buffer(bitread_working_state *state, register bit_buf_type get_buffer, register int bits_left, int nbits)
Definition: jdhuff.c:465
const WCHAR * action
Definition: action.c:7783
NTSTATUS get_buffer(LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
Definition: libsupp.c:645

Definition at line 135 of file jdhuff.c.

◆ DROP_BITS

#define DROP_BITS (   nbits)    (bits_left -= (nbits))

Definition at line 147 of file jdhuff.c.

◆ GET_BITS

#define GET_BITS (   nbits)    (((int) (get_buffer >> (bits_left -= (nbits)))) & BIT_MASK(nbits))

Definition at line 141 of file jdhuff.c.

◆ HUFF_DECODE

#define HUFF_DECODE (   result,
  state,
  htbl,
  failaction,
  slowlabel 
)
Value:
{ register int nb, look; \
if (bits_left < HUFF_LOOKAHEAD) { \
if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \
get_buffer = state.get_buffer; bits_left = state.bits_left; \
if (bits_left < HUFF_LOOKAHEAD) { \
nb = 1; goto slowlabel; \
} \
} \
if ((nb = htbl->look_nbits[look]) != 0) { \
DROP_BITS(nb); \
result = htbl->look_sym[look]; \
} else { \
nb = HUFF_LOOKAHEAD+1; \
slowlabel: \
if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \
{ failaction; } \
get_buffer = state.get_buffer; bits_left = state.bits_left; \
} \
}
jpeg_huff_decode(bitread_working_state *state, register bit_buf_type get_buffer, register int bits_left, d_derived_tbl *htbl, int min_bits)
Definition: jdhuff.c:592
#define HUFF_LOOKAHEAD
Definition: jdhuff.c:26
static int state
Definition: maze.c:121
jpeg_fill_bit_buffer(bitread_working_state *state, register bit_buf_type get_buffer, register int bits_left, int nbits)
Definition: jdhuff.c:465
#define PEEK_BITS(nbits)
Definition: jdhuff.c:144
NTSTATUS get_buffer(LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
Definition: libsupp.c:645
GLuint64EXT * result
Definition: glext.h:11304

Definition at line 168 of file jdhuff.c.

◆ HUFF_EXTEND

#define HUFF_EXTEND (   x,
  s 
)    ((x) <= bmask[(s) - 1] ? (x) - bmask[s] : (x))

Definition at line 578 of file jdhuff.c.

◆ HUFF_LOOKAHEAD

#define HUFF_LOOKAHEAD   8 /* # of bits of lookahead */

Definition at line 26 of file jdhuff.c.

◆ JPEG_INTERNALS

#define JPEG_INTERNALS

Definition at line 19 of file jdhuff.c.

◆ MIN_GET_BITS

#define MIN_GET_BITS   (BIT_BUF_SIZE-7)

Definition at line 460 of file jdhuff.c.

◆ PEEK_BITS

#define PEEK_BITS (   nbits)    (((int) (get_buffer >> (bits_left - (nbits)))) & BIT_MASK(nbits))

Definition at line 144 of file jdhuff.c.

Typedef Documentation

◆ bit_buf_type

Definition at line 69 of file jdhuff.c.

◆ huff_entropy_ptr

Definition at line 257 of file jdhuff.c.

Function Documentation

◆ decode_mcu()

decode_mcu ( j_decompress_ptr  cinfo,
JBLOCKROW MCU_data 
)

Definition at line 1198 of file jdhuff.c.

1199 {
1200  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1201  int blkn;
1204 
1205  /* Process restart marker if needed; may have to suspend */
1206  if (cinfo->restart_interval) {
1207  if (entropy->restarts_to_go == 0)
1208  if (! process_restart(cinfo))
1209  return FALSE;
1210  }
1211 
1212  /* If we've run out of data, just leave the MCU set to zeroes.
1213  * This way, we return uniform gray for the remainder of the segment.
1214  */
1215  if (! entropy->insufficient_data) {
1216 
1217  /* Load up working state */
1218  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
1219  ASSIGN_STATE(state, entropy->saved);
1220 
1221  /* Outer loop handles each block in the MCU */
1222 
1223  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1224  JBLOCKROW block = MCU_data[blkn];
1225  d_derived_tbl * htbl;
1226  register int s, k, r;
1227  int coef_limit, ci;
1228 
1229  /* Decode a single block's worth of coefficients */
1230 
1231  /* Section F.2.2.1: decode the DC coefficient difference */
1232  htbl = entropy->dc_cur_tbls[blkn];
1233  HUFF_DECODE(s, br_state, htbl, return FALSE, label1);
1234 
1235  htbl = entropy->ac_cur_tbls[blkn];
1236  k = 1;
1237  coef_limit = entropy->coef_limit[blkn];
1238  if (coef_limit) {
1239  /* Convert DC difference to actual value, update last_dc_val */
1240  if (s) {
1241  CHECK_BIT_BUFFER(br_state, s, return FALSE);
1242  r = GET_BITS(s);
1243  s = HUFF_EXTEND(r, s);
1244  }
1245  ci = cinfo->MCU_membership[blkn];
1246  s += state.last_dc_val[ci];
1247  state.last_dc_val[ci] = s;
1248  /* Output the DC coefficient */
1249  (*block)[0] = (JCOEF) s;
1250 
1251  /* Section F.2.2.2: decode the AC coefficients */
1252  /* Since zeroes are skipped, output area must be cleared beforehand */
1253  for (; k < coef_limit; k++) {
1254  HUFF_DECODE(s, br_state, htbl, return FALSE, label2);
1255 
1256  r = s >> 4;
1257  s &= 15;
1258 
1259  if (s) {
1260  k += r;
1261  CHECK_BIT_BUFFER(br_state, s, return FALSE);
1262  r = GET_BITS(s);
1263  s = HUFF_EXTEND(r, s);
1264  /* Output coefficient in natural (dezigzagged) order.
1265  * Note: the extra entries in jpeg_natural_order[] will save us
1266  * if k >= DCTSIZE2, which could happen if the data is corrupted.
1267  */
1268  (*block)[jpeg_natural_order[k]] = (JCOEF) s;
1269  } else {
1270  if (r != 15)
1271  goto EndOfBlock;
1272  k += 15;
1273  }
1274  }
1275  } else {
1276  if (s) {
1277  CHECK_BIT_BUFFER(br_state, s, return FALSE);
1278  DROP_BITS(s);
1279  }
1280  }
1281 
1282  /* Section F.2.2.2: decode the AC coefficients */
1283  /* In this path we just discard the values */
1284  for (; k < DCTSIZE2; k++) {
1285  HUFF_DECODE(s, br_state, htbl, return FALSE, label3);
1286 
1287  r = s >> 4;
1288  s &= 15;
1289 
1290  if (s) {
1291  k += r;
1292  CHECK_BIT_BUFFER(br_state, s, return FALSE);
1293  DROP_BITS(s);
1294  } else {
1295  if (r != 15)
1296  break;
1297  k += 15;
1298  }
1299  }
1300 
1301  EndOfBlock: ;
1302  }
1303 
1304  /* Completed MCU, so update state */
1305  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
1306  ASSIGN_STATE(entropy->saved, state);
1307  }
1308 
1309  /* Account for restart interval (no-op if not using restarts) */
1310  entropy->restarts_to_go--;
1311 
1312  return TRUE;
1313 }
static unsigned int block
Definition: xmlmemory.c:118
#define TRUE
Definition: types.h:120
#define HUFF_EXTEND(x, s)
Definition: jdhuff.c:578
static const WCHAR label2[]
Definition: itemdlg.c:1547
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
savable_state saved
Definition: jchuff.c:84
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
short JCOEF
Definition: jmorecfg.h:151
#define CHECK_BIT_BUFFER(state, nbits, action)
Definition: jdhuff.c:135
#define DROP_BITS(nbits)
Definition: jdhuff.c:147
#define DCTSIZE2
Definition: jpeglib.h:51
unsigned int restart_interval
Definition: jpeglib.h:594
if(!(yy_init))
Definition: macro.lex.yy.c:714
JBLOCK FAR * JBLOCKROW
Definition: jpeglib.h:80
static int state
Definition: maze.c:121
GLdouble s
Definition: gl.h:2039
#define ASSIGN_STATE(dest, src)
Definition: jdhuff.c:209
const int jpeg_natural_order[DCTSIZE2+16]
Definition: jutils.c:54
process_restart(j_decompress_ptr cinfo)
Definition: jdhuff.c:652
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
Definition: jdhuff.c:168
#define BITREAD_SAVE_STATE(cinfop, permstate)
Definition: jdhuff.c:111
int MCU_membership[D_MAX_BLOCKS_IN_MCU]
Definition: jpeglib.h:657
#define GET_BITS(nbits)
Definition: jdhuff.c:141
unsigned int restarts_to_go
Definition: jchuff.c:87
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684
int k
Definition: mpi.c:3369
#define BITREAD_LOAD_STATE(cinfop, permstate)
Definition: jdhuff.c:104
#define BITREAD_STATE_VARS
Definition: jdhuff.c:99

Referenced by start_pass_huff_decoder().

◆ decode_mcu_AC_first()

decode_mcu_AC_first ( j_decompress_ptr  cinfo,
JBLOCKROW MCU_data 
)

Definition at line 779 of file jdhuff.c.

780 {
781  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
782  register int s, k, r;
783  unsigned int EOBRUN;
784  int Se, Al;
785  const int * natural_order;
788  d_derived_tbl * tbl;
789 
790  /* Process restart marker if needed; may have to suspend */
791  if (cinfo->restart_interval) {
792  if (entropy->restarts_to_go == 0)
793  if (! process_restart(cinfo))
794  return FALSE;
795  }
796 
797  /* If we've run out of data, just leave the MCU set to zeroes.
798  * This way, we return uniform gray for the remainder of the segment.
799  */
800  if (! entropy->insufficient_data) {
801 
802  /* Load up working state.
803  * We can avoid loading/saving bitread state if in an EOB run.
804  */
805  EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
806 
807  /* There is always only one block per MCU */
808 
809  if (EOBRUN) /* if it's a band of zeroes... */
810  EOBRUN--; /* ...process it now (we do nothing) */
811  else {
812  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
813  Se = cinfo->Se;
814  Al = cinfo->Al;
815  natural_order = cinfo->natural_order;
816  block = MCU_data[0];
817  tbl = entropy->ac_derived_tbl;
818 
819  for (k = cinfo->Ss; k <= Se; k++) {
820  HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
821  r = s >> 4;
822  s &= 15;
823  if (s) {
824  k += r;
825  CHECK_BIT_BUFFER(br_state, s, return FALSE);
826  r = GET_BITS(s);
827  s = HUFF_EXTEND(r, s);
828  /* Scale and output coefficient in natural (dezigzagged) order */
829  (*block)[natural_order[k]] = (JCOEF) (s << Al);
830  } else {
831  if (r != 15) { /* EOBr, run length is 2^r + appended bits */
832  if (r) { /* EOBr, r > 0 */
833  EOBRUN = 1 << r;
834  CHECK_BIT_BUFFER(br_state, r, return FALSE);
835  r = GET_BITS(r);
836  EOBRUN += r;
837  EOBRUN--; /* this band is processed at this moment */
838  }
839  break; /* force end-of-band */
840  }
841  k += 15; /* ZRL: skip 15 zeroes in band */
842  }
843  }
844 
845  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
846  }
847 
848  /* Completed MCU, so update state */
849  entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
850  }
851 
852  /* Account for restart interval (no-op if not using restarts) */
853  entropy->restarts_to_go--;
854 
855  return TRUE;
856 }
static unsigned int block
Definition: xmlmemory.c:118
#define TRUE
Definition: types.h:120
#define HUFF_EXTEND(x, s)
Definition: jdhuff.c:578
static const WCHAR label2[]
Definition: itemdlg.c:1547
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
savable_state saved
Definition: jchuff.c:84
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
short JCOEF
Definition: jmorecfg.h:151
#define CHECK_BIT_BUFFER(state, nbits, action)
Definition: jdhuff.c:135
unsigned int restart_interval
Definition: jpeglib.h:594
if(!(yy_init))
Definition: macro.lex.yy.c:714
JBLOCK FAR * JBLOCKROW
Definition: jpeglib.h:80
GLdouble s
Definition: gl.h:2039
const int * natural_order
Definition: jpeglib.h:666
process_restart(j_decompress_ptr cinfo)
Definition: jdhuff.c:652
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
Definition: jdhuff.c:168
#define BITREAD_SAVE_STATE(cinfop, permstate)
Definition: jdhuff.c:111
unsigned int EOBRUN
Definition: jdhuff.c:199
#define GET_BITS(nbits)
Definition: jdhuff.c:141
unsigned int restarts_to_go
Definition: jchuff.c:87
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684
int k
Definition: mpi.c:3369
#define BITREAD_LOAD_STATE(cinfop, permstate)
Definition: jdhuff.c:104
#define BITREAD_STATE_VARS
Definition: jdhuff.c:99

Referenced by start_pass_huff_decoder().

◆ decode_mcu_AC_refine()

decode_mcu_AC_refine ( j_decompress_ptr  cinfo,
JBLOCKROW MCU_data 
)

Definition at line 913 of file jdhuff.c.

914 {
915  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
916  register int s, k, r;
917  unsigned int EOBRUN;
918  int Se, p1, m1;
919  const int * natural_order;
921  JCOEFPTR thiscoef;
923  d_derived_tbl * tbl;
924  int num_newnz;
925  int newnz_pos[DCTSIZE2];
926 
927  /* Process restart marker if needed; may have to suspend */
928  if (cinfo->restart_interval) {
929  if (entropy->restarts_to_go == 0)
930  if (! process_restart(cinfo))
931  return FALSE;
932  }
933 
934  /* If we've run out of data, don't modify the MCU.
935  */
936  if (! entropy->insufficient_data) {
937 
938  Se = cinfo->Se;
939  p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
940  m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
941  natural_order = cinfo->natural_order;
942 
943  /* Load up working state */
944  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
945  EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
946 
947  /* There is always only one block per MCU */
948  block = MCU_data[0];
949  tbl = entropy->ac_derived_tbl;
950 
951  /* If we are forced to suspend, we must undo the assignments to any newly
952  * nonzero coefficients in the block, because otherwise we'd get confused
953  * next time about which coefficients were already nonzero.
954  * But we need not undo addition of bits to already-nonzero coefficients;
955  * instead, we can test the current bit to see if we already did it.
956  */
957  num_newnz = 0;
958 
959  /* initialize coefficient loop counter to start of band */
960  k = cinfo->Ss;
961 
962  if (EOBRUN == 0) {
963  do {
964  HUFF_DECODE(s, br_state, tbl, goto undoit, label3);
965  r = s >> 4;
966  s &= 15;
967  if (s) {
968  if (s != 1) /* size of new coef should always be 1 */
969  WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
970  CHECK_BIT_BUFFER(br_state, 1, goto undoit);
971  if (GET_BITS(1))
972  s = p1; /* newly nonzero coef is positive */
973  else
974  s = m1; /* newly nonzero coef is negative */
975  } else {
976  if (r != 15) {
977  EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */
978  if (r) {
979  CHECK_BIT_BUFFER(br_state, r, goto undoit);
980  r = GET_BITS(r);
981  EOBRUN += r;
982  }
983  break; /* rest of block is handled by EOB logic */
984  }
985  /* note s = 0 for processing ZRL */
986  }
987  /* Advance over already-nonzero coefs and r still-zero coefs,
988  * appending correction bits to the nonzeroes. A correction bit is 1
989  * if the absolute value of the coefficient must be increased.
990  */
991  do {
992  thiscoef = *block + natural_order[k];
993  if (*thiscoef) {
994  CHECK_BIT_BUFFER(br_state, 1, goto undoit);
995  if (GET_BITS(1)) {
996  if ((*thiscoef & p1) == 0) { /* do nothing if already set it */
997  if (*thiscoef >= 0)
998  *thiscoef += p1;
999  else
1000  *thiscoef += m1;
1001  }
1002  }
1003  } else {
1004  if (--r < 0)
1005  break; /* reached target zero coefficient */
1006  }
1007  k++;
1008  } while (k <= Se);
1009  if (s) {
1010  int pos = natural_order[k];
1011  /* Output newly nonzero coefficient */
1012  (*block)[pos] = (JCOEF) s;
1013  /* Remember its position in case we have to suspend */
1014  newnz_pos[num_newnz++] = pos;
1015  }
1016  k++;
1017  } while (k <= Se);
1018  }
1019 
1020  if (EOBRUN) {
1021  /* Scan any remaining coefficient positions after the end-of-band
1022  * (the last newly nonzero coefficient, if any). Append a correction
1023  * bit to each already-nonzero coefficient. A correction bit is 1
1024  * if the absolute value of the coefficient must be increased.
1025  */
1026  do {
1027  thiscoef = *block + natural_order[k];
1028  if (*thiscoef) {
1029  CHECK_BIT_BUFFER(br_state, 1, goto undoit);
1030  if (GET_BITS(1)) {
1031  if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */
1032  if (*thiscoef >= 0)
1033  *thiscoef += p1;
1034  else
1035  *thiscoef += m1;
1036  }
1037  }
1038  }
1039  k++;
1040  } while (k <= Se);
1041  /* Count one block completed in EOB run */
1042  EOBRUN--;
1043  }
1044 
1045  /* Completed MCU, so update state */
1046  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
1047  entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
1048  }
1049 
1050  /* Account for restart interval (no-op if not using restarts) */
1051  entropy->restarts_to_go--;
1052 
1053  return TRUE;
1054 
1055 undoit:
1056  /* Re-zero any output coefficients that we made newly nonzero */
1057  while (num_newnz)
1058  (*block)[newnz_pos[--num_newnz]] = 0;
1059 
1060  return FALSE;
1061 }
static unsigned int block
Definition: xmlmemory.c:118
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
savable_state saved
Definition: jchuff.c:84
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
short JCOEF
Definition: jmorecfg.h:151
#define CHECK_BIT_BUFFER(state, nbits, action)
Definition: jdhuff.c:135
#define DCTSIZE2
Definition: jpeglib.h:51
unsigned int restart_interval
Definition: jpeglib.h:594
if(!(yy_init))
Definition: macro.lex.yy.c:714
JBLOCK FAR * JBLOCKROW
Definition: jpeglib.h:80
#define WARNMS(cinfo, code)
Definition: jerror.h:251
JCOEF FAR * JCOEFPTR
Definition: jpeglib.h:84
GLdouble s
Definition: gl.h:2039
const int * natural_order
Definition: jpeglib.h:666
process_restart(j_decompress_ptr cinfo)
Definition: jdhuff.c:652
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
Definition: jdhuff.c:168
#define BITREAD_SAVE_STATE(cinfop, permstate)
Definition: jdhuff.c:111
unsigned int EOBRUN
Definition: jdhuff.c:199
#define GET_BITS(nbits)
Definition: jdhuff.c:141
unsigned int restarts_to_go
Definition: jchuff.c:87
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684
int k
Definition: mpi.c:3369
#define BITREAD_LOAD_STATE(cinfop, permstate)
Definition: jdhuff.c:104
#define BITREAD_STATE_VARS
Definition: jdhuff.c:99

Referenced by start_pass_huff_decoder().

◆ decode_mcu_DC_first()

decode_mcu_DC_first ( j_decompress_ptr  cinfo,
JBLOCKROW MCU_data 
)

Definition at line 708 of file jdhuff.c.

709 {
710  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
711  int Al = cinfo->Al;
712  register int s, r;
713  int blkn, ci;
717  d_derived_tbl * tbl;
719 
720  /* Process restart marker if needed; may have to suspend */
721  if (cinfo->restart_interval) {
722  if (entropy->restarts_to_go == 0)
723  if (! process_restart(cinfo))
724  return FALSE;
725  }
726 
727  /* If we've run out of data, just leave the MCU set to zeroes.
728  * This way, we return uniform gray for the remainder of the segment.
729  */
730  if (! entropy->insufficient_data) {
731 
732  /* Load up working state */
733  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
734  ASSIGN_STATE(state, entropy->saved);
735 
736  /* Outer loop handles each block in the MCU */
737 
738  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
739  block = MCU_data[blkn];
740  ci = cinfo->MCU_membership[blkn];
741  compptr = cinfo->cur_comp_info[ci];
742  tbl = entropy->derived_tbls[compptr->dc_tbl_no];
743 
744  /* Decode a single block's worth of coefficients */
745 
746  /* Section F.2.2.1: decode the DC coefficient difference */
747  HUFF_DECODE(s, br_state, tbl, return FALSE, label1);
748  if (s) {
749  CHECK_BIT_BUFFER(br_state, s, return FALSE);
750  r = GET_BITS(s);
751  s = HUFF_EXTEND(r, s);
752  }
753 
754  /* Convert DC difference to actual value, update last_dc_val */
755  s += state.last_dc_val[ci];
756  state.last_dc_val[ci] = s;
757  /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
758  (*block)[0] = (JCOEF) (s << Al);
759  }
760 
761  /* Completed MCU, so update state */
762  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
763  ASSIGN_STATE(entropy->saved, state);
764  }
765 
766  /* Account for restart interval (no-op if not using restarts) */
767  entropy->restarts_to_go--;
768 
769  return TRUE;
770 }
static unsigned int block
Definition: xmlmemory.c:118
#define TRUE
Definition: types.h:120
#define HUFF_EXTEND(x, s)
Definition: jdhuff.c:578
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]
Definition: jpeglib.h:650
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
savable_state saved
Definition: jchuff.c:84
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
short JCOEF
Definition: jmorecfg.h:151
jpeg_component_info * compptr
Definition: jdct.h:238
#define CHECK_BIT_BUFFER(state, nbits, action)
Definition: jdhuff.c:135
unsigned int restart_interval
Definition: jpeglib.h:594
if(!(yy_init))
Definition: macro.lex.yy.c:714
JBLOCK FAR * JBLOCKROW
Definition: jpeglib.h:80
static int state
Definition: maze.c:121
GLdouble s
Definition: gl.h:2039
#define ASSIGN_STATE(dest, src)
Definition: jdhuff.c:209
process_restart(j_decompress_ptr cinfo)
Definition: jdhuff.c:652
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
Definition: jdhuff.c:168
#define BITREAD_SAVE_STATE(cinfop, permstate)
Definition: jdhuff.c:111
int MCU_membership[D_MAX_BLOCKS_IN_MCU]
Definition: jpeglib.h:657
#define GET_BITS(nbits)
Definition: jdhuff.c:141
unsigned int restarts_to_go
Definition: jchuff.c:87
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684
#define BITREAD_LOAD_STATE(cinfop, permstate)
Definition: jdhuff.c:104
#define BITREAD_STATE_VARS
Definition: jdhuff.c:99

Referenced by start_pass_huff_decoder().

◆ decode_mcu_DC_refine()

decode_mcu_DC_refine ( j_decompress_ptr  cinfo,
JBLOCKROW MCU_data 
)

Definition at line 866 of file jdhuff.c.

867 {
868  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
869  int p1, blkn;
871 
872  /* Process restart marker if needed; may have to suspend */
873  if (cinfo->restart_interval) {
874  if (entropy->restarts_to_go == 0)
875  if (! process_restart(cinfo))
876  return FALSE;
877  }
878 
879  /* Not worth the cycles to check insufficient_data here,
880  * since we will not change the data anyway if we read zeroes.
881  */
882 
883  /* Load up working state */
884  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
885 
886  p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
887 
888  /* Outer loop handles each block in the MCU */
889 
890  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
891  /* Encoded data is simply the next bit of the two's-complement DC value */
892  CHECK_BIT_BUFFER(br_state, 1, return FALSE);
893  if (GET_BITS(1))
894  MCU_data[blkn][0][0] |= p1;
895  /* Note: since we use |=, repeating the assignment later is safe */
896  }
897 
898  /* Completed MCU, so update state */
899  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
900 
901  /* Account for restart interval (no-op if not using restarts) */
902  entropy->restarts_to_go--;
903 
904  return TRUE;
905 }
#define TRUE
Definition: types.h:120
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
#define CHECK_BIT_BUFFER(state, nbits, action)
Definition: jdhuff.c:135
unsigned int restart_interval
Definition: jpeglib.h:594
if(!(yy_init))
Definition: macro.lex.yy.c:714
process_restart(j_decompress_ptr cinfo)
Definition: jdhuff.c:652
#define BITREAD_SAVE_STATE(cinfop, permstate)
Definition: jdhuff.c:111
#define GET_BITS(nbits)
Definition: jdhuff.c:141
unsigned int restarts_to_go
Definition: jchuff.c:87
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684
#define BITREAD_LOAD_STATE(cinfop, permstate)
Definition: jdhuff.c:104
#define BITREAD_STATE_VARS
Definition: jdhuff.c:99

Referenced by start_pass_huff_decoder().

◆ decode_mcu_sub()

decode_mcu_sub ( j_decompress_ptr  cinfo,
JBLOCKROW MCU_data 
)

Definition at line 1070 of file jdhuff.c.

1071 {
1072  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1073  const int * natural_order;
1074  int Se, blkn;
1077 
1078  /* Process restart marker if needed; may have to suspend */
1079  if (cinfo->restart_interval) {
1080  if (entropy->restarts_to_go == 0)
1081  if (! process_restart(cinfo))
1082  return FALSE;
1083  }
1084 
1085  /* If we've run out of data, just leave the MCU set to zeroes.
1086  * This way, we return uniform gray for the remainder of the segment.
1087  */
1088  if (! entropy->insufficient_data) {
1089 
1090  natural_order = cinfo->natural_order;
1091  Se = cinfo->lim_Se;
1092 
1093  /* Load up working state */
1094  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
1095  ASSIGN_STATE(state, entropy->saved);
1096 
1097  /* Outer loop handles each block in the MCU */
1098 
1099  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1100  JBLOCKROW block = MCU_data[blkn];
1101  d_derived_tbl * htbl;
1102  register int s, k, r;
1103  int coef_limit, ci;
1104 
1105  /* Decode a single block's worth of coefficients */
1106 
1107  /* Section F.2.2.1: decode the DC coefficient difference */
1108  htbl = entropy->dc_cur_tbls[blkn];
1109  HUFF_DECODE(s, br_state, htbl, return FALSE, label1);
1110 
1111  htbl = entropy->ac_cur_tbls[blkn];
1112  k = 1;
1113  coef_limit = entropy->coef_limit[blkn];
1114  if (coef_limit) {
1115  /* Convert DC difference to actual value, update last_dc_val */
1116  if (s) {
1117  CHECK_BIT_BUFFER(br_state, s, return FALSE);
1118  r = GET_BITS(s);
1119  s = HUFF_EXTEND(r, s);
1120  }
1121  ci = cinfo->MCU_membership[blkn];
1122  s += state.last_dc_val[ci];
1123  state.last_dc_val[ci] = s;
1124  /* Output the DC coefficient */
1125  (*block)[0] = (JCOEF) s;
1126 
1127  /* Section F.2.2.2: decode the AC coefficients */
1128  /* Since zeroes are skipped, output area must be cleared beforehand */
1129  for (; k < coef_limit; k++) {
1130  HUFF_DECODE(s, br_state, htbl, return FALSE, label2);
1131 
1132  r = s >> 4;
1133  s &= 15;
1134 
1135  if (s) {
1136  k += r;
1137  CHECK_BIT_BUFFER(br_state, s, return FALSE);
1138  r = GET_BITS(s);
1139  s = HUFF_EXTEND(r, s);
1140  /* Output coefficient in natural (dezigzagged) order.
1141  * Note: the extra entries in natural_order[] will save us
1142  * if k > Se, which could happen if the data is corrupted.
1143  */
1144  (*block)[natural_order[k]] = (JCOEF) s;
1145  } else {
1146  if (r != 15)
1147  goto EndOfBlock;
1148  k += 15;
1149  }
1150  }
1151  } else {
1152  if (s) {
1153  CHECK_BIT_BUFFER(br_state, s, return FALSE);
1154  DROP_BITS(s);
1155  }
1156  }
1157 
1158  /* Section F.2.2.2: decode the AC coefficients */
1159  /* In this path we just discard the values */
1160  for (; k <= Se; k++) {
1161  HUFF_DECODE(s, br_state, htbl, return FALSE, label3);
1162 
1163  r = s >> 4;
1164  s &= 15;
1165 
1166  if (s) {
1167  k += r;
1168  CHECK_BIT_BUFFER(br_state, s, return FALSE);
1169  DROP_BITS(s);
1170  } else {
1171  if (r != 15)
1172  break;
1173  k += 15;
1174  }
1175  }
1176 
1177  EndOfBlock: ;
1178  }
1179 
1180  /* Completed MCU, so update state */
1181  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
1182  ASSIGN_STATE(entropy->saved, state);
1183  }
1184 
1185  /* Account for restart interval (no-op if not using restarts) */
1186  entropy->restarts_to_go--;
1187 
1188  return TRUE;
1189 }
static unsigned int block
Definition: xmlmemory.c:118
#define TRUE
Definition: types.h:120
#define HUFF_EXTEND(x, s)
Definition: jdhuff.c:578
static const WCHAR label2[]
Definition: itemdlg.c:1547
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
savable_state saved
Definition: jchuff.c:84
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
short JCOEF
Definition: jmorecfg.h:151
#define CHECK_BIT_BUFFER(state, nbits, action)
Definition: jdhuff.c:135
#define DROP_BITS(nbits)
Definition: jdhuff.c:147
unsigned int restart_interval
Definition: jpeglib.h:594
if(!(yy_init))
Definition: macro.lex.yy.c:714
JBLOCK FAR * JBLOCKROW
Definition: jpeglib.h:80
static int state
Definition: maze.c:121
GLdouble s
Definition: gl.h:2039
#define ASSIGN_STATE(dest, src)
Definition: jdhuff.c:209
const int * natural_order
Definition: jpeglib.h:666
process_restart(j_decompress_ptr cinfo)
Definition: jdhuff.c:652
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
Definition: jdhuff.c:168
#define BITREAD_SAVE_STATE(cinfop, permstate)
Definition: jdhuff.c:111
int MCU_membership[D_MAX_BLOCKS_IN_MCU]
Definition: jpeglib.h:657
#define GET_BITS(nbits)
Definition: jdhuff.c:141
unsigned int restarts_to_go
Definition: jchuff.c:87
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684
int k
Definition: mpi.c:3369
#define BITREAD_LOAD_STATE(cinfop, permstate)
Definition: jdhuff.c:104
#define BITREAD_STATE_VARS
Definition: jdhuff.c:99

Referenced by start_pass_huff_decoder().

◆ finish_pass_huff()

finish_pass_huff ( j_decompress_ptr  cinfo)

Definition at line 635 of file jdhuff.c.

636 {
637  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
638 
639  /* Throw away any unused bits remaining in bit buffer; */
640  /* include any full bytes in next_marker's count of discarded bytes */
641  cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
642  entropy->bitstate.bits_left = 0;
643 }
struct jpeg_marker_reader * marker
Definition: jpeglib.h:683
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684

Referenced by jinit_huff_decoder(), and process_restart().

◆ jinit_huff_decoder()

jinit_huff_decoder ( j_decompress_ptr  cinfo)

Definition at line 1520 of file jdhuff.c.

1521 {
1522  huff_entropy_ptr entropy;
1523  int i;
1524 
1525  entropy = (huff_entropy_ptr)
1526  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
1528  cinfo->entropy = &entropy->pub;
1529  entropy->pub.start_pass = start_pass_huff_decoder;
1530  entropy->pub.finish_pass = finish_pass_huff;
1531 
1532  if (cinfo->progressive_mode) {
1533  /* Create progression status table */
1534  int *coef_bit_ptr, ci;
1535  cinfo->coef_bits = (int (*)[DCTSIZE2])
1536  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
1537  cinfo->num_components*DCTSIZE2*SIZEOF(int));
1538  coef_bit_ptr = & cinfo->coef_bits[0][0];
1539  for (ci = 0; ci < cinfo->num_components; ci++)
1540  for (i = 0; i < DCTSIZE2; i++)
1541  *coef_bit_ptr++ = -1;
1542 
1543  /* Mark derived tables unallocated */
1544  for (i = 0; i < NUM_HUFF_TBLS; i++) {
1545  entropy->derived_tbls[i] = NULL;
1546  }
1547  } else {
1548  /* Mark tables unallocated */
1549  for (i = 0; i < NUM_HUFF_TBLS; i++) {
1550  entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
1551  }
1552  }
1553 }
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
#define NUM_HUFF_TBLS
Definition: jpeglib.h:53
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
finish_pass_huff(j_decompress_ptr cinfo)
Definition: jdhuff.c:635
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SIZEOF(_ar)
Definition: calc.h:97
#define JPOOL_IMAGE
Definition: jpeglib.h:808
c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]
Definition: jchuff.c:92
smooth NULL
Definition: ftsmooth.c:416
#define DCTSIZE2
Definition: jpeglib.h:51
struct jpeg_entropy_encoder pub
Definition: jchuff.c:82
start_pass_huff_decoder(j_decompress_ptr cinfo)
Definition: jdhuff.c:1321
boolean progressive_mode
Definition: jpeglib.h:587
int(* coef_bits)[DCTSIZE2]
Definition: jpeglib.h:559
c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]
Definition: jchuff.c:91
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by master_selection(), and transdecode_master_selection().

◆ jpeg_fill_bit_buffer()

jpeg_fill_bit_buffer ( bitread_working_state state,
register bit_buf_type  get_buffer,
register int  bits_left,
int  nbits 
)

Definition at line 465 of file jdhuff.c.

469 {
470  /* Copy heavily used state fields into locals (hopefully registers) */
471  register const JOCTET * next_input_byte = state->next_input_byte;
472  register size_t bytes_in_buffer = state->bytes_in_buffer;
473  j_decompress_ptr cinfo = state->cinfo;
474 
475  /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */
476  /* (It is assumed that no request will be for more than that many bits.) */
477  /* We fail to do so only if we hit a marker or are forced to suspend. */
478 
479  if (cinfo->unread_marker == 0) { /* cannot advance past a marker */
480  while (bits_left < MIN_GET_BITS) {
481  register int c;
482 
483  /* Attempt to read a byte */
484  if (bytes_in_buffer == 0) {
485  if (! (*cinfo->src->fill_input_buffer) (cinfo))
486  return FALSE;
487  next_input_byte = cinfo->src->next_input_byte;
488  bytes_in_buffer = cinfo->src->bytes_in_buffer;
489  }
490  bytes_in_buffer--;
491  c = GETJOCTET(*next_input_byte++);
492 
493  /* If it's 0xFF, check and discard stuffed zero byte */
494  if (c == 0xFF) {
495  /* Loop here to discard any padding FF's on terminating marker,
496  * so that we can save a valid unread_marker value. NOTE: we will
497  * accept multiple FF's followed by a 0 as meaning a single FF data
498  * byte. This data pattern is not valid according to the standard.
499  */
500  do {
501  if (bytes_in_buffer == 0) {
502  if (! (*cinfo->src->fill_input_buffer) (cinfo))
503  return FALSE;
504  next_input_byte = cinfo->src->next_input_byte;
505  bytes_in_buffer = cinfo->src->bytes_in_buffer;
506  }
507  bytes_in_buffer--;
508  c = GETJOCTET(*next_input_byte++);
509  } while (c == 0xFF);
510 
511  if (c == 0) {
512  /* Found FF/00, which represents an FF data byte */
513  c = 0xFF;
514  } else {
515  /* Oops, it's actually a marker indicating end of compressed data.
516  * Save the marker code for later use.
517  * Fine point: it might appear that we should save the marker into
518  * bitread working state, not straight into permanent state. But
519  * once we have hit a marker, we cannot need to suspend within the
520  * current MCU, because we will read no more bytes from the data
521  * source. So it is OK to update permanent state right away.
522  */
523  cinfo->unread_marker = c;
524  /* See if we need to insert some fake zero bits. */
525  goto no_more_bytes;
526  }
527  }
528 
529  /* OK, load c into get_buffer */
530  get_buffer = (get_buffer << 8) | c;
531  bits_left += 8;
532  } /* end while */
533  } else {
534  no_more_bytes:
535  /* We get here if we've read the marker that terminates the compressed
536  * data segment. There should be enough bits in the buffer register
537  * to satisfy the request; if so, no problem.
538  */
539  if (nbits > bits_left) {
540  /* Uh-oh. Report corrupted data to user and stuff zeroes into
541  * the data stream, so that we can produce some kind of image.
542  * We use a nonvolatile flag to ensure that only one warning message
543  * appears per data segment.
544  */
545  if (! ((huff_entropy_ptr) cinfo->entropy)->insufficient_data) {
546  WARNMS(cinfo, JWRN_HIT_MARKER);
547  ((huff_entropy_ptr) cinfo->entropy)->insufficient_data = TRUE;
548  }
549  /* Fill the buffer with zero bits */
550  get_buffer <<= MIN_GET_BITS - bits_left;
551  bits_left = MIN_GET_BITS;
552  }
553  }
554 
555  /* Unload the local registers */
556  state->next_input_byte = next_input_byte;
557  state->bytes_in_buffer = bytes_in_buffer;
558  state->get_buffer = get_buffer;
559  state->bits_left = bits_left;
560 
561  return TRUE;
562 }
#define TRUE
Definition: types.h:120
#define MIN_GET_BITS
Definition: jdhuff.c:460
#define GETJOCTET(value)
Definition: jmorecfg.h:171
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
const GLubyte * c
Definition: glext.h:8905
#define WARNMS(cinfo, code)
Definition: jerror.h:251
static int state
Definition: maze.c:121
struct jpeg_source_mgr * src
Definition: jpeglib.h:463
#define c
Definition: ke_i.h:80
NTSTATUS get_buffer(LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
Definition: libsupp.c:645
char JOCTET
Definition: jmorecfg.h:167
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684

◆ jpeg_huff_decode()

jpeg_huff_decode ( bitread_working_state state,
register bit_buf_type  get_buffer,
register int  bits_left,
d_derived_tbl htbl,
int  min_bits 
)

Definition at line 592 of file jdhuff.c.

595 {
596  register int l = min_bits;
597  register INT32 code;
598 
599  /* HUFF_DECODE has determined that the code is at least min_bits */
600  /* bits long, so fetch that many bits in one swoop. */
601 
602  CHECK_BIT_BUFFER(*state, l, return -1);
603  code = GET_BITS(l);
604 
605  /* Collect the rest of the Huffman code one bit at a time. */
606  /* This is per Figure F.16 in the JPEG spec. */
607 
608  while (code > htbl->maxcode[l]) {
609  code <<= 1;
610  CHECK_BIT_BUFFER(*state, 1, return -1);
611  code |= GET_BITS(1);
612  l++;
613  }
614 
615  /* Unload the local registers */
616  state->get_buffer = get_buffer;
617  state->bits_left = bits_left;
618 
619  /* With garbage input we may reach the sentinel value l = 17. */
620 
621  if (l > 16) {
622  WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);
623  return 0; /* fake a zero as the safest result */
624  }
625 
626  return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ];
627 }
INT32 valoffset[17]
Definition: jdhuff.c:32
UINT8 huffval[256]
Definition: jpeglib.h:113
#define CHECK_BIT_BUFFER(state, nbits, action)
Definition: jdhuff.c:135
r l[0]
Definition: byte_order.h:167
#define WARNMS(cinfo, code)
Definition: jerror.h:251
INT32 maxcode[18]
Definition: jdhuff.c:30
static int state
Definition: maze.c:121
int code
Definition: i386-dis.c:3591
#define GET_BITS(nbits)
Definition: jdhuff.c:141
NTSTATUS get_buffer(LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
Definition: libsupp.c:645
signed int INT32
JHUFF_TBL * pub
Definition: jdhuff.c:39
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ jpeg_make_d_derived_tbl()

jpeg_make_d_derived_tbl ( j_decompress_ptr  cinfo,
boolean  isDC,
int  tblno,
d_derived_tbl **  pdtbl 
)

Definition at line 323 of file jdhuff.c.

325 {
326  JHUFF_TBL *htbl;
327  d_derived_tbl *dtbl;
328  int p, i, l, si, numsymbols;
329  int lookbits, ctr;
330  char huffsize[257];
331  unsigned int huffcode[257];
332  unsigned int code;
333 
334  /* Note that huffsize[] and huffcode[] are filled in code-length order,
335  * paralleling the order of the symbols themselves in htbl->huffval[].
336  */
337 
338  /* Find the input Huffman table */
339  if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
340  ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
341  htbl =
342  isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
343  if (htbl == NULL)
344  ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
345 
346  /* Allocate a workspace if we haven't already done so. */
347  if (*pdtbl == NULL)
348  *pdtbl = (d_derived_tbl *)
349  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
351  dtbl = *pdtbl;
352  dtbl->pub = htbl; /* fill in back link */
353 
354  /* Figure C.1: make table of Huffman code length for each symbol */
355 
356  p = 0;
357  for (l = 1; l <= 16; l++) {
358  i = (int) htbl->bits[l];
359  if (i < 0 || p + i > 256) /* protect against table overrun */
360  ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
361  while (i--)
362  huffsize[p++] = (char) l;
363  }
364  huffsize[p] = 0;
365  numsymbols = p;
366 
367  /* Figure C.2: generate the codes themselves */
368  /* We also validate that the counts represent a legal Huffman code tree. */
369 
370  code = 0;
371  si = huffsize[0];
372  p = 0;
373  while (huffsize[p]) {
374  while (((int) huffsize[p]) == si) {
375  huffcode[p++] = code;
376  code++;
377  }
378  /* code is now 1 more than the last code used for codelength si; but
379  * it must still fit in si bits, since no code is allowed to be all ones.
380  */
381  if (((INT32) code) >= (((INT32) 1) << si))
382  ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
383  code <<= 1;
384  si++;
385  }
386 
387  /* Figure F.15: generate decoding tables for bit-sequential decoding */
388 
389  p = 0;
390  for (l = 1; l <= 16; l++) {
391  if (htbl->bits[l]) {
392  /* valoffset[l] = huffval[] index of 1st symbol of code length l,
393  * minus the minimum code of length l
394  */
395  dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p];
396  p += htbl->bits[l];
397  dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */
398  } else {
399  dtbl->maxcode[l] = -1; /* -1 if no codes of this length */
400  }
401  }
402  dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */
403 
404  /* Compute lookahead tables to speed up decoding.
405  * First we set all the table entries to 0, indicating "too long";
406  * then we iterate through the Huffman codes that are short enough and
407  * fill in all the entries that correspond to bit sequences starting
408  * with that code.
409  */
410 
411  MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits));
412 
413  p = 0;
414  for (l = 1; l <= HUFF_LOOKAHEAD; l++) {
415  for (i = 1; i <= (int) htbl->bits[l]; i++, p++) {
416  /* l = current code's length, p = its index in huffcode[] & huffval[]. */
417  /* Generate left-justified code followed by all possible bit sequences */
418  lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);
419  for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {
420  dtbl->look_nbits[lookbits] = l;
421  dtbl->look_sym[lookbits] = htbl->huffval[p];
422  lookbits++;
423  }
424  }
425  }
426 
427  /* Validate symbols as being reasonable.
428  * For AC tables, we make no check, but accept all byte values 0..255.
429  * For DC tables, we require the symbols to be in range 0..15.
430  * (Tighter bounds could be applied depending on the data depth and mode,
431  * but this is sufficient to ensure safe decoding.)
432  */
433  if (isDC) {
434  for (i = 0; i < numsymbols; i++) {
435  int sym = htbl->huffval[i];
436  if (sym < 0 || sym > 15)
437  ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
438  }
439  }
440 }
UINT8 look_sym[1<< HUFF_LOOKAHEAD]
Definition: jdhuff.c:47
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
INT32 valoffset[17]
Definition: jdhuff.c:32
UINT8 huffval[256]
Definition: jpeglib.h:113
int look_nbits[1<< HUFF_LOOKAHEAD]
Definition: jdhuff.c:46
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]
Definition: jpeglib.h:573
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
#define NUM_HUFF_TBLS
Definition: jpeglib.h:53
#define MEMZERO(addr, type, size)
Definition: svc_dg.c:324
#define HUFF_LOOKAHEAD
Definition: jdhuff.c:26
UINT8 bits[17]
Definition: jpeglib.h:111
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SIZEOF(_ar)
Definition: calc.h:97
#define JPOOL_IMAGE
Definition: jpeglib.h:808
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:29
r l[0]
Definition: byte_order.h:167
if(!(yy_init))
Definition: macro.lex.yy.c:714
INT32 maxcode[18]
Definition: jdhuff.c:30
static const WCHAR L[]
Definition: oid.c:1250
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:212
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]
Definition: jpeglib.h:574
int code
Definition: i386-dis.c:3591
signed int INT32
JHUFF_TBL * pub
Definition: jdhuff.c:39
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by start_pass_huff_decoder().

◆ process_restart()

process_restart ( j_decompress_ptr  cinfo)

Definition at line 652 of file jdhuff.c.

653 {
654  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
655  int ci;
656 
657  finish_pass_huff(cinfo);
658 
659  /* Advance past the RSTn marker */
660  if (! (*cinfo->marker->read_restart_marker) (cinfo))
661  return FALSE;
662 
663  /* Re-initialize DC predictions to 0 */
664  for (ci = 0; ci < cinfo->comps_in_scan; ci++)
665  entropy->saved.last_dc_val[ci] = 0;
666  /* Re-init EOB run count, too */
667  entropy->saved.EOBRUN = 0;
668 
669  /* Reset restart counter */
670  entropy->restarts_to_go = cinfo->restart_interval;
671 
672  /* Reset out-of-data flag, unless read_restart_marker left us smack up
673  * against a marker. In that case we will end up treating the next data
674  * segment as empty, and we can avoid producing bogus output pixels by
675  * leaving the flag set.
676  */
677  if (cinfo->unread_marker == 0)
678  entropy->insufficient_data = FALSE;
679 
680  return TRUE;
681 }
#define TRUE
Definition: types.h:120
struct jpeg_marker_reader * marker
Definition: jpeglib.h:683
savable_state saved
Definition: jchuff.c:84
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
finish_pass_huff(j_decompress_ptr cinfo)
Definition: jdhuff.c:635
unsigned int restart_interval
Definition: jpeglib.h:594
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned int EOBRUN
Definition: jdhuff.c:199
int last_dc_val[MAX_COMPS_IN_SCAN]
Definition: jchuff.c:58
unsigned int restarts_to_go
Definition: jchuff.c:87
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684

Referenced by decode_mcu(), decode_mcu_AC_first(), decode_mcu_AC_refine(), decode_mcu_DC_first(), decode_mcu_DC_refine(), and decode_mcu_sub().

◆ start_pass_huff_decoder()

start_pass_huff_decoder ( j_decompress_ptr  cinfo)

Definition at line 1321 of file jdhuff.c.

1322 {
1323  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1324  int ci, blkn, tbl, i;
1326 
1327  if (cinfo->progressive_mode) {
1328  /* Validate progressive scan parameters */
1329  if (cinfo->Ss == 0) {
1330  if (cinfo->Se != 0)
1331  goto bad;
1332  } else {
1333  /* need not check Ss/Se < 0 since they came from unsigned bytes */
1334  if (cinfo->Se < cinfo->Ss || cinfo->Se > cinfo->lim_Se)
1335  goto bad;
1336  /* AC scans may have only one component */
1337  if (cinfo->comps_in_scan != 1)
1338  goto bad;
1339  }
1340  if (cinfo->Ah != 0) {
1341  /* Successive approximation refinement scan: must have Al = Ah-1. */
1342  if (cinfo->Ah-1 != cinfo->Al)
1343  goto bad;
1344  }
1345  if (cinfo->Al > 13) { /* need not check for < 0 */
1346  /* Arguably the maximum Al value should be less than 13 for 8-bit precision,
1347  * but the spec doesn't say so, and we try to be liberal about what we
1348  * accept. Note: large Al values could result in out-of-range DC
1349  * coefficients during early scans, leading to bizarre displays due to
1350  * overflows in the IDCT math. But we won't crash.
1351  */
1352  bad:
1353  ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
1354  cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
1355  }
1356  /* Update progression status, and verify that scan order is legal.
1357  * Note that inter-scan inconsistencies are treated as warnings
1358  * not fatal errors ... not clear if this is right way to behave.
1359  */
1360  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1361  int coefi, cindex = cinfo->cur_comp_info[ci]->component_index;
1362  int *coef_bit_ptr = & cinfo->coef_bits[cindex][0];
1363  if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
1364  WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
1365  for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
1366  int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
1367  if (cinfo->Ah != expected)
1368  WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
1369  coef_bit_ptr[coefi] = cinfo->Al;
1370  }
1371  }
1372 
1373  /* Select MCU decoding routine */
1374  if (cinfo->Ah == 0) {
1375  if (cinfo->Ss == 0)
1376  entropy->pub.decode_mcu = decode_mcu_DC_first;
1377  else
1378  entropy->pub.decode_mcu = decode_mcu_AC_first;
1379  } else {
1380  if (cinfo->Ss == 0)
1381  entropy->pub.decode_mcu = decode_mcu_DC_refine;
1382  else
1383  entropy->pub.decode_mcu = decode_mcu_AC_refine;
1384  }
1385 
1386  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1387  compptr = cinfo->cur_comp_info[ci];
1388  /* Make sure requested tables are present, and compute derived tables.
1389  * We may build same derived table more than once, but it's not expensive.
1390  */
1391  if (cinfo->Ss == 0) {
1392  if (cinfo->Ah == 0) { /* DC refinement needs no table */
1393  tbl = compptr->dc_tbl_no;
1394  jpeg_make_d_derived_tbl(cinfo, TRUE, tbl,
1395  & entropy->derived_tbls[tbl]);
1396  }
1397  } else {
1398  tbl = compptr->ac_tbl_no;
1399  jpeg_make_d_derived_tbl(cinfo, FALSE, tbl,
1400  & entropy->derived_tbls[tbl]);
1401  /* remember the single active table */
1402  entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
1403  }
1404  /* Initialize DC predictions to 0 */
1405  entropy->saved.last_dc_val[ci] = 0;
1406  }
1407 
1408  /* Initialize private state variables */
1409  entropy->saved.EOBRUN = 0;
1410  } else {
1411  /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
1412  * This ought to be an error condition, but we make it a warning because
1413  * there are some baseline files out there with all zeroes in these bytes.
1414  */
1415  if (cinfo->Ss != 0 || cinfo->Ah != 0 || cinfo->Al != 0 ||
1416  ((cinfo->is_baseline || cinfo->Se < DCTSIZE2) &&
1417  cinfo->Se != cinfo->lim_Se))
1418  WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
1419 
1420  /* Select MCU decoding routine */
1421  /* We retain the hard-coded case for full-size blocks.
1422  * This is not necessary, but it appears that this version is slightly
1423  * more performant in the given implementation.
1424  * With an improved implementation we would prefer a single optimized
1425  * function.
1426  */
1427  if (cinfo->lim_Se != DCTSIZE2-1)
1428  entropy->pub.decode_mcu = decode_mcu_sub;
1429  else
1430  entropy->pub.decode_mcu = decode_mcu;
1431 
1432  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1433  compptr = cinfo->cur_comp_info[ci];
1434  /* Compute derived values for Huffman tables */
1435  /* We may do this more than once for a table, but it's not expensive */
1436  tbl = compptr->dc_tbl_no;
1437  jpeg_make_d_derived_tbl(cinfo, TRUE, tbl,
1438  & entropy->dc_derived_tbls[tbl]);
1439  if (cinfo->lim_Se) { /* AC needs no table when not present */
1440  tbl = compptr->ac_tbl_no;
1441  jpeg_make_d_derived_tbl(cinfo, FALSE, tbl,
1442  & entropy->ac_derived_tbls[tbl]);
1443  }
1444  /* Initialize DC predictions to 0 */
1445  entropy->saved.last_dc_val[ci] = 0;
1446  }
1447 
1448  /* Precalculate decoding info for each block in an MCU of this scan */
1449  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1450  ci = cinfo->MCU_membership[blkn];
1451  compptr = cinfo->cur_comp_info[ci];
1452  /* Precalculate which table to use for each block */
1453  entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
1454  entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
1455  /* Decide whether we really care about the coefficient values */
1456  if (compptr->component_needed) {
1457  ci = compptr->DCT_v_scaled_size;
1459  switch (cinfo->lim_Se) {
1460  case (1*1-1):
1461  entropy->coef_limit[blkn] = 1;
1462  break;
1463  case (2*2-1):
1464  if (ci <= 0 || ci > 2) ci = 2;
1465  if (i <= 0 || i > 2) i = 2;
1466  entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order2[ci - 1][i - 1];
1467  break;
1468  case (3*3-1):
1469  if (ci <= 0 || ci > 3) ci = 3;
1470  if (i <= 0 || i > 3) i = 3;
1471  entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order3[ci - 1][i - 1];
1472  break;
1473  case (4*4-1):
1474  if (ci <= 0 || ci > 4) ci = 4;
1475  if (i <= 0 || i > 4) i = 4;
1476  entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order4[ci - 1][i - 1];
1477  break;
1478  case (5*5-1):
1479  if (ci <= 0 || ci > 5) ci = 5;
1480  if (i <= 0 || i > 5) i = 5;
1481  entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order5[ci - 1][i - 1];
1482  break;
1483  case (6*6-1):
1484  if (ci <= 0 || ci > 6) ci = 6;
1485  if (i <= 0 || i > 6) i = 6;
1486  entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order6[ci - 1][i - 1];
1487  break;
1488  case (7*7-1):
1489  if (ci <= 0 || ci > 7) ci = 7;
1490  if (i <= 0 || i > 7) i = 7;
1491  entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order7[ci - 1][i - 1];
1492  break;
1493  default:
1494  if (ci <= 0 || ci > 8) ci = 8;
1495  if (i <= 0 || i > 8) i = 8;
1496  entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order[ci - 1][i - 1];
1497  break;
1498  }
1499  } else {
1500  entropy->coef_limit[blkn] = 0;
1501  }
1502  }
1503  }
1504 
1505  /* Initialize bitread state variables */
1506  entropy->bitstate.bits_left = 0;
1507  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
1508  entropy->insufficient_data = FALSE;
1509 
1510  /* Initialize restart counter */
1511  entropy->restarts_to_go = cinfo->restart_interval;
1512 }
#define TRUE
Definition: types.h:120
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]
Definition: jpeglib.h:650
savable_state saved
Definition: jchuff.c:84
huff_entropy_decoder * huff_entropy_ptr
Definition: jdhuff.c:257
boolean component_needed
Definition: jpeglib.h:174
decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
Definition: jdhuff.c:708
jpeg_component_info * compptr
Definition: jdct.h:238
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define WARNMS2(cinfo, code, p1, p2)
Definition: jerror.h:258
static const int jpeg_zigzag_order4[4][4]
Definition: jdhuff.c:298
decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
Definition: jdhuff.c:866
c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]
Definition: jchuff.c:92
#define ERREXIT4(cinfo, code, p1, p2, p3, p4)
Definition: jerror.h:227
static const int jpeg_zigzag_order3[3][3]
Definition: jdhuff.c:305
jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC, int tblno, d_derived_tbl **pdtbl)
Definition: jdhuff.c:323
static const int jpeg_zigzag_order7[7][7]
Definition: jdhuff.c:271
#define DCTSIZE2
Definition: jpeglib.h:51
unsigned int restart_interval
Definition: jpeglib.h:594
decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
Definition: jdhuff.c:1198
if(!(yy_init))
Definition: macro.lex.yy.c:714
struct jpeg_entropy_encoder pub
Definition: jchuff.c:82
decode_mcu_sub(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
Definition: jdhuff.c:1070
static const int jpeg_zigzag_order2[2][2]
Definition: jdhuff.c:311
#define WARNMS(cinfo, code)
Definition: jerror.h:251
static const int jpeg_zigzag_order6[6][6]
Definition: jdhuff.c:281
decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
Definition: jdhuff.c:913
static const int jpeg_zigzag_order[8][8]
Definition: jdhuff.c:260
int MCU_membership[D_MAX_BLOCKS_IN_MCU]
Definition: jpeglib.h:657
unsigned int EOBRUN
Definition: jdhuff.c:199
int last_dc_val[MAX_COMPS_IN_SCAN]
Definition: jchuff.c:58
boolean progressive_mode
Definition: jpeglib.h:587
static const int jpeg_zigzag_order5[5][5]
Definition: jdhuff.c:290
unsigned int restarts_to_go
Definition: jchuff.c:87
int(* coef_bits)[DCTSIZE2]
Definition: jpeglib.h:559
c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]
Definition: jchuff.c:91
decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
Definition: jdhuff.c:779
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:684
BOOL expected
Definition: store.c:2063

Referenced by jinit_huff_decoder().

Variable Documentation

◆ bmask

const int bmask[16]
static
Initial value:
=
{ 0, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF,
0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF }

Definition at line 580 of file jdhuff.c.

◆ jpeg_zigzag_order

const int jpeg_zigzag_order[8][8]
static
Initial value:
= {
{ 0, 1, 5, 6, 14, 15, 27, 28 },
{ 2, 4, 7, 13, 16, 26, 29, 42 },
{ 3, 8, 12, 17, 25, 30, 41, 43 },
{ 9, 11, 18, 24, 31, 40, 44, 53 },
{ 10, 19, 23, 32, 39, 45, 52, 54 },
{ 20, 22, 33, 38, 46, 51, 55, 60 },
{ 21, 34, 37, 47, 50, 56, 59, 61 },
{ 35, 36, 48, 49, 57, 58, 62, 63 }
}

Definition at line 260 of file jdhuff.c.

Referenced by start_pass_huff_decoder().

◆ jpeg_zigzag_order2

const int jpeg_zigzag_order2[2][2]
static
Initial value:
= {
{ 0, 1 },
{ 2, 3 }
}

Definition at line 311 of file jdhuff.c.

Referenced by start_pass_huff_decoder().

◆ jpeg_zigzag_order3

const int jpeg_zigzag_order3[3][3]
static
Initial value:
= {
{ 0, 1, 5 },
{ 2, 4, 6 },
{ 3, 7, 8 }
}

Definition at line 305 of file jdhuff.c.

Referenced by start_pass_huff_decoder().

◆ jpeg_zigzag_order4

const int jpeg_zigzag_order4[4][4]
static
Initial value:
= {
{ 0, 1, 5, 6 },
{ 2, 4, 7, 12 },
{ 3, 8, 11, 13 },
{ 9, 10, 14, 15 }
}

Definition at line 298 of file jdhuff.c.

Referenced by start_pass_huff_decoder().

◆ jpeg_zigzag_order5

const int jpeg_zigzag_order5[5][5]
static
Initial value:
= {
{ 0, 1, 5, 6, 14 },
{ 2, 4, 7, 13, 15 },
{ 3, 8, 12, 16, 21 },
{ 9, 11, 17, 20, 22 },
{ 10, 18, 19, 23, 24 }
}

Definition at line 290 of file jdhuff.c.

Referenced by start_pass_huff_decoder().

◆ jpeg_zigzag_order6

const int jpeg_zigzag_order6[6][6]
static
Initial value:
= {
{ 0, 1, 5, 6, 14, 15 },
{ 2, 4, 7, 13, 16, 25 },
{ 3, 8, 12, 17, 24, 26 },
{ 9, 11, 18, 23, 27, 32 },
{ 10, 19, 22, 28, 31, 33 },
{ 20, 21, 29, 30, 34, 35 }
}

Definition at line 281 of file jdhuff.c.

Referenced by start_pass_huff_decoder().

◆ jpeg_zigzag_order7

const int jpeg_zigzag_order7[7][7]
static
Initial value:
= {
{ 0, 1, 5, 6, 14, 15, 27 },
{ 2, 4, 7, 13, 16, 26, 28 },
{ 3, 8, 12, 17, 25, 29, 38 },
{ 9, 11, 18, 24, 30, 37, 39 },
{ 10, 19, 23, 31, 36, 40, 45 },
{ 20, 22, 32, 35, 41, 44, 46 },
{ 21, 33, 34, 42, 43, 47, 48 }
}

Definition at line 271 of file jdhuff.c.

Referenced by start_pass_huff_decoder().