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  

jdtrans.c File Reference

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

Go to the source code of this file.


Defines

#define JPEG_INTERNALS

Functions

 LOCAL (void) transdecode_master_selection JPP((j_decompress_ptr cinfo))
 jpeg_read_coefficients (j_decompress_ptr cinfo)
 transdecode_master_selection (j_decompress_ptr cinfo)

Define Documentation

#define JPEG_INTERNALS
 

Definition at line 13 of file jdtrans.c.


Function Documentation

jpeg_read_coefficients j_decompress_ptr    cinfo
 

Definition at line 45 of file jdtrans.c.

References jpeg_decompress_struct::buffered_image, jpeg_decompress_struct::coef, jpeg_d_coef_controller::coef_arrays, DSTATE_BUFIMAGE, DSTATE_RDCOEFS, DSTATE_READY, DSTATE_STOPPING, ERREXIT1, jpeg_decompress_struct::inputctl, JPEG_REACHED_EOI, JPEG_REACHED_SOS, JPEG_ROW_COMPLETED, JPEG_SUSPENDED, retcode, jpeg_decompress_struct::total_iMCU_rows, and transdecode_master_selection().

Referenced by main().

00046 {
00047   if (cinfo->global_state == DSTATE_READY) {
00048     /* First call: initialize active modules */
00049     transdecode_master_selection(cinfo);
00050     cinfo->global_state = DSTATE_RDCOEFS;
00051   }
00052   if (cinfo->global_state == DSTATE_RDCOEFS) {
00053     /* Absorb whole file into the coef buffer */
00054     for (;;) {
00055       int retcode;
00056       /* Call progress monitor hook if present */
00057       if (cinfo->progress != NULL)
00058         (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
00059       /* Absorb some more input */
00060       retcode = (*cinfo->inputctl->consume_input) (cinfo);
00061       if (retcode == JPEG_SUSPENDED)
00062         return NULL;
00063       if (retcode == JPEG_REACHED_EOI)
00064         break;
00065       /* Advance progress counter if appropriate */
00066       if (cinfo->progress != NULL &&
00067           (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
00068         if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
00069           /* startup underestimated number of scans; ratchet up one scan */
00070           cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
00071         }
00072       }
00073     }
00074     /* Set state so that jpeg_finish_decompress does the right thing */
00075     cinfo->global_state = DSTATE_STOPPING;
00076   }
00077   /* At this point we should be in state DSTATE_STOPPING if being used
00078    * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access
00079    * to the coefficients during a full buffered-image-mode decompression.
00080    */
00081   if ((cinfo->global_state == DSTATE_STOPPING ||
00082        cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) {
00083     return cinfo->coef->coef_arrays;
00084   }
00085   /* Oops, improper usage */
00086   ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
00087   return NULL;                  /* keep compiler happy */
00088 }

LOCAL void   
 

transdecode_master_selection j_decompress_ptr    cinfo
 

Definition at line 97 of file jdtrans.c.

References jpeg_decompress_struct::arith_code, jpeg_decompress_struct::buffered_image, ERREXIT, jpeg_input_controller::has_multiple_scans, jpeg_decompress_struct::inputctl, JERR_ARITH_NOTIMPL, jinit_d_coef_controller(), jinit_huff_decoder(), jinit_phuff_decoder(), L, jpeg_decompress_struct::num_components, jpeg_decompress_struct::progressive_mode, and jpeg_decompress_struct::total_iMCU_rows.

Referenced by jpeg_read_coefficients().

00098 {
00099   /* This is effectively a buffered-image operation. */
00100   cinfo->buffered_image = TRUE;
00101 
00102   /* Entropy decoding: either Huffman or arithmetic coding. */
00103   if (cinfo->arith_code) {
00104     ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
00105   } else {
00106     if (cinfo->progressive_mode) {
00107 #ifdef D_PROGRESSIVE_SUPPORTED
00108       jinit_phuff_decoder(cinfo);
00109 #else
00110       ERREXIT(cinfo, JERR_NOT_COMPILED);
00111 #endif
00112     } else
00113       jinit_huff_decoder(cinfo);
00114   }
00115 
00116   /* Always get a full-image coefficient buffer. */
00117   jinit_d_coef_controller(cinfo, TRUE);
00118 
00119   /* We can now tell the memory manager to allocate virtual arrays. */
00120   (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
00121 
00122   /* Initialize input side of decompressor to consume first scan. */
00123   (*cinfo->inputctl->start_input_pass) (cinfo);
00124 
00125   /* Initialize progress monitoring. */
00126   if (cinfo->progress != NULL) {
00127     int nscans;
00128     /* Estimate number of scans to set pass_limit. */
00129     if (cinfo->progressive_mode) {
00130       /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
00131       nscans = 2 + 3 * cinfo->num_components;
00132     } else if (cinfo->inputctl->has_multiple_scans) {
00133       /* For a nonprogressive multiscan file, estimate 1 scan per component. */
00134       nscans = cinfo->num_components;
00135     } else {
00136       nscans = 1;
00137     }
00138     cinfo->progress->pass_counter = 0L;
00139     cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
00140     cinfo->progress->completed_passes = 0;
00141     cinfo->progress->total_passes = 1;
00142   }
00143 }
 

Powered by Plone

This site conforms to the following standards: