📄 ref_reverse_roi.c
字号:
case 3:
new_vert_limit = 2;
new_remaining_max_vert_hp_descent = remaining_max_vert_hp_descent-1;
new_remaining_max_horiz_hp_descent = remaining_max_horiz_hp_descent;
new_horiz_limit = 1;
break;
}
hor_stage->branches[hor_idx] =
create_roi_mask_generation_tree(num_levels,component_idx,
info,lev,hor_stage,
remaining_hp_descent-1,
band_idx,
new_vert_limit, new_horiz_limit,
new_remaining_max_vert_hp_descent,
new_remaining_max_horiz_hp_descent,
decomp_sequence,
decomp_sequence_pos,
first_max_horiz_hp_descent,
first_max_vert_hp_descent);
}
else
{ /* Band is finished. Insert a leaf node. */
if (remaining_hp_descent > 1) {
current_opcode = decomp_sequence[*decomp_sequence_pos];
assert(current_opcode == 0);
(*decomp_sequence_pos)++;
}
leaf_stage = ref_roi_create_band_stage();
hor_stage->branches[hor_idx] = leaf_stage;
leaf_stage->parent = hor_stage;
lev->bands[band_idx] = (roi_band_ref) leaf_stage;
}
}
}
return(vert_stage);
}
/* SAIC General Decomp. End mods */
/*****************************************************************************/
/* STATIC check_partition_implicit */
/*****************************************************************************/
static void
check_partition_implicit(roi_component_info_ptr comp_info,
int component_idx, reverse_info_ref info)
/* This function determines whether or not a partition is implicitly
recoverable at the decoder, based upon the following criteria:
1) there must be only one non-zero `boost' value; and 2) the boost, B,
must satisfy B >= (M-E), where M is the number of magnitude bits in an
`ifc_int' word, i.e. M=IMPLEMENTATION_PRECISION-1, and E is the number
of extra least significant bits returned by `forward_info__get_quant_info'.
This relationship must hold for all subbands in the relevant component
within the current tile. If these conditions are not satisfied, the
function generates an error message which indicates how the boost values
must be changed to be compatible with implict recovery of the ROI
partition at the decoder. The test should be repeated for each tile. */
{
roi_tile_ptr tile;
roi_level_info_ptr lev;
roi_region_ptr region;
int n, b;
int min_boost, extra_lsbs;
/* SAIC General Decomp. Begin */
int valid_band;
/* SAIC General Decomp. End */
tile = comp_info->tiles + comp_info->current_tile_idx;
for (region=tile->regions; region != NULL; region=region->next)
if (region->boost != tile->max_boost)
local_error("The `-Rmax_shift' flag may only be used in conjunction "
"with a single region boost, of sufficiently large "
"magnitude. You cannot have multiple regions with "
"different boosts!");
min_boost = 0;
for (n=0; n <= comp_info->num_levels; n++)
{
lev = comp_info->levels + n;
for (b=lev->min_band; b <= lev->max_band; b++)
{
info->get_band_info(info,component_idx,n,b,NULL,NULL,NULL,NULL,NULL,NULL,&valid_band);
if (!valid_band)
continue;
/* MITRE General Offset/SQ Begin */
info->get_quant_info(info,component_idx,n,b,
NULL,NULL,&extra_lsbs,NULL);
/* MITRE General Offset/SQ End */
if (min_boost < (IMPLEMENTATION_PRECISION-1-extra_lsbs))
min_boost = IMPLEMENTATION_PRECISION-1-extra_lsbs;
}
}
if (tile->max_boost < min_boost)
local_error("The `-Rmax_shift' flag may not be used with the supplied "
"region boost values. For the decoder to be able to "
"implicitly recover the ROI partition information from the "
"decoded sample values themselves, it is necessary to use "
"a boost value of at least %d in specifying the regions of "
"interest!",min_boost);
}
/*****************************************************************************/
/* STATIC retrieve_roi_parameters_from_stream */
/*****************************************************************************/
static void
retrieve_roi_parameters_from_stream(roi_tile_ptr tile, int instance,
stream_in_ref stream)
{
int tnum = tile->tnum;
roi_region_ptr reg;
double val;
int num_rects, num_circs, num_boosts, num_regions, idx, boost_idx;
num_boosts = stream->size_marker_elt(stream,tnum,MARKER_RGN_BOOSTS,instance);
num_rects = stream->size_marker_elt(stream,tnum,MARKER_RGN_RECTS,instance);
num_circs = stream->size_marker_elt(stream,tnum,MARKER_RGN_CIRCS,instance);
assert((num_rects % 4) == 0); num_rects = num_rects / 4;
assert((num_circs % 3) == 0); num_circs = num_circs / 3;
num_regions = num_rects + num_circs;
tile->is_rectangular = (num_circs == 0);
if (num_boosts == 0)
{
assert(num_regions == 0);
assert(tile->regions == NULL);
tile->max_boost = 0;
return;
}
if (num_regions == 0)
{
assert(num_boosts == 1);
assert(tile->regions == NULL);
tile->implicit_partition = 1;
tile->max_boost = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_BOOSTS,instance,0);
return;
}
tile->max_boost = 0;
boost_idx = 0;
for (idx=0; num_rects > 0; num_rects--)
{
reg = (roi_region_ptr) local_malloc(ROI_MEM_KEY,sizeof(roi_region));
reg->next = tile->regions;
tile->regions = reg;
reg->is_rectangular = 1;
reg->boost = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_BOOSTS,instance,
boost_idx++);
assert(reg->boost > 0);
reg->rect.left = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_RECTS,instance,idx++);
reg->rect.top = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_RECTS,instance,idx++);
reg->rect.right = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_RECTS,instance,idx++);
reg->rect.bottom = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_RECTS,instance,idx++);
reg->circle.centre_col = tile->dims.left_col;
reg->circle.centre_row = tile->dims.top_row;
reg->circle.radius = tile->dims.cols + tile->dims.rows;
val = (double)(reg->circle.radius);
reg->circle.radius_squared = val * val;
if (reg->boost > tile->max_boost)
tile->max_boost = reg->boost;
}
for (idx=0; num_circs > 0; num_circs--)
{
reg = (roi_region_ptr) local_malloc(ROI_MEM_KEY,sizeof(roi_region));
reg->next = tile->regions;
tile->regions = reg;
reg->is_rectangular = 0;
reg->boost = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_BOOSTS,instance,
boost_idx++);
assert(reg->boost > 0);
reg->circle.centre_col = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_CIRCS,instance,idx++);
reg->circle.centre_row = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_CIRCS,instance,idx++);
reg->circle.radius = (int)
stream->get_marker_val(stream,tnum,MARKER_RGN_CIRCS,instance,idx++);
val = (double)(reg->circle.radius);
reg->circle.radius_squared = val * val;
reg->rect.left = tile->dims.left_col;
reg->rect.right = reg->rect.left + tile->dims.cols - 1;
reg->rect.top = tile->dims.top_row;
reg->rect.bottom = reg->rect.top + tile->dims.rows - 1;
if (reg->boost > tile->max_boost)
tile->max_boost = reg->boost;
}
assert(boost_idx == num_boosts);
}
/*****************************************************************************/
/* STATIC start_tile */
/*****************************************************************************/
static void
start_tile(ref_reverse_roi_ref self)
{
int num_components = self->num_components;
reverse_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 =
(n <= (comp_info->num_levels - self->discard_levels));
}
/* 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,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -