Back to index

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

Go to the source code of this file.

Classes

struct  my_prep_controller

Defines

#define JPEG_INTERNALS

Typedefs

typedef my_prep_controllermy_prep_ptr

Functions

 start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
 expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, int input_rows, int output_rows)
 pre_process_data (j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail, JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, JDIMENSION out_row_groups_avail)
 jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)

Class Documentation

struct my_prep_controller

Definition at line 53 of file jcprepct.c.

Collaboration diagram for my_prep_controller:
Class Members
JSAMPARRAY color_buf
int next_buf_row
JDIMENSION rows_to_go

Define Documentation

Definition at line 17 of file jcprepct.c.


Typedef Documentation

Definition at line 70 of file jcprepct.c.


Function Documentation

expand_bottom_edge ( JSAMPARRAY  image_data,
JDIMENSION  num_cols,
int  input_rows,
int  output_rows 
)

Definition at line 106 of file jcprepct.c.

{
  register int row;

  for (row = input_rows; row < output_rows; row++) {
    jcopy_sample_rows(image_data, input_rows-1, image_data, row,
                    1, num_cols);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

jinit_c_prep_controller ( j_compress_ptr  cinfo,
boolean  need_full_buffer 
)

Definition at line 315 of file jcprepct.c.

{
  my_prep_ptr prep;
  int ci;
  jpeg_component_info * compptr;

  if (need_full_buffer)            /* safety check */
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);

  prep = (my_prep_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
                            SIZEOF(my_prep_controller));
  cinfo->prep = (struct jpeg_c_prep_controller *) prep;
  prep->pub.start_pass = start_pass_prep;

  /* Allocate the color conversion buffer.
   * We make the buffer wide enough to allow the downsampler to edge-expand
   * horizontally within the buffer, if it so chooses.
   */
  if (cinfo->downsample->need_context_rows) {
    /* Set up to provide context rows */
#ifdef CONTEXT_ROWS_SUPPORTED
    prep->pub.pre_process_data = pre_process_context;
    create_context_buffer(cinfo);
#else
    ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
  } else {
    /* No context, just make it tall enough for one row group */
    prep->pub.pre_process_data = pre_process_data;
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
        ci++, compptr++) {
      prep->color_buf[ci] = (*cinfo->mem->alloc_sarray)
       ((j_common_ptr) cinfo, JPOOL_IMAGE,
        (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE *
                     cinfo->max_h_samp_factor) / compptr->h_samp_factor),
        (JDIMENSION) cinfo->max_v_samp_factor);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

pre_process_data ( j_compress_ptr  cinfo,
JSAMPARRAY  input_buf,
JDIMENSION in_row_ctr,
JDIMENSION  in_rows_avail,
JSAMPIMAGE  output_buf,
JDIMENSION out_row_group_ctr,
JDIMENSION  out_row_groups_avail 
)

Definition at line 128 of file jcprepct.c.

{
  my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
  int numrows, ci;
  JDIMENSION inrows;
  jpeg_component_info * compptr;

  while (*in_row_ctr < in_rows_avail &&
        *out_row_group_ctr < out_row_groups_avail) {
    /* Do color conversion to fill the conversion buffer. */
    inrows = in_rows_avail - *in_row_ctr;
    numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
    numrows = (int) MIN((JDIMENSION) numrows, inrows);
    (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
                                   prep->color_buf,
                                   (JDIMENSION) prep->next_buf_row,
                                   numrows);
    *in_row_ctr += numrows;
    prep->next_buf_row += numrows;
    prep->rows_to_go -= numrows;
    /* If at bottom of image, pad to fill the conversion buffer. */
    if (prep->rows_to_go == 0 &&
       prep->next_buf_row < cinfo->max_v_samp_factor) {
      for (ci = 0; ci < cinfo->num_components; ci++) {
       expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
                        prep->next_buf_row, cinfo->max_v_samp_factor);
      }
      prep->next_buf_row = cinfo->max_v_samp_factor;
    }
    /* If we've filled the conversion buffer, empty it. */
    if (prep->next_buf_row == cinfo->max_v_samp_factor) {
      (*cinfo->downsample->downsample) (cinfo,
                                   prep->color_buf, (JDIMENSION) 0,
                                   output_buf, *out_row_group_ctr);
      prep->next_buf_row = 0;
      (*out_row_group_ctr)++;
    }
    /* If at bottom of image, pad the output to a full iMCU height.
     * Note we assume the caller is providing a one-iMCU-height output buffer!
     */
    if (prep->rows_to_go == 0 &&
       *out_row_group_ctr < out_row_groups_avail) {
      for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
          ci++, compptr++) {
       expand_bottom_edge(output_buf[ci],
                        compptr->width_in_blocks * DCTSIZE,
                        (int) (*out_row_group_ctr * compptr->v_samp_factor),
                        (int) (out_row_groups_avail * compptr->v_samp_factor));
      }
      *out_row_group_ctr = out_row_groups_avail;
      break;                /* can exit outer loop without test */
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

start_pass_prep ( j_compress_ptr  cinfo,
J_BUF_MODE  pass_mode 
)

Definition at line 78 of file jcprepct.c.

{
  my_prep_ptr prep = (my_prep_ptr) cinfo->prep;

  if (pass_mode != JBUF_PASS_THRU)
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);

  /* Initialize total-height counter for detecting bottom of image */
  prep->rows_to_go = cinfo->image_height;
  /* Mark the conversion buffer empty */
  prep->next_buf_row = 0;
#ifdef CONTEXT_ROWS_SUPPORTED
  /* Preset additional state variables for context mode.
   * These aren't used in non-context mode, so we needn't test which mode.
   */
  prep->this_row_group = 0;
  /* Set next_buf_stop to stop after two row groups have been read in. */
  prep->next_buf_stop = 2 * cinfo->max_v_samp_factor;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function: