📄 params.cpp
字号:
{ if ((source->comp_idx >= 0) && (source->comp_idx < skip_components)) { source = source->next_comp; continue; } kdu_params *src = source; kdu_params *dst = target; bool all_insts = (src == src->first_inst) && (dst == dst->first_inst); do { if (src->inst_idx != dst->inst_idx) break; if (dst->marked) { kdu_error e; e << "Illegal attempt to modify a `kdu_params' " "object which has already been marked!"; } if (dst->empty) dst->copy_with_xforms(src,skip_components,discard_levels, transpose,vflip,hflip); if (!all_insts) break; src = src->next_inst; if (dst->next_inst == NULL) dst->new_instance(); dst = dst->next_inst; } while ((src != NULL) && (dst != NULL)); if (!all_comps) break; source = source->next_comp; target = target->next_comp; } source = source_ref; target = this; if ((source != source->first_cluster) || (target != target->first_cluster)) return; source = source->next_cluster; target = target->next_cluster; while ((source != NULL) && (target != NULL)) { target->copy_from(source,source_tile,target_tile,instance, skip_components,discard_levels,transpose,vflip,hflip); source = source->next_cluster; target = target->next_cluster; }}/*****************************************************************************//* kdu_params::access_cluster *//*****************************************************************************/kdu_params * kdu_params::access_cluster(const char *name){ kdu_params *scan; scan = this->first_inst->first_comp->first_tile->first_cluster; if (name == NULL) return(scan); while ((scan != NULL) && (strcmp(scan->cluster_name,name) != 0)) scan = scan->next_cluster; return(scan);}/*****************************************************************************//* kdu_params::access_cluster *//*****************************************************************************/kdu_params * kdu_params::access_cluster(int seq){ kdu_params *scan; scan = this->first_inst->first_comp->first_tile->first_cluster; while ((scan != NULL) && (seq > 0)) { scan = scan->next_cluster; seq--; } return(scan);}/*****************************************************************************//* kdu_params::access_relation *//*****************************************************************************/kdu_params * kdu_params::access_relation(int tile_idx, int comp_idx, int inst_idx){ kdu_params *scan; scan = this->first_inst->first_comp->first_tile; while ((scan != NULL) && (scan->tile_idx != tile_idx)) scan = scan->next_tile; while ((scan != NULL) && (scan->comp_idx != comp_idx)) scan = scan->next_comp; while ((scan != NULL) && (scan->inst_idx != inst_idx)) scan = scan->next_inst; return(scan);}/*****************************************************************************//* kdu_params::get (int) *//*****************************************************************************/bool kdu_params::get(const char *name, int record_idx, int field_idx, int &value, bool allow_inherit, bool allow_extend, bool allow_derived){ kd_attribute *ap; att_val *att_ptr; assert((record_idx >= 0) && (field_idx >= 0)); for (ap=attributes; ap != NULL; ap=ap->next) if (strcmp(name,ap->name) == 0) break; if (ap == NULL) { kdu_error e; e << "Attempt to access a code-stream attribute using " "the invalid name, \"" << name << "\"!"; } if (field_idx >= ap->num_fields) { kdu_error e; e << "Attempt to access a code-stream attribute, with " "an invalid field index!\n"; e << "The attribute name is \"" << name << "\".\n"; e << "The field index is " << field_idx << "."; } att_ptr = ap->values + field_idx; if (att_ptr->pattern[0] == 'F') { kdu_error e; e << "Attempting to access a floating point code-stream " "attribute field with the integer access method!\n"; e << "The attribute name is \"" << name << "\"."; } bool have_attribute = (ap->num_records > 0); if (ap->derived && !allow_derived) have_attribute = false; if ((!have_attribute) && allow_inherit && (inst_idx == 0)) { // Try inheritance. kdu_params *summary; summary = access_relation(tile_idx,-1); if ((summary != NULL) && (this != summary) && summary->get(name,record_idx,field_idx,value,false, allow_extend,allow_derived)) return true; summary = access_relation(-1,comp_idx); if ((summary != NULL) && (this != summary) && summary->get(name,record_idx,field_idx,value,true, allow_extend,allow_derived)) return true; } if (!have_attribute) return false; if ((ap->num_records <= record_idx) && allow_extend && (ap->flags & this->CAN_EXTRAPOLATE)) record_idx = ap->num_records - 1; att_ptr += ap->num_fields*record_idx; if ((record_idx < 0) || (record_idx >= ap->num_records) || !att_ptr->is_set) return false; value = att_ptr->ival; return true;}/*****************************************************************************//* kdu_params::get (bool) *//*****************************************************************************/bool kdu_params::get(const char *name, int record_idx, int field_idx, bool &value, bool allow_inherit, bool allow_extend, bool allow_derived){ kd_attribute *ap; att_val *att_ptr; assert((record_idx >= 0) && (field_idx >= 0)); for (ap=attributes; ap != NULL; ap=ap->next) if (strcmp(name,ap->name) == 0) break; if (ap == NULL) { kdu_error e; e << "Attempt to access a code-stream attribute using " "the invalid name, \"" << name << "\"!"; } if (field_idx >= ap->num_fields) { kdu_error e; e << "Attempt to access a code-stream attribute, with " "an invalid field index!\n"; e << "The attribute name is \"" << name << "\".\n"; e << "The field index is " << field_idx << "."; } att_ptr = ap->values + field_idx; if (att_ptr->pattern[0] != 'B') { kdu_error e; e << "Attempting to access a non-boolean code-stream " "attribute field with the boolean access method!\n"; e << "The attribute name is \"" << name << "\"."; } bool have_attribute = (ap->num_records > 0); if (ap->derived && !allow_derived) have_attribute = false; if ((!have_attribute) && allow_inherit && (inst_idx == 0)) { // Try inheritance. kdu_params *summary; summary = access_relation(tile_idx,-1); if ((summary != NULL) && (this != summary) && summary->get(name,record_idx,field_idx,value,false, allow_extend,allow_derived)) return true; summary = access_relation(-1,comp_idx); if ((summary != NULL) && (this != summary) && summary->get(name,record_idx,field_idx,value,true, allow_extend,allow_derived)) return true; } if (!have_attribute) return false; if ((ap->num_records <= record_idx) && allow_extend && (ap->flags & this->CAN_EXTRAPOLATE)) record_idx = ap->num_records - 1; att_ptr += ap->num_fields*record_idx; if ((record_idx < 0) || (record_idx >= ap->num_records) || !att_ptr->is_set) return false; value = (att_ptr->ival)?true:false; return true;}/*****************************************************************************//* kdu_params::get (float) *//*****************************************************************************/bool kdu_params::get(const char *name, int record_idx, int field_idx, float &value, bool allow_inherit, bool allow_extend, bool allow_derived){ kd_attribute *ap; att_val *att_ptr; assert((record_idx >= 0) && (field_idx >= 0)); for (ap=attributes; ap != NULL; ap=ap->next) if (strcmp(name,ap->name) == 0) break; if (ap == NULL) { kdu_error e; e << "Attempt to access a code-stream attribute using " "the invalid name, \"" << name << "\"!"; } if (field_idx >= ap->num_fields) { kdu_error e; e << "Attempt to access a code-stream attribute, with " "an invalid field index!\n"; e << "The attribute name is \"" << name << "\".\n"; e << "The field index is " << field_idx << "."; } att_ptr = ap->values + field_idx; if (att_ptr->pattern[0] != 'F') { kdu_error e; e << "Attempting to access an integer code-stream parameter " "attribute field with the floating point access method!\n"; e << "The attribute name is \"" << name << "\"."; } bool have_attribute = (ap->num_records > 0); if (ap->derived && !allow_derived) have_attribute = false; if ((!have_attribute) && allow_inherit && (inst_idx == 0)) { // Try inheritance. kdu_params *summary; summary = access_relation(tile_idx,-1); if ((summary != NULL) && (this != summary) && summary->get(name,record_idx,field_idx,value,false, allow_extend,allow_derived)) return true; summary = access_relation(-1,comp_idx); if ((summary != NULL) && (this != summary) && summary->get(name,record_idx,field_idx,value,true, allow_extend,allow_derived)) return true; } if (!have_attribute) return false; if ((ap->num_records <= record_idx) && allow_extend && (ap->flags & this->CAN_EXTRAPOLATE)) record_idx = ap->num_records - 1; att_ptr += ap->num_fields*record_idx; if ((record_idx < 0) || (record_idx >= ap->num_records) || !att_ptr->is_set) return false; value = att_ptr->fval; return true;}/*****************************************************************************//* kdu_params::set (int) *//*****************************************************************************/void kdu_params::set(const char *name, int record_idx, int field_idx, int value){ kd_attribute *ap; char const *cp; assert((record_idx >= 0) && (field_idx >= 0)); for (ap=attributes; ap != NULL; ap=ap->next) if (strcmp(name,ap->name) == 0) break; if (ap == NULL) { kdu_error e; e << "Attempt to set a code-stream attribute using " "the invalid name, \"" << name << "\"!"; } if ((ap->flags & ALL_COMPONENTS) && (comp_idx != -1)) { kdu_error e; e << "Attempt to set a non-tile-specific code-stream attribute " "in a specific component!\n"; e << "The attribute name is \"" << name << "\"."; } if (field_idx >= ap->num_fields) { kdu_error e; e << "Attempt to set a code-stream attribute, with an " "invalid field index!\n"; e << "The attribute name is \"" << name << "\".\n"; e << "The field index is " << field_idx << "."; } cp = ap->values[field_idx].pattern; if (*cp == 'F') { kdu_error e; e << "Attempting to set a floating point code-stream parameter " "attribute field with the integer access method!\n"; e << "The attribute name is \"" << name << "\"."; } else if (*cp == 'B') { if ((value & 1) != value) { kdu_error e; e << "Attempting to set a boolean code-stream parameter " "attribute field with an integer not equal to 0 or 1!\n"; e << "The attribute name is \"" << name << "\"."; } } else if (*cp == '(') { char buf[80]; int val; do { cp = parse_translator_entry(cp+1,',',buf,80,val); } while ((*cp == ',') && (val != value)); if (val != value) { kdu_error e; e << "Attempting to set a code-stream attribute " "field using an integer value which does not match any " "of the defined translation values for the field!\n"; e << "The attribute name is \"" << name << "\"."; } } else if (*cp == '[') { char buf[80]; int val, tmp=0; do { cp = parse_translator_entry(cp+1,'|',buf,80,val); if ((value & val) == val) tmp |= val; // Word contains this flag (or this set of flags). } while (*cp == '|'); if (tmp != value) { kdu_error e;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -