Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
jcmainct.c File Reference
#include "jinclude.h"
#include "jpeglib.h"

Go to the source code of this file.

Classes

struct  my_main_controller

Defines

#define JPEG_INTERNALS

Typedefs

typedef my_main_controllermy_main_ptr

Functions

 METHODDEF (void)
 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)

Class Documentation

struct my_main_controller

Definition at line 28 of file jcmainct.c.

Collaboration diagram for my_main_controller:
Class Members
JSAMPARRAY buffer
boolean buffer_full
int context_state
JDIMENSION cur_iMCU_row
JDIMENSION iMCU_row_ctr
J_BUF_MODE pass_mode
JDIMENSION rowgroup_ctr
JDIMENSION rowgroups_avail
boolean suspended
int whichptr
JSAMPIMAGE xbuffer

Define Documentation

Definition at line 13 of file jcmainct.c.


Typedef Documentation

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.

{
  my_main_ptr main;
  int ci;
  jpeg_component_info *compptr;

  main = (my_main_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
                            SIZEOF(my_main_controller));
  cinfo->main = (struct jpeg_c_main_controller *) main;
  main->pub.start_pass = start_pass_main;

  /* We don't need to create a buffer in raw-data mode. */
  if (cinfo->raw_data_in)
    return;

  /* Create the buffer.  It holds downsampled data, so each component
   * may be of a different size.
   */
  if (need_full_buffer) {
#ifdef FULL_MAIN_BUFFER_SUPPORTED
    /* Allocate a full-image virtual array for each component */
    /* Note we pad the bottom to a multiple of the iMCU height */
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
        ci++, compptr++) {
      main->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
       ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
        compptr->width_in_blocks * DCTSIZE,
        (JDIMENSION) jround_up((long) compptr->height_in_blocks,
                            (long) compptr->v_samp_factor) * DCTSIZE,
        (JDIMENSION) (compptr->v_samp_factor * DCTSIZE));
    }
#else
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
#endif
  } else {
#ifdef FULL_MAIN_BUFFER_SUPPORTED
    main->whole_image[0] = NULL; /* flag for no virtual arrays */
#endif
    /* Allocate a strip buffer for each component */
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
        ci++, compptr++) {
      main->buffer[ci] = (*cinfo->mem->alloc_sarray)
       ((j_common_ptr) cinfo, JPOOL_IMAGE,
        compptr->width_in_blocks * DCTSIZE,
        (JDIMENSION) (compptr->v_samp_factor * DCTSIZE));
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

METHODDEF ( void  )

Definition at line 54 of file jcmainct.c.

{
  my_main_ptr main = (my_main_ptr) cinfo->main;

  /* Do nothing in raw-data mode. */
  if (cinfo->raw_data_in)
    return;

  main->cur_iMCU_row = 0;   /* initialize counters */
  main->rowgroup_ctr = 0;
  main->suspended = FALSE;
  main->pass_mode = pass_mode;     /* save mode for use by process_data */

  switch (pass_mode) {
  case JBUF_PASS_THRU:
#ifdef FULL_MAIN_BUFFER_SUPPORTED
    if (main->whole_image[0] != NULL)
      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
#endif
    main->pub.process_data = process_data_simple_main;
    break;
#ifdef FULL_MAIN_BUFFER_SUPPORTED
  case JBUF_SAVE_SOURCE:
  case JBUF_CRANK_DEST:
  case JBUF_SAVE_AND_PASS:
    if (main->whole_image[0] == NULL)
      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
    main->pub.process_data = process_data_buffer_main;
    break;
#endif
  default:
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
    break;
  }
}

Here is the call graph for this function:

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.

{
  my_main_ptr main = (my_main_ptr) cinfo->main;

  while (main->cur_iMCU_row < cinfo->total_iMCU_rows) {
    /* Read input data if we haven't filled the main buffer yet */
    if (main->rowgroup_ctr < DCTSIZE)
      (*cinfo->prep->pre_process_data) (cinfo,
                                   input_buf, in_row_ctr, in_rows_avail,
                                   main->buffer, &main->rowgroup_ctr,
                                   (JDIMENSION) DCTSIZE);

    /* If we don't have a full iMCU row buffered, return to application for
     * more data.  Note that preprocessor will always pad to fill the iMCU row
     * at the bottom of the image.
     */
    if (main->rowgroup_ctr != DCTSIZE)
      return;

    /* Send the completed row to the compressor */
    if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) {
      /* If compressor did not consume the whole row, then we must need to
       * suspend processing and return to the application.  In this situation
       * we pretend we didn't yet consume the last input row; otherwise, if
       * it happened to be the last row of the image, the application would
       * think we were done.
       */
      if (! main->suspended) {
       (*in_row_ctr)--;
       main->suspended = TRUE;
      }
      return;
    }
    /* We did finish the row.  Undo our little suspension hack if a previous
     * call suspended; then mark the main buffer empty.
     */
    if (main->suspended) {
      (*in_row_ctr)++;
      main->suspended = FALSE;
    }
    main->rowgroup_ctr = 0;
    main->cur_iMCU_row++;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: