hwvideo.pas 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. {
  2. Copyright (c) 1991, 1992, 1993 International Business Machines Corporation
  3. Copyright (c) 2002 by Valery Gaynullin
  4. Copyright (c) 2002-2003 by Yuri Prokushev ([email protected])
  5. This is Video Acceleration Interface
  6. This program is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU Library General Public License (LGPL) as
  8. published by the Free Software Foundation; either version 2 of the
  9. License, or (at your option) any later version. This program is
  10. distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE.
  13. See the GNU Library General Public License for more details. You should
  14. have received a copy of the GNU Library General Public License along
  15. with this program; if not, write to the Free Software Foundation, Inc.,
  16. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. **********************************************************************}
  18. {
  19. @abstract(Video Acceleration Interface)
  20. @author(Valery Gaynullin)
  21. @author(Yuri Prokushev ([email protected]))
  22. @created(29 Nov 2002)
  23. @lastmod(19 Jan 2003)
  24. This is Video Acceleration Interface.
  25. Warning: This code is alfa. Future versions of this unit will propably
  26. not be compatible.
  27. }
  28. Unit HWVideo;
  29. Interface
  30. Uses
  31. Os2Def,
  32. PMWin,
  33. PMGpi;
  34. // GRADD function class
  35. Const
  36. VA2_FUNCTION_CLASS='Video Acceleration 2';
  37. Type
  38. THWVIDEOCAPS=record
  39. ulLength: Cardinal;
  40. ulCapsFlags: Cardinal; //flags, describing HW capability
  41. szlSrcMax: SIZEL; //maximum source size (pixels)
  42. rctlDstMargin: RECTL; //destination rectangle margins
  43. fccDstColor: Cardinal; //screen FOURCC
  44. ulScanAlign: Cardinal; //requered scanline aligment-1
  45. ulNumColors: Cardinal; //count of supported source FOURCC
  46. fccColorType: ^Cardinal; //array of supported FOURCC
  47. ulAttrCount: Cardinal; //count of viewport attributes
  48. end;
  49. PHWVIDEOCAPS=^THWVIDEOCAPS;
  50. //ulCapsFlag defines
  51. Const
  52. HWVIDEOCAPS_MINIFY = $00000001; //Chip can perform downscaling
  53. HWVIDEOCAPS_FILTER = $00000002; //Image filtering present
  54. HWVIDEOCAPS_NONINTEGER_SCALE = $00000004; //allow scale to noninteger ratio
  55. HWVIDEOCAPS_COLOR_KEYING = $00000008; //allow color keying
  56. HWVIDEOCAPS_OVERLAY = $00000010; //overlay-type HW
  57. HWVIDEOCAPS_SEPARATE_OUT = $00000020; //used separate output connector (like TV out)
  58. HWVIDEOCAPS_DECODE = $00000040; //support non-RAW data
  59. HWVIDEOCAPS_NEEDPROTECT = $00000080; //HW need to lock VRAM
  60. Type
  61. THWATTRIBUTE=record
  62. ulLength: Cardinal; //size of structure in bytes
  63. szAttrDesc: Array[0..64] of Char; //string, describing attribute
  64. ulAttrType: Cardinal; //type of attribute, check ATTRTYPE_* const
  65. ulValueSize: Cardinal; //size in bytes of each value member
  66. ulValueCount: Cardinal; //count of value members
  67. pValueList: Pointer; //list of supported values
  68. ulCurrentValue: Cardinal; //current value
  69. ulDefaultValue: Cardinal; //default value
  70. ulAttribFlags: Cardinal; //flags to define some additional properties
  71. end;
  72. PHWATTRIBUTE=^THWATTRIBUTE;
  73. //types of attributes.
  74. // if ATTRTYPE_BOOLEAN, ATTRTYPE_STATICTEXT or ATTRTYPE_BYTE,
  75. // ulValueCount & ulValueSize undefined,
  76. // pValueList can be NULL,
  77. // else this must be actual value of allocated chunk of memory.
  78. Const
  79. //attribute of ON/OFF type
  80. ATTRTYPE_BOOLEAN = 1;
  81. //attribute can be member of set string type
  82. ATTRTYPE_AGGREGATE_STRING = 2;
  83. //attribute have no value - this is static text string
  84. ATTRTYPE_STATICTEXT = 3;
  85. //attribute can be any value in 0..255 margins
  86. ATTRTYPE_BYTE = 4;
  87. //defines for ulAttribFlags field
  88. //changing this attribute affect HW capability, so application
  89. //must re-read Caps after changing value of this attribute
  90. //application must not assume preserving any capability when this
  91. //attribute was changed
  92. ATTRIB_CHANGE_CAPS = 1;
  93. //some common attribute names
  94. Const
  95. ATTRIBUTE_BRIGHTNESS = 'Brightness';
  96. ATTRIBUTE_CONTRAST = 'Contrast';
  97. ATTRIBUTE_SATURATION = 'Saturation';
  98. ATTRIBUTE_HUE = 'Hue';
  99. ATTRIBUTE_FILTERING = 'Filtering';
  100. ATTRIBUTE_TVOUT = 'Output to TV';
  101. ATTRIBUTE_COLORKEY = 'Color Keying';
  102. Type
  103. THWVIDEOSETUP=record
  104. ulLength: Cardinal;
  105. rctlDstRect: RECTL; //destination screen rectangle
  106. szlSrcSize: SIZEL; //source image size
  107. ulSrcPitch: Cardinal; //byte offset between image rows
  108. fccColor: Cardinal; //image format
  109. ulKeyColor: Cardinal; //color key
  110. rctlSrcRect: RECTL;
  111. end;
  112. PHWVIDEOSETUP=^THWVIDEOSETUP;
  113. //return codes
  114. Const
  115. //no error
  116. HWVIDEO_DONE = 0;
  117. //unspecified error
  118. HWVIDEO_ERROR = 3;
  119. //FS session active, accelerator not available
  120. HWVIDEO_ERROR_BACKGROUND = 4;
  121. //HW not available
  122. HWVIDEO_ERROR_NO_HW = 6;
  123. //incorrect parameter
  124. HWVIDEO_ERROR_PARAMETER = 7;
  125. //to low offscreen VRAM to handle setup
  126. HWVIDEO_ERROR_LOW_VRAM = 8;
  127. //HW already in use
  128. HWVIDEO_ERROR_USED = 9;
  129. //Init HWVideo subsystem
  130. //check for presence and avilability of accelerated HW, if present and
  131. //available - lock it for this process.
  132. Function HWVIDEOInit: Cardinal; cdecl;
  133. //Get HW capability
  134. //return filled structure. When called, ulNumColors must be
  135. //set to actual allocated size of fccColorType array.
  136. //if call returned with error, then need to check returned
  137. //ulNumColors, allocate larger space and call again.
  138. Function HWVIDEOCaps(pCaps: PHWVIDEOCAPS): Cardinal; cdecl;
  139. //Set HWVideo viewport
  140. //Check HW capability to handle this setup, allocate buffers.
  141. //one special case: pSetup==NULL - disable video and free all
  142. //buffers
  143. Function HWVIDEOSetup(pSetup: PHWVIDEOSETUP): Cardinal; cdecl;
  144. //Get HWVideo buffer pointer
  145. //return linear pointer to overlay buffer and it's physical address
  146. Function HWVIDEOBeginUpdate(var ppBuffer: Pointer; var pulPhysBuffer: Cardinal): Cardinal; cdecl;
  147. //Display HWVideo buffer
  148. //set pending state for last accessed videobuffer, switch
  149. //buffers on next VSYNC
  150. Function HWVIDEOEndUpdate: Cardinal; cdecl;
  151. //Get current HW attributes
  152. //0<=ulAttribNum<pCaps->ulAttrCount, else error returned.
  153. Function HWVIDEOGetAttrib(ulAttribNum: Cardinal; pAttrib: PHWATTRIBUTE): Cardinal; cdecl;
  154. //Set new attribute value
  155. //0<=ulAttribNum<pCaps.ulAttrCount, else error returned.
  156. //pAttrib->ulCurrentValue filled with new value
  157. Function HWVIDEOSetAttrib(ulAttribNum: Cardinal; pAttrib: PHWATTRIBUTE): Cardinal; cdecl;
  158. //Close HWVideo
  159. Function HWVIDEOClose: Cardinal; cdecl;
  160. Implementation
  161. Function HWVIDEOInit: Cardinal; cdecl;
  162. external 'hwvideo' name 'HWVIDEOInit';
  163. Function HWVIDEOCaps(pCaps: PHWVIDEOCAPS): Cardinal; cdecl;
  164. external 'hwvideo' name 'HWVIDEOCaps';
  165. Function HWVIDEOSetup(pSetup: PHWVIDEOSETUP): Cardinal; cdecl;
  166. external 'hwvideo' name 'HWVIDEOSetup';
  167. Function HWVIDEOBeginUpdate(var ppBuffer: Pointer; var pulPhysBuffer: Cardinal): Cardinal; cdecl;
  168. external 'hwvideo' name 'HWVIDEOBeginUpdate';
  169. Function HWVIDEOEndUpdate: Cardinal; cdecl;
  170. external 'hwvideo' name 'HWVIDEOEndUpdate';
  171. Function HWVIDEOGetAttrib(ulAttribNum: Cardinal; pAttrib: PHWATTRIBUTE): Cardinal; cdecl;
  172. external 'hwvideo' name 'HWVIDEOGetAttrib';
  173. Function HWVIDEOSetAttrib(ulAttribNum: Cardinal; pAttrib: PHWATTRIBUTE): Cardinal; cdecl;
  174. external 'hwvideo' name 'HWVIDEOSetAttrib';
  175. Function HWVIDEOClose: Cardinal; cdecl;
  176. external 'hwvideo' name 'HWVIDEOClose';
  177. End.