StdAfx.h
上传用户:szklck
上传日期:2007-01-22
资源大小:925k
文件大小:13k
源码类别:

图形图像处理

开发平台:

Visual C++

  1. // stdafx.h : include file for standard system include files,
  2. //  or project specific include files that are used frequently, but
  3. //      are changed infrequently
  4. //
  5. #if !defined(AFX_STDAFX_H__268251D4_7C24_486C_B4E9_B3B8F706FE26__INCLUDED_)
  6. #define AFX_STDAFX_H__268251D4_7C24_486C_B4E9_B3B8F706FE26__INCLUDED_
  7. #if _MSC_VER > 1000
  8. #pragma once
  9. #endif // _MSC_VER > 1000
  10. #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
  11. #include <afxwin.h>         // MFC core and standard components
  12. #include <afxext.h>         // MFC extensions
  13. #include <afxdisp.h>        // MFC Automation classes
  14. #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
  15. #ifndef _AFX_NO_AFXCMN_SUPPORT
  16. #include <afxcmn.h> // MFC support for Windows Common Controls
  17. #endif // _AFX_NO_AFXCMN_SUPPORT
  18. typedef struct{
  19.   int infile;                 // bit input 
  20.   unsigned char rdbfr[2051];  //缓冲的大小
  21.   unsigned char *rdptr;       //指向缓冲的指针
  22.   unsigned char inbfr[16];    //16维的字符数组
  23.   int incnt;                  //缓存中的比特数
  24.   int bitcnt;                 //
  25.   short block[12][64];        // block data 
  26. }ldecode;//base,*ld;
  27. //outtype
  28. #define T_YUV      0
  29. #define T_SIF      1
  30. #define T_TGA      2
  31. #define T_PPM      3
  32. #define T_X11      4
  33. #define T_YUV_CONC 5
  34. #define T_BMP      6
  35. typedef struct
  36. {
  37.    int val;
  38.    int run;
  39.    int sign;
  40. }RunCoef;
  41. static int convmat[8][4]=
  42. {
  43.   {117504, 138453, 13954, 34903}, /* no sequence_display_extension */
  44.   {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
  45.   {104597, 132201, 25675, 53279}, /* unspecified */
  46.   {104597, 132201, 25675, 53279}, /* reserved */
  47.   {104448, 132798, 24759, 53109}, /* FCC */
  48.   {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
  49.   {104597, 132201, 25675, 53279}, /* SMPTE 170M */
  50.   {117579, 136230, 16907, 35559}  /* SMPTE 240M (1987) */
  51. };
  52. #define SF_SQCIF                        1  /* 001 */
  53. #define SF_QCIF                         2  /* 010 */
  54. #define SF_CIF                          3  /* 011 */
  55. #define SF_4CIF                         4  /* 100 */
  56. #define SF_16CIF                        5  /* 101 */
  57. // Corresponds to CIF//////////////////////
  58. #define MBC_MAX                         22
  59. #define MBR_MAX                         18
  60. #define NO_VEC                          999
  61. ////////////////////////////////////////////
  62. #define MODE_INTER                      0
  63. #define MODE_INTER_Q                    1
  64. #define MODE_INTER4V                    2
  65. #define MODE_INTRA                      3
  66. #define MODE_INTRA_Q                    4
  67. #define SEC                             31
  68. #define PSC                 1
  69. #define PSC_LENGTH             17
  70. static int bquant_tab[]={5,6,7,8};
  71. static int bscan_tab[] ={2,4,6,8};
  72. static int roundtab[16]={0,0,0,1,1,1,1,1,1,1,1,1,1,1,2,2};
  73. static int OM[5][8][8]={
  74. {
  75.   {4,5,5,5,5,5,5,4},
  76.   {5,5,5,5,5,5,5,5},
  77.   {5,5,6,6,6,6,5,5},
  78.   {5,5,6,6,6,6,5,5},
  79.   {5,5,6,6,6,6,5,5},
  80.   {5,5,6,6,6,6,5,5},
  81.   {5,5,5,5,5,5,5,5},
  82.   {4,5,5,5,5,5,5,4},
  83. },{
  84.   {2,2,2,2,2,2,2,2},
  85.   {1,1,2,2,2,2,1,1},
  86.   {1,1,1,1,1,1,1,1},
  87.   {1,1,1,1,1,1,1,1},
  88.   {0,0,0,0,0,0,0,0},
  89.   {0,0,0,0,0,0,0,0},
  90.   {0,0,0,0,0,0,0,0},
  91.   {0,0,0,0,0,0,0,0},
  92. },{
  93.   {0,0,0,0,0,0,0,0},
  94.   {0,0,0,0,0,0,0,0},
  95.   {0,0,0,0,0,0,0,0},
  96.   {0,0,0,0,0,0,0,0},
  97.   {1,1,1,1,1,1,1,1},
  98.   {1,1,1,1,1,1,1,1},
  99.   {1,1,2,2,2,2,1,1},
  100.   {2,2,2,2,2,2,2,2},
  101. },{
  102.   {0,0,0,0,1,1,1,2},
  103.   {0,0,0,0,1,1,2,2},
  104.   {0,0,0,0,1,1,2,2},
  105.   {0,0,0,0,1,1,2,2},
  106.   {0,0,0,0,1,1,2,2},
  107.   {0,0,0,0,1,1,2,2},
  108.   {0,0,0,0,1,1,2,2},
  109.   {0,0,0,0,1,1,1,2},
  110. },{
  111.   {2,1,1,1,0,0,0,0},
  112.   {2,2,1,1,0,0,0,0},
  113.   {2,2,1,1,0,0,0,0},
  114.   {2,2,1,1,0,0,0,0},
  115.   {2,2,1,1,0,0,0,0},
  116.   {2,2,1,1,0,0,0,0},
  117.   {2,2,1,1,0,0,0,0},
  118.   {2,1,1,1,0,0,0,0},
  119. }};
  120. //霍夫曼编码
  121. typedef struct
  122. {
  123.   unsigned int code; //right justified 
  124.   char len;
  125. } VLCtable;
  126. //DCT编码系数表1
  127. static VLCtable DCT3Dtab0[]=
  128. {
  129. {4225,7}, {4209,7}, {4193,7}, {4177,7}, {193,7},  {177,7}, 
  130. {161,7},  {4,7},    {4161,6}, {4161,6}, {4145,6}, {4145,6}, 
  131. {4129,6}, {4129,6}, {4113,6}, {4113,6}, {145,6},  {145,6}, 
  132. {129,6},  {129,6},  {113,6},  {113,6},  {97,6},   {97,6}, 
  133. {18,6},   {18,6},   {3,6},    {3,6},    {81,5},   {81,5}, //5
  134. {81,5},   {81,5},   {65,5},   {65,5},   {65,5},   {65,5}, 
  135. {49,5},   {49,5},   {49,5},   {49,5},   {4097,4}, {4097,4}, 
  136. {4097,4}, {4097,4}, {4097,4}, {4097,4}, {4097,4}, {4097,4}, 
  137. {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, 
  138. {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, //10
  139. {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, 
  140. {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, 
  141. {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, 
  142. {1,2},  {1,2},  {17,3}, {17,3}, {17,3}, {17,3}, 
  143. {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3},//15 
  144. {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, 
  145. {33,4}, {33,4}, {33,4}, {33,4}, {33,4}, {33,4}, 
  146. {33,4}, {33,4}, {2,4},  {2,4},  {2,4},  {2,4},
  147. {2,4},  {2,4},  {2,4},  {2,4}   //19
  148. };
  149. //DCT编码系数表2
  150. static VLCtable DCT3Dtab1[]= 
  151. {
  152. {9,10},   {8,10},   {4481,9}, {4481,9}, {4465,9}, {4465,9}, 
  153. {4449,9}, {4449,9}, {4433,9}, {4433,9}, {4417,9}, {4417,9}, 
  154. {4401,9}, {4401,9}, {4385,9}, {4385,9}, {4369,9}, {4369,9}, 
  155. {4098,9}, {4098,9}, {353,9},  {353,9},  {337,9},  {337,9}, 
  156. {321,9},  {321,9},  {305,9},  {305,9},  {289,9},  {289,9}, //5
  157. {273,9},  {273,9},  {257,9},  {257,9},  {241,9},  {241,9}, 
  158. {66,9},   {66,9},   {50,9},   {50,9},   {7,9},    {7,9}, 
  159. {6,9},    {6,9},    {4353,8}, {4353,8}, {4353,8}, {4353,8}, 
  160. {4337,8}, {4337,8}, {4337,8}, {4337,8}, {4321,8}, {4321,8}, 
  161. {4321,8}, {4321,8}, {4305,8}, {4305,8}, {4305,8}, {4305,8}, //10
  162. {4289,8}, {4289,8}, {4289,8}, {4289,8}, {4273,8}, {4273,8}, 
  163. {4273,8}, {4273,8}, {4257,8}, {4257,8}, {4257,8}, {4257,8}, 
  164. {4241,8}, {4241,8}, {4241,8}, {4241,8}, {225,8},  {225,8}, 
  165. {225,8},  {225,8},  {209,8},  {209,8},  {209,8},  {209,8}, 
  166. {34,8},   {34,8},   {34,8},   {34,8},   {19,8},   {19,8}, //15
  167. {19,8},   {19,8},   {5,8},    {5,8},    {5,8},    {5,8} 
  168. };
  169. //DCT编码系数表3
  170. static VLCtable DCT3Dtab2[]=
  171. {
  172. {4114,11}, {4114,11}, {4099,11}, {4099,11}, {11,11}, 
  173. {11,11},   {10,11},   {10,11},   {4545,10}, {4545,10},
  174. {4545,10}, {4545,10}, {4529,10}, {4529,10}, {4529,10},
  175. {4529,10}, {4513,10}, {4513,10}, {4513,10}, {4513,10}, 
  176. {4497,10}, {4497,10}, {4497,10}, {4497,10}, {146,10},//5
  177. {146,10},  {146,10},  {146,10},  {130,10},  {130,10}, 
  178. {130,10},  {130,10},  {114,10},  {114,10},  {114,10}, 
  179. {114,10},  {98,10},   {98,10},   {98,10},   {98,10}, 
  180. {82,10},   {82,10},   {82,10},   {82,10},   {51,10},
  181. {51,10},   {51,10},   {51,10},   {35,10},   {35,10},//10
  182. {35,10},   {35,10},   {20,10},   {20,10},   {20,10}, 
  183. {20,10},   {12,11},   {12,11},   {21,11},   {21,11}, 
  184. {369,11},  {369,11},  {385,11},  {385,11},  {4561,11},
  185. {4561,11}, {4577,11}, {4577,11}, {4593,11}, {4593,11},
  186. {4609,11}, {4609,11}, {22,12},   {36,12},   {67,12}, //15
  187. {83,12},   {99,12},   {162,12},  {401,12},  {417,12},
  188. {4625,12}, {4641,12}, {4657,12}, {4673,12}, {4689,12},
  189. {4705,12}, {4721,12}, {4737,12}, {7167,7},  {7167,7},
  190. {7167,7},  {7167,7},  {7167,7},  {7167,7},  {7167,7}, 
  191. {7167,7},  {7167,7},  {7167,7},  {7167,7},  {7167,7}, //20
  192. {7167,7},  {7167,7},  {7167,7},  {7167,7},  {7167,7},
  193. {7167,7},  {7167,7},  {7167,7},  {7167,7},  {7167,7},
  194. {7167,7},  {7167,7},  {7167,7},  {7167,7},  {7167,7}, 
  195. {7167,7},  {7167,7},  {7167,7},  {7167,7},  {7167,7} 
  196. };
  197. #define deESCAPE                        7167
  198. #define ESCAPE_INDEX                    102
  199. #define PCT_INTER                       1
  200. #define PCT_INTRA                       0
  201. #define ON                              1
  202. #define OFF                             0
  203. #define PBMODE_NORMAL                   0
  204. #define PBMODE_MVDB                     1
  205. #define PBMODE_CBPB_MVDB                2
  206. //解码的vlc表
  207. static VLCtable TMNMVtab0[]= 
  208. {
  209. {3,4}, {61,4}, {2,3}, {2,3}, {62,3}, {62,3}, 
  210. {1,2}, {1,2}, {1,2},  {1,2}, {63,2}, {63,2}, 
  211. {63,2}, {63,2}
  212. };
  213.  
  214. static VLCtable TMNMVtab1[]= 
  215. {
  216. {12,10}, {52,10}, {11,10}, {53,10}, {10,9}, {10,9}, 
  217. {54,9},  {54,9},  {9,9},   {9,9},   {55,9}, {55,9}, 
  218. {8,9},  {8,9},  {56,9}, {56,9}, {7,7},  {7,7}, 
  219. {7,7},  {7,7},  {7,7},  {7,7},  {7,7},  {7,7}, 
  220. {57,7}, {57,7}, {57,7}, {57,7}, {57,7}, {57,7}, 
  221. {57,7}, {57,7}, {6,7},  {6,7},  {6,7},  {6,7}, 
  222. {6,7},  {6,7},  {6,7},  {6,7},  {58,7}, {58,7}, 
  223. {58,7}, {58,7}, {58,7}, {58,7}, {58,7}, {58,7}, 
  224. {5,7},  {5,7},  {5,7},  {5,7},  {5,7},  {5,7}, 
  225. {5,7},  {5,7},  {59,7}, {59,7}, {59,7}, {59,7}, 
  226. {59,7}, {59,7}, {59,7}, {59,7}, {4,6},  {4,6}, 
  227. {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, 
  228. {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, 
  229. {4,6}, {4,6}, {60,6},{60,6},{60,6},{60,6},
  230. {60,6},{60,6},{60,6},{60,6},{60,6},{60,6},
  231. {60,6},{60,6},{60,6},{60,6},{60,6},{60,6}
  232. };
  233. static VLCtable TMNMVtab2[]= 
  234. {
  235. {32,12}, {31,12}, {33,12}, {30,11}, {30,11}, {34,11}, 
  236. {34,11}, {29,11}, {29,11}, {35,11}, {35,11}, {28,11}, 
  237. {28,11}, {36,11}, {36,11}, {27,11}, {27,11}, {37,11}, 
  238. {37,11}, {26,11}, {26,11}, {38,11}, {38,11}, {25,11}, 
  239. {25,11}, {39,11}, {39,11}, {24,10}, {24,10}, {24,10}, 
  240. {24,10}, {40,10}, {40,10}, {40,10}, {40,10}, {23,10}, 
  241. {23,10}, {23,10}, {23,10}, {41,10}, {41,10}, {41,10}, 
  242. {41,10}, {22,10}, {22,10}, {22,10}, {22,10}, {42,10}, 
  243. {42,10}, {42,10}, {42,10}, {21,10}, {21,10}, {21,10}, 
  244. {21,10}, {43,10}, {43,10}, {43,10}, {43,10}, {20,10}, 
  245. {20,10}, {20,10}, {20,10}, {44,10}, {44,10}, {44,10}, 
  246. {44,10}, {19,10}, {19,10}, {19,10}, {19,10}, {45,10}, 
  247. {45,10}, {45,10}, {45,10}, {18,10}, {18,10}, {18,10}, 
  248. {18,10}, {46,10}, {46,10}, {46,10}, {46,10}, {17,10}, 
  249. {17,10}, {17,10}, {17,10}, {47,10}, {47,10}, {47,10}, 
  250. {47,10}, {16,10}, {16,10}, {16,10}, {16,10}, {48,10}, 
  251. {48,10}, {48,10}, {48,10}, {15,10}, {15,10}, {15,10}, 
  252. {15,10}, {49,10}, {49,10}, {49,10}, {49,10}, {14,10}, 
  253. {14,10}, {14,10}, {14,10}, {50,10}, {50,10}, {50,10}, 
  254. {50,10}, {13,10}, {13,10}, {13,10}, {13,10}, {51,10}, 
  255. {51,10}, {51,10}, {51,10}
  256. };
  257. //帧间编码色度块
  258. static VLCtable MCBPCtab[]= 
  259. {
  260. {ERROR,0},
  261. {255,9}, {52,9}, {36,9}, {20,9}, {49,9}, {35,8}, {35,8}, {19,8}, {19,8}, 
  262. {50,8},  {50,8}, {51,7}, {51,7}, {51,7}, {51,7}, {34,7}, {34,7}, {34,7}, 
  263. {34,7},  {18,7}, {18,7}, {18,7}, {18,7}, {33,7}, {33,7}, {33,7}, {33,7}, 
  264. {17,7},  {17,7}, {17,7}, {17,7}, {4,6},  {4,6},  {4,6},  {4,6},  {4,6}, 
  265. {4,6},   {4,6},  {4,6},  {48,6}, {48,6}, {48,6}, {48,6}, {48,6}, {48,6}, 
  266. {48,6},  {48,6}, {3,5},  {3,5},  {3,5},  {3,5},  {3,5},  {3,5},  {3,5}, 
  267. {3,5},  {3,5},  {3,5},  {3,5},  {3,5},  {3,5},  {3,5},  {3,5},  {3,5}, 
  268. {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, 
  269. {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, 
  270. {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, 
  271. {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {16,4}, {16,4}, {16,4}, {16,4}, 
  272. {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, 
  273. {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, 
  274. {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, 
  275. {16,4},{2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, 
  276. {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, 
  277. {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, 
  278. {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, 
  279. {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, 
  280. {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, 
  281. {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, 
  282. {2,3}, {2,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, 
  283. {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, 
  284. {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, 
  285. {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, 
  286. {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, 
  287. {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, 
  288. {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, 
  289. {1,3}, {1,3}, {1,3} 
  290. };
  291. //帧内编码色度块
  292. static VLCtable MCBPCtabintra[]=
  293. {
  294. {ERROR,0},
  295. {20,6}, {36,6}, {52,6}, {4,4},  {4,4},  {4,4}, 
  296. {4,4},  {19,3}, {19,3}, {19,3}, {19,3}, {19,3}, 
  297. {19,3}, {19,3}, {19,3}, {35,3}, {35,3}, {35,3}, 
  298. {35,3}, {35,3}, {35,3}, {35,3}, {35,3}, {51,3}, 
  299. {51,3}, {51,3}, {51,3}, {51,3}, {51,3}, {51,3}, 
  300. {51,3}
  301. };
  302. //亮度块的编码色
  303. static VLCtable CBPYtab[48]=
  304. { {ERROR,0}, {ERROR,0}, {9,6}, {6,6}, {7,5}, {7,5}, {11,5}, {11,5},
  305.   {13,5}, {13,5}, {14,5}, {14,5}, {15,4}, {15,4}, {15,4}, {15,4}, 
  306.   {3,4}, {3,4}, {3,4}, {3,4}, {5,4},{5,4},{5,4},{5,4},
  307.   {1,4}, {1,4}, {1,4}, {1,4}, {10,4}, {10,4}, {10,4}, {10,4},
  308.   {2,4}, {2,4}, {2,4}, {2,4}, {12,4}, {12,4}, {12,4}, {12,4}, 
  309.   {4,4}, {4,4}, {4,4}, {4,4}, {8,4}, {8,4}, {8,4}, {8,4} 
  310. };
  311. //{{AFX_INSERT_LOCATION}}
  312. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  313. #endif // !defined(AFX_STDAFX_H__268251D4_7C24_486C_B4E9_B3B8F706FE26__INCLUDED_)