Back to index

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

Go to the source code of this file.

Classes

struct  my_post_controller

Defines

#define JPEG_INTERNALS

Typedefs

typedef my_post_controllermy_post_ptr

Functions

 METHODDEF (void)
 post_process_1pass (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
 jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)

Class Documentation

struct my_post_controller

Definition at line 26 of file jdpostct.c.

Collaboration diagram for my_post_controller:
Class Members
JSAMPARRAY buffer
JDIMENSION next_row
JDIMENSION starting_row
JDIMENSION strip_height
jvirt_sarray_ptr whole_image

Define Documentation

Definition at line 19 of file jdpostct.c.


Typedef Documentation

Definition at line 42 of file jdpostct.c.


Function Documentation

jinit_d_post_controller ( j_decompress_ptr  cinfo,
boolean  need_full_buffer 
)

Definition at line 250 of file jdpostct.c.

{
  my_post_ptr post;

  post = (my_post_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
                            SIZEOF(my_post_controller));
  cinfo->post = (struct jpeg_d_post_controller *) post;
  post->pub.start_pass = start_pass_dpost;
  post->whole_image = NULL; /* flag for no virtual arrays */
  post->buffer = NULL;             /* flag for no strip buffer */

  /* Create the quantization buffer, if needed */
  if (cinfo->quantize_colors) {
    /* The buffer strip height is max_v_samp_factor, which is typically
     * an efficient number of rows for upsampling to return.
     * (In the presence of output rescaling, we might want to be smarter?)
     */
    post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor;
    if (need_full_buffer) {
      /* Two-pass color quantization: need full-image storage. */
      /* We round up the number of rows to a multiple of the strip height. */
#ifdef QUANT_2PASS_SUPPORTED
      post->whole_image = (*cinfo->mem->request_virt_sarray)
       ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
        cinfo->output_width * cinfo->out_color_components,
        (JDIMENSION) jround_up((long) cinfo->output_height,
                            (long) post->strip_height),
        post->strip_height);
#else
      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
#endif /* QUANT_2PASS_SUPPORTED */
    } else {
      /* One-pass color quantization: just make a strip buffer. */
      post->buffer = (*cinfo->mem->alloc_sarray)
       ((j_common_ptr) cinfo, JPOOL_IMAGE,
        cinfo->output_width * cinfo->out_color_components,
        post->strip_height);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

METHODDEF ( void  )

Definition at line 46 of file jdpostct.c.

{
  my_post_ptr post = (my_post_ptr) cinfo->post;

  switch (pass_mode) {
  case JBUF_PASS_THRU:
    if (cinfo->quantize_colors) {
      /* Single-pass processing with color quantization. */
      post->pub.post_process_data = post_process_1pass;
      /* We could be doing buffered-image output before starting a 2-pass
       * color quantization; in that case, jinit_d_post_controller did not
       * allocate a strip buffer.  Use the virtual-array buffer as workspace.
       */
      if (post->buffer == NULL) {
       post->buffer = (*cinfo->mem->access_virt_sarray)
         ((j_common_ptr) cinfo, post->whole_image,
          (JDIMENSION) 0, post->strip_height, TRUE);
      }
    } else {
      /* For single-pass processing without color quantization,
       * I have no work to do; just call the upsampler directly.
       */
      post->pub.post_process_data = cinfo->upsample->upsample;
    }
    break;
#ifdef QUANT_2PASS_SUPPORTED
  case JBUF_SAVE_AND_PASS:
    /* First pass of 2-pass quantization */
    if (post->whole_image == NULL)
      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
    post->pub.post_process_data = post_process_prepass;
    break;
  case JBUF_CRANK_DEST:
    /* Second pass of 2-pass quantization */
    if (post->whole_image == NULL)
      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
    post->pub.post_process_data = post_process_2pass;
    break;
#endif /* QUANT_2PASS_SUPPORTED */
  default:
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
    break;
  }
  post->starting_row = post->next_row = 0;
}

Here is the call graph for this function:

post_process_1pass ( j_decompress_ptr  cinfo,
JSAMPIMAGE  input_buf,
JDIMENSION in_row_group_ctr,
JDIMENSION  in_row_groups_avail,
JSAMPARRAY  output_buf,
JDIMENSION out_row_ctr,
JDIMENSION  out_rows_avail 
)

Definition at line 126 of file jdpostct.c.

{
  my_post_ptr post = (my_post_ptr) cinfo->post;
  JDIMENSION num_rows, max_rows;

  /* Fill the buffer, but not more than what we can dump out in one go. */
  /* Note we rely on the upsampler to detect bottom of image. */
  max_rows = out_rows_avail - *out_row_ctr;
  if (max_rows > post->strip_height)
    max_rows = post->strip_height;
  num_rows = 0;
  (*cinfo->upsample->upsample) (cinfo,
              input_buf, in_row_group_ctr, in_row_groups_avail,
              post->buffer, &num_rows, max_rows);
  /* Quantize and emit data. */
  (*cinfo->cquantize->color_quantize) (cinfo,
              post->buffer, output_buf + *out_row_ctr, (int) num_rows);
  *out_row_ctr += num_rows;
}

Here is the call graph for this function:

Here is the caller graph for this function: