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  

jcmainct.c File Reference

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

Go to the source code of this file.


Data Structures

struct  my_main_controller

Defines

#define JPEG_INTERNALS

Typedefs

typedef my_main_controllermy_main_ptr

Functions

 METHODDEF (void) process_data_simple_main JPP((j_compress_ptr cinfo
 start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
 process_data_simple_main (j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
 jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)

Variables

JSAMPARRAY input_buf
JSAMPARRAY JDIMENSIONin_row_ctr
JSAMPARRAY JDIMENSION JDIMENSION in_rows_avail

Define Documentation

#define JPEG_INTERNALS
 

Definition at line 13 of file jcmainct.c.


Typedef Documentation

typedef my_main_controller* my_main_ptr
 

Definition at line 50 of file jcmainct.c.


Function Documentation

jinit_c_main_controller j_compress_ptr    cinfo,
boolean    need_full_buffer
 

Definition at line 245 of file jcmainct.c.

References compptr, ERREXIT, jpeg_component_info::height_in_blocks, JPOOL_IMAGE, jround_up(), need_full_buffer, SIZEOF, start_pass_main(), jpeg_component_info::v_samp_factor, and jpeg_component_info::width_in_blocks.

Referenced by jinit_compress_master().

00246 {
00247   my_main_ptr main;
00248   int ci;
00249   jpeg_component_info *compptr;
00250 
00251   main = (my_main_ptr)
00252     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00253                                 SIZEOF(my_main_controller));
00254   cinfo->main = (struct jpeg_c_main_controller *) main;
00255   main->pub.start_pass = start_pass_main;
00256 
00257   /* We don't need to create a buffer in raw-data mode. */
00258   if (cinfo->raw_data_in)
00259     return;
00260 
00261   /* Create the buffer.  It holds downsampled data, so each component
00262    * may be of a different size.
00263    */
00264   if (need_full_buffer) {
00265 #ifdef FULL_MAIN_BUFFER_SUPPORTED
00266     /* Allocate a full-image virtual array for each component */
00267     /* Note we pad the bottom to a multiple of the iMCU height */
00268     for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00269          ci++, compptr++) {
00270       main->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
00271         ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
00272          compptr->width_in_blocks * DCTSIZE,
00273          (JDIMENSION) jround_up((long) compptr->height_in_blocks,
00274                                 (long) compptr->v_samp_factor) * DCTSIZE,
00275          (JDIMENSION) (compptr->v_samp_factor * DCTSIZE));
00276     }
00277 #else
00278     ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
00279 #endif
00280   } else {
00281 #ifdef FULL_MAIN_BUFFER_SUPPORTED
00282     main->whole_image[0] = NULL; /* flag for no virtual arrays */
00283 #endif
00284     /* Allocate a strip buffer for each component */
00285     for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00286          ci++, compptr++) {
00287       main->buffer[ci] = (*cinfo->mem->alloc_sarray)
00288         ((j_common_ptr) cinfo, JPOOL_IMAGE,
00289          compptr->width_in_blocks * DCTSIZE,
00290          (JDIMENSION) (compptr->v_samp_factor * DCTSIZE));
00291     }
00292   }
00293 }

METHODDEF void   
 

process_data_simple_main j_compress_ptr    cinfo,
JSAMPARRAY    input_buf,
JDIMENSION   in_row_ctr,
JDIMENSION    in_rows_avail
 

Definition at line 113 of file jcmainct.c.

References my_main_controller::buffer, jpeg_compress_struct::coef, my_main_controller::cur_iMCU_row, in_row_ctr, in_rows_avail, input_buf, JDIMENSION, JSAMPARRAY, jpeg_compress_struct::main, jpeg_compress_struct::prep, my_main_controller::rowgroup_ctr, my_main_controller::suspended, and jpeg_compress_struct::total_iMCU_rows.

Referenced by start_pass_main().

00116 {
00117   my_main_ptr main = (my_main_ptr) cinfo->main;
00118 
00119   while (main->cur_iMCU_row < cinfo->total_iMCU_rows) {
00120     /* Read input data if we haven't filled the main buffer yet */
00121     if (main->rowgroup_ctr < DCTSIZE)
00122       (*cinfo->prep->pre_process_data) (cinfo,
00123                                         input_buf, in_row_ctr, in_rows_avail,
00124                                         main->buffer, &main->rowgroup_ctr,
00125                                         (JDIMENSION) DCTSIZE);
00126 
00127     /* If we don't have a full iMCU row buffered, return to application for
00128      * more data.  Note that preprocessor will always pad to fill the iMCU row
00129      * at the bottom of the image.
00130      */
00131     if (main->rowgroup_ctr != DCTSIZE)
00132       return;
00133 
00134     /* Send the completed row to the compressor */
00135     if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) {
00136       /* If compressor did not consume the whole row, then we must need to
00137        * suspend processing and return to the application.  In this situation
00138        * we pretend we didn't yet consume the last input row; otherwise, if
00139        * it happened to be the last row of the image, the application would
00140        * think we were done.
00141        */
00142       if (! main->suspended) {
00143         (*in_row_ctr)--;
00144         main->suspended = TRUE;
00145       }
00146       return;
00147     }
00148     /* We did finish the row.  Undo our little suspension hack if a previous
00149      * call suspended; then mark the main buffer empty.
00150      */
00151     if (main->suspended) {
00152       (*in_row_ctr)++;
00153       main->suspended = FALSE;
00154     }
00155     main->rowgroup_ctr = 0;
00156     main->cur_iMCU_row++;
00157   }
00158 }

start_pass_main j_compress_ptr    cinfo,
J_BUF_MODE    pass_mode
 

Definition at line 69 of file jcmainct.c.

References my_main_controller::cur_iMCU_row, ERREXIT, J_BUF_MODE, JBUF_CRANK_DEST, JBUF_PASS_THRU, JBUF_SAVE_AND_PASS, JBUF_SAVE_SOURCE, jpeg_compress_struct::main, my_main_controller::pass_mode, process_data_simple_main(), my_main_controller::pub, jpeg_compress_struct::raw_data_in, my_main_controller::rowgroup_ctr, and my_main_controller::suspended.

Referenced by jinit_c_main_controller().

00070 {
00071   my_main_ptr main = (my_main_ptr) cinfo->main;
00072 
00073   /* Do nothing in raw-data mode. */
00074   if (cinfo->raw_data_in)
00075     return;
00076 
00077   main->cur_iMCU_row = 0;       /* initialize counters */
00078   main->rowgroup_ctr = 0;
00079   main->suspended = FALSE;
00080   main->pass_mode = pass_mode;  /* save mode for use by process_data */
00081 
00082   switch (pass_mode) {
00083   case JBUF_PASS_THRU:
00084 #ifdef FULL_MAIN_BUFFER_SUPPORTED
00085     if (main->whole_image[0] != NULL)
00086       ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
00087 #endif
00088     main->pub.process_data = process_data_simple_main;
00089     break;
00090 #ifdef FULL_MAIN_BUFFER_SUPPORTED
00091   case JBUF_SAVE_SOURCE:
00092   case JBUF_CRANK_DEST:
00093   case JBUF_SAVE_AND_PASS:
00094     if (main->whole_image[0] == NULL)
00095       ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
00096     main->pub.process_data = process_data_buffer_main;
00097     break;
00098 #endif
00099   default:
00100     ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
00101     break;
00102   }
00103 }

Variable Documentation

JSAMPARRAY JDIMENSION* in_row_ctr
 

Definition at line 55 of file jcmainct.c.

Referenced by pre_process_context(), pre_process_data(), and process_data_simple_main().

JSAMPARRAY JDIMENSION JDIMENSION in_rows_avail
 

Definition at line 55 of file jcmainct.c.

Referenced by pre_process_context(), pre_process_data(), and process_data_simple_main().

JSAMPARRAY input_buf
 

Definition at line 55 of file jcmainct.c.

Referenced by process_data_simple_main().

 

Powered by Plone

This site conforms to the following standards: