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

📄 spiht3d.c

📁 该文件是小波信源编码SPIHT算法的C语言代码
💻 C
📖 第 1 页 / 共 5 页
字号:
  return(0);}static int QccSPIHT3DTypeA(QccWAVSubbandPyramid3D                           *subband_pyramid,                           QccWAVSubbandPyramid3D *mask,                           int ***sign_array,                           QccBitBuffer *buffer,                           QccSPIHT3DCoefficientBlock *coefficient_block,                           QccListNode *current_list_node,                           double threshold,                           QccList *LSP,                           QccList *LIP,                           QccList *LIS,                           int method,                           QccENTArithmeticModel *model,                           int target_bit_cnt,                           int block_size,                           int zerotree_type){  int base_frame, base_row, base_col;  QccSPIHT3DCoefficientBlock new_coefficient_block;  QccListNode *new_node = NULL;  int bit;  int offspring_frame[8];  int offspring_row[8];  int offspring_col[8];  int num_offspring;  int offspring;  int new_state;  int cnt;  int frame, row, col;  int return_value;  base_frame = coefficient_block->frame;  base_row = coefficient_block->row;  base_col = coefficient_block->col;  if (QccSPIHT3DDescendantsOutsideMask(subband_pyramid,                                       mask,                                       base_frame, base_row, base_col,                                       block_size,                                       zerotree_type))    return(0);  if (method == QCCSPIHT3D_ENCODE)    {      bit = QccSPIHT3DDescendantsSignificance(subband_pyramid,                                              base_frame, base_row, base_col,                                              threshold,                                              block_size,                                              zerotree_type);            if (bit == -1)        return(0);    }    if (model != NULL)    if (QccENTArithmeticSetModelContext(model,                                        QCCSPIHT3D_LIS_TYPEA_CONTEXT +                                        coefficient_block->state))      {        QccErrorAddMessage("(QccSPIHT3DTypeA): Error calling QccENTArithmeticSetModelContext()");        return(2);      }    if (QccSPIHT3DInputOutput(buffer, &bit, method, model, target_bit_cnt))    {      QccErrorAddMessage("(QccSPIHT3DTypeA): Error calling QccSPIHT3DInputOutput()");      return(2);    }    if (!bit)    return(0);    num_offspring =     QccSPIHT3DGetOffspring(subband_pyramid,                           base_frame, base_row, base_col,                           offspring_frame,                           offspring_row,                           offspring_col,                           block_size,                           zerotree_type);    for (offspring = 0; offspring < num_offspring; offspring++)    {      new_coefficient_block.frame =         offspring_frame[offspring];      new_coefficient_block.row =         offspring_row[offspring];      new_coefficient_block.col =         offspring_col[offspring];      new_coefficient_block.type =         QCCSPIHT3D_TYPE_A;      new_coefficient_block.state = 0;            if (model != NULL)        if (QccENTArithmeticSetModelContext(model,                                            QCCSPIHT3D_LIS_TYPEA_OFFSPRING_CONTEXT +                                            coefficient_block->state))          {            QccErrorAddMessage("(QccSPIHT3DTypeA): Error calling QccENTArithmeticSetModelContext()");            return(2);          }            if (QccSPIHT3DInputOutputSignificanceBits(subband_pyramid,                                                buffer,                                                &new_coefficient_block,                                                threshold,                                                method,                                                model,                                                target_bit_cnt,                                                block_size))        {          QccErrorAddMessage("(QccSPIHT3DTypeA): Error calling QccSPIHT3DInputOutputSignificanceBits()");          return(2);        }            new_state = new_coefficient_block.state;            cnt = 0;      for (frame = 0; frame < block_size; frame++)        for (row = 0; row < block_size; row++)          for (col = 0; col < block_size; col++)            if (QccSPIHT3DIsSignificant(new_state,                                        frame, row, col, block_size))              {                cnt++;                if ((return_value =                     QccSPIHT3DAddNodeToLSP(LSP,                                            offspring_frame[offspring] + frame,                                            offspring_row[offspring] + row,                                            offspring_col[offspring] + col,                                            subband_pyramid,                                            threshold,                                            sign_array,                                            buffer,                                            method,                                            model,                                            target_bit_cnt)))                  {                    QccErrorAddMessage("(QccSPIHT3DTypeA): Error calling QccSPIHT3DAddNodeToLSP()");                    return(return_value);                  }              }            if (cnt != block_size * block_size * block_size)        {          if ((new_node =               QccListCreateNode(sizeof(QccSPIHT3DCoefficientBlock),                                 (void *)(&new_coefficient_block))) == NULL)            {              QccErrorAddMessage("(QccSPIHT3DTypeA): Error calling QccListCreateNode()");              return(1);            }                    if (QccListAppendNode(LIP, new_node))            {              QccErrorAddMessage("(QccSPIHT3DTypeA): Error calling QccListAppendNode()");              return(1);            }        }    }    if (QccSPIHT3DGetOffspring(subband_pyramid,                             offspring_frame[0],                             offspring_row[0],                             offspring_col[0],                             offspring_frame,                             offspring_row,                             offspring_col,                             block_size,                             zerotree_type))    {      coefficient_block->type = QCCSPIHT3D_TYPE_B;            if ((new_node =           QccListCreateNode(sizeof(QccSPIHT3DCoefficientBlock),                             (void *)(coefficient_block))) == NULL)        {          QccErrorAddMessage("(QccSPIHT3DTypeA): Error calling QccListCreateNode()");          return(1);        }            if (QccListAppendNode(LIS, new_node))        {          QccErrorAddMessage("(QccSPIHT3DTypeA): Error calling QccListAppendNode()");          return(1);        }    }    coefficient_block->type = QCCSPIHT3D_TYPE_DELETE;    return(0);}static int QccSPIHT3DTypeB(QccWAVSubbandPyramid3D *subband_pyramid,                           QccWAVSubbandPyramid3D *mask,                           int ***sign_array,                           QccBitBuffer *buffer,                           QccSPIHT3DCoefficientBlock *coefficient_block,                           QccListNode *current_list_node,                           double threshold,                           QccList *LIS,                           int method,                           QccENTArithmeticModel *model,                           int target_bit_cnt,                           int block_size,                           int zerotree_type){  int bit;  int offspring_frame[8];  int offspring_row[8];  int offspring_col[8];  int num_offspring;  int offspring;  QccSPIHT3DCoefficientBlock new_coefficient_block;  QccListNode *new_node;  int base_frame, base_row, base_col;  base_frame = coefficient_block->frame;  base_row = coefficient_block->row;  base_col = coefficient_block->col;  if (QccSPIHT3DDescendantsOutsideMask(subband_pyramid,                                       mask,                                       base_frame, base_row, base_col,                                       block_size,                                       zerotree_type))    return(0);    if (method == QCCSPIHT3D_ENCODE)    {      bit = QccSPIHT3DLSignificance(subband_pyramid,                                    coefficient_block->frame,                                    coefficient_block->row,                                    coefficient_block->col,                                    threshold,                                    block_size,                                    zerotree_type);            if (bit == -1)        return(0);    }          if (model != NULL)    if (QccENTArithmeticSetModelContext(model,                                        QCCSPIHT3D_LIS_TYPEB_CONTEXT +                                        coefficient_block->state))      {        QccErrorAddMessage("(QccSPIHT3DTypeB): Error calling QccENTArithmeticSetModelContext()");        return(2);      }    if (QccSPIHT3DInputOutput(buffer, &bit, method, model, target_bit_cnt))    {      QccErrorAddMessage("(QccSPIHT3DTypeB): Error calling QccSPIHT3DInputOutput()");      return(2);    }    if (!bit)    return(0);    num_offspring = QccSPIHT3DGetOffspring(subband_pyramid,                                         coefficient_block->frame,                                         coefficient_block->row,                                         coefficient_block->col,                                         offspring_frame,                                         offspring_row,                                         offspring_col,                                         block_size,                                         zerotree_type);    for (offspring = 0; offspring < num_offspring; offspring++)    {      new_coefficient_block.frame =         offspring_frame[offspring];      new_coefficient_block.row =         offspring_row[offspring];      new_coefficient_block.col =         offspring_col[offspring];      new_coefficient_block.type =         QCCSPIHT3D_TYPE_A;      new_coefficient_block.state = 0;            if ((new_node =           QccListCreateNode(sizeof(QccSPIHT3DCoefficientBlock),                             (void *)(&new_coefficient_block))) == NULL)        {          QccErrorAddMessage("(QccSPIHT3DTypeB): Error calling QccListCreateNode()");          return(1);        }      if (QccListAppendNode(LIS, new_node))        {          QccErrorAddMessage("(QccSPIHT3DTypeB): Error calling QccListAppendNode()");          return(1);        }    }    QccSPIHT3DGetCoefficientBlockFromNode(current_list_node)->type =    QCCSPIHT3D_TYPE_DELETE;    return(0);}static int QccSPIHT3DSortingPass(QccWAVSubbandPyramid3D *subband_pyramid,                                 QccWAVSubbandPyramid3D *mask,                                 int ***sign_array,                                 QccBitBuffer *buffer,                                 double threshold,                                 QccList *LSP,                                 QccList *LIP,                                 QccList *LIS,                                 int method,                                 QccENTArithmeticModel *model,                                 int target_bit_cnt,                                 int block_size,                                 int zerotree_type){  int return_value;  int old_state;  int new_state;  int frame, row, col;  int cnt;  int base_frame, base_row, base_col;  QccSPIHT3DCoefficientBlock *current_coefficient_block;  QccListNode *current_list_node;    current_list_node = LIP->start;  while (current_list_node != NULL)    {      current_coefficient_block =        QccSPIHT3DGetCoefficientBlockFromNode(current_list_node);            if (current_coefficient_block->type != QCCSPIHT3D_TYPE_DELETE)        {          old_state = current_coefficient_block->state;                    if (model != NULL)            if (QccENTArithmeticSetModelContext(model,                                                 QCCSPIHT3D_LIP_CONTEXT +                                                old_state))              {                QccErrorAddMessage("(QccSPIHT3DSortingPass): Error calling QccENTArithmeticSetModelContext()");                goto Finished;              }                    if (QccSPIHT3DInputOutputSignificanceBits(subband_pyramid,                                                    buffer,  

⌨️ 快捷键说明

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