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

📄 sfq.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 5 页
字号:
          goto Error;        }      printf("Subband %d, num nonull %d\n",              child_subband,             num_variances);      {        int i;        printf("subband %d\n", child_subband);        for (i = 0; i < num_variances; i++)          printf("%d %f %f\n",                  zerotree_symbols[addresses[i]],                 sorted_variances[i],                  delta_J_vector[addresses[i]]);      }      if (QccWAVsfqZerotreeFindThresholdHigh(sorted_variances,                                             zerotree_symbols,                                             delta_J_vector,                                             addresses,                                             num_variances,                                             lambda,                                             &first_zero_position))        {          QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccWAVsfqZerotreeFindThresholdHigh()");          goto Error;        }      high_tree_thresholds[child_subband] = addresses[first_zero_position];      /*        printf("Subband %d\n", child_subband);        {        int i;        printf("subband %d\n", child_subband);        for (i = 0; i < num_variances; i++)        printf("%f %d\n", sorted_variances[i],         zerotree_symbols[addresses[i]]);        }      */      if (QccWAVsfqZerotreeFindThresholdLow(sorted_variances,                                            zerotree_symbols,                                            delta_J_vector,                                            addresses,                                            num_variances,                                            lambda,                                            first_zero_position,                                            &last_one_position))        {          QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccWAVsfqZerotreeFindThresholdLow()");          goto Error;        }      low_tree_thresholds[child_subband] = addresses[last_one_position];      /*        printf("Subband %d\n", child_subband);        {        int i;        printf("subband %d\n", child_subband);        for (i = 0; i < num_variances; i++)        printf("%f %d\n", sorted_variances[i],         zerotree_symbols[addresses[i]]);        }      */      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]))            {              zerotree->zerotree[child_subband][row][col] =                zerotree_symbols[variance_index];              if (zerotree->zerotree[child_subband][row][col] ==                  QCCWAVZEROTREE_SYMBOLZTROOT)                QccWAVZerotreeCarveOutZerotree(zerotree,                                               child_subband, row, col);              else                QccWAVZerotreeUndoZerotree(zerotree,                                           child_subband, row, col);              high_variance =                (high_tree_thresholds[child_subband] >= 0) ?                parent_variances[high_tree_thresholds[child_subband]] :                -MAXDOUBLE;              low_variance =                (low_tree_thresholds[child_subband] >= 0) ?                parent_variances[low_tree_thresholds[child_subband]] :                MAXDOUBLE;              /*****/              if ((parent_variances[variance_index] >                   high_variance) ||                  (parent_variances[variance_index] <                   low_variance))                zerotree->zerotree[child_subband][row][col] =                  QCCWAVZEROTREE_SYMBOLTEMP;              variance_index++;            }      /****/      printf("Subband: %d %f %f %d %d\n",              child_subband,             parent_variances[high_tree_thresholds[child_subband]],             parent_variances[low_tree_thresholds[child_subband]],             high_tree_thresholds[child_subband],             low_tree_thresholds[child_subband]);      /*        if (parent_variances[high_tree_thresholds[child_subband]] <=        parent_variances[low_tree_thresholds[child_subband]])        printf("*** ERROR ***\n");      */    }  return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccIMGImageComponentFree(&filtered_variances);  QccVectorFree(parent_variances);  QccVectorFree(sorted_variances);  QccVectorFree(delta_J_vector);  if (zerotree_symbols != NULL)    QccFree(zerotree_symbols);  return(return_value);}static int QccWAVsfqPruneZerotree(QccVector *squared_subband_images,                                  QccIMGImageComponent *quantized_variances,                                  QccVector *distortion,                                  QccChannel *channels,                                  QccWAVZerotree *zerotree,                                  QccSQScalarQuantizer *quantizer,                                  double lambda,                                  int *high_tree_thresholds,                                  int *low_tree_thresholds){  int return_value;  int num_subbands;  int subband;  QccVector *J = NULL;  QccVector *residue_tree_J = NULL;  QccVector *delta_J = NULL;  QccVector codeword_lengths = NULL;  int zerotree_changed;  int row, col;  int cost_index;    num_subbands = zerotree->num_subbands;    if ((codeword_lengths =        QccVectorAlloc(quantizer->num_levels)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccVectorAlloc()");      goto Error;    }    if ((J = (QccVector *)malloc(sizeof(QccVector)*num_subbands)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error allocating memory");      goto Error;    }  if ((residue_tree_J =        (QccVector *)malloc(sizeof(QccVector)*num_subbands)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error allocating memory");      goto Error;    }  if ((delta_J =        (QccVector *)malloc(sizeof(QccVector)*num_subbands)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error allocating memory");      goto Error;    }    for (subband = QCCWAVSFQ_ZEROTREE_STARTSUBBAND;        subband < num_subbands; subband++)    {      if ((J[subband] =           QccVectorAlloc(channels[subband].channel_length)) == NULL)        {          QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccVectorAlloc()");          goto Error;        }      if ((residue_tree_J[subband] =           QccVectorAlloc(channels[subband].channel_length)) == NULL)        {          QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccVectorAlloc()");          goto Error;        }      if ((delta_J[subband] =           QccVectorAlloc(channels[subband].channel_length)) == NULL)        {          QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccVectorAlloc()");          goto Error;        }    }    do    {      /*        printf("Pruning iteration %d\n", iteration);        iteration++;      */      zerotree_changed = 0;      QccWAVsfqCalcCodewordLengths(codeword_lengths, quantizer->num_levels,                                   channels, zerotree);      for (subband = num_subbands - 1;            subband >= QCCWAVSFQ_ZEROTREE_STARTSUBBAND; subband--)        {          for (row = 0, cost_index = 0;               row < zerotree->num_rows[subband];               row++)            for (col = 0;                 col < zerotree->num_cols[subband];                 col++, cost_index++)              {                if (!QccWAVZerotreeNullSymbol(zerotree->zerotree                                              [subband][row][col]))                  {                    J[subband][cost_index] =                      (subband) ?                      distortion[subband][cost_index] +                      lambda *                       codeword_lengths[channels[subband].channel_symbols                                      [cost_index]] : 0.0;                    if (zerotree->zerotree[subband][row][col] ==                        QCCWAVZEROTREE_SYMBOLSIGNIFICANT)                      residue_tree_J[subband][cost_index] =                        QccWAVsfqSelectMinimumCost(zerotree, subband,                                                    row, col, cost_index,                                                   J, residue_tree_J,                                                   delta_J,                                                   squared_subband_images,                                                   &zerotree_changed);                  }                else                  J[subband][cost_index] = 0.0;              }        }    }  while (zerotree_changed);    if ((high_tree_thresholds != NULL) && (low_tree_thresholds != NULL))    for (subband = 0; subband < zerotree->num_subbands - 6; subband++)      if (QccWAVsfqZerotreePrediction(&quantized_variances[subband],                                      zerotree,                                      delta_J,                                      subband, lambda,                                      high_tree_thresholds,                                      low_tree_thresholds))        {          QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccWAVsfqZerotreePrediction()");          goto Error;        }  return_value = 0;  goto Return;   Error:  return_value = 1; Return:  if (codeword_lengths != NULL)    QccVectorFree(codeword_lengths);  if (J != NULL)    {      for (subband = QCCWAVSFQ_ZEROTREE_STARTSUBBAND;            subband < num_subbands; subband++)        QccVectorFree(J[subband]);      QccFree(J);    }  if (residue_tree_J != NULL)    {      for (subband = QCCWAVSFQ_ZEROTREE_STARTSUBBAND;            subband < num_subbands; subband++)        QccVectorFree(residue_tree_J[subband]);      QccFree(residue_tree_J);    }  if (delta_J != NULL)    {      for (subband = QCCWAVSFQ_ZEROTREE_STARTSUBBAND;            subband < num_subbands; subband++)        QccVectorFree(delta_J[subband]);      QccFree(delta_J);    }    return(return_value);}static int QccWAVsfqHighpassEncodeProcess(QccIMGImageComponent *subband_images,                                          QccIMGImageComponent                                           *quantized_subband_images,                                          QccVector *squared_subband_images,                                          QccWAVZerotree *zerotree,                                          QccSQScalarQuantizer                                           *highpass_quantizer,                                          QccChannel *channels,                                          double lambda,                                          int *high_tree_thresholds,                                          int *low_tree_thresholds,                                          double *distortion, double *rate,                                          QccIMGImageComponent                                          *reconstructed_baseband){  int return_value;  int num_subbands;  int subband;  QccVector *distortion_vector = NULL;  int row, col;  int image_index, total_num_symbols;  int num_nonnull_symbols = 0;  int num_predicted_symbols = 0;  num_subbands = zerotree->num_subbands;    if ((distortion_vector =       (QccVector *)malloc(sizeof(QccVector)*num_subbands)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error allocating memory");      goto Error;    }  for (subband = 0; subband < num_subbands; subband++)    if ((distortion_vector[subband] =          QccVectorAlloc(channels[subband].channel_length)) == NULL)      {        QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error calling QccVectorAlloc()");        goto Error;      }    for (subband = 1; subband < num_subbands; subband++)    {      if (QccIMGImageComponentScalarQuantize(&(subband_images[subband]),                                             highpass_quantizer,                                             distortion_vector[subband],                                             &(channels[subband])))        {          QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error calling QccIMGImageComponentScalarQuantize()");          goto Error;        }      if (QccIMGImageComponentInverseScalarQuantize(&(channels[subband]),                                                    highpass_quantizer,                                                    &(quantized_subband_images[subband])))        {          QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error calling QccIMGImageComponentInverseScalarQuantize()");          goto Error;        }      if (QccChannelNormalize(&(channels[subband])))        {          QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error calling QccChannelNormalize()");          goto Error;        }    }    for (row = 0; row < reconstructed_baseband->num_rows; row++)    for (col = 0; col < reconstructed_baseband->num_cols; col++)      quantized_subband_images[0].image[row][col] =        reconstructed_baseband->image[row][col];  for (subband = 0; subband < num_subbands; subband++)    for (row = 0, image_index = 0;          row < subband_images[subband].num_rows; row++)      for (col = 0; col < subband_images[subband].num_cols;            col++, image_index++)        {          squared_subband_images[subband][image_index] =            subband_images[subband].image[row][col] *            subband_images[subband].image[row][col];          quantized_subband_images[subband].image[row][col] =            quantized_subband_images[subband].image[row][col] *            quantized_subband_images[subband].image[row][col];

⌨️ 快捷键说明

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