📄 ref_reverse_roi.c
字号:
0, 0);
/* Initialize the mask generation tree. */
if (comp_info->root != NULL)
comp_info->root->initialize(comp_info->root,&(tile->dims));
}
/* Determine ROI parameters for the tile and copy them 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;
retrieve_roi_parameters_from_stream(tile,c,self->stream);
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(reverse_roi_ref base, int discard_levels, int num_components,
reverse_info_ref info, stream_in_ref stream, cmdl_ref cmdl)
{
ref_reverse_roi_ref self = (ref_reverse_roi_ref) base;
roi_component_info_ptr comp_info;
roi_tile_ptr tile;
char **params;
int p, c, tnum;
self->stream = stream;
self->info = info;
self->num_components = num_components;
self->discard_levels = discard_levels;
/* First get general configuration command-line arguments. */
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 = 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;
/* MITRE General Offset/SQ Begin */ /* Begin Aerospace MCT mods */
info->get_fixed_tile_info(info,c,tnum,&xnum,&ynum,
&(tile->dims),NULL,NULL,NULL,NULL,NULL,NULL,NULL);
/* MITRE General Offset/SQ End */ /* 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;
}
}
}
/* Finally, start the first tile. */
start_tile(self);
}
/*****************************************************************************/
/* STATIC __get_usage */
/*****************************************************************************/
static char **
__get_usage(reverse_roi_ref base)
{
static char *args[] =
{
/* Begin ROIrect */
"-Rno_rect",
"This flag forces the use of the generic ROI mask generation "
"implementation, rather than the fast rectangular mask generation. "
"The flag has no affect unless all ROI regions in some tile-component "
"have rectangular geometries, since this is the condition under which "
"the specific implementation for rectangular geometries will normally "
"be used.",
/* End ROIrect */
NULL};
return(args);
}
/*****************************************************************************/
/* STATIC __next_tile */
/*****************************************************************************/
static void
__next_tile(reverse_roi_ref base)
{
ref_reverse_roi_ref self = (ref_reverse_roi_ref) base;
roi_component_info_ptr comp;
int c;
for (c=0; c < self->num_components; c++)
{
comp = self->components + c;
ref_roi_terminate_component(comp);
comp->tiles[comp->current_tile_idx].regions = NULL;
comp->current_tile_idx++;
assert(comp->current_tile_idx < comp->num_tiles);
}
start_tile(self);
}
/*****************************************************************************/
/* STATIC __get_max_boost */
/*****************************************************************************/
static int
__get_max_boost(reverse_roi_ref base, int component_idx, int level_idx,
int band_idx, int *mask_implicit)
{
ref_reverse_roi_ref self = (ref_reverse_roi_ref) base;
roi_component_info_ptr comp_info;
assert(component_idx < self->num_components);
comp_info = self->components + component_idx;
if (mask_implicit != NULL)
*mask_implicit = comp_info->implicit_partition;
return(comp_info->max_boost);
}
/*****************************************************************************/
/* STATIC __check_roi */
/*****************************************************************************/
static int
__check_roi(reverse_roi_ref base, int component_idx, int level_idx,
int band_idx, int block_rows, int block_cols, int top_row,
int left_col, int *min_boost, std_byte *mask[])
{
ref_reverse_roi_ref self = (ref_reverse_roi_ref) base;
roi_component_info_ptr comp_info;
roi_level_info_ptr lev;
roi_band_ref band;
std_byte *mp, **mpp, min, max;
int r, c;
assert(component_idx < self->num_components);
comp_info = self->components + component_idx;
if (comp_info->max_boost == 0)
{
*min_boost = 0;
return(0);
}
assert(level_idx <= comp_info->num_levels);
lev = comp_info->levels + level_idx;
assert((band_idx >= lev->min_band) && (band_idx <= lev->max_band));
band = lev->bands[band_idx];
assert(lev->roi_generation_needed && (band != NULL));
if (comp_info->implicit_partition)
{
*min_boost = 0;
for (r=0; r < block_rows; r++)
mask[r] = NULL;
return(comp_info->max_boost);
}
assert(!lev->block_aligned); /* Otherwise, we would not have saved the
regions during compression. */
ref_roi_get_band_mask(band,block_rows,block_cols,top_row,left_col,mask,
comp_info); /* ROIrect */
/* Determine min and max boost. */
min = max = *(mask[0]);
for (mpp=mask, r=block_rows; r > 0; r--, mpp++)
for (mp=*mpp, c=block_cols; c > 0; c--, mp++)
if (*mp < min)
min = *mp;
else if (*mp > max)
max = *mp;
*min_boost = (int) min;
if (min)
for (mpp=mask, r=block_rows; r > 0; r--, mpp++)
for (mp=*mpp, c=block_cols; c > 0; c--, mp++)
*mp -= min;
return((int)(max-min));
}
/*****************************************************************************/
/* STATIC __terminate */
/*****************************************************************************/
static void
__terminate(reverse_roi_ref base)
{
ref_reverse_roi_ref self = (ref_reverse_roi_ref) base;
int c;
if (self->components != NULL)
{
for (c=0; c < self->num_components; c++)
{
ref_roi_terminate_component(self->components + c);
if (self->components[c].tiles != NULL)
local_free(self->components[c].tiles);
}
local_free(self->components);
}
local_free(self);
}
/*****************************************************************************/
/* EXTERN create_reference_reverse_roi */
/*****************************************************************************/
reverse_roi_ref
create_reference_reverse_roi(void)
{
ref_reverse_roi_ref result;
result = (ref_reverse_roi_ref)
local_malloc(ROI_MEM_KEY,sizeof(ref_reverse_roi_obj));
result->base.initialize = __initialize;
result->base.get_usage = __get_usage;
result->base.get_max_boost = __get_max_boost;
result->base.check_roi = __check_roi;
result->base.next_tile = __next_tile;
result->base.terminate = __terminate;
return((reverse_roi_ref) result);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -