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