home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyth_os2.zip / python-1.0.2 / Modules / yuv.h < prev    next >
C/C++ Source or Header  |  1994-01-02  |  4KB  |  123 lines

  1. /***********************************************************
  2. Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
  3. Amsterdam, The Netherlands.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Stichting Mathematisch
  12. Centrum or CWI not be used in advertising or publicity pertaining to
  13. distribution of the software without specific, written prior permission.
  14.  
  15. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  16. THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  18. FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  21. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  
  23. ******************************************************************/
  24.  
  25. #ifndef Py_YUV_H
  26. #define Py_YUV_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30.  
  31. /*
  32.  * SVideo YUV 4:1:1 format.
  33.  *
  34.  * 4 consecutive quadwords describe 8 pixels on 2 lines, as depicted
  35.  * below.  An array of (width/4) of the below structure describes 2
  36.  * scan lines.
  37.  *
  38.  * +-------------------+
  39.  * | 00 | 01 | 02 | 03 | . . .
  40.  * +-------------------+
  41.  * | 10 | 11 | 12 | 13 | . . .
  42.  * +-------------------+
  43.  */
  44. struct yuv411 {
  45.     struct {
  46.         unsigned int dummy:8;
  47.         unsigned int y0:8;
  48.         unsigned int u0:2;
  49.         unsigned int v0:2;
  50.         unsigned int y1:8;
  51.         unsigned int u1:2;
  52.         unsigned int v1:2;
  53.     } v[4];
  54. };
  55.  
  56. #define YUV411_Y00(y)    (y).v[0].y0
  57. #define YUV411_Y01(y)    (y).v[1].y0
  58. #define YUV411_Y02(y)    (y).v[2].y0
  59. #define YUV411_Y03(y)    (y).v[3].y0
  60. #define YUV411_Y10(y)    (y).v[0].y1
  61. #define YUV411_Y11(y)    (y).v[1].y1
  62. #define YUV411_Y12(y)    (y).v[2].y1
  63. #define YUV411_Y13(y)    (y).v[3].y1
  64. #define YUV411_U00(y)    ((y).v[0].u0<<6|(y).v[1].u0<<4|(y).v[2].u0<<2|(y).v[3].u0)
  65. #define YUV411_U01(y)    YUV411_U00(y)
  66. #define YUV411_U02(y)    YUV411_U00(y)
  67. #define YUV411_U03(y)    YUV411_U00(y)
  68. #define YUV411_U10(y)    ((y).v[0].u1<<6|(y).v[1].u1<<4|(y).v[2].u1<<2|(y).v[3].u1)
  69. #define YUV411_U11(y)    YUV411_U10(y)
  70. #define YUV411_U12(y)    YUV411_U10(y)
  71. #define YUV411_U13(y)    YUV411_U10(y)
  72. #define YUV411_V00(y)    ((y).v[0].v0<<6|(y).v[1].v0<<4|(y).v[2].v0<<2|(y).v[3].v0)
  73. #define YUV411_V01(y)    YUV411_V00(y)
  74. #define YUV411_V02(y)    YUV411_V00(y)
  75. #define YUV411_V03(y)    YUV411_V00(y)
  76. #define YUV411_V10(y)    ((y).v[0].v1<<6|(y).v[1].v1<<4|(y).v[2].v1<<2|(y).v[3].v1)
  77. #define YUV411_V11(y)    YUV411_V10(y)
  78. #define YUV411_V12(y)    YUV411_V10(y)
  79. #define YUV411_V13(y)    YUV411_V10(y)
  80.  
  81. /*
  82.  * Compression Library YUV 4:2:2 format.
  83.  *
  84.  * 1 longword describes 2 pixels.
  85.  *
  86.  * +-------+
  87.  * | 0 | 1 |
  88.  * +-------+
  89.  */
  90. struct yuv422 {
  91.     unsigned int u:8;
  92.     unsigned int y0:8;
  93.     unsigned int v:8;
  94.     unsigned int y1:8;
  95. };
  96. #define YUV422_Y0(y)    (y).y0
  97. #define YUV422_Y1(y)    (y).y1
  98. #define YUV422_U0(y)    (y).u
  99. #define YUV422_U1(y)    (y).u
  100. #define YUV422_V0(y)    (y).v
  101. #define YUV422_V1(y)    (y).v
  102.  
  103. /*
  104.  * Compression library YUV 4:2:2 Duplicate Chroma format.
  105.  *
  106.  * This is like the previous format, but the U and V values are
  107.  * duplicated vertically (and hence there is some redundancy in the
  108.  * data).  With other words, lines 2*n and 2*n+1 have the same U and V
  109.  * values but different Y values.
  110.  */
  111.  
  112. /*
  113.  * Conversion functions.
  114.  */
  115. void yuv_sv411_to_cl422dc(int, void *, void *, int, int);
  116. void yuv_sv411_to_cl422dc_quartersize(int, void *, void *, int, int);
  117. void yuv_sv411_to_cl422dc_sixteenthsize(int, void *, void *, int, int);
  118.  
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif /* !Py_YUV_H */
  123.