📄 ref_forward_roi.c
字号:
assert(strcmp(*params,"*") == 0);
p--; params++;
}
else
{ /* Reuse last component's parameter set. */
p = last_comp_p;
params = last_comp_params;
}
}
}
/* Now check for the `max_shift' mode. */
if ((p = cmdl->extract(cmdl,"-Rmax_shift",tnum,¶ms)) >= 0)
{
int state;
if (params != global_max_shift_params)
for (c=0; c < num_components; c++)
components[c].tiles[tnum].tile_specific_params = 1;
c = 0;
state = 1;
while ((p > 0) && (c < num_components))
{
if (strcmp(*params,"Y") == 0)
state = 1;
else if (strcmp(*params,"N") == 0)
state = 0;
else
local_error("The `-max-shift' argument takes zero or more "
"parameters, each of which must be one of the two "
"characters, `Y' or `N'!");
components[c].tiles[tnum].implicit_partition = state;
c++;
}
for (; c < num_components; c++)
components[c].tiles[tnum].implicit_partition = state;
}
}
/*****************************************************************************/
/* STATIC save_tile_component_marker */
/*****************************************************************************/
static void
save_tile_component_marker(roi_tile_ptr tile, int instance, int tnum,
stream_out_ref stream)
/* Writes the region geometries and boost values, as well as the
implicit partition mode flag into the relevant RGN marker in the
code-stream. The information applies to the component whose zero-based
index is `instance'; this is also the instance number for the marker.
If `tnum' is negative, the information is written to the global header,
rather than a tile-header in the codestream. */
{
roi_region_ptr reg;
int num_rects;
int num_circs;
int idx, boost_idx;
if (tile->implicit_partition)
{
stream->declare_marker_elt(stream,tnum,MARKER_RGN_BOOSTS,instance,8,1);
stream->set_marker_val(stream,tnum,MARKER_RGN_BOOSTS,instance,(std_uint)
(tile->max_boost),0);
return;
}
num_rects = num_circs = 0;
for (reg=tile->regions; reg != NULL; reg=reg->next)
{
if (reg->is_rectangular)
num_rects++;
else
num_circs++;
}
stream->declare_marker_elt(stream,tnum,MARKER_RGN_BOOSTS,instance,8,
num_rects+num_circs);
stream->declare_marker_elt(stream,tnum,MARKER_RGN_RECTS,instance,32,
4*num_rects);
stream->declare_marker_elt(stream,tnum,MARKER_RGN_CIRCS,instance,32,
3*num_circs);
boost_idx = 0;
for (idx=0, reg=tile->regions; reg != NULL; reg=reg->next)
if (reg->is_rectangular)
{
stream->set_marker_val(stream,tnum,MARKER_RGN_BOOSTS,instance,
(std_uint)(reg->boost),boost_idx++);
stream->set_marker_val(stream,tnum,MARKER_RGN_RECTS,instance,
(std_uint)(reg->rect.left),idx++);
stream->set_marker_val(stream,tnum,MARKER_RGN_RECTS,instance,
(std_uint)(reg->rect.top),idx++);
stream->set_marker_val(stream,tnum,MARKER_RGN_RECTS,instance,
(std_uint)(reg->rect.right),idx++);
stream->set_marker_val(stream,tnum,MARKER_RGN_RECTS,instance,
(std_uint)(reg->rect.bottom),idx++);
}
for (idx=0, reg=tile->regions; reg != NULL; reg=reg->next)
if (!reg->is_rectangular)
{
stream->set_marker_val(stream,tnum,MARKER_RGN_BOOSTS,instance,
(std_uint)(reg->boost),boost_idx++);
stream->set_marker_val(stream,tnum,MARKER_RGN_CIRCS,instance,
(std_uint)(reg->circle.centre_col),idx++);
stream->set_marker_val(stream,tnum,MARKER_RGN_CIRCS,instance,
(std_uint)(reg->circle.centre_row),idx++);
stream->set_marker_val(stream,tnum,MARKER_RGN_CIRCS,instance,
(std_uint)(reg->circle.radius),idx++);
}
}
/*****************************************************************************/
/* STATIC start_tile */
/*****************************************************************************/
static void
start_tile(ref_forward_roi_ref self)
{
int num_components = self->num_components;
forward_info_ref info = self->info;
roi_component_info_ptr comp_info;
roi_tile_ptr tile;
roi_level_info_ptr lev;
int c, n;
for (c=0; c < num_components; c++)
{
/* SAIC General Decomp. Begin */
int decomp_sequence[16];
int decomp_sequence_pos = 0;
/* SAIC General Decomp. End */
comp_info = self->components + c;
tile = comp_info->tiles + comp_info->current_tile_idx;
/* Build resolution levels. */
comp_info->num_levels =
info->get_var_tile_info(info,c,NULL,NULL,NULL,NULL,NULL);
comp_info->levels = (roi_level_info_ptr)
local_malloc(ROI_MEM_KEY,
sizeof(roi_level_info)*(comp_info->num_levels+1));
for (n=0; n <= comp_info->num_levels; n++)
{
lev = comp_info->levels + n;
if (n == 0)
{
lev->min_band = lev->max_band = LL_BAND;
lev->max_hp_descent = 1;
}
else
{
info->get_level_info(info,c,n,NULL,&(lev->max_hp_descent),NULL,NULL);
if (lev->max_hp_descent == 0)
{ lev->min_band = 0; lev->max_band = -1; continue; }
else
{
lev->min_band = 1 << (lev->max_hp_descent+lev->max_hp_descent-2);
lev->max_band = (1<<(lev->max_hp_descent+lev->max_hp_descent)) - 1;
}
}
lev->bands = (roi_band_ref *)
local_malloc(ROI_MEM_KEY,
sizeof(roi_band_ref)*(lev->max_band+1));
lev->roi_generation_needed = 1;
lev->block_aligned = self->block_aligned;
}
/* Build the mask generation tree. */
n = comp_info->num_levels;
comp_info->root =
create_roi_mask_generation_tree(n,c,info,comp_info->levels+n,
NULL,0,0,
0, 0, 0, 0,
decomp_sequence,
&decomp_sequence_pos,
0, 0);
/* Initialize the mask generation tree. */
if (comp_info->root != NULL)
comp_info->root->initialize(comp_info->root,&(tile->dims));
}
/* Copy ROI parameters for the tile into the working locations. */
for (c=0; c < num_components; c++)
{
comp_info = self->components + c;
tile = comp_info->tiles + comp_info->current_tile_idx;
if (comp_info->root != NULL)
comp_info->root->regions = tile->regions;
comp_info->max_boost = tile->max_boost;
comp_info->implicit_partition = tile->implicit_partition;
comp_info->is_rectangular = tile->is_rectangular;
if (self->no_rect)
comp_info->is_rectangular = 0;
if (tile->implicit_partition)
check_partition_implicit(comp_info,c,info);
}
}
/* ========================================================================= */
/* ------------------------- Interface Implementation ---------------------- */
/* ========================================================================= */
/*****************************************************************************/
/* STATIC __initialize */
/*****************************************************************************/
static void
__initialize(forward_roi_ref base, int num_components,
forward_info_ref info, stream_out_ref stream,
cmdl_ref cmdl)
{
ref_forward_roi_ref self = (ref_forward_roi_ref) base;
roi_component_info_ptr comp_info;
roi_tile_ptr tile;
char **params, **global_rgn_params, **global_max_shift_params;
int p, c, tnum, num_tiles=0; /* TJF: =0 to avoid warnings */
self->info = info;
self->num_components = num_components;
/* First get general configuration command-line arguments. */
if ((p = cmdl->extract(cmdl,"-Ralign",-1,¶ms)) >= 0)
{
if (p != 0)
local_error("The `-Ralign' argument takes no parameters!");
self->block_aligned = 1;
}
if ((p = cmdl->extract(cmdl,"-Rno_rect",-1,¶ms)) >= 0)
{
if (p != 0)
local_error("The `-Rno_rect' argument takes no parameters!");
self->no_rect = 1;
}
/* Now create the component and tile structure. */
self->components = (roi_component_info_ptr)
local_malloc(ROI_MEM_KEY,sizeof(roi_component_info)*num_components);
for (c=0; c < num_components; c++)
{
comp_info = self->components + c;
tnum = 0;
/* MITRE General Offset/SQ Begin */ /* Begin Aerospace MCT mods */
while (info->get_fixed_tile_info(info,c,tnum,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL))
/* MITRE General Offset/SQ End */ /* End Aerospace MCT mods */
tnum++;
comp_info->num_tiles = num_tiles = tnum;
comp_info->tiles = (roi_tile_ptr)
local_malloc(ROI_MEM_KEY,sizeof(roi_tile)*comp_info->num_tiles);
for (tnum=0; tnum < comp_info->num_tiles; tnum++)
{
int xnum, ynum;
tile = comp_info->tiles + tnum;
tile->tnum = tnum;
/* Begin Aerospace MCT mods */
info->get_fixed_tile_info(info,c,tnum,&xnum,&ynum,
&(tile->dims),NULL,NULL,NULL,NULL,NULL,NULL,NULL);
/* End Aerospace MCT mods */
if (xnum == 0)
comp_info->image_dims.rows += tile->dims.rows;
if (ynum == 0)
comp_info->image_dims.cols += tile->dims.cols;
if ((xnum == 0) && (ynum == 0))
{
comp_info->image_dims.left_col = tile->dims.left_col;
comp_info->image_dims.top_row = tile->dims.top_row;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -