Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  *  Copyright 2000-2011 Intel Corporation All Rights Reserved
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a
  5.  * copy of this software and associated documentation files (the
  6.  * "Software"), to deal in the Software without restriction, including
  7.  * without limitation the rights to use, copy, modify, merge, publish,
  8.  * distribute, sub license, and/or sell copies of the Software, and to
  9.  * permit persons to whom the Software is furnished to do so, subject to
  10.  * the following conditions:
  11.  *
  12.  * The above copyright notice and this permission notice (including the
  13.  * next paragraph) shall be included in all copies or substantial portions
  14.  * of the Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  19.  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
  20.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  21.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  22.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23.  *
  24.  * This file was originally licensed under the following license
  25.  *
  26.  *  Licensed under the Apache License, Version 2.0 (the "License");
  27.  *  you may not use this file except in compliance with the License.
  28.  *  You may obtain a copy of the License at
  29.  *
  30.  *      http://www.apache.org/licenses/LICENSE-2.0
  31.  *
  32.  *  Unless required by applicable law or agreed to in writing, software
  33.  *  distributed under the License is distributed on an "AS IS" BASIS,
  34.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  35.  *  See the License for the specific language governing permissions and
  36.  *  limitations under the License.
  37.  */
  38. //   40    // Total instruction count
  39. //    1    // Total kernel count
  40.  
  41. .kernel NV12_DN_NV12
  42. .code
  43.  
  44.  
  45.  
  46. // FileName:    DN_PL_Core.asm
  47. // Author:              Vivek Kumar
  48. // Description: Tasks for DN only case (16x8 block) for planar format
  49.  
  50.  
  51.  
  52. // FileName:    DN.asm
  53. // Author:              Vivek Kumar
  54. // Description: Tasks for DN only case (16x8 block)
  55.  
  56.  
  57.  
  58.  
  59. // Module name: common.inc
  60. //
  61. // Common header file for all Video-Processing kernels
  62. //
  63.  
  64. .default_execution_size (16)
  65. .default_register_type  :ub
  66.  
  67. .reg_count_total        128
  68. .reg_count_payload      7
  69.  
  70. //========== Common constants ==========
  71.  
  72.  
  73. //========== Macros ==========
  74.  
  75.  
  76. //Fast Jump, For more details see "Set_Layer_N.asm"
  77.  
  78.  
  79. //========== Defines ====================
  80.  
  81. //========== Static Parameters (Common To All) ==========
  82. //r1
  83.  
  84.  
  85. //r2
  86.  
  87.                                     //  e.g.            byte0   byte1  byte2
  88.                                     // YUYV               0       1      3
  89.                                     // YVYU               0       3      1
  90.  
  91. //Color Pipe (IECP) parameters
  92.  
  93.  
  94. //ByteCopy
  95.  
  96.  
  97. //r4
  98.  
  99.                                     //  e.g.              byte0           byte1           byte2
  100.                                     // YUYV                 0               1               3
  101.                                     // YVYU                 0               3               1
  102.  
  103.  
  104. //========== Inline parameters (Common To All) ===========
  105.  
  106.  
  107. //============== Binding Index Table===========
  108. //Common between DNDI and DNUV
  109.  
  110.  
  111. //================= Common Message Descriptor =====
  112. // Message descriptor for thread spawning
  113. // Message Descriptors
  114. //                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
  115. //                  0000,0000,0000
  116. //                  0001(Spawn a root thread),0001 (Root thread spawn thread)
  117. //                = 0x02000011
  118. // Thread Spawner Message Descriptor
  119.  
  120.  
  121. // Message descriptor for atomic operation add
  122. // Message Descriptors
  123. //                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
  124. //                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
  125. //                  0000,0000 (Binding table index, added later)
  126. //                = 0x02000011
  127.  
  128. // Atomic Operation Add Message Descriptor
  129.  
  130.  
  131. // Message descriptor for dataport media write
  132.         // Message Descriptors
  133.                 //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
  134.                 //                  1 (header present 1) 0 1010 (media block write) 000000
  135.                 //                  00000000 (binding table index - set later)
  136.                 //                = 0x020A8000
  137.  
  138.  
  139. // Message Length defines
  140.  
  141.  
  142. // Response Length defines
  143.  
  144.  
  145. // Block Width and Height Size defines
  146.  
  147.  
  148. // Extended Message Descriptors
  149.  
  150.  
  151. // Common message descriptors:
  152.  
  153.  
  154. //===================== Math Function Control ===================================
  155.  
  156.  
  157. //============ Message Registers ===============
  158.                              // buf4 starts from r28
  159.  
  160.  
  161. //#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
  162.  
  163.  
  164. .declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
  165. .declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
  166. .declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
  167. .declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
  168.  
  169. //=================== End of thread instruction ===========================
  170.  
  171.  
  172. //=====================Pointers Used=====================================
  173.  
  174.  
  175. //=======================================================================
  176.  
  177.  
  178. //r11-r17
  179. // Define temp space for any usages
  180.  
  181.  
  182. // Common Buffers
  183.  
  184.  
  185. // temp space for rotation
  186.  
  187. .declare fROBUF           Base=r11.0            ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
  188.  
  189. .declare udROBUF                Base=r11.0              ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
  190.  
  191. .declare uwROBUF                Base=r11.0              ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
  192.  
  193. .declare ubROBUF                Base=r11.0              ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
  194.  
  195. .declare ub4ROBUF       Base=r11.0              ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
  196.  
  197.  
  198. // End of common.inc
  199.  
  200.  
  201. // FileName:    DNDI.inc
  202. // Author:      Vivek Kumar
  203. // Description: Include file for DN, DI and DNDI
  204. // Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
  205.  
  206.  
  207.  
  208.  
  209. // End of common.inc
  210.  
  211.  
  212. //Interface:
  213. //Static Parameters:
  214. //r1
  215.  
  216.  
  217. //====================== Binding table (Explicit To DNDI)=========================================
  218.  
  219.  
  220. .declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
  221. .declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
  222. .declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
  223.  
  224.  
  225. .declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
  226.  
  227.  
  228. .declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
  229.  
  230.  
  231. .declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
  232. .declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
  233. .declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
  234.  
  235.  
  236. .declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
  237. .declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
  238. .declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
  239.  
  240.  
  241. .declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
  242. .declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
  243. .declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
  244. .declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
  245.  
  246.  
  247. .declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
  248. .declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
  249.  
  250.  
  251. .declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
  252. .declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
  253.  
  254. //r45
  255. //Use r45 as message header, so no need to "mov" the data.
  256.  
  257. .declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
  258.  
  259. // Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
  260. .declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
  261. .declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
  262. .declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
  263.  
  264. // Message response (UV Copy); Use buffer 5
  265. .declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
  266. .declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
  267.  
  268. //Temp GRFs: For 42X to 422 Conversion
  269. .declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
  270. .declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
  271. //---------------------------------------------------------------------------
  272. // Message descriptors
  273. //---------------------------------------------------------------------------
  274. // Extended message descriptor
  275.     // Message descriptor   for sampler read
  276.     //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
  277.     //                      1 (header present 1) 0 11 (SIMD32/64 mode)
  278.     //                      1000 (message type) 0000 (DI state index)
  279.     //                      00000000 (binding table index - set later)
  280.     //                    = 0x040b8000
  281.  
  282.  
  283. // Attention: The Message Length is The Number of GRFs with Data Only, without the Header
  284.  
  285.  
  286. //---------------------------------------------------------------------------
  287. // VDI Return Data format
  288. //---------------------------------------------------------------------------
  289. // Defines for DI enabled
  290.  
  291.  
  292. // Defines for DI disabled
  293.  
  294.  
  295.  
  296. // FileName:    DNDI_Command.asm
  297. // Author:              Vivek Kumar
  298. // Description: Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
  299.  
  300. // Prepare the DNDI send command
  301. mov (8)         mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
  302. mov (1)         mwMSGHDR_DNDI(1,4)<1>                   r9.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
  303. mov (1)         mwMSGHDR_DNDI(1,12)<1>                  r9.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
  304.  
  305. send (8)        udDNDI_RESP(0)<1>       r18     0x2     0x45E8003:ud
  306.  
  307. // On Gen6, with VDI walker, use the XY pair returned rather than programmed above
  308. // VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
  309. mov (2)         r9.0<1>:w     uwDNDI_RESP(4,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15
  310.  
  311.  
  312.  
  313. // FileName:    DN_Hist_Save.asm
  314. // Author:              Vivek Kumar
  315. // Description: Saves DN history data to statistics surface
  316.  
  317. // Write denoise history to memory
  318. mov (8)    r27<1>:ud                            r0.0<8;8,1>:ud                                          // message header  
  319.  
  320.  
  321.         mov (2)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(4,0)<2;2,1>         // Move denoise history to MRF (4x2)
  322.  
  323.  
  324. shr (2)    r27.0<1>:ud          r9.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
  325. add (1)    r27.0<1>:ud          r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
  326. mov (1)    r27.2<1>:ud          0x10003:ud                                                                      { NoDDChk }     // block width and height
  327.  
  328. mov (8)         mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
  329. send (8)        null<1>:d       r22     0x5             0x40A8021:ud
  330.  
  331.  
  332.  
  333. // FileName:    DNDI_Enc_Stats_Save.asm
  334. // Author:              Vivek Kumar
  335. // Description: Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
  336.  
  337. // Write encoder statistics to memory
  338. //Currently enable this only on Gen6 validation
  339. mov (8)         mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
  340. mov (8)         mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
  341.  
  342. shr (1)         mudMSGHDR_ENC_STATS(0,0)<1>             r9.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
  343. mul (1)         acc0.1<1>:ud                                    r9.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
  344. shr (1)         mudMSGHDR_ENC_STATS(0,1)<1>             acc0.1<0;1,0>:ud                        2:w             { NoDDClr, NoDDChk }            //enable the flag after testing on si                      { NoDDClr, NoDDChk } // Y origin * 3/4
  345. mov (1)         mudMSGHDR_ENC_STATS(0,2)<1>             0x50003:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
  346. add (2)         mudMSGHDR_ENC_STATS(0,0)<1>             mudMSGHDR_ENC_STATS(0,0)<2;2,1>         r1.12<2;2,1>:uw                                 // Add pitch to X,Y origin
  347.  
  348.  
  349.         //Data block for Encoder Statistics
  350.         //----------------------------------------------------
  351.         //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
  352.         //----------------------------------------------------
  353.         //| BNE |   X  |   X   |  X  |           X           |
  354.         //----------------------------------------------------
  355.         //|     X      |     SVCM    |           X           |
  356.         //----------------------------------------------------
  357.         //|   SHCM     |     STAD    |           X           |
  358.         //----------------------------------------------------
  359.         //|            X             |           X           |
  360.         //----------------------------------------------------
  361.         //|     X      |     SVCM    |           X           |
  362.         //----------------------------------------------------
  363.         //|   SHCM     |     STAD    |           X           |
  364.         //----------------------------------------------------
  365.         mov (1)         mubMSGHDR_ENC_STATS(1,0)<1>             ubDNDI_RESP(4,8)<0;1,0>                 { NoDDClr }                             // Move encoder statistics to MRF
  366.         mov (1)         muwMSGHDR_ENC_STATS(1,3)<1>             uwDNDI_RESP(4,11)<0;1,0>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
  367.         mov (2)         muwMSGHDR_ENC_STATS(1,4)<1>             uwDNDI_RESP(4,12)<2;2,1>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
  368.         mov (1)         muwMSGHDR_ENC_STATS(1,9)<1>             uwDNDI_RESP(4,8)<0;1,0>                 { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
  369.         mov (2)         muwMSGHDR_ENC_STATS(1,10)<1>    uwDNDI_RESP(4,9)<2;2,1>                 { NoDDChk }                             // Move encoder statistics to MRF
  370.  
  371.  
  372. send (8)   null<1>:d    r24    0x5    0x40A8021:ud
  373.  
  374.  
  375.  
  376. // FileName:    DN_Load_UV_NV12_16x8.asm
  377. // Author:              Vivek Kumar
  378. // Description: Read UV for 16x8 block through DATAPORT
  379.  
  380.  
  381.  
  382. // FileName:    UVCopy_Load_16x8.asm
  383. // Author:              Vivek Kumar
  384. // Description: Read UV for 16x8 block through DATAPORT
  385.  
  386. //CHANGE        :  Read extra UV data to convert to 422. -rT
  387. //we are reading extra data in ALL cases irrespective of whether upsampling is reqd or not later on, to keep things simple.
  388.  
  389.  
  390.         add (2)         r27.0<1>:d                              r9.0<2;2,1>:w                           r4.4<2;2,1>:w                           // Source Y Block origin
  391.         asr (1)         r27.1<1>:d                      r27.1<0;1,0>:d          1:w                                             { NoDDClr }     // U/V block origin should be half of Y's
  392.         mov (1)         r27.2<1>:ud                             0x4000F:ud                                      { NoDDChk }     // U/V block width and height (8x5)
  393.     mov (8)     mudMSGHDR_UVCOPY(0)<1>          r27.0<8;8,1>:ud
  394.         send (8)        udDNDI_UV_RESP(0)<1>            r36     0x4     0x2390001:ud
  395.  
  396.         //Update Header for Save
  397.         mov (1)         mudMSGHDR_UVCOPY(0,2)<1>        0x3000F:ud                                                                      // U/V block width and height (8x4)
  398.  
  399.  
  400.  
  401. // FileName:    DN_Save_Y_16x8.asm
  402. // Author:      Vivek Kumar
  403. // Description: Save one 16x8 blocks of Y channel of DN output for reference
  404.  
  405.  
  406. mov (8)     mudDN_Y_OUT(0,0)<1>     r0<8;8,1>:ud                                // message header
  407. mov (2)     mudDN_Y_OUT(0,0)<1>     r9.0<2;2,1>:w                  { NoDDClr }     // X origin
  408. mov (1)     mudDN_Y_OUT(0,2)<1>     0x7000F:ud    { NoDDChk }     // block width and height (16x8)
  409.  
  410. //send out data through data port
  411. send (8)    null<1>:d    mudDN_Y_OUT      0x5    0xA0A8018:ud
  412.  
  413.  
  414.  
  415. // FileName:    DN_Save_UV_NV12_16x8.asm
  416. // Author:              Vivek Kumar
  417. // Description: Save UV for 16x8 block through DATAPORT
  418.  
  419.  
  420.  
  421. // FileName:    UVCopy_Save_16x8.asm
  422. // Author:              Vivek Kumar
  423. // Description: Save UV for 16x8 block through DATAPORT
  424.  
  425.  
  426. //Reuse the header from Load component
  427. //Header is modified at the end of load - to be usable for save.
  428.  
  429.         mov (8)         mudMSGHDR_UVCOPY(1)<1>          udDNDI_UV_RESP(0)<8;8,1>
  430.         mov (8)         mudMSGHDR_UVCOPY(2)<1>          udDNDI_UV_RESP(1)<8;8,1>
  431.         send (8)        null<1>:d    r36        0x5    0x60A8019:ud
  432.  
  433.  
  434.  
  435. //End of Thread message
  436.  
  437. mov (8) r127<1>:ud r0.0<8;8,1>:ud
  438.  send (1) null<1>:d r127 0x27 0x02000010
  439.  
  440.  
  441. .end_code
  442. .end_kernel
  443.