📄 hplx_synthesis.c
字号:
{
val = *(sp++);
*(line_buf++) = (ifc_int)((val<0.0F)?(val-0.5F):(val+0.5F));
}
}
else
base->dequant->pull_line_fixed(base->dequant,line_buf,base->component_idx,
base->level_idx,base->band_idx,width);
}
/*****************************************************************************/
/* leaf__pull_line_float */
/*****************************************************************************/
static void
leaf__pull_line_float(hplx_synthesis_stage_ref base, float *line_buf,
int width)
{
assert(base->use_floats); /* The only way to get floats is if the
decomposition is using floats, since the
input at the root level is fixed-point. */
base->dequant->pull_line_float(base->dequant,line_buf,base->component_idx,
base->level_idx,base->band_idx,width);
/* SAIC/Sharp/Fuji Xmask begin */
if (base->alpha != 0.0) apply_visual_unmask_float(base, line_buf, width);
/* SAIC/Sharp/Fuji Xmask end */
}
/*****************************************************************************/
/* STATIC leaf__terminate */
/*****************************************************************************/
static void
leaf__terminate(hplx_synthesis_stage_ref base)
{
hplx_synthesis_leaf_ref self = (hplx_synthesis_leaf_ref) base;
if (self->conversion_buf != NULL)
local_free(self->conversion_buf);
local_free(self);
}
/*****************************************************************************/
/* STATIC create_hplx_synthesis_leaf */
/*****************************************************************************/
static hplx_synthesis_stage_ref
create_hplx_synthesis_leaf(void)
{
hplx_synthesis_leaf_ref result;
result = (hplx_synthesis_leaf_ref)
local_malloc(XFORM_MEM_KEY,sizeof(hplx_synthesis_leaf_obj));
memset(result,0,sizeof(hplx_synthesis_leaf_obj));
result->base.initialize = leaf__initialize;
result->base.pull_line_fixed = leaf__pull_line_fixed;
result->base.pull_line_float = leaf__pull_line_float;
result->base.terminate = leaf__terminate;
return((hplx_synthesis_stage_ref) result);
}
/*****************************************************************************/
/* STATIC start_tile */
/*****************************************************************************/
static void
start_tile(hplx_synthesis_ref self)
{
int num_components = self->num_components;
stream_in_ref stream = self->stream;
reverse_info_ref info = self->info;
dequantizer_ref dequantizer = self->dequantizer;
canvas_dims dims;
frame_info frame;
hplx_synthesis_stage_ref root_stage;
int c, num_levels, reversible, sso_ext, use_floats;
/* SAIC/Sharp/Fuji Xmask begin */
float alpha = 0.0F, beta = 0.0F;
int minlevel = 1, win_width = 6;
int bits_retained = 9, respect_block_boundaries = 1;
/* SAIC/Sharp/Fuji Xmask end */
for (c=0; c < num_components; c++)
{
/* SAIC General Decomp. Begin */
int decomp_sequence[16];
int decomp_sequence_pos = 0;
/* SAIC General Decomp. End */
if ((root_stage = self->components[c]) != NULL)
{
/* SAIC/Sharp/Fuji Xmask begin */
if (self->alpha != 0.0) destroy_Xmask_prev_rows(root_stage);
/* SAIC/Sharp/Fuji Xmask end */
root_stage->terminate(root_stage);
self->components[c] = NULL;
}
num_levels = info->get_var_tile_info(info,c,NULL,NULL,&reversible,NULL,NULL);
if (num_levels < self->discard_levels)
local_error("The current codestream does not support sufficient "
"resolution scalability for the requested reduction "
"in resolution. At most %d resolution levels may "
"be discarded!",num_levels);
num_levels -= self->discard_levels;
info->get_level_info(info,c,num_levels,&dims,NULL,&frame,NULL);
use_floats = !reversible;
sso_ext = 0;
if (stream->size_marker_elt(stream,self->current_tnum,
MARKER_COC_SSOEXT,c))
sso_ext = stream->get_marker_val(stream,self->current_tnum,
MARKER_COC_SSOEXT,c,0);
/* SAIC/Sharp/Fuji Xmask begin */
self->alpha = alpha = 0.0F;
if (stream->size_marker_elt(stream,self->current_tnum,
MARKER_VMS_S,0)) {
unsigned char val;
val = stream->get_marker_val(stream,self->current_tnum,
MARKER_VMS_S,0,0);
respect_block_boundaries = (val & 0x80) >> 7;
minlevel = val & 0x1F;
}
if (stream->size_marker_elt(stream,self->current_tnum,
MARKER_VMS_W,0))
win_width = stream->get_marker_val(stream,self->current_tnum,
MARKER_VMS_W,0,0);
if (stream->size_marker_elt(stream,self->current_tnum,
MARKER_VMS_R,0))
bits_retained = stream->get_marker_val(stream,self->current_tnum,
MARKER_VMS_R,0,0);
if (stream->size_marker_elt(stream,self->current_tnum,
MARKER_VMS_A,0)) {
unsigned char alpha_quant =
stream->get_marker_val(stream,self->current_tnum,
MARKER_VMS_A,0,0);
self->alpha = alpha = alpha_quant/128.0F;
}
if (stream->size_marker_elt(stream,self->current_tnum,
MARKER_VMS_B,0)) {
unsigned char beta_quant =
stream->get_marker_val(stream,self->current_tnum,
MARKER_VMS_B,0,0);
beta = beta_quant/128.0F;
}
/* SAIC/Sharp/Fuji Xmask end */
self->components[c] = root_stage =
create_decomposition_tree(num_levels,c,info,dequantizer,
use_floats,0,0,self->usePsExtension,sso_ext,
/* OTLPF_CONVENTION begin; JX Wei ADFA, WJ Zeng Sharp */
self->otlpf_convention,
/* OTLPF_CONVENTION end; JX Wei ADFA, WJ Zeng Sharp */
/* SAIC/Sharp/Fuji Xmask begin mods */
self->decoder, alpha, beta,
minlevel, win_width, bits_retained,
respect_block_boundaries,
/* SAIC/Sharp/Fuji Xmask end mods */
0, 0, 0, 0,
decomp_sequence,
&decomp_sequence_pos,
0, 0);
root_stage->initialize(root_stage,info,&dims,&(frame.dims));
}
}
/* ========================================================================= */
/* ------------------ Implementation of Interface Functions ---------------- */
/* ========================================================================= */
/*****************************************************************************/
/* STATIC __initialize */
/*****************************************************************************/
static void
__initialize(synthesis_ref base, int discard_levels, int num_components,
reverse_info_ref info, dequantizer_ref dequantizer,
/* SAIC/Sharp/Fuji Xmask begin */
decoder_ref decoder,
/* SAIC/Sharp/Fuji Xmask end */
stream_in_ref stream, cmdl_ref cmdl)
{
hplx_synthesis_ref self = (hplx_synthesis_ref) base;
/* SAIC/Sharp/Fuji Xmask begin */
float alpha, beta;
int minlevel, win_width, bits_retained;
unsigned char respect_block_boundaries;
unsigned char *alpha_quant, *beta_quant;
unsigned char *usminlevel, *uswin_width, *usbits, *usrespect_block_boundaries;
int size;
/* SAIC/Sharp/Fuji Xmask end */
/* OTLPF_CONVENTION begin; JX Wei ADFA, WJ Zeng Sharp */
int p;
/* OTLPF_CONVENTION end; JX Wei ADFA, WJ Zeng Sharp */
self->info = info;
self->dequantizer = dequantizer;
self->stream = stream;
self->discard_levels = discard_levels;
self->num_components = num_components;
self->components = (hplx_synthesis_stage_ref *)
local_malloc(XFORM_MEM_KEY,
sizeof(hplx_synthesis_stage_ref)*num_components);
if (stream->get_main_cmetag(stream,CME_PSE,0,NULL) != NULL)
self->usePsExtension = 1;
/* OTLPF_CONVENTION begin; JX Wei ADFA, WJ Zeng Sharp */
self->otlpf_convention = (int) stream->get_main_cmetag(stream, 0xFD00, 0, &size);
/* OTLPF_CONVENTION end; JX Wei ADFA, WJ Zeng Sharp */
/* SAIC/Sharp/Fuji Xmask begin */
self->decoder = decoder;
/* SAIC/Sharp/Fuji Xmask end */
/* All the real initialization happens in the `start_tile' function. */
start_tile(self);
}
/*****************************************************************************/
/* STATIC __get_usage */
/*****************************************************************************/
static char **
__get_usage(synthesis_ref base)
{
/* SAIC General Decomp. Begin */
static char *args[] =
{"`-Xwt_output' <output wavelet PPM file> (default = none)",
"Specifies a file for outputing a viewable PPM file for the wavelet "
"transform used in encoding. Note that this argument can provide "
"significant utility in debugging encoder `-Fgen_decomp' strings. "
"Also note that this option does not currently work for tiled images.",
NULL};
/* SAIC General Decomp. End */
return(args);
}
/*****************************************************************************/
/* STATIC __pull_line */
/*****************************************************************************/
static void
__pull_line(synthesis_ref base, ifc_int *line_buf, int component_idx,
int width)
{
hplx_synthesis_ref self = (hplx_synthesis_ref) base;
hplx_synthesis_stage_ref stage;
assert(component_idx < self->num_components);
stage = self->components[component_idx];
stage->pull_line_fixed(stage,line_buf,width);
}
/*****************************************************************************/
/* STATIC __next_tile */
/*****************************************************************************/
static void
__next_tile(synthesis_ref base)
{
hplx_synthesis_ref self = (hplx_synthesis_ref) base;
self->current_tnum++;
start_tile(self);
self->dequantizer->next_tile(self->dequantizer);
}
/*****************************************************************************/
/* STATIC __terminate */
/*****************************************************************************/
static void
__terminate(synthesis_ref base)
{
hplx_synthesis_ref self = (hplx_synthesis_ref) base;
int c;
if (self->components != NULL)
{
for (c=0; c < self->num_components; c++)
{
/* SAIC/Sharp/Fuji Xmask begin */
if (self->alpha != 0.0) destroy_Xmask_prev_rows(self->components[c]);
/* SAIC/Sharp/Fuji Xmask end */
if (self->components[c] != NULL)
self->components[c]->terminate(self->components[c]);
}
local_free(self->components);
}
local_free(self);
}
/*****************************************************************************/
/* EXTERN create_hplx_synthesis */
/*****************************************************************************/
synthesis_ref
create_hplx_synthesis(void)
{
hplx_synthesis_ref result;
result = (hplx_synthesis_ref)
local_malloc(XFORM_MEM_KEY,sizeof(hplx_synthesis_obj));
result->base.initialize = __initialize;
result->base.get_usage = __get_usage;
result->base.pull_line = __pull_line;
result->base.next_tile = __next_tile;
result->base.terminate = __terminate;
return((synthesis_ref) result);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -