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

📄 wdrdecode.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
字号:
/* * * 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. * *//* *  This code was written by Yufei Yuan <yuanyufei@hotmail.com> */#include "wdrdecode3d.h"#define USG_STRING "[-w %s:wavelet] [-b %s:boundary] [-pw %: %s:pcpfile] [-m %: %s:mask] [-r %: %f:rate] %s:bitstream %s:imgfile"QccWAVWavelet Wavelet;QccString WaveletFilename = QCCWAVWAVELET_DEFAULT_WAVELET;QccString Boundary = "symmetric";QccWAVPerceptualWeights PerceptualWeights;int UsePerceptualWeights = 0;int NumLevels;int NumSubbands;QccBitBuffer InputBuffer;int NumRows, NumCols;QccIMGImage OutputImage;double ImageMean;int MaxCoefficientBits;QccIMGImage Mask;int MaskSpecified = 0;int MaskNumRows, MaskNumCols;float Rate;int RateSpecified;int NumPixels;int TargetBitCnt;int main(int argc, char *argv[]){  int row, col;  QccInit(argc, argv);    QccWAVWaveletInitialize(&Wavelet);  QccWAVPerceptualWeightsInitialize(&PerceptualWeights);  QccIMGImageInitialize(&OutputImage);  QccIMGImageInitialize(&Mask);  QccBitBufferInitialize(&InputBuffer);    if (QccParseParameters(argc, argv, USG_STRING,                         WaveletFilename,                         Boundary,                         &UsePerceptualWeights,                         PerceptualWeights.filename,                         &MaskSpecified,                         Mask.filename,                         &RateSpecified,                         &Rate,                         InputBuffer.filename,                         OutputImage.filename))    QccErrorExit();    if (QccWAVWaveletCreate(&Wavelet, WaveletFilename, Boundary))    {      QccErrorAddMessage("%s: Error calling QccWAVWaveletCreate()", argv[0]);      QccErrorExit();    }    InputBuffer.type = QCCBITBUFFER_INPUT;  if (QccBitBufferStart(&InputBuffer))    {      QccErrorAddMessage("%s: Error calling QccBitBufferStart()", argv[0]);      QccErrorExit();    }    if (QccWAVwdrDecodeHeader(&InputBuffer,                            &NumLevels,                            &NumRows,                            &NumCols,                            &ImageMean,                            &MaxCoefficientBits))    {      QccErrorAddMessage("%s: Error calling QccWAVwdrDecodeHeader()", argv[0]);      QccErrorExit();    }  NumSubbands = QccWAVSubbandPyramidNumLevelsToNumSubbands(NumLevels);    if (MaskSpecified)    {      if (QccIMGImageRead(&Mask))        {          QccErrorAddMessage("%s: Error calling QccIMGImageRead()", argv[0]);          QccErrorExit();        }      if (QccIMGImageColor(&Mask))        {          QccErrorAddMessage("%s: Mask must be grayscale", argv[0]);          QccErrorExit();        }      if (QccIMGImageGetSize(&Mask, &MaskNumRows, &MaskNumCols))        {          QccErrorAddMessage("%s: Error calling QccIMGImageGetSize()",                             argv[0]);          QccErrorExit();        }            if ((MaskNumRows != NumRows) || (MaskNumCols != NumCols))        {          QccErrorAddMessage("%s: Mask must be same size as image", argv[0]);          QccErrorExit();        }      NumPixels = 0;      for (row = 0; row < MaskNumRows; row++)        for (col = 0; col < MaskNumCols; col++)          if (!QccAlphaTransparent(Mask.Y.image[row][col]))            NumPixels++;    }  else    NumPixels = NumRows * NumCols;    if (QccIMGImageDetermineType(&OutputImage))    {      QccErrorAddMessage("%s: Error calling QccIMGImageDetermineType()",                         argv[0]);      QccErrorExit();    }  if (QccIMGImageColor(&OutputImage))    {      QccErrorAddMessage("%s: Output image must be grayscale",                         argv[0]);      QccErrorExit();    }  if (QccIMGImageSetSize(&OutputImage, NumRows, NumCols))    {      QccErrorAddMessage("%s: Error calling QccIMGImageSetSize()",                         argv[0]);      QccErrorExit();    }  if (QccIMGImageAlloc(&OutputImage))    {      QccErrorAddMessage("%s: Error calling QccIMGImageAlloc()", argv[0]);      QccErrorExit();    }    if (UsePerceptualWeights)    {      if (QccWAVPerceptualWeightsRead(&PerceptualWeights))        {          QccErrorAddMessage("%s: Error calling QccWAVPerceptualWeightsRead()",                             argv[0]);          QccErrorExit();        }      if (PerceptualWeights.num_subbands != NumSubbands)        {          QccErrorAddMessage("%s: Number of subbands in %s does not match that specified in %s",                             argv[0],                             PerceptualWeights.filename, InputBuffer.filename);        }    }    if (!RateSpecified)    TargetBitCnt = QCCENT_ANYNUMBITS;  else    TargetBitCnt = (int)(ceil((NumPixels * Rate)/8.0))*8;    if (QccWAVwdrDecode(&InputBuffer,                      &(OutputImage.Y),                      (MaskSpecified ? &(Mask.Y) : NULL),                      NumLevels,                      &Wavelet,                      ((UsePerceptualWeights) ? &PerceptualWeights : NULL),                      ImageMean,                      MaxCoefficientBits,                      TargetBitCnt))    {      QccErrorAddMessage("%s: Error calling QccWAVwdrDecode()", argv[0]);      QccErrorExit();    }    if (QccIMGImageWrite(&OutputImage))    {      QccErrorAddMessage("%s: Error calling QccIMGImageWrite()", argv[0]);      QccErrorExit();    }    if (QccBitBufferEnd(&InputBuffer))    {      QccErrorAddMessage("%s: Error calling QccBitBufferEnd()", argv[0]);      QccErrorExit();    }    QccWAVWaveletFree(&Wavelet);  QccWAVPerceptualWeightsFree(&PerceptualWeights);  QccIMGImageFree(&OutputImage);  QccIMGImageFree(&Mask);  QccExit;}

⌨️ 快捷键说明

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