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

📄 wdr.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 4 页
字号:
                                int **sign_array,                                QccBitBuffer *buffer,                                double threshold,                                QccList *ICS,                                QccList *TPS,                                int method,                                 int target_bit_cnt,                                unsigned int *relative_origin,                                unsigned int virtual_end,                                QccENTArithmeticModel *model){  int sign = 0;  int return_value;  unsigned char significant;  QccWAVwdrCoefficientBlock *current_coefficient_block;  QccListNode *current_list_node;  QccListNode *next_list_node;    current_list_node = ICS->start;    if (method == QCCWAVWDR_ENCODE)    while (current_list_node != NULL)      {        next_list_node = current_list_node->next;        current_coefficient_block =          QccWAVwdrGetCoefficientBlockFromNode(current_list_node);        significant = FALSE;                if ((return_value = QccWAVwdrOutputRunLength(subband_pyramid,                                                     buffer,                                                     current_coefficient_block,                                                     threshold,                                                     target_bit_cnt,                                                     relative_origin,                                                     &significant,                                                     model)))          {            if (return_value == 2)              return(2);            else              {                QccErrorAddMessage("(QccWAVwdrSortingPass): Error calling QccWAVwdrOutputRunLength()");                goto Error;              }          }                if (significant == TRUE)          {            if ((return_value =                 QccWAVwdrAddNodeToTPS(TPS,                                       current_coefficient_block->row,                                       current_coefficient_block->col,                                       subband_pyramid,                                       threshold,                                       sign_array,                                       buffer,                                       method,                                       target_bit_cnt,                                       model)))              {                if (return_value == 2)                  return(2);                else                  {                    QccErrorAddMessage("(QccWAVwdrSortingPass): Error calling QccWAVwdrAddNodeToTPS()");                    goto Error;                  }              }                        if (QccListDeleteNode(ICS, current_list_node))              {                QccErrorAddMessage("(QccWAVwdrSortingPass): Error calling QccListDeleteNode()");                goto Error;              }          }                current_list_node = next_list_node;      }  else    {      while (*relative_origin != virtual_end)        {          if ((return_value = QccWAVwdrInputRunLength(subband_pyramid,                                                      buffer,                                                      relative_origin,                                                      &sign,                                                      model)))            {              if (return_value == 2)                return(2);              else                {                  QccErrorAddMessage("(QccWAVwdrSortingPass): Error calling QccWAVwdrInputRunLength()");                  goto Error;                }            }                    if (*relative_origin == virtual_end)            break;                    if (*relative_origin > virtual_end)            {              QccErrorAddMessage("(QccWAVwdrSortingPass): Synchronization Error In Decoding");              goto Error;            }                    current_coefficient_block =            QccWAVwdrGetCoefficientBlockFromNode(current_list_node);                    while (current_coefficient_block->index != *relative_origin)            {              current_list_node = current_list_node->next;              current_coefficient_block =                QccWAVwdrGetCoefficientBlockFromNode(current_list_node);            }                    if (QccWAVwdrAddNodeToTPS(TPS,                                    current_coefficient_block->row,                                    current_coefficient_block->col,                                    subband_pyramid,                                    threshold,                                    sign_array,                                    buffer,                                    method,                                    target_bit_cnt,                                    model))            {              QccErrorAddMessage("(QccWAVwdrSortingPass): Error calling QccWAVwdrAddNodeToTPS()");              goto Error;            }                    sign_array[current_coefficient_block->row]            [current_coefficient_block->col] = sign;                    next_list_node = current_list_node->next;          if (QccListDeleteNode(ICS, current_list_node))            {              QccErrorAddMessage("(QccWAVwdrSortingPass): Error calling QccListDeleteNode()");              goto Error;            }          current_list_node = next_list_node;        }            if (sign == 1)        {          QccErrorAddMessage("(QccWAVwdrSortingPass): Synchronization Error In Decoding");          goto Error;        }    }    return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);}static int QccWAVwdrOutputVirtualEnd(QccBitBuffer *buffer,                                     unsigned int relative_origin,                                     unsigned int virtual_end,                                     int target_bit_cnt,                                      QccENTArithmeticModel *model){  unsigned int run_length, temp;  int symbol = POSITIVE, reduced_bits, return_value;    run_length = virtual_end - relative_origin;  temp = run_length; reduced_bits = 0;  while (temp != 0)    {      temp >>= 1;      reduced_bits++;    }  reduced_bits--;    if (model != NULL)    if (QccENTArithmeticSetModelContext(model, QCCWAVWDR_RUN_CONTEXT))      {        QccErrorAddMessage("(QccWAVwdrOutputVirtualEnd): Error calling QccENTArithmeticSetModelContext()");        goto Error;      }    if ((return_value = QccWAVwdrOutputSymbol(buffer,                                            run_length,                                            reduced_bits,                                            target_bit_cnt,                                            model)))    {      if (return_value == 2)        return(2);      else        {          QccErrorAddMessage("(QccWAVwdrOutputVirtualEnd): Error calling QccWAVwdrOutputSymbol()");          goto Error;        }    }    if ((return_value = QccWAVwdrInputOutput(buffer,                                           &symbol,                                           QCCWAVWDR_ENCODE,                                           model,                                           target_bit_cnt)))    {      if (return_value == 2)        return(2);      else        {          QccErrorAddMessage("(QccWAVwdrOutputVirtualEnd): Error calling QccWAVwdrInputOutput()");          goto Error;        }    }    return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);    }static int QccWAVwdrUpdateIndex(QccList *ICS){  QccListNode *current_node, *stop;  QccWAVwdrCoefficientBlock *current_coefficient;  unsigned int adjust_index = 1;    current_node = ICS->start;  stop = ICS->end;  if ((current_node == NULL) || (stop == NULL))    return(0);  stop = stop->next;    while (current_node != stop)    {      current_coefficient = QccWAVwdrGetCoefficientBlockFromNode(current_node);      current_coefficient->index = adjust_index;      adjust_index++;      current_node = current_node->next;    }    return(0);}static int QccWAVwdrRefinementPass(QccWAVSubbandPyramid *subband_pyramid,                                   QccBitBuffer *buffer, double threshold,                                    QccList *SCS,                                   QccListNode *stop,                                   int method,                                   int target_bit_cnt,                                   QccENTArithmeticModel *model){  QccListNode *current_node;  QccWAVwdrCoefficientBlock *current_coefficient;  int return_value;    current_node = SCS->start;  if ((current_node == NULL) || (stop == NULL))    return(0);  stop = stop->next;    while (current_node != stop)    {      current_coefficient = QccWAVwdrGetCoefficientBlockFromNode(current_node);            if ((return_value =           QccWAVwdrInputOutputRefinementBit(subband_pyramid,                                             buffer,                                             threshold,                                             current_coefficient,                                             method,                                             model,                                             target_bit_cnt)))        {          if (return_value == 2)            return(2);          else            {              QccErrorAddMessage("(QccWAVwdrRefinementPass): Error calling QccWAVwdrInputOutputRefinementBit()");              goto Error;            }        }            current_node = current_node->next;    }    return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);    }int QccWAVwdrEncode(const QccIMGImageComponent *image,                    const QccIMGImageComponent *mask,                    QccBitBuffer *buffer,                    int num_levels,                    const QccWAVWavelet *wavelet,                    const QccWAVPerceptualWeights *perceptual_weights,                    int target_bit_cnt){  int return_value;  QccENTArithmeticModel *model = NULL;      QccWAVSubbandPyramid image_subband_pyramid;  QccWAVSubbandPyramid mask_subband_pyramid;  int **sign_array = NULL;  double image_mean;  int max_coefficient_bits;  QccList ICS;  QccList SCS;  QccList TPS;  QccListNode *stop;  double threshold;  unsigned int relative_origin;  int row;  unsigned int virtual_end;  int bitplane = 0;  if (image == NULL)    return(0);  if (buffer == NULL)    return(0);  if (wavelet == NULL)    return(0);    QccWAVSubbandPyramidInitialize(&image_subband_pyramid);  QccWAVSubbandPyramidInitialize(&mask_subband_pyramid);  QccListInitialize(&ICS);  QccListInitialize(&SCS);  QccListInitialize(&TPS);  if ((model = QccENTArithmeticEncodeStart(QccWAVwdrArithmeticContexts,                                           QCCWAVWDR_NUM_CONTEXTS, NULL,                                           QCCENT_ANYNUMBITS)) == NULL)    {      QccErrorAddMessage("(QccWAVwdrEncode): Error calling QccENTArithmeticEncodeStart()");      goto Error;    }    image_subband_pyramid.num_levels = 0;  image_subband_pyramid.num_rows = image->num_rows;  image_subband_pyramid.num_cols = image->num_cols;    if (QccWAVSubbandPyramidAlloc(&image_subband_pyramid))    {      QccErrorAddMessage("(QccWAVwdrEncode): Error calling QccWAVSubbandPyramidAlloc()");      goto Error;    }    if (mask != NULL)    {      if ((mask->num_rows != image->num_rows) ||          (mask->num_cols != image->num_cols))        {          QccErrorAddMessage("(QccWAVwdrEncode): Mask and image must be same size");          goto Error;        }            mask_subband_pyramid.num_levels = 0;      mask_subband_pyramid.num_rows = mask->num_rows;      mask_subband_pyramid.num_cols = mask->num_cols;      if (QccWAVSubbandPyramidAlloc(&mask_subband_pyramid))        {          QccErrorAddMessage("(QccWAVwdrEncode): Error calling QccWAVSubbandPyramidAlloc()");          goto Error;        }    }    if ((sign_array = (int **)malloc(sizeof(int *) * image->num_rows)) == NULL)    {      QccErrorAddMessage("(QccWAVwdrEncode): Error allocating memory");      goto Error;    }    for (row = 0; row < image->num_rows; row++)    if ((sign_array[row] =         (int *)malloc(sizeof(int) * image->num_cols)) == NULL)      {        QccErrorAddMessage("(QccWAVwdrEncode): Error allocating memory");        goto Error;      }    if (QccWAVwdrEncodeDWT(&image_subband_pyramid,                         sign_array,                         image,                         num_levels,                         &image_mean,                         &max_coefficient_bits,                         &mask_subband_pyramid,                         mask,                         wavelet,

⌨️ 快捷键说明

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