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

📄 klttce3d.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * * QccPack: Quantization, compression, and coding utilities * Copyright (C) 1997-2007  James E. Fowler *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. *  * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *//*  * * Written by * * Jing Zhang, at Mississippi State University, 2008  * */#include "libQccPack.h"#define QCCWAVKLTTCE3D_BOUNDARY_VALUE (1e-6)//definition used in context information#define QCCWAVKLTTCE3D_Z 0 //zero, AKA, insignificant#define QCCWAVKLTTCE3D_NZN_NEW 2 //non-zero-neighbor#define QCCWAVKLTTCE3D_S 3 //significant#define QCCWAVKLTTCE3D_S_NEW 4#define QCCWAVKLTTCE3D_NZN 5// more refinement can be made if direction of Tarp filter is considered// but the improvement is minor//ugly fix, use 1-D IIR filter to provide PMF estimate#define QCCWAVKLTTCE3D_ALPHA_1D 0.995 #define QCCWAVKLTTCE3D_ALPHA_1D_O 0.005// this should be 0.5, however, 0.3 seems to work a little better (minor)// reason unknown#define QCCWAVKLTTCE3D_REFINE_HOLDER 0.3 // threshold for cross-scale prediction...#define QCCWAVKLTTCE3D_PREDICT_THRESHOLD 0.05  //weight factor for cross-scale and current scale#define QCCWAVKLTTCE3D_CURRENT_SCALE 0.6 #define QCCWAVKLTTCE3D_PARENT_SCALE 0.4#define QCCWAVKLTTCE3D_MAXBITPLANES 128                                      static int QccWAVklttce3DEncodeBitPlaneInfo(QccBitBuffer *output_buffer,                                            int num_subbands,                                            int *max_coefficient_bits){  int subband;  int num_zeros = 0;  for (subband = 1; subband < num_subbands; subband++)    {      num_zeros = max_coefficient_bits[subband-1] - max_coefficient_bits[subband];      if (num_zeros>0)                   QccBitBufferPutBit(output_buffer, 0);      else        QccBitBufferPutBit(output_buffer, 1);    }    for (subband = 1; subband < num_subbands; subband++)    {      for (num_zeros = abs(max_coefficient_bits[subband-1] - max_coefficient_bits[subband]);           num_zeros > 0;           num_zeros--)        if (QccBitBufferPutBit(output_buffer, 0))          return(1);      if (QccBitBufferPutBit(output_buffer, 1))        return(1);    }  return(0);}static int QccWAVklttce3DDecodeBitPlaneInfo(QccBitBuffer *input_buffer,                                            int num_subbands,                                            int *max_bits,                                            int max_coefficient_bits){  int subband;  int bit_value;  int *max_bits_sign;  if ((max_bits_sign =       (int *)malloc(sizeof(int) * num_subbands )) == NULL)    {      QccErrorAddMessage("(QccWAVklttce3DDecodeBitPlaneInfo): Error allocating memory");          }    max_bits[0] = max_coefficient_bits;  for (subband = 1; subband < num_subbands; subband++)    {            QccBitBufferGetBit(input_buffer,&bit_value);                  if (bit_value == 0)        max_bits_sign[subband] = 1;        else        max_bits_sign[subband] = -1;    }    for (subband = 1; subband < num_subbands; subband++)    {      max_bits[subband] = 0;      do        {          if (QccBitBufferGetBit(input_buffer,&bit_value))            return(1);          max_bits[subband]++;        }      while (bit_value == 0);      max_bits[subband]--;        max_bits[subband] = max_bits[subband - 1] -         max_bits[subband] * max_bits_sign[subband];    }    return(0);}static int QccWAVTce3DUpdateModel(QccENTArithmeticModel *model, double prob){  double p[2];  p[0] = 1 - prob;  p[1] = prob;  if (QccENTArithmeticSetModelProbabilities(model,                                            p,                                            0))    {           QccErrorAddMessage("(QccWAVTarp3DUpdateModel): Error calling QccENTArithmeticSetModelProbabilities()");      return(1);    }  return(0);}static int QccWAVklttceForwardKLTDWT(QccWAVSubbandPyramid3D                                     *image_subband_pyramid,                                     int num_levels,                                     const QccWAVWavelet *wavelet,                                     QccHYPklt *klt){  int return_value;  QccIMGImageCube image_cube;  image_subband_pyramid->temporal_num_levels = 0;  image_subband_pyramid->spatial_num_levels = 0;   image_cube.num_frames = image_subband_pyramid->num_frames;  image_cube.num_rows = image_subband_pyramid->num_rows;  image_cube.num_cols = image_subband_pyramid->num_cols;  image_cube.volume = image_subband_pyramid->volume;  if (QccHYPkltTrain(&image_cube,                     klt))    {      QccErrorAddMessage("(QccWAVklttceForwardKLTDWT): Error calling QccHYPkltTrain()");      goto Error;    }  if (QccHYPkltTransform(&image_cube,                         klt,                         klt->num_bands))    {      QccErrorAddMessage("(QccWAVklttceForwardKLTDWT): Error calling QccHYPkltTransform()");      goto Error;    }    if (QccWAVSubbandPyramid3DDWT(image_subband_pyramid,                                QCCWAVSUBBANDPYRAMID3D_PACKET,                                0,                                num_levels,                                wavelet))    {      QccErrorAddMessage("(QccWAVklttceForwardKLTDWT): Error calling QccWAVSubbandPyramid3DDWT()");      goto Error;    }  return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);}static int QccWAVklttceInverseKLTDWT(QccWAVSubbandPyramid3D                                     *image_subband_pyramid,                                     const QccWAVWavelet *wavelet,                                     int num_levels,                                     const QccHYPklt *klt){  int return_value;  QccIMGImageCube image_cube;  if (QccWAVSubbandPyramid3DInverseDWT(image_subband_pyramid,                                       wavelet))    {      QccErrorAddMessage("(QccWAVklttceInverseKLTDWT): Error calling QccWAVSubbandPyramid3DInverseDWT()");      goto Error;    }  image_cube.num_frames = image_subband_pyramid->num_frames;  image_cube.num_rows = image_subband_pyramid->num_rows;  image_cube.num_cols = image_subband_pyramid->num_cols;  image_cube.volume = image_subband_pyramid->volume;  if (QccHYPkltInverseTransform(&image_cube,                                klt))    {      QccErrorAddMessage("(QccWAVklttceInverseKLTDWT): Error calling QccHYPkltInverseTransform(()");      goto Error;    }    return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);}static int QccWAVklttce3DForwardTransform(QccWAVSubbandPyramid3D                                          *image_subband_pyramid,                                          char ***sign_array,                                          const QccIMGImageCube *image,                                          int num_levels,                                          int **max_coefficient_bits,                                          const QccWAVWavelet *wavelet,                                          QccHYPklt *klt){  double coefficient_magnitude;  double max_coefficient = -MAXFLOAT;  int frame, row, col;  int num_subbands,subband;  int subband_origin_frame;  int subband_origin_row;  int subband_origin_col;  int subband_num_frames;  int subband_num_rows;  int subband_num_cols;  num_subbands =    QccWAVSubbandPyramid3DNumLevelsToNumSubbandsPacket(0, num_levels);    if (QccVolumeCopy(image_subband_pyramid->volume,                    image->volume,                    image->num_frames,                    image->num_rows,                    image->num_cols))    {      QccErrorAddMessage("(QccWAVklttce3DForwardTransform): Error calling QccVolumeCopy()");      return(1);    }  if (QccWAVklttceForwardKLTDWT(image_subband_pyramid,                                num_levels,                                wavelet,                                klt))    {      QccErrorAddMessage("(QccWAVklttce3DForwardTransform): Error calling QccWAVklttceForwardKLTDWT()");      return(1);    }   for (subband = 0; subband < num_subbands; subband++)    {      if (QccWAVSubbandPyramid3DSubbandSize(image_subband_pyramid,                                            subband,                                            &subband_num_frames,                                            &subband_num_rows,                                            &subband_num_cols))        {          QccErrorAddMessage("(QccWAVklttce3DForwardTransform): Error calling QccWAVSubbandPyramid3DSubbandSize()");          return(1);        }      if (QccWAVSubbandPyramid3DSubbandOffsets(image_subband_pyramid,                                               subband,                                               &subband_origin_frame,                                               &subband_origin_row,                                               &subband_origin_col))        {          QccErrorAddMessage("(QccWAVklttce3DForwardTransform): Error calling QccWAVSubbandPyramid3DSubbandOffsets()");          return(1);        }               for (frame = 0; frame < subband_num_frames; frame++)        {          max_coefficient = -MAXFLOAT;          for (row = 0; row < subband_num_rows; row++)            for (col = 0; col < subband_num_cols; col++)              {                coefficient_magnitude =                  fabs(image_subband_pyramid->volume                       [subband_origin_frame+frame]                       [subband_origin_row+row]                       [subband_origin_col+col]);                if (image_subband_pyramid->volume                    [subband_origin_frame+frame]                    [subband_origin_row+row]                    [subband_origin_col+col] !=                    coefficient_magnitude)                  {                    image_subband_pyramid->volume                      [subband_origin_frame+frame]                      [subband_origin_row+row]                      [subband_origin_col+col] =                      coefficient_magnitude;

⌨️ 快捷键说明

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