⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 std_reverse_info.c

📁 JPEG2000实现的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
  self->tiles_wide =
    CEIL_RATIO(self->grid_dims.cols + self->grid_dims.left_col -
               self->tile_dims.left_col,self->tile_dims.cols);
  self->total_tiles = self->tiles_high * self->tiles_wide;
  self->tiles = (std_tile_info_ptr)
    local_malloc(INFO_MEM_KEY,
                 sizeof(std_tile_info)*self->total_tiles);
  initialize_tiles(self);

  /* Retrieve other parameters from the codestream, constructing a tile-
     specific structure for the first tile if necessary and leaving the
     remaining tiles for now. */

  initialize_tile_specific(self,-1,self->default_components,stream);

  tile = self->tiles;
  tile->visited = 1;
  if (stream->have_tile_specific_markers(stream,0))
    {
      tile->components = (std_component_info_ptr)
        local_malloc(INFO_MEM_KEY,sizeof(std_component_info)*num_components);
      initialize_tile_specific(self,0,tile->components,stream);
    }

/* SAIC TCQ begin */
#if (IMPLEMENTATION_PRECISION < 32)
  {
    int quantizer;

    quantizer = stream->get_marker_val(stream,-1,MARKER_QCD_WHICH,0,0);
    if (quantizer == 2)
      for (c=0; c < num_components; c++)
        {
          if (self->default_components[c].bitdepth > 8)
            {
              local_printf(0, 76, "WARNING");
              local_printf(4, 70,
                           "The input encoded image contains %d-bit sample "
                           "values.  Use of %d-bit precision ITCQ on "
                           "images with such large bit-depths may "
                           "yield poor results.  Use of 32-bit ITCQ "
                           "is recommended!\n\n",
                           self->default_components[c].bitdepth,
                           IMPLEMENTATION_PRECISION);
              break; /* Don't print the message again. */
            }
        }
  }
#endif /* (IMPLEMENTATION_PRECISION < 32) */
/* SAIC TCQ end */
}

/*****************************************************************************/
/* STATIC                          __get_usage                               */
/*****************************************************************************/

static char **
  __get_usage(reverse_info_ref base)
{
  static char *args[] =
    {"-Fconv (default=use lifting implementation)",
       "This flag forces the use of a convolution-based implementation of "
       "the Wavelet transform in place of the default lifting-based "
       "implementation.  The flag affects only those image components "
       "which have a non-reversible decomposition.  The codestream does not "
       "provide any indication as to whether non-reversible transforms "
       "are implemented using lifting or convolution.",
     NULL};

  return(args);
}

/* MITRE General Offset/SQ Begin mods */
/*****************************************************************************/
/* STATIC                     __get_fixed_tile_info                          */
/*****************************************************************************/
static int
 __get_fixed_tile_info(reverse_info_ref base, int component_idx,
                       int tnum, int *xnum, int *ynum,
                       canvas_dims_ptr dims,
                       int *hor_subsampling, int *vert_subsampling,

                       /** OTLPF_CONVENSION begin **/
                       int *hor_offset, int *vert_offset, int *num_levels,
                       /** OTLPF_CONVENSION end **/

                       int *precision,
                       /* Begin Aerospace MCT mods */
                       int *multicomp_xform)
                       /* End Aerospace MCT mods */
{
  std_reverse_info_ref self = (std_reverse_info_ref) base;
  std_tile_info_ptr tile;
  std_component_info_ptr comp_info;

  if ((tnum < 0) || (tnum >= self->total_tiles))
    return(0);
  tile = self->tiles + tnum;
  if (xnum != NULL)
    *xnum = tile->x_idx;
  if (ynum != NULL)
    *ynum = tile->y_idx;
  if (multicomp_xform != NULL )
    *multicomp_xform = 
       ( self->stream->get_marker_val(self->stream,tnum,MARKER_COD_CXFORM,
                      0,0) == MIXING_XFORM_LIN ) ? 1:0;
  if (component_idx < 0)
    {
      if (dims != NULL)
        *dims = tile->dims;
      if (hor_subsampling != NULL)
        *hor_subsampling = 1;
      if (vert_subsampling != NULL)
        *vert_subsampling = 1;
      assert(precision == NULL);
    }
  else
    {
      /* Begin Aerospace MCT mods (TSW) */
      /* If the multi-component transform is used for this tile, it is 
     possible that the requested component has index greater than
     num_components. However, in that case, all component size info
     must be the same as for any other component, since we are requiring
     that all components have the same size if multi-component
     transforms are used. Also, in that case the precision data is
     irrelevant since the writer object will have already initialized 
         the output image files with proper bitdepths. */
      if ( ( component_idx >= self->num_components ) && 
       ( self->stream->get_marker_val(self->stream,tnum,MARKER_COD_CXFORM,
                      0,0) == MIXING_XFORM_LIN ) )
    component_idx = self->num_components-1;
      /* End Aerospace MCT mods (TSW) */
      comp_info = tile->components + component_idx;
      assert((component_idx < self->num_components) &&
             (component_idx == comp_info->component_idx));
      if (dims != NULL)
        {
          int ax, ay, bx, by, h_factor, v_factor;;

          ax = tile->dims.left_col;
          ay = tile->dims.top_row;
          bx = ax + tile->dims.cols;
          by = ay + tile->dims.rows;
          h_factor = comp_info->hor_subsampling;
          v_factor = comp_info->vert_subsampling;
          ax = CEIL_RATIO(ax,h_factor);
          bx = CEIL_RATIO(bx,h_factor);
          ay = CEIL_RATIO(ay,v_factor);
          by = CEIL_RATIO(by,v_factor);
          dims->left_col = ax;
          dims->top_row = ay;
          dims->cols = bx - ax;
          dims->rows = by - ay;
        }
      if (hor_subsampling != NULL)
        *hor_subsampling = comp_info->hor_subsampling;
      if (vert_subsampling != NULL)
        *vert_subsampling = comp_info->vert_subsampling;

      /* OTLPF_CONVENTION begin; JX Wei ADFA, WJ Zeng Sharp */
      if (num_levels != NULL)
              *num_levels = comp_info->num_levels;
      if (hor_offset != NULL)
              *hor_offset = self->tile_dims.left_col;
      if (vert_offset != NULL)
              *vert_offset = self->tile_dims.top_row;
      /* OTLPF_CONVENTION end; JX Wei ADFA, WJ Zeng Sharp */

      if (precision != NULL)
        *precision =
          (comp_info->is_signed)?(-comp_info->bitdepth):(comp_info->bitdepth);
    }
  return(1);
}
/* MITRE General Offset/SQ End mods */

/*****************************************************************************/
/* STATIC                     __get_var_tile_info                            */
/*****************************************************************************/

