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

📄 sfq.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 5 页
字号:
    {      child_subband_start = 1;      child_subband_end = 3;    }    cost1 = cost2 = 0.0;    if (level > 1)    {      for (child_subband = child_subband_start;           child_subband <= child_subband_end;           child_subband++)        {          cost1 +=             QccWAVsfqCalcChildrenCost(squared_subband_images,                                       child_subband,                                      row, col,                                      zerotree->num_cols                                      [child_subband]);          cost2 +=            QccWAVsfqCalcChildrenCost(J, child_subband,                                      row, col,                                      zerotree->num_cols                                      [child_subband]) +            QccWAVsfqCalcChildrenCost(residue_tree_J, child_subband,                                      row, col,                                      zerotree->num_cols                                      [child_subband]);        }            if (cost1 <= cost2)        {          zerotree->zerotree[subband][row][col] =            QCCWAVZEROTREE_SYMBOLZTROOT;          QccWAVZerotreeCarveOutZerotree(zerotree,                                         subband,                                         row, col);          minimum_cost = cost1;          *zerotree_pruned = 1;        }      else        minimum_cost = cost2;            squared_subband_images[subband][cost_index] += cost1;      delta_J[subband][cost_index] = fabs(cost1 - cost2);    }  else    minimum_cost = 0.0;    return(minimum_cost);}static int QccWAVsfqZerotreeFindThresholdHigh(QccVector sorted_variances,                                              int *zerotree_symbols,                                              QccVector delta_J,                                              int *addresses,                                              int num_variances,                                              double lambda,                                              int *first_zero_position){  int return_value;  int *blist = NULL;  int variance_index;  int bindex;  int blength;  int previous_zero_position = 0;  int hindex = 0;  int bsum;  double J_sum;  int num_reversals = 0;  int bits_saved = 0;  if ((blist = (int *)malloc(sizeof(int) * num_variances)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqZerotreeFindThresholdHigh): Error allocating memory");      goto Error;    }  do    {      for (variance_index = 0, bindex = -1;            variance_index < num_variances; variance_index++)        {          if (zerotree_symbols[addresses[variance_index]] ==              QCCWAVZEROTREE_SYMBOLZTROOT)            {              if (bindex >= 0)                blist[bindex] = variance_index - previous_zero_position;              bindex++;              previous_zero_position = variance_index;            }        }      blength = bindex;            for (hindex = 0; hindex < blength; hindex++)        {          for (variance_index = 0, bindex = 0, J_sum = 0.0, bsum = 0;                bindex <= hindex; variance_index++)            if (zerotree_symbols[addresses[variance_index]] ==                QCCWAVZEROTREE_SYMBOLZTROOT)              {                bsum += blist[bindex];                J_sum += delta_J[addresses[variance_index]];                bindex++;              }                    if (bsum*lambda > J_sum)            {              for (variance_index--; variance_index >= 0; variance_index--)                {                  if (zerotree_symbols[addresses[variance_index]] ==                      QCCWAVZEROTREE_SYMBOLZTROOT)                    {                      zerotree_symbols[addresses[variance_index]] =                         QCCWAVZEROTREE_SYMBOLSIGNIFICANT;                      num_reversals++;                    }                }              bits_saved += bsum;              break;            }        }    }  while (hindex < blength);  *first_zero_position = -1;  for (variance_index = 0; variance_index < num_variances;        variance_index++)    if (zerotree_symbols[addresses[variance_index]] ==        QCCWAVZEROTREE_SYMBOLZTROOT)      {        *first_zero_position = variance_index;        break;      }  printf("High: bits saved = %d, position %d\n",          bits_saved, variance_index);           return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);}static int QccWAVsfqZerotreeFindThresholdLow(QccVector sorted_variances,                                             int *zerotree_symbols,                                             QccVector delta_J,                                             int *addresses,                                             int num_variances,                                             double lambda,                                             int first_zero_position,                                             int *last_one_position){  int return_value;  int *blist = NULL;  int variance_index;  int bindex;  int blength;  int previous_one_position = 0;  int hindex = 0;  int bsum;  double J_sum;  int num_reversals = 0;  int bits_saved = 0;  if ((blist = (int *)malloc(sizeof(int) * num_variances)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqZerotreeFindThresholdLow): Error allocating memory");      goto Error;    }  do    {      for (variance_index = num_variances - 1, bindex = -1;            (variance_index >= 0) && (variance_index > first_zero_position);            variance_index--)        {          if (zerotree_symbols[addresses[variance_index]] ==              QCCWAVZEROTREE_SYMBOLSIGNIFICANT)            {              if (bindex >= 0)                blist[bindex] = previous_one_position - variance_index;              bindex++;              previous_one_position = variance_index;            }        }      blength = bindex;            for (hindex = 0; hindex < blength; hindex++)        {          for (variance_index = num_variances - 1, bindex = 0, J_sum = 0.0,                 bsum = 0;                bindex <= hindex; variance_index--)            if (zerotree_symbols[addresses[variance_index]] ==                QCCWAVZEROTREE_SYMBOLSIGNIFICANT)              {                bsum += blist[bindex];                J_sum += delta_J[addresses[variance_index]];                bindex++;              }                    if (bsum*lambda > J_sum)            {              for (variance_index++; variance_index < num_variances;                   variance_index++)                {                  if (zerotree_symbols[addresses[variance_index]] ==                      QCCWAVZEROTREE_SYMBOLSIGNIFICANT)                    {                      zerotree_symbols[addresses[variance_index]] =                         QCCWAVZEROTREE_SYMBOLZTROOT;                      num_reversals++;                    }                }              bits_saved += bsum;              break;            }        }    }  while (hindex < blength);  *last_one_position = -1;  for (variance_index = num_variances - 1;       variance_index >= 0; variance_index--)    if (zerotree_symbols[addresses[variance_index]] ==        QCCWAVZEROTREE_SYMBOLSIGNIFICANT)      {        *last_one_position = variance_index;        break;      }  printf("Low: bits saved = %d, position %d\n",          bits_saved, variance_index);           return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);}static int QccWAVsfqZerotreePrediction(QccIMGImageComponent                                        *quantized_variances,                                       QccWAVZerotree *zerotree,                                       QccVector *delta_J,                                       int subband,                                       double lambda,                                       int *high_tree_thresholds,                                       int *low_tree_thresholds){  int return_value;  int row, col;  QccIMGImageComponent filtered_variances;  double filter_coefficients[] = { 0.333333, 0.333333, 0.333333 };  QccFilter filter =    {      QCCFILTER_SYMMETRICWHOLE,      3,      NULL    };  int child_subband;  int child_subband_start, child_subband_end;  QccVector parent_variances = NULL;  QccVector sorted_variances = NULL;  QccVector delta_J_vector = NULL;  int num_variances;  int variance_index;  int *zerotree_symbols = NULL;  int *addresses = NULL;  int first_zero_position, last_one_position;  double high_variance, low_variance;  filter.coefficients = filter_coefficients;  QccIMGImageComponentInitialize(&filtered_variances);  filtered_variances = *quantized_variances;  filtered_variances.image = NULL;  if (QccIMGImageComponentAlloc(&filtered_variances))    {      QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccIMGImageComponentAlloc()");      goto Error;    }    for (row = 0; row < zerotree->num_rows[subband]; row++)    for (col = 0; col < zerotree->num_cols[subband]; col++)      {        filtered_variances.image[row][col] = 0.0;        if (QccWAVZerotreeNullSymbol(zerotree->zerotree[subband][row][col]))          quantized_variances->image[row][col] = 0.0;      }    if (QccIMGImageComponentFilterSeparable(quantized_variances,                                          &filtered_variances,                                          &filter, &filter,                                          QCCFILTER_SYMMETRIC_EXTENSION))    {      QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccIMGImageComponentFilterSeparable()");      goto Error;    }  if (!subband)    {      child_subband_start = 1;      child_subband_end = 3;    }  else    child_subband_start = child_subband_end = subband + 3;  if ((parent_variances =        QccVectorAlloc(zerotree->num_rows[child_subband_start] *                      zerotree->num_cols[child_subband_start])) == NULL)    {      QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccVectorAlloc()");      goto Error;    }  if ((sorted_variances =        QccVectorAlloc(zerotree->num_rows[child_subband_start] *                      zerotree->num_cols[child_subband_start])) == NULL)    {      QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccVectorAlloc()");      goto Error;    }  if ((delta_J_vector =        QccVectorAlloc(zerotree->num_rows[child_subband_start] *                      zerotree->num_cols[child_subband_start])) == NULL)    {      QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccVectorAlloc()");      goto Error;    }  if ((zerotree_symbols =       (int *)malloc(sizeof(int) * zerotree->num_rows[child_subband_start] *                     zerotree->num_cols[child_subband_start])) == NULL)    {      QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error allocating memory");      goto Error;    }  if ((addresses =       (int *)malloc(sizeof(int) * zerotree->num_rows[child_subband_start] *                     zerotree->num_cols[child_subband_start])) == NULL)    {      QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error allocating memory");      goto Error;    }  for (child_subband = child_subband_start;       child_subband <= child_subband_end;       child_subband++)    {      for (variance_index = 0, row = 0;            row < zerotree->num_rows[child_subband]; row++)        for (col = 0; col < zerotree->num_cols[child_subband]; col++)          if (!QccWAVZerotreeNullSymbol(zerotree->zerotree                                        [child_subband][row][col]))            {              parent_variances[variance_index] =                filtered_variances.image[row/2][col/2];              zerotree_symbols[variance_index] =                zerotree->zerotree[child_subband][row][col];              addresses[variance_index] = variance_index;              delta_J_vector[variance_index++] =                delta_J[child_subband][row *                                       zerotree->num_cols[child_subband] + col];            }      num_variances = variance_index;      if (QccVectorSortComponents(parent_variances, sorted_variances,                                  num_variances,                                  QCCVECTOR_SORTDESCENDING,                                  addresses))        {          QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccVectorSortComponents()");

⌨️ 快捷键说明

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