大头
Table_bottom

标签云
Table_bottom

分类
Table_bottom

日历
二月
28293031123
45678910
11121314151617
18192021222324
252627282912
Table_bottom

评论
Table_bottom

留言
Table_bottom

微博
Table_bottom

热门文章
Table_bottom

随机文章
Table_bottom

豆瓣上谁关注这里
Table_bottom

链接
Table_bottom

搜索栏
Table_bottom

RSS
RSS Link
Table_bottom

功能
Table_bottom

页面
Table_bottom

计数器
462731
Table_bottom

访客统计
Table_bottom

存档
Table_bottom

rgb to yuv

 

  1. void RGB2YUV(BYTE *in, BYTE *out, DWORD len)
  2. {
  3.         int r,g,b;
  4.         int y, cb,cr;
  5.         int i;
  6.         int data;
  7.  
  8.         for(i=0; i<len; i=i+4)
  9.         {
  10.                 r = *(in+2);
  11.                 g = *(in+1);
  12.                 b = *(in);
  13.  
  14.                 y= (0.257*r + 0.504*g + 0.098*b + 16);
  15.                 cb = -0.148*r - 0.291*g + 0.439*b + 128;
  16.                 cr = 0.439*r - 0.368*g - 0.071*b + 128;
  17.                 if(y <16)
  18.                 {
  19.                         y = 16;
  20.                 }
  21.                 else if(y>235)
  22.                 {
  23.                         y = 235;
  24.                 }
  25.  
  26.                 if(cb <16)
  27.                 {
  28.                         cb = 16;
  29.                 }
  30.                 else if(cb>240)
  31.                 {
  32.                         cb = 240;
  33.                 }
  34.  
  35.                 if(cr <16)
  36.                 {
  37.                         cr = 16;
  38.                 }
  39.                 else if(cr>240)
  40.                 {
  41.                         cr = 240;
  42.                 }
  43.                 *(DWORD *)out = 0x7f000000 + ((DWORD)cr<<16) + ((DWORD)cb<<8) + (DWORD)y;
  44.  
  45.                 in += 4;
  46.                 out += 4;
  47.         }
  48. }

 

Windows 98 源代码

 

  1. /*
  2. 微软最高机密——Windows 98 源代码
  3. 项目:Chicago(tm)
  4. 项目发行日期:1998年夏天
  5. */
  6.  
  7. #include "win31.h"
  8. #include "win95.h"
  9. #include "evenmore.h"
  10. #include "oldstuff.h"
  11. #include "billrulz.h"
  12. #define INSTALL = HARD
  13.  
  14. char make_prog_look_big[1600000]; /*使程序看起来很大*/
  15.  
  16. void main()
  17. {
  18.  while(!CRASHED) {  /*如果不崩溃*/
  19.   display_copyright_message();  /*显示版权信息*/
  20.   display_bill_rules_message();  /*显示比尔的规则的信息*/
  21.   do_nothing_loop();        /*进行空循环*/
  22.   if (first_time_installation) {  /*如果是第一次安装*/
  23.    make_50_megabyte_swapfile();   /*创建50M的交换文件*/
  24.    do_nothing_loop();        /*进行空循环*/
  25.    totally_screw_up_HPFS_file_system(); /*将HPFS文件系统完全搞乱*/
  26.    search_and_destroy_the_rest_of_OS/2(); /*搜寻并删除OS/2的所有残余信息*/
  27.    hang_system();  /*挂起系统*/
  28.    }
  29.   write_something(anything); /*随便写一些信息*/
  30.   display_copyright_message(); /*显示版权信息*/
  31.   do_nothing_loop();  /*进行空循环*/
  32.   do_some_stuff();
  33.   if (still_not_crashed) {  /*如果还没崩溃*/
  34.    display_copyright_message(); /*显示版权信息*/
  35.    do_nothing_loop();    /*进行空循环*/
  36.    basically_run_windows_3.1(); /*基本上运行Windows 3.1*/
  37.    do_nothing_loop();  /*进行空循环*/
  38.    do_nothing_loop();  /*进行空循环*/
  39.    }
  40.   }
  41.  
  42.  if (detect_cache()) /*如果检测到缓存*/
  43.   disable_cache();  /*使缓存失效*/
  44.  
  45.  if (fast_cpu()) {  /*如果CPU很快*/
  46.   set_wait_states(lots); /*设置等待状态*/
  47.   set_mouse(speed, very_slow); /*设置鼠标(速度很慢)*/
  48.   set_mouse(action, jumpy);  /*设置鼠标(动作跳跃)*/
  49.   set_mouse(reaction, sometimes); /*设置鼠标(有时反应)*/
  50.   }
  51.  
  52. /* printf("Welcome to Windows 3.11"); */
  53. /* printf("Welcome to Windows 95"); */
  54.  
  55.  printf("Welcome to Windows 98"); /*输出“欢迎使用Windows 98”*/
  56.  
  57.  if (system_ok()) /*如果系统正常*/
  58.   crash(to_dos_prompt); /*崩溃(到DOS提示符)*/
  59.  else
  60.   system_memory = open("a:\swp0001.swp", O_CREATE);
  61.   /*否则打开a:\swp0001.swp作为系统内存*/
  62.  
  63.  while(something) {
  64.   sleep(5);   /*睡眠5秒钟*/
  65.   get_user_input(); /*接收用户输入*/
  66.   sleep(5);   /*睡眠5秒钟*/
  67.   act_on_user_input(); /*对用户输入起反应*/
  68.   sleep(5);   /*睡眠5秒钟*/
  69.   }
  70.  
  71.  create_general_protection_fault(); /*产生一般保护错误*/
  72.  blue_screnn(); /*蓝屏*/
  73. }
  74.  

 

补充编译警告

在实际的工程中,往往会出现callback函数的参数类型,定义和实际使用的并不一致。要注意强制类型转换。

在某个 struct 定义中使用了 union,而此 union 中定义了两个结构,第一个结构包含5个 UINT8 类型的成员,第二个结构包含1个指针类型成员,1个 UINT16 类型成员,1个 UINT8 类型成员。工程中两个结构都会使用到,而编译器无法知道程序使用的是 union 中的哪一个成员,默认为第一个。由此产生类型不匹配的编译警告,这里有产生错误的隐患。

一些资源

http://digilander.libero.it/robang/rubrica/serial.htm  --  Serial Programming Guide for POSIX Operating Systems

http://www.embed.com.cn/bbs/index.asp  --  嵌入开发网

http://www.lysator.liu.se/c/ANSI-C-grammar-y.html  --  ANSI C Yacc grammar

http://www.51eda.com/bbs/index.asp  --  中国EDA技术网

http://bbs.driverdevelop.com/columns.php?action=columns  --  驱动开发网

http://www.linuxpilot.net.cn/  --  Linux Pilot

http://www.linuxworld.com/  --  linux world

http://www.linuxjournal.com/  --  linux journal

http://www.salon.com/tech/special/opensource/  --  the free software story

http://www.gentoo.org/  --  gentoo linux

http://www.linuxfocus.org/  --  linux focus

http://www.debian.org/intl/zh/mailing_lists  --  Debian 中文计划邮件列表

http://www.debian.org/MailingLists/  --  debian Mailing Lists

http://www.sgi.com/tech/stl/  --  Standard Template Library Programmer's Guide