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

📄 sfq.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 5 页
字号:
      QccErrorAddMessage("(QccWAVsfqDecodeReconstructZerotree): Error calling QccIMGImageComponentAlloc()");      goto Error;    }  if (QccIMGImageComponentAlloc(&filtered_variances))    {      QccErrorAddMessage("(QccWAVsfqDecodeReconstructZerotree): Error calling QccIMGImageComponentAlloc()");      goto Error;    }  for (row = 0; row < zerotree->num_rows[parent_subband]; row++)    for (col = 0; col < zerotree->num_cols[parent_subband]; col++)      {        filtered_variances.image[row][col] = 0.0;        if (QccWAVZerotreeNullSymbol(zerotree->zerotree                                     [parent_subband][row][col]))          variances.image[row][col] = 0.0;        else          variances.image[row][col] =            subband_images[parent_subband].image[row][col] *            subband_images[parent_subband].image[row][col];      }  if (QccIMGImageComponentFilterSeparable(&variances,                                          &filtered_variances,                                          &filter, &filter,                                          QCCFILTER_SYMMETRIC_EXTENSION))    {      QccErrorAddMessage("(QccWAVsfqDecodeReconstructZerotree): Error calling QccIMGImageComponentFilterSeparable()");      goto Error;    }  high_variance = -MAXDOUBLE;  low_variance = MAXDOUBLE;  for (row = 0, variance_index = 0; row < zerotree->num_rows[subband]; row++)    for (col = 0; col < zerotree->num_cols[subband]; col++)      if (!QccWAVZerotreeNullSymbol(zerotree->zerotree[subband][row][col]))        {          parent_variance = filtered_variances.image[row / 2][col / 2];          if (variance_index == high_tree_thresholds[subband])            high_variance = parent_variance;          if (variance_index == low_tree_thresholds[subband])            low_variance = parent_variance;          variance_index++;        }  /****/  printf("Subband: %d %f %f %d %d\n",          subband,         high_variance, low_variance,         high_tree_thresholds[subband],         low_tree_thresholds[subband]);  for (row = 0; row < zerotree->num_rows[subband]; row++)    for (col = 0; col < zerotree->num_cols[subband]; col++)      if (!QccWAVZerotreeNullSymbol(zerotree->zerotree[subband][row][col]))        {          parent_variance = filtered_variances.image[row / 2][col / 2];          if (parent_variance > high_variance)            zerotree->zerotree[subband][row][col] =              QCCWAVZEROTREE_SYMBOLSIGNIFICANT;          else            /*****/            if (parent_variance < low_variance)              zerotree->zerotree[subband][row][col] =                QCCWAVZEROTREE_SYMBOLZTROOT;            else              zerotree->zerotree[subband][row][col] =                zerotree_symbols[(*zerotree_index)++];          if (zerotree->zerotree[subband][row][col] ==              QCCWAVZEROTREE_SYMBOLZTROOT)            QccWAVZerotreeCarveOutZerotree(zerotree,                                           subband, row, col);        }  return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccIMGImageComponentFree(&variances);  QccIMGImageComponentFree(&filtered_variances);  return(return_value);}static int QccWAVsfqDecodeReconstructSubband(QccWAVZerotree *zerotree,                                             QccChannel *channels,                                             int subband,                                             const QccSQScalarQuantizer                                              *highpass_quantizer,                                             const QccSQScalarQuantizer                                              *baseband_quantizer,                                             QccIMGImageComponent                                              *subband_images){  int return_value;  int row, col, channel_index;  if (QccChannelDenormalize(&(channels[subband])))    {      QccErrorAddMessage("(QccWAVsfqDecodeReconstructSubband): Error calling QccChannelDenormalize()");      goto Error;    }  for (row = 0, channel_index = 0;        row < zerotree->num_rows[subband];        row++)    for (col = 0;          col < zerotree->num_cols[subband];          col++)      if (!QccWAVZerotreeNullSymbol(zerotree->zerotree[subband][row][col]))        {          if (QccSQInverseScalarQuantization(channels                                             [subband].channel_symbols                                             [channel_index++],                                             (subband) ? highpass_quantizer :                                             baseband_quantizer,                                             &(subband_images                                               [subband].image[row][col])))            {              QccErrorAddMessage("(QccWAVsfqDecodeReconstructSubband): Error calling QccSQInverseScalarQuantization()");              goto Error;            }        }      else        subband_images[subband].image[row][col] = 0.0;    return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);}int QccWAVsfqDecode(QccBitBuffer *input_buffer,                    QccIMGImageComponent *output_image,                    QccWAVZerotree *zerotree,                    const QccSQScalarQuantizer *baseband_quantizer,                    const QccSQScalarQuantizer *highpass_quantizer,                    int *high_tree_thresholds,                    int *low_tree_thresholds,                    QccChannel *channels,                    const QccWAVWavelet *wavelet,                    const QccWAVPerceptualWeights *perceptual_weights){  int return_value;  int num_subbands;  int subband;  QccIMGImageComponent *subband_images = NULL;  QccWAVSubbandPyramid subband_pyramid;  int *zerotree_symbols = NULL;  QccENTArithmeticModel *model = NULL;  int num_contexts;  int *num_symbols = NULL;  int zerotree_index;  if ((output_image == NULL) ||      (zerotree == NULL) ||      (baseband_quantizer == NULL) ||      (highpass_quantizer == NULL) ||      (channels == NULL) ||      (wavelet == NULL))    return(0);    num_subbands = zerotree->num_subbands;    if ((zerotree_symbols =        (int *)malloc(sizeof(int) *                      zerotree->image_num_rows * zerotree->image_num_cols))       == NULL)    {      QccErrorAddMessage("(QccWAVsfqDecode): Error allocating memory");      goto Error;    }      if (QccWAVsfqDisassembleBitstreamZerotree(num_subbands,                                            high_tree_thresholds,                                            low_tree_thresholds,                                            zerotree_symbols,                                            input_buffer))    {      QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVsfqDisassembleBitstreamZerotree()");      goto Error;    }  if ((subband_images =       (QccIMGImageComponent *)malloc(sizeof(QccIMGImageComponent) *                                       num_subbands)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqDecode): Error allocating memory");      goto Error;    }    for (subband = 0; subband < num_subbands; subband++)    {      QccIMGImageComponentInitialize(&subband_images[subband]);      subband_images[subband].num_rows = zerotree->num_rows[subband];      subband_images[subband].num_cols = zerotree->num_cols[subband];      if (QccIMGImageComponentAlloc(&(subband_images[subband])))        {          QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccIMGImageComponentAlloc()");          goto Error;        }    }    num_contexts = zerotree->num_subbands;  if ((num_symbols = (int *)malloc(sizeof(int) * num_contexts)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqDecode): Error allocating memory");      goto Error;    }  for (subband = 0; subband < zerotree->num_subbands; subband++)    num_symbols[subband] = channels[subband].alphabet_size;    if ((model =        QccENTArithmeticDecodeStart(input_buffer,                                   num_symbols,                                   num_contexts,                                   NULL,                                   QCCENT_ANYNUMBITS)) == NULL)    {      QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccENTArithmeticDecodeStart()");      goto Error;    }    for (subband = 0, zerotree_index = 0; subband < num_subbands; subband++)    {      if (QccWAVsfqDecodeReconstructZerotree(zerotree,                                             zerotree_symbols,                                             &zerotree_index,                                             high_tree_thresholds,                                             low_tree_thresholds,                                             subband,                                             subband_images))        {          QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVsfqDecodeReconstructZerotree()");          goto Error;        }      if (QccWAVsfqDisassembleBitstreamChannel(model,                                               zerotree,                                               channels,                                               subband,                                               input_buffer))        {          QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVsfqDisassembleBitstreamChannel()");          goto Error;        }      if (QccWAVsfqDecodeReconstructSubband(zerotree,                                            channels,                                            subband,                                            highpass_quantizer,                                            baseband_quantizer,                                            subband_images))        {          QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVsfqDecodeReconstructSubband()");          goto Error;        }    }  QccWAVSubbandPyramidInitialize(&subband_pyramid);  subband_pyramid.num_rows = zerotree->image_num_rows;  subband_pyramid.num_cols = zerotree->image_num_cols;  subband_pyramid.num_levels = zerotree->num_levels;  if (QccWAVSubbandPyramidAlloc(&subband_pyramid))    {      QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVSubbandPyramidAlloc()");      goto Error;    }    if (QccWAVSubbandPyramidAssembleFromImageComponent(subband_images,                                                     &subband_pyramid))    {      QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVSubbandPyramidAssembleFromImageComponent()");      goto Error;    }    if (perceptual_weights != NULL)    if (QccWAVPerceptualWeightsRemove(&subband_pyramid,                                      perceptual_weights))      {        QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVPerceptualWeightsRemove()");        QccErrorExit();      }  if (zerotree->num_levels)    if (QccWAVSubbandPyramidInverseDWT(&subband_pyramid,                                       wavelet))      {        QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVWaveletSynthesisSubbandPyramid()");        goto Error;      }    if (QccWAVSubbandPyramidAddMean(&subband_pyramid,                                  zerotree->image_mean))    {      QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVSubbandPyramidAddMean()");      goto Error;    }    if (QccMatrixCopy(output_image->image,                    subband_pyramid.matrix,                    subband_pyramid.num_rows,                    subband_pyramid.num_cols))    {      QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccMatrixCopy()");      goto Error;    }    QccIMGImageComponentSetMin(output_image);  QccIMGImageComponentSetMax(output_image);  return_value = 0;  goto Return; Error:  return_value = 1; Return:  if (zerotree_symbols != NULL)    QccFree(zerotree_symbols);  if (subband_images != NULL)    {      for (subband = 0; subband < num_subbands; subband++)        QccIMGImageComponentFree(&(subband_images[subband]));      QccFree(subband_images);    }  QccWAVSubbandPyramidFree(&subband_pyramid);  QccENTArithmeticFreeModel(model);  if (num_symbols != NULL)    QccFree(num_symbols);  return(return_value);}int QccWAVsfqAssembleBitstreamHeader(const QccWAVZerotree *zerotree,                                     const QccSQScalarQuantizer                                     *mean_quantizer,                                     const QccSQScalarQuantizer                                     *baseband_quantizer,                                     const QccSQScalarQuantizer                                     *highpass_quantizer,                                     const int *high_tree_thresholds,                                     const int *low_tree_thresholds,                                     QccBitBuffer *output_buffer,                                     int *num_output_bits){  int return_value;  int mean_partition;  int no_tree_prediction;  int subband, row, col;  int num_nonnull_symbols;  if ((zerotree == NULL) || (output_buffer == NULL))    return(0);    no_tree_prediction =    ((high_tree_thresholds == NULL) && (low_tree_thresholds == NULL));    if (QccBitBufferPutChar(output_buffer,                          (char)no_tree_prediction))    {      QccErrorAddMessage("(QccWAVsfqAssembleBitstreamHeader): Error calling QccBitBufferPutChar()");      goto Error;    }  if (QccBitBufferPutChar(output_buffer,                          (char)zerotree->num_levels))    {      QccErrorAddMessage("(QccWAVsfqAssembleBitstreamHeader): Error calling QccBitBufferPutChar()");      goto Error;    }  if (QccBitBufferPutDouble(output_buffer,                            baseband_quantizer->stepsize))    {      QccErrorAddMessage("(QccWAVsfqAssembleBitstreamHeader): Error calling QccBitBufferPutDouble()"

⌨️ 快捷键说明

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