static int
 __get_var_tile_info(reverse_info_ref base, int component_idx,
                     int *tnum, canvas_dims_ptr dims,
                     int *reversible, int *sample_downshift,
                     double *dc_offset)
{
  std_reverse_info_ref self = (std_reverse_info_ref) base;
  std_tile_info_ptr tile;
  std_component_info_ptr comp_info;

  if (self->current_tile_idx >= self->total_tiles)
    local_error("Attempting to access level information beyond "
                "the last image tile!");
  tile = self->tiles + self->current_tile_idx;
  /* Begin Aerospace MCT mods (TSW) */
  /* If the multi-component transform is used for this tile, it is 
     possible that the requested component has index greater than
     num_components. However, in that case, all component size info
     must be the same as for any other component, since we are requiring
     that all components have the same size if multi-component
     transforms are used. Also, in that case the precision data is
     irrelevant since the writer object will have already initialized 
     the output image files with proper bitdepths. */
  if ( ( component_idx >= self->num_components ) && 
       ( self->stream->get_marker_val(self->stream,self->current_tile_idx,
                  MARKER_COD_CXFORM,0,0) == MIXING_XFORM_LIN ) )
    component_idx = self->num_components-1;
  /* End Aerospace MCT mods (TSW) */
  comp_info = tile->components + component_idx;
  assert((component_idx < self->num_components) &&
         (component_idx == comp_info->component_idx));
  if (tnum != NULL)
    *tnum = self->current_tile_idx;
  if (dims != NULL)
    {
      int ax, ay, bx, by, h_factor, v_factor;;

      ax = tile->dims.left_col;
      ay = tile->dims.top_row;
      bx = ax + tile->dims.cols;
      by = ay + tile->dims.rows;
      h_factor = comp_info->hor_subsampling;
      v_factor = comp_info->vert_subsampling;
      ax = CEIL_RATIO(ax,h_factor);
      bx = CEIL_RATIO(bx,h_factor);
      ay = CEIL_RATIO(ay,v_factor);
      by = CEIL_RATIO(by,v_factor);
      ax -= (tile->x_idx > 0)?comp_info->ovlp_left:0;
      ay -= (tile->y_idx > 0)?comp_info->ovlp_top:0;
      bx += (tile->x_idx < (self->tiles_wide-1))?comp_info->ovlp_right:0;
      by += (tile->y_idx < (self->tiles_high-1))?comp_info->ovlp_bottom:0;
      dims->left_col = ax;
      dims->top_row = ay;
      dims->cols = bx - ax;
      dims->rows = by - ay;
    }
  if (reversible != NULL)
    *reversible = comp_info->reversible;
  if (sample_downshift != NULL)
    *sample_downshift = comp_info->sample_downshift;
  if (dc_offset != NULL)
    *dc_offset = comp_info->adjust_dc;
  return(comp_info->num_levels);
}

/*****************************************************************************/
/* STATIC                          __next_tile                               */
/*****************************************************************************/

static int
  __next_tile(reverse_info_ref base, int reset)
{
  std_reverse_info_ref self = (std_reverse_info_ref) base;
  std_tile_info_ptr tile;

  if (reset)
    {
      self->current_tile_idx = 0;
      return(INFO__TILE_START);
    }
  self->current_tile_idx++;
  if (self->current_tile_idx >= self->total_tiles)
    return(0);
  tile = self->tiles + self->current_tile_idx;
  if (!tile->visited)
    {
      int tnum;

      tnum = self->current_tile_idx;
      tile->visited = 1;
      if (self->stream->have_tile_specific_markers(self->stream,tnum))
        {
          tile->components = (std_component_info_ptr)
            local_malloc(INFO_MEM_KEY,
                         sizeof(std_component_info)*self->num_components);
          initialize_tile_specific(self,tnum,tile->components,self->stream);
        }
    }
  if (tile->x_idx == 0)
    return(INFO__TILE_DOWN);
  return(INFO__TILE_RIGHT);
}

/*****************************************************************************/
/* STATIC                        __get_level_info                            */
/*****************************************************************************/

static void
  __get_level_info(reverse_info_ref base, int component_idx, int level_idx,
                   canvas_dims_ptr dims, int *max_hp_descent,
                   frame_info_ptr frame,

                   /* SAIC General Decomp. Begin */
                   int *decomp_sequence)
                   /* SAIC General Decomp. End */
{
  std_reverse_info_ref self = (std_reverse_info_ref) base;
  std_tile_info_ptr tile;
  std_component_info_ptr comp_info;
  std_level_info_ptr lev;

  /* SAIC General Decomp. Begin */
  int n;
  /* SAIC General Decomp. End */

  /* OTLPF_CONVENTION begin; JX Wei ADFA, WJ Zeng Sharp */
  int twidth;
  /* OTLPF_CONVENTION end; JX Wei ADFA, WJ Zeng Sharp */

  if (self->current_tile_idx >= self->total_tiles)
    local_error("Attempting to access level information beyond "
                "the last image tile!");
  tile = self->tiles + self->current_tile_idx;
  comp_info = tile->components + component_idx;
  assert((component_idx < self->num_components) &&
         (level_idx <= comp_info->num_levels));
  lev = comp_info->levels + level_idx;
  if (dims != NULL)
    {
      int ax, ay, bx, by, h_factor, v_factor;;

      ax = tile->dims.left_col;
      ay = tile->dims.top_row;
      bx = ax 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -