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

📄 chngolombencode.c

📁 QccPack-0.54-1 released (2007-04-30) is being developed and tested on Fedora Core Linux. QccPack pro
💻 C
字号:
/* * * 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. * *//* *  This code was written by Yufei Yuan <yuanyufei@hotmail.com> */#include "chngolombencode.h"#define USG_STRING "[-s %:] [-vo %:] [-p %f:prob] [-m %d:m] %s:channel %s:bitstream"QccChannel Channel;QccBitBuffer OutputBuffer;int Silent = 0;int ValueOnly = 0;float Prob = 0;int M = 0;int main(int argc, char *argv[]){  double rate;    QccInit(argc, argv);    QccChannelInitialize(&Channel);  QccBitBufferInitialize(&OutputBuffer);    if (QccParseParameters(argc, argv,                         USG_STRING,                         &Silent,                         &ValueOnly,                         &Prob,                         &M,                         Channel.filename,                         OutputBuffer.filename))    QccErrorExit();    if (QccChannelReadWholefile(&Channel))    {      QccErrorAddMessage("%s: Error calling QccChannelReadWholefile()",                         argv[0]);      QccErrorExit();    }    if (Channel.alphabet_size != 2)    {      QccErrorAddMessage("%s: Channel must contain only binary symbols (zeros and ones)",                         argv[0]);      QccErrorExit();    }    if (QccChannelRemoveNullSymbols(&Channel))    {      QccErrorAddMessage("%s: Error calling QccChannelRemoveNullSymbols()",                         argv[0]);      QccErrorExit();    }    OutputBuffer.type = QCCBITBUFFER_OUTPUT;  if (QccBitBufferStart(&OutputBuffer))    {      QccErrorAddMessage("%s: Error calling QccBitBufferStartup()",                         argv[0]);      QccErrorExit();    }    if (QccBitBufferPutInt(&OutputBuffer, Channel.channel_length))    {      QccErrorAddMessage("%s: Error calling QccBitBufferPutInt()",                         argv[0]);      QccErrorExit();    }    if (QccENTGolombEncodeChannel(&Channel,                                &OutputBuffer,                                (Prob == 0) ? NULL : &Prob,                                (M == 0) ? NULL : &M))    {      QccErrorAddMessage("%s: Error calling QccENTGolombEncodeChannel()",                         argv[0]);      QccErrorExit();    }    if (QccBitBufferFlush(&OutputBuffer))    {      QccErrorAddMessage("%s: Error calling QccBitBufferFlush()",                         argv[0]);      QccErrorExit();    }    if (QccBitBufferEnd(&OutputBuffer))    {      QccErrorAddMessage("%s: Error calling QccBitBufferEnd()",                         argv[0]);      QccErrorExit();    }    rate = (double)(OutputBuffer.bit_cnt) / Channel.channel_length;    if (!Silent)    {      if (ValueOnly)        printf("%f\n", rate);      else        {          printf("Channel %s coded to:\n %f (bits/symbol)\n",                 Channel.filename, rate);          printf("using Golomb runlength coding.\n");        }    }    QccExit;}

⌨️ 快捷键说明

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