📄 sp_comm.c
字号:
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = *//* S + P I M A G E C O M P R E S S I O N *//* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = *//* > > > > > ANSI C version 1.06 - 05/30/95 < < < < < *//* File shared by the encoder and decoder *//* 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - */#include <string.h>#include <time.h>/* - - Definitions - - - - - - - - - - - - - - - - - - - - - - - - - - */#define KEY_2 0x55#define KEY_3 0x52#ifndef CLOCKS_PER_SEC#define CLOCKS_PER_SEC 1e6#endif#define NumbSets 28typedef struct { int x, y;} Image_Coord;typedef struct { int bias, bits;} Set_Data;/* - - Static variables - - - - - - - - - - - - - - - - - - - - - - - */char * m_msg = "insufficient memory";char line[80];int * buffer[2], smooth_image = 0;Set_Data set_table[NumbSets];/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *//* - - Functions - - - - - - - - - - - - - - - - - - - - - - - - - - - */void Error(char * s){ printf("\n\aError: %s\n", s); exit(1);}/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */void Construct_Set_Table(void){ int i, k, b, m; set_table[0].bias = set_table[0].bits = 0; for (i = 1; i < 4; i++) { set_table[i].bias = i; set_table[i].bits = 1; } m = 2; k = 2; for (b = i = 4; i < NumbSets; i++, m++) { set_table[i].bias = b; set_table[i].bits = m; set_table[++i].bias = b + k; set_table[i].bits = m; k = b; b <<= 1; }}/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */int Set(int n){ int k; if (n < 0) n = -n; if (n < 4) return n; for (k = 5; n >= set_table[k].bias; ++k) ; return --k;}/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */void Select_Quadrant(int q, Image_Coord s, Image_Coord * min, Image_Coord * max){ switch (q) { case 0 : min->x = min->y = 0; break; case 1 : min->x = 0; min->y = s.y; break; case 2 : min->x = s.x; min->y = 0; break; case 3 : min->x = s.x; min->y = s.y; } max->x = min->x + s.x; max->y = min->y + s.y;}/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = *//* end of file < sp_comm.c > */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -