30 |
|
|
31 |
/* allocates a Pattern */ |
/* allocates a Pattern */ |
32 |
|
|
33 |
Paso_Pattern* Paso_Pattern_alloc(int type, dim_t input_block_size, dim_t output_block_size, dim_t numOutput, index_t* ptr, index_t* index) { |
Paso_Pattern* Paso_Pattern_alloc(int type, dim_t input_block_size, dim_t output_block_size, dim_t numOutput, dim_t numInput, index_t* ptr, index_t* index) { |
34 |
Paso_Pattern*out=NULL; |
Paso_Pattern*out=NULL; |
35 |
index_t index_offset=(type & PATTERN_FORMAT_OFFSET1 ? 1:0); |
index_t index_offset=(type & PATTERN_FORMAT_OFFSET1 ? 1:0); |
36 |
index_t loc_min_index,loc_max_index,min_index=index_offset,max_index=index_offset-1; |
index_t loc_min_index,loc_max_index,min_index=index_offset,max_index=index_offset-1; |
79 |
max_index=MAX(loc_max_index,max_index); |
max_index=MAX(loc_max_index,max_index); |
80 |
} |
} |
81 |
} |
} |
82 |
if (min_index<index_offset) { |
if ( (min_index<index_offset) || (max_index>=numInput+index_offset) ) { |
83 |
Paso_setError(TYPE_ERROR,"Paso_Pattern_alloc: lower Pattern index out of range."); |
Paso_setError(TYPE_ERROR,"Paso_Pattern_alloc: Pattern index out of range."); |
84 |
return NULL; |
return NULL; |
85 |
} |
} |
86 |
} |
} |
89 |
out->type=type; |
out->type=type; |
90 |
out->reference_counter=1; |
out->reference_counter=1; |
91 |
out->numOutput=numOutput; |
out->numOutput=numOutput; |
92 |
|
out->numInput=numInput; |
93 |
out->ptr=ptr; |
out->ptr=ptr; |
94 |
out->index=index; |
out->index=index; |
95 |
out->input_block_size=input_block_size; |
out->input_block_size=input_block_size; |
97 |
out->block_size=out->input_block_size * out->output_block_size; |
out->block_size=out->input_block_size * out->output_block_size; |
98 |
if (out->ptr == NULL) { |
if (out->ptr == NULL) { |
99 |
out->len=0; |
out->len=0; |
|
out->numInput=0; |
|
100 |
} else { |
} else { |
101 |
out->len=out->ptr[out->numOutput] - index_offset; |
out->len=out->ptr[out->numOutput] - index_offset; |
|
out->numInput=max_index+1-index_offset; |
|
102 |
} |
} |
103 |
} |
} |
104 |
#ifdef Paso_TRACE |
#ifdef Paso_TRACE |