COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
jdcoefct.cpp File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jdcoefct.cpp:

Classes

struct  my_coef_controller
 

Macros

#define JPEG_INTERNALS
 
#define SAVED_COEFS   6 /* we save coef_bits[0..5] */
 
#define Q01_POS   1
 
#define Q10_POS   8
 
#define Q20_POS   16
 
#define Q11_POS   9
 
#define Q02_POS   2
 

Typedefs

typedef my_coef_controllermy_coef_ptr
 

Functions

static int decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
 
static int decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
 
static boolean smoothing_ok (j_decompress_ptr cinfo)
 
static int decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
 
static void start_iMCU_row (j_decompress_ptr cinfo)
 
static void start_input_pass (j_decompress_ptr cinfo)
 
static void start_output_pass (j_decompress_ptr cinfo)
 
static int dummy_consume_data (j_decompress_ptr cinfo)
 
static int consume_data (j_decompress_ptr cinfo)
 
void jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
 

Macro Definition Documentation

#define JPEG_INTERNALS
#define SAVED_COEFS   6 /* we save coef_bits[0..5] */
#define Q01_POS   1
#define Q10_POS   8
#define Q20_POS   16
#define Q11_POS   9
#define Q02_POS   2

Typedef Documentation

Function Documentation

static int decompress_onepass ( j_decompress_ptr  cinfo,
JSAMPIMAGE  output_buf 
)
static
148 {
149  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
150  JDIMENSION MCU_col_num; /* index of current MCU within row */
151  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
152  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
153  int blkn, ci, xindex, yindex, yoffset, useful_width;
154  JSAMPARRAY output_ptr;
155  JDIMENSION start_col, output_col;
157  inverse_DCT_method_ptr inverse_DCT;
158 
159  /* Loop to process as much as one whole iMCU row */
160  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
161  yoffset++) {
162  for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
163  MCU_col_num++) {
164  /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
165  jzero_far((void FAR *) coef->MCU_buffer[0],
166  (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
167  if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
168  /* Suspension forced; update state counters and exit */
169  coef->MCU_vert_offset = yoffset;
170  coef->MCU_ctr = MCU_col_num;
171  return JPEG_SUSPENDED;
172  }
173  /* Determine where data should go in output_buf and do the IDCT thing.
174  * We skip dummy blocks at the right and bottom edges (but blkn gets
175  * incremented past them!). Note the inner loop relies on having
176  * allocated the MCU_buffer[] blocks sequentially.
177  */
178  blkn = 0; /* index of current DCT block within MCU */
179  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
180  compptr = cinfo->cur_comp_info[ci];
181  /* Don't bother to IDCT an uninteresting component. */
182  if (! compptr->component_needed) {
183  blkn += compptr->MCU_blocks;
184  continue;
185  }
186  inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
187  useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
189  output_ptr = output_buf[compptr->component_index] +
190  yoffset * compptr->DCT_scaled_size;
191  start_col = MCU_col_num * compptr->MCU_sample_width;
192  for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
193  if (cinfo->input_iMCU_row < last_iMCU_row ||
194  yoffset+yindex < compptr->last_row_height) {
195  output_col = start_col;
196  for (xindex = 0; xindex < useful_width; xindex++) {
197  (*inverse_DCT) (cinfo, compptr,
198  (JCOEFPTR) coef->MCU_buffer[blkn+xindex],
199  output_ptr, output_col);
201  }
202  }
203  blkn += compptr->MCU_width;
204  output_ptr += compptr->DCT_scaled_size;
205  }
206  }
207  }
208  /* Completed an MCU row, but perhaps not an iMCU row */
209  coef->MCU_ctr = 0;
210  }
211  /* Completed the iMCU row, advance counters for next one */
212  cinfo->output_iMCU_row++;
213  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
214  start_iMCU_row(cinfo);
215  return JPEG_ROW_COMPLETED;
216  }
217  /* Completed the scan */
218  (*cinfo->inputctl->finish_input_pass) (cinfo);
219  return JPEG_SCAN_COMPLETED;
220 }
JDIMENSION MCU_ctr
Definition: jdcoefct.cpp:33
jpeg_component_info * cur_comp_info[4]
Definition: jpeglib.h:602
int comps_in_scan
Definition: jpeglib.h:601
struct jpeg_input_controller * inputctl
Definition: jpeglib.h:628
int MCU_height
Definition: jpeglib.h:170
inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]
Definition: jpegint.h:228
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
int DCT_scaled_size
Definition: jpeglib.h:152
static void start_iMCU_row(j_decompress_ptr cinfo)
Definition: jdcoefct.cpp:79
#define JPEG_ROW_COMPLETED
Definition: jpeglib.h:1003
int MCU_blocks
Definition: jpeglib.h:171
#define SIZEOF(object)
Definition: jinclude.h:80
boolean component_needed
Definition: jpeglib.h:165
jpeg_component_info * compptr
Definition: jdct.h:102
int MCU_vert_offset
Definition: jccoefct.cpp:39
jpeg_component_info JCOEFPTR JSAMPARRAY JDIMENSION output_col
Definition: jdct.h:102
int MCU_width
Definition: jpeglib.h:169
int component_index
Definition: jpeglib.h:126
static double coef[360+1][360+1][2]
Definition: physicslib.cpp:39
#define FAR
Definition: jmorecfg.h:215
JCOEF * JCOEFPTR
Definition: jpeglib.h:80
JCOEF JBLOCK[64]
Definition: jpeglib.h:75
JSAMPROW * JSAMPARRAY
Definition: jpeglib.h:72
Definition: jpeglib.h:121
Definition: jccoefct.cpp:34
int MCU_sample_width
Definition: jpeglib.h:172
JBLOCKROW MCU_buffer[10]
Definition: jccoefct.cpp:51
#define JPEG_SCAN_COMPLETED
Definition: jpeglib.h:1004
JDIMENSION input_iMCU_row
Definition: jpeglib.h:500
#define JPEG_SUSPENDED
Definition: jpeglib.h:970
JDIMENSION MCUs_per_row
Definition: jpeglib.h:605
JDIMENSION output_iMCU_row
Definition: jpeglib.h:507
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:102
unsigned int JDIMENSION
Definition: jmorecfg.h:171
int blocks_in_MCU
Definition: jpeglib.h:608
struct jpeg_inverse_dct * idct
Definition: jpeglib.h:631
my_coef_controller * my_coef_ptr
Definition: jdcoefct.cpp:62
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:630
int last_col_width
Definition: jpeglib.h:173
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:585
void jzero_far(void *target, size_t bytestozero)
Definition: jutils.cpp:165
static int decompress_data ( j_decompress_ptr  cinfo,
JSAMPIMAGE  output_buf 
)
static
316 {
317  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
318  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
319  JDIMENSION block_num;
320  int ci, block_row, block_rows;
322  JBLOCKROW buffer_ptr;
323  JSAMPARRAY output_ptr;
326  inverse_DCT_method_ptr inverse_DCT;
327 
328  /* Force some input to be done if we are getting ahead of the input. */
329  while (cinfo->input_scan_number < cinfo->output_scan_number ||
330  (cinfo->input_scan_number == cinfo->output_scan_number &&
331  cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
332  if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
333  return JPEG_SUSPENDED;
334  }
335 
336  /* OK, output from the virtual arrays. */
337  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
338  ci++, compptr++) {
339  /* Don't bother to IDCT an uninteresting component. */
340  if (! compptr->component_needed)
341  continue;
342  /* Align the virtual buffer for this component. */
343  buffer = (*cinfo->mem->access_virt_barray)
344  ((j_common_ptr) cinfo, coef->whole_image[ci],
347  /* Count non-dummy DCT block rows in this iMCU row. */
348  if (cinfo->output_iMCU_row < last_iMCU_row)
349  block_rows = compptr->v_samp_factor;
350  else {
351  /* NB: can't use last_row_height here; it is input-side-dependent! */
352  block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
353  if (block_rows == 0) block_rows = compptr->v_samp_factor;
354  }
355  inverse_DCT = cinfo->idct->inverse_DCT[ci];
356  output_ptr = output_buf[ci];
357  /* Loop over all DCT blocks to be processed. */
358  for (block_row = 0; block_row < block_rows; block_row++) {
359  buffer_ptr = buffer[block_row];
360  output_col = 0;
361  for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {
362  (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
363  output_ptr, output_col);
364  buffer_ptr++;
366  }
367  output_ptr += compptr->DCT_scaled_size;
368  }
369  }
370 
371  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
372  return JPEG_ROW_COMPLETED;
373  return JPEG_SCAN_COMPLETED;
374 }
int v_samp_factor
Definition: jpeglib.h:128
JBLOCKARRAY(* access_virt_barray)()
Definition: jpeglib.h:795
struct jpeg_input_controller * inputctl
Definition: jpeglib.h:628
jpeg_component_info * comp_info
Definition: jpeglib.h:540
inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]
Definition: jpegint.h:228
int output_scan_number
Definition: jpeglib.h:506
JBLOCKROW * JBLOCKARRAY
Definition: jpeglib.h:77
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
int DCT_scaled_size
Definition: jpeglib.h:152
#define JPEG_ROW_COMPLETED
Definition: jpeglib.h:1003
Definition: jpeglib.h:258
boolean component_needed
Definition: jpeglib.h:165
jpeg_component_info * compptr
Definition: jdct.h:102
JDIMENSION width_in_blocks
Definition: jpeglib.h:144
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:417
#define FALSE
Definition: jpleph.cpp:69
jpeg_component_info JCOEFPTR JSAMPARRAY JDIMENSION output_col
Definition: jdct.h:102
JDIMENSION height_in_blocks
Definition: jpeglib.h:145
static char buffer[255]
Definition: propagator_simple.cpp:60
int input_scan_number
Definition: jpeglib.h:499
static double coef[360+1][360+1][2]
Definition: physicslib.cpp:39
JCOEF * JCOEFPTR
Definition: jpeglib.h:80
JSAMPROW * JSAMPARRAY
Definition: jpeglib.h:72
Definition: jpeglib.h:121
Definition: jccoefct.cpp:34
JBLOCK * JBLOCKROW
Definition: jpeglib.h:76
#define JPEG_SCAN_COMPLETED
Definition: jpeglib.h:1004
JDIMENSION input_iMCU_row
Definition: jpeglib.h:500
#define JPEG_SUSPENDED
Definition: jpeglib.h:970
JDIMENSION output_iMCU_row
Definition: jpeglib.h:507
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:102
unsigned int JDIMENSION
Definition: jmorecfg.h:171
struct jpeg_inverse_dct * idct
Definition: jpeglib.h:631
jvirt_barray_ptr whole_image[10]
Definition: jccoefct.cpp:54
my_coef_controller * my_coef_ptr
Definition: jdcoefct.cpp:62
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:585
static boolean smoothing_ok ( j_decompress_ptr  cinfo)
static
406 {
407  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
408  boolean smoothing_useful = FALSE;
409  int ci, coefi;
411  JQUANT_TBL * qtable;
412  int * coef_bits;
413  int * coef_bits_latch;
414 
415  if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)
416  return FALSE;
417 
418  /* Allocate latch area if not already done */
419  if (coef->coef_bits_latch == NULL)
420  coef->coef_bits_latch = (int *)
421  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
422  cinfo->num_components *
423  (SAVED_COEFS * SIZEOF(int)));
424  coef_bits_latch = coef->coef_bits_latch;
425 
426  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
427  ci++, compptr++) {
428  /* All components' quantization values must already be latched. */
429  if ((qtable = compptr->quant_table) == NULL)
430  return FALSE;
431  /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */
432  if (qtable->quantval[0] == 0 ||
433  qtable->quantval[Q01_POS] == 0 ||
434  qtable->quantval[Q10_POS] == 0 ||
435  qtable->quantval[Q20_POS] == 0 ||
436  qtable->quantval[Q11_POS] == 0 ||
437  qtable->quantval[Q02_POS] == 0)
438  return FALSE;
439  /* DC values must be at least partly known for all components. */
440  coef_bits = cinfo->coef_bits[ci];
441  if (coef_bits[0] < 0)
442  return FALSE;
443  /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
444  for (coefi = 1; coefi <= 5; coefi++) {
445  coef_bits_latch[coefi] = coef_bits[coefi];
446  if (coef_bits[coefi] != 0)
447  smoothing_useful = TRUE;
448  }
449  coef_bits_latch += SAVED_COEFS;
450  }
451 
452  return smoothing_useful;
453 }
int num_components
Definition: jpeglib.h:427
jpeg_component_info * comp_info
Definition: jpeglib.h:540
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:266
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
void *(* alloc_small)()
Definition: jpeglib.h:764
Definition: jpeglib.h:88
#define SIZEOF(object)
Definition: jinclude.h:80
jpeg_component_info * compptr
Definition: jdct.h:102
#define JPOOL_IMAGE
Definition: jpeglib.h:754
#define Q20_POS
Definition: jdcoefct.cpp:392
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:417
#define FALSE
Definition: jpleph.cpp:69
#define Q11_POS
Definition: jdcoefct.cpp:393
int(* coef_bits)[64]
Definition: jpeglib.h:516
static double coef[360+1][360+1][2]
Definition: physicslib.cpp:39
#define TRUE
Definition: jpleph.cpp:68
JQUANT_TBL * quant_table
Definition: jpeglib.h:180
int * coef_bits_latch
Definition: jdcoefct.cpp:57
#define Q10_POS
Definition: jdcoefct.cpp:391
Definition: jpeglib.h:121
Definition: jccoefct.cpp:34
#define Q02_POS
Definition: jdcoefct.cpp:394
boolean progressive_mode
Definition: jpeglib.h:543
#define Q01_POS
Definition: jdcoefct.cpp:390
my_coef_controller * my_coef_ptr
Definition: jdcoefct.cpp:62
#define SAVED_COEFS
Definition: jdcoefct.cpp:58
static int decompress_smooth_data ( j_decompress_ptr  cinfo,
JSAMPIMAGE  output_buf 
)
static
462 {
463  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
464  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
465  JDIMENSION block_num, last_block_column;
466  int ci, block_row, block_rows, access_rows;
468  JBLOCKROW buffer_ptr, prev_block_row, next_block_row;
469  JSAMPARRAY output_ptr;
472  inverse_DCT_method_ptr inverse_DCT;
473  boolean first_row, last_row;
474  JBLOCK workspace;
475  int *coef_bits;
476  JQUANT_TBL *quanttbl;
477  int32_t Q00,Q01,Q02,Q10,Q11,Q20, num;
478  int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
479  int Al, pred;
480 
481  /* Force some input to be done if we are getting ahead of the input. */
482  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
483  ! cinfo->inputctl->eoi_reached) {
484  if (cinfo->input_scan_number == cinfo->output_scan_number) {
485  /* If input is working on current scan, we ordinarily want it to
486  * have completed the current row. But if input scan is DC,
487  * we want it to keep one row ahead so that next block row's DC
488  * values are up to date.
489  */
490  JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;
491  if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)
492  break;
493  }
494  if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
495  return JPEG_SUSPENDED;
496  }
497 
498  /* OK, output from the virtual arrays. */
499  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
500  ci++, compptr++) {
501  /* Don't bother to IDCT an uninteresting component. */
502  if (! compptr->component_needed)
503  continue;
504  /* Count non-dummy DCT block rows in this iMCU row. */
505  if (cinfo->output_iMCU_row < last_iMCU_row) {
506  block_rows = compptr->v_samp_factor;
507  access_rows = block_rows * 2; /* this and next iMCU row */
508  last_row = FALSE;
509  } else {
510  /* NB: can't use last_row_height here; it is input-side-dependent! */
511  block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
512  if (block_rows == 0) block_rows = compptr->v_samp_factor;
513  access_rows = block_rows; /* this iMCU row only */
514  last_row = TRUE;
515  }
516  /* Align the virtual buffer for this component. */
517  if (cinfo->output_iMCU_row > 0) {
518  access_rows += compptr->v_samp_factor; /* prior iMCU row too */
519  buffer = (*cinfo->mem->access_virt_barray)
520  ((j_common_ptr) cinfo, coef->whole_image[ci],
521  (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
522  (JDIMENSION) access_rows, FALSE);
523  buffer += compptr->v_samp_factor; /* point to current iMCU row */
524  first_row = FALSE;
525  } else {
526  buffer = (*cinfo->mem->access_virt_barray)
527  ((j_common_ptr) cinfo, coef->whole_image[ci],
528  (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);
529  first_row = TRUE;
530  }
531  /* Fetch component-dependent info */
532  coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
533  quanttbl = compptr->quant_table;
534  Q00 = quanttbl->quantval[0];
535  Q01 = quanttbl->quantval[Q01_POS];
536  Q10 = quanttbl->quantval[Q10_POS];
537  Q20 = quanttbl->quantval[Q20_POS];
538  Q11 = quanttbl->quantval[Q11_POS];
539  Q02 = quanttbl->quantval[Q02_POS];
540  inverse_DCT = cinfo->idct->inverse_DCT[ci];
541  output_ptr = output_buf[ci];
542  /* Loop over all DCT blocks to be processed. */
543  for (block_row = 0; block_row < block_rows; block_row++) {
544  buffer_ptr = buffer[block_row];
545  if (first_row && block_row == 0)
546  prev_block_row = buffer_ptr;
547  else
548  prev_block_row = buffer[block_row-1];
549  if (last_row && block_row == block_rows-1)
550  next_block_row = buffer_ptr;
551  else
552  next_block_row = buffer[block_row+1];
553  /* We fetch the surrounding DC values using a sliding-register approach.
554  * Initialize all nine here so as to do the right thing on narrow pics.
555  */
556  DC1 = DC2 = DC3 = (int) prev_block_row[0][0];
557  DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];
558  DC7 = DC8 = DC9 = (int) next_block_row[0][0];
559  output_col = 0;
560  last_block_column = compptr->width_in_blocks - 1;
561  for (block_num = 0; block_num <= last_block_column; block_num++) {
562  /* Fetch current DCT block into workspace so we can modify it. */
563  jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);
564  /* Update DC values */
565  if (block_num < last_block_column) {
566  DC3 = (int) prev_block_row[1][0];
567  DC6 = (int) buffer_ptr[1][0];
568  DC9 = (int) next_block_row[1][0];
569  }
570  /* Compute coefficient estimates per K.8.
571  * An estimate is applied only if coefficient is still zero,
572  * and is not known to be fully accurate.
573  */
574  /* AC01 */
575  if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
576  num = 36 * Q00 * (DC4 - DC6);
577  if (num >= 0) {
578  pred = (int) (((Q01<<7) + num) / (Q01<<8));
579  if (Al > 0 && pred >= (1<<Al))
580  pred = (1<<Al)-1;
581  } else {
582  pred = (int) (((Q01<<7) - num) / (Q01<<8));
583  if (Al > 0 && pred >= (1<<Al))
584  pred = (1<<Al)-1;
585  pred = -pred;
586  }
587  workspace[1] = (JCOEF) pred;
588  }
589  /* AC10 */
590  if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
591  num = 36 * Q00 * (DC2 - DC8);
592  if (num >= 0) {
593  pred = (int) (((Q10<<7) + num) / (Q10<<8));
594  if (Al > 0 && pred >= (1<<Al))
595  pred = (1<<Al)-1;
596  } else {
597  pred = (int) (((Q10<<7) - num) / (Q10<<8));
598  if (Al > 0 && pred >= (1<<Al))
599  pred = (1<<Al)-1;
600  pred = -pred;
601  }
602  workspace[8] = (JCOEF) pred;
603  }
604  /* AC20 */
605  if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
606  num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
607  if (num >= 0) {
608  pred = (int) (((Q20<<7) + num) / (Q20<<8));
609  if (Al > 0 && pred >= (1<<Al))
610  pred = (1<<Al)-1;
611  } else {
612  pred = (int) (((Q20<<7) - num) / (Q20<<8));
613  if (Al > 0 && pred >= (1<<Al))
614  pred = (1<<Al)-1;
615  pred = -pred;
616  }
617  workspace[16] = (JCOEF) pred;
618  }
619  /* AC11 */
620  if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
621  num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
622  if (num >= 0) {
623  pred = (int) (((Q11<<7) + num) / (Q11<<8));
624  if (Al > 0 && pred >= (1<<Al))
625  pred = (1<<Al)-1;
626  } else {
627  pred = (int) (((Q11<<7) - num) / (Q11<<8));
628  if (Al > 0 && pred >= (1<<Al))
629  pred = (1<<Al)-1;
630  pred = -pred;
631  }
632  workspace[9] = (JCOEF) pred;
633  }
634  /* AC02 */
635  if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
636  num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
637  if (num >= 0) {
638  pred = (int) (((Q02<<7) + num) / (Q02<<8));
639  if (Al > 0 && pred >= (1<<Al))
640  pred = (1<<Al)-1;
641  } else {
642  pred = (int) (((Q02<<7) - num) / (Q02<<8));
643  if (Al > 0 && pred >= (1<<Al))
644  pred = (1<<Al)-1;
645  pred = -pred;
646  }
647  workspace[2] = (JCOEF) pred;
648  }
649  /* OK, do the IDCT */
650  (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,
651  output_ptr, output_col);
652  /* Advance for next column */
653  DC1 = DC2; DC2 = DC3;
654  DC4 = DC5; DC5 = DC6;
655  DC7 = DC8; DC8 = DC9;
656  buffer_ptr++, prev_block_row++, next_block_row++;
658  }
659  output_ptr += compptr->DCT_scaled_size;
660  }
661  }
662 
663  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
664  return JPEG_ROW_COMPLETED;
665  return JPEG_SCAN_COMPLETED;
666 }
int v_samp_factor
Definition: jpeglib.h:128
JBLOCKARRAY(* access_virt_barray)()
Definition: jpeglib.h:795
void jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row, JDIMENSION num_blocks)
Definition: jutils.cpp:145
static double delta
Definition: agent_exec-2-0.cpp:141
struct jpeg_input_controller * inputctl
Definition: jpeglib.h:628
jpeg_component_info * comp_info
Definition: jpeglib.h:540
inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]
Definition: jpegint.h:228
int output_scan_number
Definition: jpeglib.h:506
JBLOCKROW * JBLOCKARRAY
Definition: jpeglib.h:77
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
Definition: jpeglib.h:88
int DCT_scaled_size
Definition: jpeglib.h:152
#define JPEG_ROW_COMPLETED
Definition: jpeglib.h:1003
Definition: jpeglib.h:258
boolean component_needed
Definition: jpeglib.h:165
short JCOEF
Definition: jmorecfg.h:99
uint16_t quantval[64]
Definition: jpeglib.h:93
jpeg_component_info * compptr
Definition: jdct.h:102
JDIMENSION width_in_blocks
Definition: jpeglib.h:144
#define Q20_POS
Definition: jdcoefct.cpp:392
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:417
#define FALSE
Definition: jpleph.cpp:69
jpeg_component_info JCOEFPTR JSAMPARRAY JDIMENSION output_col
Definition: jdct.h:102
JDIMENSION height_in_blocks
Definition: jpeglib.h:145
#define Q11_POS
Definition: jdcoefct.cpp:393
static char buffer[255]
Definition: propagator_simple.cpp:60
int input_scan_number
Definition: jpeglib.h:499
static double coef[360+1][360+1][2]
Definition: physicslib.cpp:39
boolean eoi_reached
Definition: jpegint.h:154
JCOEF * JCOEFPTR
Definition: jpeglib.h:80
#define TRUE
Definition: jpleph.cpp:68
int Ss
Definition: jpeglib.h:613
JQUANT_TBL * quant_table
Definition: jpeglib.h:180
JCOEF JBLOCK[64]
Definition: jpeglib.h:75
int * coef_bits_latch
Definition: jdcoefct.cpp:57
#define Q10_POS
Definition: jdcoefct.cpp:391
JSAMPROW * JSAMPARRAY
Definition: jpeglib.h:72
Definition: jpeglib.h:121
Definition: jccoefct.cpp:34
JBLOCK * JBLOCKROW
Definition: jpeglib.h:76
#define JPEG_SCAN_COMPLETED
Definition: jpeglib.h:1004
JDIMENSION input_iMCU_row
Definition: jpeglib.h:500
#define JPEG_SUSPENDED
Definition: jpeglib.h:970
JDIMENSION output_iMCU_row
Definition: jpeglib.h:507
#define Q02_POS
Definition: jdcoefct.cpp:394
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:102
unsigned int JDIMENSION
Definition: jmorecfg.h:171
#define Q01_POS
Definition: jdcoefct.cpp:390
struct jpeg_inverse_dct * idct
Definition: jpeglib.h:631
jvirt_barray_ptr whole_image[10]
Definition: jccoefct.cpp:54
my_coef_controller * my_coef_ptr
Definition: jdcoefct.cpp:62
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:585
#define SAVED_COEFS
Definition: jdcoefct.cpp:58
static void start_iMCU_row ( j_decompress_ptr  cinfo)
static
81 {
82  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
83 
84  /* In an interleaved scan, an MCU row is the same as an iMCU row.
85  * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
86  * But at the bottom of the image, process only what's left.
87  */
88  if (cinfo->comps_in_scan > 1) {
89  coef->MCU_rows_per_iMCU_row = 1;
90  } else {
91  if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))
93  else
95  }
96 
97  coef->MCU_ctr = 0;
98  coef->MCU_vert_offset = 0;
99 }
JDIMENSION MCU_ctr
Definition: jdcoefct.cpp:33
int v_samp_factor
Definition: jpeglib.h:128
jpeg_component_info * cur_comp_info[4]
Definition: jpeglib.h:602
int comps_in_scan
Definition: jpeglib.h:601
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
int MCU_vert_offset
Definition: jccoefct.cpp:39
int last_row_height
Definition: jpeglib.h:174
static double coef[360+1][360+1][2]
Definition: physicslib.cpp:39
Definition: jccoefct.cpp:34
JDIMENSION input_iMCU_row
Definition: jpeglib.h:500
my_coef_controller * my_coef_ptr
Definition: jdcoefct.cpp:62
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:585
int MCU_rows_per_iMCU_row
Definition: jccoefct.cpp:40
static void start_input_pass ( j_decompress_ptr  cinfo)
static
108 {
109  cinfo->input_iMCU_row = 0;
110  start_iMCU_row(cinfo);
111 }
static void start_iMCU_row(j_decompress_ptr cinfo)
Definition: jdcoefct.cpp:79
JDIMENSION input_iMCU_row
Definition: jpeglib.h:500
static void start_output_pass ( j_decompress_ptr  cinfo)
static
120 {
121 #ifdef BLOCK_SMOOTHING_SUPPORTED
122  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
123 
124  /* If multipass, check to see whether to use block smoothing on this pass */
125  if (coef->pub.coef_arrays != NULL) {
126  if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
127  coef->pub.decompress_data = decompress_smooth_data;
128  else
129  coef->pub.decompress_data = decompress_data;
130  }
131 #endif
132  cinfo->output_iMCU_row = 0;
133 }
boolean do_block_smoothing
Definition: jpeglib.h:446
static boolean smoothing_ok(j_decompress_ptr cinfo)
Definition: jdcoefct.cpp:405
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
static int decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
Definition: jdcoefct.cpp:315
struct jpeg_c_coef_controller pub
Definition: jccoefct.cpp:35
static double coef[360+1][360+1][2]
Definition: physicslib.cpp:39
Definition: jccoefct.cpp:34
JDIMENSION output_iMCU_row
Definition: jpeglib.h:507
static int decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
Definition: jdcoefct.cpp:461
my_coef_controller * my_coef_ptr
Definition: jdcoefct.cpp:62
static int dummy_consume_data ( j_decompress_ptr  cinfo)
static
229 {
230  return JPEG_SUSPENDED; /* Always indicate nothing was done */
231 }
#define JPEG_SUSPENDED
Definition: jpeglib.h:970
static int consume_data ( j_decompress_ptr  cinfo)
static
245 {
246  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
247  JDIMENSION MCU_col_num; /* index of current MCU within row */
248  int blkn, ci, xindex, yindex, yoffset;
249  JDIMENSION start_col;
251  JBLOCKROW buffer_ptr;
253 
254  /* Align the virtual buffers for the components used in this scan. */
255  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
256  compptr = cinfo->cur_comp_info[ci];
257  buffer[ci] = (*cinfo->mem->access_virt_barray)
261  /* Note: entropy decoder expects buffer to be zeroed,
262  * but this is handled automatically by the memory manager
263  * because we requested a pre-zeroed array.
264  */
265  }
266 
267  /* Loop to process one whole iMCU row */
268  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
269  yoffset++) {
270  for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
271  MCU_col_num++) {
272  /* Construct list of pointers to DCT blocks belonging to this MCU */
273  blkn = 0; /* index of current DCT block within MCU */
274  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
275  compptr = cinfo->cur_comp_info[ci];
276  start_col = MCU_col_num * compptr->MCU_width;
277  for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
278  buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
279  for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
280  coef->MCU_buffer[blkn++] = buffer_ptr++;
281  }
282  }
283  }
284  /* Try to fetch the MCU. */
285  if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
286  /* Suspension forced; update state counters and exit */
287  coef->MCU_vert_offset = yoffset;
288  coef->MCU_ctr = MCU_col_num;
289  return JPEG_SUSPENDED;
290  }
291  }
292  /* Completed an MCU row, but perhaps not an iMCU row */
293  coef->MCU_ctr = 0;
294  }
295  /* Completed the iMCU row, advance counters for next one */
296  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
297  start_iMCU_row(cinfo);
298  return JPEG_ROW_COMPLETED;
299  }
300  /* Completed the scan */
301  (*cinfo->inputctl->finish_input_pass) (cinfo);
302  return JPEG_SCAN_COMPLETED;
303 }
JDIMENSION MCU_ctr
Definition: jdcoefct.cpp:33
int v_samp_factor
Definition: jpeglib.h:128
JBLOCKARRAY(* access_virt_barray)()
Definition: jpeglib.h:795
jpeg_component_info * cur_comp_info[4]
Definition: jpeglib.h:602
int comps_in_scan
Definition: jpeglib.h:601
struct jpeg_input_controller * inputctl
Definition: jpeglib.h:628
int MCU_height
Definition: jpeglib.h:170
JBLOCKROW * JBLOCKARRAY
Definition: jpeglib.h:77
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
static void start_iMCU_row(j_decompress_ptr cinfo)
Definition: jdcoefct.cpp:79
#define JPEG_ROW_COMPLETED
Definition: jpeglib.h:1003
Definition: jpeglib.h:258
jpeg_component_info * compptr
Definition: jdct.h:102
int MCU_vert_offset
Definition: jccoefct.cpp:39
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:417
int MCU_width
Definition: jpeglib.h:169
int component_index
Definition: jpeglib.h:126
static char buffer[255]
Definition: propagator_simple.cpp:60
static double coef[360+1][360+1][2]
Definition: physicslib.cpp:39
#define TRUE
Definition: jpleph.cpp:68
Definition: jpeglib.h:121
Definition: jccoefct.cpp:34
JBLOCKROW MCU_buffer[10]
Definition: jccoefct.cpp:51
JBLOCK * JBLOCKROW
Definition: jpeglib.h:76
#define JPEG_SCAN_COMPLETED
Definition: jpeglib.h:1004
JDIMENSION input_iMCU_row
Definition: jpeglib.h:500
#define JPEG_SUSPENDED
Definition: jpeglib.h:970
unsigned int JDIMENSION
Definition: jmorecfg.h:171
jvirt_barray_ptr whole_image[10]
Definition: jccoefct.cpp:54
my_coef_controller * my_coef_ptr
Definition: jdcoefct.cpp:62
struct jpeg_entropy_decoder * entropy
Definition: jpeglib.h:630
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:585
#define MAX_COMPS_IN_SCAN
Definition: jpeglib.h:51
void jinit_d_coef_controller ( j_decompress_ptr  cinfo,
boolean  need_full_buffer 
)
677 {
679 
680  coef = (my_coef_ptr)
681  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
683  cinfo->coef = (struct jpeg_d_coef_controller *) coef;
684  coef->pub.start_input_pass = start_input_pass;
685  coef->pub.start_output_pass = start_output_pass;
686 #ifdef BLOCK_SMOOTHING_SUPPORTED
687  coef->coef_bits_latch = NULL;
688 #endif
689 
690  /* Create the coefficient buffer. */
691  if (need_full_buffer) {
692 #ifdef D_MULTISCAN_FILES_SUPPORTED
693  /* Allocate a full-image virtual array for each component, */
694  /* padded to a multiple of samp_factor DCT blocks in each direction. */
695  /* Note we ask for a pre-zeroed array. */
696  int ci, access_rows;
698 
699  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
700  ci++, compptr++) {
701  access_rows = compptr->v_samp_factor;
702 #ifdef BLOCK_SMOOTHING_SUPPORTED
703  /* If block smoothing could be used, need a bigger window */
704  if (cinfo->progressive_mode)
705  access_rows *= 3;
706 #endif
707  coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
708  ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,
709  (JDIMENSION) jround_up((long) compptr->width_in_blocks,
710  (long) compptr->h_samp_factor),
711  (JDIMENSION) jround_up((long) compptr->height_in_blocks,
712  (long) compptr->v_samp_factor),
713  (JDIMENSION) access_rows);
714  }
715  coef->pub.consume_data = consume_data;
716  coef->pub.decompress_data = decompress_data;
717  coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
718 #else
719  ERREXIT(cinfo, JERR_NOT_COMPILED);
720 #endif
721  } else {
722  /* We only need a single-MCU buffer. */
724  int i;
725 
726  buffer = (JBLOCKROW)
727  (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
729  for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
730  coef->MCU_buffer[i] = buffer + i;
731  }
732  coef->pub.consume_data = dummy_consume_data;
733  coef->pub.decompress_data = decompress_onepass;
734  coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
735  }
736 }
static int decompress_onepass(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
Definition: jdcoefct.cpp:147
int v_samp_factor
Definition: jpeglib.h:128
jpeg_component_info * comp_info
Definition: jpeglib.h:540
int i
Definition: rw_test.cpp:37
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:266
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
void *(* alloc_small)()
Definition: jpeglib.h:764
long jround_up(long a, long b)
Definition: jutils.cpp:81
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
Definition: jpeglib.h:258
#define SIZEOF(object)
Definition: jinclude.h:80
boolean need_full_buffer
Definition: jpegint.h:338
static int decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
Definition: jdcoefct.cpp:315
static int dummy_consume_data(j_decompress_ptr cinfo)
Definition: jdcoefct.cpp:228
jpeg_component_info * compptr
Definition: jdct.h:102
JDIMENSION width_in_blocks
Definition: jpeglib.h:144
#define JPOOL_IMAGE
Definition: jpeglib.h:754
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:417
struct jpeg_c_coef_controller pub
Definition: jccoefct.cpp:35
Definition: jerror.h:95
JDIMENSION height_in_blocks
Definition: jpeglib.h:145
static char buffer[255]
Definition: propagator_simple.cpp:60
Definition: jpegint.h:166
static double coef[360+1][360+1][2]
Definition: physicslib.cpp:39
#define TRUE
Definition: jpleph.cpp:68
static int consume_data(j_decompress_ptr cinfo)
Definition: jdcoefct.cpp:244
JCOEF JBLOCK[64]
Definition: jpeglib.h:75
static void start_input_pass(j_decompress_ptr cinfo)
Definition: jdcoefct.cpp:107
int * coef_bits_latch
Definition: jdcoefct.cpp:57
Definition: jpeglib.h:121
Definition: jccoefct.cpp:34
JBLOCKROW MCU_buffer[10]
Definition: jccoefct.cpp:51
#define D_MAX_BLOCKS_IN_MCU
Definition: jpeglib.h:62
JBLOCK * JBLOCKROW
Definition: jpeglib.h:76
void *(* alloc_large)()
Definition: jpeglib.h:766
int h_samp_factor
Definition: jpeglib.h:127
jvirt_barray_ptr(* request_virt_barray)()
Definition: jpeglib.h:784
boolean progressive_mode
Definition: jpeglib.h:543
unsigned int JDIMENSION
Definition: jmorecfg.h:171
jvirt_barray_ptr whole_image[10]
Definition: jccoefct.cpp:54
my_coef_controller * my_coef_ptr
Definition: jdcoefct.cpp:62
static void start_output_pass(j_decompress_ptr cinfo)
Definition: jdcoefct.cpp:119