📄 component_demix.c
字号:
}
destroy_kernel(&(self->tile_kernel->third_d_kernel));
}
local_free(self->tile_kernel);
self->tile_kernel = NULL;
}
if ((self->colour_xform == MIXING_XFORM_WLT_INT) ||
(self->colour_xform == MIXING_XFORM_WLT_FLT)) {
for (b=0; b < 2; b++) {
if ((self->conv.branch_to_even+b)->taps != NULL) {
local_free((self->conv.branch_to_even+b)->taps -
(self->conv.branch_to_even+b)->neg_support);
(self->conv.branch_to_even+b)->taps = NULL;
}
if ((self->conv.branch_to_odd+b)->taps != NULL) {
local_free((self->conv.branch_to_odd+b)->taps -
(self->conv.branch_to_odd+b)->neg_support);
(self->conv.branch_to_odd+b)->taps = NULL;
}
}
if (self->conv.out_buf != NULL) {
local_free(self->conv.out_buf - self->conv.extend);
self->conv.out_buf = NULL;
}
if (self->conv.branch_bufs[0] != NULL) {
local_free(self->conv.branch_bufs[0] - self->conv.extend);
self->conv.branch_bufs[0] = NULL;
}
if (self->conv.branch_bufs[1] != NULL) {
local_free(self->conv.branch_bufs[1] - self->conv.extend);
self->conv.branch_bufs[1] = NULL;
}
self->tile_kernel = (component_tile_kernel_ptr)
local_malloc(MIXING_MEM_KEY, sizeof(component_tile_kernel));
self->tile_kernel->third_d_xform_flag = 1;
data = (char *)
stream->get_main_cmetag(stream,(std_ushort) self->next_xform_marker,
0, &size);
if (self->colour_xform == MIXING_XFORM_WLT_FLT) {
self->tile_kernel->third_d_kernel.kernel_type = INFO__CONVOLUTION;
if (data == NULL) {
id = self->tile_kernel->third_d_identifier = (char *)
local_malloc(MIXING_MEM_KEY,5*sizeof(char));
strcpy(id,"W9X7");
}
}
else {
self->tile_kernel->third_d_kernel.kernel_type = INFO__INT_LIFTING;
if (data == NULL) {
id = self->tile_kernel->third_d_identifier = (char *)
local_malloc(MIXING_MEM_KEY,5*sizeof(char));
strcpy(id,"W5X3");
}
}
if (data != NULL) {
int i, j, k = 1;
self->tile_kernel->third_d_kernel_user_defined = data[0];
if (self->tile_kernel->third_d_kernel_user_defined) {
user = (std_user_defined_ptr)
local_malloc(MIXING_MEM_KEY, sizeof(std_user_defined));
user->num_steps = data[k++];
for (i=0; i<user->num_steps; i++) {
user->step_supports[i] = data[k++];
user->downshifts[i] = data[k++];
}
for (i=0; i<user->num_steps; i++) {
for (j=0; j<user->step_supports[i]; j++) {
user->taps[i][j] = (data[k++] << 8);
user->taps[i][j] |= data[k++];
}
}
}
else {
id = self->tile_kernel->third_d_identifier = (char *)
local_malloc(MIXING_MEM_KEY, (size-1) * sizeof(char));
memcpy(id, data+1, size-1);
}
}
std_translate_kernel(self->tile_kernel->third_d_identifier,user,
&(self->tile_kernel->third_d_kernel));
self->kernel_type =
get_third_d_kernel_type(self->tile_kernel, INFO__SYNTHESIS,
branch_neg_supports, branch_pos_supports,
branch_neg_supports+1, branch_pos_supports+1);
if(self->kernel_type == INFO__CONVOLUTION)
{
get_third_d_convolution_taps(self->tile_kernel,branch_taps,
branch_taps+1);
self->conv.even_taps =
((branch_neg_supports[0] + branch_pos_supports[0]) & 1);
for (self->conv.extend=0, b=0; b < 2; b++)
{
create_polyphase_kernel(self->conv.branch_to_even+b,b,0,
branch_neg_supports[b],branch_pos_supports[b],
branch_taps[b]);
create_polyphase_kernel(self->conv.branch_to_odd+b,b,1,
branch_neg_supports[b],branch_pos_supports[b],
branch_taps[b]);
if (self->conv.branch_to_even[b].neg_support > self->conv.extend)
self->conv.extend = self->conv.branch_to_even[b].neg_support;
if (self->conv.branch_to_even[b].pos_support > self->conv.extend)
self->conv.extend = self->conv.branch_to_even[b].pos_support;
if (self->conv.branch_to_odd[b].neg_support > self->conv.extend)
self->conv.extend = self->conv.branch_to_odd[b].neg_support;
if (self->conv.branch_to_odd[b].pos_support > self->conv.extend)
self->conv.extend = self->conv.branch_to_odd[b].pos_support;
}
self->conv.extend++;
self->conv.out_buf = local_malloc(MIXING_MEM_KEY,
(self->num_components+(2*self->conv.extend))*sizeof(float));
self->conv.out_buf += self->conv.extend;
self->conv.branch_bufs[0] = local_malloc(MIXING_MEM_KEY,
(self->num_components+(2*self->conv.extend))*sizeof(float));
self->conv.branch_bufs[0] += self->conv.extend;
self->conv.branch_bufs[1] = local_malloc(MIXING_MEM_KEY,
(self->num_components+(2*self->conv.extend))*sizeof(float));
self->conv.branch_bufs[1] += self->conv.extend;
}
else if(self->kernel_type == INFO__INT_LIFTING)
{
self->lift.num_steps =
get_third_d_int_steps(self->tile_kernel,self->lift.neg_supports,
self->lift.pos_supports,self->lift.int_taps,
self->lift.int_downshifts);
for (n=0; n < self->lift.num_steps; n++)
{
if (self->lift.neg_supports[n] > self->lift.neg_extend)
self->lift.neg_extend = self->lift.neg_supports[n];
if (self->lift.pos_supports[n] > self->lift.pos_extend)
self->lift.pos_extend = self->lift.pos_supports[n];
}
for (b=0; b < 2; b++)
{
if (self->lift.branch_buf_int[b] != NULL)
local_free(self->lift.branch_buf_int[b]-self->lift.neg_extend);
self->lift.branch_buf_int[b] = (ifc_int *)
local_malloc(MIXING_MEM_KEY,sizeof(ifc_int)*
(self->num_components+self->lift.neg_extend
+self->lift.pos_extend+1));
self->lift.branch_buf_int[b] += self->lift.neg_extend;
}
self->lift.first_idx = 0;
}
if (user != NULL)
local_free(user);
/* LANL begin */
#ifdef LANL_CMPNT_WVLT
if (self->colour_xform == MIXING_XFORM_WLT_INT) {
if (self->intX)
local_free(self->intX);
if (self->intY)
local_free(self->intY);
self->intX = local_malloc(MIXING_MEM_KEY,
(self->num_components)*sizeof(int));
self->intY = local_malloc(MIXING_MEM_KEY,
(self->num_components)*sizeof(int));
} else {
if (self->floatX)
local_free(self->floatX);
if (self->floatY)
local_free(self->floatY);
self->floatX = local_malloc(MIXING_MEM_KEY,
(self->num_components)*sizeof(float));
self->floatY = local_malloc(MIXING_MEM_KEY,
(self->num_components)*sizeof(float));
}
if (reversible==INFO__REVERSIBLE)
fltbankrev_init_from_std_lifting_info(&self->fltbankrev,
&(self->tile_kernel->
third_d_kernel.
lifting));
else
fltbankirr_init_from_std_lifting_info(&self->fltbankirr,
&(self->tile_kernel->
third_d_kernel.
lifting));
#endif
/* LANL end */
}
/*UofA End */
self->next_xform_marker--;
}
/* ========================================================================= */
/* ------------------------- Interface Implementation ---------------------- */
/* ========================================================================= */
/*****************************************************************************/
/* STATIC __initialize */
/*****************************************************************************/
static void
__initialize(component_demix_ref base, int discard_levels,
int orig_components, int reconstructed_components,
reverse_info_ref info, synthesis_ref synthesis,
stream_in_ref stream, cmdl_ref cmdl)
{
the_component_demix_ref self = (the_component_demix_ref) base;
/* OTLPF_CONVENTION begin; JX Wei ADFA, WJ Zeng Sharp */
int size;
/* OTLPF_CONVENTION end; JX Wei ADFA, WJ Zeng Sharp */
/* OTLPF_CONVENTION begin; JX Wei ADFA, WJ Zeng Sharp */
int p;
/* OTLPF_CONVENTION end; JX Wei ADFA, WJ Zeng Sharp */
self->synthesis = synthesis;
self->info = info;
self->num_components = reconstructed_components;
self->orig_components = orig_components;
self->stream = stream;
self->components = (mixing_component_info_ptr)
local_malloc(MIXING_MEM_KEY,
sizeof(mixing_component_info)*reconstructed_components);
self->discard_levels = discard_levels;
/* Kodak/SAIC Linear Transform Begin */
self->next_xform_marker = 0xFEF3;
/* Kodak/SAIC Linear Transform End */
/* 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 */
/* LANL begin */
#ifdef LANL_CMPNT_WVLT
self->intX = 0;
self->intY = 0;
self->floatX = 0;
self->floatY = 0;
#endif
/* LANL end */
/* LANL Begin */
#if defined(LANL_CMPNT_WVLT)
{
char *lext = 0, *hext = 0, **params;
int p;
if ((p = cmdl->extract(cmdl,"-Mext",-1,¶ms)) >= 0) {
if (p == 1) {
lext = params[0];
hext = params[0];
} else if (p == 2) {
lext = params[0];
hext = params[1];
} else
local_error("Must specify 1 or 2 extensions with -Mlext flag");
OverrideExtensionPolicy = 1;
EvenUpdateExtension = string_to_stdext(hext);
OddUpdateExtension = string_to_stdext(lext);
}
}
#endif
/* LANL End */
/* Begin Aerospace MCT mods (TSW) */
/* As of now, all tile collections and transform matrix information is
formed for each tile. The cost is negligible, since all the data is
pointed to rather than copied from a marker segment. Also, the
instantiation scheme for the pre-markers allows a tile header value
to override a main value. Thus, nothing needs to be initialized here
for multiple component transforms.
Right now there will be a main
COD marker indicating that the linear mixing has been used. This
will need to be changed in the future.*/
/* End Aerospace MCT mods (TSW) */
start_tile(self);
}
/*****************************************************************************/
/* STATIC __get_usage */
/*****************************************************************************/
static char **
__get_usage(component_demix_ref base)
{
#if defined(LANL_CMPNT_WVLT)
static char *args[] =
{"-Mext [extension] [extension]",
"Flag specifying extension policy for non-WS filter banks. Extensions"
" specified may be one of Z00 (zero extension), C00 (constant "
"extension), or be of the form Cxy, where C is S or A (symmetric "
"or anti-symmetric), and x and y may each take on the value 1 or 2, "
"determining the type of symmetric extension (W or H) at the left "
"and right boundaries respectively. If one extension string is "
"specified, it is applied to all steps; if two are specified, the "
"first is applied in extension to the even channel, and the second "
"is applied to extensions of the odd channel.",
NULL};
return (args);
#else
/* LANL End */
return(NULL);
#endif
}
/*****************************************************************************/
/* STATIC __next_tile */
/*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -