Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Header file for all AVC INTER prediction kernels
  3.  * Copyright © <2010>, Intel Corporation.
  4.  *
  5.  * Permission is hereby granted, free of charge, to any person obtaining a
  6.  * copy of this software and associated documentation files (the
  7.  * "Software"), to deal in the Software without restriction, including
  8.  * without limitation the rights to use, copy, modify, merge, publish,
  9.  * distribute, sub license, and/or sell copies of the Software, and to
  10.  * permit persons to whom the Software is furnished to do so, subject to
  11.  * the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice (including the
  14.  * next paragraph) shall be included in all copies or substantial portions
  15.  * of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  20.  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
  21.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24.  *
  25.  * This file was originally licensed under the following license
  26.  *
  27.  *  Licensed under the Apache License, Version 2.0 (the "License");
  28.  *  you may not use this file except in compliance with the License.
  29.  *  You may obtain a copy of the License at
  30.  *
  31.  *      http://www.apache.org/licenses/LICENSE-2.0
  32.  *
  33.  *  Unless required by applicable law or agreed to in writing, software
  34.  *  distributed under the License is distributed on an "AS IS" BASIS,
  35.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  36.  *  See the License for the specific language governing permissions and
  37.  *  limitations under the License.
  38.  *
  39.  */
  40. #if !defined(__INTER_HEADER__)  // Make sure this file is only included once
  41. #define __INTER_HEADER__
  42.  
  43. // Module name: inter_header.inc
  44. //
  45. // Header file for all AVC INTER prediction kernels
  46. //
  47.  
  48. #define INTER_KERNEL
  49.  
  50. //-------------------------------------------------------------------------------------------
  51. // TODO: The followings will be merged with the above definitions later
  52. //-------------------------------------------------------------------------------------------
  53.  
  54.  
  55. //------------ Input parameters & bit masks
  56.  
  57. // SW WA for weighted prediction - 2007/09/06  
  58. //.declare      guwR1                   Base=r1 ElementSize=2 Type=uw  
  59. //.declare      guwW128                 Base=r63.13 ElementSize=2 Type=uw
  60.  
  61. #ifdef DEV_ILK
  62. // #define SW_W_128             // Enable SW WA for special Weight=128 case. Can be commented to disable it
  63. #else   // Pre DEV_ILK
  64. #define SW_W_128                // Enable SW WA for special Weight=128 case.
  65. #endif  // DEV_ILK
  66.  
  67. #ifdef  SW_W_128
  68. .declare        gudW128                 Base=r1.0 ElementSize=4 Type=ud
  69. #else
  70. #endif  // SW_W_128
  71.  
  72. #define         gORIX                   r3.4                            // :ub, X origin
  73. #define         gORIY                   r3.5                            // :ub, Y origin
  74.  
  75. #define         gCBP                    r3.9                            // :ub, CBP (0, 0, Y0, Y1, Y2, Y3, Cb, Cr)
  76. #define         nCBPY_MASK              0x3c
  77. #define         nCBPU_MASK              0x2
  78. #define         nCBPV_MASK              0x1
  79.  
  80. #define         gFIELDFLAGS             r3.1                            // :uw - To compute message descriptor for write
  81.  
  82. #define         gMBTYPE                 r3.1                            // :ub, MB type
  83. #define         nMBTYPE_MASK    0x1f
  84. #define         gFIELDMBFLAG    r3.1                            // :ub, Field MB flag
  85. #define         nFIELDMB_MASK   0x40
  86. #define         gMBPARITY               r3.3                            // :ub, Bottom field flag
  87. #define         nMBPARITY_MASK  0x01
  88.  
  89. #define         gWPREDFLAG              r3.0                            // :ub, Weighted pred flag
  90. #define         nWBIDIR_MASK    0xc0
  91.  
  92. #define         gSUBMB_SHAPE    r3.12                           // :ub, Sub-MB shape
  93. #define         gSUBMB_MODE             r3.13                           // :ub, Sub-MB prediction mode
  94. .declare        guwSUBMB_SHAPE_MODE     Base=r3.6 ElementSize=2 Type=uw
  95.  
  96. #define         gYWDENOM                r3.14                           // :ub, Luma log2 weight denom
  97. #define         gCWDENOM                r3.15                           // :ub, Chroma log2 weight denom
  98.  
  99. #define         gADDR                   r3.24                           // :ub, Register addresses of error data / MV
  100.  
  101. .declare        gubBIDX                 Base=r3.16 ElementSize=1 Type=ub
  102.  
  103. #define         gWGT                    r8                                      // Weights/offsets
  104. .declare    gdWGT                       Base=r8  ElementSize=4 Type=d
  105. .declare    gwWGT                       Base=r8  ElementSize=2 Type=w
  106. #define         gMV                             r4                                      // MVs
  107. .declare    gwMV                        Base=r4  ElementSize=2 Type=w
  108. .declare    gdMV                        Base=r4  ElementSize=4 Type=d
  109.  
  110. .declare        gwERRORY                Base=r10 ElementSize=2 Type=w           // 16 GRFs
  111. .declare        gubERRORY               Base=r10 ElementSize=1 Type=ub
  112. .declare        gwERRORC                Base=r26 ElementSize=2 Type=w           // 8 GRFs
  113. .declare        gubERRORC               Base=r26 ElementSize=2 Type=ub
  114.  
  115. //------------ Address registers
  116. #define         pMSGDSC                 a0.0                            // ud: Must be the leading dword of the address register
  117. #define         pREF                    a0.0
  118.  
  119. #define         pBIDX                   a0.2                           
  120. #define         pWGT                    a0.3
  121. #define         pERRORYC                a0.2                            // :ud 
  122. #define         pERRORY                 a0.4
  123. #define         pERRORC                 a0.5
  124. #define         pMV                             a0.6   
  125.  
  126. #define         pWGT_BIDX               a0.1                            // :ud, WGT & BIDX
  127. #define         pRECON_MV               a0.3                            // :ud, RECON & MV
  128.  
  129. #define         pREF0                   a0.0                            // :uw
  130. #define         pREF0D                  a0.0                            // :ud
  131. #define         pREF1                   a0.1
  132. #define         pREF2                   a0.2
  133. #define         pREF2D                  a0.1                            // :ud
  134. #define         pREF3                   a0.3
  135. #define         pREF4                   a0.4
  136. #define         pREF4D                  a0.2                            // :ud
  137. #define         pREF5                   a0.5
  138. #define         pREF6                   a0.6
  139. #define         pREF6D                  a0.3                            // :ud
  140. #define         pREF7                   a0.7
  141.  
  142. #define         pRES                    a0.6
  143. #define         pRESD                   a0.3                            // :ud
  144. #define         pRESULT                 a0.7
  145.  
  146. #define         p0                              a0.0
  147. #define         p1                              a0.1
  148.  
  149. //------------ Constants for static/inline/indirect
  150. #define         nOFFSET_BIDX    112                                     // = 32*3+4*4
  151.  
  152. #define         nOFFSET_WGT             256                                     // = 32*8
  153. #define         nOFFSET_WGT_BIDX 0x01000070                     // = (256<<16)+112
  154. #define         nOFFSET_ERROR   0x03400140                      // = (320+128*4)<<16+320=0x03400140
  155. #define         nOFFSET_ERRORY  0x0140
  156. #define         nOFFSET_ERRORC  0x0340
  157. #define         nOFFSET_MV              128                                     // = 32*4
  158. #define         nOFFSET_RECON_MV 0x04400080                     // = (1088<<16)+128             // TODO: OFFSET_RECON is obsolete
  159.  
  160. //------------ Constants for kernel internal variables
  161. #define         nOFFSET_INTPY0  0x0640                          // = 32*50
  162. #define         nOFFSET_INTPY1  0x0780                          // = 32*60
  163. #define         nOFFSET_INTPC0  0x06c0                          // = 32*54
  164. #define         nOFFSET_INTPC1  0x0480                          // = 32*36
  165. #define         nOFFSET_INTP0   0x06c00640
  166. #define         nOFFSET_INTP1   0x04800780
  167.  
  168. #define         nOFFSET_INTERIM         0x0480                          // = 32*36
  169. #define         nOFFSET_INTERIM2        0x04A00480                      // = ((32*37)<<16)|(32*36)
  170. #define         nOFFSET_INTERIM3        0x04A00480                      // = ((32*36+32)<<16)|(32*36)
  171. #define         nOFFSET_INTERIM4        0x04A00490                      // = ((32*37)<<16)|(32*36+16)
  172.  
  173. #define         nOFFSET_INTERIM4x4              0x04C0                  // = 32*38
  174. #define         nOFFSET_INTERIM4x4_4    0x04E004D0              // = ((32*38+32)<<16)|(32*38+16)
  175. #define         nOFFSET_INTERIM4x4_5    0x04D004C0              // = ((32*38+16)<<16)|(32*38)
  176. #define         nOFFSET_INTERIM4x4_6    0x04E004C0              // = ((32*38+32)<<16)|(32*38)
  177. #define         nOFFSET_INTERIM4x4_7    0x04D004C8              // = ((32*38+16)<<16)|(32*38+8)
  178. #define         nOFFSET_INTERIM4x4_8    0x04E004D8              // = ((32*38+32)<<16)|(32*38+24)
  179. #define         nOFFSET_INTERIM4x4_9    0x04F004E8              // = ((32*38+48)<<16)|(32*38+40)
  180.  
  181. #define         nOFFSET_RES             0x540                           // = 32*42
  182. #define         nOFFSET_REF             0x560                           // = 32*43
  183. #define         nOFFSET_REFC    0x700                           // = 32*56
  184.  
  185.                         // Binding table index
  186. #define         nBDIX_DESTY             0
  187. #define         nBDIX_DESTC             1
  188. #define         nBI_LC_DIFF             0x10                            // Binding table index diff between luma and chroma
  189.  
  190. #define         nGRFWIB                 32
  191. #define         nGRFHWIB                16
  192.  
  193. //------------ Regions
  194.  
  195. .declare    gudREF                      Base=r43 ElementSize=4 SrcRegion=<16;16,1> Type=ud
  196. .declare    gubREF                      Base=r43 ElementSize=1 Type=ub
  197. .declare    gudREFC                     Base=r56 ElementSize=4 SrcRegion=<16;16,1> Type=ud
  198.  
  199. // 16x16 handling
  200. .declare    gudREF21x21         Base=r58 ElementSize=4 SrcRegion=<16;16,1> Type=ud
  201. .declare    gudREF18x10         Base=r66 ElementSize=4 SrcRegion=<16;16,1> Type=ud
  202. .declare    gubREF18x10         Base=r66 ElementSize=1 SrcRegion=<16;16,1> Type=ub
  203.  
  204.  
  205.  
  206. .declare    gudREF16x16         Base=r38 ElementSize=4 Type=ud                  // 8 GRFs
  207. .declare    gubREF16x16         Base=r38 ElementSize=1 Type=ub
  208. .declare    gudREFC16x8         Base=r46 ElementSize=4 Type=ud                  // 4 GRFs
  209. .declare    gubREFC16x8         Base=r46 ElementSize=1 Type=ub
  210.  
  211. // TODO
  212. .declare    gubAVG                      Base=r56 ElementSize=1 Type=ub
  213. .declare        gubREFY_BWD             Base=r64 ElementSize=1 Type=ub
  214. .declare        gubREFC_BWD             Base=r72 ElementSize=1 Type=ub
  215.  
  216.  
  217. .declare    guwINTPY0           Base=r50 ElementSize=2 SrcRegion=<16;16,1> Type=uw
  218. .declare        gudINTPY0               Base=r50 ElementSize=4 Type=ud
  219. .declare    gubINTPY0           Base=r50 ElementSize=1 SrcRegion=<32;16,2> Type=ub
  220. .declare    guwINTPY1           Base=r60 ElementSize=2 SrcRegion=<16;16,1> Type=uw
  221. .declare        gudINTPY1               Base=r60 ElementSize=4 Type=ud
  222. .declare    gubINTPY1           Base=r60 ElementSize=1 SrcRegion=<32;16,2> Type=ub
  223. .declare    guwYPRED            Base=r50 ElementSize=2 SrcRegion=<8;8,1> Type=uw
  224. .declare    gubYPRED            Base=r50 ElementSize=1 SrcRegion=<32;16,2> Type=ub
  225.  
  226. .declare    guwINTPC0           Base=r54 ElementSize=2 SrcRegion=<16;16,1> Type=uw
  227. .declare    gwINTPC0            Base=r54 ElementSize=2 SrcRegion=<16;16,1> Type=w
  228. .declare        gudINTPC0               Base=r54 ElementSize=4 Type=ud
  229. .declare    gubINTPC0           Base=r54 ElementSize=1 SrcRegion=<32;16,2> Type=ub
  230. .declare    guwINTPC1           Base=r36 ElementSize=2 SrcRegion=<16;16,1> Type=uw
  231. .declare        gudINTPC1               Base=r36 ElementSize=4 Type=ud
  232. .declare    gubINTPC1           Base=r36 ElementSize=1 SrcRegion=<32;16,2> Type=ub
  233. .declare    guwCPRED            Base=r54 ElementSize=2 SrcRegion=<16;8,2> Type=uw
  234. .declare    gubCPRED            Base=r54 ElementSize=1 SrcRegion=<32;8,4> Type=ub
  235.  
  236. #define         gINTERIM                r36
  237. .declare        gubINTERIM_BUF  Base=r36 ElementSize=1 SrcRegion=<32;16,2> Type=ub
  238. #define         gINTERIM4x4             r38
  239. .declare        gubINTERIM4x4_BUF Base=r38 ElementSize=1 SrcRegion=<32;16,2> Type=ub
  240. .declare        gwINTERIM4x4_BUF Base=r38 ElementSize=2  Type=w
  241.  
  242. .declare        gubINTERIM_BUF2 Base=r42 ElementSize=1 SrcRegion=<8;4,2> Type=ub
  243. .declare        gwINTERIM_BUF2  Base=r42 ElementSize=2 SrcRegion=<16;16,1> Type=w      
  244. .declare        guwINTERIM_BUF2 Base=r42 ElementSize=2 Type=uw 
  245.  
  246. .declare        gwINTERIM_BUF3  Base=r38 ElementSize=2 SrcRegion=<16;16,1> Type=w               // 2 GRFs
  247. .declare        gubINTERIM_BUF3 Base=r38 ElementSize=1 Type=ub                                                 
  248.  
  249. .declare        gwTEMP                  Base=r42 ElementSize=2 SrcRegion=<16;16,1> Type=w
  250.  
  251. //------------ General registers
  252.  
  253. #define         gX                              r3.2                            // w
  254. #define         gY                              r3.3                            // w
  255.  
  256. #define         gMSGDSC_R               r3.6                            // ud
  257. #define         gMSGDSC_W               r3.7                            // ud
  258.  
  259. #ifdef  SW_W_128
  260. .declare        gwMBTYPE                Base=r8.6 ElementSize=2 Type=w                  // Shared with gLOOP_SUBMB
  261.  
  262. // TODO
  263. #define         gLOOP_SUBMB             r8.6
  264. #define         gLOOP_SUBMBPT   r8.7
  265. #define         gLOOP_DIR               r9.6
  266. #define         gLOOPCNT                r9.7                            // Loop counter for submodules
  267. #else
  268. .declare        gwMBTYPE                Base=r1.0 ElementSize=2 Type=w                  // Shared with gLOOP_SUBMB
  269.  
  270. // TODO
  271. #define         gLOOP_SUBMB             r1.0
  272. #define         gLOOP_SUBMBPT   r1.1
  273. #define         gLOOP_DIR               r8.7
  274. #define         gLOOPCNT                r9.7                            // Loop counter for submodules
  275. #endif  // SW_W_128
  276.  
  277. #define         gW0                             r34.6                           // Temporary WORD
  278. #define         gW1                             r34.7                           // Temporary WORD
  279. #define         gW2                             r34.8                           // Temporary WORD
  280. #define         gW3                             r34.9                           // Temporary WORD
  281. #define         gD0                             r34.3                           // Temporary DWORD
  282.  
  283. #define         gW4                             r34.15
  284.  
  285. //
  286.  
  287. #define         gMVX_INT                r34.0                           // :w
  288. #define         gMVY_INT                r34.1                           // :w
  289. #define         gMVX_FRAC               r34.2                           // :w
  290. #define         gMVY_FRAC               r34.3                           // :w
  291. #define         gMVX_FRACC              r34.4                           // :w
  292. #define         gMVY_FRACC              r34.5                           // :w
  293.  
  294. #define         gpINTPY                 r34.10
  295. #define         gpINTPC                 r34.11
  296. #define         gpINTP                  r34.5                           // DW
  297.  
  298. #define         gPREDFLAG               r34.12
  299. #define         gBIDX                   r34.13
  300. #define         gREFPARITY              r34.14
  301. #define         gCHRMVADJ               r1.14
  302. #define         gPARITY                 r1.15
  303. #define         gCBP_MASK               r1.1
  304.  
  305. #define         gMVSTEP                 r1.13
  306.  
  307. #define         gpADDR                  r1.2                            // :uw (8 words)
  308.  
  309. #define         gSHAPETEMP              r8.15                           // :uw
  310.  
  311. #define         gCOEFA                  r42.0                          
  312. #define         gCOEFB                  r42.1                          
  313. #define         gCOEFC                  r42.2                          
  314. #define         gCOEFD                  r42.3
  315.  
  316. // Weighted prediction
  317. #define         gPREDFLAG0              r46.0
  318. #define         gPREDFLAG1              r46.2
  319.  
  320. #define         gWEIGHTFLAG             r43.2
  321. #define         gBIPRED                 r43.3
  322. #define         gYADD                   r43.4
  323. #define         gCADD                   r43.5
  324. #define         gYSHIFT                 r43.6
  325. #define         gCSHIFT                 r43.7
  326.  
  327. #define         gOFFSET                 r44.0
  328. #define         gUOFFSET                r44.1
  329. #define         gVOFFSET                r44.2
  330.  
  331. #define         gWT0                    r45.0
  332. #define         gO0                             r45.1
  333. #define         gWT1                    r45.2
  334. #define         gO1                             r45.3
  335. #define         gUW0                    r45.4
  336. #define         gUO0                    r45.5
  337. #define         gUW1                    r45.6
  338. #define         gUO1                    r45.7  
  339. #define         gVW0                    r45.8  
  340. #define         gVO0                    r45.9  
  341. #define         gVW1                    r45.10 
  342. #define         gVO1                    r45.11
  343.  
  344. #define         gWT0_D                  r45.0  
  345. #define         gUW0_D                  r45.2  
  346.  
  347. //------------ Message-related Registers & constants
  348. #define         gMSGSRC                 r2                                      // Message Source
  349.  
  350. #define         mMSGHDR                 m1             
  351. #define         mMSGHDRY                m1             
  352. #define         mMSGHDRC                m2             
  353. #define         mMSGHDR1                m1             
  354. #define         mMSGHDR2                m2             
  355. #define         mMSGHDR3                m3             
  356. #define         mMSGHDR4                m4             
  357. #define         mMSGHDRYW               m1             
  358. #define         mMSGHDRCW               m10            
  359.  
  360. #ifdef DEV_ILK
  361.         // 0000 0100(read)  0001(msg len) xxxx(resp len) 1010 (sampler cache) xxxx (field/frame) xxxx xxxx (bidx)
  362. #define         nDWBRMSGDSC_SC          0x0208A002      // DWORD Block Read Message Descriptor through Data Port, Sampler Cache
  363. #define         nDWBRMSGDSC_SC_TF       0x0208E602      // DWORD Block Read Message Descriptor through Data Port, Sampler Cache
  364. #define         nDWBRMSGDSC_SC_BF       0x0208E702      // DWORD Block Read Message Descriptor through Data Port, Sampler Cache
  365.         // 0000 0101(write) 0001(msg len) xxxx(resp len) 0010 (render cache)  xxxx (field/frame) xxxx xxxx (bidx)                                                                              
  366. #define         nDWBWMSGDSC             0x02082000  // DWORD Block Write Message Descriptor through Data Port, Render Cache
  367. #define         nDWBWMSGDSC_TF  0x02082600  // DWORD Block Write Message Descriptor through Data Port, Render Cache
  368. #define         nDWBWMSGDSC_BF  0x02082700  // DWORD Block Write Message Descriptor through Data Port, Render Cache                                                                            
  369.  
  370. #else   // Pre DEV_ILK
  371.         // 0000 0100(read)  0001(msg len) xxxx(resp len) 1010 (sampler cache) xxxx (field/frame) xxxx xxxx (bidx)
  372. #define         nDWBRMSGDSC_SC          0x0410A002      // DWORD Block Read Message Descriptor through Data Port, Sampler Cache
  373. #define         nDWBRMSGDSC_SC_TF       0x0410A602      // DWORD Block Read Message Descriptor through Data Port, Sampler Cache
  374. #define         nDWBRMSGDSC_SC_BF       0x0410A702      // DWORD Block Read Message Descriptor through Data Port, Sampler Cache
  375.         // 0000 0101(write) 0001(msg len) xxxx(resp len) 0010 (render cache)  xxxx (field/frame) xxxx xxxx (bidx)                                                                              
  376. #define         nDWBWMSGDSC             0x05102000  // DWORD Block Write Message Descriptor through Data Port, Render Cache
  377. #define         nDWBWMSGDSC_TF  0x05102600  // DWORD Block Write Message Descriptor through Data Port, Render Cache
  378. #define         nDWBWMSGDSC_BF  0x05102700  // DWORD Block Write Message Descriptor through Data Port, Render Cache                                                                            
  379. #endif  // DEV_ILK
  380.  
  381. #define         nDWB_FIELD_MASK 0x0600
  382.                                                                                
  383. // message data payload
  384. .declare    mbMSGPAYLOADY       Base=m2  ElementSize=1 SrcRegion=REGION(16,1) Type=b
  385. .declare    mbMSGPAYLOADC       Base=m11 ElementSize=1 SrcRegion=REGION(16,1) Type=b
  386.  
  387. // Destination registers for write commit
  388. #define         gREG_WRITE_COMMIT_Y             r10.0
  389. #define         gREG_WRITE_COMMIT_UV    r11.0
  390.  
  391. #define RETURN_REG_INTER        r1.5            // Return pointer for all sub-routine calls (type DWORD)
  392.  
  393. #define CALL_INTER(subFunc, skipInst)   add (1) RETURN_REG_INTER<1>:ud   ip:ud  1+skipInst*INST_SIZE \n\
  394.                                 jmpi (1) subFunc
  395. #define RETURN_INTER            mov (1) ip:ud   RETURN_REG_INTER<0;1,0>:ud              // Return to calling module
  396.  
  397.  
  398. // End of inter_header.inc
  399.  
  400. #endif  // !defined(__INTER_HEADER__)
  401.  
  402.