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

📄 ebcot_decoder.c

📁 关于视频压缩的jpeg2000压缩算法,C编写
💻 C
📖 第 1 页 / 共 5 页
字号:
  ebcot_packet_info_ptr packet;  canvas_dims dims;  int new_packets;  int n, c, p;  int x_inc, y_inc, inc, x0, x1, y0, y1, x, y;  /* Reset `next_packet_idx' fields. */  for (c=0; c < tile->num_components; c++)    {      comp_info = tile->components + c;      for (n=0; n <= comp_info->num_levels; n++)        {          lev = comp_info->levels +n;          lev->next_packet_idx = 0;        }    }  new_packets = 0;  for (n=0; n < max_levels; n++)    {      /* Determine spatial progression parameters. */      x_inc = y_inc = 0;      for (c=0; c < max_components; c++)        {          comp_info = tile->components + c;          if (n > comp_info->num_levels)            continue;          lev = comp_info->levels + n;          if ((!is_power_of_2(comp_info->hor_subsampling)) ||              (!is_power_of_2(comp_info->vert_subsampling)))            local_error("Cannot use packet progressions where spatial "                        "progression dominates component progression unless "                        "component sub-sampling factors are exact "                        "powers of 2!");          if (lev->ppx >= 0)            {              inc = comp_info->hor_subsampling;              inc <<= lev->ppx + comp_info->num_levels - n;              if ((x_inc == 0) || (inc < x_inc))                x_inc = inc;            }          if (lev->ppy >= 0)            {              inc = comp_info->vert_subsampling;              inc <<= lev->ppy + comp_info->num_levels - n;              if ((y_inc == 0) || (inc < y_inc))                y_inc = inc;            }        }      dims = tile->reference_dims;      if (x_inc == 0)        { /* Only one packet horizontally. */          x0 = 0; x1 = x_inc = 1;        }      else        {          x0 = dims.left_col; x1 = x0 + dims.cols;          x0 &= ~(x_inc-1); /* Start on integer multiple of x_inc. */        }      if (y_inc == 0)        { /* Only one packet vertically. */          y0 = 0; y1 = y_inc = 1;        }      else        {          y0 = dims.top_row; y1 = y0 + dims.rows;          y0 &= ~(y_inc-1); /* Start on integer multiple of y_inc. */        }      /* Now walk through the progression. */      for (y=y0; y < y1; y += y_inc)        for (x=x0; x < x1; x += x_inc)          for (c=0; c < max_components; c++)            {              comp_info = tile->components + c;              if (n > comp_info->num_levels)                continue;              lev = comp_info->levels + n;              p = lev->next_packet_idx;              packet = lev->packets + p;              if ((p < lev->total_packets) &&                  ((y==y0) || (y==packet->yref)) &&                  ((x==x0) || (x==packet->xref)))                {                  lev->next_packet_idx++;                  while (packet->included_layers < max_layers)                    {                      seq->layer_idx = packet->included_layers;                      seq->packet = packet;                      new_packets++;                      seq++;                      packet->included_layers++;                    }                }            }    }  return(new_packets);}/*****************************************************************************//* STATIC          construct_position_component_progression                  *//*****************************************************************************/static int  construct_position_component_progression(ebcot_tile_ptr tile,                                           ebcot_sequence_ptr seq,                                           int max_layers, int max_levels,                                           int max_components){  ebcot_component_info_ptr comp_info;  ebcot_level_info_ptr lev;  ebcot_packet_info_ptr packet;  canvas_dims dims;  int new_packets;  int n, c, p;  int x_inc, y_inc, inc, x0, x1, y0, y1, x, y;  /* Reset `next_packet_idx' fields. */  for (c=0; c < tile->num_components; c++)    {      comp_info = tile->components + c;      for (n=0; n <= comp_info->num_levels; n++)        {          lev = comp_info->levels +n;          lev->next_packet_idx = 0;        }    }  /* Determine spatial progression parameters. */  x_inc = y_inc = 0;  for (c=0; c < max_components; c++)    {      comp_info = tile->components + c;      if ((!is_power_of_2(comp_info->hor_subsampling)) ||          (!is_power_of_2(comp_info->vert_subsampling)))        local_error("Cannot use packet progressions where spatial "                    "progression dominates component progression unless "                    "component sub-sampling factors are exact powers of 2!");      for (n=0; n < max_levels; n++)        {          lev = comp_info->levels + n;          if (lev->ppx >= 0)            {              inc = comp_info->hor_subsampling;              inc <<= lev->ppx + comp_info->num_levels - n;              if ((x_inc == 0) || (inc < x_inc))                x_inc = inc;            }          if (lev->ppy >= 0)            {              inc = comp_info->vert_subsampling;              inc <<= lev->ppy + comp_info->num_levels - n;              if ((y_inc == 0) || (inc < y_inc))                y_inc = inc;            }        }    }  dims = tile->reference_dims;  if (x_inc == 0)    { /* Only one packet horizontally. */      x0 = 0; x1 = x_inc = 1;    }  else    {      x0 = dims.left_col; x1 = x0 + dims.cols;      x0 &= ~(x_inc-1); /* Start on integer multiple of x_inc. */    }  if (y_inc == 0)    { /* Only one packet vertically. */      y0 = 0; y1 = y_inc = 1;    }  else    {      y0 = dims.top_row; y1 = y0 + dims.rows;      y0 &= ~(y_inc-1); /* Start on integer multiple of y_inc. */    }  /* Now walk through the progression. */  new_packets = 0;  for (y=y0; y < y1; y += y_inc)    for (x=x0; x < x1; x += x_inc)      for (c=0; c < max_components; c++)        for (n=0; n < max_levels; n++)          {            comp_info = tile->components + c;            if (n > comp_info->num_levels)              continue;            lev = comp_info->levels + n;            p = lev->next_packet_idx;            packet = lev->packets + p;            if ((p < lev->total_packets) &&                ((y==y0) || (y==packet->yref)) &&                ((x==x0) || (x==packet->xref)))              {                lev->next_packet_idx++;                while (packet->included_layers < max_layers)                  {                    seq->layer_idx = packet->included_layers;                    seq->packet = packet;                    new_packets++;                    seq++;                    packet->included_layers++;                  }              }          }  return(new_packets);}/*****************************************************************************//* STATIC          construct_component_position_progression                  *//*****************************************************************************/static int  construct_component_position_progression(ebcot_tile_ptr tile,                                           ebcot_sequence_ptr seq,                                           int max_layers, int max_levels,                                           int max_components){  ebcot_component_info_ptr comp_info;  ebcot_level_info_ptr lev;  ebcot_packet_info_ptr packet;  canvas_dims dims;  int new_packets;  int n, c, p;  int x_inc, y_inc, inc, x0, x1, y0, y1, x, y;  /* Reset `next_packet_idx' fields. */  for (c=0; c < tile->num_components; c++)    {      comp_info = tile->components + c;      for (n=0; n <= comp_info->num_levels; n++)        {          lev = comp_info->levels +n;          lev->next_packet_idx = 0;        }    }  new_packets = 0;  for (c=0; c < max_components; c++)    {      comp_info = tile->components + c;      /* Determine spatial progression parameters. */      x_inc = y_inc = 0;      for (n=0; n < max_levels; n++)        {          if (n > comp_info->num_levels)            continue;          lev = comp_info->levels + n;          if (lev->ppx >= 0)            {              inc = comp_info->hor_subsampling;              inc <<= lev->ppx + comp_info->num_levels - n;              if ((x_inc == 0) || (inc < x_inc))                x_inc = inc;            }          if (lev->ppy >= 0)            {              inc = comp_info->vert_subsampling;              inc <<= lev->ppy + comp_info->num_levels - n;              if ((y_inc == 0) || (inc < y_inc))                y_inc = inc;            }        }      dims = tile->reference_dims;      if (x_inc == 0)        { /* Only one packet horizontally. */          x0 = 0; x1 = x_inc = 1;        }      else        {          x0 = dims.left_col; x1 = x0 + dims.cols;          x0 &= ~(x_inc-1); /* Start on integer multiple of x_inc. */        }      if (y_inc == 0)        { /* Only one packet vertically. */          y0 = 0; y1 = y_inc = 1;        }      else        {          y0 = dims.top_row; y1 = y0 + dims.rows;          y0 &= ~(y_inc-1); /* Start on integer multiple of y_inc. */        }      /* Now walk through the component's progression. */      for (y=y0; y < y1; y += y_inc)        for (x=x0; x < x1; x += x_inc)          for (n=0; n < max_levels; n++)            {              if (n > comp_info->num_levels)                continue;              lev = comp_info->levels + n;              p = lev->next_packet_idx;              packet = lev->packets + p;              if ((p < lev->total_packets) &&                  ((y==y0) || (y==packet->yref)) &&                  ((x==x0) || (x==packet->xref)))                {                  lev->next_packet_idx++;                  while (packet->included_layers < max_layers)                    {                      seq->layer_idx = packet->included_layers;                      seq->packet = packet;                      new_packets++;                      seq++;                      packet->included_layers++;                    }                }            }    }  return(new_packets);}/*****************************************************************************//* STATIC                 construct_progression_sequence                     *//*****************************************************************************/static void  construct_progression_sequence(ebcot_tile_ptr tile) /* This function converts the packet progression specification represented    by the `tile->progression' and `tile->progression_changes' fields into    a sequence spanning the total number of packets in the tile, which it    stores in the `tile->packet_sequence' array (also allocated by this    function). */{  int num_layers = tile->num_layers;  int num_packets, total_packets, max_tile_levels, c;  int max_layers, max_levels, max_components, style;  ebcot_order_ptr order;  ebcot_sequence_ptr seq;  max_tile_levels = 0;  for (c=0; c < tile->num_components; c++)

⌨️ 快捷键说明

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