Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

jdcoefct.c File Reference

#include "jinclude.h"
#include "jpeglib.h"

Go to the source code of this file.


Data Structures

struct  my_coef_controller

Defines

#define JPEG_INTERNALS
#define SAVED_COEFS   6
#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

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

Variables

JSAMPIMAGE output_buf

Define Documentation

#define JPEG_INTERNALS
 

Definition at line 17 of file jdcoefct.c.

#define Q01_POS   1
 

Definition at line 390 of file jdcoefct.c.

Referenced by decompress_smooth_data(), and smoothing_ok().

#define Q02_POS   2
 

Definition at line 394 of file jdcoefct.c.

Referenced by decompress_smooth_data(), and smoothing_ok().

#define Q10_POS   8
 

Definition at line 391 of file jdcoefct.c.

Referenced by decompress_smooth_data(), and smoothing_ok().

#define Q11_POS   9
 

Definition at line 393 of file jdcoefct.c.

Referenced by decompress_smooth_data(), and smoothing_ok().

#define Q20_POS   16
 

Definition at line 392 of file jdcoefct.c.

Referenced by decompress_smooth_data(), and smoothing_ok().

#define SAVED_COEFS   6
 

Definition at line 58 of file jdcoefct.c.

Referenced by decompress_smooth_data(), and smoothing_ok().


Typedef Documentation

typedef my_coef_controller* my_coef_ptr
 

Definition at line 62 of file jdcoefct.c.


Function Documentation

consume_data j_decompress_ptr    cinfo
 

Definition at line 244 of file jdcoefct.c.

References jpeg_decompress_struct::coef, jpeg_component_info::component_index, compptr, jpeg_decompress_struct::comps_in_scan, jpeg_decompress_struct::cur_comp_info, jpeg_decompress_struct::entropy, jpeg_decompress_struct::input_iMCU_row, jpeg_decompress_struct::inputctl, JBLOCKARRAY, JBLOCKROW, JDIMENSION, JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, JPEG_SUSPENDED, MAX_COMPS_IN_SCAN, my_coef_controller::MCU_buffer, my_coef_controller::MCU_ctr, jpeg_component_info::MCU_height, my_coef_controller::MCU_rows_per_iMCU_row, my_coef_controller::MCU_vert_offset, jpeg_component_info::MCU_width, jpeg_decompress_struct::MCUs_per_row, start_iMCU_row(), jpeg_decompress_struct::total_iMCU_rows, jpeg_component_info::v_samp_factor, and my_coef_controller::whole_image.

Referenced by jinit_d_coef_controller().

00245 {
00246   my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00247   JDIMENSION MCU_col_num;       /* index of current MCU within row */
00248   int blkn, ci, xindex, yindex, yoffset;
00249   JDIMENSION start_col;
00250   JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
00251   JBLOCKROW buffer_ptr;
00252   jpeg_component_info *compptr;
00253 
00254   /* Align the virtual buffers for the components used in this scan. */
00255   for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00256     compptr = cinfo->cur_comp_info[ci];
00257     buffer[ci] = (*cinfo->mem->access_virt_barray)
00258       ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
00259        cinfo->input_iMCU_row * compptr->v_samp_factor,
00260        (JDIMENSION) compptr->v_samp_factor, TRUE);
00261     /* Note: entropy decoder expects buffer to be zeroed,
00262      * but this is handled automatically by the memory manager
00263      * because we requested a pre-zeroed array.
00264      */
00265   }
00266 
00267   /* Loop to process one whole iMCU row */
00268   for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
00269        yoffset++) {
00270     for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
00271          MCU_col_num++) {
00272       /* Construct list of pointers to DCT blocks belonging to this MCU */
00273       blkn = 0;                 /* index of current DCT block within MCU */
00274       for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00275         compptr = cinfo->cur_comp_info[ci];
00276         start_col = MCU_col_num * compptr->MCU_width;
00277         for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
00278           buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
00279           for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
00280             coef->MCU_buffer[blkn++] = buffer_ptr++;
00281           }
00282         }
00283       }
00284       /* Try to fetch the MCU. */
00285       if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
00286         /* Suspension forced; update state counters and exit */
00287         coef->MCU_vert_offset = yoffset;
00288         coef->MCU_ctr = MCU_col_num;
00289         return JPEG_SUSPENDED;
00290       }
00291     }
00292     /* Completed an MCU row, but perhaps not an iMCU row */
00293     coef->MCU_ctr = 0;
00294   }
00295   /* Completed the iMCU row, advance counters for next one */
00296   if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
00297     start_iMCU_row(cinfo);
00298     return JPEG_ROW_COMPLETED;
00299   }
00300   /* Completed the scan */
00301   (*cinfo->inputctl->finish_input_pass) (cinfo);
00302   return JPEG_SCAN_COMPLETED;
00303 }

decompress_data j_decompress_ptr    cinfo,
JSAMPIMAGE    output_buf
 

Definition at line 315 of file jdcoefct.c.

References jpeg_decompress_struct::coef, jpeg_decompress_struct::comp_info, jpeg_component_info::component_needed, compptr, jpeg_component_info::DCT_scaled_size, jpeg_component_info::height_in_blocks, jpeg_decompress_struct::input_iMCU_row, jpeg_decompress_struct::input_scan_number, jpeg_decompress_struct::inputctl, JBLOCKARRAY, JBLOCKROW, JDIMENSION, JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, JPEG_SUSPENDED, JSAMPARRAY, JSAMPIMAGE, jpeg_decompress_struct::num_components, output_col, jpeg_decompress_struct::output_iMCU_row, jpeg_decompress_struct::output_scan_number, jpeg_decompress_struct::total_iMCU_rows, jpeg_component_info::v_samp_factor, my_coef_controller::whole_image, and jpeg_component_info::width_in_blocks.

Referenced by jinit_d_coef_controller(), and start_output_pass().

00316 {
00317   my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00318   JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
00319   JDIMENSION block_num;
00320   int ci, block_row, block_rows;
00321   JBLOCKARRAY buffer;
00322   JBLOCKROW buffer_ptr;
00323   JSAMPARRAY output_ptr;
00324   JDIMENSION output_col;
00325   jpeg_component_info *compptr;
00326   inverse_DCT_method_ptr inverse_DCT;
00327 
00328   /* Force some input to be done if we are getting ahead of the input. */
00329   while (cinfo->input_scan_number < cinfo->output_scan_number ||
00330          (cinfo->input_scan_number == cinfo->output_scan_number &&
00331           cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
00332     if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
00333       return JPEG_SUSPENDED;
00334   }
00335 
00336   /* OK, output from the virtual arrays. */
00337   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00338        ci++, compptr++) {
00339     /* Don't bother to IDCT an uninteresting component. */
00340     if (! compptr->component_needed)
00341       continue;
00342     /* Align the virtual buffer for this component. */
00343     buffer = (*cinfo->mem->access_virt_barray)
00344       ((j_common_ptr) cinfo, coef->whole_image[ci],
00345        cinfo->output_iMCU_row * compptr->v_samp_factor,
00346        (JDIMENSION) compptr->v_samp_factor, FALSE);
00347     /* Count non-dummy DCT block rows in this iMCU row. */
00348     if (cinfo->output_iMCU_row < last_iMCU_row)
00349       block_rows = compptr->v_samp_factor;
00350     else {
00351       /* NB: can't use last_row_height here; it is input-side-dependent! */
00352       block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
00353       if (block_rows == 0) block_rows = compptr->v_samp_factor;
00354     }
00355     inverse_DCT = cinfo->idct->inverse_DCT[ci];
00356     output_ptr = output_buf[ci];
00357     /* Loop over all DCT blocks to be processed. */
00358     for (block_row = 0; block_row < block_rows; block_row++) {
00359       buffer_ptr = buffer[block_row];
00360       output_col = 0;
00361       for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {
00362         (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
00363                         output_ptr, output_col);
00364         buffer_ptr++;
00365         output_col += compptr->DCT_scaled_size;
00366       }
00367       output_ptr += compptr->DCT_scaled_size;
00368     }
00369   }
00370 
00371   if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
00372     return JPEG_ROW_COMPLETED;
00373   return JPEG_SCAN_COMPLETED;
00374 }

decompress_onepass j_decompress_ptr    cinfo,
JSAMPIMAGE    output_buf
 

Definition at line 147 of file jdcoefct.c.

References jpeg_decompress_struct::blocks_in_MCU, jpeg_decompress_struct::coef, jpeg_component_info::component_index, jpeg_component_info::component_needed, compptr, jpeg_decompress_struct::comps_in_scan, jpeg_decompress_struct::cur_comp_info, jpeg_component_info::DCT_scaled_size, jpeg_decompress_struct::entropy, jpeg_decompress_struct::idct, jpeg_decompress_struct::input_iMCU_row, jpeg_decompress_struct::inputctl, jpeg_inverse_dct::inverse_DCT, JBLOCK, JDIMENSION, JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, JPEG_SUSPENDED, JSAMPARRAY, JSAMPIMAGE, jzero_far(), jpeg_component_info::last_col_width, jpeg_component_info::last_row_height, jpeg_component_info::MCU_blocks, my_coef_controller::MCU_buffer, my_coef_controller::MCU_ctr, jpeg_component_info::MCU_height, my_coef_controller::MCU_rows_per_iMCU_row, jpeg_component_info::MCU_sample_width, my_coef_controller::MCU_vert_offset, jpeg_component_info::MCU_width, jpeg_decompress_struct::MCUs_per_row, output_col, jpeg_decompress_struct::output_iMCU_row, SIZEOF, start_iMCU_row(), and jpeg_decompress_struct::total_iMCU_rows.

Referenced by jinit_d_coef_controller().

00148 {
00149   my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00150   JDIMENSION MCU_col_num;       /* index of current MCU within row */
00151   JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
00152   JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
00153   int blkn, ci, xindex, yindex, yoffset, useful_width;
00154   JSAMPARRAY output_ptr;
00155   JDIMENSION start_col, output_col;
00156   jpeg_component_info *compptr;
00157   inverse_DCT_method_ptr inverse_DCT;
00158 
00159   /* Loop to process as much as one whole iMCU row */
00160   for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
00161        yoffset++) {
00162     for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
00163          MCU_col_num++) {
00164       /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
00165       jzero_far((void FAR *) coef->MCU_buffer[0],
00166                 (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
00167       if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
00168         /* Suspension forced; update state counters and exit */
00169         coef->MCU_vert_offset = yoffset;
00170         coef->MCU_ctr = MCU_col_num;
00171         return JPEG_SUSPENDED;
00172       }
00173       /* Determine where data should go in output_buf and do the IDCT thing.
00174        * We skip dummy blocks at the right and bottom edges (but blkn gets
00175        * incremented past them!).  Note the inner loop relies on having
00176        * allocated the MCU_buffer[] blocks sequentially.
00177        */
00178       blkn = 0;                 /* index of current DCT block within MCU */
00179       for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00180         compptr = cinfo->cur_comp_info[ci];
00181         /* Don't bother to IDCT an uninteresting component. */
00182         if (! compptr->component_needed) {
00183           blkn += compptr->MCU_blocks;
00184           continue;
00185         }
00186         inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
00187         useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
00188                                                     : compptr->last_col_width;
00189         output_ptr = output_buf[compptr->component_index] +
00190           yoffset * compptr->DCT_scaled_size;
00191         start_col = MCU_col_num * compptr->MCU_sample_width;
00192         for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
00193           if (cinfo->input_iMCU_row < last_iMCU_row ||
00194               yoffset+yindex < compptr->last_row_height) {
00195             output_col = start_col;
00196             for (xindex = 0; xindex < useful_width; xindex++) {
00197               (*inverse_DCT) (cinfo, compptr,
00198                               (JCOEFPTR) coef->MCU_buffer[blkn+xindex],
00199                               output_ptr, output_col);
00200               output_col += compptr->DCT_scaled_size;
00201             }
00202           }
00203           blkn += compptr->MCU_width;
00204           output_ptr += compptr->DCT_scaled_size;
00205         }
00206       }
00207     }
00208     /* Completed an MCU row, but perhaps not an iMCU row */
00209     coef->MCU_ctr = 0;
00210   }
00211   /* Completed the iMCU row, advance counters for next one */
00212   cinfo->output_iMCU_row++;
00213   if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
00214     start_iMCU_row(cinfo);
00215     return JPEG_ROW_COMPLETED;
00216   }
00217   /* Completed the scan */
00218   (*cinfo->inputctl->finish_input_pass) (cinfo);
00219   return JPEG_SCAN_COMPLETED;
00220 }

decompress_smooth_data j_decompress_ptr    cinfo,
JSAMPIMAGE    output_buf
 

Definition at line 461 of file jdcoefct.c.

References jpeg_decompress_struct::coef, my_coef_controller::coef_bits_latch, jpeg_decompress_struct::comp_info, jpeg_component_info::component_needed, compptr, jpeg_component_info::DCT_scaled_size, jpeg_input_controller::eoi_reached, jpeg_component_info::height_in_blocks, jpeg_decompress_struct::idct, jpeg_decompress_struct::input_iMCU_row, jpeg_decompress_struct::input_scan_number, jpeg_decompress_struct::inputctl, INT32, jpeg_inverse_dct::inverse_DCT, JBLOCK, JBLOCKARRAY, JBLOCKROW, jcopy_block_row(), JDIMENSION, JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, JPEG_SUSPENDED, JSAMPARRAY, JSAMPIMAGE, jpeg_decompress_struct::num_components, output_col, jpeg_decompress_struct::output_iMCU_row, jpeg_decompress_struct::output_scan_number, Q01_POS, Q02_POS, Q10_POS, Q11_POS, Q20_POS, jpeg_component_info::quant_table, JQUANT_TBL::quantval, SAVED_COEFS, jpeg_decompress_struct::Ss, jpeg_decompress_struct::total_iMCU_rows, jpeg_component_info::v_samp_factor, my_coef_controller::whole_image, and jpeg_component_info::width_in_blocks.

Referenced by start_output_pass().

00462 {
00463   my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00464   JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
00465   JDIMENSION block_num, last_block_column;
00466   int ci, block_row, block_rows, access_rows;
00467   JBLOCKARRAY buffer;
00468   JBLOCKROW buffer_ptr, prev_block_row, next_block_row;
00469   JSAMPARRAY output_ptr;
00470   JDIMENSION output_col;
00471   jpeg_component_info *compptr;
00472   inverse_DCT_method_ptr inverse_DCT;
00473   boolean first_row, last_row;
00474   JBLOCK workspace;
00475   int *coef_bits;
00476   JQUANT_TBL *quanttbl;
00477   INT32 Q00,Q01,Q02,Q10,Q11,Q20, num;
00478   int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
00479   int Al, pred;
00480 
00481   /* Force some input to be done if we are getting ahead of the input. */
00482   while (cinfo->input_scan_number <= cinfo->output_scan_number &&
00483          ! cinfo->inputctl->eoi_reached) {
00484     if (cinfo->input_scan_number == cinfo->output_scan_number) {
00485       /* If input is working on current scan, we ordinarily want it to
00486        * have completed the current row.  But if input scan is DC,
00487        * we want it to keep one row ahead so that next block row's DC
00488        * values are up to date.
00489        */
00490       JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;
00491       if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)
00492         break;
00493     }
00494     if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
00495       return JPEG_SUSPENDED;
00496   }
00497 
00498   /* OK, output from the virtual arrays. */
00499   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00500        ci++, compptr++) {
00501     /* Don't bother to IDCT an uninteresting component. */
00502     if (! compptr->component_needed)
00503       continue;
00504     /* Count non-dummy DCT block rows in this iMCU row. */
00505     if (cinfo->output_iMCU_row < last_iMCU_row) {
00506       block_rows = compptr->v_samp_factor;
00507       access_rows = block_rows * 2; /* this and next iMCU row */
00508       last_row = FALSE;
00509     } else {
00510       /* NB: can't use last_row_height here; it is input-side-dependent! */
00511       block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
00512       if (block_rows == 0) block_rows = compptr->v_samp_factor;
00513       access_rows = block_rows; /* this iMCU row only */
00514       last_row = TRUE;
00515     }
00516     /* Align the virtual buffer for this component. */
00517     if (cinfo->output_iMCU_row > 0) {
00518       access_rows += compptr->v_samp_factor; /* prior iMCU row too */
00519       buffer = (*cinfo->mem->access_virt_barray)
00520         ((j_common_ptr) cinfo, coef->whole_image[ci],
00521          (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
00522          (JDIMENSION) access_rows, FALSE);
00523       buffer += compptr->v_samp_factor; /* point to current iMCU row */
00524       first_row = FALSE;
00525     } else {
00526       buffer = (*cinfo->mem->access_virt_barray)
00527         ((j_common_ptr) cinfo, coef->whole_image[ci],
00528          (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);
00529       first_row = TRUE;
00530     }
00531     /* Fetch component-dependent info */
00532     coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
00533     quanttbl = compptr->quant_table;
00534     Q00 = quanttbl->quantval[0];
00535     Q01 = quanttbl->quantval[Q01_POS];
00536     Q10 = quanttbl->quantval[Q10_POS];
00537     Q20 = quanttbl->quantval[Q20_POS];
00538     Q11 = quanttbl->quantval[Q11_POS];
00539     Q02 = quanttbl->quantval[Q02_POS];
00540     inverse_DCT = cinfo->idct->inverse_DCT[ci];
00541     output_ptr = output_buf[ci];
00542     /* Loop over all DCT blocks to be processed. */
00543     for (block_row = 0; block_row < block_rows; block_row++) {
00544       buffer_ptr = buffer[block_row];
00545       if (first_row && block_row == 0)
00546         prev_block_row = buffer_ptr;
00547       else
00548         prev_block_row = buffer[block_row-1];
00549       if (last_row && block_row == block_rows-1)
00550         next_block_row = buffer_ptr;
00551       else
00552         next_block_row = buffer[block_row+1];
00553       /* We fetch the surrounding DC values using a sliding-register approach.
00554        * Initialize all nine here so as to do the right thing on narrow pics.
00555        */
00556       DC1 = DC2 = DC3 = (int) prev_block_row[0][0];
00557       DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];
00558       DC7 = DC8 = DC9 = (int) next_block_row[0][0];
00559       output_col = 0;
00560       last_block_column = compptr->width_in_blocks - 1;
00561       for (block_num = 0; block_num <= last_block_column; block_num++) {
00562         /* Fetch current DCT block into workspace so we can modify it. */
00563         jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);
00564         /* Update DC values */
00565         if (block_num < last_block_column) {
00566           DC3 = (int) prev_block_row[1][0];
00567           DC6 = (int) buffer_ptr[1][0];
00568           DC9 = (int) next_block_row[1][0];
00569         }
00570         /* Compute coefficient estimates per K.8.
00571          * An estimate is applied only if coefficient is still zero,
00572          * and is not known to be fully accurate.
00573          */
00574         /* AC01 */
00575         if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
00576           num = 36 * Q00 * (DC4 - DC6);
00577           if (num >= 0) {
00578             pred = (int) (((Q01<<7) + num) / (Q01<<8));
00579             if (Al > 0 && pred >= (1<<Al))
00580               pred = (1<<Al)-1;
00581           } else {
00582             pred = (int) (((Q01<<7) - num) / (Q01<<8));
00583             if (Al > 0 && pred >= (1<<Al))
00584               pred = (1<<Al)-1;
00585             pred = -pred;
00586           }
00587           workspace[1] = (JCOEF) pred;
00588         }
00589         /* AC10 */
00590         if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
00591           num = 36 * Q00 * (DC2 - DC8);
00592           if (num >= 0) {
00593             pred = (int) (((Q10<<7) + num) / (Q10<<8));
00594             if (Al > 0 && pred >= (1<<Al))
00595               pred = (1<<Al)-1;
00596           } else {
00597             pred = (int) (((Q10<<7) - num) / (Q10<<8));
00598             if (Al > 0 && pred >= (1<<Al))
00599               pred = (1<<Al)-1;
00600             pred = -pred;
00601           }
00602           workspace[8] = (JCOEF) pred;
00603         }
00604         /* AC20 */
00605         if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
00606           num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
00607           if (num >= 0) {
00608             pred = (int) (((Q20<<7) + num) / (Q20<<8));
00609             if (Al > 0 && pred >= (1<<Al))
00610               pred = (1<<Al)-1;
00611           } else {
00612             pred = (int) (((Q20<<7) - num) / (Q20<<8));
00613             if (Al > 0 && pred >= (1<<Al))
00614               pred = (1<<Al)-1;
00615             pred = -pred;
00616           }
00617           workspace[16] = (JCOEF) pred;
00618         }
00619         /* AC11 */
00620         if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
00621           num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
00622           if (num >= 0) {
00623             pred = (int) (((Q11<<7) + num) / (Q11<<8));
00624             if (Al > 0 && pred >= (1<<Al))
00625               pred = (1<<Al)-1;
00626           } else {
00627             pred = (int) (((Q11<<7) - num) / (Q11<<8));
00628             if (Al > 0 && pred >= (1<<Al))
00629               pred = (1<<Al)-1;
00630             pred = -pred;
00631           }
00632           workspace[9] = (JCOEF) pred;
00633         }
00634         /* AC02 */
00635         if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
00636           num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
00637           if (num >= 0) {
00638             pred = (int) (((Q02<<7) + num) / (Q02<<8));
00639             if (Al > 0 && pred >= (1<<Al))
00640               pred = (1<<Al)-1;
00641           } else {
00642             pred = (int) (((Q02<<7) - num) / (Q02<<8));
00643             if (Al > 0 && pred >= (1<<Al))
00644               pred = (1<<Al)-1;
00645             pred = -pred;
00646           }
00647           workspace[2] = (JCOEF) pred;
00648         }
00649         /* OK, do the IDCT */
00650         (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,
00651                         output_ptr, output_col);
00652         /* Advance for next column */
00653         DC1 = DC2; DC2 = DC3;
00654         DC4 = DC5; DC5 = DC6;
00655         DC7 = DC8; DC8 = DC9;
00656         buffer_ptr++, prev_block_row++, next_block_row++;
00657         output_col += compptr->DCT_scaled_size;
00658       }
00659       output_ptr += compptr->DCT_scaled_size;
00660     }
00661   }
00662 
00663   if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
00664     return JPEG_ROW_COMPLETED;
00665   return JPEG_SCAN_COMPLETED;
00666 }

dummy_consume_data j_decompress_ptr    cinfo
 

Definition at line 228 of file jdcoefct.c.

References JPEG_SUSPENDED.

Referenced by jinit_d_coef_controller().

00229 {
00230   return JPEG_SUSPENDED;        /* Always indicate nothing was done */
00231 }

jinit_d_coef_controller j_decompress_ptr    cinfo,
boolean    need_full_buffer
 

Definition at line 676 of file jdcoefct.c.

References jpeg_d_coef_controller::coef_arrays, compptr, consume_data(), D_MAX_BLOCKS_IN_MCU, decompress_data(), decompress_onepass(), dummy_consume_data(), ERREXIT, jpeg_component_info::h_samp_factor, jpeg_component_info::height_in_blocks, i, JBLOCK, JBLOCKROW, JPOOL_IMAGE, jround_up(), need_full_buffer, SIZEOF, start_input_pass(), start_output_pass(), jpeg_component_info::v_samp_factor, and jpeg_component_info::width_in_blocks.

Referenced by master_selection(), and transdecode_master_selection().

00677 {
00678   my_coef_ptr coef;
00679 
00680   coef = (my_coef_ptr)
00681     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00682                                 SIZEOF(my_coef_controller));
00683   cinfo->coef = (struct jpeg_d_coef_controller *) coef;
00684   coef->pub.start_input_pass = start_input_pass;
00685   coef->pub.start_output_pass = start_output_pass;
00686 #ifdef BLOCK_SMOOTHING_SUPPORTED
00687   coef->coef_bits_latch = NULL;
00688 #endif
00689 
00690   /* Create the coefficient buffer. */
00691   if (need_full_buffer) {
00692 #ifdef D_MULTISCAN_FILES_SUPPORTED
00693     /* Allocate a full-image virtual array for each component, */
00694     /* padded to a multiple of samp_factor DCT blocks in each direction. */
00695     /* Note we ask for a pre-zeroed array. */
00696     int ci, access_rows;
00697     jpeg_component_info *compptr;
00698 
00699     for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00700          ci++, compptr++) {
00701       access_rows = compptr->v_samp_factor;
00702 #ifdef BLOCK_SMOOTHING_SUPPORTED
00703       /* If block smoothing could be used, need a bigger window */
00704       if (cinfo->progressive_mode)
00705         access_rows *= 3;
00706 #endif
00707       coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
00708         ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,
00709          (JDIMENSION) jround_up((long) compptr->width_in_blocks,
00710                                 (long) compptr->h_samp_factor),
00711          (JDIMENSION) jround_up((long) compptr->height_in_blocks,
00712                                 (long) compptr->v_samp_factor),
00713          (JDIMENSION) access_rows);
00714     }
00715     coef->pub.consume_data = consume_data;
00716     coef->pub.decompress_data = decompress_data;
00717     coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
00718 #else
00719     ERREXIT(cinfo, JERR_NOT_COMPILED);
00720 #endif
00721   } else {
00722     /* We only need a single-MCU buffer. */
00723     JBLOCKROW buffer;
00724     int i;
00725 
00726     buffer = (JBLOCKROW)
00727       (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00728                                   D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
00729     for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
00730       coef->MCU_buffer[i] = buffer + i;
00731     }
00732     coef->pub.consume_data = dummy_consume_data;
00733     coef->pub.decompress_data = decompress_onepass;
00734     coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
00735   }
00736 }

LOCAL boolean   
 

METHODDEF int   
 

smoothing_ok j_decompress_ptr    cinfo
 

Definition at line 405 of file jdcoefct.c.

References jpeg_decompress_struct::coef, jpeg_decompress_struct::coef_bits, my_coef_controller::coef_bits_latch, compptr, JPOOL_IMAGE, jpeg_decompress_struct::progressive_mode, Q01_POS, Q02_POS, Q10_POS, Q11_POS, Q20_POS, jpeg_component_info::quant_table, JQUANT_TBL::quantval, SAVED_COEFS, and SIZEOF.

Referenced by start_output_pass().

00406 {
00407   my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00408   boolean smoothing_useful = FALSE;
00409   int ci, coefi;
00410   jpeg_component_info *compptr;
00411   JQUANT_TBL * qtable;
00412   int * coef_bits;
00413   int * coef_bits_latch;
00414 
00415   if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)
00416     return FALSE;
00417 
00418   /* Allocate latch area if not already done */
00419   if (coef->coef_bits_latch == NULL)
00420     coef->coef_bits_latch = (int *)
00421       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00422                                   cinfo->num_components *
00423                                   (SAVED_COEFS * SIZEOF(int)));
00424   coef_bits_latch = coef->coef_bits_latch;
00425 
00426   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00427        ci++, compptr++) {
00428     /* All components' quantization values must already be latched. */
00429     if ((qtable = compptr->quant_table) == NULL)
00430       return FALSE;
00431     /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */
00432     if (qtable->quantval[0] == 0 ||
00433         qtable->quantval[Q01_POS] == 0 ||
00434         qtable->quantval[Q10_POS] == 0 ||
00435         qtable->quantval[Q20_POS] == 0 ||
00436         qtable->quantval[Q11_POS] == 0 ||
00437         qtable->quantval[Q02_POS] == 0)
00438       return FALSE;
00439     /* DC values must be at least partly known for all components. */
00440     coef_bits = cinfo->coef_bits[ci];
00441     if (coef_bits[0] < 0)
00442       return FALSE;
00443     /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
00444     for (coefi = 1; coefi <= 5; coefi++) {
00445       coef_bits_latch[coefi] = coef_bits[coefi];
00446       if (coef_bits[coefi] != 0)
00447         smoothing_useful = TRUE;
00448     }
00449     coef_bits_latch += SAVED_COEFS;
00450   }
00451 
00452   return smoothing_useful;
00453 }

start_iMCU_row j_decompress_ptr    cinfo
 

Definition at line 79 of file jdcoefct.c.

References jpeg_decompress_struct::coef, jpeg_decompress_struct::comps_in_scan, jpeg_decompress_struct::cur_comp_info, jpeg_decompress_struct::input_iMCU_row, jpeg_component_info::last_row_height, my_coef_controller::MCU_ctr, my_coef_controller::MCU_rows_per_iMCU_row, my_coef_controller::MCU_vert_offset, jpeg_decompress_struct::total_iMCU_rows, and jpeg_component_info::v_samp_factor.

Referenced by compress_data(), compress_output(), consume_data(), decompress_onepass(), start_input_pass(), and start_pass_coef().

00081 {
00082   my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00083 
00084   /* In an interleaved scan, an MCU row is the same as an iMCU row.
00085    * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
00086    * But at the bottom of the image, process only what's left.
00087    */
00088   if (cinfo->comps_in_scan > 1) {
00089     coef->MCU_rows_per_iMCU_row = 1;
00090   } else {
00091     if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))
00092       coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
00093     else
00094       coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
00095   }
00096 
00097   coef->MCU_ctr = 0;
00098   coef->MCU_vert_offset = 0;
00099 }

start_input_pass j_decompress_ptr    cinfo
 

Definition at line 107 of file jdcoefct.c.

References jpeg_decompress_struct::input_iMCU_row, and start_iMCU_row().

Referenced by jinit_d_coef_controller().

00108 {
00109   cinfo->input_iMCU_row = 0;
00110   start_iMCU_row(cinfo);
00111 }

start_output_pass j_decompress_ptr    cinfo
 

Definition at line 119 of file jdcoefct.c.

References jpeg_decompress_struct::coef, decompress_data(), decompress_smooth_data(), jpeg_decompress_struct::do_block_smoothing, jpeg_decompress_struct::output_iMCU_row, my_coef_controller::pub, and smoothing_ok().

Referenced by jinit_d_coef_controller().

00120 {
00121 #ifdef BLOCK_SMOOTHING_SUPPORTED
00122   my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00123 
00124   /* If multipass, check to see whether to use block smoothing on this pass */
00125   if (coef->pub.coef_arrays != NULL) {
00126     if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
00127       coef->pub.decompress_data = decompress_smooth_data;
00128     else
00129       coef->pub.decompress_data = decompress_data;
00130   }
00131 #endif
00132   cinfo->output_iMCU_row = 0;
00133 }

Variable Documentation

JSAMPIMAGE JDIMENSION JDIMENSION JSAMPARRAY output_buf
 

Definition at line 61 of file jdpostct.c.

Referenced by post_process_1pass(), post_process_2pass(), and post_process_prepass().

 

Powered by Plone

This site conforms to the following standards: