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

📄 tce3d.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-2009  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 QCCWAVTCE3D_BOUNDARY_VALUE (1e-6)//definition used in context information#define QCCWAVTCE3D_Z 0 //zero, AKA, insignificant#define QCCWAVTCE3D_NZN_NEW 2 //non-zero-neighbor#define QCCWAVTCE3D_S 3 //significant#define QCCWAVTCE3D_S_NEW 4#define QCCWAVTCE3D_NZN 5//ugly fix, use 1-D IIR filter to provide PMF estimate#define QCCWAVTCE3D_ALPHA_1D 0.995 #define QCCWAVTCE3D_ALPHA_1D_O 0.005#define QCCWAVTCE3D_REFINE_HOLDER 0.3 // threshold for cross-scale prediction...#define QCCWAVTCE3D_PREDICT_THRESHOLD 0.05  //weight factor for cross-scale and current scale#define QCCWAVTCE3D_CURRENT_SCALE 0.6 #define QCCWAVTCE3D_PARENT_SCALE 0.4#define QCCWAVTCE3D_MAXBITPLANES 128static int QccWAVtce3DEncodeBitPlaneInfo(QccBitBuffer *output_buffer,                                         int num_subbands,                                         int *max_coefficient_bits){  int subband;  int num_zeros = 0;    for (subband = 1; subband < num_subbands; subband++)    {      for (num_zeros = max_coefficient_bits[0] - 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 QccWAVtce3DDecodeBitPlaneInfo(QccBitBuffer *input_buffer,                                         int num_subbands,                                         int *max_bits,                                         int max_coefficient_bits){  int subband;  int bit_value;    max_bits[0] = max_coefficient_bits;    for (subband = 1; subband < num_subbands; subband++)    {      max_bits[subband] = max_coefficient_bits;      do        {          if (QccBitBufferGetBit(input_buffer,&bit_value))            return(1);          max_bits[subband]--;        }      while (bit_value == 0);      max_bits[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("(QccWAVtce3DUpdateModel): Error calling QccENTArithmeticSetModelProbabilities()");      return(1);    }    return(0);}static int QccWAVtce3DEncodeDWT(QccWAVSubbandPyramid3D *image_subband_pyramid,                                char ***sign_array,                                const QccIMGImageCube *image,                                int transform_type,                                int temporal_num_levels,                                int spatial_num_levels,                                double *image_mean,                                int *max_coefficient_bits,                                const QccWAVWavelet *wavelet){  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;    if (transform_type ==      QCCWAVSUBBANDPYRAMID3D_DYADIC)    num_subbands =      QccWAVSubbandPyramid3DNumLevelsToNumSubbandsDyadic(spatial_num_levels);  else    num_subbands =      QccWAVSubbandPyramid3DNumLevelsToNumSubbandsPacket(temporal_num_levels,                                                         spatial_num_levels);    if (QccVolumeCopy(image_subband_pyramid->volume,                    image->volume,                    image->num_frames,                    image->num_rows,                    image->num_cols))    {      QccErrorAddMessage("(QccWAVtce3DEncodeDWT): Error calling QccVolumeCopy()");      return(1);    }    if (QccWAVSubbandPyramid3DSubtractMean(image_subband_pyramid,                                         image_mean,                                         NULL))    {      QccErrorAddMessage("(QccWAVtce3DEncodeDWT): Error calling QccWAVSubbandPyramid3DSubtractMean()");      return(1);    }    if (QccWAVSubbandPyramid3DDWT(image_subband_pyramid,                                transform_type,                                temporal_num_levels,                                spatial_num_levels,                                wavelet))    {      QccErrorAddMessage("(QccWAVtce3DEncodeDWT): Error calling QccWAVSubbandPyramid3DDWT()");      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("(QccWAVtce3DEncodeDWT): Error calling QccWAVSubbandPyramid3DSubbandSize()");          return(1);        }      if (QccWAVSubbandPyramid3DSubbandOffsets(image_subband_pyramid,                                               subband,                                               &subband_origin_frame,                                               &subband_origin_row,                                               &subband_origin_col))        {          QccErrorAddMessage("(QccWAVtce3DEncodeDWT): Error calling QccWAVSubbandPyramid3DSubbandOffsets()");          return(1);        }            max_coefficient = -MAXFLOAT;            for (frame = 0; frame < subband_num_frames; frame++)        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;                  sign_array[subband_origin_frame+frame]                    [subband_origin_row + row]                    [subband_origin_col + col] = 1;                }              else                sign_array[subband_origin_frame+frame]                  [subband_origin_row + row]                  [subband_origin_col + col] = 0;                            if (coefficient_magnitude > max_coefficient)                max_coefficient = coefficient_magnitude;            }            max_coefficient_bits[subband] =         (int)floor(QccMathMax(0, QccMathLog2(max_coefficient + 0.0001)));    }    return(0);}int QccWAVtce3DEncodeHeader(QccBitBuffer *buffer,                             int transform_type,                            int temporal_num_levels,                            int spatial_num_levels,                            int num_frames,                            int num_rows,                            int num_cols,                            double image_mean,                            int *max_coefficient_bits,                            double alpha){  int return_value;    if (QccBitBufferPutBit(buffer, transform_type))    {      QccErrorAddMessage("(QccWAVTarp3DEncodeHeader): Error calling QccBitBufferPutBit()");      goto Error;    }    if (transform_type == QCCWAVSUBBANDPYRAMID3D_PACKET)    {      if (QccBitBufferPutChar(buffer, (unsigned char)temporal_num_levels))        {          QccErrorAddMessage("(QccWAVTarp3DEncodeHeader): Error calling QccBitBufferPuChar()");          goto Error;        }    }    if (QccBitBufferPutChar(buffer, (unsigned char)spatial_num_levels))    {      QccErrorAddMessage("(QccWAVTarp3DEncodeHeader): Error calling QccBitBufferPuChar()");      goto Error;    }    if (QccBitBufferPutInt(buffer, num_frames))    {      QccErrorAddMessage("(QccWAVTarp3DEncodeHeader): Error calling QccBitBufferPutInt()");      goto Error;    }    if (QccBitBufferPutInt(buffer, num_rows))    {      QccErrorAddMessage("(QccWAVTarp3DEncodeHeader): Error calling QccBitBufferPutInt()");      goto Error;    }    if (QccBitBufferPutInt(buffer, num_cols))    {      QccErrorAddMessage("(QccWAVTarp3DEncodeHeader): Error calling QccBitBufferPutInt()");      goto Error;    }    if (QccBitBufferPutDouble(buffer, image_mean))    {      QccErrorAddMessage("(QccWAVTarp3DEncodeHeader): Error calling QccBitBufferPutDouble()");      goto Error;    }    if (QccBitBufferPutInt(buffer, max_coefficient_bits[0]))    {      QccErrorAddMessage("(QccWAVTarp3DEncodeHeader): Error calling QccBitBufferPutInt()");      goto Error;    }    if (QccBitBufferPutDouble(buffer, alpha))    {      QccErrorAddMessage("(QccWAVTarpEncodeHeader3D): Error calling QccBitBufferPutDouble()");      goto Error;    }    return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);}static int QccWAVtce3DRevEst(QccWAVSubbandPyramid3D *coefficients,                             char ***significance_map,                             int subband,                             double *subband_significance,                             double ***p,                             double alpha){  int return_value;  int subband_origin_frame;  int subband_origin_row;  int subband_origin_col;  int subband_num_frames;  int subband_num_rows;  int subband_num_cols;  int frame,row, col;  int current_frame, current_row, current_col;  QccMatrix p1=NULL;  QccVector p2 = NULL;  QccMatrix p3=NULL;  QccMatrix p4=NULL;  QccVector p5 = NULL;  char *p_char;

⌨️ 快捷键说明

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