home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dive1.zip / FOURCC.H < prev    next >
C/C++ Source or Header  |  1995-12-08  |  11KB  |  251 lines

  1. /*****************************************************************************\
  2. *
  3. * Module Name: FOURCC.H
  4. *
  5. * OS/2 Warp Multimedia Extensions Color space definitions
  6. *
  7. * Copyright (c) International Business Machines Corporation 1993, 1995
  8. *                         All Rights Reserved
  9. *
  10. *
  11. \*****************************************************************************/
  12. #ifdef __cplusplus
  13.    extern "C" {
  14. #endif
  15.  
  16.  
  17. #ifndef _FOURCC_H_
  18. #define _FOURCC_H_
  19.  
  20. #define FOURCC_SCRN  0
  21. #define FOURCC_R565  mmioFOURCC( 'R', '5', '6', '5' )
  22. #define FOURCC_R555  mmioFOURCC( 'R', '5', '5', '5' )
  23. #define FOURCC_R664  mmioFOURCC( 'R', '6', '6', '4' )
  24. #define FOURCC_RGB3  mmioFOURCC( 'R', 'G', 'B', '3' )
  25. #define FOURCC_BGR3  mmioFOURCC( 'B', 'G', 'R', '3' )
  26. #define FOURCC_RGB4  mmioFOURCC( 'R', 'G', 'B', '4' )
  27. #define FOURCC_BGR4  mmioFOURCC( 'B', 'G', 'R', '4' )
  28. #define FOURCC_LUT8  mmioFOURCC( 'L', 'U', 'T', '8' )
  29. #define FOURCC_LT12  mmioFOURCC( 'L', 'T', '1', '2' )
  30. #define FOURCC_GREY  mmioFOURCC( 'G', 'R', 'E', 'Y' )
  31. #define FOURCC_GY16  mmioFOURCC( 'G', 'Y', '1', '6' )
  32. #define FOURCC_Y888  mmioFOURCC( 'Y', '8', '8', '8' )
  33. #define FOURCC_Y2X2  mmioFOURCC( 'Y', '2', 'X', '2' )
  34. #define FOURCC_Y4X4  mmioFOURCC( 'Y', '4', 'X', '4' )
  35. #define FOURCC_YUV9  mmioFOURCC( 'Y', 'U', 'V', '9' )
  36. #define FOURCC_Y644  mmioFOURCC( 'Y', '6', '4', '4' )
  37. #define FOURCC_MONO  mmioFOURCC( 'M', 'O', 'N', 'O' )
  38. #define FOURCC_Y422  mmioFOURCC( 'Y', '4', '2', '2' )
  39. #define FOURCC_Y42B  mmioFOURCC( 'Y', '4', '2', 'B' )
  40. #define FOURCC_Y42D  mmioFOURCC( 'Y', '4', '2', 'D' )
  41. #define FOURCC_Y411  mmioFOURCC( 'Y', '4', '1', '1' )
  42. #define FOURCC_VGA   mmioFOURCC( 'V', 'G', 'A', ' ' )
  43.  
  44.  
  45.  
  46.  
  47. /******************************************************************************
  48.  
  49.  DIVE color format definitions:
  50.  
  51.    FOURCC_SCRN : Use the fourcc of the screen, typically LUT8, R565, or BGR3.
  52.  
  53.    FOURCC_R565 : This is single plane two byte per pixel format:
  54.                  in USHORT: "rrrr rggg  gggb bbbb"
  55.                             "4321 0543  2104 3210"
  56.                  in memory: "gggb bbbb  rrrr rggg"
  57.                             "2104 3210  4321 0543"
  58.  
  59.    FOURCC_R555 : This is single plane two byte per pixel format:
  60.                  in USHORT: "xrrr rrgg  gggb bbbb"
  61.                             "-432 1043  2104 3210"
  62.                  in memory: "gggb bbbb  xrrr rrgg"
  63.                             "2104 3210  -432 1043"
  64.  
  65.    FOURCC_R664 : This is single plane two byte per pixel format:
  66.                  in USHORT: "rrrr rrgg  gggg bbbb"
  67.                             "5432 1054  3210 3210"
  68.                  in memory: "gggg bbbb  rrrr rrgg"
  69.                             "3210 3210  5432 1054"
  70.  
  71.    FOURCC_RGB3 : This is single plane three byte per pixel format:
  72.                  in ULONG:  "xxxx xxxx  bbbb bbbb  gggg gggg  rrrr rrrr"
  73.                             "---- ----  7654 3210  7654 3210  7654 3210"
  74.                  in memory: "rrrr rrrr  gggg gggg  bbbb bbbb"
  75.                             "7654 3210  7654 3210  7654 3210"
  76.  
  77.    FOURCC_BGR3 : This is single plane three byte per pixel format:
  78.                  in ULONG:  "xxxx xxxx  rrrr rrrr  gggg gggg  bbbb bbbb"
  79.                             "---- ----  7654 3210  7654 3210  7654 3210"
  80.                  in memory: "bbbb bbbb  gggg gggg  rrrr rrrr"
  81.                             "7654 3210  7654 3210  7654 3210"
  82.  
  83.    FOURCC_RGB4 : This is single plane four byte per pixel format:
  84.                  in ULONG:  "0000 0000  bbbb bbbb  gggg gggg  rrrr rrrr"
  85.                             "---- ----  7654 3210  7654 3210  7654 3210"
  86.                  in memory: "rrrr rrrr  gggg gggg  bbbb bbbb  0000 0000"
  87.                             "7654 3210  7654 3210  7654 3210  ---- ----"
  88.  
  89.    FOURCC_BGR4 : This is single plane four byte per pixel format:
  90.                  in ULONG:  "0000 0000  rrrr rrrr  gggg gggg  bbbb bbbb"
  91.                             "---- ----  7654 3210  7654 3210  7654 3210"
  92.                  in memory: "bbbb bbbb  gggg gggg  rrrr rrrr  0000 0000"
  93.                             "7654 3210  7654 3210  7654 3210  ---- ----"
  94.  
  95.    FOURCC_LUT8 : This is a single plane one byte per pixel format:
  96.                  in BYTE:   "7654 3210"
  97.                  in memory: "7654 3210"
  98.                  An 256 entry BGR4 palette represents the lookup table.
  99.  
  100.    FOURCC_LT12 : This is a single plane two byte per pixel format:
  101.                  in USHORT: "0000 ba98  7654 3210"
  102.                  in memory: "7654 3210  0000 ba98"
  103.                  An 4096 entry BGR4 palette represents the lookup table.
  104.  
  105.    FOURCC_Y888 : This is a three plane one byte per component pixel format:
  106.                  ┌──────────────┐
  107.                  │              │     In Y888, each of the three consecutive
  108.                  │      Y       │     planse are of the same size (i.e. the
  109.                  │   [0..255]   │     chrominance planes are not subsampled).
  110.                  │  7654  3210  │
  111.                  └──────────────┘     Normal CCIR601 conversions apply:
  112.                  ┌──────────────┐     R = Y + ( Cr - 128 ) * 1.370
  113.                  │      Cr      │     G = Y - ( Cb - 128 ) * 0.336
  114.                  │   [0..255]   │           - ( Cr - 128 ) * 0.698
  115.                  │ center = 128 │     B = Y + ( Cb - 128 ) * 1.730
  116.                  │  7654  3210  │
  117.                  └──────────────┘     Y = R * 0.299 + G * 0.587 + B * 0.114
  118.                  ┌──────────────┐         U = ( B - Y ) * 0.492
  119.                  │      Cb      │         V = ( R - Y ) * 0.877
  120.                  │   [0..255]   │     Cb = U + 128
  121.                  │ center = 128 │     Cr = V + 128
  122.                  │  7654  3210  │
  123.                  └──────────────┘
  124.  
  125.    FOURCC_Y2X2 : This is a three plane one byte per component pixel format:
  126.                  ┌────┐
  127.                  │    │   Same as Y888, except that the Cr and Cb planes
  128.                  │    │   are subsampled 2x2.
  129.                  └────┘
  130.                  ┌──┐
  131.                  │  │
  132.                  └──┘
  133.                  ┌──┐
  134.                  │  │
  135.                  └──┘
  136.  
  137.    FOURCC_Y4X4 : This is a three plane one byte per component pixel format:
  138.                  ┌────┐
  139.                  │    │   Same as Y888, except that the Cr and Cb planes
  140.                  │    │   are subsampled 4x4.
  141.                  └────┘
  142.                  ┌┐
  143.                  └┘
  144.                  ┌┐
  145.                  └┘
  146.  
  147.    FOURCC_YUV9 : This is a three plane one byte per component pixel format:
  148.                  Same as Y4X4.
  149.  
  150.    FOURCC_Y644 : This is a two plane one byte per component pixel format:
  151.                  ┌────┐
  152.                  │    │   The first plane is a Y plane: "00YY YYYY" "--54 3210"
  153.                  │    │   The second plane a UV combined plane, and it
  154.                  └────┘      is 4x4 subsampled: "UUUU VVVV" "3210 3210"
  155.                  ┌┐          To convert from the four-bit chrominance
  156.                  └┘          components to normal 8-bit, do:
  157.                                  U = 6.375 * ( U' - 5 )
  158.                                  V = 7.500 * ( V' - 6 )
  159.  
  160.    FOURCC_MONO : This is a single plane one bit per pixel format:
  161.                  ┌────┐
  162.                  │    │   Each byte is "0123 4567" in pixel order left to
  163.                  │    │   right where a zero bit corresponds to black and
  164.                  └────┘   a one bit corresponds to white.
  165.  
  166.    FOURCC_Y422 : This is a single plane three component interleaved format:
  167.                  ┌────┐
  168.                  │    │   "yyyy yyyy" "uuuu uuuu" "yyyy yyyy" "vvvv vvvv"
  169.                  │    │   "7654 3210" "7654 3210" "7654 3210" "7654 3210"
  170.                  └────┘   where each of the above repeating groups represent
  171.                           two pixels.  The left Y, the U and the V combine to
  172.                           form the left CCIR601 color, and the right Y, the
  173.                           U and the V combine to form the right.  This is
  174.                           effectively a 2x1 subsampling.
  175.  
  176.    FOURCC_Y42B : Same as FOURCC_Y422, except byte swapped within words:
  177.                  ┌────┐
  178.                  │    │   "uuuu uuuu" "yyyy yyyy" "vvvv vvvv" "yyyy yyyy"
  179.                  │    │   "7654 3210" "7654 3210" "7654 3210" "7654 3210"
  180.                  └────┘
  181.  
  182.    FOURCC_Y42D : Same as FOURCC_Y422, except byte swapped within DWORDs:
  183.                  ┌────┐
  184.                  │    │   "vvvv vvvv" "yyyy yyyy" "uuuu uuuu" "yyyy yyyy"
  185.                  │    │   "7654 3210" "7654 3210" "7654 3210" "7654 3210"
  186.                  └────┘
  187.  
  188.    FOURCC_Y411 : This is a single plane three component interleaved format:
  189.                  ┌────┐
  190.                  │    │   Use four consecutive 2-byte words as four pixels.
  191.                  │    │   The is effectively a 4x1 subsampling.  Each word
  192.                  └────┘   has it's own 7-bit luminance and a chrominance part:
  193.  
  194.               Cb6:Cb5:Cr6:Cr5:???:???:???:???  Ya6:Ya5:Ya4:Ya3:Ya2:Ya1:Ya0:???
  195.               Cb4:Cb3:Cr4:Cr3:???:???:???:???  Yb6:Yb5:Yb4:Yb3:Yb2:Yb1:Yb0:???
  196.               Cb2:Cb1:Cr2:Cr1:???:???:???:???  Yc6:Yc5:Yc4:Yc3:Yc2:Yc1:Yc0:???
  197.               Cb0:???:Cr0:???:???:???:???:???  Yd6:Yd5:Yd4:Yd3:Yd2:Yd1:Yd0:???
  198.                                               ┌───────────────────┐
  199.               Therefore, four pixels in a     │        Cr         │
  200.               row share a chrominace pair     ├───────────────────┤
  201.               and look like:                  │        Cb         │
  202.                                               ├────┬────┬────┬────┤
  203.                                               │ Ya │ Yb │ Yc │ Yd │
  204.                                               └────┴────┴────┴────┘
  205.  
  206.    FOURCC_VGA  : This is a single plane 16 color format:
  207.                  ┌────┐
  208.                  │    │   Each byte is "xxxx yyyy" "3210 3210" where 'x'
  209.                  │    │   is the first pixel and 'y' is the next.  The 16
  210.                  └────┘   colors are the standard VGA colors.
  211.  
  212.  
  213.  
  214.  
  215.  DIVE conversion support matrix:
  216.  
  217.          R  R  R  R  B  R  B  L  L  G  G  Y  Y  Y  Y  Y  M  Y  Y  V
  218.          5  5  6  G  G  G  G  U  T  R  Y  8  2  4  U  6  O  4  4  G
  219.          6  5  6  B  R  B  R  T  1  E  1  8  X  X  V  4  N  2  1  A
  220. out |in  5  5  4  3  3  4  4  8  2  Y  6  8  2  4  9  4  O  2  1
  221. ----|--------------------------------------------------------------
  222. R565|    X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
  223. R555|    X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
  224. R664|    X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
  225. RGB3|    X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
  226. BGR3|    X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
  227. RGB4|    X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
  228. BGR4|    X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
  229. LUT8|    X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
  230. LT12|                            X
  231. GREY|                               X
  232. GY16|                                  X
  233. Y888|
  234. Y2X2|
  235. Y4X4|
  236. YUV9|
  237. Y644|
  238. MONO|
  239. Y422|    X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
  240. Y411|
  241. VGA |
  242.  
  243. ******************************************************************************/
  244.  
  245. #endif
  246.  
  247. #ifdef __cplusplus
  248. }
  249. #endif
  250.  
  251.