⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 params.cpp

📁 该源码是JPEG2000的c++源代码,希望对研究JPEG2000标准以及编解码的朋友们有用.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                          break;                        success = (*bp == '\0') &&                          ((*dp==',')||(*dp=='}')||(*dp=='|')||(*dp=='\0'));                    } while ((*pp == '|') && !success);                  if ((!success) && (*cp == '0') &&                      ((cp[1]==',') || (cp[1]=='}') ||                       (cp[1]=='|') || (cp[1]=='\0')))                    {                      success = true;                      val = 0;                      dp = cp+1;                    }                  if (!success)                    { kdu_error e;                      e << "Malformed attribute string, \"" << string                        << "\"!\n"; e << "Problem encountered at \"" << cp                        << "\".\n";                      display_options(att->pattern,e);                    }                  att->ival |= val;                  cp = dp;                } while (*cp == '|');            }          else            assert(0);          att->is_set = true;        }      if (*cp == '}')        cp++;      else if (open_record)        { kdu_error e;          e << "Malformed attribute string, \"" << string << "\"!\n";          e << "Problem encountered at \"" << cp << "\".\n";          e << "Opening brace for record is not matched by a closing brace.";        }      rec++;    }  this->empty = false;  return true;}/*****************************************************************************//*                          kdu_params::parse_string                         *//*****************************************************************************/bool  kdu_params::parse_string(char *string, int which_tile){  int target_tile = -1;  char *delim = strchr(string,':');  if (delim != NULL)    {      delim++;      while ((*delim != 'T') && (*delim != '=') && (*delim != '\0'))        delim++;      if (*delim == 'T')        target_tile = (int) strtol(delim+1,NULL,10);    }  if (target_tile != which_tile)    return false;  return parse_string(string);}/*****************************************************************************//*                kdu_params::textualize_attributes  (one only)              *//*****************************************************************************/void  kdu_params::textualize_attributes(ostream &stream, bool skip_derived){  kd_attribute *ap;  int rec, fld;  for (ap=attributes; ap != NULL; ap=ap->next)    {      if (ap->num_records == 0)        continue;      if (ap->derived && skip_derived)        continue;      stream << ap->name;      if ((comp_idx >= 0) || (tile_idx >= 0))        { // Write the location specifier.          stream << ':';          if (tile_idx >= 0)            stream << "T" << tile_idx;          if (comp_idx >= 0)            stream << "C" << comp_idx;        }      stream << '=';      for (rec=0; rec < ap->num_records; rec++)        {          if (rec > 0)            stream << ',';          if (ap->num_fields > 1)            stream << '{';          for (fld=0; fld < ap->num_fields; fld++)            {              att_val *att = ap->values + rec*ap->num_fields + fld;              char const *cp;                              if (fld > 0)                stream << ',';              if (!att->is_set)                { kdu_error e;                  e << "Attempting to textualize a code-stream parameter "                    "attribute, which has only partially been set!\n";                  e << "Error occurred in attribute \"" << ap->name << "\" "                    " in field " << fld << " of record " << rec << ".";                }              cp = att->pattern;              if (*cp == 'F')                stream << att->fval;              else if (*cp == 'I')                stream << att->ival;              else if (*cp == 'B')                stream << ((att->ival)?"yes":"no");              else if (*cp == '(')                {                  char buf[80];                  int val;                                    do {                      cp = parse_translator_entry(cp+1,',',buf,80,val);                      if (val == att->ival)                        break;                    } while (*cp == ',');                  assert(val == att->ival);                  stream << buf;                }              else if (*cp == '[')                {                  char buf[80];                  int val, acc=0;                                    if (att->ival == 0)                    stream << 0;                  do {                      cp = parse_translator_entry(cp+1,'|',buf,80,val);                      if (((att->ival & val) == val) && ((acc | val) > acc))                        {                          stream << buf;                          acc |= val;                          if (acc == att->ival)                            break;                          stream << ',';                        }                    } while (*cp == '|');                  assert(acc == att->ival);                }              else                assert(0);            }          if (ap->num_fields > 1)            stream << '}';        }      stream << '\n';    }}/*****************************************************************************//*            kdu_params::textualize_attributes  (list processing)           *//*****************************************************************************/void  kdu_params::textualize_attributes(ostream &stream, int min_tile, int max_tile,                                   bool skip_derived){  kdu_params *scan;  if ((tile_idx >= min_tile) && (tile_idx <= max_tile))    {      this->textualize_attributes(stream,skip_derived);      if (this == first_inst)        for (scan=this->next_inst; scan != NULL; scan=scan->next_inst)          scan->textualize_attributes(stream,skip_derived);      if (this == first_comp)        for (scan=this->next_comp; scan != NULL; scan=scan->next_comp)          scan->textualize_attributes(stream,min_tile,max_tile,skip_derived);    }  if (this == first_tile)    for (scan=this->next_tile; scan != NULL; scan=scan->next_tile)      scan->textualize_attributes(stream,min_tile,max_tile,skip_derived);  if (this == first_cluster)    for (scan=this->next_cluster; scan != NULL; scan=scan->next_cluster)      scan->textualize_attributes(stream,min_tile,max_tile,skip_derived);}/*****************************************************************************//*                        kdu_params::describe_strings                       *//*****************************************************************************/void  kdu_params::describe_strings(ostream &stream, bool include_comments){  kd_attribute *ap;  for (ap=attributes; ap != NULL; ap=ap->next)    ap->describe(stream,allow_tiles,allow_comps,include_comments);}/*****************************************************************************//*                        kdu_params::describe_string                        *//*****************************************************************************/void  kdu_params::describe_string(const char *name,                             ostream &stream, bool include_comments){  kd_attribute *ap;  for (ap=attributes; ap != NULL; ap=ap->next)    if (strcmp(ap->name,name) == 0)      break;  if (ap == NULL)    { kdu_error e; e << "\"kdu_params::describe_string\" invoked with an "      "invalid attribute identifier, \"" << name << "\"."; }  ap->describe(stream,allow_tiles,allow_comps,include_comments);}/*****************************************************************************//*                          kdu_params::find_string                          *//*****************************************************************************/kdu_params *  kdu_params::find_string(char *string, const char * &name){  kd_attribute *ap;  char *delim;  size_t name_len;  for (delim=string; *delim != '\0'; delim++)    if ((*delim == ' ') || (*delim == '\t') || (*delim == '\n'))      return NULL;    else if ((*delim == ':') || (*delim == '='))      break;  name_len = (size_t)(delim - string);  for (ap=attributes; ap != NULL; ap=ap->next)    if ((strncmp(ap->name,string,name_len)==0) && (strlen(ap->name)==name_len))      break;  if (ap == NULL)    {      if (this == first_cluster)        {          kdu_params *scan, *result;          for (scan=this->next_cluster; scan != NULL; scan=scan->next_cluster)            if ((result = scan->find_string(string,name)) != NULL)              return(result);        }      return NULL;    }  assert(ap != NULL);  name = ap->name;  if (*delim == '\0')    return this;  int target_tile = -2;  int target_comp = -2;  if (*delim == ':')    {      delim++;      while (*delim != '=')        if (*delim == '\0')          break;        else if ((*delim == 'T') && (target_tile < 0))          target_tile = (int) strtol(delim+1,&delim,10);        else if ((*delim == 'C') && (target_comp < 0))          target_comp = (int) strtol(delim+1,&delim,10);        else          return this;    }  if (target_tile < -1)    target_tile = this->tile_idx;  if (target_comp < -1)    target_comp = this->comp_idx;  // Locate the object to which the attribute belongs.  if ((this->tile_idx != target_tile) || (this->comp_idx != target_comp))    {      kdu_params *target;      target = access_relation(target_tile,target_comp);      if (target == NULL)        return this;      return target->find_string(string,name);    }  return this;}/*****************************************************************************//*                  kdu_params::delete_unparsed_attribute                    *//*****************************************************************************/void  kdu_params::delete_unparsed_attribute(const char *name){  kd_attribute *ap;  for (ap=attributes; ap != NULL; ap=ap->next)    if (strcmp(ap->name,name) == 0)      break;  if (ap == NULL)    { kdu_error e; e << "Attempting to delete a non-existent attribute with "      "\"kdu_params::delete_unparsed_attribute\"."; }  if (!ap->parsed)    {      int num_fields = ap->num_records * ap->num_fields;      for (int n=0; n < num_fields; n++)        ap->values[n].is_set = false;      ap->num_records = 0;    }  kdu_params *scan;  if (this == first_inst)    for (scan=next_inst; scan != NULL; scan=scan->next_inst)      scan->delete_unparsed_attribute(name);  if (this == first_comp)    for (scan=next_comp; scan != NULL; scan=scan->next_comp)      scan->delete_unparsed_attribute(name);  if (this == first_tile)    for (scan=next_tile; scan != NULL; scan=scan->next_tile)      scan->delete_unparsed_attribute(name);}/*****************************************************************************//*                    kdu_params::translate_marker_segment                   *//*****************************************************************************/bool  kdu_params::translate_marker_segment(kdu_uint16 code, int num_bytes,                                      kdu_byte bytes[], int which_tile,                                      int tpart_idx){  kdu_params *cluster, *tile, *comp, *inst;  cluster = this->first_inst->first_comp->first_tile->first_cluster;  for (; cluster != NULL; cluster = cluster->next_cluster)    {      for (tile=cluster; tile != NULL; tile=tile->next_tile)        if (tile->tile_idx == which_tile)          break;      if (tile == NULL)        continue;      for (comp=tile; comp != NULL; comp=comp->next_comp)        {          for (inst=comp; inst != NULL; inst=inst->next_inst)            if (!inst->marked)              break;          if (inst == NULL)            continue;          if (inst->read_marker_segment(code,num_bytes,bytes,tpart_idx))            {              inst->marked = true;              if (inst->allow_insts)                inst->new_instance();              inst->empty = false;              return true;            }        }    }  return false;}/*****************************************************************************//*                    kdu_params::generate_marker_segments                   *//*****************************************************************************/int  kdu_params::generate_marker_segments(kdu_output *out, int which_tile,                                      int tpart_idx

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -