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

📄 sp_unpack.c

📁 常用的无损压缩算法源代码
💻 C
字号:
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = *//*               S + P   I M A G E   C O M P R E S S I O N             *//* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = *//*     > > > > >    ANSI C version  2.06  -  05/30/95    < < < < <     *//*                       Huffman code version                          *//*   Amir Said - amir@densis.fee.unicamp.br                            *//*   Faculty of Electrical Engineering                                 *//*   University of Campinas (UNICAMP) - Campinas, SP 13081, Brazil     *//*   William A. Pearlman - pearlman@ecse.rpi.edu                       *//*   Dept. of Electrical, Computer, and Systems Engineering            *//*   Rensselaer Polytechnic Institute - Troy, NY 12180, USA            *//*     Copyright (c) 1995 Amir Said & William A. Pearlman              *//*   This program is Copyright (c) by Amir Said and William A. Pearlman.   It may be freely redistributed in its entirety provided that this   copyright notice is not removed. It may not be sold for profit or   incorporated in commercial programs without the written permission   of the copyright holders. This program is provided as is, without   any express or implied warranty, without even the warranty of   fitness for a particular purpose.*//* - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - */#define KEY_1 0xB4#include "huffman.h"#include "sp_comm.c"#include "sp_decd.c"/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *//* - - Implementations - - - - - - - - - - - - - - - - - - - - - - - - */void Decode_Quadrant(int q, Image_Coord d, int ** cf){  int i, j, c, v, s;  Image_Coord min, max;  Select_Quadrant(q, d, &min, &max);  Read_Code(&code_file);  for (i = min.x; i < max.x; i++)    for (j = min.y; j < max.y; j++)      if (s = Read_Symbol(&code_file)) {        c = Read_Bits(&code_file, set_table[s].bits);        v = (c >> 1) + set_table[s].bias;        cf[i][j] = (c & 1 ? -v : v); }      else        cf[i][j] = 0;}/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */int ** Decode_Image(int lv, Image_Coord d){  int ** cf, i, k;  if ((cf = (int **) malloc(d.x * sizeof(int *))) == NULL)    Error(m_msg);  for (k = 0; k < d.x; k++)    if ((cf[k] = (int *) malloc(d.y * sizeof(int))) == NULL)      Error(m_msg);  k = 1 + (d.x > d.y ? d.x : d.y);  for (i = 0; i <= 1; i++)    if ((buffer[i] = (int *) malloc(k * sizeof(int))) == NULL)      Error(m_msg);  lv -= 2;  d.x >>= lv;  d.y >>= lv;  Decode_Quadrant(0, d, cf);  for (i = lv - 1; i >= 0; i--) {    for (k = 1; k <= 3; k++) {      Decode_Quadrant(k, d, cf); }    d.x <<= 1;  d.y <<= 1; }  return cf;}/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = *//* end of file < sp_unpack.c > */

⌨️ 快捷键说明

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