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

📄 filter_bank.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 3 页
字号:
                                     boundary_extension))    {      QccErrorAddMessage("(QccWAVFilterBankAnalysis): Error calling QccFilterMultiRateFilterVector()");      goto Error;    }    return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccVectorFree(signal2);  return(return_value);}int QccWAVFilterBankSynthesis(QccVector signal,                              int signal_length,                              int phase,                              const QccWAVFilterBank *filter_bank,                              int boundary_extension){  int return_value = 0;  QccVector lowpass_band;  int lowpass_band_length;  int lowpass_upsampling;  QccVector highpass_band;  int highpass_band_length;  int highpass_upsampling;  QccVector temp_vector = NULL;  QccVector signal2 = NULL;    if (signal == NULL)    return(0);  if (filter_bank == NULL)    return(0);    if (!signal_length)    return(0);    if (boundary_extension == QCCWAVWAVELET_BOUNDARY_BOUNDARY_WAVELET)    {      QccErrorAddMessage("(QccWAVFilterBankSynthesis): Boundary wavelets not supported for filter banks");      goto Error;    }  if ((filter_bank->orthogonality == QCCWAVFILTERBANK_ORTHOGONAL) &&      (boundary_extension != QCCWAVWAVELET_BOUNDARY_PERIODIC_EXTENSION))    {      QccErrorAddMessage("(QccWAVFilterBankSynthesis): Orthogonal filter banks must use periodic boundary extension");      goto Error;    }    if ((boundary_extension == QCCWAVWAVELET_BOUNDARY_PERIODIC_EXTENSION) &&      (signal_length % 2))    {      QccErrorAddMessage("(QccWAVFilterBankSynthesis): Signal length must be even for periodic extension");      goto Error;    }  if (signal_length == 1)    {      if (phase == QCCWAVFILTERBANK_PHASE_EVEN)        signal[0] /= M_SQRT2;      else        signal[0] *= M_SQRT2;      return(0);    }  if ((signal2 = QccVectorAlloc(signal_length)) == NULL)    {      QccErrorAddMessage("(QccWAVFilterBankSynthesis): Error calling QccVectorAlloc()");      goto Error;    }  if (QccVectorCopy(signal2, signal, signal_length))    {      QccErrorAddMessage("(QccWAVFilterBankSynthesis): Error calling QccVectorCopy()");      goto Error;    }  if (signal_length % 2)    if (phase == QCCWAVFILTERBANK_PHASE_ODD)      lowpass_band_length = signal_length / 2;    else      lowpass_band_length = signal_length / 2 + 1;  else    lowpass_band_length = signal_length / 2;  highpass_band_length = signal_length - lowpass_band_length;  if (phase == QCCWAVFILTERBANK_PHASE_ODD)    {      lowpass_upsampling = QCCFILTER_UPSAMPLEODD;      highpass_upsampling =        (filter_bank->orthogonality == QCCWAVFILTERBANK_BIORTHOGONAL) ?        QCCFILTER_UPSAMPLEEVEN :        QCCFILTER_UPSAMPLEODD;    }  else    {      lowpass_upsampling = QCCFILTER_UPSAMPLEEVEN;      highpass_upsampling =        (filter_bank->orthogonality == QCCWAVFILTERBANK_BIORTHOGONAL) ?        QCCFILTER_UPSAMPLEODD :        QCCFILTER_UPSAMPLEEVEN;    }  lowpass_band = signal2;  highpass_band = &(signal2[lowpass_band_length]);    if ((temp_vector = QccVectorAlloc(signal_length)) == NULL)    {      QccErrorAddMessage("(QccWAVFilterBankSynthesis): Error calling QccVectorAlloc()");      goto Error;    }    if (QccFilterMultiRateFilterVector(lowpass_band,                                     lowpass_band_length,                                     temp_vector,                                     signal_length,                                     &filter_bank->lowpass_synthesis_filter,                                     lowpass_upsampling,                                     QCCFILTER_SAMESAMPLING,                                     boundary_extension))    {      QccErrorAddMessage("(QccWAVFilterBankSynthesis): Error calling QccFilterMultiRateFilterVector()");      goto Error;    }    if (QccFilterMultiRateFilterVector(highpass_band,                                     highpass_band_length,                                     signal,                                     signal_length,                                     &filter_bank->highpass_synthesis_filter,                                     highpass_upsampling,                                     QCCFILTER_SAMESAMPLING,                                     boundary_extension))    {      QccErrorAddMessage("(QccWAVFilterBankSynthesis): Error calling QccFilterMultiRateFilterVector()");      goto Error;    }    if (QccVectorAdd(signal,                   temp_vector,                   signal_length))    {      QccErrorAddMessage("(QccWAVFilterBankSynthesis): Error calling QccVectorAdd()");      goto Error;    }    return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccVectorFree(signal2);  QccVectorFree(temp_vector);  return(return_value);}int QccWAVFilterBankRedundantAnalysis(const QccVector input_signal,                                      QccVector output_signal_low,                                      QccVector output_signal_high,                                      int signal_length,                                      const QccWAVFilterBank *filter_bank,                                      int boundary_extension){  int return_value = 0;  if (input_signal == NULL)    return(0);  if (output_signal_low == NULL)    return(0);  if (output_signal_high == NULL)    return(0);  if (filter_bank == NULL)    return(0);    if (!signal_length)    return(0);  if (signal_length == 1)    {      output_signal_low[0] = input_signal[0] * M_SQRT2;      output_signal_high[0] = input_signal[0] / M_SQRT2;      return(0);    }    if (boundary_extension == QCCWAVWAVELET_BOUNDARY_BOUNDARY_WAVELET)    {      QccErrorAddMessage("(QccWAVFilterBankRedundantAnalysis): Boundary wavelets not supported for filter banks");      goto Error;    }  if ((filter_bank->orthogonality == QCCWAVFILTERBANK_ORTHOGONAL) &&      (boundary_extension != QCCWAVWAVELET_BOUNDARY_PERIODIC_EXTENSION))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantAnalysis): Orthogonal filter banks must use periodic boundary extension");      goto Error;    }    if ((boundary_extension == QCCWAVWAVELET_BOUNDARY_PERIODIC_EXTENSION) &&      (signal_length % 2))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantAnalysis): Signal length must be even for periodic extension");      goto Error;    }  if (QccFilterMultiRateFilterVector(input_signal,                                     signal_length,                                     output_signal_low,                                     signal_length,                                     &filter_bank->lowpass_analysis_filter,                                     QCCFILTER_SAMESAMPLING,                                     QCCFILTER_SAMESAMPLING,                                     boundary_extension))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantAnalysis): Error calling QccFilterMultiRateFilterVector()");      goto Error;    }    if (QccFilterMultiRateFilterVector(input_signal,                                     signal_length,                                     output_signal_high,                                     signal_length,                                     &filter_bank->highpass_analysis_filter,                                     QCCFILTER_SAMESAMPLING,                                     QCCFILTER_SAMESAMPLING,                                     boundary_extension))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantAnalysis): Error calling QccFilterMultiRateFilterVector()");      goto Error;    }    return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);}int QccWAVFilterBankRedundantSynthesis(const QccVector input_signal_low,                                       const QccVector input_signal_high,                                       QccVector output_signal,                                       int signal_length,                                       const QccWAVFilterBank *filter_bank,                                       int boundary_extension){  int return_value = 0;  QccVector temp_signal = NULL;  if (input_signal_low == NULL)    return(0);  if (input_signal_high == NULL)    return(0);  if (output_signal == NULL)    return(0);  if (filter_bank == NULL)    return(0);    if (!signal_length)    return(0);  if (signal_length == 1)    {      output_signal[0] =        (input_signal_low[0] / M_SQRT2 + input_signal_high[0] * M_SQRT2) / 2;      return(0);    }    if ((temp_signal = QccVectorAlloc(signal_length)) == NULL)    {      QccErrorAddMessage("(QccWAVFilterBankRedundantSynthesis): Error calling QccVectorAlloc()");      goto Error;    }  if (boundary_extension == QCCWAVWAVELET_BOUNDARY_BOUNDARY_WAVELET)    {      QccErrorAddMessage("(QccWAVFilterBankRedundantSynthesis): Boundary wavelets not supported for filter banks");      goto Error;    }  if ((filter_bank->orthogonality == QCCWAVFILTERBANK_ORTHOGONAL) &&      (boundary_extension != QCCWAVWAVELET_BOUNDARY_PERIODIC_EXTENSION))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantSynthesis): Orthogonal filter banks must use periodic boundary extension");      goto Error;    }    if ((boundary_extension == QCCWAVWAVELET_BOUNDARY_PERIODIC_EXTENSION) &&      (signal_length % 2))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantSynthesis): Signal length must be even for periodic extension");      goto Error;    }  if (QccFilterMultiRateFilterVector(input_signal_low,                                     signal_length,                                     output_signal,                                     signal_length,                                     &filter_bank->lowpass_synthesis_filter,                                     QCCFILTER_SAMESAMPLING,                                     QCCFILTER_SAMESAMPLING,                                     boundary_extension))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantSynthesis): Error calling QccFilterMultiRateFilterVector()");      goto Error;    }    if (QccFilterMultiRateFilterVector(input_signal_high,                                     signal_length,                                     temp_signal,                                     signal_length,                                     &filter_bank->highpass_synthesis_filter,                                     QCCFILTER_SAMESAMPLING,                                     QCCFILTER_SAMESAMPLING,                                     boundary_extension))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantSynthesis): Error calling QccFilterMultiRateFilterVector()");      goto Error;    }    if (QccVectorAdd(output_signal,                   temp_signal,                   signal_length))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantSynthesis): Error calling QccVectorAdd()");      goto Error;    }  if (QccVectorScalarMult(output_signal,                          0.5,                          signal_length))    {      QccErrorAddMessage("(QccWAVFilterBankRedundantSynthesis): Error calling QccVectorScalarMult()");      goto Error;    }  return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccVectorFree(temp_signal);  return(return_value);}

⌨️ 快捷键说明

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