📄 component_demix.c
字号:
MARKER_MIC_TMCO,instance,i);
if ( sptr.off_vector > maxoff )
maxoff = sptr.off_vector;
cptr->intermed_segment[i] = sptr;
}
self->tile_collection = cptr;
/* set up the dependency matrices now */
tptr->n_depend_xfm = maxmat;
tptr->n_depend_off = maxoff;
tptr->depend_xfms = (matrix_data_ref) local_malloc(MIXING_MEM_KEY,
sizeof(matrix_data)*(maxmat+1));
for(i=0;i<=maxmat;i++)
tptr->depend_xfms[i].matrix_values = NULL;
tptr->depend_offs = (vector_data_ref) local_malloc(MIXING_MEM_KEY,
sizeof(vector_data)*(maxoff+1));
for(i=0;i<=maxoff;i++)
tptr->depend_offs[i].vector_values = NULL;
for(i=0;i<nseg;i++){
ixnum = cptr->intermed_segment[i].xfm_matrix;
if((ixnum>0)&&(tptr->depend_xfms[ixnum].matrix_values==NULL)){
nin = cptr->intermed_segment[i].n_input_components;
nout = cptr->intermed_segment[i].n_output_components;
mptr.matrix_values = (float **)local_malloc(MIXING_MEM_KEY,
nout*sizeof(float *));
/* Original tile number is used to access matrices, since this
ensures that if a MCT with proper index is present in the
tile part header, it will override the one in main. */
memptr = (float *) stream->get_marker_val_indirect(stream,tix,
MARKER_MCT_SP,ixnum+16);
for(j=0;j<nout;j++)
mptr.matrix_values[j]= memptr+nin*j;
tptr->depend_xfms[ixnum]=mptr;
}
ixnum = cptr->intermed_segment[i].off_vector;
if((ixnum>0)&&(tptr->depend_offs[ixnum].vector_values==NULL)){
vptr.vector_values = (float *) stream->get_marker_val_indirect(stream,
tix,MARKER_MCT_SP,ixnum+48);
tptr->depend_offs[ixnum]=vptr;
}
}
self->transforms = tptr;
}
/*****************************************************************************/
/* STATIC find_number_of_codestream_components */
/*****************************************************************************/
static void find_number_of_codestream_components(collection_ref col)
{
int i,j,max_c_number=-1;
for(i=0;i<col->n_intermed_segments;i++)
for(j=0;j<col->intermed_segment[i].n_output_components;j++)
if(col->intermed_segment[i].output_components[j]>max_c_number)
max_c_number = col->intermed_segment[i].output_components[j];
for(i=0;i<col->n_comp_segments;i++)
for(j=0;j<col->comp_segment[i].n_output_components;j++)
if(col->comp_segment[i].output_components[j]>max_c_number)
max_c_number = col->comp_segment[i].output_components[j];
col->n_codestream_components = max_c_number+1;
}
/*****************************************************************************/
/* STATIC set_dimensions_reference */
/*****************************************************************************/
static void set_dimensions_reference(the_component_demix_ref self)
{
int i,max_c_number = -1;
/* The remainder of this routine needs to get filled in later. For now,
it is hardwired to point to certain places for testing */
for ( i = 0; i < self->num_components; i++ )
self->dims_reference[i] = 0;
/* for ( i = 0; i < col->n_intermed_segments; i++ )
for( j = 0; j < col->intermed_segment[i].n_output_components; j++ )
if (col->intermed_segment[i].output_components[j] > max_c_number)
max_c_number = col->intermed_segment[i].output_components[j];
for ( i = 0; i < col->n_comp_segments; i++ )
for( j = 0; j < col->comp_segment[i].n_output_components; j++ )
if (col->comp_segment[i].output_components[j] > max_c_number)
max_c_number = col->comp_segment[i].output_components[j];
col->n_codestream_components = max_c_number+1;*/
}
/* End Aerospace MCT mods (TSW) */
/*****************************************************************************/
/* STATIC destroy_buffers */
/*****************************************************************************/
static void
destroy_buffers(mixing_component_info_ptr comp)
{
mixing_row_buffer_ptr buf;
while ((buf = comp->head) != NULL){
comp->head = buf->next;
local_free(buf);
}
comp->tail = NULL;
comp->num_buffered_rows = 0;
}
/*****************************************************************************/
/* STATIC start_tile */
/*****************************************************************************/
static void
start_tile(the_component_demix_ref self)
{
int tnum = self->current_tile_idx;
stream_in_ref stream = self->stream;
int c, ax, bx, reversible;
canvas_dims dims, last_dims;
mixing_component_info_ptr comp;
/* UofA Begin */
std_user_defined_ptr user = NULL;
int b, n;
int branch_neg_supports[2], branch_pos_supports[2];
float *branch_taps[2];
char *id = NULL;
/* UofA End */
/* Kodak/SAIC Linear Transform Begin */
int size;
char *data;
/* Kodak/SAIC Linear Transform End */
/* OTLPF_CONVENTION begin; JX Wei ADFA, WJ Zeng Sharp */
int xnum, twidth, factor, hor_offset, hor_subsampling;
/* OTLPF_CONVENTION end; JX Wei ADFA, WJ Zeng Sharp */
self->colour_xform = (int)
stream->get_marker_val(stream,tnum,MARKER_COD_CXFORM,0,0);
assert(self->colour_xform <= MIXING_XFORM_LIN);
if (((self->colour_xform == MIXING_XFORM__RCT) ||
(self->colour_xform == MIXING_XFORM__YCbCr)) &&
(self->orig_components < 3))
local_error("The codestream is marked as having a colour transform in "
"one or more tiles, but contains less than 3 image "
"components!");
if (((self->colour_xform == MIXING_XFORM__RCT) ||
(self->colour_xform == MIXING_XFORM__YCbCr)) &&
(self->num_components < 3))
{
if (self->num_components == 1)
self->colour_xform = 0;
else
local_error("Attempting to reconstruct only %d components "
"of a colour image which has been "
"subjected to a colour transform in one or more "
"tiles!! Only full colour or monochrome reconstruction "
"makes any sense!",self->num_components);
}
/* UofA Begin */
if (((self->colour_xform == MIXING_XFORM_WLT_INT) ||
(self->colour_xform == MIXING_XFORM_WLT_FLT)) &&
(self->num_components == 1)) {
local_error("Wavelet compoment mixing requires more than one component!");
}
/* UofA End */
/* Kodak/SAIC Linear Transform Begin */
if ((self->colour_xform == MIXING_XFORM_LIN) &&
(self->num_components == 1)) {
local_error("Linear compoment mixing requires more than one component!");
}
/* Kodak/SAIC Linear Transform End */
/* Begin Aerospace MCT mods (TSW) */
/* for (c=0; c < self->num_components; c++)*/
for (c=0; c < self->orig_components; c++)
/* End Aerospace MCT mods */
{
comp = self->components + c;
assert(comp->num_buffered_rows == 0);
self->info->get_var_tile_info(self->info,c,NULL,&dims,&reversible,NULL,NULL);
if ((self->colour_xform == MIXING_XFORM__RCT) &&
(reversible != INFO__REVERSIBLE) && (c < 3))
local_error("When using the RCT colour transform, the first 3 "
"image components must have reversible decompositions "
"in every tile!");
if ((self->colour_xform == MIXING_XFORM__YCbCr) &&
(reversible != INFO__IRREVERSIBLE) && (c < 3))
local_error("When using the YCbCr colour transform, the first 3 "
"image components must have non-reversible decompositions "
"in every tile!");
/* UofA Begin */
if ((self->colour_xform == MIXING_XFORM_WLT_FLT) &&
(reversible == INFO__REVERSIBLE))
local_error("Fully reversible compression is not possible with "
"floating point wavelet component mixing!");
/* UofA End */
/* Begin Aerospace MCT mods (TSW) */
/* There is no real reason to disallow reversible transforms with
the MCT. There will be rounding loss associated with the forward
and inverse MCTs, but the samples passed to the wavelet coder
will be reversible. */
/* Kodak/SAIC Linear Transform Begin */
/* if ((self->colour_xform == MIXING_XFORM_LIN) &&
(reversible == INFO__REVERSIBLE))
local_error("Fully reversible compression is not possible with "
"floating point linear component mixing!");*/
/* Kodak/SAIC Linear Transform End */
/* End Aerospace MCT mods (TSW) */
if (((self->colour_xform == MIXING_XFORM__RCT) ||
(self->colour_xform == MIXING_XFORM__YCbCr)) &&
(c < 3))
{
if (c == 0)
last_dims = dims;
else if ((dims.rows != last_dims.rows) ||
(dims.cols != last_dims.cols) ||
(dims.top_row != last_dims.top_row) ||
(dims.left_col != last_dims.left_col))
local_error("Colour transforms may not be used with image "
"components of different dimensions!");
}
/* UofA Begin */
else if ((self->colour_xform == MIXING_XFORM_WLT_INT) ||
(self->colour_xform == MIXING_XFORM_WLT_FLT))
{
if (c == 0)
last_dims = dims;
else if ((dims.rows != last_dims.rows) ||
(dims.cols != last_dims.cols) ||
(dims.top_row != last_dims.top_row) ||
(dims.left_col != last_dims.left_col))
local_error("Wavelet component transforms may not be used with "
"image components of different dimensions!");
}
/* UofA End */
/* Kodak/SAIC Linear Transform Begin */
else if (self->colour_xform == MIXING_XFORM_LIN)
{
if (c == 0)
last_dims = dims;
else if ((dims.rows != last_dims.rows) ||
(dims.cols != last_dims.cols) ||
(dims.top_row != last_dims.top_row) ||
(dims.left_col != last_dims.left_col))
local_error("Linear component transforms may not be used with "
"image components of different dimensions!");
}
/* Kodak/SAIC Linear Transform End */
ax = dims.left_col; bx = ax + dims.cols;
/* OTLPF_CONVENTION begin; JX Wei ADFA, WJ Zeng Sharp */
if(self->otlpf_convention) {
self->info->get_fixed_tile_info(self->info, c,
0, &xnum, NULL, NULL,
&hor_subsampling, NULL,
&hor_offset, NULL, NULL, NULL,NULL);
factor = 1 << self -> discard_levels;
twidth = (bx - ax + factor -1)/factor;
ax = self->info->new_otlpf_sub_band(0, ax, factor, xnum, hor_offset, hor_subsampling);
bx = ax + twidth;
}
else {
ax = 1 + ((ax-1)>>self->discard_levels);
bx = 1 + ((bx-1)>>self->discard_levels);
}
/* OTLPF_CONVENTION end; JX Wei ADFA, WJ Zeng Sharp */
dims.cols = bx - ax;
if (dims.cols > comp->tile_cols)
destroy_buffers(comp);
comp->tile_cols = dims.cols;
}
/* Kodak/SAIC Linear Transform Begin */
if (self->T_rev != NULL) {
local_free(self->T_rev[0]);
local_free(self->T_rev);
self->T_rev = NULL;
}
if (self->colour_xform == MIXING_XFORM_LIN) {
/* Begin Aerospace MCT mods (TSW) */
fill_collection_and_matrix(self);
if ( self->dims_reference == NULL ) {
self->dims_reference = (int *) local_malloc(MIXING_MEM_KEY,
self->num_components*sizeof(int));
set_dimensions_reference(self);
}
/* find_number_of_codestream_components(self->tile_collection);*/
/* EKC mct end mods */
}
else
if ( self->dims_reference == NULL ) {
self->dims_reference = (int *) local_malloc(MIXING_MEM_KEY,
self->num_components*sizeof(int));
for( c=0; c<self->num_components; c++ )
self->dims_reference[c] = c;
}
/* End Aerospace MCT mods */
/* Kodak/SAIC Linear Transform End */
/*UofA Begin */
if (self->tile_kernel != NULL) {
if (self->tile_kernel->third_d_xform_flag) {
if (self->tile_kernel->third_d_identifier != NULL) {
local_free(self->tile_kernel->third_d_identifier);
self->tile_kernel->third_d_identifier = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -