New combined shaders for Ivybridge
authorXiang, Haihao <haihao.xiang@intel.com>
Wed, 22 Aug 2012 06:51:40 +0000 (02:51 -0400)
committerXiang, Haihao <haihao.xiang@intel.com>
Wed, 22 Aug 2012 06:57:33 +0000 (02:57 -0400)
In addtion, add the license header.

You need the latest intel-gen4asm to build these shaders

Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
47 files changed:
src/shaders/post_processing/gen7/DI_Core.g4a
src/shaders/post_processing/gen7/DI_Save_NV12_16x4.g4a
src/shaders/post_processing/gen7/DI_Save_PA_16x4.g4a
src/shaders/post_processing/gen7/EOT.g4a
src/shaders/post_processing/gen7/Makefile.am
src/shaders/post_processing/gen7/NV12_DNDI_422CP.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/NV12_DNDI_PA.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/NV12_DNUV_NV12.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/NV12_DN_422CP.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/NV12_DN_NV12.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PA_AVS_Buf_0.g4a
src/shaders/post_processing/gen7/PA_AVS_Buf_1.g4a
src/shaders/post_processing/gen7/PA_AVS_Buf_2.g4a
src/shaders/post_processing/gen7/PA_AVS_Buf_3.g4a
src/shaders/post_processing/gen7/PA_DI_422CP.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PA_DI_PA.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PA_DNDI_422CP.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PA_DNDI_PA.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PA_DNUV_PA.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PA_DN_422CP.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PA_DN_PA.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PL2_AVS_Buf_0.g4a
src/shaders/post_processing/gen7/PL2_AVS_Buf_1.g4a
src/shaders/post_processing/gen7/PL2_AVS_Buf_2.g4a
src/shaders/post_processing/gen7/PL2_AVS_Buf_3.g4a
src/shaders/post_processing/gen7/PL3_AVS_Buf_0.g4a
src/shaders/post_processing/gen7/PL3_AVS_Buf_1.g4a
src/shaders/post_processing/gen7/PL3_AVS_Buf_2.g4a
src/shaders/post_processing/gen7/PL3_AVS_Buf_3.g4a
src/shaders/post_processing/gen7/PL3_DNDI_422CP.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PL3_DNDI_PA.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PL3_DNUV_PL3.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PL3_DN_422CP.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PL3_DN_PL3.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PL_DI_422CP.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/PL_DI_PA.g4a [new file with mode: 0644]
src/shaders/post_processing/gen7/Save_AVS_NV12.g4a
src/shaders/post_processing/gen7/Save_AVS_PA.g4a
src/shaders/post_processing/gen7/Save_AVS_PL3.g4a
src/shaders/post_processing/gen7/Save_AVS_RGB.g4a
src/shaders/post_processing/gen7/Set_AVS_Buf_0123_BGRA.g4a
src/shaders/post_processing/gen7/Set_AVS_Buf_0123_PL2.g4a
src/shaders/post_processing/gen7/Set_AVS_Buf_0123_PL3.g4a
src/shaders/post_processing/gen7/Set_AVS_Buf_0123_VUYA.g4a
src/shaders/post_processing/gen7/Set_AVS_Buf_0123_VYUA.g4a
src/shaders/post_processing/gen7/Set_Layer_0.g4a
src/shaders/post_processing/gen7/VP_Setup.g4a

index a1e5fe5..952e1d4 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   22    // Total instruction count
 //    1    // Total kernel count
 
index 20dae16..68ef504 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   20    // Total instruction count
 //    1    // Total kernel count
 
index b52e3da..a59054d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   33    // Total instruction count
 //    1    // Total kernel count
 
index 5943692..9523b4c 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    2    // Total instruction count
 //    1    // Total kernel count
 
index 3127218..dbe552e 100644 (file)
@@ -16,10 +16,22 @@ INTEL_PP_G4A = \
        DI_Save_NV12_16x4.g4a           \
        DI_Save_PA_16x4.g4a             \
        EOT.g4a                         \
+       NV12_DNDI_422CP.g4a             \
+       NV12_DNDI_PA.g4a                \
+       NV12_DNUV_NV12.g4a              \
+       NV12_DN_422CP.g4a               \
+       NV12_DN_NV12.g4a                \
        PA_AVS_Buf_0.g4a                \
        PA_AVS_Buf_1.g4a                \
        PA_AVS_Buf_2.g4a                \
        PA_AVS_Buf_3.g4a                \
+       PA_DI_422CP.g4a                 \
+       PA_DI_PA.g4a                    \
+       PA_DNDI_422CP.g4a               \
+       PA_DNDI_PA.g4a                  \
+       PA_DNUV_PA.g4a                  \
+       PA_DN_422CP.g4a                 \
+       PA_DN_PA.g4a                    \
        PL2_AVS_Buf_0.g4a               \
        PL2_AVS_Buf_1.g4a               \
        PL2_AVS_Buf_2.g4a               \
@@ -28,6 +40,13 @@ INTEL_PP_G4A = \
        PL3_AVS_Buf_1.g4a               \
        PL3_AVS_Buf_2.g4a               \
        PL3_AVS_Buf_3.g4a               \
+       PL3_DNDI_422CP.g4a              \
+       PL3_DNDI_PA.g4a                 \
+       PL3_DNUV_PL3.g4a                \
+       PL3_DN_422CP.g4a                \
+       PL3_DN_PL3.g4a                  \
+       PL_DI_422CP.g4a                 \
+       PL_DI_PA.g4a                    \
        Save_AVS_PA.g4a                 \
        Save_AVS_PL3.g4a                \
        Save_AVS_NV12.g4a               \
diff --git a/src/shaders/post_processing/gen7/NV12_DNDI_422CP.g4a b/src/shaders/post_processing/gen7/NV12_DNDI_422CP.g4a
new file mode 100644 (file)
index 0000000..0c0002f
--- /dev/null
@@ -0,0 +1,557 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//  116    // Total instruction count
+//    1    // Total kernel count
+
+.kernel NV12_DNDI_422CP
+.code
+
+
+
+// FileName:   DNDI_PL_Core.asm
+// Author:             Tatiya, Rupesh
+
+
+
+// FileName:   DNDI_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN+DI case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4BE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+       mov (1)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(9,0)<0;1,0>         // Move denoise history to MRF (4x1)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x3:ud                                                                  { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Load_UV_NV12_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x4 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Load_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x4 block through DATAPORT 
+
+
+       add (2)         r27.0<1>:d                              r7.0<2;2,1>:w                           r4.4<2;2,1>:w                           // Source Y Block origin
+       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
+       mov (1)         r27.2<1>:ud                             0x1000F:ud                                      { NoDDChk }             // U/V block width and height (8x4)
+    mov (8)     mudMSGHDR_UVCOPY(0)<1>         r27.0<8;8,1>:ud
+       send (8)        udDNDI_UV_RESP(0)<1>            r36     0x4     0x2190001:ud
+
+
+
+// FileName:   DN_Save_Y_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save one 16x4 blocks of Y channel of DN output for reference
+
+
+ // check top/bottom field first
+cmp.e.f0.0 (1)  null<1>:w               r1.28<0;1,0>:ub     1:w
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                                            // message header   
+mov (2)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<2;2,1>:w                           { NoDDClr }             // X origin * 2 (422 output)
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x3000F:ud              { NoDDChk }             // block width and height (32x8)
+
+(f0.0) jmpi (1) TOP_FIELD_FIRST
+
+BOTTOM_FIELD_FIRST:
+
+       mov (4)     mudMSGHDR_DN_OUT(1,0)<1>    udDNDI_RESP(10,0)<4;4,1>        { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(1,4)<1>    udDNDI_RESP(4,4)<4;4,1>                 { NoDDChk }             // 1st field luma from current frame (line 1,3)
+       mov (4)     mudMSGHDR_DN_OUT(2,0)<1>    udDNDI_RESP(10,4)<4;4,1>        { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(2,4)<1>   udDNDI_RESP(5,4)<4;4,1>          { NoDDChk }             // 1st field luma from current frame (line 1,3)    
+
+       jmpi (1) SAVE_DN_CURR
+
+TOP_FIELD_FIRST:
+       mov (4)     mudMSGHDR_DN_OUT(1,0)<1>    udDNDI_RESP(4,0)<4;4,1>                 { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(1,4)<1>    udDNDI_RESP(10,0)<4;4,1>        { NoDDChk }             // 1st field luma from current frame (line 1,3)
+       mov (4)     mudMSGHDR_DN_OUT(2,0)<1>    udDNDI_RESP(5,0)<4;4,1>                 { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(2,4)<1>   udDNDI_RESP(10,4)<4;4,1>         { NoDDChk }             // 1st field luma from current frame (line 1,3)
+
+SAVE_DN_CURR:
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0x60A8018:ud     
+
+
+
+// FileName:    DI_Save_422CP_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in 422 format to Color Pipe (IECP)
+
+
+.declare mubMSGHDR_DI_OUT1_1  Base=r18.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT1_2  Base=r21.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_1  Base=r24.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_2  Base=r27.0      ElementSize=1  Type=ub
+
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:ud     r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:ud     r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3000F:ud        { NoDDClr, NoDDChk }       // Block width and height (16x8)
+
+//M0.3  - 0 - CP Enable, 1 - Area of Interest, 3:2 Message Format(TBD), 4:3 - Ignored, 31:5 CP state pointer
+//Compose area-of-interest bit + color pipe state pointer
+or (1)  r27.3<1>:ud     r2.4<0;1,0>:ud     r7.26<0;1,0>:b     { NoDDChk }
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r24.0<1>:ud       r27<8;8,1>:ud
+
+
+// Pack 2nd field Y; First 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT1_1(1)<2>                       ubDNDI_RESP(0,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(1,16)<2>            ubDNDI_RESP(0,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2)<2>                       ubDNDI_RESP(0,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2,16)<2>            ubDNDI_RESP(0,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; First 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,1)<4>                 ubDNDI_RESP(2,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,17)<4>        ubDNDI_RESP(2,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,3)<4>         ubDNDI_RESP(2,0)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,19)<4>        ubDNDI_RESP(2,16)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,1)<4>                 ubDNDI_RESP(2,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,17)<4>        ubDNDI_RESP(2,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,3)<4>         ubDNDI_RESP(2,32)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,19)<4>        ubDNDI_RESP(2,48)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+
+// Pack 2nd field Y; Second 8x4 block
+mov    (8)     r21.0<1>:ud             r18.0<8;8,1>:ud
+add    (1)     r21.0<1>:ud             r21.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT1_2(1)<2>                       ubDNDI_RESP(0,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(1,16)<2>            ubDNDI_RESP(0,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2)<2>                       ubDNDI_RESP(0,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2,16)<2>            ubDNDI_RESP(0,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; Second 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,1)<4>                 ubDNDI_RESP(2,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,17)<4>                ubDNDI_RESP(2,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,3)<4>                 ubDNDI_RESP(2,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,19)<4>                ubDNDI_RESP(2,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,1)<4>                 ubDNDI_RESP(2,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,17)<4>                ubDNDI_RESP(2,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,3)<4>                 ubDNDI_RESP(2,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,19)<4>                ubDNDI_RESP(2,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r18.0   0x5     0x60A801B:ud
+send (8)    null<1>:d    r21.0   0x5     0x60A801B:ud
+
+// Pack 1st field Y; 1st 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT2_1(1)<2>                       ubDNDI_RESP(4,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(1,16)<2>            ubDNDI_RESP(4,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2)<2>                       ubDNDI_RESP(4,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2,16)<2>            ubDNDI_RESP(4,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U,V; 1st 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,1)<4>                 ubDNDI_RESP(6,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,17)<4>        ubDNDI_RESP(6,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,3)<4>         ubDNDI_RESP(6,0)<8;4,2>             { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,19)<4>        ubDNDI_RESP(6,16)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,1)<4>                 ubDNDI_RESP(6,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,17)<4>        ubDNDI_RESP(6,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,3)<4>         ubDNDI_RESP(6,32)<8;4,2>                    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,19)<4>        ubDNDI_RESP(6,48)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+
+// Pack 1st field Y; 2nd 8x4 block
+mov    (8)     r27.0<1>:ud             r24.0<8;8,1>:ud
+add    (1)     r27.0<1>:ud             r27.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT2_2(1)<2>                       ubDNDI_RESP(4,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(1,16)<2>            ubDNDI_RESP(4,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2)<2>                       ubDNDI_RESP(4,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2,16)<2>            ubDNDI_RESP(4,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U, V; 2nd 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,1)<4>                 ubDNDI_RESP(6,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,17)<4>                ubDNDI_RESP(6,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,3)<4>                 ubDNDI_RESP(6,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,19)<4>                ubDNDI_RESP(6,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,1)<4>                 ubDNDI_RESP(6,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,17)<4>                ubDNDI_RESP(6,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,3)<4>                 ubDNDI_RESP(6,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,19)<4>                ubDNDI_RESP(6,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r24.0     0x5     0x60A801E:ud
+send (8)    null<1>:d    r27.0     0x5     0x60A801E:ud
+
+
+
+// FileName:   DN_Save_UV_NV12_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x4 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Save_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x4 block through DATAPORT 
+
+
+//Reuse the header from Load component
+
+       mov (8)         mudMSGHDR_UVCOPY(1)<1>          udDNDI_UV_RESP(0)<8;8,1>
+       send (8)        null<1>:d    r36        0x5    0x40A8019:ud 
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/NV12_DNDI_PA.g4a b/src/shaders/post_processing/gen7/NV12_DNDI_PA.g4a
new file mode 100644 (file)
index 0000000..7fd55b0
--- /dev/null
@@ -0,0 +1,495 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   86    // Total instruction count
+//    1    // Total kernel count
+
+.kernel NV12_DNDI_PA
+.code
+
+
+
+// FileName:   DNDI_PL_Core.asm
+// Author:             Tatiya, Rupesh
+
+
+
+// FileName:   DNDI_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN+DI case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4BE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+       mov (1)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(9,0)<0;1,0>         // Move denoise history to MRF (4x1)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x3:ud                                                                  { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Load_UV_NV12_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x4 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Load_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x4 block through DATAPORT 
+
+
+       add (2)         r27.0<1>:d                              r7.0<2;2,1>:w                           r4.4<2;2,1>:w                           // Source Y Block origin
+       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
+       mov (1)         r27.2<1>:ud                             0x1000F:ud                                      { NoDDChk }             // U/V block width and height (8x4)
+    mov (8)     mudMSGHDR_UVCOPY(0)<1>         r27.0<8;8,1>:ud
+       send (8)        udDNDI_UV_RESP(0)<1>            r36     0x4     0x2190001:ud
+
+
+
+// FileName:   DN_Save_Y_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save one 16x4 blocks of Y channel of DN output for reference
+
+
+ // check top/bottom field first
+cmp.e.f0.0 (1)  null<1>:w               r1.28<0;1,0>:ub     1:w
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                                            // message header   
+mov (2)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<2;2,1>:w                           { NoDDClr }             // X origin * 2 (422 output)
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x3000F:ud              { NoDDChk }             // block width and height (32x8)
+
+(f0.0) jmpi (1) TOP_FIELD_FIRST
+
+BOTTOM_FIELD_FIRST:
+
+       mov (4)     mudMSGHDR_DN_OUT(1,0)<1>    udDNDI_RESP(10,0)<4;4,1>        { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(1,4)<1>    udDNDI_RESP(4,4)<4;4,1>                 { NoDDChk }             // 1st field luma from current frame (line 1,3)
+       mov (4)     mudMSGHDR_DN_OUT(2,0)<1>    udDNDI_RESP(10,4)<4;4,1>        { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(2,4)<1>   udDNDI_RESP(5,4)<4;4,1>          { NoDDChk }             // 1st field luma from current frame (line 1,3)    
+
+       jmpi (1) SAVE_DN_CURR
+
+TOP_FIELD_FIRST:
+       mov (4)     mudMSGHDR_DN_OUT(1,0)<1>    udDNDI_RESP(4,0)<4;4,1>                 { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(1,4)<1>    udDNDI_RESP(10,0)<4;4,1>        { NoDDChk }             // 1st field luma from current frame (line 1,3)
+       mov (4)     mudMSGHDR_DN_OUT(2,0)<1>    udDNDI_RESP(5,0)<4;4,1>                 { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(2,4)<1>   udDNDI_RESP(10,4)<4;4,1>         { NoDDChk }             // 1st field luma from current frame (line 1,3)
+
+SAVE_DN_CURR:
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0x60A8018:ud     
+
+
+
+// FileName:    DI_Save_PA_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in Packed format
+
+
+add (4) a0.4<1>:uw   r2.28<4;4,1>:ub   608:w               // Initial Y,U,V offset in YUV422 block; it starts at m20
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:d      r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:d      r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3001F:ud          { NoDDChk }          // Block width and height (32x8)
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r23.0<1>:ud       r27<8;8,1>:ud
+
+// Pack 2nd field Y
+    mov (16)    r[a0.4, 0]<2>      ubDNDI_RESP(0,0)               { NoDDClr }
+    mov (16)    r[a0.4, 32]<2>      ubDNDI_RESP(0,16)               { NoDDClr }
+    mov (16)    r[a0.4, 64]<2>      ubDNDI_RESP(0,32)               { NoDDClr }
+    mov (16)    r[a0.4, 96]<2>      ubDNDI_RESP(0,48)               { NoDDClr }
+// Pack 2nd field U
+    mov (8)     r[a0.5, 0]<4>      ubDNDI_RESP(2,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 32]<4>      ubDNDI_RESP(2,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 64]<4>      ubDNDI_RESP(2,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 96]<4>      ubDNDI_RESP(2,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 2nd field V
+    mov (8)     r[a0.6, 0]<4>      ubDNDI_RESP(2,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 32]<4>      ubDNDI_RESP(2,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 64]<4>      ubDNDI_RESP(2,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 96]<4>      ubDNDI_RESP(2,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+// Pack 1st field Y
+    mov (16)    r[a0.4, 160]<2>    ubDNDI_RESP(4,0)               { NoDDClr }
+    mov (16)    r[a0.4, 192]<2>    ubDNDI_RESP(4,16)               { NoDDClr }
+    mov (16)    r[a0.4, 224]<2>    ubDNDI_RESP(4,32)               { NoDDClr }
+    mov (16)    r[a0.4, 256]<2>    ubDNDI_RESP(4,48)               { NoDDClr }
+// Pack 1st field U
+    mov (8)     r[a0.5, 160]<4>    ubDNDI_RESP(6,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 192]<4>    ubDNDI_RESP(6,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 224]<4>    ubDNDI_RESP(6,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 256]<4>    ubDNDI_RESP(6,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 1st field V
+    mov (8)     r[a0.6, 160]<4>    ubDNDI_RESP(6,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 192]<4>    ubDNDI_RESP(6,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 224]<4>    ubDNDI_RESP(6,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 256]<4>    ubDNDI_RESP(6,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+//save the previous frame
+send (8)    null<1>:d    r18.0     0x5     0xA0A801B:ud
+
+//save the current frame
+send (8)    null<1>:d    r23.0     0x5     0xA0A801E:ud
+
+
+
+// FileName:   DN_Save_UV_NV12_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x4 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Save_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x4 block through DATAPORT 
+
+
+//Reuse the header from Load component
+
+       mov (8)         mudMSGHDR_UVCOPY(1)<1>          udDNDI_UV_RESP(0)<8;8,1>
+       send (8)        null<1>:d    r36        0x5    0x40A8019:ud 
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/NV12_DNUV_NV12.g4a b/src/shaders/post_processing/gen7/NV12_DNUV_NV12.g4a
new file mode 100644 (file)
index 0000000..f560ef8
--- /dev/null
@@ -0,0 +1,2491 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+// 1153    // Total instruction count
+//    1    // Total kernel count
+
+
+.kernel NV12_DNUV_NV12
+.code
+
+
+
+//Module               : DN_UV_Setup
+//Author               : Tatiya, Rupesh
+//Description  : Initial Set-up for DN_UV
+
+
+
+
+// Module name : ChromaDenoise.inc
+// Author              : Tatiya, Rupesh
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//======================================================
+//Interface for serpent mode Chroma Denoise, added by Le
+//======================================================
+//r1
+
+
+//noise history thresholds (low and high)
+
+
+//temporal difference thresholds (high and low)
+
+
+//noise history thresholds (low and high)
+//#define ubNoiseHistMaxHigh  r1.22
+//#define ubNoiseHistMaxLow  r1.23
+//#define ubNoiseHistDeltaHigh  r1.24
+//#define ubNoiseHistDeltaLow  r1.25
+
+//Gaussian thresholds
+
+
+//temporal difference thresholds (default)
+
+
+//r2
+//history thresholds (default)
+
+
+//denoise factor  (0-63)
+
+
+//====================== Binding table (Explicit To DNUV)=========================================
+//Used by DN_UV kernels
+
+
+       //Pointer to Current Frame UV
+
+
+//r1-r6
+       //CURBE GRFs used as TEMP : Used for max computation and storing max temporarily. : r1-r6
+
+
+       .declare        ubCURBE_TEMP    Base=r1.0       ElementSize=1   Type=ub
+       .declare        uwCURBE_TEMP    Base=r1.0       ElementSize=2   Type=uw
+       .declare        wCURBE_TEMP             Base=r1.0       ElementSize=2   Type=w
+       .declare        fCURBE_TEMP             Base=r1.0       ElementSize=4   Type=f
+       .declare        udCURBE_TEMP            Base=r1.0       ElementSize=4   Type=ud
+       .declare        uwMAX_ABS_DIFF  Base=r5.0       ElementSize=2   Type=uw
+
+       //r1
+
+
+       //r3
+
+
+    //r4
+
+//r7
+       //All of the following has to defined in Same GRF for optimal performance.
+
+
+//r8-24
+    //Previous Frame UV
+
+       .declare        udPREV_UV               Base=r8.0       ElementSize=4   Type=ud
+       .declare        ubPREV_UV               Base=r8.0       ElementSize=1   Type=ub
+
+
+//r25-48
+       //TEMP Space for any Usage.
+
+
+//=========================================================================
+//Definations and declarations for serpent mode Chroma Denoise, added by Le
+//=========================================================================      
+
+
+       .declare        udGNE_UV                Base=r24.0      ElementSize=4   Type=ud
+  .declare     fGNE_UV         Base=r24.0      ElementSize=4   Type=f
+  .declare     ubGNE_UV                Base=r24.0      ElementSize=1   Type=ub
+
+  .declare     udMSGHDR_BNE_SERP       Base=r25.0      ElementSize=4   Type=ud
+  .declare     udMSGSRC_BNE_SERP       Base=r26.0      ElementSize=4   Type=ud
+
+
+  .declare     ubDN_UV_Thresholds Base=r26.0   ElementSize=1   Type=ub
+  .declare     ubDN_UV_Thresholds_Temp  Base=r27.0     ElementSize=1   Type=ub
+  .declare     udDN_UV_Thresholds Base=r26.0   ElementSize=4   Type=ud
+  .declare     udDN_UV_Thresholds_Temp Base=r27.0      ElementSize=4   Type=ud
+  .declare     fDN_UV_Thresholds Base=r26.0    ElementSize=4   Type=f
+  .declare     fDN_UV_Thresholds_Temp Base=r27.0       ElementSize=4   Type=f  
+
+
+//====================================================================================
+
+
+       //TEMP23: To hold V data for PL3 surfaces
+       .declare        udCURR_V_TEMP   Base=r25.0      ElementSize=4   Type=ud
+       .declare        ubCURR_V_TEMP   Base=r25.0      ElementSize=1   Type=ub
+
+       //GRFs to calculate Median: r25-r42
+       .declare        ubMEDIAN_TEMP   Base=r25.0      ElementSize=1   Type=ub
+
+       //18 GRFs to hold difference : r25-r42
+       .declare        wDIFF                   Base=r25.0      ElementSize=2   Type=w
+       .declare        uwDIFF                  Base=r25.0      ElementSize=2   Type=uw
+
+       //Temporal Diff
+       .declare        wDIFF_TEMPORAL                  Base=r25.0      ElementSize=2   Type=w
+       .declare        ubDIFF_TEMPORAL                 Base=r25.0      ElementSize=1   Type=ub
+
+       //4 GRFs to hold Sobel Value : r43-46
+       .declare        wSOBEL_X        Base=r43.0      ElementSize=2   Type=w
+       .declare        uwSOBEL         Base=r43.0      ElementSize=2   Type=uw
+
+
+       //2 GRFs to hold SOAD temporarily: r47-48
+       .declare        uwSOAD                  Base=r47.0      ElementSize=2   Type=uw
+
+       //Temp GRFs to hold extra YUYV pixels: r43-r48
+       .declare        ubTEMP5                 Base=r43.0      ElementSize=1   Type=ub
+
+       //Temp GRFs in Median Calculation: r47-r48
+       .declare        ubTEMP1                 Base=r47.0      ElementSize=1   Type=ub
+
+       .declare        uwTEMP0                 Base=r48.0      ElementSize=2   Type=uw
+       .declare        ubTEMP0                 Base=r48.0      ElementSize=1   Type=ub
+
+       //Temp Space to store Median : r49-50
+
+       .declare        ubMEDIAN        Base=r49.0      ElementSize=1   Type=ub
+
+//r49
+
+
+//r50
+    //Message Source
+
+
+//r51
+       //DN_UV History Surface
+
+       .declare        udHIST_UV               Base=r51.0      ElementSize=4   Type=ud
+       .declare        ubHIST_UV               Base=r51.0      ElementSize=1   Type=ub
+
+//r52 - r91
+       //r52
+       //Current Frame UV
+
+
+       .declare        udCURR_UV               Base=r52.0      ElementSize=4   Type=ud
+       .declare        ubCURR_UV               Base=r52.0      ElementSize=1   Type=ub
+
+       //r54
+       //CURBE COPY
+
+
+       //r55
+
+
+       .declare        uwSOAD_MIN_8x4          Base=r56.0      ElementSize=2   Type=uw
+
+       //r61
+
+
+       //r62
+
+
+       //History Surface Temp Origin
+
+
+    //r63
+    //Current Frame Y Temp Origin
+
+
+       //BNE Surface Origin
+
+
+    //r70
+
+       .declare        uwDIFF_TEMPORAL_SUM4x4  Base=r70.0      ElementSize=2   Type=uw  //4 GRFs
+
+       //r74-91 : For Saving Dest UV (PL2/PL3)
+
+
+       .declare        ubMSGPAYLOAD_UV0        Base=r75.0      ElementSize=1   Type=ub
+
+
+       .declare        ubMSGPAYLOAD_U          Base=r75.0      ElementSize=1   Type=ub
+
+
+       .declare        ubMSGPAYLOAD_UV1        Base=r84.0      ElementSize=1   Type=ub
+
+
+       .declare        ubMSGPAYLOAD_V          Base=r84.0      ElementSize=1   Type=ub
+
+       //r90
+
+       .declare        uwDIFF_TEMPORAL_SUM4x4_FINAL    Base=r90.0      ElementSize=2   Type=uw  //2 GRFs
+
+//r92-127
+       //Current Frame Y
+
+
+       //r92
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_0           Base=r92        ElementSize=2   Type=uw
+       //r101
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_1           Base=r101       ElementSize=2   Type=uw
+       //r110
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_2           Base=r110       ElementSize=2   Type=uw
+       //r119
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_3           Base=r119       ElementSize=2   Type=uw
+
+       .declare        udCURR_Y0               Base=r93.0      ElementSize=4   Type=ud
+    .declare   ubCURR_Y0               Base=r93.0      ElementSize=1   Type=ub
+    .declare   udCURR_Y1               Base=r102.0     ElementSize=4   Type=ud
+       .declare        ubCURR_Y1               Base=r102.0     ElementSize=1   Type=ub
+       .declare        udCURR_Y2               Base=r111.0     ElementSize=4   Type=ud
+       .declare        ubCURR_Y2               Base=r111.0     ElementSize=1   Type=ub
+       .declare        udCURR_Y3               Base=r120.0     ElementSize=4   Type=ud
+       .declare        ubCURR_Y3               Base=r120.0     ElementSize=1   Type=ub
+
+       //r92: To hold U data for PL3 surfaces
+       .declare        udCURR_U_TEMP           Base=r92.0      ElementSize=4   Type=ud
+    .declare   ubCURR_U_TEMP           Base=r92.0      ElementSize=1   Type=ub
+
+    //r112: To hold U data for PL3 surfaces
+       .declare        udPREV_U_TEMP           Base=r112.0     ElementSize=4   Type=ud
+       .declare        ubPREV_U_TEMP           Base=r112.0     ElementSize=1   Type=ub
+
+       //r120: To hold U data for PL3 surfaces
+       .declare        udPREV_V_TEMP           Base=r120.0     ElementSize=4   Type=ud
+       .declare        ubPREV_V_TEMP           Base=r120.0     ElementSize=1   Type=ub
+
+
+       // Initialize message source with r0.
+       mov (8)   r50.0<1>:ud           r0.0<8;8,1>:ud
+       mov (8)   r92.0<1>:ud           r0.0<8;8,1>:ud
+       mov (8)   r101.0<1>:ud          r0.0<8;8,1>:ud
+       mov (8)   r110.0<1>:ud          r0.0<8;8,1>:ud
+       mov (8)   r119.0<1>:ud          r0.0<8;8,1>:ud
+
+
+
+//Module Name  :       DN_UV_PL2_Load_Curr_Frame_UV
+//Author               :       Tatiya, Rupesh
+//Description  :       Loads Current Frame UV data for PL2 input.
+
+
+
+//Module name  :  DN_UV_Load_Curr_Frame_UV
+//Author               :  Tatiya, Rupesh
+//Description  :  Loads Current Frame (UV only).
+//                                We need 4 extra rows (2 per field) and 2 extra pixel (1 each side) for both U and V each.
+//                                The processing size is 16x16 U and V each. So we need : U size - 18x20, V size - 18x20, UV size - 36x20, YUYV size - 72x20.
+
+
+
+
+//36x20 interleaved UV block is partitioned as follows:
+//                             <------ 18 --------> <--------18 ------->
+//                             -----------------------------------------
+//                             |               20x8   A        !|    20x8     D    !
+//                             |      (overlapped) !|   (overlapped)   !
+//                             |-------------------!|------------------!
+//                             |       20x8   B    !|      20x8   E    !
+//                             |      (overlapped) !|     (overlapped) !
+//                             |-------------------!|------------------!
+//                             |               20x4   C    !|          20x4   F    !
+//                             |     (overlapped)      !|    (overlapped)      !
+//                             -----------------------------------------
+//
+// Cordinates: (x-2, y-2), (x+14, y-2), (x-2, y+6), (x+14, y+6), (x-2, y+14), (x+14, y+14)
+
+       //UV surface origin: (ORIX, ORIY/2)
+       add  (2)        r7.4<1>:w               r7.0<2;2,1>:w           r4.4<2;2,1>:w    { AccWrEn } // Source Block origin
+       shr  (1)        r7.5<1>:w               acc0.5<0;1,0>:w         1:w
+       mov  (2)        acc0.0<1>:d                                                     r7.4<2;2,1>:w
+
+       //A
+       add  (2)        r50.0<1>:d      acc0.0<2;2,1>:d         -2:d                                    { AccWrEn }
+       mov  (1)        r50.2<1>:ud     0x70013:ud                      
+       send (8)        udCURR_UV(0)<1>                 r50             0x4     0x2890004:ud
+
+       //B
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 8:d
+       send (8)        udCURR_UV(8)<1>                 r50             0x4     0x2890004:ud
+
+       //C
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 16:d                            
+       mov  (1)        r50.2<1>:ud     0x30013:ud                      
+       send (8)        udCURR_UV(16)<1>                r50             0x4     0x2490004:ud
+
+       //D
+       add  (1)    r50.0<1>:d  acc0.0<0;1,0>:d                 16:d                            { AccWrEn }
+       mov  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                                                         
+       mov  (1)        r50.2<1>:ud     0x70013:ud                      
+       send (8)        udCURR_UV(20)<1>                r50             0x4     0x2890004:ud
+
+       //E
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 8:d
+       send (8)        udCURR_UV(28)<1>                r50             0x4     0x2890004:ud
+
+       //F
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 16:d                                    
+       mov  (1)        r50.2<1>:ud     0x30013:ud                              
+       send (8)        udCURR_UV(36)<1>                r50             0x4     0x2490004:ud
+
+       //History Origin, Current Y origin and BNE surface origin - all are in inline GRF. Use , . -rT.
+
+       //Calculate Origin For History Surface: (ORIX/4, ORIY/8)
+       mov  (16)   acc0.0<1>:w                                         r7.0<0;2,1>:w
+       shr  (1)        r7.2<1>:w               acc0.2<0;1,0>:w 2:w                     
+       shr  (1)        r7.3<1>:w               acc0.3<0;1,0>:w 3:w                     
+
+       //Calculate Origin For BNE Surface: (ORIX/8, ORIY/16)
+       shr  (1)        r7.6<1>:w               acc0.6<0;1,0>:w         3:w             
+       shr  (1)        r7.7<1>:w               acc0.7<0;1,0>:w         4:w             
+
+
+
+//Module Name  :       DN_UV_PL2_Load_Prev_Frame_UV
+//Author               :       Tatiya, Rupesh
+//Description  :       Loads Pevious Frame UV data for PL2 input.
+
+
+
+//Module Name  :       DN_UV_Load_Prev_Frame_UV
+//Author               :       Tatiya, Rupesh
+//Description  :   Loads Prev Frame (UV only). U size - 16x16, V size - 16x16, UV size - 32x16, YUYV size - 64x16.
+
+
+
+
+       mov  (2)        r50.0<1>:d              r7.4<2;2,1>:w                   { AccWrEn }     // Source lock origin
+       mov  (1)        r50.2<1>:ud             0xF000F:ud                                              // U/V block width and height (16x16)
+       send (8)        udPREV_UV(0)<1>         r50             0x4     0x2890001:ud
+
+       add  (1)        r50.0<1>:ud             acc0.0<0;1,0>:d         16:w                                                                            // Add 16 to X origin
+       send (8)        udPREV_UV(8)<1>         r50             0x4     0x2890001:ud
+
+
+       //TODO - See if History loading can be combined with Prev Frame Load. - rT
+
+
+//Module name  :  DN_UV_Load_Hist_UV
+//Author               :  Tatiya, Rupesh
+//Description  :  Load DN History for UV denoise. 4x4 for each U & V.
+
+
+
+
+       mov  (2)        r50.0<1>:d      r7.2<2;2,1>:w                   
+       mov  (1)        r50.2<1>:ud     0x30007:ud              
+       send (8)        udHIST_UV(0)<1>                 r50             0x4     0x2190022:ud
+
+
+
+//Module Name  : DN_UV_420_Load_Curr_Frame_Y
+//Author               : Tatiya, Rupesh
+//Description  : Load Curr Frame Y data for 420 Input
+
+
+
+//Module Name  : DN_UV_Load_Curr_Frame_Y
+//Author               : Tatiya, Rupesh
+//Description  : Loads Y of Current frame.
+
+
+
+
+       //For 16x16 U and 16x16 V for 420, we need to read 32x32 Y.
+
+       mov (8)         acc0.0<1>:ud            r0.0<8;8,1>:ud
+       mov (1)         acc0.2<1>:ud            0xF000F:ud
+       add (2)         acc0.0<1>:ud            r7.0<2;2,1>:w           r4.4<2;2,1>:w
+
+       mov (8)     r92.0<1>:ud acc0.0<8;8,1>:ud
+
+       mov (8)     r101.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r110.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r119.0<1>:ud        acc0.0<8;8,1>:ud
+
+       add (1)         r101.1<1>:d     acc0.1<0;1,0>:d                 16:d
+
+       add (1)         r110.0<1>:d     acc0.0<0;1,0>:d                 16:d
+
+       add (2)         r119.0<1>:d     acc0.0<2;2,1>:d                 16:d
+
+       send (8)        udCURR_Y0(0)<1>         r92             0x4     0x2890003:ud
+       send (8)        udCURR_Y1(0)<1>         r101            0x4     0x2890003:ud
+       send (8)        udCURR_Y2(0)<1>         r110            0x4     0x2890003:ud
+       send (8)        udCURR_Y3(0)<1>         r119            0x4     0x2890003:ud
+
+
+
+//Module Name : DN_UV_Noise_Detection_UV
+//Author         : Tatiya, Rupesh
+//Description : Performs noise detection on 16x16 U and 16x16 V each.
+
+
+
+//Module Name  : DN_UV_Move_CURBE_Inline_UV.asm
+//Author               : Tatiya, Rupesh
+
+
+
+
+       //Mov CURBE data to another space - so that it can be used as Temp Space --> r1 - r6
+       mov (4) r54.28<1>:ub            r2.28<4;4,1>:ub         //Dest. YUY2 offset
+       mov (2) r54.5<1>:ud             r4.0<4;2,2>:ud          //Src YUY2 offset and Origin offset
+       mov (4) r55.28<1>:ub            r1.0<4;4,1>:ub
+
+       mov (8) r61.20<1>:ub            r1.4<8;8,1>:ub          
+       mov (4) r61.28<1>:ub            r1.12<4;4,1>:ub         
+
+       //Move Inline Data to another space - so that it can be used as Temp Space --> r7
+       mov (4) r62.10<1>:w                             r7.0<4;4,1>:w
+       mov (4) r63.10<1>:w             r7.4<4;4,1>:w
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       mov (1) a0.0:uw                         1664:uw                         
+       mov (1) a0.1:uw 1816:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         1792:uw                 
+       mov (1) a0.1:uw 1820:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         1920:uw                 
+       mov (1) a0.1:uw 1848:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2048:uw                 
+       mov (1) a0.1:uw 1852:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       mov (1) a0.0:uw                         2304:uw                 
+       mov (1) a0.1:uw 1880:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2432:uw                 
+       mov (1) a0.1:uw 1884:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2560:uw                 
+       mov (1) a0.1:uw 1912:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2688:uw                 
+       mov (1) a0.1:uw 1916:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+//Module               : DN_UV_Noise_Reduction_UV
+//Author               : Tatiya, Rupesh
+//Description  : Performs Noise Reduction on 16x16 U and 16x16 V.
+//Tasks                        : 1. Update weight history
+//                               2. Find if it block is motion block
+//                               3. Compute Denoised Pixel.
+
+
+
+
+//History is 1+1 byte every 4x4 U and 4x4 V.
+
+       cmp.l.f0.0 (16) null<1>:w               ubHIST_UV(0,0)<16;16,1>         r61.20<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w               ubHIST_UV(0,0)<16;16,1>         r61.22<0;2,1>:ub
+
+       mov (16)        uwCURBE_TEMP(0)<1>      0:w
+       mov (16)        uwCURBE_TEMP(1)<1>      0:w
+
+       //Compute diff betn curr and prev. - First 16 lines
+       // 8 lines here
+    add (16)   wDIFF_TEMPORAL(0)<1>                    ubCURR_UV(2,2)<16;16,1>         -ubPREV_UV(0,0)<16;16,1>                //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(1)<1>                    ubCURR_UV(3,2)<16;16,1>         -ubPREV_UV(0,16)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(2)<1>                    ubCURR_UV(4,2)<16;16,1>         -ubPREV_UV(0,32)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(3)<1>                    ubCURR_UV(5,2)<16;16,1>         -ubPREV_UV(0,48)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(4)<1>                    ubCURR_UV(6,2)<16;16,1>         -ubPREV_UV(0,64)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(5)<1>                    ubCURR_UV(7,2)<16;16,1>         -ubPREV_UV(0,80)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(6)<1>                    ubCURR_UV(8,2)<16;16,1>         -ubPREV_UV(0,96)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(7)<1>                    ubCURR_UV(9,2)<16;16,1>         -ubPREV_UV(0,112)<16;16,1>              //Diff UV interleaved
+
+       //Update WT HIST
+       (-f0.0) shr     (16) uwCURBE_TEMP(0)<1>         ubHIST_UV(0,0)<16;16,1>         1:w
+       (f1.0)  add     (16) uwCURBE_TEMP(2)<1>         ubHIST_UV(0,0)<16;16,1>         r61.24<0;2,1>:ub
+       (f0.0)  mov     (16) uwCURBE_TEMP(2)<1>         r61.20<0;2,1>:ub
+       (-f0.0.anyv) mov        (16) uwCURBE_TEMP(2)<1>         ubHIST_UV(0,0)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w               ubHIST_UV(0,16)<16;16,1>        r61.20<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w               ubHIST_UV(0,16)<16;16,1>        r61.22<0;2,1>:ub
+
+       //Compute diff betn curr and prev. - First 16 lines
+       // 8 more lines here
+    add (16)   wDIFF_TEMPORAL(8)<1>                    ubCURR_UV(10,2)<16;16,1>                -ubPREV_UV(0,128)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(9)<1>                    ubCURR_UV(11,2)<16;16,1>                -ubPREV_UV(0,144)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(10)<1>                   ubCURR_UV(12,2)<16;16,1>                -ubPREV_UV(0,160)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(11)<1>                   ubCURR_UV(13,2)<16;16,1>                -ubPREV_UV(0,176)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(12)<1>                   ubCURR_UV(14,2)<16;16,1>                -ubPREV_UV(0,192)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(13)<1>                   ubCURR_UV(15,2)<16;16,1>                -ubPREV_UV(0,208)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(14)<1>                   ubCURR_UV(16,2)<16;16,1>                -ubPREV_UV(0,224)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(15)<1>                   ubCURR_UV(17,2)<16;16,1>                -ubPREV_UV(0,240)<16;16,1>              //Diff UV interleaved
+
+       (-f0.0) shr     (16) uwCURBE_TEMP(1)<1>         ubHIST_UV(0,16)<16;16,1>        1:w
+       (f1.0)  add     (16) uwCURBE_TEMP(3)<1>         ubHIST_UV(0,16)<16;16,1>        r61.24<0;2,1>:ub
+       (f0.0)  mov     (16) uwCURBE_TEMP(3)<1>         r61.20<0;2,1>:ub
+       (-f0.0.anyv) mov(16) uwCURBE_TEMP(3)<1>         ubHIST_UV(0,16)<16;16,1>
+
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(0)<16;16,1> (abs)wDIFF_TEMPORAL(1)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(2)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(3)<16;16,1>
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(4)<16;16,1> (abs)wDIFF_TEMPORAL(5)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(6)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(7)<16;16,1>
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(8)<16;16,1> (abs)wDIFF_TEMPORAL(9)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(10)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(2)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(11)<16;16,1>
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(12)<16;16,1>        (abs)wDIFF_TEMPORAL(13)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(14)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(3)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(15)<16;16,1>
+
+//Compute diff betn curr and prev. - Second 16 lines
+//13 lines.
+    add (16)   wDIFF_TEMPORAL(16)<1>           ubCURR_UV(22,2)<16;16,1>                -ubPREV_UV(8,0)<16;16,1>                //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(17)<1>           ubCURR_UV(23,2)<16;16,1>                -ubPREV_UV(8,16)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(18)<1>           ubCURR_UV(24,2)<16;16,1>                -ubPREV_UV(8,32)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(19)<1>           ubCURR_UV(25,2)<16;16,1>                -ubPREV_UV(8,48)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(20)<1>           ubCURR_UV(26,2)<16;16,1>                -ubPREV_UV(8,64)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(21)<1>           ubCURR_UV(27,2)<16;16,1>                -ubPREV_UV(8,80)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(22)<1>           ubCURR_UV(28,2)<16;16,1>                -ubPREV_UV(8,96)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(23)<1>           ubCURR_UV(29,2)<16;16,1>                -ubPREV_UV(8,112)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(24)<1>           ubCURR_UV(30,2)<16;16,1>                -ubPREV_UV(8,128)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(25)<1>           ubCURR_UV(31,2)<16;16,1>                -ubPREV_UV(8,144)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(26)<1>           ubCURR_UV(32,2)<16;16,1>                -ubPREV_UV(8,160)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(27)<1>           ubCURR_UV(33,2)<16;16,1>                -ubPREV_UV(8,176)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(28)<1>           ubCURR_UV(34,2)<16;16,1>                -ubPREV_UV(8,192)<16;16,1>              //Diff UV interleaved
+
+//3 more lines
+    add (16)   wCURBE_TEMP(4)<1>               ubCURR_UV(35,2)<16;16,1>                -ubPREV_UV(8,208)<16;16,1>              //Diff UV interleaved
+    add (16)   wCURBE_TEMP(5)<1>               ubCURR_UV(36,2)<16;16,1>                -ubPREV_UV(8,224)<16;16,1>              //Diff UV interleaved
+    add (16)   wCURBE_TEMP(6)<1>               ubCURR_UV(37,2)<16;16,1>                -ubPREV_UV(8,240)<16;16,1>              //Diff UV interleaved
+
+       //16x4 to 8x4 - First 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>            uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>            uwDIFF_TEMPORAL_SUM4x4(2,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(2,2)<4;2,1>
+
+       //8x4 to 4x4 - First 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4_FINAL(0)<1>      uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>              { AccWrEn }
+
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(16)<16;16,1>        (abs)wDIFF_TEMPORAL(17)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(18)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(19)<16;16,1>
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(20)<16;16,1>        (abs)wDIFF_TEMPORAL(21)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(22)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(23)<16;16,1>
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(24)<16;16,1>        (abs)wDIFF_TEMPORAL(25)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(26)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(2)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(27)<16;16,1>
+
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(28)<16;16,1>        (abs)wCURBE_TEMP(4)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wCURBE_TEMP(5)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(3)<1>    acc0.0<16;16,1>:uw                                      (abs)wCURBE_TEMP(6)<16;16,1>
+
+       //Find if block is motion block - First 16 lines
+       cmp.g.f0.0  (16) null<1>:w                              uwDIFF_TEMPORAL_SUM4x4_FINAL(0)<16;16,1>                r61.26<0;2,1>:ub
+
+       //Move TEMPORAL_SUM4x4 for SIMD16 use later.
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,0)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,2)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,4)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,6)<0;2,1>      
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,8)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,10)<0;2,1>     
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,12)<0;2,1>             
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,14)<0;2,1>     
+
+       //Pick Appropriate Weight History Based on motion. - First 16 lines
+       (-f0.0) mov (16) uwCURBE_TEMP(0)<1>             uwCURBE_TEMP(2)<16;16,1>
+
+       //Actual DN - First 16 lines
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(0)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(0)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(2,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(2,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(2,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,0)<8;8,1>                                   uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,8)<8;8,1>                                   uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(0)<1>                    acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(0)<1>                   ubCURR_UV(2,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(0)<1>    wDIFF_TEMPORAL(0)<16;16,1>                                      ubCURR_UV(2,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(1)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(1)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(3,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(3,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(3,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,16)<8;8,1>                          uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,24)<8;8,1>                          uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(1)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(1)<1>           ubCURR_UV(3,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(1)<1>    wDIFF_TEMPORAL(1)<16;16,1>                              ubCURR_UV(3,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(2)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(2)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(4,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(4,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(4,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,32)<8;8,1>                          uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,40)<8;8,1>                          uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(2)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(2)<1>           ubCURR_UV(4,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(2)<1>    wDIFF_TEMPORAL(2)<16;16,1>                              ubCURR_UV(4,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(3)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(3)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(5,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(5,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(5,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,48)<8;8,1>                          uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,56)<8;8,1>                          uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(3)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(3)<1>           ubCURR_UV(5,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(3)<1>    wDIFF_TEMPORAL(3)<16;16,1>                              ubCURR_UV(5,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(4)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(4)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(6,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(6,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(6,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,64)<8;8,1>                                  uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,72)<8;8,1>                                  uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(4)<1>                    acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(4)<1>                   ubCURR_UV(6,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(4)<1>    wDIFF_TEMPORAL(4)<16;16,1>                                      ubCURR_UV(6,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(5)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(5)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(7,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(7,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(7,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,80)<8;8,1>                          uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,88)<8;8,1>                          uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(5)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(5)<1>           ubCURR_UV(7,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(5)<1>    wDIFF_TEMPORAL(5)<16;16,1>                              ubCURR_UV(7,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(6)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(6)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(8,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(8,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(8,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,96)<8;8,1>                          uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,104)<8;8,1>                         uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(6)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(6)<1>           ubCURR_UV(8,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(6)<1>    wDIFF_TEMPORAL(6)<16;16,1>                              ubCURR_UV(8,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(7)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(7)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(9,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(9,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(9,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,112)<8;8,1>                         uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,120)<8;8,1>                         uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(7)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(7)<1>           ubCURR_UV(9,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(7)<1>    wDIFF_TEMPORAL(7)<16;16,1>                              ubCURR_UV(9,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(8)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(8)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(10,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(10,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(10,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,128)<8;8,1>                                 uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,136)<8;8,1>                                 uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(8)<1>                    acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(8)<1>                   ubCURR_UV(10,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(8)<1>    wDIFF_TEMPORAL(8)<16;16,1>                                      ubCURR_UV(10,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(9)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(9)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(11,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(11,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(11,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,144)<8;8,1>                         uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,152)<8;8,1>                         uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(9)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(9)<1>           ubCURR_UV(11,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(9)<1>    wDIFF_TEMPORAL(9)<16;16,1>                              ubCURR_UV(11,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(10)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(10)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(12,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(12,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(12,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,160)<8;8,1>                         uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,168)<8;8,1>                         uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(10)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(10)<1>          ubCURR_UV(12,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(10)<1>   wDIFF_TEMPORAL(10)<16;16,1>                             ubCURR_UV(12,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(11)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(11)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(13,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(13,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(13,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,176)<8;8,1>                         uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,184)<8;8,1>                         uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(11)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(11)<1>          ubCURR_UV(13,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(11)<1>   wDIFF_TEMPORAL(11)<16;16,1>                             ubCURR_UV(13,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(12)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(12)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(14,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(14,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(14,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,192)<8;8,1>                                 uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,200)<8;8,1>                                 uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(12)<1>                   acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(12)<1>                  ubCURR_UV(14,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(12)<1>   wDIFF_TEMPORAL(12)<16;16,1>                                     ubCURR_UV(14,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(13)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(13)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(15,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(15,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(15,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,208)<8;8,1>                         uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,216)<8;8,1>                         uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(13)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(13)<1>          ubCURR_UV(15,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(13)<1>   wDIFF_TEMPORAL(13)<16;16,1>                             ubCURR_UV(15,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(14)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(14)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(16,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(16,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(16,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,224)<8;8,1>                         uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,232)<8;8,1>                         uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(14)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(14)<1>          ubCURR_UV(16,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(14)<1>   wDIFF_TEMPORAL(14)<16;16,1>                             ubCURR_UV(16,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(15)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(15)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(17,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(17,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(17,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,240)<8;8,1>                         uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,248)<8;8,1>                         uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(15)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(15)<1>          ubCURR_UV(17,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(15)<1>   wDIFF_TEMPORAL(15)<16;16,1>                             ubCURR_UV(17,2)<16;16,1>
+
+
+       //16x4 to 8x4 - Second 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>    uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>    uwDIFF_TEMPORAL_SUM4x4(2,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(2,2)<4;2,1>
+
+       //8x4 to 4x4 - Second 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4_FINAL(1)<1>      uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>     { AccWrEn }
+
+       //Find if block is motion block - Second 16 lines
+       cmp.g.f1.0  (16) null<1>:w                              uwDIFF_TEMPORAL_SUM4x4_FINAL(1)<16;16,1>                r61.26<0;2,1>:ub
+
+       //Move TEMPORAL_SUM4x4 for SIMD16 use later.
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,0)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,2)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,4)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,6)<0;2,1>      
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,8)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,10)<0;2,1>     
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,12)<0;2,1>             
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,14)<0;2,1>     
+
+       //Pick Appropriate Weight History Based on motion. - Second 16 lines
+       (-f1.0) mov (16) uwCURBE_TEMP(1)<1>             uwCURBE_TEMP(3)<16;16,1>
+
+       //Actual DN - Second 16 lines
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(16)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(16)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(22,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(22,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(22,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,0)<8;8,1>                                   uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,8)<8;8,1>                                   uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(16)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(16)<1>                  ubCURR_UV(22,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(16)<1>   wDIFF_TEMPORAL(16)<16;16,1>                     ubCURR_UV(22,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(17)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(17)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(23,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(23,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(23,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,16)<8;8,1>                          uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,24)<8;8,1>                          uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(17)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(17)<1>                  ubCURR_UV(23,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(17)<1>   wDIFF_TEMPORAL(17)<16;16,1>                     ubCURR_UV(23,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(18)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(18)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(24,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(24,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(24,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,32)<8;8,1>                          uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,40)<8;8,1>                          uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(18)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(18)<1>                  ubCURR_UV(24,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(18)<1>   wDIFF_TEMPORAL(18)<16;16,1>                     ubCURR_UV(24,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(19)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(19)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(25,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(25,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(25,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,48)<8;8,1>                          uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,56)<8;8,1>                          uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(19)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(19)<1>                  ubCURR_UV(25,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(19)<1>   wDIFF_TEMPORAL(19)<16;16,1>                     ubCURR_UV(25,2)<16;16,1>
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(20)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(20)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(26,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(26,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(26,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,64)<8;8,1>                                  uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,72)<8;8,1>                                  uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(20)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(20)<1>                  ubCURR_UV(26,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(20)<1>   wDIFF_TEMPORAL(20)<16;16,1>                     ubCURR_UV(26,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(21)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(21)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(27,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(27,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(27,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,80)<8;8,1>                          uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,88)<8;8,1>                          uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(21)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(21)<1>                  ubCURR_UV(27,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(21)<1>   wDIFF_TEMPORAL(21)<16;16,1>                     ubCURR_UV(27,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(22)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(22)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(28,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(28,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(28,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,96)<8;8,1>                          uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,104)<8;8,1>                         uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(22)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(22)<1>                  ubCURR_UV(28,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(22)<1>   wDIFF_TEMPORAL(22)<16;16,1>                     ubCURR_UV(28,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(23)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(23)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(29,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(29,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(29,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,112)<8;8,1>                         uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,120)<8;8,1>                         uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(23)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(23)<1>                  ubCURR_UV(29,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(23)<1>   wDIFF_TEMPORAL(23)<16;16,1>                     ubCURR_UV(29,2)<16;16,1>
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(24)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(24)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(30,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(30,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(30,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,128)<8;8,1>                                 uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,136)<8;8,1>                                 uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(24)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(24)<1>                  ubCURR_UV(30,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(24)<1>   wDIFF_TEMPORAL(24)<16;16,1>                     ubCURR_UV(30,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(25)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(25)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(31,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(31,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(31,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,144)<8;8,1>                         uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,152)<8;8,1>                         uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(25)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(25)<1>                  ubCURR_UV(31,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(25)<1>   wDIFF_TEMPORAL(25)<16;16,1>                     ubCURR_UV(31,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(26)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(26)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(32,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(32,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(32,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,160)<8;8,1>                         uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,168)<8;8,1>                         uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(26)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(26)<1>                  ubCURR_UV(32,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(26)<1>   wDIFF_TEMPORAL(26)<16;16,1>                     ubCURR_UV(32,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(27)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(27)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(33,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(33,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(33,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,176)<8;8,1>                         uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,184)<8;8,1>                         uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(27)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(27)<1>                  ubCURR_UV(33,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(27)<1>   wDIFF_TEMPORAL(27)<16;16,1>                     ubCURR_UV(33,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(28)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(28)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(34,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(34,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(34,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,192)<8;8,1>                                 uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,200)<8;8,1>                                 uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(28)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(28)<1>                  ubCURR_UV(34,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(28)<1>   wDIFF_TEMPORAL(28)<16;16,1>                             ubCURR_UV(34,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(4)<16;16,1>                            r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(4)<16;16,1>                            r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(35,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(35,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(35,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,208)<8;8,1>                         uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,216)<8;8,1>                         uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wCURBE_TEMP(4)<1>                              acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wCURBE_TEMP(4)<1>                              ubCURR_UV(35,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wCURBE_TEMP(4)<1>               wCURBE_TEMP(4)<16;16,1>                         ubCURR_UV(35,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(5)<16;16,1>                            r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(5)<16;16,1>                            r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(36,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(36,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(36,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,224)<8;8,1>                         uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,232)<8;8,1>                         uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wCURBE_TEMP(5)<1>                              acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wCURBE_TEMP(5)<1>                              ubCURR_UV(36,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wCURBE_TEMP(5)<1>               wCURBE_TEMP(5)<16;16,1>                         ubCURR_UV(36,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(6)<16;16,1>                            r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(6)<16;16,1>                            r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(37,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(37,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(37,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,240)<8;8,1>                         uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,248)<8;8,1>                         uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wCURBE_TEMP(6)<1>                              acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wCURBE_TEMP(6)<1>                              ubCURR_UV(37,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wCURBE_TEMP(6)<1>               wCURBE_TEMP(6)<16;16,1>                         ubCURR_UV(37,2)<16;16,1>
+
+       //Pack Weight History WORD -> BYTE
+       mov (16) ubCURBE_TEMP(3,0)<1>           ubCURBE_TEMP(0)<32;16,2>        
+       mov (16) ubCURBE_TEMP(3,16)<1>          ubCURBE_TEMP(1)<32;16,2>        
+
+
+
+//Module Name  : DN_UV_Compute_BNE_UV
+//Author               : Tatiya, Rupesh
+//Description  : Computes minimum SOAD for each 16x4 block.
+
+       cmp.l.f0.0  (8) null:w                                  uwSOAD_MIN_8x4(0,12)<16;4,1>    uwSOAD_MIN_8x4(2,12)<16;4,1>
+       (f0.0)sel       (8) uwCURBE_TEMP(1,0)<1>        uwSOAD_MIN_8x4(0,12)<16;4,1>    uwSOAD_MIN_8x4(2,12)<16;4,1>
+
+    mov  (8)   ubCURBE_TEMP(1)<1>                      ubCURBE_TEMP(1)<16;8,2>
+
+
+
+//Module Name  : DN_UV_PL2_Pack_Denoised_UV
+//Name                 : Tatiya, Rupesh
+//Description  : Pack UV denoised data based on PL2 input.
+
+
+
+//Module Name  : DN_UV_Pack_Denoised_UV
+//Name                 : Tatiya, Rupesh
+//Description  : Pack UV denoised data based on PL2/PL3/PA.
+
+
+//First 16 lines.
+       mov  (16)       ubMSGPAYLOAD_UV0(0,0)<1>                ubDIFF_TEMPORAL(0)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(0,16)<1>               ubDIFF_TEMPORAL(1)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(1,0)<1>                ubDIFF_TEMPORAL(2)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(1,16)<1>               ubDIFF_TEMPORAL(3)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(2,0)<1>                ubDIFF_TEMPORAL(4)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(2,16)<1>               ubDIFF_TEMPORAL(5)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(3,0)<1>                ubDIFF_TEMPORAL(6)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(3,16)<1>               ubDIFF_TEMPORAL(7)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(4,0)<1>                ubDIFF_TEMPORAL(8)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(4,16)<1>               ubDIFF_TEMPORAL(9)<32;16,2>             
+       mov  (16)       ubMSGPAYLOAD_UV0(5,0)<1>                ubDIFF_TEMPORAL(10)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV0(5,16)<1>               ubDIFF_TEMPORAL(11)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV0(6,0)<1>                ubDIFF_TEMPORAL(12)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV0(6,16)<1>               ubDIFF_TEMPORAL(13)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV0(7,0)<1>                ubDIFF_TEMPORAL(14)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV0(7,16)<1>               ubDIFF_TEMPORAL(15)<32;16,2>            
+
+//Second 16 lines.
+//12 lines first
+       mov  (16)       ubMSGPAYLOAD_UV1(0,0)<1>                ubDIFF_TEMPORAL(16)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(0,16)<1>               ubDIFF_TEMPORAL(17)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(1,0)<1>                ubDIFF_TEMPORAL(18)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(1,16)<1>               ubDIFF_TEMPORAL(19)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(2,0)<1>                ubDIFF_TEMPORAL(20)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(2,16)<1>               ubDIFF_TEMPORAL(21)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(3,0)<1>                ubDIFF_TEMPORAL(22)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(3,16)<1>               ubDIFF_TEMPORAL(23)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(4,0)<1>                ubDIFF_TEMPORAL(24)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(4,16)<1>               ubDIFF_TEMPORAL(25)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(5,0)<1>                ubDIFF_TEMPORAL(26)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(5,16)<1>               ubDIFF_TEMPORAL(27)<32;16,2>            
+
+       //3 lines next
+       mov  (16)       ubMSGPAYLOAD_UV1(6,0)<1>                ubDIFF_TEMPORAL(28)<32;16,2>            
+       mov  (16)       ubMSGPAYLOAD_UV1(6,16)<1>               ubCURBE_TEMP(4)<32;16,2>                        
+       mov  (16)       ubMSGPAYLOAD_UV1(7,0)<1>                ubCURBE_TEMP(5)<32;16,2>                        
+       mov  (16)       ubMSGPAYLOAD_UV1(7,16)<1>               ubCURBE_TEMP(6)<32;16,2>                        
+
+
+
+//Module Name  : DN_UV_420_Save_Curr_Frame_Y
+//Author               : Tatiya, Rupesh
+//Description  : Save Curr Frame Y data for 420 Input
+
+
+
+//Module Name  : DN_UV_Load_Curr_Frame_Y
+//Author               : Tatiya, Rupesh
+//Description  : Saves Y or YUY2 of Current frame.
+
+
+
+
+       mov (8)         acc0.0<1>:ud            r0.0<8;8,1>:ud
+       mov (2)         acc0.0<1>:d                     r62.10<2;2,1>:w
+
+       mov (1)         acc0.2<1>:d                     0xF000F:ud
+
+       mov (8)     r92.0<1>:ud acc0.0<8;8,1>:ud
+
+       mov (8)     r101.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r110.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r119.0<1>:ud        acc0.0<8;8,1>:ud
+
+       add (1)         r101.1<1>:d     acc0.1<0;1,0>:d                 16:d
+
+       add (1)         r110.0<1>:d     acc0.0<0;1,0>:d                 16:d
+
+       add (2)         r119.0<1>:d     acc0.0<2;2,1>:d                 16:d
+
+       send (8)        null<1>:d       r92             0x5             0x120A8018:ud
+       send (8)        null<1>:d       r101            0x5             0x120A8018:ud
+       send (8)        null<1>:d       r110            0x5             0x120A8018:ud
+       send (8)        null<1>:d       r119            0x5             0x120A8018:ud
+
+
+       //TODO - See if History saving can be combined with Curr Frame Save. - rT
+
+
+//Module Name  : DN_UV_Save_Hist_UV
+//Author               : Tatiya, Rupesh
+//Description  : Saves DN history for UV data.
+
+       mov (8)  r3.0<1>:ud     r0.0<8;8,1>:ud
+       mov (2)  r3.0<1>:d      r62.12<2;2,1>:w                         
+       mov (1)  r3.2<1>:d      0x30007:ud              
+
+       send (8) null<1>:d      r3              0x5             0x40A8021:ud
+
+
+
+//Module Name  : DN_UV_Save_BNE_UV
+//Author               : Tatiya, Rupesh
+//Description  : Saves BNE values for 16x16 U and 16x16 V.
+
+       mov (8)  r1.0<1>:ud     r0.0<8;8,1>:ud
+       mov (2)  r1.0<1>:d              r63.12<2;2,1>:w                                 
+       mov (1)  r1.2<1>:d              0x10003:ud              
+
+       send (8) null<1>:d      r1              0x5             0x40A8023:ud
+
+
+
+//Module Name  : DN_UV_PL2_Save_Curr_Frame_UV
+//Author               : Tatiya, Rupesh
+
+
+
+//Module name  :  DN_UV_Save_Curr_Frame_UV
+//Author               :  Tatiya, Rupesh
+//Description  :  Saves Current Frame (UV only).
+
+
+
+
+       mov  (8)                r74<1>:ud               r0.0<8;8,1>:ud
+       mov  (8)                r83<1>:ud               r0.0<8;8,1>:ud
+
+       mov (1)  r74.0<1>:d             r62.10<0;1,0>:w                                         
+       shr (1)  r74.1<1>:d             r62.11<0;1,0>:w                 1:w                     
+       mov (1)  r74.2<1>:d             0xF000F:ud              
+
+       add (1)  r83.0<1>:d             r62.10<0;1,0>:w                 16:d            
+       shr (1)  r83.1<1>:d             r62.11<0;1,0>:w                  1:w            
+       mov (1)  r83.2<1>:d             0xF000F:ud              
+
+       send (8) null<1>:d      r74             0x5             0x120A8019:ud
+       send (8) null<1>:d      r83             0x5             0x120A8019:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+       //All sub-routines here
+
+
+// Module Name  : Noise_Detection
+// Author              : Tatiya, Rupesh
+// Description : Performs noise detection on 32 pixels of U (8x4) and 32 pixels of V (8x4).
+
+DN_UV_NOISE_DETECTION_UV:
+
+// Find Field Block Median
+//
+// Purpose   : Find the median value of the nine pixels in the same field
+//             which are centered at current pixel.
+//
+//             Works on 9 pixels centered at the current pixel
+//                NOTE: pixels are within same field.
+//                      v4 - current pixel
+//
+//                  v2 v1 v0
+//                   *  *  *     <--- Different field - not used
+//                  v5 v4 v3
+//                   *  *  *     <--- Different field - not used
+//                  v8 v7 v6
+
+// Algorithm to find median modifies the data.
+// Copy the data needed to calculate median so the original source data stays intact.
+//
+
+//TODO - Change Interleaved implementation to separated one if - ,  does not work on predication. - rT
+
+//Delete Later - rT
+//mov (1) pCUR_UV:uw           52*32:uw
+
+// v0
+mov (16) ubMEDIAN_TEMP(0,0)<1>         r[a0.0,0]<16;16,1>              
+// v0
+mov (16) ubMEDIAN_TEMP(0,16)<1>        r[a0.0,32]<16;16,1>             
+// v1
+mov (16) ubMEDIAN_TEMP(1,0)<1>         r[a0.0,2]<16;16,1>              
+// v1
+mov (16) ubMEDIAN_TEMP(1,16)<1>        r[a0.0,34]<16;16,1>             
+// v2
+mov (16) ubMEDIAN_TEMP(2,0)<1>         r[a0.0,4]<16;16,1>              
+// v2
+mov (16) ubMEDIAN_TEMP(2,16)<1>        r[a0.0,36]<16;16,1>             
+// v3
+mov (16) ubMEDIAN_TEMP(3,0)<1>         r[a0.0,64]<16;16,1>     
+// v3
+mov (16) ubMEDIAN_TEMP(3,16)<1>        r[a0.0,96]<16;16,1>             
+// v4
+mov (16) ubMEDIAN_TEMP(4,0)<1>         r[a0.0,66]<16;16,1>     
+// v4
+mov (16) ubMEDIAN_TEMP(4,16)<1>        r[a0.0,98]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(5,0)<1>         r[a0.0,68]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(5,16)<1>        r[a0.0,100]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(6,0)<1>         r[a0.0,128]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(6,16)<1>        r[a0.0,160]<16;16,1>            
+// v7
+mov (16) ubMEDIAN_TEMP(7,0)<1>         r[a0.0,130]<16;16,1>    
+// v7
+mov (16) ubMEDIAN_TEMP(7,16)<1>        r[a0.0,162]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(8,0)<1>         r[a0.0,132]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(8,16)<1>        r[a0.0,164]<16;16,1>    
+
+//TODO - Optimize one instruction here.
+add (1)  a0.0:uw               a0.0<0;1,0>:uw 64:uw
+// v0
+mov (16) ubMEDIAN_TEMP(9,0)<1>         r[a0.0,0]<16;16,1>              
+// v0
+mov (16) ubMEDIAN_TEMP(9,16)<1>        r[a0.0,32]<16;16,1>             
+// v1
+mov (16) ubMEDIAN_TEMP(10,0)<1>        r[a0.0,2]<16;16,1>              
+// v1
+mov (16) ubMEDIAN_TEMP(10,16)<1>       r[a0.0,34]<16;16,1>             
+// v2
+mov (16) ubMEDIAN_TEMP(11,0)<1>        r[a0.0,4]<16;16,1>              
+// v2
+mov (16) ubMEDIAN_TEMP(11,16)<1>       r[a0.0,36]<16;16,1>             
+// v3
+mov (16) ubMEDIAN_TEMP(12,0)<1>        r[a0.0,64]<16;16,1>     
+// v3
+mov (16) ubMEDIAN_TEMP(12,16)<1>       r[a0.0,96]<16;16,1>             
+// v4
+mov (16) ubMEDIAN_TEMP(13,0)<1>                r[a0.0,66]<16;16,1>     
+// v4
+mov (16) ubMEDIAN_TEMP(13,16)<1>       r[a0.0,98]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(14,0)<1>                r[a0.0,68]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(14,16)<1>       r[a0.0,100]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(15,0)<1>        r[a0.0,128]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(15,16)<1>       r[a0.0,160]<16;16,1>            
+// v7
+mov (16) ubMEDIAN_TEMP(16,0)<1>                r[a0.0,130]<16;16,1>    
+// v7
+mov (16) ubMEDIAN_TEMP(16,16)<1>       r[a0.0,162]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(17,0)<1>                r[a0.0,132]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(17,16)<1>       r[a0.0,164]<16;16,1>    
+
+//TODO - Optimize one instruction here.
+add (1)  a0.0:uw               a0.0<0;1,0>:uw 64:uw
+
+// MedianSwap
+//
+//  MedianSwap(inOutLeft, inOutRight)
+//  {
+//      if (inOutLeft > inOutRight)
+//      {
+//          temp = inOutLeft
+//          inOutLeft = inOutRight
+//          inOutRight = temp
+//      }
+//  }
+
+// MedianSwap(v1, v2) - U
+// MedianSwap(v4, v5) - U
+// MedianSwap(v1, v2) - V
+// MedianSwap(v4, v5) - V
+
+cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(1,0)<32;16,2>  ubMEDIAN_TEMP(2,0)<32;16,2>
+cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>  ubMEDIAN_TEMP(5,0)<32;16,2>
+cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(1,1)<32;16,2>    ubMEDIAN_TEMP(2,1)<32;16,2>
+cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>    ubMEDIAN_TEMP(5,1)<32;16,2>
+
+               mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(1,0)<32;16,2>       
+               mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,0)<32;16,2>       
+               mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(1,1)<32;16,2>       
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>       
+
+(f0.0) mov (16) ubMEDIAN_TEMP(1,0)<2>          ubMEDIAN_TEMP(2,0)<32;16,2>             
+(f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>          ubMEDIAN_TEMP(5,0)<32;16,2>             
+(f1.0) mov (16) ubMEDIAN_TEMP(1,1)<2>                  ubMEDIAN_TEMP(2,1)<32;16,2>             
+(f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>          ubMEDIAN_TEMP(5,1)<32;16,2>             
+
+(f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubTEMP1(0,0)<16;16,1>                
+(f0.1) mov (16) ubMEDIAN_TEMP(5,0)<2>     ubTEMP1(0,16)<16;16,1>               
+(f1.0) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubTEMP1(1,0)<16;16,1>                
+(f1.1) mov (16) ubMEDIAN_TEMP(5,1)<2>     ubTEMP1(1,16)<16;16,1>       
+
+// MedianSwap(v7, v8) - U
+// MedianSwap(v0, v1) - U
+// MedianSwap(v7, v8) - V
+// MedianSwap(v0, v1) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(7,0)<32;16,2>           ubMEDIAN_TEMP(8,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(0,0)<32;16,2>   ubMEDIAN_TEMP(1,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(7,1)<32;16,2>   ubMEDIAN_TEMP(8,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(0,1)<32;16,2>   ubMEDIAN_TEMP(1,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(7,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(0,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(7,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(0,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(7,0)<2>   ubMEDIAN_TEMP(8,0)<32;16,2>      
+ (f0.1) mov (16) ubMEDIAN_TEMP(0,0)<2> ubMEDIAN_TEMP(1,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(7,1)<2>         ubMEDIAN_TEMP(8,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(0,1)<2> ubMEDIAN_TEMP(1,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(8,0)<2>     ubTEMP1(0,0)<16;16,1>          
+ (f0.1) mov (16) ubMEDIAN_TEMP(1,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(8,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(1,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v3, v4) - U
+ // MedianSwap(v6, v7) - U
+ // MedianSwap(v3, v4) - V
+ // MedianSwap(v6, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(3,0)<32;16,2>           ubMEDIAN_TEMP(4,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(6,0)<32;16,2>   ubMEDIAN_TEMP(7,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(3,1)<32;16,2>   ubMEDIAN_TEMP(4,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(6,1)<32;16,2>   ubMEDIAN_TEMP(7,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(3,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(6,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(3,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(6,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(3,0)<2>   ubMEDIAN_TEMP(4,0)<32;16,2>      
+ (f0.1) mov (16) ubMEDIAN_TEMP(6,0)<2> ubMEDIAN_TEMP(7,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(3,1)<2>         ubMEDIAN_TEMP(4,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(6,1)<2> ubMEDIAN_TEMP(7,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(7,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(4,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(7,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v1, v2) - U
+ // MedianSwap(v4, v5) - U
+ // MedianSwap(v1, v2) - V
+ // MedianSwap(v4, v5) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(1,0)<32;16,2>           ubMEDIAN_TEMP(2,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>   ubMEDIAN_TEMP(5,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(1,1)<32;16,2>   ubMEDIAN_TEMP(2,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(5,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(1,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(1,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(1,0)<2>   ubMEDIAN_TEMP(2,0)<32;16,2>           
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2> ubMEDIAN_TEMP(5,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(1,1)<2>         ubMEDIAN_TEMP(2,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2> ubMEDIAN_TEMP(5,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(5,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(5,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v7, v8) - U
+ // MedianSwap(v0, v3) - U
+ // MedianSwap(v7, v8) - V
+ // MedianSwap(v0, v3) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(7,0)<32;16,2>           ubMEDIAN_TEMP(8,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(0,0)<32;16,2>   ubMEDIAN_TEMP(3,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(7,1)<32;16,2>   ubMEDIAN_TEMP(8,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(0,1)<32;16,2>   ubMEDIAN_TEMP(3,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(7,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(0,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(7,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(0,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(7,0)<2>   ubMEDIAN_TEMP(8,0)<32;16,2>           
+ (f0.1) mov (16) ubMEDIAN_TEMP(0,0)<2> ubMEDIAN_TEMP(3,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(7,1)<2>         ubMEDIAN_TEMP(8,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(0,1)<2> ubMEDIAN_TEMP(3,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(8,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(3,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(8,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(3,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // NOTE:
+ // Compare v0 to v6 to find the minimum.
+ // Store the minimum for future use.
+ //TODO - Find if MIN is needed.
+ //cmp.l.f0.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,0)<32;16,2>  ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //cmp.l.f1.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,1)<32;16,2>  ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+ //(f0.0)  mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,0)<32;16,2>
+ //(f1.0)  mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,1)<32;16,2>
+ //(-f0.0) mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //(-f1.0) mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+
+ // MedianSwap(v5, v8) - U
+ // MedianSwap(v4, v7) - U
+ // MedianSwap(v5, v8) - V
+ // MedianSwap(v4, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(5,0)<32;16,2>           ubMEDIAN_TEMP(8,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>   ubMEDIAN_TEMP(7,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(5,1)<32;16,2>   ubMEDIAN_TEMP(8,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(7,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(5,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(5,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(5,0)<2>         ubMEDIAN_TEMP(8,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(7,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(5,1)<2>         ubMEDIAN_TEMP(8,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(7,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(8,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(7,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(8,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(7,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+// NOTE:
+// Compare v2 to v8 to find the maximum.
+// Store the maximum for future use.
+ //TODO - Find if MAX is needed.
+// cmp.g.f0.0  (16) null:w         ubMEDIAN_TEMP(%1+2,0)<32;16,2> ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+// cmp.g.f1.0  (16) null:w         ubMEDIAN_TEMP(%1+2,1)<32;16,2> ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+//(f0.0)  mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,0)<32;16,2>
+//(f1.0)  mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,1)<32;16,2>
+//(-f0.0) mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+//(-f1.0) mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+
+// MedianSwap(v3, v6) - U
+// MedianSwap(v1, v4) - U
+// MedianSwap(v3, v6) - V
+// MedianSwap(v1, v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(3,0)<32;16,2>           ubMEDIAN_TEMP(6,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(1,0)<32;16,2>   ubMEDIAN_TEMP(4,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(3,1)<32;16,2>   ubMEDIAN_TEMP(6,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(1,1)<32;16,2>   ubMEDIAN_TEMP(4,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(6,0)<2>     ubMEDIAN_TEMP(3,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>     ubMEDIAN_TEMP(1,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(6,1)<2>     ubMEDIAN_TEMP(3,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>     ubMEDIAN_TEMP(1,1)<32;16,2>      
+
+ // MedianSwap(v2,v5) - U
+ // MedianSwap(v4,v7) - U
+ // MedianSwap(v2,v5) - V
+ // MedianSwap(v4,v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(2,0)<32;16,2>           ubMEDIAN_TEMP(5,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>   ubMEDIAN_TEMP(7,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(2,1)<32;16,2>   ubMEDIAN_TEMP(5,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(7,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubMEDIAN_TEMP(5,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>     ubMEDIAN_TEMP(7,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubMEDIAN_TEMP(5,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>     ubMEDIAN_TEMP(7,1)<32;16,2>      
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>           ubMEDIAN_TEMP(2,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(2,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(4,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(2,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(2,1)<32;16,2>             
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubTEMP1(0,16)<16;16,1>      
+
+ // MedianSwap(v6,v4) - U
+ // MedianSwap(v6,v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(6,0)<32;16,2>   ubMEDIAN_TEMP(4,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(6,1)<32;16,2>   ubMEDIAN_TEMP(4,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(6,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(6,1)<32;16,2>             
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>           ubMEDIAN_TEMP(2,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(2,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(2,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(2,1)<32;16,2>             
+cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(10,0)<32;16,2>  ubMEDIAN_TEMP(11,0)<32;16,2>
+cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>  ubMEDIAN_TEMP(14,0)<32;16,2>
+cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(10,1)<32;16,2>   ubMEDIAN_TEMP(11,1)<32;16,2>
+cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>   ubMEDIAN_TEMP(14,1)<32;16,2>
+
+               mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(10,0)<32;16,2>      
+               mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,0)<32;16,2>      
+               mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(10,1)<32;16,2>      
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>      
+
+(f0.0) mov (16) ubMEDIAN_TEMP(10,0)<2>         ubMEDIAN_TEMP(11,0)<32;16,2>            
+(f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>         ubMEDIAN_TEMP(14,0)<32;16,2>            
+(f1.0) mov (16) ubMEDIAN_TEMP(10,1)<2>                 ubMEDIAN_TEMP(11,1)<32;16,2>            
+(f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>         ubMEDIAN_TEMP(14,1)<32;16,2>            
+
+(f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubTEMP1(0,0)<16;16,1>               
+(f0.1) mov (16) ubMEDIAN_TEMP(14,0)<2>     ubTEMP1(0,16)<16;16,1>              
+(f1.0) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubTEMP1(1,0)<16;16,1>               
+(f1.1) mov (16) ubMEDIAN_TEMP(14,1)<2>     ubTEMP1(1,16)<16;16,1>      
+
+// MedianSwap(v7, v8) - U
+// MedianSwap(v0, v1) - U
+// MedianSwap(v7, v8) - V
+// MedianSwap(v0, v1) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(16,0)<32;16,2>          ubMEDIAN_TEMP(17,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(9,0)<32;16,2>   ubMEDIAN_TEMP(10,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(16,1)<32;16,2>  ubMEDIAN_TEMP(17,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(9,1)<32;16,2>   ubMEDIAN_TEMP(10,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(16,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(9,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(16,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(9,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(16,0)<2>   ubMEDIAN_TEMP(17,0)<32;16,2>    
+ (f0.1) mov (16) ubMEDIAN_TEMP(9,0)<2> ubMEDIAN_TEMP(10,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(16,1)<2>        ubMEDIAN_TEMP(17,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(9,1)<2> ubMEDIAN_TEMP(10,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(17,0)<2>     ubTEMP1(0,0)<16;16,1>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(10,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(17,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(10,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v3, v4) - U
+ // MedianSwap(v6, v7) - U
+ // MedianSwap(v3, v4) - V
+ // MedianSwap(v6, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(12,0)<32;16,2>          ubMEDIAN_TEMP(13,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(15,0)<32;16,2>          ubMEDIAN_TEMP(16,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(12,1)<32;16,2>  ubMEDIAN_TEMP(13,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(15,1)<32;16,2>  ubMEDIAN_TEMP(16,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(12,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(15,0)<32;16,2>             
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(12,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(15,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(12,0)<2>   ubMEDIAN_TEMP(13,0)<32;16,2>    
+ (f0.1) mov (16) ubMEDIAN_TEMP(15,0)<2>        ubMEDIAN_TEMP(16,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(12,1)<2>        ubMEDIAN_TEMP(13,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(15,1)<2>        ubMEDIAN_TEMP(16,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(16,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(13,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(16,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v1, v2) - U
+ // MedianSwap(v4, v5) - U
+ // MedianSwap(v1, v2) - V
+ // MedianSwap(v4, v5) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(10,0)<32;16,2>          ubMEDIAN_TEMP(11,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(14,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(10,1)<32;16,2>  ubMEDIAN_TEMP(11,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>  ubMEDIAN_TEMP(14,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(10,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,0)<32;16,2>             
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(10,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(10,0)<2>   ubMEDIAN_TEMP(11,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(14,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(10,1)<2>        ubMEDIAN_TEMP(11,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>        ubMEDIAN_TEMP(14,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(14,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(14,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v7, v8) - U
+ // MedianSwap(v0, v3) - U
+ // MedianSwap(v7, v8) - V
+ // MedianSwap(v0, v3) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(16,0)<32;16,2>          ubMEDIAN_TEMP(17,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(9,0)<32;16,2>   ubMEDIAN_TEMP(12,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(16,1)<32;16,2>  ubMEDIAN_TEMP(17,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(9,1)<32;16,2>   ubMEDIAN_TEMP(12,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(16,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(9,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(16,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(9,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(16,0)<2>   ubMEDIAN_TEMP(17,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(9,0)<2> ubMEDIAN_TEMP(12,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(16,1)<2>        ubMEDIAN_TEMP(17,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(9,1)<2> ubMEDIAN_TEMP(12,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(17,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(12,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(17,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(12,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // NOTE:
+ // Compare v0 to v6 to find the minimum.
+ // Store the minimum for future use.
+ //TODO - Find if MIN is needed.
+ //cmp.l.f0.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,0)<32;16,2>  ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //cmp.l.f1.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,1)<32;16,2>  ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+ //(f0.0)  mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,0)<32;16,2>
+ //(f1.0)  mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,1)<32;16,2>
+ //(-f0.0) mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //(-f1.0) mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+
+ // MedianSwap(v5, v8) - U
+ // MedianSwap(v4, v7) - U
+ // MedianSwap(v5, v8) - V
+ // MedianSwap(v4, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(14,0)<32;16,2>          ubMEDIAN_TEMP(17,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(16,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(14,1)<32;16,2>  ubMEDIAN_TEMP(17,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>  ubMEDIAN_TEMP(16,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(14,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,0)<32;16,2>             
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(14,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(14,0)<2>        ubMEDIAN_TEMP(17,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>                ubMEDIAN_TEMP(16,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(14,1)<2>        ubMEDIAN_TEMP(17,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(16,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(17,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(16,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(17,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(16,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+// NOTE:
+// Compare v2 to v8 to find the maximum.
+// Store the maximum for future use.
+ //TODO - Find if MAX is needed.
+// cmp.g.f0.0  (16) null:w         ubMEDIAN_TEMP(%1+2,0)<32;16,2> ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+// cmp.g.f1.0  (16) null:w         ubMEDIAN_TEMP(%1+2,1)<32;16,2> ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+//(f0.0)  mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,0)<32;16,2>
+//(f1.0)  mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,1)<32;16,2>
+//(-f0.0) mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+//(-f1.0) mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+
+// MedianSwap(v3, v6) - U
+// MedianSwap(v1, v4) - U
+// MedianSwap(v3, v6) - V
+// MedianSwap(v1, v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(12,0)<32;16,2>          ubMEDIAN_TEMP(15,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(10,0)<32;16,2>          ubMEDIAN_TEMP(13,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(12,1)<32;16,2>  ubMEDIAN_TEMP(15,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(10,1)<32;16,2>  ubMEDIAN_TEMP(13,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(15,0)<2>     ubMEDIAN_TEMP(12,0)<32;16,2>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>     ubMEDIAN_TEMP(10,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(15,1)<2>     ubMEDIAN_TEMP(12,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>     ubMEDIAN_TEMP(10,1)<32;16,2>      
+
+ // MedianSwap(v2,v5) - U
+ // MedianSwap(v4,v7) - U
+ // MedianSwap(v2,v5) - V
+ // MedianSwap(v4,v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(11,0)<32;16,2>          ubMEDIAN_TEMP(14,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(16,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(11,1)<32;16,2>  ubMEDIAN_TEMP(14,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>  ubMEDIAN_TEMP(16,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubMEDIAN_TEMP(14,0)<32;16,2>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>     ubMEDIAN_TEMP(16,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubMEDIAN_TEMP(14,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>     ubMEDIAN_TEMP(16,1)<32;16,2>      
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(11,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>          ubMEDIAN_TEMP(11,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(13,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>             
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(11,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(11,1)<32;16,2>            
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubTEMP1(0,16)<16;16,1>     
+
+ // MedianSwap(v6,v4) - U
+ // MedianSwap(v6,v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(15,0)<32;16,2>   ubMEDIAN_TEMP(13,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(15,1)<32;16,2>   ubMEDIAN_TEMP(13,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(15,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(15,1)<32;16,2>            
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(11,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>          ubMEDIAN_TEMP(11,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(11,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(11,1)<32;16,2>            
+
+// Sobel Value calculation for the current pixel v4
+//          v2 v1 v0
+//           *  *  *     <--- Different field - not used
+//          v5 v4 v3
+//           *  *  *     <--- Different field - not used
+//          v8 v7 v6
+//
+//    Gx = -v0 - 2*v3 - v6 + v2 + 2*v5 + v8
+//    Gy =  v0 + 2*v1 + v2 - v6 - 2*v7 - v8
+//
+//  Sobel = (|Gx| + |Gy|) >> 3
+
+//TODO - Change Later - rT
+add (1) a0.0:uw  a0.0<0;1,0>:uw -128:uw
+
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,64]<16;16,1>:ub                  -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,132]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,0]<16;16,1>:ub           -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,128]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,4]<16;16,1>:ub                   1:w
+// + 2 * v5
+mac (16) wSOBEL_X(0)<1>        r[a0.0,68]<16;16,1>:ub                  2:w
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,96]<16;16,1>:ub                  -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,164]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,32]<16;16,1>:ub                  -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,160]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,36]<16;16,1>:ub                  1:w
+// + 2 * v5
+mac (16) wSOBEL_X(1)<1>        r[a0.0,100]<16;16,1>:ub                 2:w
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,128]<16;16,1>:ub                 -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,196]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,64]<16;16,1>:ub                  -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,192]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,68]<16;16,1>:ub                  1:w
+// + 2 * v5
+mac (16) wSOBEL_X(2)<1>        r[a0.0,132]<16;16,1>:ub                 2:w
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,160]<16;16,1>:ub                 -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,228]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,96]<16;16,1>:ub                  -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,224]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,100]<16;16,1>:ub                 1:w
+// + 2 * v5
+mac (16) wSOBEL_X(3)<1>        r[a0.0,164]<16;16,1>:ub                 2:w
+
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,2]<16;16,1>:ub    2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,0]<16;16,1>:ub    1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,132]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,4]<16;16,1>:ub    1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,128]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,130]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(0)<16;16,1>
+
+shr (16) uwSOBEL(0)<1> acc0.0<16;16,1>:uw   3:uw
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,34]<16;16,1>:ub           2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,32]<16;16,1>:ub           1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,164]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,36]<16;16,1>:ub           1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,160]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,162]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(1)<16;16,1>
+
+shr (16) uwSOBEL(1)<1> acc0.0<16;16,1>:uw   3:uw
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,66]<16;16,1>:ub           2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,64]<16;16,1>:ub           1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,196]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,68]<16;16,1>:ub           1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,192]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,194]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(2)<16;16,1>
+
+shr (16) uwSOBEL(2)<1> acc0.0<16;16,1>:uw   3:uw
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,98]<16;16,1>:ub           2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,96]<16;16,1>:ub           1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,228]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,100]<16;16,1>:ub          1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,224]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,226]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(3)<16;16,1>
+
+shr (16) uwSOBEL(3)<1> acc0.0<16;16,1>:uw   3:uw
+
+//Mov Median in CURBE_TEMP to free up temp space.
+mov (16)       ubMEDIAN(0,0)<1>        ubMEDIAN_TEMP(4,0)<16;16,1>             
+mov (16)       ubMEDIAN(0,16)<1> ubMEDIAN_TEMP(4,16)<16;16,1>          
+mov (16)       ubMEDIAN(0,32)<1>       ubMEDIAN_TEMP(13,0)<16;16,1>            
+mov (16)       ubMEDIAN(0,48)<1> ubMEDIAN_TEMP(13,16)<16;16,1>         
+
+// Find:
+//      absDiff = abs(ubCurY - ubMedian)
+// Find the difference between pixel and median value.
+
+//Median is interleaved. So difference is also interleaved.
+
+//------------------------------------------------------------------------------------------
+//Process 16 U and 16 V pixels here and rest later.
+// first row - v0,v1,v2
+add (16) wDIFF(0)<1>   r[a0.0,0]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(1)<1>   r[a0.0,2]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(2)<1>   r[a0.0,4]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+
+// second row - v3,v4,v5
+add (16) wDIFF(3)<1>   r[a0.0,64]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(4)<1>   r[a0.0,66]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(5)<1>   r[a0.0,68]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+
+// third row - v6,v7,v8
+add (16) wDIFF(6)<1>   r[a0.0,128]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(7)<1>   r[a0.0,130]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(8)<1>   r[a0.0,132]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+// first row - v0,v1,v2
+add (16) wDIFF(9)<1>   r[a0.0,32]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(10)<1>   r[a0.0,34]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(11)<1>   r[a0.0,36]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+
+// second row - v3,v4,v5
+add (16) wDIFF(12)<1>   r[a0.0,96]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(13)<1>   r[a0.0,98]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(14)<1>   r[a0.0,100]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+
+// third row - v6,v7,v8
+add (16) wDIFF(15)<1>   r[a0.0,160]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(16)<1>   r[a0.0,162]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(17)<1>   r[a0.0,164]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+
+//TODO - Change Later - rT
+add (1) a0.0:uw  a0.0<0;1,0>:uw 64:uw
+
+// Find sum of all absolute differences AND
+// maximum absolute difference for 16 U and 16 V here.
+//First 2 rows of 8x4
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(0)<16;16,1>  (abs)wDIFF(1)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(2)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(3)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(4)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(5)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(6)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(7)<16;16,1>
+       add        (16) uwSOAD(0)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(8)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//------------
+       //DIFF(0-7) is not needed here. Populate it.
+       // first row - v0,v1,v2
+       add (16) wDIFF(0)<1>   r[a0.0,0]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(1)<1>   r[a0.0,2]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(2)<1>   r[a0.0,4]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+
+       // second row - v3,v4,v5
+       add (16) wDIFF(3)<1>   r[a0.0,64]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(4)<1>   r[a0.0,66]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(5)<1>   r[a0.0,68]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+
+       // third row - v6,v7
+       add (16) wDIFF(6)<1>   r[a0.0,128]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(7)<1>   r[a0.0,130]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+//------------
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(0)<1> uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+
+//------------
+       //Load v8 - DIFF(8)
+       add (16) wDIFF(8)<1>                    r[a0.0,132]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+//------------
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(9)<16;16,1>  (abs)wDIFF(10)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(11)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(12)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(13)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(14)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(15)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(16)<16;16,1>
+       add        (16) uwSOAD(1)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(17)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//------------
+       //DIFF(0-7) is not needed here. Populate it.
+       // first row - v0,v1,v2
+       add (16) wDIFF(9)<1>   r[a0.0,32]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(10)<1>   r[a0.0,34]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(11)<1>   r[a0.0,36]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+
+       // second row - v3,v4,v5
+       add (16) wDIFF(12)<1>   r[a0.0,96]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(13)<1>   r[a0.0,98]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(14)<1>   r[a0.0,100]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+
+       // third row - v6,v7
+       add (16) wDIFF(15)<1>   r[a0.0,160]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(16)<1>   r[a0.0,162]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+//------------
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(1)<1> uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+
+//------------
+       //Load v8 - DIFF(8)
+       add (16) wDIFF(17)<1>                           r[a0.0,164]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+//------------
+
+//if ((sobel_edge_measure < m_SobelEdgeThreshold) && ((block_max-block_min) < m_LocalDiffThreshold))
+//                                             if (sigma_mb_min > sigma)
+//                                                     sigma_mb_min = sigma;
+
+//NOTE: block_min is always zero as median is one of the value in 3x3 block. So no need o calculate it.
+//             So just do -
+//if ((sobel_edge_measure < m_SobelEdgeThreshold) && ((block_max) < m_LocalDiffThreshold) && ( sigma < sigma_mb_min))
+//                                                     sigma_mb_min = sigma;
+
+//We are processing 32 bytes of U and 32 bytes of V - each of size 8x4.
+//Compare first 8 bytes with max possible (255).
+//Start above condition from second 8 bytes.
+
+//TODO - Change Later - rT
+//     mov (1) pCUR_MIN_SOAD_8x4:uw    1752:uw         //r54.24:ub
+
+//First row of 8x4
+        cmp.l.f0.0     (16) null:uw                    uwSOBEL(0)<16;16,1>         r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(0)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(0)<16;16,1>                      255:uw
+(f0.0)  sel            (16) uwSOBEL(0)<1>   uwSOAD(0)<16;16,1>                 255:uw
+
+//Second row of 8x4
+               cmp.l.f0.0      (16) null:uw                    uwSOBEL(1)<16;16,1>         r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(1)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(1)<16;16,1>                      uwSOBEL(0)<16;16,1>
+(f0.0)  mov            (16) uwSOBEL(0)<1>   uwSOAD(1)<16;16,1>
+
+// Find sum of all absolute differences AND
+// maximum absolute difference for 16 U and 16 V here.
+//Second 2 rows of 8x4
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(0)<16;16,1>  (abs)wDIFF(1)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(2)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(3)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(4)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(5)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(6)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(7)<16;16,1>
+       add        (16) uwSOAD(0)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(8)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(0)<1>   uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(9)<16;16,1>  (abs)wDIFF(10)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(11)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(12)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(13)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(14)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(15)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(16)<16;16,1>
+       add        (16) uwSOAD(1)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(17)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(1)<1>   uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+
+//Third row of 8x4
+        cmp.l.f0.0     (16) null:uw                    uwSOBEL(2)<16;16,1>             r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(0)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(0)<16;16,1>                      uwSOBEL(0)<16;16,1>
+(f0.0)  mov            (16) uwSOBEL(0)<1>   uwSOAD(0)<16;16,1>
+
+//Fourth row of 8x4
+               cmp.l.f0.0      (16) null:uw                    uwSOBEL(3)<16;16,1>             r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(1)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(1)<16;16,1>                      uwSOBEL(0)<16;16,1>
+(f0.0)  mov            (16) uwSOBEL(0)<1>   uwSOAD(1)<16;16,1>
+
+               cmp.l.f0.0      (8) null:uw                     uwSOBEL(0,0)<8;8,1>     uwSOBEL(0,8)<8;8,1>
+(f0.0)  sel            (8) uwSOBEL(0)<1>       uwSOBEL(0,0)<8;8,1>     uwSOBEL(0,8)<8;8,1>
+
+               cmp.l.f0.0      (4) null:uw                     uwSOBEL(0,0)<4;4,1>     uwSOBEL(0,4)<4;4,1>
+(f0.0)  sel            (4) uwSOBEL(0)<1>       uwSOBEL(0,0)<4;4,1>     uwSOBEL(0,4)<4;4,1>
+
+               cmp.l.f0.0      (2) null:uw                                             uwSOBEL(0,0)<2;2,1>  uwSOBEL(0,2)<2;2,1>
+(f0.0)  sel            (2) r[a0.1,0]<1>:uw     uwSOBEL(0,0)<2;2,1>  uwSOBEL(0,2)<2;2,1>
+
+
+
+
+
+
+// End of common.inc
+
+mov (1) ip:ud r7.7<0;1,0>:d
+
+
+.end_code
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/NV12_DN_422CP.g4a b/src/shaders/post_processing/gen7/NV12_DN_422CP.g4a
new file mode 100644 (file)
index 0000000..926469e
--- /dev/null
@@ -0,0 +1,539 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//  113    // Total instruction count
+//    1    // Total kernel count
+
+.kernel NV12_DN_422CP
+.code
+
+
+
+// FileName:   DN_PL_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block) for planar format
+
+
+
+// FileName:   DN.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x45E8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(4,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+
+       mov (2)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(4,0)<2;2,1>         // Move denoise history to MRF (4x2)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x10003:ud                                                                      { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x50003:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE |   X  |   X   |  X  |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       //|            X             |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       mov (1)         mubMSGHDR_ENC_STATS(1,0)<1>             ubDNDI_RESP(4,8)<0;1,0>                 { NoDDClr }                             // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,3)<1>             uwDNDI_RESP(4,11)<0;1,0>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,4)<1>             uwDNDI_RESP(4,12)<2;2,1>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,9)<1>             uwDNDI_RESP(4,8)<0;1,0>                 { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,10)<1>    uwDNDI_RESP(4,9)<2;2,1>                 { NoDDChk }                             // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Load_UV_NV12_16x8.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x8 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Load_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x8 block through DATAPORT
+
+//CHANGE       :  Read extra UV data to convert to 422. -rT
+//we are reading extra data in ALL cases irrespective of whether upsampling is reqd or not later on, to keep things simple.
+
+
+       add (2)         r27.0<1>:d                              r7.0<2;2,1>:w                           r4.4<2;2,1>:w                           // Source Y Block origin
+       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
+       mov (1)         r27.2<1>:ud                             0x4000F:ud                                      { NoDDChk }     // U/V block width and height (8x5)
+    mov (8)     mudMSGHDR_UVCOPY(0)<1>         r27.0<8;8,1>:ud
+       send (8)        udDNDI_UV_RESP(0)<1>            r36     0x4     0x2390001:ud
+
+       //Update Header for Save
+       mov (1)         mudMSGHDR_UVCOPY(0,2)<1>        0x3000F:ud                                                                      // U/V block width and height (8x4)
+
+
+
+// FileName:    DN_Save_Y_16x8.asm
+// Author:      Vivek Kumar
+// Description: Save one 16x8 blocks of Y channel of DN output for reference
+
+
+mov (8)     mudDN_Y_OUT(0,0)<1>     r0<8;8,1>:ud                                // message header
+mov (2)     mudDN_Y_OUT(0,0)<1>     r7.0<2;2,1>:w                  { NoDDClr }     // X origin
+mov (1)     mudDN_Y_OUT(0,2)<1>     0x7000F:ud    { NoDDChk }     // block width and height (16x8)
+
+//send out data through data port
+send (8)    null<1>:d    mudDN_Y_OUT      0x5    0xA0A8018:ud
+
+
+
+// FileName:   DN_Save_UV_NV12_16x8.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x8 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Save_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x8 block through DATAPORT
+
+
+//Reuse the header from Load component
+//Header is modified at the end of load - to be usable for save.
+
+       mov (8)         mudMSGHDR_UVCOPY(1)<1>          udDNDI_UV_RESP(0)<8;8,1>
+       mov (8)         mudMSGHDR_UVCOPY(2)<1>          udDNDI_UV_RESP(1)<8;8,1>
+       send (8)        null<1>:d    r36        0x5    0x60A8019:ud
+
+
+
+// FileName:   DN_Upsample_UV_NV12_16x8.asm
+// Author:             Tatiya, Rupesh
+// Description:        Upconvert 420 UV to 422
+
+
+
+// FileName:   UVCopy_Upsample_UV_16x8.asm
+// Author:             Tatiya, Rupesh
+// Description:        Convert 42X UV to 422 - to be used for IECP.
+
+
+       avg.sat (16) uwDNDI_UVCOPY_TEMP(0)              ubDNDI_UV_RESP(0,0)<16;16,1>     ubDNDI_UV_RESP(0,0)<16;16,1>
+       avg.sat (16) uwDNDI_UVCOPY_TEMP(1)      ubDNDI_UV_RESP(0,0)<16;16,1>     ubDNDI_UV_RESP(0,16)<16;16,1>
+       avg.sat (16) uwDNDI_UVCOPY_TEMP(2)              ubDNDI_UV_RESP(0,16)<16;16,1>     ubDNDI_UV_RESP(0,16)<16;16,1>
+       avg.sat (16) uwDNDI_UVCOPY_TEMP(3)      ubDNDI_UV_RESP(0,16)<16;16,1>     ubDNDI_UV_RESP(0,32)<16;16,1>
+       avg.sat (16) uwDNDI_UVCOPY_TEMP(4)              ubDNDI_UV_RESP(0,32)<16;16,1>     ubDNDI_UV_RESP(0,32)<16;16,1>
+       avg.sat (16) uwDNDI_UVCOPY_TEMP(5)      ubDNDI_UV_RESP(0,32)<16;16,1>     ubDNDI_UV_RESP(0,48)<16;16,1>
+       avg.sat (16) uwDNDI_UVCOPY_TEMP(6)              ubDNDI_UV_RESP(0,48)<16;16,1>     ubDNDI_UV_RESP(0,48)<16;16,1>
+       avg.sat (16) uwDNDI_UVCOPY_TEMP(7)      ubDNDI_UV_RESP(0,48)<16;16,1>     ubDNDI_UV_RESP(0,64)<16;16,1>
+
+       mov     (16)    ubDNDI_RESP(5,1)<2>             ubDNDI_UVCOPY_TEMP(0,0)<32;8,4>         { NoDDClr }             //Copy U data
+       mov     (16)    ubDNDI_RESP(5,0)<2>             ubDNDI_UVCOPY_TEMP(0,2)<32;8,4>         { NoDDChk }             //Copy V data
+       mov     (16)    ubDNDI_RESP(5,33)<2>            ubDNDI_UVCOPY_TEMP(2,0)<32;8,4>         { NoDDClr }             //Copy U data
+       mov     (16)    ubDNDI_RESP(5,32)<2>            ubDNDI_UVCOPY_TEMP(2,2)<32;8,4>         { NoDDChk }             //Copy V data
+       mov     (16)    ubDNDI_RESP(5,65)<2>            ubDNDI_UVCOPY_TEMP(4,0)<32;8,4>         { NoDDClr }             //Copy U data
+       mov     (16)    ubDNDI_RESP(5,64)<2>            ubDNDI_UVCOPY_TEMP(4,2)<32;8,4>         { NoDDChk }             //Copy V data
+       mov     (16)    ubDNDI_RESP(5,97)<2>            ubDNDI_UVCOPY_TEMP(6,0)<32;8,4>         { NoDDClr }             //Copy U data
+       mov     (16)    ubDNDI_RESP(5,96)<2>            ubDNDI_UVCOPY_TEMP(6,2)<32;8,4>         { NoDDChk }             //Copy V data
+
+
+
+// FileName:   DN_Save_422CP_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Save one 16x8 blocks of DN output to the color pipe in 4-2-2 format
+
+
+.declare mubMSGHDR_DN_OUT_2   Base=r36.0      ElementSize=1  Type=ub
+
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                    // message header
+shl (1)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<0;1,0>:w     1:w           { NoDDClr }            // X origin * 2 (422 output)
+mov (1)     mdMSGHDR_DN_OUT(0,1)<1>            r7.1<0;1,0>:w                   { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x7000F:ud      { NoDDClr, NoDDChk }            // block width and height (16x8)
+
+//M0.3 - 0 - CP Enable, 1 - Area of Interest, 3:2 Message Format(TBD), 4:3 - Ignored, 31:5 CP state pointer
+//Compose area-of-interest bit + color pipe state pointer
+or (1)         mudMSGHDR_DN_OUT(0,3)<1>                r2.4<0;1,0>:ud  r7.26<0;1,0>:b          { NoDDChk }
+
+// First 8 x 8 Block
+       mov (8)         mubMSGHDR_DN_OUT(1)<2>                  ubDNDI_RESP(0,0)<8;8,1>                         { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(1,16)<2>               ubDNDI_RESP(0,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(2)<2>                  ubDNDI_RESP(0,32)<8;8,1>                                { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(2,16)<2>               ubDNDI_RESP(0,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(3)<2>                  ubDNDI_RESP(0,64)<8;8,1>                                { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(3,16)<2>               ubDNDI_RESP(0,80)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(4)<2>                  ubDNDI_RESP(0,96)<8;8,1>                                { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(4,16)<2>               ubDNDI_RESP(0,112)<8;8,1>                       { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(1,1)<4>    ubDNDI_RESP(5,1)<8;4,2>                 { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(1,17)<4>           ubDNDI_RESP(5,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(1,3)<4>    ubDNDI_RESP(5,0)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(1,19)<4>           ubDNDI_RESP(5,16)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(2,1)<4>    ubDNDI_RESP(5,33)<8;4,2>                        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(2,17)<4>           ubDNDI_RESP(5,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(2,3)<4>    ubDNDI_RESP(5,32)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(2,19)<4>           ubDNDI_RESP(5,48)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(3,1)<4>    ubDNDI_RESP(5,65)<8;4,2>                        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(3,17)<4>           ubDNDI_RESP(5,81)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(3,3)<4>    ubDNDI_RESP(5,64)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(3,19)<4>           ubDNDI_RESP(5,80)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(4,1)<4>    ubDNDI_RESP(5,97)<8;4,2>                        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(4,17)<4>           ubDNDI_RESP(5,113)<8;4,2>               { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(4,3)<4>    ubDNDI_RESP(5,96)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(4,19)<4>           ubDNDI_RESP(5,112)<8;4,2>                       { NoDDChk }     // copy line of V directly to memory as optimization
+
+// Second 8 x 8 Block
+mov    (8)     r36.0<1>:ud             r31.0<8;8,1>:ud
+add    (1)     r36.0<1>:ud             r36.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DN_OUT_2(1)<2>                ubDNDI_RESP(0,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(1,16)<2>     ubDNDI_RESP(0,24)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(2)<2>                ubDNDI_RESP(0,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(2,16)<2>     ubDNDI_RESP(0,56)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(3)<2>                ubDNDI_RESP(0,72)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(3,16)<2>     ubDNDI_RESP(0,88)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(4)<2>                ubDNDI_RESP(0,104)<8;8,1>                       { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(4,16)<2>     ubDNDI_RESP(0,120)<8;8,1>                       { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(1,1)<4>          ubDNDI_RESP(5,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(1,17)<4>         ubDNDI_RESP(5,25)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(1,3)<4>          ubDNDI_RESP(5,8)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(1,19)<4>         ubDNDI_RESP(5,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(2,1)<4>          ubDNDI_RESP(5,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(2,17)<4>         ubDNDI_RESP(5,57)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(2,3)<4>          ubDNDI_RESP(5,40)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(2,19)<4>         ubDNDI_RESP(5,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(3,1)<4>          ubDNDI_RESP(5,73)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(3,17)<4>         ubDNDI_RESP(5,89)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(3,3)<4>          ubDNDI_RESP(5,72)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(3,19)<4>         ubDNDI_RESP(5,88)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(4,1)<4>          ubDNDI_RESP(5,105)<8;4,2>               { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(4,17)<4>         ubDNDI_RESP(5,121)<8;4,2>               { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(4,3)<4>          ubDNDI_RESP(5,104)<8;4,2>                       { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(4,19)<4>         ubDNDI_RESP(5,120)<8;4,2>               { NoDDChk }     // copy line of V directly to memory as optimization
+
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0xA0A801B:ud
+send (8)    null<1>:d    r36.0 0x5    0xA0A801B:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/NV12_DN_NV12.g4a b/src/shaders/post_processing/gen7/NV12_DN_NV12.g4a
new file mode 100644 (file)
index 0000000..4c932b8
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   40    // Total instruction count
+//    1    // Total kernel count
+
+.kernel NV12_DN_NV12
+.code
+
+
+
+// FileName:   DN_PL_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block) for planar format
+
+
+
+// FileName:   DN.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x45E8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(4,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+
+       mov (2)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(4,0)<2;2,1>         // Move denoise history to MRF (4x2)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x10003:ud                                                                      { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x50003:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE |   X  |   X   |  X  |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       //|            X             |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       mov (1)         mubMSGHDR_ENC_STATS(1,0)<1>             ubDNDI_RESP(4,8)<0;1,0>                 { NoDDClr }                             // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,3)<1>             uwDNDI_RESP(4,11)<0;1,0>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,4)<1>             uwDNDI_RESP(4,12)<2;2,1>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,9)<1>             uwDNDI_RESP(4,8)<0;1,0>                 { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,10)<1>    uwDNDI_RESP(4,9)<2;2,1>                 { NoDDChk }                             // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Load_UV_NV12_16x8.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x8 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Load_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x8 block through DATAPORT
+
+//CHANGE       :  Read extra UV data to convert to 422. -rT
+//we are reading extra data in ALL cases irrespective of whether upsampling is reqd or not later on, to keep things simple.
+
+
+       add (2)         r27.0<1>:d                              r7.0<2;2,1>:w                           r4.4<2;2,1>:w                           // Source Y Block origin
+       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
+       mov (1)         r27.2<1>:ud                             0x4000F:ud                                      { NoDDChk }     // U/V block width and height (8x5)
+    mov (8)     mudMSGHDR_UVCOPY(0)<1>         r27.0<8;8,1>:ud
+       send (8)        udDNDI_UV_RESP(0)<1>            r36     0x4     0x2390001:ud
+
+       //Update Header for Save
+       mov (1)         mudMSGHDR_UVCOPY(0,2)<1>        0x3000F:ud                                                                      // U/V block width and height (8x4)
+
+
+
+// FileName:    DN_Save_Y_16x8.asm
+// Author:      Vivek Kumar
+// Description: Save one 16x8 blocks of Y channel of DN output for reference
+
+
+mov (8)     mudDN_Y_OUT(0,0)<1>     r0<8;8,1>:ud                                // message header
+mov (2)     mudDN_Y_OUT(0,0)<1>     r7.0<2;2,1>:w                  { NoDDClr }     // X origin
+mov (1)     mudDN_Y_OUT(0,2)<1>     0x7000F:ud    { NoDDChk }     // block width and height (16x8)
+
+//send out data through data port
+send (8)    null<1>:d    mudDN_Y_OUT      0x5    0xA0A8018:ud
+
+
+
+// FileName:   DN_Save_UV_NV12_16x8.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x8 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Save_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x8 block through DATAPORT
+
+
+//Reuse the header from Load component
+//Header is modified at the end of load - to be usable for save.
+
+       mov (8)         mudMSGHDR_UVCOPY(1)<1>          udDNDI_UV_RESP(0)<8;8,1>
+       mov (8)         mudMSGHDR_UVCOPY(2)<1>          udDNDI_UV_RESP(1)<8;8,1>
+       send (8)        null<1>:d    r36        0x5    0x60A8019:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
index 0197025..956fc8f 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    9    // Total instruction count
 //    1    // Total kernel count
 
index f3971f0..5db6481 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    7    // Total instruction count
 //    1    // Total kernel count
 
index 941ea0a..607612c 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    7    // Total instruction count
 //    1    // Total kernel count
 
index af0edb7..b1f07b9 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    7    // Total instruction count
 //    1    // Total kernel count
 
diff --git a/src/shaders/post_processing/gen7/PA_DI_422CP.g4a b/src/shaders/post_processing/gen7/PA_DI_422CP.g4a
new file mode 100644 (file)
index 0000000..9f9bed0
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   87    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PA_DI_422CP
+.code
+
+
+
+// FileName:   DI.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DI only case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4AE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:    DI_Save_422CP_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in 422 format to Color Pipe (IECP)
+
+
+.declare mubMSGHDR_DI_OUT1_1  Base=r18.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT1_2  Base=r21.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_1  Base=r24.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_2  Base=r27.0      ElementSize=1  Type=ub
+
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:ud     r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:ud     r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3000F:ud        { NoDDClr, NoDDChk }       // Block width and height (16x8)
+
+//M0.3  - 0 - CP Enable, 1 - Area of Interest, 3:2 Message Format(TBD), 4:3 - Ignored, 31:5 CP state pointer
+//Compose area-of-interest bit + color pipe state pointer
+or (1)  r27.3<1>:ud     r2.4<0;1,0>:ud     r7.26<0;1,0>:b     { NoDDChk }
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r24.0<1>:ud       r27<8;8,1>:ud
+
+
+// Pack 2nd field Y; First 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT1_1(1)<2>                       ubDNDI_RESP(0,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(1,16)<2>            ubDNDI_RESP(0,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2)<2>                       ubDNDI_RESP(0,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2,16)<2>            ubDNDI_RESP(0,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; First 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,1)<4>                 ubDNDI_RESP(2,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,17)<4>        ubDNDI_RESP(2,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,3)<4>         ubDNDI_RESP(2,0)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,19)<4>        ubDNDI_RESP(2,16)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,1)<4>                 ubDNDI_RESP(2,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,17)<4>        ubDNDI_RESP(2,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,3)<4>         ubDNDI_RESP(2,32)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,19)<4>        ubDNDI_RESP(2,48)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+
+// Pack 2nd field Y; Second 8x4 block
+mov    (8)     r21.0<1>:ud             r18.0<8;8,1>:ud
+add    (1)     r21.0<1>:ud             r21.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT1_2(1)<2>                       ubDNDI_RESP(0,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(1,16)<2>            ubDNDI_RESP(0,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2)<2>                       ubDNDI_RESP(0,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2,16)<2>            ubDNDI_RESP(0,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; Second 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,1)<4>                 ubDNDI_RESP(2,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,17)<4>                ubDNDI_RESP(2,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,3)<4>                 ubDNDI_RESP(2,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,19)<4>                ubDNDI_RESP(2,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,1)<4>                 ubDNDI_RESP(2,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,17)<4>                ubDNDI_RESP(2,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,3)<4>                 ubDNDI_RESP(2,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,19)<4>                ubDNDI_RESP(2,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r18.0   0x5     0x60A801B:ud
+send (8)    null<1>:d    r21.0   0x5     0x60A801B:ud
+
+// Pack 1st field Y; 1st 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT2_1(1)<2>                       ubDNDI_RESP(4,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(1,16)<2>            ubDNDI_RESP(4,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2)<2>                       ubDNDI_RESP(4,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2,16)<2>            ubDNDI_RESP(4,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U,V; 1st 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,1)<4>                 ubDNDI_RESP(6,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,17)<4>        ubDNDI_RESP(6,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,3)<4>         ubDNDI_RESP(6,0)<8;4,2>             { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,19)<4>        ubDNDI_RESP(6,16)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,1)<4>                 ubDNDI_RESP(6,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,17)<4>        ubDNDI_RESP(6,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,3)<4>         ubDNDI_RESP(6,32)<8;4,2>                    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,19)<4>        ubDNDI_RESP(6,48)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+
+// Pack 1st field Y; 2nd 8x4 block
+mov    (8)     r27.0<1>:ud             r24.0<8;8,1>:ud
+add    (1)     r27.0<1>:ud             r27.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT2_2(1)<2>                       ubDNDI_RESP(4,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(1,16)<2>            ubDNDI_RESP(4,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2)<2>                       ubDNDI_RESP(4,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2,16)<2>            ubDNDI_RESP(4,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U, V; 2nd 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,1)<4>                 ubDNDI_RESP(6,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,17)<4>                ubDNDI_RESP(6,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,3)<4>                 ubDNDI_RESP(6,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,19)<4>                ubDNDI_RESP(6,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,1)<4>                 ubDNDI_RESP(6,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,17)<4>                ubDNDI_RESP(6,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,3)<4>                 ubDNDI_RESP(6,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,19)<4>                ubDNDI_RESP(6,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r24.0     0x5     0x60A801E:ud
+send (8)    null<1>:d    r27.0     0x5     0x60A801E:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PA_DI_PA.g4a b/src/shaders/post_processing/gen7/PA_DI_PA.g4a
new file mode 100644 (file)
index 0000000..f7a70f4
--- /dev/null
@@ -0,0 +1,399 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   57    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PA_DI_PA
+.code
+
+
+
+// FileName:   DI.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DI only case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4AE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:    DI_Save_PA_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in Packed format
+
+
+add (4) a0.4<1>:uw   r2.28<4;4,1>:ub   608:w               // Initial Y,U,V offset in YUV422 block; it starts at m20
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:d      r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:d      r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3001F:ud          { NoDDChk }          // Block width and height (32x8)
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r23.0<1>:ud       r27<8;8,1>:ud
+
+// Pack 2nd field Y
+    mov (16)    r[a0.4, 0]<2>      ubDNDI_RESP(0,0)               { NoDDClr }
+    mov (16)    r[a0.4, 32]<2>      ubDNDI_RESP(0,16)               { NoDDClr }
+    mov (16)    r[a0.4, 64]<2>      ubDNDI_RESP(0,32)               { NoDDClr }
+    mov (16)    r[a0.4, 96]<2>      ubDNDI_RESP(0,48)               { NoDDClr }
+// Pack 2nd field U
+    mov (8)     r[a0.5, 0]<4>      ubDNDI_RESP(2,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 32]<4>      ubDNDI_RESP(2,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 64]<4>      ubDNDI_RESP(2,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 96]<4>      ubDNDI_RESP(2,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 2nd field V
+    mov (8)     r[a0.6, 0]<4>      ubDNDI_RESP(2,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 32]<4>      ubDNDI_RESP(2,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 64]<4>      ubDNDI_RESP(2,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 96]<4>      ubDNDI_RESP(2,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+// Pack 1st field Y
+    mov (16)    r[a0.4, 160]<2>    ubDNDI_RESP(4,0)               { NoDDClr }
+    mov (16)    r[a0.4, 192]<2>    ubDNDI_RESP(4,16)               { NoDDClr }
+    mov (16)    r[a0.4, 224]<2>    ubDNDI_RESP(4,32)               { NoDDClr }
+    mov (16)    r[a0.4, 256]<2>    ubDNDI_RESP(4,48)               { NoDDClr }
+// Pack 1st field U
+    mov (8)     r[a0.5, 160]<4>    ubDNDI_RESP(6,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 192]<4>    ubDNDI_RESP(6,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 224]<4>    ubDNDI_RESP(6,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 256]<4>    ubDNDI_RESP(6,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 1st field V
+    mov (8)     r[a0.6, 160]<4>    ubDNDI_RESP(6,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 192]<4>    ubDNDI_RESP(6,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 224]<4>    ubDNDI_RESP(6,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 256]<4>    ubDNDI_RESP(6,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+//save the previous frame
+send (8)    null<1>:d    r18.0     0x5     0xA0A801B:ud
+
+//save the current frame
+send (8)    null<1>:d    r23.0     0x5     0xA0A801E:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PA_DNDI_422CP.g4a b/src/shaders/post_processing/gen7/PA_DNDI_422CP.g4a
new file mode 100644 (file)
index 0000000..13302e8
--- /dev/null
@@ -0,0 +1,537 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//  127    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PA_DNDI_422CP
+.code
+
+
+
+// FileName:   DNDI_PL_Core.asm
+// Author:             Tatiya, Rupesh
+
+
+
+// FileName:   DNDI_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN+DI case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4CE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+       mov (1)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(9,0)<0;1,0>         // Move denoise history to MRF (4x1)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x3:ud                                                                  { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Save_PA_16x4.asm
+// Author:             Vivek Kumar
+// Description:        Save one 16x4 blocks of DN output in Packed format for reference
+
+
+ // check top/bottom field first
+cmp.e.f0.0 (1)  null<1>:w               r1.28<0;1,0>:ub     1:w
+
+add (4)                a0.4<1>:uw   r4.0<4;4,1>:ub   1024:w    // Initial Y,U,V offset in YUV422 block; it starts at m14
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                    // message header
+shl (1)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<0;1,0>:w     1:w           { NoDDClr }            // X origin * 2 (422 output)
+mov (1)     mdMSGHDR_DN_OUT(0,1)<1>            r7.1<0;1,0>:w                   { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x3001F:ud      { NoDDChk }            // block width and height (32x8)
+
+(f0.0) jmpi (1) TOP_FIELD_FIRST
+
+BOTTOM_FIELD_FIRST:
+       mov (16)    r[a0.4,  0]<2>:ub     ubDNDI_RESP(10,0)     { NoDDClr }     // 2nd field luma from current frame (line 0,2)
+       mov (16)    r[a0.4,  32]<2>:ub   ubDNDI_RESP(4,16)              { NoDDClr }     // 1st field luma from current frame (line 1,3)
+       mov (16)    r[a0.4,  64]<2>:ub     ubDNDI_RESP(10,16)   { NoDDClr }     // 2nd field luma from current frame (line 0,2)
+       mov (16)    r[a0.4,  96]<2>:ub   ubDNDI_RESP(5,16)              { NoDDClr }     // 1st field luma from current frame (line 1,3)
+       mov (8)     r[a0.5,  0]<4>:ub     ubDNDI_RESP(11,1)<16;8,2> { NoDDClr, NoDDChk }        // 2nd field U from current frame (line 0,2)
+       mov (8)     r[a0.5,  32]<4>:ub   ubDNDI_RESP(6,17)<16;8,2>      { NoDDClr, NoDDChk }    // 1st field U from current frame (line 1,3)
+       mov (8)     r[a0.5,  64]<4>:ub     ubDNDI_RESP(11,17)<16;8,2> { NoDDClr, NoDDChk }      // 2nd field U from current frame (line 0,2)
+       mov (8)     r[a0.5,  96]<4>:ub   ubDNDI_RESP(7,17)<16;8,2>      { NoDDClr, NoDDChk }    // 1st field U from current frame (line 1,3)
+       mov (8)     r[a0.6,  0]<4>:ub     ubDNDI_RESP(11,0)<16;8,2>     { NoDDChk }             // 2nd field V from current frame (line 0,2)
+       mov (8)     r[a0.6,  32]<4>:ub   ubDNDI_RESP(6,16)<16;8,2>              { NoDDChk }             // 1st field U from current frame (line 1,3)
+       mov (8)     r[a0.6,  64]<4>:ub     ubDNDI_RESP(11,16)<16;8,2>   { NoDDChk }             // 2nd field V from current frame (line 0,2)
+       mov (8)     r[a0.6,  96]<4>:ub   ubDNDI_RESP(7,16)<16;8,2>              { NoDDChk }             // 1st field U from current frame (line 1,3)
+jmpi (1) SAVE_DN_CURR
+
+TOP_FIELD_FIRST:
+       mov (16)    r[a0.4,  0]<2>:ub       ubDNDI_RESP(4,0)            { NoDDClr }     // 1st field luma from current frame (line 0,2)
+       mov (16)    r[a0.4,  32]<2>:ub     ubDNDI_RESP(10,0)    { NoDDClr }     // 2nd field luma from current frame (line 1,3)
+       mov (16)    r[a0.4,  64]<2>:ub       ubDNDI_RESP(5,0)           { NoDDClr }     // 1st field luma from current frame (line 0,2)
+       mov (16)    r[a0.4,  96]<2>:ub     ubDNDI_RESP(10,16)   { NoDDClr }     // 2nd field luma from current frame (line 1,3)
+       mov (8)     r[a0.5,  0]<4>:ub       ubDNDI_RESP(6,1)<16;8,2>                    { NoDDClr, NoDDChk }    // 1st field U from current frame (line 0,2)
+       mov (8)     r[a0.5,  32]<4>:ub     ubDNDI_RESP(11,1)<16;8,2>    { NoDDClr, NoDDChk }    // 2nd field U from current frame (line 1,3)
+       mov (8)     r[a0.5,  64]<4>:ub       ubDNDI_RESP(7,1)<16;8,2>                   { NoDDClr, NoDDChk }    // 1st field U from current frame (line 0,2)
+       mov (8)     r[a0.5,  96]<4>:ub     ubDNDI_RESP(11,17)<16;8,2>   { NoDDClr, NoDDChk }    // 2nd field U from current frame (line 1,3)
+       mov (8)     r[a0.6,  0]<4>:ub       ubDNDI_RESP(6,0)<16;8,2>                    { NoDDChk }     // 1st field V from current frame (line 0,2)
+       mov (8)     r[a0.6,  32]<4>:ub     ubDNDI_RESP(11,0)<16;8,2>    { NoDDChk }     // 2nd field V from current frame (line 1,3)
+       mov (8)     r[a0.6,  64]<4>:ub       ubDNDI_RESP(7,0)<16;8,2>                   { NoDDChk }     // 1st field V from current frame (line 0,2)
+       mov (8)     r[a0.6,  96]<4>:ub     ubDNDI_RESP(11,16)<16;8,2>   { NoDDChk }     // 2nd field V from current frame (line 1,3)
+
+SAVE_DN_CURR:
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0xA0A8018:ud
+
+
+
+// FileName:    DI_Save_422CP_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in 422 format to Color Pipe (IECP)
+
+
+.declare mubMSGHDR_DI_OUT1_1  Base=r18.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT1_2  Base=r21.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_1  Base=r24.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_2  Base=r27.0      ElementSize=1  Type=ub
+
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:ud     r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:ud     r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3000F:ud        { NoDDClr, NoDDChk }       // Block width and height (16x8)
+
+//M0.3  - 0 - CP Enable, 1 - Area of Interest, 3:2 Message Format(TBD), 4:3 - Ignored, 31:5 CP state pointer
+//Compose area-of-interest bit + color pipe state pointer
+or (1)  r27.3<1>:ud     r2.4<0;1,0>:ud     r7.26<0;1,0>:b     { NoDDChk }
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r24.0<1>:ud       r27<8;8,1>:ud
+
+
+// Pack 2nd field Y; First 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT1_1(1)<2>                       ubDNDI_RESP(0,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(1,16)<2>            ubDNDI_RESP(0,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2)<2>                       ubDNDI_RESP(0,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2,16)<2>            ubDNDI_RESP(0,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; First 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,1)<4>                 ubDNDI_RESP(2,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,17)<4>        ubDNDI_RESP(2,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,3)<4>         ubDNDI_RESP(2,0)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,19)<4>        ubDNDI_RESP(2,16)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,1)<4>                 ubDNDI_RESP(2,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,17)<4>        ubDNDI_RESP(2,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,3)<4>         ubDNDI_RESP(2,32)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,19)<4>        ubDNDI_RESP(2,48)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+
+// Pack 2nd field Y; Second 8x4 block
+mov    (8)     r21.0<1>:ud             r18.0<8;8,1>:ud
+add    (1)     r21.0<1>:ud             r21.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT1_2(1)<2>                       ubDNDI_RESP(0,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(1,16)<2>            ubDNDI_RESP(0,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2)<2>                       ubDNDI_RESP(0,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2,16)<2>            ubDNDI_RESP(0,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; Second 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,1)<4>                 ubDNDI_RESP(2,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,17)<4>                ubDNDI_RESP(2,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,3)<4>                 ubDNDI_RESP(2,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,19)<4>                ubDNDI_RESP(2,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,1)<4>                 ubDNDI_RESP(2,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,17)<4>                ubDNDI_RESP(2,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,3)<4>                 ubDNDI_RESP(2,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,19)<4>                ubDNDI_RESP(2,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r18.0   0x5     0x60A801B:ud
+send (8)    null<1>:d    r21.0   0x5     0x60A801B:ud
+
+// Pack 1st field Y; 1st 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT2_1(1)<2>                       ubDNDI_RESP(4,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(1,16)<2>            ubDNDI_RESP(4,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2)<2>                       ubDNDI_RESP(4,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2,16)<2>            ubDNDI_RESP(4,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U,V; 1st 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,1)<4>                 ubDNDI_RESP(6,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,17)<4>        ubDNDI_RESP(6,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,3)<4>         ubDNDI_RESP(6,0)<8;4,2>             { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,19)<4>        ubDNDI_RESP(6,16)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,1)<4>                 ubDNDI_RESP(6,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,17)<4>        ubDNDI_RESP(6,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,3)<4>         ubDNDI_RESP(6,32)<8;4,2>                    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,19)<4>        ubDNDI_RESP(6,48)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+
+// Pack 1st field Y; 2nd 8x4 block
+mov    (8)     r27.0<1>:ud             r24.0<8;8,1>:ud
+add    (1)     r27.0<1>:ud             r27.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT2_2(1)<2>                       ubDNDI_RESP(4,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(1,16)<2>            ubDNDI_RESP(4,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2)<2>                       ubDNDI_RESP(4,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2,16)<2>            ubDNDI_RESP(4,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U, V; 2nd 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,1)<4>                 ubDNDI_RESP(6,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,17)<4>                ubDNDI_RESP(6,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,3)<4>                 ubDNDI_RESP(6,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,19)<4>                ubDNDI_RESP(6,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,1)<4>                 ubDNDI_RESP(6,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,17)<4>                ubDNDI_RESP(6,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,3)<4>                 ubDNDI_RESP(6,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,19)<4>                ubDNDI_RESP(6,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r24.0     0x5     0x60A801E:ud
+send (8)    null<1>:d    r27.0     0x5     0x60A801E:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PA_DNDI_PA.g4a b/src/shaders/post_processing/gen7/PA_DNDI_PA.g4a
new file mode 100644 (file)
index 0000000..b42149c
--- /dev/null
@@ -0,0 +1,475 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   97    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PA_DNDI_PA
+.code
+
+
+
+// FileName:   DNDI_PL_Core.asm
+// Author:             Tatiya, Rupesh
+
+
+
+// FileName:   DNDI_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN+DI case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4CE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+       mov (1)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(9,0)<0;1,0>         // Move denoise history to MRF (4x1)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x3:ud                                                                  { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Save_PA_16x4.asm
+// Author:             Vivek Kumar
+// Description:        Save one 16x4 blocks of DN output in Packed format for reference
+
+
+ // check top/bottom field first
+cmp.e.f0.0 (1)  null<1>:w               r1.28<0;1,0>:ub     1:w
+
+add (4)                a0.4<1>:uw   r4.0<4;4,1>:ub   1024:w    // Initial Y,U,V offset in YUV422 block; it starts at m14
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                    // message header
+shl (1)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<0;1,0>:w     1:w           { NoDDClr }            // X origin * 2 (422 output)
+mov (1)     mdMSGHDR_DN_OUT(0,1)<1>            r7.1<0;1,0>:w                   { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x3001F:ud      { NoDDChk }            // block width and height (32x8)
+
+(f0.0) jmpi (1) TOP_FIELD_FIRST
+
+BOTTOM_FIELD_FIRST:
+       mov (16)    r[a0.4,  0]<2>:ub     ubDNDI_RESP(10,0)     { NoDDClr }     // 2nd field luma from current frame (line 0,2)
+       mov (16)    r[a0.4,  32]<2>:ub   ubDNDI_RESP(4,16)              { NoDDClr }     // 1st field luma from current frame (line 1,3)
+       mov (16)    r[a0.4,  64]<2>:ub     ubDNDI_RESP(10,16)   { NoDDClr }     // 2nd field luma from current frame (line 0,2)
+       mov (16)    r[a0.4,  96]<2>:ub   ubDNDI_RESP(5,16)              { NoDDClr }     // 1st field luma from current frame (line 1,3)
+       mov (8)     r[a0.5,  0]<4>:ub     ubDNDI_RESP(11,1)<16;8,2> { NoDDClr, NoDDChk }        // 2nd field U from current frame (line 0,2)
+       mov (8)     r[a0.5,  32]<4>:ub   ubDNDI_RESP(6,17)<16;8,2>      { NoDDClr, NoDDChk }    // 1st field U from current frame (line 1,3)
+       mov (8)     r[a0.5,  64]<4>:ub     ubDNDI_RESP(11,17)<16;8,2> { NoDDClr, NoDDChk }      // 2nd field U from current frame (line 0,2)
+       mov (8)     r[a0.5,  96]<4>:ub   ubDNDI_RESP(7,17)<16;8,2>      { NoDDClr, NoDDChk }    // 1st field U from current frame (line 1,3)
+       mov (8)     r[a0.6,  0]<4>:ub     ubDNDI_RESP(11,0)<16;8,2>     { NoDDChk }             // 2nd field V from current frame (line 0,2)
+       mov (8)     r[a0.6,  32]<4>:ub   ubDNDI_RESP(6,16)<16;8,2>              { NoDDChk }             // 1st field U from current frame (line 1,3)
+       mov (8)     r[a0.6,  64]<4>:ub     ubDNDI_RESP(11,16)<16;8,2>   { NoDDChk }             // 2nd field V from current frame (line 0,2)
+       mov (8)     r[a0.6,  96]<4>:ub   ubDNDI_RESP(7,16)<16;8,2>              { NoDDChk }             // 1st field U from current frame (line 1,3)
+jmpi (1) SAVE_DN_CURR
+
+TOP_FIELD_FIRST:
+       mov (16)    r[a0.4,  0]<2>:ub       ubDNDI_RESP(4,0)            { NoDDClr }     // 1st field luma from current frame (line 0,2)
+       mov (16)    r[a0.4,  32]<2>:ub     ubDNDI_RESP(10,0)    { NoDDClr }     // 2nd field luma from current frame (line 1,3)
+       mov (16)    r[a0.4,  64]<2>:ub       ubDNDI_RESP(5,0)           { NoDDClr }     // 1st field luma from current frame (line 0,2)
+       mov (16)    r[a0.4,  96]<2>:ub     ubDNDI_RESP(10,16)   { NoDDClr }     // 2nd field luma from current frame (line 1,3)
+       mov (8)     r[a0.5,  0]<4>:ub       ubDNDI_RESP(6,1)<16;8,2>                    { NoDDClr, NoDDChk }    // 1st field U from current frame (line 0,2)
+       mov (8)     r[a0.5,  32]<4>:ub     ubDNDI_RESP(11,1)<16;8,2>    { NoDDClr, NoDDChk }    // 2nd field U from current frame (line 1,3)
+       mov (8)     r[a0.5,  64]<4>:ub       ubDNDI_RESP(7,1)<16;8,2>                   { NoDDClr, NoDDChk }    // 1st field U from current frame (line 0,2)
+       mov (8)     r[a0.5,  96]<4>:ub     ubDNDI_RESP(11,17)<16;8,2>   { NoDDClr, NoDDChk }    // 2nd field U from current frame (line 1,3)
+       mov (8)     r[a0.6,  0]<4>:ub       ubDNDI_RESP(6,0)<16;8,2>                    { NoDDChk }     // 1st field V from current frame (line 0,2)
+       mov (8)     r[a0.6,  32]<4>:ub     ubDNDI_RESP(11,0)<16;8,2>    { NoDDChk }     // 2nd field V from current frame (line 1,3)
+       mov (8)     r[a0.6,  64]<4>:ub       ubDNDI_RESP(7,0)<16;8,2>                   { NoDDChk }     // 1st field V from current frame (line 0,2)
+       mov (8)     r[a0.6,  96]<4>:ub     ubDNDI_RESP(11,16)<16;8,2>   { NoDDChk }     // 2nd field V from current frame (line 1,3)
+
+SAVE_DN_CURR:
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0xA0A8018:ud
+
+
+
+// FileName:    DI_Save_PA_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in Packed format
+
+
+add (4) a0.4<1>:uw   r2.28<4;4,1>:ub   608:w               // Initial Y,U,V offset in YUV422 block; it starts at m20
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:d      r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:d      r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3001F:ud          { NoDDChk }          // Block width and height (32x8)
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r23.0<1>:ud       r27<8;8,1>:ud
+
+// Pack 2nd field Y
+    mov (16)    r[a0.4, 0]<2>      ubDNDI_RESP(0,0)               { NoDDClr }
+    mov (16)    r[a0.4, 32]<2>      ubDNDI_RESP(0,16)               { NoDDClr }
+    mov (16)    r[a0.4, 64]<2>      ubDNDI_RESP(0,32)               { NoDDClr }
+    mov (16)    r[a0.4, 96]<2>      ubDNDI_RESP(0,48)               { NoDDClr }
+// Pack 2nd field U
+    mov (8)     r[a0.5, 0]<4>      ubDNDI_RESP(2,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 32]<4>      ubDNDI_RESP(2,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 64]<4>      ubDNDI_RESP(2,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 96]<4>      ubDNDI_RESP(2,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 2nd field V
+    mov (8)     r[a0.6, 0]<4>      ubDNDI_RESP(2,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 32]<4>      ubDNDI_RESP(2,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 64]<4>      ubDNDI_RESP(2,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 96]<4>      ubDNDI_RESP(2,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+// Pack 1st field Y
+    mov (16)    r[a0.4, 160]<2>    ubDNDI_RESP(4,0)               { NoDDClr }
+    mov (16)    r[a0.4, 192]<2>    ubDNDI_RESP(4,16)               { NoDDClr }
+    mov (16)    r[a0.4, 224]<2>    ubDNDI_RESP(4,32)               { NoDDClr }
+    mov (16)    r[a0.4, 256]<2>    ubDNDI_RESP(4,48)               { NoDDClr }
+// Pack 1st field U
+    mov (8)     r[a0.5, 160]<4>    ubDNDI_RESP(6,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 192]<4>    ubDNDI_RESP(6,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 224]<4>    ubDNDI_RESP(6,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 256]<4>    ubDNDI_RESP(6,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 1st field V
+    mov (8)     r[a0.6, 160]<4>    ubDNDI_RESP(6,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 192]<4>    ubDNDI_RESP(6,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 224]<4>    ubDNDI_RESP(6,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 256]<4>    ubDNDI_RESP(6,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+//save the previous frame
+send (8)    null<1>:d    r18.0     0x5     0xA0A801B:ud
+
+//save the current frame
+send (8)    null<1>:d    r23.0     0x5     0xA0A801E:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PA_DNUV_PA.g4a b/src/shaders/post_processing/gen7/PA_DNUV_PA.g4a
new file mode 100644 (file)
index 0000000..cb1fd9c
--- /dev/null
@@ -0,0 +1,2704 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+// 1319    // Total instruction count
+//    1    // Total kernel count
+
+
+.kernel YUY2_DNUV_YUY2
+.code
+
+
+
+//Module               : DN_UV_Setup
+//Author               : Tatiya, Rupesh
+//Description  : Initial Set-up for DN_UV
+
+
+
+
+// Module name : ChromaDenoise.inc
+// Author              : Tatiya, Rupesh
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//======================================================
+//Interface for serpent mode Chroma Denoise, added by Le
+//======================================================
+//r1
+
+
+//noise history thresholds (low and high)
+
+
+//temporal difference thresholds (high and low)
+
+
+//noise history thresholds (low and high)
+//#define ubNoiseHistMaxHigh  r1.22
+//#define ubNoiseHistMaxLow  r1.23
+//#define ubNoiseHistDeltaHigh  r1.24
+//#define ubNoiseHistDeltaLow  r1.25
+
+//Gaussian thresholds
+
+
+//temporal difference thresholds (default)
+
+
+//r2
+//history thresholds (default)
+
+
+//denoise factor  (0-63)
+
+
+//====================== Binding table (Explicit To DNUV)=========================================
+//Used by DN_UV kernels
+
+
+       //Pointer to Current Frame UV
+
+
+//r1-r6
+       //CURBE GRFs used as TEMP : Used for max computation and storing max temporarily. : r1-r6
+
+
+       .declare        ubCURBE_TEMP    Base=r1.0       ElementSize=1   Type=ub
+       .declare        uwCURBE_TEMP    Base=r1.0       ElementSize=2   Type=uw
+       .declare        wCURBE_TEMP             Base=r1.0       ElementSize=2   Type=w
+       .declare        fCURBE_TEMP             Base=r1.0       ElementSize=4   Type=f
+       .declare        udCURBE_TEMP            Base=r1.0       ElementSize=4   Type=ud
+       .declare        uwMAX_ABS_DIFF  Base=r5.0       ElementSize=2   Type=uw
+
+       //r1
+
+
+       //r3
+
+
+    //r4
+
+//r7
+       //All of the following has to defined in Same GRF for optimal performance.
+
+
+//r8-24
+    //Previous Frame UV
+
+       .declare        udPREV_UV               Base=r8.0       ElementSize=4   Type=ud
+       .declare        ubPREV_UV               Base=r8.0       ElementSize=1   Type=ub
+
+
+//r25-48
+       //TEMP Space for any Usage.
+
+
+//=========================================================================
+//Definations and declarations for serpent mode Chroma Denoise, added by Le
+//=========================================================================      
+
+
+       .declare        udGNE_UV                Base=r24.0      ElementSize=4   Type=ud
+  .declare     fGNE_UV         Base=r24.0      ElementSize=4   Type=f
+  .declare     ubGNE_UV                Base=r24.0      ElementSize=1   Type=ub
+
+  .declare     udMSGHDR_BNE_SERP       Base=r25.0      ElementSize=4   Type=ud
+  .declare     udMSGSRC_BNE_SERP       Base=r26.0      ElementSize=4   Type=ud
+
+
+  .declare     ubDN_UV_Thresholds Base=r26.0   ElementSize=1   Type=ub
+  .declare     ubDN_UV_Thresholds_Temp  Base=r27.0     ElementSize=1   Type=ub
+  .declare     udDN_UV_Thresholds Base=r26.0   ElementSize=4   Type=ud
+  .declare     udDN_UV_Thresholds_Temp Base=r27.0      ElementSize=4   Type=ud
+  .declare     fDN_UV_Thresholds Base=r26.0    ElementSize=4   Type=f
+  .declare     fDN_UV_Thresholds_Temp Base=r27.0       ElementSize=4   Type=f  
+
+
+//====================================================================================
+
+
+       //TEMP23: To hold V data for PL3 surfaces
+       .declare        udCURR_V_TEMP   Base=r25.0      ElementSize=4   Type=ud
+       .declare        ubCURR_V_TEMP   Base=r25.0      ElementSize=1   Type=ub
+
+       //GRFs to calculate Median: r25-r42
+       .declare        ubMEDIAN_TEMP   Base=r25.0      ElementSize=1   Type=ub
+
+       //18 GRFs to hold difference : r25-r42
+       .declare        wDIFF                   Base=r25.0      ElementSize=2   Type=w
+       .declare        uwDIFF                  Base=r25.0      ElementSize=2   Type=uw
+
+       //Temporal Diff
+       .declare        wDIFF_TEMPORAL                  Base=r25.0      ElementSize=2   Type=w
+       .declare        ubDIFF_TEMPORAL                 Base=r25.0      ElementSize=1   Type=ub
+
+       //4 GRFs to hold Sobel Value : r43-46
+       .declare        wSOBEL_X        Base=r43.0      ElementSize=2   Type=w
+       .declare        uwSOBEL         Base=r43.0      ElementSize=2   Type=uw
+
+
+       //2 GRFs to hold SOAD temporarily: r47-48
+       .declare        uwSOAD                  Base=r47.0      ElementSize=2   Type=uw
+
+       //Temp GRFs to hold extra YUYV pixels: r43-r48
+       .declare        ubTEMP5                 Base=r43.0      ElementSize=1   Type=ub
+
+       //Temp GRFs in Median Calculation: r47-r48
+       .declare        ubTEMP1                 Base=r47.0      ElementSize=1   Type=ub
+
+       .declare        uwTEMP0                 Base=r48.0      ElementSize=2   Type=uw
+       .declare        ubTEMP0                 Base=r48.0      ElementSize=1   Type=ub
+
+       //Temp Space to store Median : r49-50
+
+       .declare        ubMEDIAN        Base=r49.0      ElementSize=1   Type=ub
+
+//r49
+
+
+//r50
+    //Message Source
+
+
+//r51
+       //DN_UV History Surface
+
+       .declare        udHIST_UV               Base=r51.0      ElementSize=4   Type=ud
+       .declare        ubHIST_UV               Base=r51.0      ElementSize=1   Type=ub
+
+//r52 - r91
+       //r52
+       //Current Frame UV
+
+
+       .declare        udCURR_UV               Base=r52.0      ElementSize=4   Type=ud
+       .declare        ubCURR_UV               Base=r52.0      ElementSize=1   Type=ub
+
+       //r54
+       //CURBE COPY
+
+
+       //r55
+
+
+       .declare        uwSOAD_MIN_8x4          Base=r56.0      ElementSize=2   Type=uw
+
+       //r61
+
+
+       //r62
+
+
+       //History Surface Temp Origin
+
+
+    //r63
+    //Current Frame Y Temp Origin
+
+
+       //BNE Surface Origin
+
+
+    //r70
+
+       .declare        uwDIFF_TEMPORAL_SUM4x4  Base=r70.0      ElementSize=2   Type=uw  //4 GRFs
+
+       //r74-91 : For Saving Dest UV (PL2/PL3)
+
+
+       .declare        ubMSGPAYLOAD_UV0        Base=r75.0      ElementSize=1   Type=ub
+
+
+       .declare        ubMSGPAYLOAD_U          Base=r75.0      ElementSize=1   Type=ub
+
+
+       .declare        ubMSGPAYLOAD_UV1        Base=r84.0      ElementSize=1   Type=ub
+
+
+       .declare        ubMSGPAYLOAD_V          Base=r84.0      ElementSize=1   Type=ub
+
+       //r90
+
+       .declare        uwDIFF_TEMPORAL_SUM4x4_FINAL    Base=r90.0      ElementSize=2   Type=uw  //2 GRFs
+
+//r92-127
+       //Current Frame Y
+
+
+       //r92
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_0           Base=r92        ElementSize=2   Type=uw
+       //r101
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_1           Base=r101       ElementSize=2   Type=uw
+       //r110
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_2           Base=r110       ElementSize=2   Type=uw
+       //r119
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_3           Base=r119       ElementSize=2   Type=uw
+
+       .declare        udCURR_Y0               Base=r93.0      ElementSize=4   Type=ud
+    .declare   ubCURR_Y0               Base=r93.0      ElementSize=1   Type=ub
+    .declare   udCURR_Y1               Base=r102.0     ElementSize=4   Type=ud
+       .declare        ubCURR_Y1               Base=r102.0     ElementSize=1   Type=ub
+       .declare        udCURR_Y2               Base=r111.0     ElementSize=4   Type=ud
+       .declare        ubCURR_Y2               Base=r111.0     ElementSize=1   Type=ub
+       .declare        udCURR_Y3               Base=r120.0     ElementSize=4   Type=ud
+       .declare        ubCURR_Y3               Base=r120.0     ElementSize=1   Type=ub
+
+       //r92: To hold U data for PL3 surfaces
+       .declare        udCURR_U_TEMP           Base=r92.0      ElementSize=4   Type=ud
+    .declare   ubCURR_U_TEMP           Base=r92.0      ElementSize=1   Type=ub
+
+    //r112: To hold U data for PL3 surfaces
+       .declare        udPREV_U_TEMP           Base=r112.0     ElementSize=4   Type=ud
+       .declare        ubPREV_U_TEMP           Base=r112.0     ElementSize=1   Type=ub
+
+       //r120: To hold U data for PL3 surfaces
+       .declare        udPREV_V_TEMP           Base=r120.0     ElementSize=4   Type=ud
+       .declare        ubPREV_V_TEMP           Base=r120.0     ElementSize=1   Type=ub
+
+
+       // Initialize message source with r0.
+       mov (8)   r50.0<1>:ud           r0.0<8;8,1>:ud
+       mov (8)   r92.0<1>:ud           r0.0<8;8,1>:ud
+       mov (8)   r101.0<1>:ud          r0.0<8;8,1>:ud
+       mov (8)   r110.0<1>:ud          r0.0<8;8,1>:ud
+       mov (8)   r119.0<1>:ud          r0.0<8;8,1>:ud
+
+
+
+//Module Name  :       DN_UV_YUY2_Load_Curr_Frame_YUV
+//Author               :       Tatiya, Rupesh
+//Description  :       Loads Current Frame YUV data for YUY2 input.
+
+
+
+//Module name  :  DN_UV_Load_Curr_Frame_UV
+//Author               :  Tatiya, Rupesh
+//Description  :  Loads Current Frame (UV only).
+//                                We need 4 extra rows (2 per field) and 2 extra pixel (1 each side) for both U and V each.
+//                                The processing size is 16x16 U and V each. So we need : U size - 18x20, V size - 18x20, UV size - 36x20, YUYV size - 72x20.
+
+
+
+
+//72x20 interleaved YUYV block is partitioned as follows:
+//                             <------ 36 --------> <--------36 ------->
+//                             ------------------------------------------
+//                             |   |   32x2 B1         |               32x2 B2  |       |
+//                             | 4 |--------------------------------| 4 |
+//                             | x |                           |                                | x |
+//                             |20 |     32x8 A1   |           32x8 A3  | 20|
+//                             |   |---------------|----------------|   |
+//                             | C1|     32x8 A2       |          32x8  A4      | C2|
+//                             |   |                           |                                |       |
+//                             |   |--------------------------------|   |
+//                             |   |   32x2 B3         |               32x2 B4  |       |
+//                             ------------------------------------------
+//
+// Cordinates: (x, y), (x, y+8), (x+32, y), (x+32, y+8), (x-4, y-2), (x+64, y-2),(x, y-2), (x+32, y-2), (x, y+16), (x+32, y+16)
+
+       //UV surface origin: (2xORIX, ORIY)
+       add  (2)        r7.4<1>:w               r7.0<2;2,1>:w           r4.4<2;2,1>:w    { AccWrEn } // Source Block origin
+       shl  (1)        r7.4<1>:w               acc0.4<0;1,0>:w         1:w
+
+       //A1
+       mov  (2)        r92.0<1>:d              r7.4<2;2,1>:w           { AccWrEn }             // Source Block origin
+       mov  (1)        r92.2<1>:ud             0x7001F:ud              
+       send (8)        udCURR_Y0(0)<1>                 r92                     0x4     0x2890003:ud
+
+       //A2
+       mov  (1)    r101.0<1>:d acc0.0<0;1,0>:d                                                 
+       add  (1)    r101.1<1>:d acc0.1<0;1,0>:d         8:d                                     
+       mov  (1)        r101.2<1>:ud    0x7001F:ud              
+       send (8)        udCURR_Y1(0)<1>         r101            0x4     0x2890003:ud
+
+       //B1
+       mov  (1)    r50.0<1>:d  acc0.0<0;1,0>:d                                                         
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 -2:d                            
+       mov  (1)        r50.2<1>:ud     0x1001F:ud                      
+       send (8)        udCURR_UV(0)<1>                 r50             0x4     0x2290003:ud
+
+       //B3
+       mov  (1)    r50.0<1>:d  acc0.0<0;1,0>:d                                                         
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 16:d                            
+       send (8)        udCURR_UV(18)<1>                r50             0x4     0x2290003:ud
+
+       //C1
+       add  (1)    r50.0<1>:d  acc0.0<0;1,0>:d                 -4:d                            
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 -2:d                            
+       mov  (1)        r50.2<1>:ud     0x130003:ud                     
+       send (8)        ubTEMP5(0)<1>                   r50             0x4     0x2390003:ud
+
+       //A3
+       add  (1)    r110.0<1>:d acc0.0<0;1,0>:d         32:d                            
+       mov  (1)    r110.1<1>:d acc0.1<0;1,0>:d                                                 
+       mov  (1)        r110.2<1>:ud    0x7001F:ud              
+       send (8)        udCURR_Y2(0)<1>         r110            0x4     0x2890003:ud
+
+       //A4
+       add  (1)    r119.0<1>:d acc0.0<0;1,0>:d         32:d                            
+       add  (1)    r119.1<1>:d acc0.1<0;1,0>:d          8:d                            
+       mov  (1)        r119.2<1>:ud    0x7001F:ud              
+       send (8)        udCURR_Y3(0)<1>         r119            0x4     0x2890003:ud
+
+       //B2
+       add  (1)    r50.0<1>:d  acc0.0<0;1,0>:d                 32:d                            
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 -2:d                            
+       mov  (1)        r50.2<1>:ud     0x1001F:ud                      
+       send (8)        udCURR_UV(20)<1>                r50             0x4     0x2290003:ud
+
+       //B4
+       add  (1)    r50.0<1>:d  acc0.0<0;1,0>:d                 32:d                            
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 16:d                            
+       send (8)        udCURR_UV(38)<1>                r50             0x4     0x2290003:ud
+
+       //C2
+       add  (1)    r50.0<1>:d  acc0.0<0;1,0>:d                 64:d                            
+       add  (1)    r50.1<1>:d  acc0.1<0;1,0>:d                 -2:d                            
+       mov  (1)        r50.2<1>:ud     0x130003:ud                     
+       send (8)        ubTEMP5(3)<1>                   r50             0x4     0x2390003:ud
+
+       //History Origin, Current Y origin and BNE surface origin - all are in inline GRF. Use , . -rT.
+
+       //Calculate Origin For History Surface: (ORIX/4, ORIY/4)
+       shr  (2)        r7.2<1>:w               r7.0<2;2,1>:w           2:w                     
+
+       //Calculate Origin For BNE Surface: (ORIX/8, ORIY/8)
+       shr  (2)        r7.6<1>:w               r7.0<2;2,1>:w           3:w                     
+
+
+
+//Module Name  :       DN_UV_YUY2_Load_Prev_Frame_YUV.asm
+//Author               :       Tatiya, Rupesh
+//Description  :       Loads Pevious Frame YUV data for YUY2 input.
+
+
+
+//Module Name  :       DN_UV_Load_Prev_Frame_UV
+//Author               :       Tatiya, Rupesh
+//Description  :   Loads Prev Frame (UV only). U size - 16x16, V size - 16x16, UV size - 32x16, YUYV size - 64x16.
+
+
+
+
+       mov  (2)        r50.0<1>:d      r7.4<2;2,1>:w           { AccWrEn }     // Source lock origin
+       mov  (1)        r50.2<1>:ud     0x7001F:ud                                      // U/V block width and height (16x16)
+       send (8)        udPREV_UV(0)<1>                 r50             0x4     0x2890000:ud
+
+       add  (1)        r50.1<1>:ud     acc0.1<0;1,0>:d         8:w                                                                             // Add 16 to X origin
+       send (8)        udPREV_UV(8)<1>                 r50             0x4     0x2890000:ud
+
+       add  (1)        r50.0<1>:ud     acc0.0<0;1,0>:d         32:w                                    
+       mov  (1)        r50.1<1>:ud     acc0.1<0;1,0>:d                                                         
+       send (8)        udPREV_UV(16)<1>                r50             0x4     0x2890000:ud
+
+       add  (1)        r50.1<1>:ud     acc0.0<0;1,0>:d          8:w
+       send (8)        udPREV_UV(24)<1>                r50             0x4     0x2890000:ud
+
+
+       //TODO - See if History loading can be combined with Prev Frame Load. - rT
+
+
+//Module name  :  DN_UV_Load_Hist_UV
+//Author               :  Tatiya, Rupesh
+//Description  :  Load DN History for UV denoise. 4x4 for each U & V.
+
+
+
+
+       mov  (2)        r50.0<1>:d      r7.2<2;2,1>:w                   
+       mov  (1)        r50.2<1>:ud     0x30007:ud              
+       send (8)        udHIST_UV(0)<1>                 r50             0x4     0x2190022:ud
+
+
+
+//Module Name: DN_UV_YUY2_Extract_Curr_Frame_UV
+//Author        : Tatiya, Rupesh
+//Description: Extract UV data from current YUY2 frame.
+
+//72x20 interleaved YUYV block is partitioned as follows:
+//                             <------ 36 --------> <--------36 ------->
+//                             ------------------------------------------
+//                             |   |   32x2 B1         |               32x2 B2  |       |
+//                             | 4 |--------------------------------| 4 |
+//                             | x |                           |                                | x |
+//                             |20 |     32x8 A1   |           32x8 A3  | 20|
+//                             |   |---------------|----------------|   |
+//                             | C1|     32x8 A2       |          32x8  A4      | C2|
+//                             |   |                           |                                |       |
+//                             |   |--------------------------------|   |
+//                             |   |   32x2 B3         |               32x2 B4  |       |
+//                             ------------------------------------------
+
+       // Set SRC pointers according to Input packing i.e. YUYV, YVYU, UYVY, VYUY
+       add  (1) a0.0<1>:uw     r4.1<0;1,0>:ub    2976:w                                        //A1
+       add  (1) a0.1<1>:uw     r4.1<0;1,0>:ub    3264:w                                //A2
+       add  (1) a0.2<1>:uw     r4.1<0;1,0>:ub    3552:w                                //A3
+       add  (1) a0.3<1>:uw     r4.1<0;1,0>:ub    3840:w                                //A4
+       add  (1) a0.4<1>:uw     r4.1<0;1,0>:ub    1664:w                                //B1
+       add  (1) a0.5<1>:uw     r4.1<0;1,0>:ub    2240:w                                //B3B2
+       add  (1) a0.6<1>:uw     r4.1<0;1,0>:ub    2880:w                                //B4
+       add  (1) a0.7<1>:uw     r4.1<0;1,0>:ub    1376:w                                //C1C2
+
+       //Left 20x20 UV : 16x16 UV (Original)+4 extra rows(2 per field on top/bottom)+4 extra pixels(2 on left/right)
+
+       //A1
+               mov (16)  ubCURR_UV(2,2)<1>             r[a0.0, 0]<32;16,2>             
+               mov (16)  ubCURR_UV(3,2)<1>             r[a0.0, 32]<32;16,2>            
+               mov (16)  ubCURR_UV(4,2)<1>             r[a0.0, 64]<32;16,2>            
+               mov (16)  ubCURR_UV(5,2)<1>             r[a0.0, 96]<32;16,2>            
+               mov (16)  ubCURR_UV(6,2)<1>             r[a0.0, 128]<32;16,2>           
+               mov (16)  ubCURR_UV(7,2)<1>             r[a0.0, 160]<32;16,2>           
+               mov (16)  ubCURR_UV(8,2)<1>             r[a0.0, 192]<32;16,2>           
+               mov (16)  ubCURR_UV(9,2)<1>             r[a0.0, 224]<32;16,2>           
+
+       //A2
+               mov (16)  ubCURR_UV(10,2)<1>            r[a0.1, 0]<32;16,2>             
+               mov (16)  ubCURR_UV(11,2)<1>            r[a0.1, 32]<32;16,2>            
+               mov (16)  ubCURR_UV(12,2)<1>            r[a0.1, 64]<32;16,2>            
+               mov (16)  ubCURR_UV(13,2)<1>            r[a0.1, 96]<32;16,2>            
+               mov (16)  ubCURR_UV(14,2)<1>            r[a0.1, 128]<32;16,2>           
+               mov (16)  ubCURR_UV(15,2)<1>            r[a0.1, 160]<32;16,2>           
+               mov (16)  ubCURR_UV(16,2)<1>            r[a0.1, 192]<32;16,2>           
+               mov (16)  ubCURR_UV(17,2)<1>            r[a0.1, 224]<32;16,2>           
+
+       //B1
+               mov (16)  ubCURR_UV(0,2)<1>             r[a0.4, 0]<32;16,2>             
+               mov (16)  ubCURR_UV(1,2)<1>             r[a0.4, 32]<32;16,2>            
+
+       //B3
+               mov (16)  ubCURR_UV(18,2)<1>            r[a0.5, 0]<32;16,2>             
+               mov (16)  ubCURR_UV(19,2)<1>            r[a0.5, 32]<32;16,2>            
+
+       //TODO - Find a way to reduce this 40 SIMD2 instructions - rT
+       //C1
+               mov (2)  ubCURR_UV(0,0)<1>                      r[a0.7, 0]<4;2,2>               
+               mov (2)  ubCURR_UV(1,0)<1>                      r[a0.7, 4]<4;2,2>               
+               mov (2)  ubCURR_UV(2,0)<1>                      r[a0.7, 8]<4;2,2>               
+               mov (2)  ubCURR_UV(3,0)<1>                      r[a0.7, 12]<4;2,2>              
+               mov (2)  ubCURR_UV(4,0)<1>                      r[a0.7, 16]<4;2,2>              
+               mov (2)  ubCURR_UV(5,0)<1>                      r[a0.7, 20]<4;2,2>              
+               mov (2)  ubCURR_UV(6,0)<1>                      r[a0.7, 24]<4;2,2>              
+               mov (2)  ubCURR_UV(7,0)<1>                      r[a0.7, 28]<4;2,2>              
+               mov (2)  ubCURR_UV(8,0)<1>                      r[a0.7, 32]<4;2,2>              
+               mov (2)  ubCURR_UV(9,0)<1>                      r[a0.7, 36]<4;2,2>              
+               mov (2)  ubCURR_UV(10,0)<1>                     r[a0.7, 40]<4;2,2>              
+               mov (2)  ubCURR_UV(11,0)<1>                     r[a0.7, 44]<4;2,2>              
+               mov (2)  ubCURR_UV(12,0)<1>                     r[a0.7, 48]<4;2,2>              
+               mov (2)  ubCURR_UV(13,0)<1>                     r[a0.7, 52]<4;2,2>              
+               mov (2)  ubCURR_UV(14,0)<1>                     r[a0.7, 56]<4;2,2>              
+               mov (2)  ubCURR_UV(15,0)<1>                     r[a0.7, 60]<4;2,2>              
+               mov (2)  ubCURR_UV(16,0)<1>                     r[a0.7, 64]<4;2,2>              
+               mov (2)  ubCURR_UV(17,0)<1>                     r[a0.7, 68]<4;2,2>              
+               mov (2)  ubCURR_UV(18,0)<1>                     r[a0.7, 72]<4;2,2>              
+               mov (2)  ubCURR_UV(19,0)<1>                     r[a0.7, 76]<4;2,2>              
+
+       //2 right bytes from B2 - 2 rows
+               mov (2)  ubCURR_UV(0,18)<1>             r[a0.5, 64]<4;2,2>      
+               mov (2)  ubCURR_UV(1,18)<1>             r[a0.5, 96]<4;2,2>      
+
+       //2 right bytes from A3 - 8 rows
+               mov (2)  ubCURR_UV(2,18)<1>             r[a0.2, 0]<4;2,2>                       
+               mov (2)  ubCURR_UV(3,18)<1>             r[a0.2, 32]<4;2,2>                      
+               mov (2)  ubCURR_UV(4,18)<1>             r[a0.2, 64]<4;2,2>                      
+               mov (2)  ubCURR_UV(5,18)<1>             r[a0.2, 96]<4;2,2>                      
+               mov (2)  ubCURR_UV(6,18)<1>             r[a0.2, 128]<4;2,2>                     
+               mov (2)  ubCURR_UV(7,18)<1>             r[a0.2, 160]<4;2,2>                     
+               mov (2)  ubCURR_UV(8,18)<1>             r[a0.2, 192]<4;2,2>                     
+               mov (2)  ubCURR_UV(9,18)<1>             r[a0.2, 224]<4;2,2>                     
+
+       //2 right bytes from A4 - 8 rows
+               mov (2)  ubCURR_UV(10,18)<1>            r[a0.3, 0]<4;2,2>                       
+               mov (2)  ubCURR_UV(11,18)<1>            r[a0.3, 32]<4;2,2>                      
+               mov (2)  ubCURR_UV(12,18)<1>            r[a0.3, 64]<4;2,2>                      
+               mov (2)  ubCURR_UV(13,18)<1>            r[a0.3, 96]<4;2,2>                      
+               mov (2)  ubCURR_UV(14,18)<1>            r[a0.3, 128]<4;2,2>                     
+               mov (2)  ubCURR_UV(15,18)<1>            r[a0.3, 160]<4;2,2>                     
+               mov (2)  ubCURR_UV(16,18)<1>            r[a0.3, 192]<4;2,2>                     
+               mov (2)  ubCURR_UV(17,18)<1>            r[a0.3, 224]<4;2,2>                     
+
+       //2 right bytes from B4 - 2 rows
+               mov (2)  ubCURR_UV(18,18)<1>            r[a0.6, 0]<4;2,2>               
+               mov (2)  ubCURR_UV(19,18)<1>            r[a0.6, 32]<4;2,2>              
+
+       //Right 20x20 UV : 16x16 UV (Original)+4 extra rows(2 per field on top/bottom)+4 extra pixels(2 on left/right)
+
+       //A3
+               mov (16)  ubCURR_UV(22,2)<1>            r[a0.2, 0]<32;16,2>             
+               mov (16)  ubCURR_UV(23,2)<1>            r[a0.2, 32]<32;16,2>            
+               mov (16)  ubCURR_UV(24,2)<1>            r[a0.2, 64]<32;16,2>            
+               mov (16)  ubCURR_UV(25,2)<1>            r[a0.2, 96]<32;16,2>            
+               mov (16)  ubCURR_UV(26,2)<1>            r[a0.2, 128]<32;16,2>           
+               mov (16)  ubCURR_UV(27,2)<1>            r[a0.2, 160]<32;16,2>           
+               mov (16)  ubCURR_UV(28,2)<1>            r[a0.2, 192]<32;16,2>           
+               mov (16)  ubCURR_UV(29,2)<1>            r[a0.2, 224]<32;16,2>           
+
+       //A4
+               mov (16)  ubCURR_UV(30,2)<1>            r[a0.3, 0]<32;16,2>             
+               mov (16)  ubCURR_UV(31,2)<1>            r[a0.3, 32]<32;16,2>            
+               mov (16)  ubCURR_UV(32,2)<1>            r[a0.3, 64]<32;16,2>            
+               mov (16)  ubCURR_UV(33,2)<1>            r[a0.3, 96]<32;16,2>            
+               mov (16)  ubCURR_UV(34,2)<1>            r[a0.3, 128]<32;16,2>           
+               mov (16)  ubCURR_UV(35,2)<1>            r[a0.3, 160]<32;16,2>           
+               mov (16)  ubCURR_UV(36,2)<1>            r[a0.3, 192]<32;16,2>           
+               mov (16)  ubCURR_UV(37,2)<1>            r[a0.3, 224]<32;16,2>           
+
+       //B2
+               mov (16)  ubCURR_UV(20,2)<1>            r[a0.5, 64]<32;16,2>    
+               mov (16)  ubCURR_UV(21,2)<1>            r[a0.5, 96]<32;16,2>    
+
+       //B4
+               mov (16)  ubCURR_UV(38,2)<1>            r[a0.6, 0]<32;16,2>             
+               mov (16)  ubCURR_UV(39,2)<1>            r[a0.6, 32]<32;16,2>            
+
+       //TODO - Find a way to reduce this 40 SIMD2 instructions - rT
+       //C2
+               mov (2)  ubCURR_UV(20,18)<1>            r[a0.7, 96]<4;2,2>              
+               mov (2)  ubCURR_UV(21,18)<1>            r[a0.7, 100]<4;2,2>             
+               mov (2)  ubCURR_UV(22,18)<1>            r[a0.7, 104]<4;2,2>             
+               mov (2)  ubCURR_UV(23,18)<1>            r[a0.7, 108]<4;2,2>             
+               mov (2)  ubCURR_UV(24,18)<1>            r[a0.7, 112]<4;2,2>             
+               mov (2)  ubCURR_UV(25,18)<1>            r[a0.7, 116]<4;2,2>             
+               mov (2)  ubCURR_UV(26,18)<1>            r[a0.7, 120]<4;2,2>             
+               mov (2)  ubCURR_UV(27,18)<1>            r[a0.7, 124]<4;2,2>             
+               mov (2)  ubCURR_UV(28,18)<1>            r[a0.7, 128]<4;2,2>             
+               mov (2)  ubCURR_UV(29,18)<1>            r[a0.7, 132]<4;2,2>             
+               mov (2)  ubCURR_UV(30,18)<1>            r[a0.7, 136]<4;2,2>             
+               mov (2)  ubCURR_UV(31,18)<1>            r[a0.7, 140]<4;2,2>             
+               mov (2)  ubCURR_UV(32,18)<1>            r[a0.7, 144]<4;2,2>             
+               mov (2)  ubCURR_UV(33,18)<1>            r[a0.7, 148]<4;2,2>             
+               mov (2)  ubCURR_UV(34,18)<1>            r[a0.7, 152]<4;2,2>             
+               mov (2)  ubCURR_UV(35,18)<1>            r[a0.7, 156]<4;2,2>             
+               mov (2)  ubCURR_UV(36,18)<1>            r[a0.7, 160]<4;2,2>             
+               mov (2)  ubCURR_UV(37,18)<1>            r[a0.7, 164]<4;2,2>             
+               mov (2)  ubCURR_UV(38,18)<1>            r[a0.7, 168]<4;2,2>             
+               mov (2)  ubCURR_UV(39,18)<1>            r[a0.7, 172]<4;2,2>             
+
+       //2 left bytes from B1 - 2 rows
+               mov (2)  ubCURR_UV(20,0)<1>             r[a0.4, 28]<4;2,2>                      
+               mov (2)  ubCURR_UV(21,0)<1>             r[a0.4, 60]<4;2,2>                      
+
+       //2 left bytes from A1 - 8 rows
+               mov (2)  ubCURR_UV(22,0)<1>             r[a0.0, 28]<4;2,2>                      
+               mov (2)  ubCURR_UV(23,0)<1>             r[a0.0, 60]<4;2,2>                      
+               mov (2)  ubCURR_UV(24,0)<1>             r[a0.0, 92]<4;2,2>                      
+               mov (2)  ubCURR_UV(25,0)<1>             r[a0.0, 124]<4;2,2>                     
+               mov (2)  ubCURR_UV(26,0)<1>             r[a0.0, 156]<4;2,2>                     
+               mov (2)  ubCURR_UV(27,0)<1>             r[a0.0, 188]<4;2,2>                     
+               mov (2)  ubCURR_UV(28,0)<1>             r[a0.0, 220]<4;2,2>                     
+               mov (2)  ubCURR_UV(29,0)<1>             r[a0.0, 252]<4;2,2>                     
+
+       //2 left bytes from A2 - 8 rows
+               mov (2)  ubCURR_UV(30,0)<1>             r[a0.1, 28]<4;2,2>                      
+               mov (2)  ubCURR_UV(31,0)<1>             r[a0.1, 60]<4;2,2>                      
+               mov (2)  ubCURR_UV(32,0)<1>             r[a0.1, 92]<4;2,2>                      
+               mov (2)  ubCURR_UV(33,0)<1>             r[a0.1, 124]<4;2,2>                     
+               mov (2)  ubCURR_UV(34,0)<1>             r[a0.1, 156]<4;2,2>                     
+               mov (2)  ubCURR_UV(35,0)<1>             r[a0.1, 188]<4;2,2>                     
+               mov (2)  ubCURR_UV(36,0)<1>             r[a0.1, 220]<4;2,2>                     
+               mov (2)  ubCURR_UV(37,0)<1>             r[a0.1, 252]<4;2,2>                     
+
+       //2 left bytes from B3 - 2 rows
+               mov (2)  ubCURR_UV(38,0)<1>             r[a0.5, 28]<4;2,2>                      
+               mov (2)  ubCURR_UV(39,0)<1>             r[a0.5, 60]<4;2,2>                      
+
+
+
+// Module Name         :       DN_UV_YUY2_Extract_Prev_Frame_UV
+// Author              :       Tatiya, Rupesh
+// Description :       Extract UV from previous frame YUY2.
+
+       // Set SRC pointers according to Input packing i.e. YUYV, YVYU, UYVY, VYUY
+       add  (1) a0.0<1>:uw     r4.1<0;1,0>:ub    256:w         
+       add  (1) a0.1<1>:uw     r4.1<0;1,0>:ub    768:w         
+
+               mov (16)  ubPREV_UV(0,0)<1>             r[a0.0, 0]<32;16,2>:ub                  
+               mov (16)  ubPREV_UV(0,16)<1>            r[a0.0, 32]<32;16,2>:ub         
+               mov (16)  ubPREV_UV(1,0)<1>             r[a0.0, 64]<32;16,2>:ub                 
+               mov (16)  ubPREV_UV(1,16)<1>            r[a0.0, 96]<32;16,2>:ub         
+               mov (16)  ubPREV_UV(2,0)<1>             r[a0.0, 128]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(2,16)<1>            r[a0.0, 160]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(3,0)<1>             r[a0.0, 192]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(3,16)<1>            r[a0.0, 224]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(4,0)<1>             r[a0.0, 256]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(4,16)<1>            r[a0.0, 288]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(5,0)<1>             r[a0.0, 320]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(5,16)<1>            r[a0.0, 352]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(6,0)<1>             r[a0.0, 384]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(6,16)<1>            r[a0.0, 416]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(7,0)<1>             r[a0.0, 448]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(7,16)<1>            r[a0.0, 480]<32;16,2>:ub                
+
+               mov (16)  ubPREV_UV(8,0)<1>             r[a0.1, 0]<32;16,2>:ub                  
+               mov (16)  ubPREV_UV(8,16)<1>            r[a0.1, 32]<32;16,2>:ub         
+               mov (16)  ubPREV_UV(9,0)<1>             r[a0.1, 64]<32;16,2>:ub                 
+               mov (16)  ubPREV_UV(9,16)<1>            r[a0.1, 96]<32;16,2>:ub         
+               mov (16)  ubPREV_UV(10,0)<1>            r[a0.1, 128]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(10,16)<1>           r[a0.1, 160]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(11,0)<1>            r[a0.1, 192]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(11,16)<1>           r[a0.1, 224]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(12,0)<1>            r[a0.1, 256]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(12,16)<1>           r[a0.1, 288]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(13,0)<1>            r[a0.1, 320]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(13,16)<1>           r[a0.1, 352]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(14,0)<1>            r[a0.1, 384]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(14,16)<1>           r[a0.1, 416]<32;16,2>:ub                
+               mov (16)  ubPREV_UV(15,0)<1>            r[a0.1, 448]<32;16,2>:ub                        
+               mov (16)  ubPREV_UV(15,16)<1>           r[a0.1, 480]<32;16,2>:ub                
+
+
+
+//Module Name : DN_UV_Noise_Detection_UV
+//Author         : Tatiya, Rupesh
+//Description : Performs noise detection on 16x16 U and 16x16 V each.
+
+
+
+//Module Name  : DN_UV_Move_CURBE_Inline_UV.asm
+//Author               : Tatiya, Rupesh
+
+
+
+
+       //Mov CURBE data to another space - so that it can be used as Temp Space --> r1 - r6
+       mov (4) r54.28<1>:ub            r2.28<4;4,1>:ub         //Dest. YUY2 offset
+       mov (2) r54.5<1>:ud             r4.0<4;2,2>:ud          //Src YUY2 offset and Origin offset
+       mov (4) r55.28<1>:ub            r1.0<4;4,1>:ub
+
+       mov (8) r61.20<1>:ub            r1.4<8;8,1>:ub          
+       mov (4) r61.28<1>:ub            r1.12<4;4,1>:ub         
+
+       //Move Inline Data to another space - so that it can be used as Temp Space --> r7
+       mov (4) r62.10<1>:w                             r7.0<4;4,1>:w
+       mov (4) r63.10<1>:w             r7.4<4;4,1>:w
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       mov (1) a0.0:uw                         1664:uw                         
+       mov (1) a0.1:uw 1816:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         1792:uw                 
+       mov (1) a0.1:uw 1820:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         1920:uw                 
+       mov (1) a0.1:uw 1848:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2048:uw                 
+       mov (1) a0.1:uw 1852:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       mov (1) a0.0:uw                         2304:uw                 
+       mov (1) a0.1:uw 1880:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2432:uw                 
+       mov (1) a0.1:uw 1884:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2560:uw                 
+       mov (1) a0.1:uw 1912:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2688:uw                 
+       mov (1) a0.1:uw 1916:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+//Module               : DN_UV_Noise_Reduction_UV
+//Author               : Tatiya, Rupesh
+//Description  : Performs Noise Reduction on 16x16 U and 16x16 V.
+//Tasks                        : 1. Update weight history
+//                               2. Find if it block is motion block
+//                               3. Compute Denoised Pixel.
+
+
+
+
+//History is 1+1 byte every 4x4 U and 4x4 V.
+
+       cmp.l.f0.0 (16) null<1>:w               ubHIST_UV(0,0)<16;16,1>         r61.20<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w               ubHIST_UV(0,0)<16;16,1>         r61.22<0;2,1>:ub
+
+       mov (16)        uwCURBE_TEMP(0)<1>      0:w
+       mov (16)        uwCURBE_TEMP(1)<1>      0:w
+
+       //Compute diff betn curr and prev. - First 16 lines
+       // 8 lines here
+    add (16)   wDIFF_TEMPORAL(0)<1>                    ubCURR_UV(2,2)<16;16,1>         -ubPREV_UV(0,0)<16;16,1>                //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(1)<1>                    ubCURR_UV(3,2)<16;16,1>         -ubPREV_UV(0,16)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(2)<1>                    ubCURR_UV(4,2)<16;16,1>         -ubPREV_UV(0,32)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(3)<1>                    ubCURR_UV(5,2)<16;16,1>         -ubPREV_UV(0,48)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(4)<1>                    ubCURR_UV(6,2)<16;16,1>         -ubPREV_UV(0,64)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(5)<1>                    ubCURR_UV(7,2)<16;16,1>         -ubPREV_UV(0,80)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(6)<1>                    ubCURR_UV(8,2)<16;16,1>         -ubPREV_UV(0,96)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(7)<1>                    ubCURR_UV(9,2)<16;16,1>         -ubPREV_UV(0,112)<16;16,1>              //Diff UV interleaved
+
+       //Update WT HIST
+       (-f0.0) shr     (16) uwCURBE_TEMP(0)<1>         ubHIST_UV(0,0)<16;16,1>         1:w
+       (f1.0)  add     (16) uwCURBE_TEMP(2)<1>         ubHIST_UV(0,0)<16;16,1>         r61.24<0;2,1>:ub
+       (f0.0)  mov     (16) uwCURBE_TEMP(2)<1>         r61.20<0;2,1>:ub
+       (-f0.0.anyv) mov        (16) uwCURBE_TEMP(2)<1>         ubHIST_UV(0,0)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w               ubHIST_UV(0,16)<16;16,1>        r61.20<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w               ubHIST_UV(0,16)<16;16,1>        r61.22<0;2,1>:ub
+
+       //Compute diff betn curr and prev. - First 16 lines
+       // 8 more lines here
+    add (16)   wDIFF_TEMPORAL(8)<1>                    ubCURR_UV(10,2)<16;16,1>                -ubPREV_UV(0,128)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(9)<1>                    ubCURR_UV(11,2)<16;16,1>                -ubPREV_UV(0,144)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(10)<1>                   ubCURR_UV(12,2)<16;16,1>                -ubPREV_UV(0,160)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(11)<1>                   ubCURR_UV(13,2)<16;16,1>                -ubPREV_UV(0,176)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(12)<1>                   ubCURR_UV(14,2)<16;16,1>                -ubPREV_UV(0,192)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(13)<1>                   ubCURR_UV(15,2)<16;16,1>                -ubPREV_UV(0,208)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(14)<1>                   ubCURR_UV(16,2)<16;16,1>                -ubPREV_UV(0,224)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(15)<1>                   ubCURR_UV(17,2)<16;16,1>                -ubPREV_UV(0,240)<16;16,1>              //Diff UV interleaved
+
+       (-f0.0) shr     (16) uwCURBE_TEMP(1)<1>         ubHIST_UV(0,16)<16;16,1>        1:w
+       (f1.0)  add     (16) uwCURBE_TEMP(3)<1>         ubHIST_UV(0,16)<16;16,1>        r61.24<0;2,1>:ub
+       (f0.0)  mov     (16) uwCURBE_TEMP(3)<1>         r61.20<0;2,1>:ub
+       (-f0.0.anyv) mov(16) uwCURBE_TEMP(3)<1>         ubHIST_UV(0,16)<16;16,1>
+
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(0)<16;16,1> (abs)wDIFF_TEMPORAL(1)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(2)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(3)<16;16,1>
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(4)<16;16,1> (abs)wDIFF_TEMPORAL(5)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(6)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(7)<16;16,1>
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(8)<16;16,1> (abs)wDIFF_TEMPORAL(9)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(10)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(2)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(11)<16;16,1>
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(12)<16;16,1>        (abs)wDIFF_TEMPORAL(13)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(14)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(3)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(15)<16;16,1>
+
+//Compute diff betn curr and prev. - Second 16 lines
+//13 lines.
+    add (16)   wDIFF_TEMPORAL(16)<1>           ubCURR_UV(22,2)<16;16,1>                -ubPREV_UV(8,0)<16;16,1>                //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(17)<1>           ubCURR_UV(23,2)<16;16,1>                -ubPREV_UV(8,16)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(18)<1>           ubCURR_UV(24,2)<16;16,1>                -ubPREV_UV(8,32)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(19)<1>           ubCURR_UV(25,2)<16;16,1>                -ubPREV_UV(8,48)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(20)<1>           ubCURR_UV(26,2)<16;16,1>                -ubPREV_UV(8,64)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(21)<1>           ubCURR_UV(27,2)<16;16,1>                -ubPREV_UV(8,80)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(22)<1>           ubCURR_UV(28,2)<16;16,1>                -ubPREV_UV(8,96)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(23)<1>           ubCURR_UV(29,2)<16;16,1>                -ubPREV_UV(8,112)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(24)<1>           ubCURR_UV(30,2)<16;16,1>                -ubPREV_UV(8,128)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(25)<1>           ubCURR_UV(31,2)<16;16,1>                -ubPREV_UV(8,144)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(26)<1>           ubCURR_UV(32,2)<16;16,1>                -ubPREV_UV(8,160)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(27)<1>           ubCURR_UV(33,2)<16;16,1>                -ubPREV_UV(8,176)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(28)<1>           ubCURR_UV(34,2)<16;16,1>                -ubPREV_UV(8,192)<16;16,1>              //Diff UV interleaved
+
+//3 more lines
+    add (16)   wCURBE_TEMP(4)<1>               ubCURR_UV(35,2)<16;16,1>                -ubPREV_UV(8,208)<16;16,1>              //Diff UV interleaved
+    add (16)   wCURBE_TEMP(5)<1>               ubCURR_UV(36,2)<16;16,1>                -ubPREV_UV(8,224)<16;16,1>              //Diff UV interleaved
+    add (16)   wCURBE_TEMP(6)<1>               ubCURR_UV(37,2)<16;16,1>                -ubPREV_UV(8,240)<16;16,1>              //Diff UV interleaved
+
+       //16x4 to 8x4 - First 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>            uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>            uwDIFF_TEMPORAL_SUM4x4(2,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(2,2)<4;2,1>
+
+       //8x4 to 4x4 - First 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4_FINAL(0)<1>      uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>              { AccWrEn }
+
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(16)<16;16,1>        (abs)wDIFF_TEMPORAL(17)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(18)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(19)<16;16,1>
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(20)<16;16,1>        (abs)wDIFF_TEMPORAL(21)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(22)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(23)<16;16,1>
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(24)<16;16,1>        (abs)wDIFF_TEMPORAL(25)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(26)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(2)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(27)<16;16,1>
+
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(28)<16;16,1>        (abs)wCURBE_TEMP(4)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wCURBE_TEMP(5)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(3)<1>    acc0.0<16;16,1>:uw                                      (abs)wCURBE_TEMP(6)<16;16,1>
+
+       //Find if block is motion block - First 16 lines
+       cmp.g.f0.0  (16) null<1>:w                              uwDIFF_TEMPORAL_SUM4x4_FINAL(0)<16;16,1>                r61.26<0;2,1>:ub
+
+       //Move TEMPORAL_SUM4x4 for SIMD16 use later.
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,0)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,2)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,4)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,6)<0;2,1>      
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,8)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,10)<0;2,1>     
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,12)<0;2,1>             
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,14)<0;2,1>     
+
+       //Pick Appropriate Weight History Based on motion. - First 16 lines
+       (-f0.0) mov (16) uwCURBE_TEMP(0)<1>             uwCURBE_TEMP(2)<16;16,1>
+
+       //Actual DN - First 16 lines
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(0)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(0)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(2,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(2,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(2,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,0)<8;8,1>                                   uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,8)<8;8,1>                                   uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(0)<1>                    acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(0)<1>                   ubCURR_UV(2,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(0)<1>    wDIFF_TEMPORAL(0)<16;16,1>                                      ubCURR_UV(2,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(1)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(1)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(3,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(3,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(3,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,16)<8;8,1>                          uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,24)<8;8,1>                          uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(1)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(1)<1>           ubCURR_UV(3,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(1)<1>    wDIFF_TEMPORAL(1)<16;16,1>                              ubCURR_UV(3,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(2)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(2)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(4,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(4,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(4,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,32)<8;8,1>                          uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,40)<8;8,1>                          uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(2)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(2)<1>           ubCURR_UV(4,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(2)<1>    wDIFF_TEMPORAL(2)<16;16,1>                              ubCURR_UV(4,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(3)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(3)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(5,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(5,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(5,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,48)<8;8,1>                          uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,56)<8;8,1>                          uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(3)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(3)<1>           ubCURR_UV(5,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(3)<1>    wDIFF_TEMPORAL(3)<16;16,1>                              ubCURR_UV(5,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(4)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(4)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(6,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(6,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(6,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,64)<8;8,1>                                  uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,72)<8;8,1>                                  uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(4)<1>                    acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(4)<1>                   ubCURR_UV(6,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(4)<1>    wDIFF_TEMPORAL(4)<16;16,1>                                      ubCURR_UV(6,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(5)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(5)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(7,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(7,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(7,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,80)<8;8,1>                          uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,88)<8;8,1>                          uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(5)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(5)<1>           ubCURR_UV(7,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(5)<1>    wDIFF_TEMPORAL(5)<16;16,1>                              ubCURR_UV(7,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(6)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(6)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(8,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(8,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(8,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,96)<8;8,1>                          uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,104)<8;8,1>                         uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(6)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(6)<1>           ubCURR_UV(8,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(6)<1>    wDIFF_TEMPORAL(6)<16;16,1>                              ubCURR_UV(8,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(7)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(7)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(9,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(9,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(9,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,112)<8;8,1>                         uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,120)<8;8,1>                         uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(7)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(7)<1>           ubCURR_UV(9,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(7)<1>    wDIFF_TEMPORAL(7)<16;16,1>                              ubCURR_UV(9,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(8)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(8)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(10,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(10,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(10,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,128)<8;8,1>                                 uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,136)<8;8,1>                                 uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(8)<1>                    acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(8)<1>                   ubCURR_UV(10,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(8)<1>    wDIFF_TEMPORAL(8)<16;16,1>                                      ubCURR_UV(10,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(9)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(9)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(11,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(11,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(11,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,144)<8;8,1>                         uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,152)<8;8,1>                         uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(9)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(9)<1>           ubCURR_UV(11,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(9)<1>    wDIFF_TEMPORAL(9)<16;16,1>                              ubCURR_UV(11,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(10)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(10)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(12,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(12,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(12,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,160)<8;8,1>                         uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,168)<8;8,1>                         uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(10)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(10)<1>          ubCURR_UV(12,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(10)<1>   wDIFF_TEMPORAL(10)<16;16,1>                             ubCURR_UV(12,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(11)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(11)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(13,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(13,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(13,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,176)<8;8,1>                         uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,184)<8;8,1>                         uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(11)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(11)<1>          ubCURR_UV(13,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(11)<1>   wDIFF_TEMPORAL(11)<16;16,1>                             ubCURR_UV(13,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(12)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(12)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(14,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(14,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(14,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,192)<8;8,1>                                 uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,200)<8;8,1>                                 uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(12)<1>                   acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(12)<1>                  ubCURR_UV(14,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(12)<1>   wDIFF_TEMPORAL(12)<16;16,1>                                     ubCURR_UV(14,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(13)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(13)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(15,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(15,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(15,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,208)<8;8,1>                         uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,216)<8;8,1>                         uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(13)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(13)<1>          ubCURR_UV(15,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(13)<1>   wDIFF_TEMPORAL(13)<16;16,1>                             ubCURR_UV(15,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(14)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(14)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(16,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(16,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(16,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,224)<8;8,1>                         uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,232)<8;8,1>                         uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(14)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(14)<1>          ubCURR_UV(16,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(14)<1>   wDIFF_TEMPORAL(14)<16;16,1>                             ubCURR_UV(16,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(15)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(15)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(17,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(17,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(17,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,240)<8;8,1>                         uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,248)<8;8,1>                         uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(15)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(15)<1>          ubCURR_UV(17,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(15)<1>   wDIFF_TEMPORAL(15)<16;16,1>                             ubCURR_UV(17,2)<16;16,1>
+
+
+       //16x4 to 8x4 - Second 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>    uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>    uwDIFF_TEMPORAL_SUM4x4(2,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(2,2)<4;2,1>
+
+       //8x4 to 4x4 - Second 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4_FINAL(1)<1>      uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>     { AccWrEn }
+
+       //Find if block is motion block - Second 16 lines
+       cmp.g.f1.0  (16) null<1>:w                              uwDIFF_TEMPORAL_SUM4x4_FINAL(1)<16;16,1>                r61.26<0;2,1>:ub
+
+       //Move TEMPORAL_SUM4x4 for SIMD16 use later.
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,0)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,2)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,4)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,6)<0;2,1>      
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,8)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,10)<0;2,1>     
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,12)<0;2,1>             
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,14)<0;2,1>     
+
+       //Pick Appropriate Weight History Based on motion. - Second 16 lines
+       (-f1.0) mov (16) uwCURBE_TEMP(1)<1>             uwCURBE_TEMP(3)<16;16,1>
+
+       //Actual DN - Second 16 lines
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(16)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(16)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(22,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(22,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(22,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,0)<8;8,1>                                   uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,8)<8;8,1>                                   uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(16)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(16)<1>                  ubCURR_UV(22,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(16)<1>   wDIFF_TEMPORAL(16)<16;16,1>                     ubCURR_UV(22,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(17)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(17)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(23,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(23,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(23,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,16)<8;8,1>                          uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,24)<8;8,1>                          uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(17)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(17)<1>                  ubCURR_UV(23,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(17)<1>   wDIFF_TEMPORAL(17)<16;16,1>                     ubCURR_UV(23,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(18)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(18)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(24,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(24,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(24,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,32)<8;8,1>                          uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,40)<8;8,1>                          uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(18)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(18)<1>                  ubCURR_UV(24,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(18)<1>   wDIFF_TEMPORAL(18)<16;16,1>                     ubCURR_UV(24,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(19)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(19)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(25,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(25,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(25,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,48)<8;8,1>                          uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,56)<8;8,1>                          uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(19)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(19)<1>                  ubCURR_UV(25,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(19)<1>   wDIFF_TEMPORAL(19)<16;16,1>                     ubCURR_UV(25,2)<16;16,1>
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(20)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(20)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(26,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(26,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(26,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,64)<8;8,1>                                  uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,72)<8;8,1>                                  uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(20)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(20)<1>                  ubCURR_UV(26,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(20)<1>   wDIFF_TEMPORAL(20)<16;16,1>                     ubCURR_UV(26,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(21)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(21)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(27,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(27,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(27,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,80)<8;8,1>                          uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,88)<8;8,1>                          uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(21)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(21)<1>                  ubCURR_UV(27,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(21)<1>   wDIFF_TEMPORAL(21)<16;16,1>                     ubCURR_UV(27,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(22)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(22)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(28,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(28,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(28,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,96)<8;8,1>                          uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,104)<8;8,1>                         uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(22)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(22)<1>                  ubCURR_UV(28,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(22)<1>   wDIFF_TEMPORAL(22)<16;16,1>                     ubCURR_UV(28,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(23)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(23)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(29,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(29,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(29,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,112)<8;8,1>                         uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,120)<8;8,1>                         uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(23)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(23)<1>                  ubCURR_UV(29,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(23)<1>   wDIFF_TEMPORAL(23)<16;16,1>                     ubCURR_UV(29,2)<16;16,1>
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(24)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(24)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(30,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(30,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(30,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,128)<8;8,1>                                 uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,136)<8;8,1>                                 uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(24)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(24)<1>                  ubCURR_UV(30,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(24)<1>   wDIFF_TEMPORAL(24)<16;16,1>                     ubCURR_UV(30,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(25)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(25)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(31,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(31,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(31,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,144)<8;8,1>                         uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,152)<8;8,1>                         uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(25)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(25)<1>                  ubCURR_UV(31,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(25)<1>   wDIFF_TEMPORAL(25)<16;16,1>                     ubCURR_UV(31,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(26)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(26)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(32,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(32,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(32,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,160)<8;8,1>                         uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,168)<8;8,1>                         uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(26)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(26)<1>                  ubCURR_UV(32,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(26)<1>   wDIFF_TEMPORAL(26)<16;16,1>                     ubCURR_UV(32,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(27)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(27)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(33,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(33,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(33,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,176)<8;8,1>                         uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,184)<8;8,1>                         uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(27)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(27)<1>                  ubCURR_UV(33,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(27)<1>   wDIFF_TEMPORAL(27)<16;16,1>                     ubCURR_UV(33,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(28)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(28)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(34,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(34,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(34,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,192)<8;8,1>                                 uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,200)<8;8,1>                                 uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(28)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(28)<1>                  ubCURR_UV(34,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(28)<1>   wDIFF_TEMPORAL(28)<16;16,1>                             ubCURR_UV(34,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(4)<16;16,1>                            r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(4)<16;16,1>                            r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(35,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(35,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(35,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,208)<8;8,1>                         uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,216)<8;8,1>                         uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wCURBE_TEMP(4)<1>                              acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wCURBE_TEMP(4)<1>                              ubCURR_UV(35,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wCURBE_TEMP(4)<1>               wCURBE_TEMP(4)<16;16,1>                         ubCURR_UV(35,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(5)<16;16,1>                            r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(5)<16;16,1>                            r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(36,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(36,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(36,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,224)<8;8,1>                         uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,232)<8;8,1>                         uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wCURBE_TEMP(5)<1>                              acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wCURBE_TEMP(5)<1>                              ubCURR_UV(36,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wCURBE_TEMP(5)<1>               wCURBE_TEMP(5)<16;16,1>                         ubCURR_UV(36,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(6)<16;16,1>                            r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(6)<16;16,1>                            r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(37,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(37,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(37,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,240)<8;8,1>                         uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,248)<8;8,1>                         uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wCURBE_TEMP(6)<1>                              acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wCURBE_TEMP(6)<1>                              ubCURR_UV(37,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wCURBE_TEMP(6)<1>               wCURBE_TEMP(6)<16;16,1>                         ubCURR_UV(37,2)<16;16,1>
+
+       //Pack Weight History WORD -> BYTE
+       mov (16) ubCURBE_TEMP(3,0)<1>           ubCURBE_TEMP(0)<32;16,2>        
+       mov (16) ubCURBE_TEMP(3,16)<1>          ubCURBE_TEMP(1)<32;16,2>        
+
+
+
+//Module Name  : DN_UV_Compute_BNE_UV
+//Author               : Tatiya, Rupesh
+//Description  : Computes minimum SOAD for each 16x4 block.
+
+       cmp.l.f0.0  (8) null:w                                  uwSOAD_MIN_8x4(0,12)<16;4,1>    uwSOAD_MIN_8x4(2,12)<16;4,1>
+       (f0.0)sel       (8) uwCURBE_TEMP(1,0)<1>        uwSOAD_MIN_8x4(0,12)<16;4,1>    uwSOAD_MIN_8x4(2,12)<16;4,1>
+
+    mov  (8)   ubCURBE_TEMP(1)<1>                      ubCURBE_TEMP(1)<16;8,2>
+
+
+
+//Module Name  : DN_UV_YUY2_Pack_Denoised_UV
+//Name                 : Tatiya, Rupesh
+//Description  : Pack UV denoised data based on YUY2 input.
+
+
+
+//Module Name  : DN_UV_Pack_Denoised_UV
+//Name                 : Tatiya, Rupesh
+//Description  : Pack UV denoised data based on PL2/PL3/PA.
+
+
+       add  (1) a0.0<1>:uw     r54.21<0;1,0>:ub    2976:w              
+       add  (1) a0.1<1>:uw     r54.21<0;1,0>:ub    3264:w              
+       add  (1) a0.2<1>:uw     r54.21<0;1,0>:ub    3552:w              
+       add  (1) a0.3<1>:uw     r54.21<0;1,0>:ub    3840:w              
+
+//First 8 lines.
+       mov  (16)       r[a0.0, 0]<2>:ub                ubDIFF_TEMPORAL(0)<32;16,2>
+       mov  (16)       r[a0.0, 32]<2>:ub               ubDIFF_TEMPORAL(1)<32;16,2>
+       mov  (16)       r[a0.0, 64]<2>:ub               ubDIFF_TEMPORAL(2)<32;16,2>
+       mov  (16)       r[a0.0, 96]<2>:ub               ubDIFF_TEMPORAL(3)<32;16,2>
+       mov  (16)       r[a0.0, 128]<2>:ub              ubDIFF_TEMPORAL(4)<32;16,2>
+       mov  (16)       r[a0.0, 160]<2>:ub              ubDIFF_TEMPORAL(5)<32;16,2>
+       mov  (16)       r[a0.0, 192]<2>:ub              ubDIFF_TEMPORAL(6)<32;16,2>
+       mov  (16)       r[a0.0, 224]<2>:ub              ubDIFF_TEMPORAL(7)<32;16,2>
+
+//Second 8 lines
+       mov  (16)       r[a0.1, 0]<2>:ub                ubDIFF_TEMPORAL(8)<32;16,2>
+       mov  (16)       r[a0.1, 32]<2>:ub               ubDIFF_TEMPORAL(9)<32;16,2>
+       mov  (16)       r[a0.1, 64]<2>:ub               ubDIFF_TEMPORAL(10)<32;16,2>
+       mov  (16)       r[a0.1, 96]<2>:ub               ubDIFF_TEMPORAL(11)<32;16,2>
+       mov  (16)       r[a0.1, 128]<2>:ub              ubDIFF_TEMPORAL(12)<32;16,2>
+       mov  (16)       r[a0.1, 160]<2>:ub              ubDIFF_TEMPORAL(13)<32;16,2>
+       mov  (16)       r[a0.1, 192]<2>:ub              ubDIFF_TEMPORAL(14)<32;16,2>
+       mov  (16)       r[a0.1, 224]<2>:ub              ubDIFF_TEMPORAL(15)<32;16,2>
+
+//Third 8 lines
+       mov  (16)       r[a0.2, 0]<2>:ub                ubDIFF_TEMPORAL(16)<32;16,2>
+       mov  (16)       r[a0.2, 32]<2>:ub               ubDIFF_TEMPORAL(17)<32;16,2>
+       mov  (16)       r[a0.2, 64]<2>:ub               ubDIFF_TEMPORAL(18)<32;16,2>
+       mov  (16)       r[a0.2, 96]<2>:ub               ubDIFF_TEMPORAL(19)<32;16,2>
+       mov  (16)       r[a0.2, 128]<2>:ub              ubDIFF_TEMPORAL(20)<32;16,2>
+       mov  (16)       r[a0.2, 160]<2>:ub              ubDIFF_TEMPORAL(21)<32;16,2>
+       mov  (16)       r[a0.2, 192]<2>:ub              ubDIFF_TEMPORAL(22)<32;16,2>
+       mov  (16)       r[a0.2, 224]<2>:ub              ubDIFF_TEMPORAL(23)<32;16,2>
+
+//Fourth 8 lines
+//5 lines first
+       mov  (16)       r[a0.3, 0]<2>:ub                ubDIFF_TEMPORAL(24)<32;16,2>
+       mov  (16)       r[a0.3, 32]<2>:ub               ubDIFF_TEMPORAL(25)<32;16,2>
+       mov  (16)       r[a0.3, 64]<2>:ub               ubDIFF_TEMPORAL(26)<32;16,2>
+       mov  (16)       r[a0.3, 96]<2>:ub               ubDIFF_TEMPORAL(27)<32;16,2>
+       mov  (16)       r[a0.3, 128]<2>:ub              ubDIFF_TEMPORAL(28)<32;16,2>
+
+//3 more lines
+       mov  (16)       r[a0.3, 160]<2>:ub              ubCURBE_TEMP(4)<32;16,2>
+       mov  (16)       r[a0.3, 192]<2>:ub              ubCURBE_TEMP(5)<32;16,2>
+       mov  (16)       r[a0.3, 224]<2>:ub              ubCURBE_TEMP(6)<32;16,2>
+
+
+       //TODO - See if History saving can be combined with Curr Frame Save. - rT
+
+
+//Module Name  : DN_UV_Save_Hist_UV
+//Author               : Tatiya, Rupesh
+//Description  : Saves DN history for UV data.
+
+       mov (8)  r3.0<1>:ud     r0.0<8;8,1>:ud
+       mov (2)  r3.0<1>:d      r62.12<2;2,1>:w                         
+       mov (1)  r3.2<1>:d      0x30007:ud              
+
+       send (8) null<1>:d      r3              0x5             0x40A8021:ud
+
+
+
+//Module Name  : DN_UV_Save_BNE_UV
+//Author               : Tatiya, Rupesh
+//Description  : Saves BNE values for 16x16 U and 16x16 V.
+
+       mov (8)  r1.0<1>:ud     r0.0<8;8,1>:ud
+       mov (2)  r1.0<1>:d              r63.12<2;2,1>:w                                 
+       mov (1)  r1.2<1>:d              0x10003:ud              
+
+       send (8) null<1>:d      r1              0x5             0x40A8023:ud
+
+
+
+//Module Name  : DN_UV_YUY2_Save_Curr_Frame_YUV
+//Author               : Tatiya, Rupesh
+
+
+
+//Module Name  : DN_UV_Load_Curr_Frame_Y
+//Author               : Tatiya, Rupesh
+//Description  : Saves Y or YUY2 of Current frame.
+
+
+
+
+       mov (8)         acc0.0<1>:ud            r0.0<8;8,1>:ud
+       shl (1)         r62.10<1>:w             r62.10<0;1,0>:w         1:w
+       mov (1)         acc0.0<1>:d                     r62.10<0;1,0>:w
+       mov (1)         acc0.1<1>:d                     r62.11<0;1,0>:w
+
+       mov (1)         acc0.2<1>:d                     0x7001F:ud
+
+       mov (8)     r92.0<1>:ud acc0.0<8;8,1>:ud
+
+       mov (8)     r101.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r110.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r119.0<1>:ud        acc0.0<8;8,1>:ud
+
+       add (1)         r101.1<1>:d     acc0.1<0;1,0>:d                 8:d
+
+       add (1)         r110.0<1>:d     acc0.0<0;1,0>:d                 32:d
+
+       add (1)         r119.0<1>:d     acc0.0<0;1,0>:d                 32:d
+       add (1)         r119.1<1>:d     acc0.1<0;1,0>:d                  8:d
+
+       send (8)        null<1>:d       r92             0x5             0x120A8018:ud
+       send (8)        null<1>:d       r101            0x5             0x120A8018:ud
+       send (8)        null<1>:d       r110            0x5             0x120A8018:ud
+       send (8)        null<1>:d       r119            0x5             0x120A8018:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+       //All sub-routines here
+
+
+// Module Name  : Noise_Detection
+// Author              : Tatiya, Rupesh
+// Description : Performs noise detection on 32 pixels of U (8x4) and 32 pixels of V (8x4).
+
+DN_UV_NOISE_DETECTION_UV:
+
+// Find Field Block Median
+//
+// Purpose   : Find the median value of the nine pixels in the same field
+//             which are centered at current pixel.
+//
+//             Works on 9 pixels centered at the current pixel
+//                NOTE: pixels are within same field.
+//                      v4 - current pixel
+//
+//                  v2 v1 v0
+//                   *  *  *     <--- Different field - not used
+//                  v5 v4 v3
+//                   *  *  *     <--- Different field - not used
+//                  v8 v7 v6
+
+// Algorithm to find median modifies the data.
+// Copy the data needed to calculate median so the original source data stays intact.
+//
+
+//TODO - Change Interleaved implementation to separated one if - ,  does not work on predication. - rT
+
+//Delete Later - rT
+//mov (1) pCUR_UV:uw           52*32:uw
+
+// v0
+mov (16) ubMEDIAN_TEMP(0,0)<1>         r[a0.0,0]<16;16,1>              
+// v0
+mov (16) ubMEDIAN_TEMP(0,16)<1>        r[a0.0,32]<16;16,1>             
+// v1
+mov (16) ubMEDIAN_TEMP(1,0)<1>         r[a0.0,2]<16;16,1>              
+// v1
+mov (16) ubMEDIAN_TEMP(1,16)<1>        r[a0.0,34]<16;16,1>             
+// v2
+mov (16) ubMEDIAN_TEMP(2,0)<1>         r[a0.0,4]<16;16,1>              
+// v2
+mov (16) ubMEDIAN_TEMP(2,16)<1>        r[a0.0,36]<16;16,1>             
+// v3
+mov (16) ubMEDIAN_TEMP(3,0)<1>         r[a0.0,64]<16;16,1>     
+// v3
+mov (16) ubMEDIAN_TEMP(3,16)<1>        r[a0.0,96]<16;16,1>             
+// v4
+mov (16) ubMEDIAN_TEMP(4,0)<1>         r[a0.0,66]<16;16,1>     
+// v4
+mov (16) ubMEDIAN_TEMP(4,16)<1>        r[a0.0,98]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(5,0)<1>         r[a0.0,68]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(5,16)<1>        r[a0.0,100]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(6,0)<1>         r[a0.0,128]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(6,16)<1>        r[a0.0,160]<16;16,1>            
+// v7
+mov (16) ubMEDIAN_TEMP(7,0)<1>         r[a0.0,130]<16;16,1>    
+// v7
+mov (16) ubMEDIAN_TEMP(7,16)<1>        r[a0.0,162]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(8,0)<1>         r[a0.0,132]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(8,16)<1>        r[a0.0,164]<16;16,1>    
+
+//TODO - Optimize one instruction here.
+add (1)  a0.0:uw               a0.0<0;1,0>:uw 64:uw
+// v0
+mov (16) ubMEDIAN_TEMP(9,0)<1>         r[a0.0,0]<16;16,1>              
+// v0
+mov (16) ubMEDIAN_TEMP(9,16)<1>        r[a0.0,32]<16;16,1>             
+// v1
+mov (16) ubMEDIAN_TEMP(10,0)<1>        r[a0.0,2]<16;16,1>              
+// v1
+mov (16) ubMEDIAN_TEMP(10,16)<1>       r[a0.0,34]<16;16,1>             
+// v2
+mov (16) ubMEDIAN_TEMP(11,0)<1>        r[a0.0,4]<16;16,1>              
+// v2
+mov (16) ubMEDIAN_TEMP(11,16)<1>       r[a0.0,36]<16;16,1>             
+// v3
+mov (16) ubMEDIAN_TEMP(12,0)<1>        r[a0.0,64]<16;16,1>     
+// v3
+mov (16) ubMEDIAN_TEMP(12,16)<1>       r[a0.0,96]<16;16,1>             
+// v4
+mov (16) ubMEDIAN_TEMP(13,0)<1>                r[a0.0,66]<16;16,1>     
+// v4
+mov (16) ubMEDIAN_TEMP(13,16)<1>       r[a0.0,98]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(14,0)<1>                r[a0.0,68]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(14,16)<1>       r[a0.0,100]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(15,0)<1>        r[a0.0,128]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(15,16)<1>       r[a0.0,160]<16;16,1>            
+// v7
+mov (16) ubMEDIAN_TEMP(16,0)<1>                r[a0.0,130]<16;16,1>    
+// v7
+mov (16) ubMEDIAN_TEMP(16,16)<1>       r[a0.0,162]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(17,0)<1>                r[a0.0,132]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(17,16)<1>       r[a0.0,164]<16;16,1>    
+
+//TODO - Optimize one instruction here.
+add (1)  a0.0:uw               a0.0<0;1,0>:uw 64:uw
+
+// MedianSwap
+//
+//  MedianSwap(inOutLeft, inOutRight)
+//  {
+//      if (inOutLeft > inOutRight)
+//      {
+//          temp = inOutLeft
+//          inOutLeft = inOutRight
+//          inOutRight = temp
+//      }
+//  }
+
+// MedianSwap(v1, v2) - U
+// MedianSwap(v4, v5) - U
+// MedianSwap(v1, v2) - V
+// MedianSwap(v4, v5) - V
+
+cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(1,0)<32;16,2>  ubMEDIAN_TEMP(2,0)<32;16,2>
+cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>  ubMEDIAN_TEMP(5,0)<32;16,2>
+cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(1,1)<32;16,2>    ubMEDIAN_TEMP(2,1)<32;16,2>
+cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>    ubMEDIAN_TEMP(5,1)<32;16,2>
+
+               mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(1,0)<32;16,2>       
+               mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,0)<32;16,2>       
+               mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(1,1)<32;16,2>       
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>       
+
+(f0.0) mov (16) ubMEDIAN_TEMP(1,0)<2>          ubMEDIAN_TEMP(2,0)<32;16,2>             
+(f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>          ubMEDIAN_TEMP(5,0)<32;16,2>             
+(f1.0) mov (16) ubMEDIAN_TEMP(1,1)<2>                  ubMEDIAN_TEMP(2,1)<32;16,2>             
+(f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>          ubMEDIAN_TEMP(5,1)<32;16,2>             
+
+(f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubTEMP1(0,0)<16;16,1>                
+(f0.1) mov (16) ubMEDIAN_TEMP(5,0)<2>     ubTEMP1(0,16)<16;16,1>               
+(f1.0) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubTEMP1(1,0)<16;16,1>                
+(f1.1) mov (16) ubMEDIAN_TEMP(5,1)<2>     ubTEMP1(1,16)<16;16,1>       
+
+// MedianSwap(v7, v8) - U
+// MedianSwap(v0, v1) - U
+// MedianSwap(v7, v8) - V
+// MedianSwap(v0, v1) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(7,0)<32;16,2>           ubMEDIAN_TEMP(8,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(0,0)<32;16,2>   ubMEDIAN_TEMP(1,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(7,1)<32;16,2>   ubMEDIAN_TEMP(8,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(0,1)<32;16,2>   ubMEDIAN_TEMP(1,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(7,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(0,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(7,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(0,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(7,0)<2>   ubMEDIAN_TEMP(8,0)<32;16,2>      
+ (f0.1) mov (16) ubMEDIAN_TEMP(0,0)<2> ubMEDIAN_TEMP(1,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(7,1)<2>         ubMEDIAN_TEMP(8,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(0,1)<2> ubMEDIAN_TEMP(1,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(8,0)<2>     ubTEMP1(0,0)<16;16,1>          
+ (f0.1) mov (16) ubMEDIAN_TEMP(1,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(8,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(1,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v3, v4) - U
+ // MedianSwap(v6, v7) - U
+ // MedianSwap(v3, v4) - V
+ // MedianSwap(v6, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(3,0)<32;16,2>           ubMEDIAN_TEMP(4,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(6,0)<32;16,2>   ubMEDIAN_TEMP(7,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(3,1)<32;16,2>   ubMEDIAN_TEMP(4,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(6,1)<32;16,2>   ubMEDIAN_TEMP(7,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(3,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(6,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(3,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(6,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(3,0)<2>   ubMEDIAN_TEMP(4,0)<32;16,2>      
+ (f0.1) mov (16) ubMEDIAN_TEMP(6,0)<2> ubMEDIAN_TEMP(7,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(3,1)<2>         ubMEDIAN_TEMP(4,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(6,1)<2> ubMEDIAN_TEMP(7,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(7,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(4,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(7,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v1, v2) - U
+ // MedianSwap(v4, v5) - U
+ // MedianSwap(v1, v2) - V
+ // MedianSwap(v4, v5) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(1,0)<32;16,2>           ubMEDIAN_TEMP(2,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>   ubMEDIAN_TEMP(5,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(1,1)<32;16,2>   ubMEDIAN_TEMP(2,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(5,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(1,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(1,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(1,0)<2>   ubMEDIAN_TEMP(2,0)<32;16,2>           
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2> ubMEDIAN_TEMP(5,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(1,1)<2>         ubMEDIAN_TEMP(2,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2> ubMEDIAN_TEMP(5,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(5,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(5,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v7, v8) - U
+ // MedianSwap(v0, v3) - U
+ // MedianSwap(v7, v8) - V
+ // MedianSwap(v0, v3) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(7,0)<32;16,2>           ubMEDIAN_TEMP(8,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(0,0)<32;16,2>   ubMEDIAN_TEMP(3,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(7,1)<32;16,2>   ubMEDIAN_TEMP(8,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(0,1)<32;16,2>   ubMEDIAN_TEMP(3,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(7,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(0,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(7,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(0,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(7,0)<2>   ubMEDIAN_TEMP(8,0)<32;16,2>           
+ (f0.1) mov (16) ubMEDIAN_TEMP(0,0)<2> ubMEDIAN_TEMP(3,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(7,1)<2>         ubMEDIAN_TEMP(8,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(0,1)<2> ubMEDIAN_TEMP(3,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(8,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(3,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(8,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(3,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // NOTE:
+ // Compare v0 to v6 to find the minimum.
+ // Store the minimum for future use.
+ //TODO - Find if MIN is needed.
+ //cmp.l.f0.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,0)<32;16,2>  ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //cmp.l.f1.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,1)<32;16,2>  ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+ //(f0.0)  mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,0)<32;16,2>
+ //(f1.0)  mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,1)<32;16,2>
+ //(-f0.0) mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //(-f1.0) mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+
+ // MedianSwap(v5, v8) - U
+ // MedianSwap(v4, v7) - U
+ // MedianSwap(v5, v8) - V
+ // MedianSwap(v4, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(5,0)<32;16,2>           ubMEDIAN_TEMP(8,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>   ubMEDIAN_TEMP(7,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(5,1)<32;16,2>   ubMEDIAN_TEMP(8,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(7,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(5,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(5,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(5,0)<2>         ubMEDIAN_TEMP(8,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(7,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(5,1)<2>         ubMEDIAN_TEMP(8,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(7,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(8,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(7,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(8,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(7,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+// NOTE:
+// Compare v2 to v8 to find the maximum.
+// Store the maximum for future use.
+ //TODO - Find if MAX is needed.
+// cmp.g.f0.0  (16) null:w         ubMEDIAN_TEMP(%1+2,0)<32;16,2> ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+// cmp.g.f1.0  (16) null:w         ubMEDIAN_TEMP(%1+2,1)<32;16,2> ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+//(f0.0)  mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,0)<32;16,2>
+//(f1.0)  mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,1)<32;16,2>
+//(-f0.0) mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+//(-f1.0) mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+
+// MedianSwap(v3, v6) - U
+// MedianSwap(v1, v4) - U
+// MedianSwap(v3, v6) - V
+// MedianSwap(v1, v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(3,0)<32;16,2>           ubMEDIAN_TEMP(6,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(1,0)<32;16,2>   ubMEDIAN_TEMP(4,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(3,1)<32;16,2>   ubMEDIAN_TEMP(6,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(1,1)<32;16,2>   ubMEDIAN_TEMP(4,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(6,0)<2>     ubMEDIAN_TEMP(3,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>     ubMEDIAN_TEMP(1,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(6,1)<2>     ubMEDIAN_TEMP(3,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>     ubMEDIAN_TEMP(1,1)<32;16,2>      
+
+ // MedianSwap(v2,v5) - U
+ // MedianSwap(v4,v7) - U
+ // MedianSwap(v2,v5) - V
+ // MedianSwap(v4,v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(2,0)<32;16,2>           ubMEDIAN_TEMP(5,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>   ubMEDIAN_TEMP(7,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(2,1)<32;16,2>   ubMEDIAN_TEMP(5,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(7,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubMEDIAN_TEMP(5,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>     ubMEDIAN_TEMP(7,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubMEDIAN_TEMP(5,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>     ubMEDIAN_TEMP(7,1)<32;16,2>      
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>           ubMEDIAN_TEMP(2,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(2,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(4,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(2,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(2,1)<32;16,2>             
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubTEMP1(0,16)<16;16,1>      
+
+ // MedianSwap(v6,v4) - U
+ // MedianSwap(v6,v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(6,0)<32;16,2>   ubMEDIAN_TEMP(4,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(6,1)<32;16,2>   ubMEDIAN_TEMP(4,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(6,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(6,1)<32;16,2>             
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>           ubMEDIAN_TEMP(2,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(2,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(2,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(2,1)<32;16,2>             
+cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(10,0)<32;16,2>  ubMEDIAN_TEMP(11,0)<32;16,2>
+cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>  ubMEDIAN_TEMP(14,0)<32;16,2>
+cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(10,1)<32;16,2>   ubMEDIAN_TEMP(11,1)<32;16,2>
+cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>   ubMEDIAN_TEMP(14,1)<32;16,2>
+
+               mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(10,0)<32;16,2>      
+               mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,0)<32;16,2>      
+               mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(10,1)<32;16,2>      
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>      
+
+(f0.0) mov (16) ubMEDIAN_TEMP(10,0)<2>         ubMEDIAN_TEMP(11,0)<32;16,2>            
+(f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>         ubMEDIAN_TEMP(14,0)<32;16,2>            
+(f1.0) mov (16) ubMEDIAN_TEMP(10,1)<2>                 ubMEDIAN_TEMP(11,1)<32;16,2>            
+(f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>         ubMEDIAN_TEMP(14,1)<32;16,2>            
+
+(f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubTEMP1(0,0)<16;16,1>               
+(f0.1) mov (16) ubMEDIAN_TEMP(14,0)<2>     ubTEMP1(0,16)<16;16,1>              
+(f1.0) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubTEMP1(1,0)<16;16,1>               
+(f1.1) mov (16) ubMEDIAN_TEMP(14,1)<2>     ubTEMP1(1,16)<16;16,1>      
+
+// MedianSwap(v7, v8) - U
+// MedianSwap(v0, v1) - U
+// MedianSwap(v7, v8) - V
+// MedianSwap(v0, v1) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(16,0)<32;16,2>          ubMEDIAN_TEMP(17,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(9,0)<32;16,2>   ubMEDIAN_TEMP(10,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(16,1)<32;16,2>  ubMEDIAN_TEMP(17,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(9,1)<32;16,2>   ubMEDIAN_TEMP(10,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(16,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(9,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(16,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(9,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(16,0)<2>   ubMEDIAN_TEMP(17,0)<32;16,2>    
+ (f0.1) mov (16) ubMEDIAN_TEMP(9,0)<2> ubMEDIAN_TEMP(10,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(16,1)<2>        ubMEDIAN_TEMP(17,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(9,1)<2> ubMEDIAN_TEMP(10,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(17,0)<2>     ubTEMP1(0,0)<16;16,1>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(10,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(17,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(10,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v3, v4) - U
+ // MedianSwap(v6, v7) - U
+ // MedianSwap(v3, v4) - V
+ // MedianSwap(v6, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(12,0)<32;16,2>          ubMEDIAN_TEMP(13,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(15,0)<32;16,2>          ubMEDIAN_TEMP(16,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(12,1)<32;16,2>  ubMEDIAN_TEMP(13,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(15,1)<32;16,2>  ubMEDIAN_TEMP(16,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(12,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(15,0)<32;16,2>             
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(12,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(15,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(12,0)<2>   ubMEDIAN_TEMP(13,0)<32;16,2>    
+ (f0.1) mov (16) ubMEDIAN_TEMP(15,0)<2>        ubMEDIAN_TEMP(16,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(12,1)<2>        ubMEDIAN_TEMP(13,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(15,1)<2>        ubMEDIAN_TEMP(16,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(16,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(13,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(16,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v1, v2) - U
+ // MedianSwap(v4, v5) - U
+ // MedianSwap(v1, v2) - V
+ // MedianSwap(v4, v5) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(10,0)<32;16,2>          ubMEDIAN_TEMP(11,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(14,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(10,1)<32;16,2>  ubMEDIAN_TEMP(11,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>  ubMEDIAN_TEMP(14,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(10,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,0)<32;16,2>             
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(10,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(10,0)<2>   ubMEDIAN_TEMP(11,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(14,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(10,1)<2>        ubMEDIAN_TEMP(11,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>        ubMEDIAN_TEMP(14,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(14,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(14,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v7, v8) - U
+ // MedianSwap(v0, v3) - U
+ // MedianSwap(v7, v8) - V
+ // MedianSwap(v0, v3) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(16,0)<32;16,2>          ubMEDIAN_TEMP(17,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(9,0)<32;16,2>   ubMEDIAN_TEMP(12,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(16,1)<32;16,2>  ubMEDIAN_TEMP(17,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(9,1)<32;16,2>   ubMEDIAN_TEMP(12,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(16,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(9,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(16,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(9,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(16,0)<2>   ubMEDIAN_TEMP(17,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(9,0)<2> ubMEDIAN_TEMP(12,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(16,1)<2>        ubMEDIAN_TEMP(17,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(9,1)<2> ubMEDIAN_TEMP(12,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(17,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(12,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(17,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(12,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // NOTE:
+ // Compare v0 to v6 to find the minimum.
+ // Store the minimum for future use.
+ //TODO - Find if MIN is needed.
+ //cmp.l.f0.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,0)<32;16,2>  ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //cmp.l.f1.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,1)<32;16,2>  ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+ //(f0.0)  mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,0)<32;16,2>
+ //(f1.0)  mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,1)<32;16,2>
+ //(-f0.0) mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //(-f1.0) mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+
+ // MedianSwap(v5, v8) - U
+ // MedianSwap(v4, v7) - U
+ // MedianSwap(v5, v8) - V
+ // MedianSwap(v4, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(14,0)<32;16,2>          ubMEDIAN_TEMP(17,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(16,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(14,1)<32;16,2>  ubMEDIAN_TEMP(17,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>  ubMEDIAN_TEMP(16,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(14,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,0)<32;16,2>             
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(14,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(14,0)<2>        ubMEDIAN_TEMP(17,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>                ubMEDIAN_TEMP(16,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(14,1)<2>        ubMEDIAN_TEMP(17,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(16,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(17,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(16,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(17,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(16,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+// NOTE:
+// Compare v2 to v8 to find the maximum.
+// Store the maximum for future use.
+ //TODO - Find if MAX is needed.
+// cmp.g.f0.0  (16) null:w         ubMEDIAN_TEMP(%1+2,0)<32;16,2> ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+// cmp.g.f1.0  (16) null:w         ubMEDIAN_TEMP(%1+2,1)<32;16,2> ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+//(f0.0)  mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,0)<32;16,2>
+//(f1.0)  mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,1)<32;16,2>
+//(-f0.0) mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+//(-f1.0) mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+
+// MedianSwap(v3, v6) - U
+// MedianSwap(v1, v4) - U
+// MedianSwap(v3, v6) - V
+// MedianSwap(v1, v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(12,0)<32;16,2>          ubMEDIAN_TEMP(15,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(10,0)<32;16,2>          ubMEDIAN_TEMP(13,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(12,1)<32;16,2>  ubMEDIAN_TEMP(15,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(10,1)<32;16,2>  ubMEDIAN_TEMP(13,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(15,0)<2>     ubMEDIAN_TEMP(12,0)<32;16,2>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>     ubMEDIAN_TEMP(10,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(15,1)<2>     ubMEDIAN_TEMP(12,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>     ubMEDIAN_TEMP(10,1)<32;16,2>      
+
+ // MedianSwap(v2,v5) - U
+ // MedianSwap(v4,v7) - U
+ // MedianSwap(v2,v5) - V
+ // MedianSwap(v4,v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(11,0)<32;16,2>          ubMEDIAN_TEMP(14,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(16,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(11,1)<32;16,2>  ubMEDIAN_TEMP(14,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>  ubMEDIAN_TEMP(16,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubMEDIAN_TEMP(14,0)<32;16,2>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>     ubMEDIAN_TEMP(16,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubMEDIAN_TEMP(14,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>     ubMEDIAN_TEMP(16,1)<32;16,2>      
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(11,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>          ubMEDIAN_TEMP(11,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(13,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>             
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(11,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(11,1)<32;16,2>            
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubTEMP1(0,16)<16;16,1>     
+
+ // MedianSwap(v6,v4) - U
+ // MedianSwap(v6,v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(15,0)<32;16,2>   ubMEDIAN_TEMP(13,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(15,1)<32;16,2>   ubMEDIAN_TEMP(13,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(15,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(15,1)<32;16,2>            
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(11,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>          ubMEDIAN_TEMP(11,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(11,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(11,1)<32;16,2>            
+
+// Sobel Value calculation for the current pixel v4
+//          v2 v1 v0
+//           *  *  *     <--- Different field - not used
+//          v5 v4 v3
+//           *  *  *     <--- Different field - not used
+//          v8 v7 v6
+//
+//    Gx = -v0 - 2*v3 - v6 + v2 + 2*v5 + v8
+//    Gy =  v0 + 2*v1 + v2 - v6 - 2*v7 - v8
+//
+//  Sobel = (|Gx| + |Gy|) >> 3
+
+//TODO - Change Later - rT
+add (1) a0.0:uw  a0.0<0;1,0>:uw -128:uw
+
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,64]<16;16,1>:ub                  -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,132]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,0]<16;16,1>:ub           -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,128]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,4]<16;16,1>:ub                   1:w
+// + 2 * v5
+mac (16) wSOBEL_X(0)<1>        r[a0.0,68]<16;16,1>:ub                  2:w
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,96]<16;16,1>:ub                  -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,164]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,32]<16;16,1>:ub                  -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,160]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,36]<16;16,1>:ub                  1:w
+// + 2 * v5
+mac (16) wSOBEL_X(1)<1>        r[a0.0,100]<16;16,1>:ub                 2:w
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,128]<16;16,1>:ub                 -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,196]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,64]<16;16,1>:ub                  -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,192]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,68]<16;16,1>:ub                  1:w
+// + 2 * v5
+mac (16) wSOBEL_X(2)<1>        r[a0.0,132]<16;16,1>:ub                 2:w
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,160]<16;16,1>:ub                 -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,228]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,96]<16;16,1>:ub                  -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,224]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,100]<16;16,1>:ub                 1:w
+// + 2 * v5
+mac (16) wSOBEL_X(3)<1>        r[a0.0,164]<16;16,1>:ub                 2:w
+
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,2]<16;16,1>:ub    2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,0]<16;16,1>:ub    1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,132]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,4]<16;16,1>:ub    1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,128]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,130]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(0)<16;16,1>
+
+shr (16) uwSOBEL(0)<1> acc0.0<16;16,1>:uw   3:uw
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,34]<16;16,1>:ub           2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,32]<16;16,1>:ub           1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,164]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,36]<16;16,1>:ub           1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,160]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,162]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(1)<16;16,1>
+
+shr (16) uwSOBEL(1)<1> acc0.0<16;16,1>:uw   3:uw
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,66]<16;16,1>:ub           2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,64]<16;16,1>:ub           1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,196]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,68]<16;16,1>:ub           1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,192]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,194]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(2)<16;16,1>
+
+shr (16) uwSOBEL(2)<1> acc0.0<16;16,1>:uw   3:uw
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,98]<16;16,1>:ub           2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,96]<16;16,1>:ub           1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,228]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,100]<16;16,1>:ub          1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,224]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,226]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(3)<16;16,1>
+
+shr (16) uwSOBEL(3)<1> acc0.0<16;16,1>:uw   3:uw
+
+//Mov Median in CURBE_TEMP to free up temp space.
+mov (16)       ubMEDIAN(0,0)<1>        ubMEDIAN_TEMP(4,0)<16;16,1>             
+mov (16)       ubMEDIAN(0,16)<1> ubMEDIAN_TEMP(4,16)<16;16,1>          
+mov (16)       ubMEDIAN(0,32)<1>       ubMEDIAN_TEMP(13,0)<16;16,1>            
+mov (16)       ubMEDIAN(0,48)<1> ubMEDIAN_TEMP(13,16)<16;16,1>         
+
+// Find:
+//      absDiff = abs(ubCurY - ubMedian)
+// Find the difference between pixel and median value.
+
+//Median is interleaved. So difference is also interleaved.
+
+//------------------------------------------------------------------------------------------
+//Process 16 U and 16 V pixels here and rest later.
+// first row - v0,v1,v2
+add (16) wDIFF(0)<1>   r[a0.0,0]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(1)<1>   r[a0.0,2]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(2)<1>   r[a0.0,4]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+
+// second row - v3,v4,v5
+add (16) wDIFF(3)<1>   r[a0.0,64]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(4)<1>   r[a0.0,66]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(5)<1>   r[a0.0,68]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+
+// third row - v6,v7,v8
+add (16) wDIFF(6)<1>   r[a0.0,128]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(7)<1>   r[a0.0,130]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(8)<1>   r[a0.0,132]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+// first row - v0,v1,v2
+add (16) wDIFF(9)<1>   r[a0.0,32]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(10)<1>   r[a0.0,34]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(11)<1>   r[a0.0,36]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+
+// second row - v3,v4,v5
+add (16) wDIFF(12)<1>   r[a0.0,96]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(13)<1>   r[a0.0,98]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(14)<1>   r[a0.0,100]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+
+// third row - v6,v7,v8
+add (16) wDIFF(15)<1>   r[a0.0,160]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(16)<1>   r[a0.0,162]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(17)<1>   r[a0.0,164]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+
+//TODO - Change Later - rT
+add (1) a0.0:uw  a0.0<0;1,0>:uw 64:uw
+
+// Find sum of all absolute differences AND
+// maximum absolute difference for 16 U and 16 V here.
+//First 2 rows of 8x4
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(0)<16;16,1>  (abs)wDIFF(1)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(2)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(3)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(4)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(5)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(6)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(7)<16;16,1>
+       add        (16) uwSOAD(0)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(8)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//------------
+       //DIFF(0-7) is not needed here. Populate it.
+       // first row - v0,v1,v2
+       add (16) wDIFF(0)<1>   r[a0.0,0]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(1)<1>   r[a0.0,2]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(2)<1>   r[a0.0,4]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+
+       // second row - v3,v4,v5
+       add (16) wDIFF(3)<1>   r[a0.0,64]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(4)<1>   r[a0.0,66]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(5)<1>   r[a0.0,68]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+
+       // third row - v6,v7
+       add (16) wDIFF(6)<1>   r[a0.0,128]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(7)<1>   r[a0.0,130]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+//------------
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(0)<1> uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+
+//------------
+       //Load v8 - DIFF(8)
+       add (16) wDIFF(8)<1>                    r[a0.0,132]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+//------------
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(9)<16;16,1>  (abs)wDIFF(10)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(11)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(12)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(13)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(14)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(15)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(16)<16;16,1>
+       add        (16) uwSOAD(1)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(17)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//------------
+       //DIFF(0-7) is not needed here. Populate it.
+       // first row - v0,v1,v2
+       add (16) wDIFF(9)<1>   r[a0.0,32]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(10)<1>   r[a0.0,34]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(11)<1>   r[a0.0,36]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+
+       // second row - v3,v4,v5
+       add (16) wDIFF(12)<1>   r[a0.0,96]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(13)<1>   r[a0.0,98]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(14)<1>   r[a0.0,100]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+
+       // third row - v6,v7
+       add (16) wDIFF(15)<1>   r[a0.0,160]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(16)<1>   r[a0.0,162]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+//------------
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(1)<1> uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+
+//------------
+       //Load v8 - DIFF(8)
+       add (16) wDIFF(17)<1>                           r[a0.0,164]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+//------------
+
+//if ((sobel_edge_measure < m_SobelEdgeThreshold) && ((block_max-block_min) < m_LocalDiffThreshold))
+//                                             if (sigma_mb_min > sigma)
+//                                                     sigma_mb_min = sigma;
+
+//NOTE: block_min is always zero as median is one of the value in 3x3 block. So no need o calculate it.
+//             So just do -
+//if ((sobel_edge_measure < m_SobelEdgeThreshold) && ((block_max) < m_LocalDiffThreshold) && ( sigma < sigma_mb_min))
+//                                                     sigma_mb_min = sigma;
+
+//We are processing 32 bytes of U and 32 bytes of V - each of size 8x4.
+//Compare first 8 bytes with max possible (255).
+//Start above condition from second 8 bytes.
+
+//TODO - Change Later - rT
+//     mov (1) pCUR_MIN_SOAD_8x4:uw    1752:uw         //r54.24:ub
+
+//First row of 8x4
+        cmp.l.f0.0     (16) null:uw                    uwSOBEL(0)<16;16,1>         r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(0)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(0)<16;16,1>                      255:uw
+(f0.0)  sel            (16) uwSOBEL(0)<1>   uwSOAD(0)<16;16,1>                 255:uw
+
+//Second row of 8x4
+               cmp.l.f0.0      (16) null:uw                    uwSOBEL(1)<16;16,1>         r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(1)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(1)<16;16,1>                      uwSOBEL(0)<16;16,1>
+(f0.0)  mov            (16) uwSOBEL(0)<1>   uwSOAD(1)<16;16,1>
+
+// Find sum of all absolute differences AND
+// maximum absolute difference for 16 U and 16 V here.
+//Second 2 rows of 8x4
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(0)<16;16,1>  (abs)wDIFF(1)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(2)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(3)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(4)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(5)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(6)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(7)<16;16,1>
+       add        (16) uwSOAD(0)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(8)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(0)<1>   uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(9)<16;16,1>  (abs)wDIFF(10)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(11)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(12)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(13)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(14)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(15)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(16)<16;16,1>
+       add        (16) uwSOAD(1)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(17)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(1)<1>   uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+
+//Third row of 8x4
+        cmp.l.f0.0     (16) null:uw                    uwSOBEL(2)<16;16,1>             r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(0)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(0)<16;16,1>                      uwSOBEL(0)<16;16,1>
+(f0.0)  mov            (16) uwSOBEL(0)<1>   uwSOAD(0)<16;16,1>
+
+//Fourth row of 8x4
+               cmp.l.f0.0      (16) null:uw                    uwSOBEL(3)<16;16,1>             r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(1)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(1)<16;16,1>                      uwSOBEL(0)<16;16,1>
+(f0.0)  mov            (16) uwSOBEL(0)<1>   uwSOAD(1)<16;16,1>
+
+               cmp.l.f0.0      (8) null:uw                     uwSOBEL(0,0)<8;8,1>     uwSOBEL(0,8)<8;8,1>
+(f0.0)  sel            (8) uwSOBEL(0)<1>       uwSOBEL(0,0)<8;8,1>     uwSOBEL(0,8)<8;8,1>
+
+               cmp.l.f0.0      (4) null:uw                     uwSOBEL(0,0)<4;4,1>     uwSOBEL(0,4)<4;4,1>
+(f0.0)  sel            (4) uwSOBEL(0)<1>       uwSOBEL(0,0)<4;4,1>     uwSOBEL(0,4)<4;4,1>
+
+               cmp.l.f0.0      (2) null:uw                                             uwSOBEL(0,0)<2;2,1>  uwSOBEL(0,2)<2;2,1>
+(f0.0)  sel            (2) r[a0.1,0]<1>:uw     uwSOBEL(0,0)<2;2,1>  uwSOBEL(0,2)<2;2,1>
+
+
+
+
+
+
+// End of common.inc
+
+mov (1) ip:ud r7.7<0;1,0>:d
+
+
+.end_code
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PA_DN_422CP.g4a b/src/shaders/post_processing/gen7/PA_DN_422CP.g4a
new file mode 100644 (file)
index 0000000..37f0ff0
--- /dev/null
@@ -0,0 +1,491 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//  114    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PA_DN_422CP
+.code
+
+
+
+// FileName:   DN_PA_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block) for Packed format
+
+
+
+// FileName:   DN.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x49E8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(4,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+
+       mov (2)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(4,0)<2;2,1>         // Move denoise history to MRF (4x2)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x10003:ud                                                                      { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x50003:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE |   X  |   X   |  X  |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       //|            X             |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       mov (1)         mubMSGHDR_ENC_STATS(1,0)<1>             ubDNDI_RESP(4,8)<0;1,0>                 { NoDDClr }                             // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,3)<1>             uwDNDI_RESP(4,11)<0;1,0>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,4)<1>             uwDNDI_RESP(4,12)<2;2,1>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,9)<1>             uwDNDI_RESP(4,8)<0;1,0>                 { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,10)<1>    uwDNDI_RESP(4,9)<2;2,1>                 { NoDDChk }                             // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Save_PA.asm
+// Author:             Vivek Kumar
+// Description:        Save one 16x8 blocks of DN output in Packed format
+
+
+add (4)                a0.4<1>:uw   r2.28<4;4,1>:ub   1024:w    // Initial Y,U,V offset in YUV422 block; it starts at m14
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                                    // message header
+shl (1)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<0;1,0>:w     1:w           { NoDDClr }     // X origin * 2 (422 output)
+mov (1)     mdMSGHDR_DN_OUT(0,1)<1>            r7.1<0;1,0>:w                   { NoDDClr, NoDDChk }  // Y origin
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x7001F:ud      { NoDDChk }     // block width and height (32x8)
+
+       mov (16)    r[a0.4,0]<2>:ub   ubDNDI_RESP(0,0)<16;16,1>         { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,32]<2>:ub   ubDNDI_RESP(0,16)<16;16,1>       { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,64]<2>:ub   ubDNDI_RESP(0,32)<16;16,1>       { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,96]<2>:ub   ubDNDI_RESP(0,48)<16;16,1>       { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,128]<2>:ub   ubDNDI_RESP(0,64)<16;16,1>      { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,160]<2>:ub   ubDNDI_RESP(0,80)<16;16,1>      { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,192]<2>:ub   ubDNDI_RESP(0,96)<16;16,1>      { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,224]<2>:ub   ubDNDI_RESP(0,112)<16;16,1>     { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)     r[a0.5,0]<4>:ub   ubDNDI_RESP(5,1)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,0]<4>:ub   ubDNDI_RESP(5,0)<16;8,2>    { NoDDChk }   // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,32]<4>:ub   ubDNDI_RESP(5,17)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,32]<4>:ub   ubDNDI_RESP(5,16)<16;8,2>    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,64]<4>:ub   ubDNDI_RESP(5,33)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,64]<4>:ub   ubDNDI_RESP(5,32)<16;8,2>    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,96]<4>:ub   ubDNDI_RESP(5,49)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,96]<4>:ub   ubDNDI_RESP(5,48)<16;8,2>    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,128]<4>:ub   ubDNDI_RESP(5,65)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,128]<4>:ub   ubDNDI_RESP(5,64)<16;8,2>    { NoDDChk }        // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,160]<4>:ub   ubDNDI_RESP(5,81)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,160]<4>:ub   ubDNDI_RESP(5,80)<16;8,2>    { NoDDChk }        // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,192]<4>:ub   ubDNDI_RESP(5,97)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,192]<4>:ub   ubDNDI_RESP(5,96)<16;8,2>    { NoDDChk }        // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,224]<4>:ub   ubDNDI_RESP(5,113)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,224]<4>:ub   ubDNDI_RESP(5,112)<16;8,2>    { NoDDChk }       // copy line of V directly to memory as optimization
+
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0x120A8018:ud
+
+
+
+// FileName:   DN_Save_422CP_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Save one 16x8 blocks of DN output to the color pipe in 4-2-2 format
+
+
+.declare mubMSGHDR_DN_OUT_2   Base=r36.0      ElementSize=1  Type=ub
+
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                    // message header
+shl (1)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<0;1,0>:w     1:w           { NoDDClr }            // X origin * 2 (422 output)
+mov (1)     mdMSGHDR_DN_OUT(0,1)<1>            r7.1<0;1,0>:w                   { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x7000F:ud      { NoDDClr, NoDDChk }            // block width and height (16x8)
+
+//M0.3 - 0 - CP Enable, 1 - Area of Interest, 3:2 Message Format(TBD), 4:3 - Ignored, 31:5 CP state pointer
+//Compose area-of-interest bit + color pipe state pointer
+or (1)         mudMSGHDR_DN_OUT(0,3)<1>                r2.4<0;1,0>:ud  r7.26<0;1,0>:b          { NoDDChk }
+
+// First 8 x 8 Block
+       mov (8)         mubMSGHDR_DN_OUT(1)<2>                  ubDNDI_RESP(0,0)<8;8,1>                         { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(1,16)<2>               ubDNDI_RESP(0,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(2)<2>                  ubDNDI_RESP(0,32)<8;8,1>                                { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(2,16)<2>               ubDNDI_RESP(0,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(3)<2>                  ubDNDI_RESP(0,64)<8;8,1>                                { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(3,16)<2>               ubDNDI_RESP(0,80)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(4)<2>                  ubDNDI_RESP(0,96)<8;8,1>                                { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(4,16)<2>               ubDNDI_RESP(0,112)<8;8,1>                       { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(1,1)<4>    ubDNDI_RESP(5,1)<8;4,2>                 { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(1,17)<4>           ubDNDI_RESP(5,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(1,3)<4>    ubDNDI_RESP(5,0)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(1,19)<4>           ubDNDI_RESP(5,16)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(2,1)<4>    ubDNDI_RESP(5,33)<8;4,2>                        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(2,17)<4>           ubDNDI_RESP(5,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(2,3)<4>    ubDNDI_RESP(5,32)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(2,19)<4>           ubDNDI_RESP(5,48)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(3,1)<4>    ubDNDI_RESP(5,65)<8;4,2>                        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(3,17)<4>           ubDNDI_RESP(5,81)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(3,3)<4>    ubDNDI_RESP(5,64)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(3,19)<4>           ubDNDI_RESP(5,80)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(4,1)<4>    ubDNDI_RESP(5,97)<8;4,2>                        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(4,17)<4>           ubDNDI_RESP(5,113)<8;4,2>               { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(4,3)<4>    ubDNDI_RESP(5,96)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(4,19)<4>           ubDNDI_RESP(5,112)<8;4,2>                       { NoDDChk }     // copy line of V directly to memory as optimization
+
+// Second 8 x 8 Block
+mov    (8)     r36.0<1>:ud             r31.0<8;8,1>:ud
+add    (1)     r36.0<1>:ud             r36.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DN_OUT_2(1)<2>                ubDNDI_RESP(0,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(1,16)<2>     ubDNDI_RESP(0,24)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(2)<2>                ubDNDI_RESP(0,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(2,16)<2>     ubDNDI_RESP(0,56)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(3)<2>                ubDNDI_RESP(0,72)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(3,16)<2>     ubDNDI_RESP(0,88)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(4)<2>                ubDNDI_RESP(0,104)<8;8,1>                       { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(4,16)<2>     ubDNDI_RESP(0,120)<8;8,1>                       { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(1,1)<4>          ubDNDI_RESP(5,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(1,17)<4>         ubDNDI_RESP(5,25)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(1,3)<4>          ubDNDI_RESP(5,8)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(1,19)<4>         ubDNDI_RESP(5,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(2,1)<4>          ubDNDI_RESP(5,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(2,17)<4>         ubDNDI_RESP(5,57)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(2,3)<4>          ubDNDI_RESP(5,40)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(2,19)<4>         ubDNDI_RESP(5,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(3,1)<4>          ubDNDI_RESP(5,73)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(3,17)<4>         ubDNDI_RESP(5,89)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(3,3)<4>          ubDNDI_RESP(5,72)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(3,19)<4>         ubDNDI_RESP(5,88)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(4,1)<4>          ubDNDI_RESP(5,105)<8;4,2>               { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(4,17)<4>         ubDNDI_RESP(5,121)<8;4,2>               { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(4,3)<4>          ubDNDI_RESP(5,104)<8;4,2>                       { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(4,19)<4>         ubDNDI_RESP(5,120)<8;4,2>               { NoDDChk }     // copy line of V directly to memory as optimization
+
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0xA0A801B:ud
+send (8)    null<1>:d    r36.0 0x5    0xA0A801B:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PA_DN_PA.g4a b/src/shaders/post_processing/gen7/PA_DN_PA.g4a
new file mode 100644 (file)
index 0000000..5469949
--- /dev/null
@@ -0,0 +1,403 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   57    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PA_DN_PA
+.code
+
+
+
+// FileName:   DN_PA_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block) for Packed format
+
+
+
+// FileName:   DN.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x49E8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(4,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+
+       mov (2)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(4,0)<2;2,1>         // Move denoise history to MRF (4x2)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x10003:ud                                                                      { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x50003:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE |   X  |   X   |  X  |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       //|            X             |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       mov (1)         mubMSGHDR_ENC_STATS(1,0)<1>             ubDNDI_RESP(4,8)<0;1,0>                 { NoDDClr }                             // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,3)<1>             uwDNDI_RESP(4,11)<0;1,0>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,4)<1>             uwDNDI_RESP(4,12)<2;2,1>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,9)<1>             uwDNDI_RESP(4,8)<0;1,0>                 { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,10)<1>    uwDNDI_RESP(4,9)<2;2,1>                 { NoDDChk }                             // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Save_PA.asm
+// Author:             Vivek Kumar
+// Description:        Save one 16x8 blocks of DN output in Packed format
+
+
+add (4)                a0.4<1>:uw   r2.28<4;4,1>:ub   1024:w    // Initial Y,U,V offset in YUV422 block; it starts at m14
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                                    // message header
+shl (1)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<0;1,0>:w     1:w           { NoDDClr }     // X origin * 2 (422 output)
+mov (1)     mdMSGHDR_DN_OUT(0,1)<1>            r7.1<0;1,0>:w                   { NoDDClr, NoDDChk }  // Y origin
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x7001F:ud      { NoDDChk }     // block width and height (32x8)
+
+       mov (16)    r[a0.4,0]<2>:ub   ubDNDI_RESP(0,0)<16;16,1>         { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,32]<2>:ub   ubDNDI_RESP(0,16)<16;16,1>       { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,64]<2>:ub   ubDNDI_RESP(0,32)<16;16,1>       { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,96]<2>:ub   ubDNDI_RESP(0,48)<16;16,1>       { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,128]<2>:ub   ubDNDI_RESP(0,64)<16;16,1>      { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,160]<2>:ub   ubDNDI_RESP(0,80)<16;16,1>      { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,192]<2>:ub   ubDNDI_RESP(0,96)<16;16,1>      { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (16)    r[a0.4,224]<2>:ub   ubDNDI_RESP(0,112)<16;16,1>     { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)     r[a0.5,0]<4>:ub   ubDNDI_RESP(5,1)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,0]<4>:ub   ubDNDI_RESP(5,0)<16;8,2>    { NoDDChk }   // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,32]<4>:ub   ubDNDI_RESP(5,17)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,32]<4>:ub   ubDNDI_RESP(5,16)<16;8,2>    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,64]<4>:ub   ubDNDI_RESP(5,33)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,64]<4>:ub   ubDNDI_RESP(5,32)<16;8,2>    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,96]<4>:ub   ubDNDI_RESP(5,49)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,96]<4>:ub   ubDNDI_RESP(5,48)<16;8,2>    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,128]<4>:ub   ubDNDI_RESP(5,65)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,128]<4>:ub   ubDNDI_RESP(5,64)<16;8,2>    { NoDDChk }        // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,160]<4>:ub   ubDNDI_RESP(5,81)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,160]<4>:ub   ubDNDI_RESP(5,80)<16;8,2>    { NoDDChk }        // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,192]<4>:ub   ubDNDI_RESP(5,97)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,192]<4>:ub   ubDNDI_RESP(5,96)<16;8,2>    { NoDDChk }        // copy line of V directly to memory as optimization
+       mov (8)     r[a0.5,224]<4>:ub   ubDNDI_RESP(5,113)<16;8,2>  { NoDDClr, NoDDChk }  // copy line of U directly to memory as optimization
+       mov (8)     r[a0.6,224]<4>:ub   ubDNDI_RESP(5,112)<16;8,2>    { NoDDChk }       // copy line of V directly to memory as optimization
+
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0x120A8018:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
index 7cc6d6e..3a6a818 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   12    // Total instruction count
 //    1    // Total kernel count
 
index 7aea0cf..5063d0b 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   10    // Total instruction count
 //    1    // Total kernel count
 
index 6b79341..f31f349 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   10    // Total instruction count
 //    1    // Total kernel count
 
index 628ded1..17de127 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   10    // Total instruction count
 //    1    // Total kernel count
 
index fec110b..ea8e6fa 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   15    // Total instruction count
 //    1    // Total kernel count
 
index d15881a..f21281d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   13    // Total instruction count
 //    1    // Total kernel count
 
index aacad6c..0622dc5 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   13    // Total instruction count
 //    1    // Total kernel count
 
index bc68ad5..082adab 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   13    // Total instruction count
 //    1    // Total kernel count
 
diff --git a/src/shaders/post_processing/gen7/PL3_DNDI_422CP.g4a b/src/shaders/post_processing/gen7/PL3_DNDI_422CP.g4a
new file mode 100644 (file)
index 0000000..16a0fc9
--- /dev/null
@@ -0,0 +1,562 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//  120    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PL3_DNDI_422CP
+.code
+
+
+
+// FileName:   DNDI_PL_Core.asm
+// Author:             Tatiya, Rupesh
+
+
+
+// FileName:   DNDI_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN+DI case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4BE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+       mov (1)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(9,0)<0;1,0>         // Move denoise history to MRF (4x1)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x3:ud                                                                  { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Load_UV_IMC3_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x4 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Load_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x4 block through DATAPORT 
+
+
+       add (2)         r27.0<1>:d                      r7.0<2;2,1>:w                           r4.4<2;2,1>:w                           // Source Y Block origin
+       asr (2)         r27.0<1>:d              r27.0<2;2,1>:d          1:w                                             { NoDDClr }             // U/V block origin should be half of Y's
+       mov (1)         r27.2<1>:ud                     0x10007:ud                                              { NoDDChk }             // U/V block width and height (8x2)
+    mov (8)     r36<1>:ud      r27.0<8;8,1>:ud
+    mov (8)     r38<1>:ud     r27.0<8;8,1>:ud
+       send (8)        udDNDI_UV_RESP(0)<1>    r36     0x4     0x2190001:ud
+       send (8)        udDNDI_UV_RESP(1)<1>    r38     0x4     0x2190002:ud
+
+
+
+// FileName:   DN_Save_Y_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save one 16x4 blocks of Y channel of DN output for reference
+
+
+ // check top/bottom field first
+cmp.e.f0.0 (1)  null<1>:w               r1.28<0;1,0>:ub     1:w
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                                            // message header   
+mov (2)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<2;2,1>:w                           { NoDDClr }             // X origin * 2 (422 output)
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x3000F:ud              { NoDDChk }             // block width and height (32x8)
+
+(f0.0) jmpi (1) TOP_FIELD_FIRST
+
+BOTTOM_FIELD_FIRST:
+
+       mov (4)     mudMSGHDR_DN_OUT(1,0)<1>    udDNDI_RESP(10,0)<4;4,1>        { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(1,4)<1>    udDNDI_RESP(4,4)<4;4,1>                 { NoDDChk }             // 1st field luma from current frame (line 1,3)
+       mov (4)     mudMSGHDR_DN_OUT(2,0)<1>    udDNDI_RESP(10,4)<4;4,1>        { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(2,4)<1>   udDNDI_RESP(5,4)<4;4,1>          { NoDDChk }             // 1st field luma from current frame (line 1,3)    
+
+       jmpi (1) SAVE_DN_CURR
+
+TOP_FIELD_FIRST:
+       mov (4)     mudMSGHDR_DN_OUT(1,0)<1>    udDNDI_RESP(4,0)<4;4,1>                 { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(1,4)<1>    udDNDI_RESP(10,0)<4;4,1>        { NoDDChk }             // 1st field luma from current frame (line 1,3)
+       mov (4)     mudMSGHDR_DN_OUT(2,0)<1>    udDNDI_RESP(5,0)<4;4,1>                 { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(2,4)<1>   udDNDI_RESP(10,4)<4;4,1>         { NoDDChk }             // 1st field luma from current frame (line 1,3)
+
+SAVE_DN_CURR:
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0x60A8018:ud     
+
+
+
+// FileName:    DI_Save_422CP_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in 422 format to Color Pipe (IECP)
+
+
+.declare mubMSGHDR_DI_OUT1_1  Base=r18.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT1_2  Base=r21.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_1  Base=r24.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_2  Base=r27.0      ElementSize=1  Type=ub
+
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:ud     r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:ud     r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3000F:ud        { NoDDClr, NoDDChk }       // Block width and height (16x8)
+
+//M0.3  - 0 - CP Enable, 1 - Area of Interest, 3:2 Message Format(TBD), 4:3 - Ignored, 31:5 CP state pointer
+//Compose area-of-interest bit + color pipe state pointer
+or (1)  r27.3<1>:ud     r2.4<0;1,0>:ud     r7.26<0;1,0>:b     { NoDDChk }
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r24.0<1>:ud       r27<8;8,1>:ud
+
+
+// Pack 2nd field Y; First 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT1_1(1)<2>                       ubDNDI_RESP(0,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(1,16)<2>            ubDNDI_RESP(0,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2)<2>                       ubDNDI_RESP(0,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2,16)<2>            ubDNDI_RESP(0,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; First 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,1)<4>                 ubDNDI_RESP(2,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,17)<4>        ubDNDI_RESP(2,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,3)<4>         ubDNDI_RESP(2,0)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,19)<4>        ubDNDI_RESP(2,16)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,1)<4>                 ubDNDI_RESP(2,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,17)<4>        ubDNDI_RESP(2,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,3)<4>         ubDNDI_RESP(2,32)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,19)<4>        ubDNDI_RESP(2,48)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+
+// Pack 2nd field Y; Second 8x4 block
+mov    (8)     r21.0<1>:ud             r18.0<8;8,1>:ud
+add    (1)     r21.0<1>:ud             r21.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT1_2(1)<2>                       ubDNDI_RESP(0,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(1,16)<2>            ubDNDI_RESP(0,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2)<2>                       ubDNDI_RESP(0,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2,16)<2>            ubDNDI_RESP(0,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; Second 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,1)<4>                 ubDNDI_RESP(2,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,17)<4>                ubDNDI_RESP(2,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,3)<4>                 ubDNDI_RESP(2,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,19)<4>                ubDNDI_RESP(2,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,1)<4>                 ubDNDI_RESP(2,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,17)<4>                ubDNDI_RESP(2,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,3)<4>                 ubDNDI_RESP(2,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,19)<4>                ubDNDI_RESP(2,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r18.0   0x5     0x60A801B:ud
+send (8)    null<1>:d    r21.0   0x5     0x60A801B:ud
+
+// Pack 1st field Y; 1st 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT2_1(1)<2>                       ubDNDI_RESP(4,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(1,16)<2>            ubDNDI_RESP(4,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2)<2>                       ubDNDI_RESP(4,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2,16)<2>            ubDNDI_RESP(4,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U,V; 1st 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,1)<4>                 ubDNDI_RESP(6,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,17)<4>        ubDNDI_RESP(6,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,3)<4>         ubDNDI_RESP(6,0)<8;4,2>             { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,19)<4>        ubDNDI_RESP(6,16)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,1)<4>                 ubDNDI_RESP(6,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,17)<4>        ubDNDI_RESP(6,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,3)<4>         ubDNDI_RESP(6,32)<8;4,2>                    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,19)<4>        ubDNDI_RESP(6,48)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+
+// Pack 1st field Y; 2nd 8x4 block
+mov    (8)     r27.0<1>:ud             r24.0<8;8,1>:ud
+add    (1)     r27.0<1>:ud             r27.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT2_2(1)<2>                       ubDNDI_RESP(4,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(1,16)<2>            ubDNDI_RESP(4,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2)<2>                       ubDNDI_RESP(4,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2,16)<2>            ubDNDI_RESP(4,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U, V; 2nd 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,1)<4>                 ubDNDI_RESP(6,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,17)<4>                ubDNDI_RESP(6,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,3)<4>                 ubDNDI_RESP(6,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,19)<4>                ubDNDI_RESP(6,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,1)<4>                 ubDNDI_RESP(6,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,17)<4>                ubDNDI_RESP(6,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,3)<4>                 ubDNDI_RESP(6,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,19)<4>                ubDNDI_RESP(6,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r24.0     0x5     0x60A801E:ud
+send (8)    null<1>:d    r27.0     0x5     0x60A801E:ud
+
+
+
+// FileName:   DN_Save_UV_IMC3_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x4 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Save_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x4 block through DATAPORT 
+
+
+//Reuse the header from Load component
+
+
+       mov (4)         mudMSGHDR_UCOPY(1)<1>           udDNDI_UV_RESP(0)<4;4,1>
+       mov (4)         mudMSGHDR_VCOPY(1)<1>           udDNDI_UV_RESP(1)<4;4,1>
+    send (4)    null<1>:d    r36       0x5    0x40A8019:ud
+    send (4)    null<1>:d    r38       0x5    0x40A801A:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PL3_DNDI_PA.g4a b/src/shaders/post_processing/gen7/PL3_DNDI_PA.g4a
new file mode 100644 (file)
index 0000000..65bceeb
--- /dev/null
@@ -0,0 +1,500 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   90    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PL3_DNDI_PA
+.code
+
+
+
+// FileName:   DNDI_PL_Core.asm
+// Author:             Tatiya, Rupesh
+
+
+
+// FileName:   DNDI_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN+DI case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4BE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+       mov (1)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(9,0)<0;1,0>         // Move denoise history to MRF (4x1)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x3:ud                                                                  { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Load_UV_IMC3_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x4 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Load_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x4 block through DATAPORT 
+
+
+       add (2)         r27.0<1>:d                      r7.0<2;2,1>:w                           r4.4<2;2,1>:w                           // Source Y Block origin
+       asr (2)         r27.0<1>:d              r27.0<2;2,1>:d          1:w                                             { NoDDClr }             // U/V block origin should be half of Y's
+       mov (1)         r27.2<1>:ud                     0x10007:ud                                              { NoDDChk }             // U/V block width and height (8x2)
+    mov (8)     r36<1>:ud      r27.0<8;8,1>:ud
+    mov (8)     r38<1>:ud     r27.0<8;8,1>:ud
+       send (8)        udDNDI_UV_RESP(0)<1>    r36     0x4     0x2190001:ud
+       send (8)        udDNDI_UV_RESP(1)<1>    r38     0x4     0x2190002:ud
+
+
+
+// FileName:   DN_Save_Y_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save one 16x4 blocks of Y channel of DN output for reference
+
+
+ // check top/bottom field first
+cmp.e.f0.0 (1)  null<1>:w               r1.28<0;1,0>:ub     1:w
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                                            // message header   
+mov (2)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<2;2,1>:w                           { NoDDClr }             // X origin * 2 (422 output)
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x3000F:ud              { NoDDChk }             // block width and height (32x8)
+
+(f0.0) jmpi (1) TOP_FIELD_FIRST
+
+BOTTOM_FIELD_FIRST:
+
+       mov (4)     mudMSGHDR_DN_OUT(1,0)<1>    udDNDI_RESP(10,0)<4;4,1>        { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(1,4)<1>    udDNDI_RESP(4,4)<4;4,1>                 { NoDDChk }             // 1st field luma from current frame (line 1,3)
+       mov (4)     mudMSGHDR_DN_OUT(2,0)<1>    udDNDI_RESP(10,4)<4;4,1>        { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(2,4)<1>   udDNDI_RESP(5,4)<4;4,1>          { NoDDChk }             // 1st field luma from current frame (line 1,3)    
+
+       jmpi (1) SAVE_DN_CURR
+
+TOP_FIELD_FIRST:
+       mov (4)     mudMSGHDR_DN_OUT(1,0)<1>    udDNDI_RESP(4,0)<4;4,1>                 { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(1,4)<1>    udDNDI_RESP(10,0)<4;4,1>        { NoDDChk }             // 1st field luma from current frame (line 1,3)
+       mov (4)     mudMSGHDR_DN_OUT(2,0)<1>    udDNDI_RESP(5,0)<4;4,1>                 { NoDDClr }             // 2nd field luma from current frame (line 0,2)
+       mov (4)     mudMSGHDR_DN_OUT(2,4)<1>   udDNDI_RESP(10,4)<4;4,1>         { NoDDChk }             // 1st field luma from current frame (line 1,3)
+
+SAVE_DN_CURR:
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0x60A8018:ud     
+
+
+
+// FileName:    DI_Save_PA_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in Packed format
+
+
+add (4) a0.4<1>:uw   r2.28<4;4,1>:ub   608:w               // Initial Y,U,V offset in YUV422 block; it starts at m20
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:d      r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:d      r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3001F:ud          { NoDDChk }          // Block width and height (32x8)
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r23.0<1>:ud       r27<8;8,1>:ud
+
+// Pack 2nd field Y
+    mov (16)    r[a0.4, 0]<2>      ubDNDI_RESP(0,0)               { NoDDClr }
+    mov (16)    r[a0.4, 32]<2>      ubDNDI_RESP(0,16)               { NoDDClr }
+    mov (16)    r[a0.4, 64]<2>      ubDNDI_RESP(0,32)               { NoDDClr }
+    mov (16)    r[a0.4, 96]<2>      ubDNDI_RESP(0,48)               { NoDDClr }
+// Pack 2nd field U
+    mov (8)     r[a0.5, 0]<4>      ubDNDI_RESP(2,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 32]<4>      ubDNDI_RESP(2,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 64]<4>      ubDNDI_RESP(2,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 96]<4>      ubDNDI_RESP(2,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 2nd field V
+    mov (8)     r[a0.6, 0]<4>      ubDNDI_RESP(2,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 32]<4>      ubDNDI_RESP(2,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 64]<4>      ubDNDI_RESP(2,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 96]<4>      ubDNDI_RESP(2,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+// Pack 1st field Y
+    mov (16)    r[a0.4, 160]<2>    ubDNDI_RESP(4,0)               { NoDDClr }
+    mov (16)    r[a0.4, 192]<2>    ubDNDI_RESP(4,16)               { NoDDClr }
+    mov (16)    r[a0.4, 224]<2>    ubDNDI_RESP(4,32)               { NoDDClr }
+    mov (16)    r[a0.4, 256]<2>    ubDNDI_RESP(4,48)               { NoDDClr }
+// Pack 1st field U
+    mov (8)     r[a0.5, 160]<4>    ubDNDI_RESP(6,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 192]<4>    ubDNDI_RESP(6,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 224]<4>    ubDNDI_RESP(6,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 256]<4>    ubDNDI_RESP(6,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 1st field V
+    mov (8)     r[a0.6, 160]<4>    ubDNDI_RESP(6,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 192]<4>    ubDNDI_RESP(6,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 224]<4>    ubDNDI_RESP(6,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 256]<4>    ubDNDI_RESP(6,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+//save the previous frame
+send (8)    null<1>:d    r18.0     0x5     0xA0A801B:ud
+
+//save the current frame
+send (8)    null<1>:d    r23.0     0x5     0xA0A801E:ud
+
+
+
+// FileName:   DN_Save_UV_IMC3_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x4 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Save_16x4.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x4 block through DATAPORT 
+
+
+//Reuse the header from Load component
+
+
+       mov (4)         mudMSGHDR_UCOPY(1)<1>           udDNDI_UV_RESP(0)<4;4,1>
+       mov (4)         mudMSGHDR_VCOPY(1)<1>           udDNDI_UV_RESP(1)<4;4,1>
+    send (4)    null<1>:d    r36       0x5    0x40A8019:ud
+    send (4)    null<1>:d    r38       0x5    0x40A801A:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PL3_DNUV_PL3.g4a b/src/shaders/post_processing/gen7/PL3_DNUV_PL3.g4a
new file mode 100644 (file)
index 0000000..2e1ad5f
--- /dev/null
@@ -0,0 +1,2684 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+// 1295    // Total instruction count
+//    1    // Total kernel count
+
+
+.kernel PL3_DNUV_PL3
+.code
+
+
+
+//Module               : DN_UV_Setup
+//Author               : Tatiya, Rupesh
+//Description  : Initial Set-up for DN_UV
+
+
+
+
+// Module name : ChromaDenoise.inc
+// Author              : Tatiya, Rupesh
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//======================================================
+//Interface for serpent mode Chroma Denoise, added by Le
+//======================================================
+//r1
+
+
+//noise history thresholds (low and high)
+
+
+//temporal difference thresholds (high and low)
+
+
+//noise history thresholds (low and high)
+//#define ubNoiseHistMaxHigh  r1.22
+//#define ubNoiseHistMaxLow  r1.23
+//#define ubNoiseHistDeltaHigh  r1.24
+//#define ubNoiseHistDeltaLow  r1.25
+
+//Gaussian thresholds
+
+
+//temporal difference thresholds (default)
+
+
+//r2
+//history thresholds (default)
+
+
+//denoise factor  (0-63)
+
+
+//====================== Binding table (Explicit To DNUV)=========================================
+//Used by DN_UV kernels
+
+
+       //Pointer to Current Frame UV
+
+
+//r1-r6
+       //CURBE GRFs used as TEMP : Used for max computation and storing max temporarily. : r1-r6
+
+
+       .declare        ubCURBE_TEMP    Base=r1.0       ElementSize=1   Type=ub
+       .declare        uwCURBE_TEMP    Base=r1.0       ElementSize=2   Type=uw
+       .declare        wCURBE_TEMP             Base=r1.0       ElementSize=2   Type=w
+       .declare        fCURBE_TEMP             Base=r1.0       ElementSize=4   Type=f
+       .declare        udCURBE_TEMP            Base=r1.0       ElementSize=4   Type=ud
+       .declare        uwMAX_ABS_DIFF  Base=r5.0       ElementSize=2   Type=uw
+
+       //r1
+
+
+       //r3
+
+
+    //r4
+
+//r7
+       //All of the following has to defined in Same GRF for optimal performance.
+
+
+//r8-24
+    //Previous Frame UV
+
+       .declare        udPREV_UV               Base=r8.0       ElementSize=4   Type=ud
+       .declare        ubPREV_UV               Base=r8.0       ElementSize=1   Type=ub
+
+
+//r25-48
+       //TEMP Space for any Usage.
+
+
+//=========================================================================
+//Definations and declarations for serpent mode Chroma Denoise, added by Le
+//=========================================================================      
+
+
+       .declare        udGNE_UV                Base=r24.0      ElementSize=4   Type=ud
+  .declare     fGNE_UV         Base=r24.0      ElementSize=4   Type=f
+  .declare     ubGNE_UV                Base=r24.0      ElementSize=1   Type=ub
+
+  .declare     udMSGHDR_BNE_SERP       Base=r25.0      ElementSize=4   Type=ud
+  .declare     udMSGSRC_BNE_SERP       Base=r26.0      ElementSize=4   Type=ud
+
+
+  .declare     ubDN_UV_Thresholds Base=r26.0   ElementSize=1   Type=ub
+  .declare     ubDN_UV_Thresholds_Temp  Base=r27.0     ElementSize=1   Type=ub
+  .declare     udDN_UV_Thresholds Base=r26.0   ElementSize=4   Type=ud
+  .declare     udDN_UV_Thresholds_Temp Base=r27.0      ElementSize=4   Type=ud
+  .declare     fDN_UV_Thresholds Base=r26.0    ElementSize=4   Type=f
+  .declare     fDN_UV_Thresholds_Temp Base=r27.0       ElementSize=4   Type=f  
+
+
+//====================================================================================
+
+
+       //TEMP23: To hold V data for PL3 surfaces
+       .declare        udCURR_V_TEMP   Base=r25.0      ElementSize=4   Type=ud
+       .declare        ubCURR_V_TEMP   Base=r25.0      ElementSize=1   Type=ub
+
+       //GRFs to calculate Median: r25-r42
+       .declare        ubMEDIAN_TEMP   Base=r25.0      ElementSize=1   Type=ub
+
+       //18 GRFs to hold difference : r25-r42
+       .declare        wDIFF                   Base=r25.0      ElementSize=2   Type=w
+       .declare        uwDIFF                  Base=r25.0      ElementSize=2   Type=uw
+
+       //Temporal Diff
+       .declare        wDIFF_TEMPORAL                  Base=r25.0      ElementSize=2   Type=w
+       .declare        ubDIFF_TEMPORAL                 Base=r25.0      ElementSize=1   Type=ub
+
+       //4 GRFs to hold Sobel Value : r43-46
+       .declare        wSOBEL_X        Base=r43.0      ElementSize=2   Type=w
+       .declare        uwSOBEL         Base=r43.0      ElementSize=2   Type=uw
+
+
+       //2 GRFs to hold SOAD temporarily: r47-48
+       .declare        uwSOAD                  Base=r47.0      ElementSize=2   Type=uw
+
+       //Temp GRFs to hold extra YUYV pixels: r43-r48
+       .declare        ubTEMP5                 Base=r43.0      ElementSize=1   Type=ub
+
+       //Temp GRFs in Median Calculation: r47-r48
+       .declare        ubTEMP1                 Base=r47.0      ElementSize=1   Type=ub
+
+       .declare        uwTEMP0                 Base=r48.0      ElementSize=2   Type=uw
+       .declare        ubTEMP0                 Base=r48.0      ElementSize=1   Type=ub
+
+       //Temp Space to store Median : r49-50
+
+       .declare        ubMEDIAN        Base=r49.0      ElementSize=1   Type=ub
+
+//r49
+
+
+//r50
+    //Message Source
+
+
+//r51
+       //DN_UV History Surface
+
+       .declare        udHIST_UV               Base=r51.0      ElementSize=4   Type=ud
+       .declare        ubHIST_UV               Base=r51.0      ElementSize=1   Type=ub
+
+//r52 - r91
+       //r52
+       //Current Frame UV
+
+
+       .declare        udCURR_UV               Base=r52.0      ElementSize=4   Type=ud
+       .declare        ubCURR_UV               Base=r52.0      ElementSize=1   Type=ub
+
+       //r54
+       //CURBE COPY
+
+
+       //r55
+
+
+       .declare        uwSOAD_MIN_8x4          Base=r56.0      ElementSize=2   Type=uw
+
+       //r61
+
+
+       //r62
+
+
+       //History Surface Temp Origin
+
+
+    //r63
+    //Current Frame Y Temp Origin
+
+
+       //BNE Surface Origin
+
+
+    //r70
+
+       .declare        uwDIFF_TEMPORAL_SUM4x4  Base=r70.0      ElementSize=2   Type=uw  //4 GRFs
+
+       //r74-91 : For Saving Dest UV (PL2/PL3)
+
+
+       .declare        ubMSGPAYLOAD_UV0        Base=r75.0      ElementSize=1   Type=ub
+
+
+       .declare        ubMSGPAYLOAD_U          Base=r75.0      ElementSize=1   Type=ub
+
+
+       .declare        ubMSGPAYLOAD_UV1        Base=r84.0      ElementSize=1   Type=ub
+
+
+       .declare        ubMSGPAYLOAD_V          Base=r84.0      ElementSize=1   Type=ub
+
+       //r90
+
+       .declare        uwDIFF_TEMPORAL_SUM4x4_FINAL    Base=r90.0      ElementSize=2   Type=uw  //2 GRFs
+
+//r92-127
+       //Current Frame Y
+
+
+       //r92
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_0           Base=r92        ElementSize=2   Type=uw
+       //r101
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_1           Base=r101       ElementSize=2   Type=uw
+       //r110
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_2           Base=r110       ElementSize=2   Type=uw
+       //r119
+    .declare   uwDIFF_TEMPORAL_SUM4x4_TEMP_3           Base=r119       ElementSize=2   Type=uw
+
+       .declare        udCURR_Y0               Base=r93.0      ElementSize=4   Type=ud
+    .declare   ubCURR_Y0               Base=r93.0      ElementSize=1   Type=ub
+    .declare   udCURR_Y1               Base=r102.0     ElementSize=4   Type=ud
+       .declare        ubCURR_Y1               Base=r102.0     ElementSize=1   Type=ub
+       .declare        udCURR_Y2               Base=r111.0     ElementSize=4   Type=ud
+       .declare        ubCURR_Y2               Base=r111.0     ElementSize=1   Type=ub
+       .declare        udCURR_Y3               Base=r120.0     ElementSize=4   Type=ud
+       .declare        ubCURR_Y3               Base=r120.0     ElementSize=1   Type=ub
+
+       //r92: To hold U data for PL3 surfaces
+       .declare        udCURR_U_TEMP           Base=r92.0      ElementSize=4   Type=ud
+    .declare   ubCURR_U_TEMP           Base=r92.0      ElementSize=1   Type=ub
+
+    //r112: To hold U data for PL3 surfaces
+       .declare        udPREV_U_TEMP           Base=r112.0     ElementSize=4   Type=ud
+       .declare        ubPREV_U_TEMP           Base=r112.0     ElementSize=1   Type=ub
+
+       //r120: To hold U data for PL3 surfaces
+       .declare        udPREV_V_TEMP           Base=r120.0     ElementSize=4   Type=ud
+       .declare        ubPREV_V_TEMP           Base=r120.0     ElementSize=1   Type=ub
+
+
+       // Initialize message source with r0.
+       mov (8)   r50.0<1>:ud           r0.0<8;8,1>:ud
+       mov (8)   r92.0<1>:ud           r0.0<8;8,1>:ud
+       mov (8)   r101.0<1>:ud          r0.0<8;8,1>:ud
+       mov (8)   r110.0<1>:ud          r0.0<8;8,1>:ud
+       mov (8)   r119.0<1>:ud          r0.0<8;8,1>:ud
+
+
+
+//Module Name  :       DN_UV_PL3_Load_Curr_Frame_UV
+//Author               :       Tatiya, Rupesh
+//Description  :       Loads Current Frame U/V data for PL3 input.
+
+
+
+//Module name  :  DN_UV_Load_Curr_Frame_UV
+//Author               :  Tatiya, Rupesh
+//Description  :  Loads Current Frame (UV only).
+//                                We need 4 extra rows (2 per field) and 2 extra pixel (1 each side) for both U and V each.
+//                                The processing size is 16x16 U and V each. So we need : U size - 18x20, V size - 18x20, UV size - 36x20, YUYV size - 72x20.
+
+
+
+
+//18x20 U/V block is partitioned as follows:
+//                             <------ 18 ------>
+//                             ------------------
+//                             |   18x8 A1      |
+//                             |                |
+//                             |----------------|
+//                             |    18x8 A2     |
+//                             |                |
+//                             |----------------|
+//                             |    18x4 A2     |
+//                             |----------------|
+//
+// Cordinates: (x-1, y-2), (x-1, y+6), (x-1, y+14)
+
+//1. Load U data into starting at CURR_Y0 (r93-r122)
+//2. Load V data into TEMP space (r25-r44)
+
+       //U/V surface origin: (ORIX/2, ORIY/2)
+       add  (2)        r7.4<1>:w               r7.0<2;2,1>:w           r4.4<2;2,1>:w    { AccWrEn }    // Source Block origin
+       shr  (2)        r7.4<1>:w               acc0.4<2;2,1>:w         1:w                                                                             //U Data
+       mov  (2)        acc0.0<1>:d                                                     r7.4<2;2,1>:w
+
+       //A1
+       add  (1)        r50.0<1>:d      acc0.0<0;1,0>:d         -1:d                                             
+       add  (1)        r50.1<1>:d      acc0.1<0;1,0>:d         -2:d                                             
+       mov  (1)        r50.2<1>:ud     0x70011:ud                               
+       send (8)        udCURR_U_TEMP(0)<1>                     r50             0x4     0x2890004:ud
+
+       //A2
+       add  (1)        r50.1<1>:d      acc0.1<0;1,0>:d         6:d
+       send (8)        udCURR_U_TEMP(8)<1>                     r50             0x4     0x2890004:ud
+
+       //A3
+       add  (1)        r50.1<1>:d      acc0.1<0;1,0>:d         14:d                                             
+       mov  (1)        r50.2<1>:ud     0x30011:ud                               
+       send (8)        udCURR_U_TEMP(16)<1>            r50             0x4     0x2490004:ud
+
+       //V Data
+       //A1
+       add  (1)        r50.0<1>:d      acc0.0<0;1,0>:d         -1:d                                             
+       add  (1)        r50.1<1>:d      acc0.1<0;1,0>:d         -2:d                                             
+       mov  (1)        r50.2<1>:ud     0x70011:ud                               
+       send (8)        udCURR_V_TEMP(0)<1>     r50             0x4     0x2890005:ud
+
+       //A2
+       add  (1)        r50.1<1>:d      acc0.1<0;1,0>:d         6:d
+       send (8)        udCURR_V_TEMP(8)<1>     r50             0x4     0x2890005:ud
+
+       //A3
+       add  (1)        r50.1<1>:d      acc0.1<0;1,0>:d         14:d                                             
+       mov  (1)        r50.2<1>:ud     0x30011:ud                               
+       send (8)        udCURR_V_TEMP(16)<1>    r50             0x4     0x2490005:ud
+
+       //History Origin, Current Y origin and BNE surface origin - all are in inline GRF. Use , . -rT.
+
+       //Calculate Origin For History Surface: (ORIX/4, ORIY/8)
+       mov  (16)       acc0.0<1>:w                                             r7.0<0;2,1>:w                           { AccWrEn }
+       shr  (1)        r7.2<1>:w               acc0.2<0;1,0>:w 2:w                     
+       shr  (1)        r7.3<1>:w               acc0.3<0;1,0>:w 3:w                     
+
+       //Calculate Origin For BNE Surface: (ORIX/8, ORIY/16)
+       shr  (1)        r7.6<1>:w               acc0.6<0;1,0>:w         3:w             
+       shr  (1)        r7.7<1>:w               acc0.7<0;1,0>:w         4:w             
+
+
+
+//Module Name  :       DN_UV_PL3_Load_Prev_Frame_UV.asm
+//Author               :       Tatiya, Rupesh
+//Description  :       Loads Pevious Frame UV data for PL3 input.
+
+
+
+//Module Name  :       DN_UV_Load_Prev_Frame_UV
+//Author               :       Tatiya, Rupesh
+//Description  :   Loads Prev Frame (UV only). U size - 16x16, V size - 16x16, UV size - 32x16, YUYV size - 64x16.
+
+
+
+
+//1. Load U in bottom half of UV space for prev frame (r17-r24)
+//2. Load V in bottom quarter of Y space for curr frame (r120-r127)
+
+       mov  (2)        r50.0<1>:d              r7.4<2;2,1>:w                   { AccWrEn }     // Source lock origin
+       mov  (1)        r50.2<1>:ud     0xF000F:ud                                              // U/V block width and height (16x16)
+
+       mov  (8)        r49.0<1>:ud     r50<8;8,1>:ud
+
+       send (8)        udPREV_U_TEMP(0)<1>             r50     0x4     0x2890001:ud    //U data
+       send (8)        udPREV_V_TEMP(0)<1>             r49     0x4     0x2890002:ud    //V data
+
+
+       //TODO - See if History loading can be combined with Prev Frame Load. - rT
+
+
+//Module name  :  DN_UV_Load_Hist_UV
+//Author               :  Tatiya, Rupesh
+//Description  :  Load DN History for UV denoise. 4x4 for each U & V.
+
+
+
+
+       mov  (2)        r50.0<1>:d      r7.2<2;2,1>:w                   
+       mov  (1)        r50.2<1>:ud     0x30007:ud              
+       send (8)        udHIST_UV(0)<1>                 r50             0x4     0x2190022:ud
+
+
+
+//File Name            : DN_UV_PL3_Interleave_Curr_Frame_UV.asm
+//Author               : Tatiya, Rupesh
+//Description  : Interleave separately loaded U and V for PL3 format.
+//                               This is needed because Noise Detection and Noise Reduction works on interleaved UV data.
+
+//1. U data: Starting at CURR_Y0 (r93-r122)
+//2. V data: TEMP space (r25-r44)
+
+//In one GRF, we need 10 U (1+8+1) bytes, but there's no SIMD10. So use SIMD16 and discard last 6 bytes.
+
+
+//Move U data
+       mov (16) ubCURR_UV(0,0)<2>      ubCURR_U_TEMP(0,0)<16;16,1>             
+       mov (16) ubCURR_UV(20,0)<2>     ubCURR_U_TEMP(0,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(1,0)<2>      ubCURR_U_TEMP(1,0)<16;16,1>             
+       mov (16) ubCURR_UV(21,0)<2>     ubCURR_U_TEMP(1,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(2,0)<2>      ubCURR_U_TEMP(2,0)<16;16,1>             
+       mov (16) ubCURR_UV(22,0)<2>     ubCURR_U_TEMP(2,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(3,0)<2>      ubCURR_U_TEMP(3,0)<16;16,1>             
+       mov (16) ubCURR_UV(23,0)<2>     ubCURR_U_TEMP(3,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(4,0)<2>      ubCURR_U_TEMP(4,0)<16;16,1>             
+       mov (16) ubCURR_UV(24,0)<2>     ubCURR_U_TEMP(4,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(5,0)<2>      ubCURR_U_TEMP(5,0)<16;16,1>             
+       mov (16) ubCURR_UV(25,0)<2>     ubCURR_U_TEMP(5,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(6,0)<2>      ubCURR_U_TEMP(6,0)<16;16,1>             
+       mov (16) ubCURR_UV(26,0)<2>     ubCURR_U_TEMP(6,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(7,0)<2>      ubCURR_U_TEMP(7,0)<16;16,1>             
+       mov (16) ubCURR_UV(27,0)<2>     ubCURR_U_TEMP(7,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(8,0)<2>      ubCURR_U_TEMP(8,0)<16;16,1>             
+       mov (16) ubCURR_UV(28,0)<2>     ubCURR_U_TEMP(8,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(9,0)<2>      ubCURR_U_TEMP(9,0)<16;16,1>             
+       mov (16) ubCURR_UV(29,0)<2>     ubCURR_U_TEMP(9,8)<16;16,1>             
+
+       mov (16) ubCURR_UV(10,0)<2>     ubCURR_U_TEMP(10,0)<16;16,1>            
+       mov (16) ubCURR_UV(30,0)<2>     ubCURR_U_TEMP(10,8)<16;16,1>            
+
+       mov (16) ubCURR_UV(11,0)<2>     ubCURR_U_TEMP(11,0)<16;16,1>            
+       mov (16) ubCURR_UV(31,0)<2>     ubCURR_U_TEMP(11,8)<16;16,1>            
+
+       mov (16) ubCURR_UV(12,0)<2>     ubCURR_U_TEMP(12,0)<16;16,1>            
+       mov (16) ubCURR_UV(32,0)<2>     ubCURR_U_TEMP(12,8)<16;16,1>            
+
+       mov (16) ubCURR_UV(13,0)<2>     ubCURR_U_TEMP(13,0)<16;16,1>            
+       mov (16) ubCURR_UV(33,0)<2>     ubCURR_U_TEMP(13,8)<16;16,1>            
+
+       mov (16) ubCURR_UV(14,0)<2>     ubCURR_U_TEMP(14,0)<16;16,1>            
+       mov (16) ubCURR_UV(34,0)<2>     ubCURR_U_TEMP(14,8)<16;16,1>            
+
+       mov (16) ubCURR_UV(15,0)<2>     ubCURR_U_TEMP(15,0)<16;16,1>            
+       mov (16) ubCURR_UV(35,0)<2>     ubCURR_U_TEMP(15,8)<16;16,1>            
+
+       mov (16) ubCURR_UV(16,0)<2>     ubCURR_U_TEMP(16,0)<16;16,1>            
+       mov (16) ubCURR_UV(36,0)<2>     ubCURR_U_TEMP(16,8)<16;16,1>            
+
+       mov (16) ubCURR_UV(17,0)<2>     ubCURR_U_TEMP(17,0)<16;16,1>            
+       mov (16) ubCURR_UV(37,0)<2>     ubCURR_U_TEMP(17,8)<16;16,1>            
+
+       mov (16) ubCURR_UV(18,0)<2>     ubCURR_U_TEMP(18,0)<16;16,1>            
+       mov (16) ubCURR_UV(38,0)<2>     ubCURR_U_TEMP(18,8)<16;16,1>            
+
+       mov (16) ubCURR_UV(19,0)<2>     ubCURR_U_TEMP(19,0)<16;16,1>            
+       mov (16) ubCURR_UV(39,0)<2>     ubCURR_U_TEMP(19,8)<16;16,1>            
+
+
+//Move V data
+       mov (16) ubCURR_UV(0,1)<2>      ubCURR_V_TEMP(0,0)<16;16,1>     
+       mov (16) ubCURR_UV(20,1)<2>     ubCURR_V_TEMP(0,8)<16;16,1>     
+       mov (16) ubCURR_UV(1,1)<2>      ubCURR_V_TEMP(1,0)<16;16,1>     
+       mov (16) ubCURR_UV(21,1)<2>     ubCURR_V_TEMP(1,8)<16;16,1>     
+       mov (16) ubCURR_UV(2,1)<2>      ubCURR_V_TEMP(2,0)<16;16,1>     
+       mov (16) ubCURR_UV(22,1)<2>     ubCURR_V_TEMP(2,8)<16;16,1>     
+       mov (16) ubCURR_UV(3,1)<2>      ubCURR_V_TEMP(3,0)<16;16,1>     
+       mov (16) ubCURR_UV(23,1)<2>     ubCURR_V_TEMP(3,8)<16;16,1>     
+       mov (16) ubCURR_UV(4,1)<2>      ubCURR_V_TEMP(4,0)<16;16,1>     
+       mov (16) ubCURR_UV(24,1)<2>     ubCURR_V_TEMP(4,8)<16;16,1>     
+       mov (16) ubCURR_UV(5,1)<2>      ubCURR_V_TEMP(5,0)<16;16,1>     
+       mov (16) ubCURR_UV(25,1)<2>     ubCURR_V_TEMP(5,8)<16;16,1>     
+       mov (16) ubCURR_UV(6,1)<2>      ubCURR_V_TEMP(6,0)<16;16,1>     
+       mov (16) ubCURR_UV(26,1)<2>     ubCURR_V_TEMP(6,8)<16;16,1>     
+       mov (16) ubCURR_UV(7,1)<2>      ubCURR_V_TEMP(7,0)<16;16,1>     
+       mov (16) ubCURR_UV(27,1)<2>     ubCURR_V_TEMP(7,8)<16;16,1>     
+       mov (16) ubCURR_UV(8,1)<2>      ubCURR_V_TEMP(8,0)<16;16,1>     
+       mov (16) ubCURR_UV(28,1)<2>     ubCURR_V_TEMP(8,8)<16;16,1>     
+       mov (16) ubCURR_UV(9,1)<2>      ubCURR_V_TEMP(9,0)<16;16,1>     
+       mov (16) ubCURR_UV(29,1)<2>     ubCURR_V_TEMP(9,8)<16;16,1>     
+       mov (16) ubCURR_UV(10,1)<2>     ubCURR_V_TEMP(10,0)<16;16,1>    
+       mov (16) ubCURR_UV(30,1)<2>     ubCURR_V_TEMP(10,8)<16;16,1>    
+       mov (16) ubCURR_UV(11,1)<2>     ubCURR_V_TEMP(11,0)<16;16,1>    
+       mov (16) ubCURR_UV(31,1)<2>     ubCURR_V_TEMP(11,8)<16;16,1>    
+       mov (16) ubCURR_UV(12,1)<2>     ubCURR_V_TEMP(12,0)<16;16,1>    
+       mov (16) ubCURR_UV(32,1)<2>     ubCURR_V_TEMP(12,8)<16;16,1>    
+       mov (16) ubCURR_UV(13,1)<2>     ubCURR_V_TEMP(13,0)<16;16,1>    
+       mov (16) ubCURR_UV(33,1)<2>     ubCURR_V_TEMP(13,8)<16;16,1>    
+       mov (16) ubCURR_UV(14,1)<2>     ubCURR_V_TEMP(14,0)<16;16,1>    
+       mov (16) ubCURR_UV(34,1)<2>     ubCURR_V_TEMP(14,8)<16;16,1>    
+       mov (16) ubCURR_UV(15,1)<2>     ubCURR_V_TEMP(15,0)<16;16,1>    
+       mov (16) ubCURR_UV(35,1)<2>     ubCURR_V_TEMP(15,8)<16;16,1>    
+       mov (16) ubCURR_UV(16,1)<2>     ubCURR_V_TEMP(16,0)<16;16,1>    
+       mov (16) ubCURR_UV(36,1)<2>     ubCURR_V_TEMP(16,8)<16;16,1>    
+       mov (16) ubCURR_UV(17,1)<2>     ubCURR_V_TEMP(17,0)<16;16,1>    
+       mov (16) ubCURR_UV(37,1)<2>     ubCURR_V_TEMP(17,8)<16;16,1>    
+       mov (16) ubCURR_UV(18,1)<2>     ubCURR_V_TEMP(18,0)<16;16,1>    
+       mov (16) ubCURR_UV(38,1)<2>     ubCURR_V_TEMP(18,8)<16;16,1>    
+       mov (16) ubCURR_UV(19,1)<2>     ubCURR_V_TEMP(19,0)<16;16,1>    
+       mov (16) ubCURR_UV(39,1)<2>     ubCURR_V_TEMP(19,8)<16;16,1>    
+
+
+
+//File Name            : DN_UV_PL3_Interleave_Prev_Frame_UV.asm
+//Author               : Tatiya, Rupesh
+//Description  : Interleave separately loaded U and V for PL3 format.
+//                This is needed because Noise Detection and Noise Reduction works on interleaved UV data.
+
+//1.U Data: bottom half of UV space for prev frame (r17-r24)
+//2.V Data: bottom quarter of Y space for curr frame (r120-r127)
+
+       mov (16)        ubPREV_UV(0,0)<2>               ubPREV_U_TEMP(0,0)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(8,0)<2>               ubPREV_U_TEMP(0,8)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(1,0)<2>               ubPREV_U_TEMP(1,0)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(9,0)<2>               ubPREV_U_TEMP(1,8)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(2,0)<2>               ubPREV_U_TEMP(2,0)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(10,0)<2>              ubPREV_U_TEMP(2,8)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(3,0)<2>               ubPREV_U_TEMP(3,0)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(11,0)<2>              ubPREV_U_TEMP(3,8)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(4,0)<2>               ubPREV_U_TEMP(4,0)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(12,0)<2>              ubPREV_U_TEMP(4,8)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(5,0)<2>               ubPREV_U_TEMP(5,0)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(13,0)<2>              ubPREV_U_TEMP(5,8)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(6,0)<2>               ubPREV_U_TEMP(6,0)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(14,0)<2>              ubPREV_U_TEMP(6,8)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(7,0)<2>               ubPREV_U_TEMP(7,0)<16;8,1>              { NoDDClr }
+       mov (16)        ubPREV_UV(15,0)<2>              ubPREV_U_TEMP(7,8)<16;8,1>              { NoDDClr }
+
+       mov (16)        ubPREV_UV(0,1)<2>               ubPREV_V_TEMP(0,0)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(8,1)<2>               ubPREV_V_TEMP(0,8)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(1,1)<2>               ubPREV_V_TEMP(1,0)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(9,1)<2>               ubPREV_V_TEMP(1,8)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(2,1)<2>               ubPREV_V_TEMP(2,0)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(10,1)<2>              ubPREV_V_TEMP(2,8)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(3,1)<2>               ubPREV_V_TEMP(3,0)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(11,1)<2>              ubPREV_V_TEMP(3,8)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(4,1)<2>               ubPREV_V_TEMP(4,0)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(12,1)<2>              ubPREV_V_TEMP(4,8)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(5,1)<2>               ubPREV_V_TEMP(5,0)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(13,1)<2>              ubPREV_V_TEMP(5,8)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(6,1)<2>               ubPREV_V_TEMP(6,0)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(14,1)<2>              ubPREV_V_TEMP(6,8)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(7,1)<2>               ubPREV_V_TEMP(7,0)<16;8,1>              { NoDDChk }
+       mov (16)        ubPREV_UV(15,1)<2>              ubPREV_V_TEMP(7,8)<16;8,1>              { NoDDChk }
+
+
+
+//Module Name  : DN_UV_420_Load_Curr_Frame_Y
+//Author               : Tatiya, Rupesh
+//Description  : Load Curr Frame Y data for 420 Input
+
+
+
+//Module Name  : DN_UV_Load_Curr_Frame_Y
+//Author               : Tatiya, Rupesh
+//Description  : Loads Y of Current frame.
+
+
+
+
+       //For 16x16 U and 16x16 V for 420, we need to read 32x32 Y.
+
+       mov (8)         acc0.0<1>:ud            r0.0<8;8,1>:ud
+       mov (1)         acc0.2<1>:ud            0xF000F:ud
+       add (2)         acc0.0<1>:ud            r7.0<2;2,1>:w           r4.4<2;2,1>:w
+
+       mov (8)     r92.0<1>:ud acc0.0<8;8,1>:ud
+
+       mov (8)     r101.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r110.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r119.0<1>:ud        acc0.0<8;8,1>:ud
+
+       add (1)         r101.1<1>:d     acc0.1<0;1,0>:d                 16:d
+
+       add (1)         r110.0<1>:d     acc0.0<0;1,0>:d                 16:d
+
+       add (2)         r119.0<1>:d     acc0.0<2;2,1>:d                 16:d
+
+       send (8)        udCURR_Y0(0)<1>         r92             0x4     0x2890003:ud
+       send (8)        udCURR_Y1(0)<1>         r101            0x4     0x2890003:ud
+       send (8)        udCURR_Y2(0)<1>         r110            0x4     0x2890003:ud
+       send (8)        udCURR_Y3(0)<1>         r119            0x4     0x2890003:ud
+
+
+
+//Module Name : DN_UV_Noise_Detection_UV
+//Author         : Tatiya, Rupesh
+//Description : Performs noise detection on 16x16 U and 16x16 V each.
+
+
+
+//Module Name  : DN_UV_Move_CURBE_Inline_UV.asm
+//Author               : Tatiya, Rupesh
+
+
+
+
+       //Mov CURBE data to another space - so that it can be used as Temp Space --> r1 - r6
+       mov (4) r54.28<1>:ub            r2.28<4;4,1>:ub         //Dest. YUY2 offset
+       mov (2) r54.5<1>:ud             r4.0<4;2,2>:ud          //Src YUY2 offset and Origin offset
+       mov (4) r55.28<1>:ub            r1.0<4;4,1>:ub
+
+       mov (8) r61.20<1>:ub            r1.4<8;8,1>:ub          
+       mov (4) r61.28<1>:ub            r1.12<4;4,1>:ub         
+
+       //Move Inline Data to another space - so that it can be used as Temp Space --> r7
+       mov (4) r62.10<1>:w                             r7.0<4;4,1>:w
+       mov (4) r63.10<1>:w             r7.4<4;4,1>:w
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       mov (1) a0.0:uw                         1664:uw                         
+       mov (1) a0.1:uw 1816:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         1792:uw                 
+       mov (1) a0.1:uw 1820:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         1920:uw                 
+       mov (1) a0.1:uw 1848:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2048:uw                 
+       mov (1) a0.1:uw 1852:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       mov (1) a0.0:uw                         2304:uw                 
+       mov (1) a0.1:uw 1880:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2432:uw                 
+       mov (1) a0.1:uw 1884:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2560:uw                 
+       mov (1) a0.1:uw 1912:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+
+
+//Module Name  : DN_UV_Noise_Detection_Set_Top_Region_N
+//Author               : Tatiya, Rupesh
+//Description  : Sets sub-region region N from Top region.
+
+
+       //TODO - remove one instruction here using arithmatic. -rT
+       mov (1) a0.0:uw                         2688:uw                 
+       mov (1) a0.1:uw 1916:uw         
+
+
+
+
+add (1) r7.7<1>:d ip:ud 32:d { NoCompact }
+ jmpi (1) DN_UV_NOISE_DETECTION_UV { NoCompact }
+
+
+
+//Module               : DN_UV_Noise_Reduction_UV
+//Author               : Tatiya, Rupesh
+//Description  : Performs Noise Reduction on 16x16 U and 16x16 V.
+//Tasks                        : 1. Update weight history
+//                               2. Find if it block is motion block
+//                               3. Compute Denoised Pixel.
+
+
+
+
+//History is 1+1 byte every 4x4 U and 4x4 V.
+
+       cmp.l.f0.0 (16) null<1>:w               ubHIST_UV(0,0)<16;16,1>         r61.20<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w               ubHIST_UV(0,0)<16;16,1>         r61.22<0;2,1>:ub
+
+       mov (16)        uwCURBE_TEMP(0)<1>      0:w
+       mov (16)        uwCURBE_TEMP(1)<1>      0:w
+
+       //Compute diff betn curr and prev. - First 16 lines
+       // 8 lines here
+    add (16)   wDIFF_TEMPORAL(0)<1>                    ubCURR_UV(2,2)<16;16,1>         -ubPREV_UV(0,0)<16;16,1>                //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(1)<1>                    ubCURR_UV(3,2)<16;16,1>         -ubPREV_UV(0,16)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(2)<1>                    ubCURR_UV(4,2)<16;16,1>         -ubPREV_UV(0,32)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(3)<1>                    ubCURR_UV(5,2)<16;16,1>         -ubPREV_UV(0,48)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(4)<1>                    ubCURR_UV(6,2)<16;16,1>         -ubPREV_UV(0,64)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(5)<1>                    ubCURR_UV(7,2)<16;16,1>         -ubPREV_UV(0,80)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(6)<1>                    ubCURR_UV(8,2)<16;16,1>         -ubPREV_UV(0,96)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(7)<1>                    ubCURR_UV(9,2)<16;16,1>         -ubPREV_UV(0,112)<16;16,1>              //Diff UV interleaved
+
+       //Update WT HIST
+       (-f0.0) shr     (16) uwCURBE_TEMP(0)<1>         ubHIST_UV(0,0)<16;16,1>         1:w
+       (f1.0)  add     (16) uwCURBE_TEMP(2)<1>         ubHIST_UV(0,0)<16;16,1>         r61.24<0;2,1>:ub
+       (f0.0)  mov     (16) uwCURBE_TEMP(2)<1>         r61.20<0;2,1>:ub
+       (-f0.0.anyv) mov        (16) uwCURBE_TEMP(2)<1>         ubHIST_UV(0,0)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w               ubHIST_UV(0,16)<16;16,1>        r61.20<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w               ubHIST_UV(0,16)<16;16,1>        r61.22<0;2,1>:ub
+
+       //Compute diff betn curr and prev. - First 16 lines
+       // 8 more lines here
+    add (16)   wDIFF_TEMPORAL(8)<1>                    ubCURR_UV(10,2)<16;16,1>                -ubPREV_UV(0,128)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(9)<1>                    ubCURR_UV(11,2)<16;16,1>                -ubPREV_UV(0,144)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(10)<1>                   ubCURR_UV(12,2)<16;16,1>                -ubPREV_UV(0,160)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(11)<1>                   ubCURR_UV(13,2)<16;16,1>                -ubPREV_UV(0,176)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(12)<1>                   ubCURR_UV(14,2)<16;16,1>                -ubPREV_UV(0,192)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(13)<1>                   ubCURR_UV(15,2)<16;16,1>                -ubPREV_UV(0,208)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(14)<1>                   ubCURR_UV(16,2)<16;16,1>                -ubPREV_UV(0,224)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(15)<1>                   ubCURR_UV(17,2)<16;16,1>                -ubPREV_UV(0,240)<16;16,1>              //Diff UV interleaved
+
+       (-f0.0) shr     (16) uwCURBE_TEMP(1)<1>         ubHIST_UV(0,16)<16;16,1>        1:w
+       (f1.0)  add     (16) uwCURBE_TEMP(3)<1>         ubHIST_UV(0,16)<16;16,1>        r61.24<0;2,1>:ub
+       (f0.0)  mov     (16) uwCURBE_TEMP(3)<1>         r61.20<0;2,1>:ub
+       (-f0.0.anyv) mov(16) uwCURBE_TEMP(3)<1>         ubHIST_UV(0,16)<16;16,1>
+
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(0)<16;16,1> (abs)wDIFF_TEMPORAL(1)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(2)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(3)<16;16,1>
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(4)<16;16,1> (abs)wDIFF_TEMPORAL(5)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(6)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(7)<16;16,1>
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(8)<16;16,1> (abs)wDIFF_TEMPORAL(9)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(10)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(2)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(11)<16;16,1>
+       //16x16 to 16x4 - First 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(12)<16;16,1>        (abs)wDIFF_TEMPORAL(13)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(14)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(3)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(15)<16;16,1>
+
+//Compute diff betn curr and prev. - Second 16 lines
+//13 lines.
+    add (16)   wDIFF_TEMPORAL(16)<1>           ubCURR_UV(22,2)<16;16,1>                -ubPREV_UV(8,0)<16;16,1>                //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(17)<1>           ubCURR_UV(23,2)<16;16,1>                -ubPREV_UV(8,16)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(18)<1>           ubCURR_UV(24,2)<16;16,1>                -ubPREV_UV(8,32)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(19)<1>           ubCURR_UV(25,2)<16;16,1>                -ubPREV_UV(8,48)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(20)<1>           ubCURR_UV(26,2)<16;16,1>                -ubPREV_UV(8,64)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(21)<1>           ubCURR_UV(27,2)<16;16,1>                -ubPREV_UV(8,80)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(22)<1>           ubCURR_UV(28,2)<16;16,1>                -ubPREV_UV(8,96)<16;16,1>               //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(23)<1>           ubCURR_UV(29,2)<16;16,1>                -ubPREV_UV(8,112)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(24)<1>           ubCURR_UV(30,2)<16;16,1>                -ubPREV_UV(8,128)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(25)<1>           ubCURR_UV(31,2)<16;16,1>                -ubPREV_UV(8,144)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(26)<1>           ubCURR_UV(32,2)<16;16,1>                -ubPREV_UV(8,160)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(27)<1>           ubCURR_UV(33,2)<16;16,1>                -ubPREV_UV(8,176)<16;16,1>              //Diff UV interleaved
+    add (16)   wDIFF_TEMPORAL(28)<1>           ubCURR_UV(34,2)<16;16,1>                -ubPREV_UV(8,192)<16;16,1>              //Diff UV interleaved
+
+//3 more lines
+    add (16)   wCURBE_TEMP(4)<1>               ubCURR_UV(35,2)<16;16,1>                -ubPREV_UV(8,208)<16;16,1>              //Diff UV interleaved
+    add (16)   wCURBE_TEMP(5)<1>               ubCURR_UV(36,2)<16;16,1>                -ubPREV_UV(8,224)<16;16,1>              //Diff UV interleaved
+    add (16)   wCURBE_TEMP(6)<1>               ubCURR_UV(37,2)<16;16,1>                -ubPREV_UV(8,240)<16;16,1>              //Diff UV interleaved
+
+       //16x4 to 8x4 - First 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>            uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>            uwDIFF_TEMPORAL_SUM4x4(2,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(2,2)<4;2,1>
+
+       //8x4 to 4x4 - First 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4_FINAL(0)<1>      uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>              { AccWrEn }
+
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(16)<16;16,1>        (abs)wDIFF_TEMPORAL(17)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(18)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(19)<16;16,1>
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(20)<16;16,1>        (abs)wDIFF_TEMPORAL(21)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(22)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(23)<16;16,1>
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(24)<16;16,1>        (abs)wDIFF_TEMPORAL(25)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(26)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(2)<1>    acc0.0<16;16,1>:uw                                      (abs)wDIFF_TEMPORAL(27)<16;16,1>
+
+       //16x16 to 16x4 - Second 16 lines
+       add (16)        acc0.0<1>:uw                                    (abs)wDIFF_TEMPORAL(28)<16;16,1>        (abs)wCURBE_TEMP(4)<16;16,1>
+       add (16)        acc0.0<1>:uw                                    acc0.0<16;16,1>:uw                                      (abs)wCURBE_TEMP(5)<16;16,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(3)<1>    acc0.0<16;16,1>:uw                                      (abs)wCURBE_TEMP(6)<16;16,1>
+
+       //Find if block is motion block - First 16 lines
+       cmp.g.f0.0  (16) null<1>:w                              uwDIFF_TEMPORAL_SUM4x4_FINAL(0)<16;16,1>                r61.26<0;2,1>:ub
+
+       //Move TEMPORAL_SUM4x4 for SIMD16 use later.
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,0)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,2)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,4)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,6)<0;2,1>      
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,8)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,10)<0;2,1>     
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,12)<0;2,1>             
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(0,14)<0;2,1>     
+
+       //Pick Appropriate Weight History Based on motion. - First 16 lines
+       (-f0.0) mov (16) uwCURBE_TEMP(0)<1>             uwCURBE_TEMP(2)<16;16,1>
+
+       //Actual DN - First 16 lines
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(0)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(0)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(2,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(2,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(2,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,0)<8;8,1>                                   uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,8)<8;8,1>                                   uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(0)<1>                    acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(0)<1>                   ubCURR_UV(2,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(0)<1>    wDIFF_TEMPORAL(0)<16;16,1>                                      ubCURR_UV(2,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(1)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(1)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(3,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(3,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(3,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,16)<8;8,1>                          uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,24)<8;8,1>                          uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(1)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(1)<1>           ubCURR_UV(3,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(1)<1>    wDIFF_TEMPORAL(1)<16;16,1>                              ubCURR_UV(3,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(2)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(2)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(4,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(4,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(4,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,32)<8;8,1>                          uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,40)<8;8,1>                          uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(2)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(2)<1>           ubCURR_UV(4,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(2)<1>    wDIFF_TEMPORAL(2)<16;16,1>                              ubCURR_UV(4,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(3)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(3)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(5,2)<8;8,1>                                   -uwCURBE_TEMP(0,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(5,10)<8;8,1>                                  -uwCURBE_TEMP(0,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(5,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,48)<8;8,1>                          uwCURBE_TEMP(0,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,56)<8;8,1>                          uwCURBE_TEMP(0,2)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(3)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(3)<1>           ubCURR_UV(5,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(3)<1>    wDIFF_TEMPORAL(3)<16;16,1>                              ubCURR_UV(5,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(4)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(4)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(6,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(6,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(6,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,64)<8;8,1>                                  uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,72)<8;8,1>                                  uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(4)<1>                    acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(4)<1>                   ubCURR_UV(6,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(4)<1>    wDIFF_TEMPORAL(4)<16;16,1>                                      ubCURR_UV(6,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(5)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(5)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(7,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(7,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(7,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,80)<8;8,1>                          uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,88)<8;8,1>                          uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(5)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(5)<1>           ubCURR_UV(7,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(5)<1>    wDIFF_TEMPORAL(5)<16;16,1>                              ubCURR_UV(7,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(6)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(6)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(8,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(8,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(8,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,96)<8;8,1>                          uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,104)<8;8,1>                         uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(6)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(6)<1>           ubCURR_UV(8,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(6)<1>    wDIFF_TEMPORAL(6)<16;16,1>                              ubCURR_UV(8,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(7)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(7)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(9,2)<8;8,1>                                   -uwCURBE_TEMP(0,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(9,10)<8;8,1>                                  -uwCURBE_TEMP(0,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(9,2)<16;16,1>                                 256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,112)<8;8,1>                         uwCURBE_TEMP(0,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,120)<8;8,1>                         uwCURBE_TEMP(0,6)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(7)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(7)<1>           ubCURR_UV(9,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(7)<1>    wDIFF_TEMPORAL(7)<16;16,1>                              ubCURR_UV(9,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(8)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(8)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(10,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(10,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(10,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,128)<8;8,1>                                 uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,136)<8;8,1>                                 uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(8)<1>                    acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(8)<1>                   ubCURR_UV(10,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(8)<1>    wDIFF_TEMPORAL(8)<16;16,1>                                      ubCURR_UV(10,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(9)<16;16,1>                 r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(9)<16;16,1>                 r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(11,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(11,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(11,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,144)<8;8,1>                         uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,152)<8;8,1>                         uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(9)<1>           acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(9)<1>           ubCURR_UV(11,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(9)<1>    wDIFF_TEMPORAL(9)<16;16,1>                              ubCURR_UV(11,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(10)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(10)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(12,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(12,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(12,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,160)<8;8,1>                         uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,168)<8;8,1>                         uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(10)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(10)<1>          ubCURR_UV(12,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(10)<1>   wDIFF_TEMPORAL(10)<16;16,1>                             ubCURR_UV(12,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(11)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(11)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(13,2)<8;8,1>                                  -uwCURBE_TEMP(0,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(13,10)<8;8,1>                                 -uwCURBE_TEMP(0,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(13,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,176)<8;8,1>                         uwCURBE_TEMP(0,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,184)<8;8,1>                         uwCURBE_TEMP(0,10)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(11)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(11)<1>          ubCURR_UV(13,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(11)<1>   wDIFF_TEMPORAL(11)<16;16,1>                             ubCURR_UV(13,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(12)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(12)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(14,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(14,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(14,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,192)<8;8,1>                                 uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,200)<8;8,1>                                 uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr (16) wDIFF_TEMPORAL(12)<1>                   acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(12)<1>                  ubCURR_UV(14,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(12)<1>   wDIFF_TEMPORAL(12)<16;16,1>                                     ubCURR_UV(14,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(13)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(13)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(15,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(15,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(15,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,208)<8;8,1>                         uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,216)<8;8,1>                         uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(13)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(13)<1>          ubCURR_UV(15,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(13)<1>   wDIFF_TEMPORAL(13)<16;16,1>                             ubCURR_UV(15,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(14)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(14)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(16,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(16,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(16,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,224)<8;8,1>                         uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,232)<8;8,1>                         uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(14)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(14)<1>          ubCURR_UV(16,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(14)<1>   wDIFF_TEMPORAL(14)<16;16,1>                             ubCURR_UV(16,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(15)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(15)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(17,2)<8;8,1>                                  -uwCURBE_TEMP(0,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(17,10)<8;8,1>                                 -uwCURBE_TEMP(0,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(17,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(0,240)<8;8,1>                         uwCURBE_TEMP(0,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(0,248)<8;8,1>                         uwCURBE_TEMP(0,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(15)<1>          acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(15)<1>          ubCURR_UV(17,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(15)<1>   wDIFF_TEMPORAL(15)<16;16,1>                             ubCURR_UV(17,2)<16;16,1>
+
+
+       //16x4 to 8x4 - Second 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(0)<1>    uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>
+       add (16)        uwDIFF_TEMPORAL_SUM4x4(1)<1>    uwDIFF_TEMPORAL_SUM4x4(2,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(2,2)<4;2,1>
+
+       //8x4 to 4x4 - Second 16 lines
+       add (16)        uwDIFF_TEMPORAL_SUM4x4_FINAL(1)<1>      uwDIFF_TEMPORAL_SUM4x4(0,0)<4;2,1>              uwDIFF_TEMPORAL_SUM4x4(0,2)<4;2,1>     { AccWrEn }
+
+       //Find if block is motion block - Second 16 lines
+       cmp.g.f1.0  (16) null<1>:w                              uwDIFF_TEMPORAL_SUM4x4_FINAL(1)<16;16,1>                r61.26<0;2,1>:ub
+
+       //Move TEMPORAL_SUM4x4 for SIMD16 use later.
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,0)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,2)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,4)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,6)<0;2,1>      
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,8)<0;2,1>              
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,10)<0;2,1>     
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,0)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,12)<0;2,1>             
+       mov (8)     uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0,8)<1>                 uwDIFF_TEMPORAL_SUM4x4_FINAL(1,14)<0;2,1>     
+
+       //Pick Appropriate Weight History Based on motion. - Second 16 lines
+       (-f1.0) mov (16) uwCURBE_TEMP(1)<1>             uwCURBE_TEMP(3)<16;16,1>
+
+       //Actual DN - Second 16 lines
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(16)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(16)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(22,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(22,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(22,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,0)<8;8,1>                                   uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,8)<8;8,1>                                   uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(16)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(16)<1>                  ubCURR_UV(22,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(16)<1>   wDIFF_TEMPORAL(16)<16;16,1>                     ubCURR_UV(22,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(17)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(17)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(23,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(23,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(23,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,16)<8;8,1>                          uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,24)<8;8,1>                          uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(17)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(17)<1>                  ubCURR_UV(23,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(17)<1>   wDIFF_TEMPORAL(17)<16;16,1>                     ubCURR_UV(23,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(18)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(18)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(24,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(24,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(24,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,32)<8;8,1>                          uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,40)<8;8,1>                          uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(18)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(18)<1>                  ubCURR_UV(24,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(18)<1>   wDIFF_TEMPORAL(18)<16;16,1>                     ubCURR_UV(24,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(19)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(19)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(25,2)<8;8,1>                                  -uwCURBE_TEMP(1,0)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(25,10)<8;8,1>                                 -uwCURBE_TEMP(1,2)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(25,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,48)<8;8,1>                          uwCURBE_TEMP(1,0)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,56)<8;8,1>                          uwCURBE_TEMP(1,2)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(19)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(19)<1>                  ubCURR_UV(25,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_0(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(19)<1>   wDIFF_TEMPORAL(19)<16;16,1>                     ubCURR_UV(25,2)<16;16,1>
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(20)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(20)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(26,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(26,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(26,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,64)<8;8,1>                                  uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,72)<8;8,1>                                  uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(20)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(20)<1>                  ubCURR_UV(26,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(20)<1>   wDIFF_TEMPORAL(20)<16;16,1>                     ubCURR_UV(26,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(21)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(21)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(27,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(27,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(27,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,80)<8;8,1>                          uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,88)<8;8,1>                          uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(21)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(21)<1>                  ubCURR_UV(27,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(21)<1>   wDIFF_TEMPORAL(21)<16;16,1>                     ubCURR_UV(27,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(22)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(22)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(28,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(28,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(28,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,96)<8;8,1>                          uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,104)<8;8,1>                         uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(22)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(22)<1>                  ubCURR_UV(28,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(22)<1>   wDIFF_TEMPORAL(22)<16;16,1>                     ubCURR_UV(28,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(23)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(23)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(29,2)<8;8,1>                                  -uwCURBE_TEMP(1,4)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(29,10)<8;8,1>                                 -uwCURBE_TEMP(1,6)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(29,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,112)<8;8,1>                         uwCURBE_TEMP(1,4)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,120)<8;8,1>                         uwCURBE_TEMP(1,6)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(23)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(23)<1>                  ubCURR_UV(29,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_1(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(23)<1>   wDIFF_TEMPORAL(23)<16;16,1>                     ubCURR_UV(29,2)<16;16,1>
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(24)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(24)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(30,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(30,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(30,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,128)<8;8,1>                                 uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,136)<8;8,1>                                 uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(24)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(24)<1>                  ubCURR_UV(30,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(24)<1>   wDIFF_TEMPORAL(24)<16;16,1>                     ubCURR_UV(30,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(25)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(25)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(31,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(31,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(31,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,144)<8;8,1>                         uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,152)<8;8,1>                         uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(25)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(25)<1>                  ubCURR_UV(31,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(25)<1>   wDIFF_TEMPORAL(25)<16;16,1>                     ubCURR_UV(31,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(26)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(26)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(32,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(32,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(32,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,160)<8;8,1>                         uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,168)<8;8,1>                         uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(26)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(26)<1>                  ubCURR_UV(32,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(26)<1>   wDIFF_TEMPORAL(26)<16;16,1>                     ubCURR_UV(32,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(27)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                                       (abs)wDIFF_TEMPORAL(27)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                                     ubCURR_UV(33,2)<8;8,1>                                  -uwCURBE_TEMP(1,8)<0;2,1>
+       mul (8) acc0.8<1>:w                                                                     ubCURR_UV(33,10)<8;8,1>                                 -uwCURBE_TEMP(1,10)<0;2,1>
+       mac (16)        acc0<1>:w                                                               ubCURR_UV(33,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                                     ubPREV_UV(8,176)<8;8,1>                         uwCURBE_TEMP(1,8)<0;2,1>
+       mac (8) acc0.8<1>:w                                                                     ubPREV_UV(8,184)<8;8,1>                         uwCURBE_TEMP(1,10)<0;2,1>
+       add (16)        acc0<1>:w                                                               acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(27)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(27)<1>                  ubCURR_UV(33,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                                      uwDIFF_TEMPORAL_SUM4x4_TEMP_2(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(27)<1>   wDIFF_TEMPORAL(27)<16;16,1>                     ubCURR_UV(33,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(28)<16;16,1>                        r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wDIFF_TEMPORAL(28)<16;16,1>                        r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(34,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(34,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(34,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,192)<8;8,1>                                 uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,200)<8;8,1>                                 uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wDIFF_TEMPORAL(28)<1>                  acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wDIFF_TEMPORAL(28)<1>                  ubCURR_UV(34,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wDIFF_TEMPORAL(28)<1>   wDIFF_TEMPORAL(28)<16;16,1>                             ubCURR_UV(34,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(4)<16;16,1>                            r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(4)<16;16,1>                            r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(35,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(35,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(35,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,208)<8;8,1>                         uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,216)<8;8,1>                         uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wCURBE_TEMP(4)<1>                              acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wCURBE_TEMP(4)<1>                              ubCURR_UV(35,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wCURBE_TEMP(4)<1>               wCURBE_TEMP(4)<16;16,1>                         ubCURR_UV(35,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(5)<16;16,1>                            r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(5)<16;16,1>                            r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(36,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(36,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(36,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,224)<8;8,1>                         uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,232)<8;8,1>                         uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wCURBE_TEMP(5)<1>                              acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wCURBE_TEMP(5)<1>                              ubCURR_UV(36,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wCURBE_TEMP(5)<1>               wCURBE_TEMP(5)<16;16,1>                         ubCURR_UV(36,2)<16;16,1>
+
+       cmp.l.f0.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(6)<16;16,1>                            r61.28<0;2,1>:ub
+       cmp.l.f1.0 (16) null<1>:w                                               (abs)wCURBE_TEMP(6)<16;16,1>                            r61.30<0;2,1>:ub
+       mul (8) acc0.0<1>:w                                                             ubCURR_UV(37,2)<8;8,1>                                  -uwCURBE_TEMP(1,12)<0;2,1>
+       mul (8) acc0.8<1>:w                                                             ubCURR_UV(37,10)<8;8,1>                                 -uwCURBE_TEMP(1,14)<0;2,1>
+       mac (16)        acc0<1>:w                                                       ubCURR_UV(37,2)<16;16,1>                                        256:w
+       mac (8) acc0.0<1>:w                                                             ubPREV_UV(8,240)<8;8,1>                         uwCURBE_TEMP(1,12)<0;2,1>
+       mac (8) acc0.8<1>:w                                                             ubPREV_UV(8,248)<8;8,1>                         uwCURBE_TEMP(1,14)<0;2,1>
+       add (16)        acc0<1>:w                                                       acc0<16;16,1>:w                                                         128:w
+       (f0.0) shr  (16) wCURBE_TEMP(6)<1>                              acc0<16;16,1>:w                                                         8:w
+       (-f0.0) mov (16) wCURBE_TEMP(6)<1>                              ubCURR_UV(37,2)<16;16,1>
+       cmp.le.f0.0 (16) null<1>:w                                              uwDIFF_TEMPORAL_SUM4x4_TEMP_3(0)<16;16,1>       r61.26<0;2,1>:ub
+       (-f0.0.allv) avg (16)   wCURBE_TEMP(6)<1>               wCURBE_TEMP(6)<16;16,1>                         ubCURR_UV(37,2)<16;16,1>
+
+       //Pack Weight History WORD -> BYTE
+       mov (16) ubCURBE_TEMP(3,0)<1>           ubCURBE_TEMP(0)<32;16,2>        
+       mov (16) ubCURBE_TEMP(3,16)<1>          ubCURBE_TEMP(1)<32;16,2>        
+
+
+
+//Module Name  : DN_UV_Compute_BNE_UV
+//Author               : Tatiya, Rupesh
+//Description  : Computes minimum SOAD for each 16x4 block.
+
+       cmp.l.f0.0  (8) null:w                                  uwSOAD_MIN_8x4(0,12)<16;4,1>    uwSOAD_MIN_8x4(2,12)<16;4,1>
+       (f0.0)sel       (8) uwCURBE_TEMP(1,0)<1>        uwSOAD_MIN_8x4(0,12)<16;4,1>    uwSOAD_MIN_8x4(2,12)<16;4,1>
+
+    mov  (8)   ubCURBE_TEMP(1)<1>                      ubCURBE_TEMP(1)<16;8,2>
+
+
+
+//File Name            : DN_UV_PL3_Unpack_Denoised_UV.asm
+//Author               : Tatiya, Rupesh
+//Description  : Upack the interleaved UV data
+
+//First 16 lines.
+       mov  (8)        ubMSGPAYLOAD_U(0,0)<1>          ubDIFF_TEMPORAL(0,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(0,16)<1> ubDIFF_TEMPORAL(1,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(0,0)<1>          ubDIFF_TEMPORAL(0,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(0,16)<1> ubDIFF_TEMPORAL(1,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(1,0)<1>          ubDIFF_TEMPORAL(2,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(1,16)<1> ubDIFF_TEMPORAL(3,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(1,0)<1>          ubDIFF_TEMPORAL(2,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(1,16)<1> ubDIFF_TEMPORAL(3,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(2,0)<1>          ubDIFF_TEMPORAL(4,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(2,16)<1> ubDIFF_TEMPORAL(5,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(2,0)<1>          ubDIFF_TEMPORAL(4,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(2,16)<1> ubDIFF_TEMPORAL(5,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(3,0)<1>          ubDIFF_TEMPORAL(6,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(3,16)<1> ubDIFF_TEMPORAL(7,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(3,0)<1>          ubDIFF_TEMPORAL(6,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(3,16)<1> ubDIFF_TEMPORAL(7,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(4,0)<1>          ubDIFF_TEMPORAL(8,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(4,16)<1> ubDIFF_TEMPORAL(9,0)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(4,0)<1>          ubDIFF_TEMPORAL(8,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_V(4,16)<1> ubDIFF_TEMPORAL(9,2)<32;8,4>            
+       mov  (8)        ubMSGPAYLOAD_U(5,0)<1>          ubDIFF_TEMPORAL(10,0)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_U(5,16)<1> ubDIFF_TEMPORAL(11,0)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_V(5,0)<1>          ubDIFF_TEMPORAL(10,2)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_V(5,16)<1> ubDIFF_TEMPORAL(11,2)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_U(6,0)<1>          ubDIFF_TEMPORAL(12,0)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_U(6,16)<1> ubDIFF_TEMPORAL(13,0)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_V(6,0)<1>          ubDIFF_TEMPORAL(12,2)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_V(6,16)<1> ubDIFF_TEMPORAL(13,2)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_U(7,0)<1>          ubDIFF_TEMPORAL(14,0)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_U(7,16)<1> ubDIFF_TEMPORAL(15,0)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_V(7,0)<1>          ubDIFF_TEMPORAL(14,2)<32;8,4>           
+       mov  (8)        ubMSGPAYLOAD_V(7,16)<1> ubDIFF_TEMPORAL(15,2)<32;8,4>           
+
+//Second 16 lines.
+//12 lines first
+       mov  (8)        ubMSGPAYLOAD_U(0,8)<1>          ubDIFF_TEMPORAL(16,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(0,24)<1> ubDIFF_TEMPORAL(17,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(0,8)<1>          ubDIFF_TEMPORAL(16,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(0,24)<1> ubDIFF_TEMPORAL(17,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(1,8)<1>          ubDIFF_TEMPORAL(18,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(1,24)<1> ubDIFF_TEMPORAL(19,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(1,8)<1>          ubDIFF_TEMPORAL(18,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(1,24)<1> ubDIFF_TEMPORAL(19,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(2,8)<1>          ubDIFF_TEMPORAL(20,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(2,24)<1> ubDIFF_TEMPORAL(21,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(2,8)<1>          ubDIFF_TEMPORAL(20,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(2,24)<1> ubDIFF_TEMPORAL(21,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(3,8)<1>          ubDIFF_TEMPORAL(22,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(3,24)<1> ubDIFF_TEMPORAL(23,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(3,8)<1>          ubDIFF_TEMPORAL(22,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(3,24)<1> ubDIFF_TEMPORAL(23,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(4,8)<1>          ubDIFF_TEMPORAL(24,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(4,24)<1> ubDIFF_TEMPORAL(25,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(4,8)<1>          ubDIFF_TEMPORAL(24,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(4,24)<1> ubDIFF_TEMPORAL(25,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(5,8)<1>          ubDIFF_TEMPORAL(26,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(5,24)<1> ubDIFF_TEMPORAL(27,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(5,8)<1>          ubDIFF_TEMPORAL(26,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(5,24)<1> ubDIFF_TEMPORAL(27,2)<32;8,4>   
+
+       //3 lines next
+       mov  (8)        ubMSGPAYLOAD_U(6,8)<1>          ubDIFF_TEMPORAL(28,0)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_U(6,24)<1>         ubCURBE_TEMP(4,0)<32;8,4>               
+       mov  (8)        ubMSGPAYLOAD_V(6,8)<1>          ubDIFF_TEMPORAL(28,2)<32;8,4>   
+       mov  (8)        ubMSGPAYLOAD_V(6,24)<1>         ubCURBE_TEMP(4,2)<32;8,4>               
+
+       mov  (8)        ubMSGPAYLOAD_U(7,8)<1>          ubCURBE_TEMP(5,0)<32;8,4>       
+    mov  (8)   ubMSGPAYLOAD_U(7,24)<1>         ubCURBE_TEMP(6,0)<32;8,4>       
+    mov  (8)   ubMSGPAYLOAD_V(7,8)<1>          ubCURBE_TEMP(5,2)<32;8,4>       
+    mov  (8)   ubMSGPAYLOAD_V(7,24)<1>         ubCURBE_TEMP(6,2)<32;8,4>       
+
+
+
+//Module Name  : DN_UV_420_Save_Curr_Frame_Y
+//Author               : Tatiya, Rupesh
+//Description  : Save Curr Frame Y data for 420 Input
+
+
+
+//Module Name  : DN_UV_Load_Curr_Frame_Y
+//Author               : Tatiya, Rupesh
+//Description  : Saves Y or YUY2 of Current frame.
+
+
+
+
+       mov (8)         acc0.0<1>:ud            r0.0<8;8,1>:ud
+       mov (2)         acc0.0<1>:d                     r62.10<2;2,1>:w
+
+       mov (1)         acc0.2<1>:d                     0xF000F:ud
+
+       mov (8)     r92.0<1>:ud acc0.0<8;8,1>:ud
+
+       mov (8)     r101.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r110.0<1>:ud        acc0.0<8;8,1>:ud
+       mov (8)     r119.0<1>:ud        acc0.0<8;8,1>:ud
+
+       add (1)         r101.1<1>:d     acc0.1<0;1,0>:d                 16:d
+
+       add (1)         r110.0<1>:d     acc0.0<0;1,0>:d                 16:d
+
+       add (2)         r119.0<1>:d     acc0.0<2;2,1>:d                 16:d
+
+       send (8)        null<1>:d       r92             0x5             0x120A8018:ud
+       send (8)        null<1>:d       r101            0x5             0x120A8018:ud
+       send (8)        null<1>:d       r110            0x5             0x120A8018:ud
+       send (8)        null<1>:d       r119            0x5             0x120A8018:ud
+
+
+       //TODO - See if History saving can be combined with Curr Frame Save. - rT
+
+
+//Module Name  : DN_UV_Save_Hist_UV
+//Author               : Tatiya, Rupesh
+//Description  : Saves DN history for UV data.
+
+       mov (8)  r3.0<1>:ud     r0.0<8;8,1>:ud
+       mov (2)  r3.0<1>:d      r62.12<2;2,1>:w                         
+       mov (1)  r3.2<1>:d      0x30007:ud              
+
+       send (8) null<1>:d      r3              0x5             0x40A8021:ud
+
+
+
+//Module Name  : DN_UV_Save_BNE_UV
+//Author               : Tatiya, Rupesh
+//Description  : Saves BNE values for 16x16 U and 16x16 V.
+
+       mov (8)  r1.0<1>:ud     r0.0<8;8,1>:ud
+       mov (2)  r1.0<1>:d              r63.12<2;2,1>:w                                 
+       mov (1)  r1.2<1>:d              0x10003:ud              
+
+       send (8) null<1>:d      r1              0x5             0x40A8023:ud
+
+
+
+//File Name    : DN_UV_PL3_Save_Curr_Frame_UV.asm
+//Author               : Tatiya, Rupesh
+//Description  : Save U and V data for PL3 surface
+
+
+
+//Module name  :  DN_UV_Save_Curr_Frame_UV
+//Author               :  Tatiya, Rupesh
+//Description  :  Saves Current Frame (UV only).
+
+
+
+
+       mov  (8) r74<1>:ud              r0.0<8;8,1>:ud
+       mov  (8) r83<1>:ud              r0.0<8;8,1>:ud
+
+       shr (2)  r74.0<1>:d             r62.10<2;2,1>:w                 1:w                     
+       mov (1)  r74.2<1>:d             0xF000F:ud              
+
+       mov (8)  r83.0<1>:ud            r74.0<8;8,1>:ud
+
+       send (8) null<1>:d      r74     0x5             0x120A8019:ud
+       send (8) null<1>:d      r83     0x5             0x120A801A:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+       //All sub-routines here
+
+
+// Module Name  : Noise_Detection
+// Author              : Tatiya, Rupesh
+// Description : Performs noise detection on 32 pixels of U (8x4) and 32 pixels of V (8x4).
+
+DN_UV_NOISE_DETECTION_UV:
+
+// Find Field Block Median
+//
+// Purpose   : Find the median value of the nine pixels in the same field
+//             which are centered at current pixel.
+//
+//             Works on 9 pixels centered at the current pixel
+//                NOTE: pixels are within same field.
+//                      v4 - current pixel
+//
+//                  v2 v1 v0
+//                   *  *  *     <--- Different field - not used
+//                  v5 v4 v3
+//                   *  *  *     <--- Different field - not used
+//                  v8 v7 v6
+
+// Algorithm to find median modifies the data.
+// Copy the data needed to calculate median so the original source data stays intact.
+//
+
+//TODO - Change Interleaved implementation to separated one if - ,  does not work on predication. - rT
+
+//Delete Later - rT
+//mov (1) pCUR_UV:uw           52*32:uw
+
+// v0
+mov (16) ubMEDIAN_TEMP(0,0)<1>         r[a0.0,0]<16;16,1>              
+// v0
+mov (16) ubMEDIAN_TEMP(0,16)<1>        r[a0.0,32]<16;16,1>             
+// v1
+mov (16) ubMEDIAN_TEMP(1,0)<1>         r[a0.0,2]<16;16,1>              
+// v1
+mov (16) ubMEDIAN_TEMP(1,16)<1>        r[a0.0,34]<16;16,1>             
+// v2
+mov (16) ubMEDIAN_TEMP(2,0)<1>         r[a0.0,4]<16;16,1>              
+// v2
+mov (16) ubMEDIAN_TEMP(2,16)<1>        r[a0.0,36]<16;16,1>             
+// v3
+mov (16) ubMEDIAN_TEMP(3,0)<1>         r[a0.0,64]<16;16,1>     
+// v3
+mov (16) ubMEDIAN_TEMP(3,16)<1>        r[a0.0,96]<16;16,1>             
+// v4
+mov (16) ubMEDIAN_TEMP(4,0)<1>         r[a0.0,66]<16;16,1>     
+// v4
+mov (16) ubMEDIAN_TEMP(4,16)<1>        r[a0.0,98]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(5,0)<1>         r[a0.0,68]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(5,16)<1>        r[a0.0,100]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(6,0)<1>         r[a0.0,128]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(6,16)<1>        r[a0.0,160]<16;16,1>            
+// v7
+mov (16) ubMEDIAN_TEMP(7,0)<1>         r[a0.0,130]<16;16,1>    
+// v7
+mov (16) ubMEDIAN_TEMP(7,16)<1>        r[a0.0,162]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(8,0)<1>         r[a0.0,132]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(8,16)<1>        r[a0.0,164]<16;16,1>    
+
+//TODO - Optimize one instruction here.
+add (1)  a0.0:uw               a0.0<0;1,0>:uw 64:uw
+// v0
+mov (16) ubMEDIAN_TEMP(9,0)<1>         r[a0.0,0]<16;16,1>              
+// v0
+mov (16) ubMEDIAN_TEMP(9,16)<1>        r[a0.0,32]<16;16,1>             
+// v1
+mov (16) ubMEDIAN_TEMP(10,0)<1>        r[a0.0,2]<16;16,1>              
+// v1
+mov (16) ubMEDIAN_TEMP(10,16)<1>       r[a0.0,34]<16;16,1>             
+// v2
+mov (16) ubMEDIAN_TEMP(11,0)<1>        r[a0.0,4]<16;16,1>              
+// v2
+mov (16) ubMEDIAN_TEMP(11,16)<1>       r[a0.0,36]<16;16,1>             
+// v3
+mov (16) ubMEDIAN_TEMP(12,0)<1>        r[a0.0,64]<16;16,1>     
+// v3
+mov (16) ubMEDIAN_TEMP(12,16)<1>       r[a0.0,96]<16;16,1>             
+// v4
+mov (16) ubMEDIAN_TEMP(13,0)<1>                r[a0.0,66]<16;16,1>     
+// v4
+mov (16) ubMEDIAN_TEMP(13,16)<1>       r[a0.0,98]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(14,0)<1>                r[a0.0,68]<16;16,1>     
+// v5
+mov (16) ubMEDIAN_TEMP(14,16)<1>       r[a0.0,100]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(15,0)<1>        r[a0.0,128]<16;16,1>    
+// v6
+mov (16) ubMEDIAN_TEMP(15,16)<1>       r[a0.0,160]<16;16,1>            
+// v7
+mov (16) ubMEDIAN_TEMP(16,0)<1>                r[a0.0,130]<16;16,1>    
+// v7
+mov (16) ubMEDIAN_TEMP(16,16)<1>       r[a0.0,162]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(17,0)<1>                r[a0.0,132]<16;16,1>    
+// v8
+mov (16) ubMEDIAN_TEMP(17,16)<1>       r[a0.0,164]<16;16,1>    
+
+//TODO - Optimize one instruction here.
+add (1)  a0.0:uw               a0.0<0;1,0>:uw 64:uw
+
+// MedianSwap
+//
+//  MedianSwap(inOutLeft, inOutRight)
+//  {
+//      if (inOutLeft > inOutRight)
+//      {
+//          temp = inOutLeft
+//          inOutLeft = inOutRight
+//          inOutRight = temp
+//      }
+//  }
+
+// MedianSwap(v1, v2) - U
+// MedianSwap(v4, v5) - U
+// MedianSwap(v1, v2) - V
+// MedianSwap(v4, v5) - V
+
+cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(1,0)<32;16,2>  ubMEDIAN_TEMP(2,0)<32;16,2>
+cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>  ubMEDIAN_TEMP(5,0)<32;16,2>
+cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(1,1)<32;16,2>    ubMEDIAN_TEMP(2,1)<32;16,2>
+cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>    ubMEDIAN_TEMP(5,1)<32;16,2>
+
+               mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(1,0)<32;16,2>       
+               mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,0)<32;16,2>       
+               mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(1,1)<32;16,2>       
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>       
+
+(f0.0) mov (16) ubMEDIAN_TEMP(1,0)<2>          ubMEDIAN_TEMP(2,0)<32;16,2>             
+(f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>          ubMEDIAN_TEMP(5,0)<32;16,2>             
+(f1.0) mov (16) ubMEDIAN_TEMP(1,1)<2>                  ubMEDIAN_TEMP(2,1)<32;16,2>             
+(f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>          ubMEDIAN_TEMP(5,1)<32;16,2>             
+
+(f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubTEMP1(0,0)<16;16,1>                
+(f0.1) mov (16) ubMEDIAN_TEMP(5,0)<2>     ubTEMP1(0,16)<16;16,1>               
+(f1.0) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubTEMP1(1,0)<16;16,1>                
+(f1.1) mov (16) ubMEDIAN_TEMP(5,1)<2>     ubTEMP1(1,16)<16;16,1>       
+
+// MedianSwap(v7, v8) - U
+// MedianSwap(v0, v1) - U
+// MedianSwap(v7, v8) - V
+// MedianSwap(v0, v1) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(7,0)<32;16,2>           ubMEDIAN_TEMP(8,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(0,0)<32;16,2>   ubMEDIAN_TEMP(1,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(7,1)<32;16,2>   ubMEDIAN_TEMP(8,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(0,1)<32;16,2>   ubMEDIAN_TEMP(1,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(7,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(0,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(7,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(0,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(7,0)<2>   ubMEDIAN_TEMP(8,0)<32;16,2>      
+ (f0.1) mov (16) ubMEDIAN_TEMP(0,0)<2> ubMEDIAN_TEMP(1,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(7,1)<2>         ubMEDIAN_TEMP(8,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(0,1)<2> ubMEDIAN_TEMP(1,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(8,0)<2>     ubTEMP1(0,0)<16;16,1>          
+ (f0.1) mov (16) ubMEDIAN_TEMP(1,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(8,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(1,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v3, v4) - U
+ // MedianSwap(v6, v7) - U
+ // MedianSwap(v3, v4) - V
+ // MedianSwap(v6, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(3,0)<32;16,2>           ubMEDIAN_TEMP(4,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(6,0)<32;16,2>   ubMEDIAN_TEMP(7,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(3,1)<32;16,2>   ubMEDIAN_TEMP(4,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(6,1)<32;16,2>   ubMEDIAN_TEMP(7,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(3,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(6,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(3,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(6,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(3,0)<2>   ubMEDIAN_TEMP(4,0)<32;16,2>      
+ (f0.1) mov (16) ubMEDIAN_TEMP(6,0)<2> ubMEDIAN_TEMP(7,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(3,1)<2>         ubMEDIAN_TEMP(4,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(6,1)<2> ubMEDIAN_TEMP(7,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(7,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(4,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(7,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v1, v2) - U
+ // MedianSwap(v4, v5) - U
+ // MedianSwap(v1, v2) - V
+ // MedianSwap(v4, v5) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(1,0)<32;16,2>           ubMEDIAN_TEMP(2,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>   ubMEDIAN_TEMP(5,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(1,1)<32;16,2>   ubMEDIAN_TEMP(2,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(5,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(1,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(1,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(1,0)<2>   ubMEDIAN_TEMP(2,0)<32;16,2>           
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2> ubMEDIAN_TEMP(5,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(1,1)<2>         ubMEDIAN_TEMP(2,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2> ubMEDIAN_TEMP(5,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(5,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(5,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v7, v8) - U
+ // MedianSwap(v0, v3) - U
+ // MedianSwap(v7, v8) - V
+ // MedianSwap(v0, v3) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(7,0)<32;16,2>           ubMEDIAN_TEMP(8,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(0,0)<32;16,2>   ubMEDIAN_TEMP(3,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(7,1)<32;16,2>   ubMEDIAN_TEMP(8,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(0,1)<32;16,2>   ubMEDIAN_TEMP(3,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(7,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(0,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(7,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(0,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(7,0)<2>   ubMEDIAN_TEMP(8,0)<32;16,2>           
+ (f0.1) mov (16) ubMEDIAN_TEMP(0,0)<2> ubMEDIAN_TEMP(3,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(7,1)<2>         ubMEDIAN_TEMP(8,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(0,1)<2> ubMEDIAN_TEMP(3,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(8,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(3,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(8,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(3,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // NOTE:
+ // Compare v0 to v6 to find the minimum.
+ // Store the minimum for future use.
+ //TODO - Find if MIN is needed.
+ //cmp.l.f0.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,0)<32;16,2>  ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //cmp.l.f1.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,1)<32;16,2>  ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+ //(f0.0)  mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,0)<32;16,2>
+ //(f1.0)  mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,1)<32;16,2>
+ //(-f0.0) mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //(-f1.0) mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+
+ // MedianSwap(v5, v8) - U
+ // MedianSwap(v4, v7) - U
+ // MedianSwap(v5, v8) - V
+ // MedianSwap(v4, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(5,0)<32;16,2>           ubMEDIAN_TEMP(8,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>   ubMEDIAN_TEMP(7,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(5,1)<32;16,2>   ubMEDIAN_TEMP(8,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(7,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(5,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(5,1)<32;16,2>              
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(5,0)<2>         ubMEDIAN_TEMP(8,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(7,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(5,1)<2>         ubMEDIAN_TEMP(8,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(7,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(8,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(7,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(8,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(7,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+// NOTE:
+// Compare v2 to v8 to find the maximum.
+// Store the maximum for future use.
+ //TODO - Find if MAX is needed.
+// cmp.g.f0.0  (16) null:w         ubMEDIAN_TEMP(%1+2,0)<32;16,2> ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+// cmp.g.f1.0  (16) null:w         ubMEDIAN_TEMP(%1+2,1)<32;16,2> ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+//(f0.0)  mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,0)<32;16,2>
+//(f1.0)  mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,1)<32;16,2>
+//(-f0.0) mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+//(-f1.0) mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+
+// MedianSwap(v3, v6) - U
+// MedianSwap(v1, v4) - U
+// MedianSwap(v3, v6) - V
+// MedianSwap(v1, v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(3,0)<32;16,2>           ubMEDIAN_TEMP(6,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(1,0)<32;16,2>   ubMEDIAN_TEMP(4,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(3,1)<32;16,2>   ubMEDIAN_TEMP(6,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(1,1)<32;16,2>   ubMEDIAN_TEMP(4,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(6,0)<2>     ubMEDIAN_TEMP(3,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>     ubMEDIAN_TEMP(1,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(6,1)<2>     ubMEDIAN_TEMP(3,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>     ubMEDIAN_TEMP(1,1)<32;16,2>      
+
+ // MedianSwap(v2,v5) - U
+ // MedianSwap(v4,v7) - U
+ // MedianSwap(v2,v5) - V
+ // MedianSwap(v4,v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(2,0)<32;16,2>           ubMEDIAN_TEMP(5,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>   ubMEDIAN_TEMP(7,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(2,1)<32;16,2>   ubMEDIAN_TEMP(5,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(7,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubMEDIAN_TEMP(5,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,0)<2>     ubMEDIAN_TEMP(7,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubMEDIAN_TEMP(5,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(4,1)<2>     ubMEDIAN_TEMP(7,1)<32;16,2>      
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>           ubMEDIAN_TEMP(2,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(2,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(4,0)<32;16,2>              
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(4,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(2,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(2,1)<32;16,2>             
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(2,0)<2>     ubTEMP1(0,0)<16;16,1>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(2,1)<2>     ubTEMP1(0,16)<16;16,1>      
+
+ // MedianSwap(v6,v4) - U
+ // MedianSwap(v6,v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(6,0)<32;16,2>   ubMEDIAN_TEMP(4,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(6,1)<32;16,2>   ubMEDIAN_TEMP(4,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(6,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(6,1)<32;16,2>             
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(4,0)<32;16,2>           ubMEDIAN_TEMP(2,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(4,1)<32;16,2>   ubMEDIAN_TEMP(2,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(4,0)<2>         ubMEDIAN_TEMP(2,0)<32;16,2>             
+ (f0.1) mov (16) ubMEDIAN_TEMP(4,1)<2>         ubMEDIAN_TEMP(2,1)<32;16,2>             
+cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(10,0)<32;16,2>  ubMEDIAN_TEMP(11,0)<32;16,2>
+cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>  ubMEDIAN_TEMP(14,0)<32;16,2>
+cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(10,1)<32;16,2>   ubMEDIAN_TEMP(11,1)<32;16,2>
+cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>   ubMEDIAN_TEMP(14,1)<32;16,2>
+
+               mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(10,0)<32;16,2>      
+               mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,0)<32;16,2>      
+               mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(10,1)<32;16,2>      
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>      
+
+(f0.0) mov (16) ubMEDIAN_TEMP(10,0)<2>         ubMEDIAN_TEMP(11,0)<32;16,2>            
+(f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>         ubMEDIAN_TEMP(14,0)<32;16,2>            
+(f1.0) mov (16) ubMEDIAN_TEMP(10,1)<2>                 ubMEDIAN_TEMP(11,1)<32;16,2>            
+(f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>         ubMEDIAN_TEMP(14,1)<32;16,2>            
+
+(f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubTEMP1(0,0)<16;16,1>               
+(f0.1) mov (16) ubMEDIAN_TEMP(14,0)<2>     ubTEMP1(0,16)<16;16,1>              
+(f1.0) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubTEMP1(1,0)<16;16,1>               
+(f1.1) mov (16) ubMEDIAN_TEMP(14,1)<2>     ubTEMP1(1,16)<16;16,1>      
+
+// MedianSwap(v7, v8) - U
+// MedianSwap(v0, v1) - U
+// MedianSwap(v7, v8) - V
+// MedianSwap(v0, v1) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(16,0)<32;16,2>          ubMEDIAN_TEMP(17,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(9,0)<32;16,2>   ubMEDIAN_TEMP(10,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(16,1)<32;16,2>  ubMEDIAN_TEMP(17,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(9,1)<32;16,2>   ubMEDIAN_TEMP(10,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(16,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(9,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(16,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(9,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(16,0)<2>   ubMEDIAN_TEMP(17,0)<32;16,2>    
+ (f0.1) mov (16) ubMEDIAN_TEMP(9,0)<2> ubMEDIAN_TEMP(10,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(16,1)<2>        ubMEDIAN_TEMP(17,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(9,1)<2> ubMEDIAN_TEMP(10,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(17,0)<2>     ubTEMP1(0,0)<16;16,1>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(10,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(17,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(10,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v3, v4) - U
+ // MedianSwap(v6, v7) - U
+ // MedianSwap(v3, v4) - V
+ // MedianSwap(v6, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(12,0)<32;16,2>          ubMEDIAN_TEMP(13,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(15,0)<32;16,2>          ubMEDIAN_TEMP(16,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(12,1)<32;16,2>  ubMEDIAN_TEMP(13,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(15,1)<32;16,2>  ubMEDIAN_TEMP(16,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(12,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(15,0)<32;16,2>             
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(12,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(15,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(12,0)<2>   ubMEDIAN_TEMP(13,0)<32;16,2>    
+ (f0.1) mov (16) ubMEDIAN_TEMP(15,0)<2>        ubMEDIAN_TEMP(16,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(12,1)<2>        ubMEDIAN_TEMP(13,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(15,1)<2>        ubMEDIAN_TEMP(16,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(16,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(13,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(16,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v1, v2) - U
+ // MedianSwap(v4, v5) - U
+ // MedianSwap(v1, v2) - V
+ // MedianSwap(v4, v5) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(10,0)<32;16,2>          ubMEDIAN_TEMP(11,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(14,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(10,1)<32;16,2>  ubMEDIAN_TEMP(11,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>  ubMEDIAN_TEMP(14,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(10,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,0)<32;16,2>             
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(10,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(10,0)<2>   ubMEDIAN_TEMP(11,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(14,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(10,1)<2>        ubMEDIAN_TEMP(11,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>        ubMEDIAN_TEMP(14,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(14,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(14,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // MedianSwap(v7, v8) - U
+ // MedianSwap(v0, v3) - U
+ // MedianSwap(v7, v8) - V
+ // MedianSwap(v0, v3) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(16,0)<32;16,2>          ubMEDIAN_TEMP(17,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(9,0)<32;16,2>   ubMEDIAN_TEMP(12,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(16,1)<32;16,2>  ubMEDIAN_TEMP(17,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(9,1)<32;16,2>   ubMEDIAN_TEMP(12,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(16,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(9,0)<32;16,2>              
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(16,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(9,1)<32;16,2>               
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(16,0)<2>   ubMEDIAN_TEMP(17,0)<32;16,2>         
+ (f0.1) mov (16) ubMEDIAN_TEMP(9,0)<2> ubMEDIAN_TEMP(12,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(16,1)<2>        ubMEDIAN_TEMP(17,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(9,1)<2> ubMEDIAN_TEMP(12,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(17,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(12,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(17,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(12,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+ // NOTE:
+ // Compare v0 to v6 to find the minimum.
+ // Store the minimum for future use.
+ //TODO - Find if MIN is needed.
+ //cmp.l.f0.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,0)<32;16,2>  ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //cmp.l.f1.0  (16) null:w                             ubMEDIAN_TEMP(%1+0,1)<32;16,2>  ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+ //(f0.0)  mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,0)<32;16,2>
+ //(f1.0)  mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+0,1)<32;16,2>
+ //(-f0.0) mov (16) ubCURR_MIN(0,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,0)<32;16,2>
+ //(-f1.0) mov (16) ubCURR_MIN(1,%2*16+0)<1>                   ubMEDIAN_TEMP(%1+6,1)<32;16,2>
+
+ // MedianSwap(v5, v8) - U
+ // MedianSwap(v4, v7) - U
+ // MedianSwap(v5, v8) - V
+ // MedianSwap(v4, v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(14,0)<32;16,2>          ubMEDIAN_TEMP(17,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(16,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(14,1)<32;16,2>  ubMEDIAN_TEMP(17,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>  ubMEDIAN_TEMP(16,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(14,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,0)<32;16,2>             
+        mov (16) ubTEMP1(1,0)<1>      ubMEDIAN_TEMP(14,1)<32;16,2>             
+               mov (16) ubTEMP1(1,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>              
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(14,0)<2>        ubMEDIAN_TEMP(17,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>                ubMEDIAN_TEMP(16,0)<32;16,2>     
+ (f1.0) mov (16) ubMEDIAN_TEMP(14,1)<2>        ubMEDIAN_TEMP(17,1)<32;16,2>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(16,1)<32;16,2>     
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(17,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(16,0)<2>     ubTEMP1(0,16)<16;16,1>    
+ (f1.0) mov (16) ubMEDIAN_TEMP(17,1)<2>     ubTEMP1(1,0)<16;16,1>     
+ (f1.1) mov (16) ubMEDIAN_TEMP(16,1)<2>     ubTEMP1(1,16)<16;16,1>    
+
+// NOTE:
+// Compare v2 to v8 to find the maximum.
+// Store the maximum for future use.
+ //TODO - Find if MAX is needed.
+// cmp.g.f0.0  (16) null:w         ubMEDIAN_TEMP(%1+2,0)<32;16,2> ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+// cmp.g.f1.0  (16) null:w         ubMEDIAN_TEMP(%1+2,1)<32;16,2> ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+//(f0.0)  mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,0)<32;16,2>
+//(f1.0)  mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+2,1)<32;16,2>
+//(-f0.0) mov (16) ubCURR_MAX(0,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,0)<32;16,2>
+//(-f1.0) mov (16) ubCURR_MAX(1,%2*16+0)<1>    ubMEDIAN_TEMP(%1+8,1)<32;16,2>
+
+// MedianSwap(v3, v6) - U
+// MedianSwap(v1, v4) - U
+// MedianSwap(v3, v6) - V
+// MedianSwap(v1, v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(12,0)<32;16,2>          ubMEDIAN_TEMP(15,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(10,0)<32;16,2>          ubMEDIAN_TEMP(13,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(12,1)<32;16,2>  ubMEDIAN_TEMP(15,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(10,1)<32;16,2>  ubMEDIAN_TEMP(13,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(15,0)<2>     ubMEDIAN_TEMP(12,0)<32;16,2>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>     ubMEDIAN_TEMP(10,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(15,1)<2>     ubMEDIAN_TEMP(12,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>     ubMEDIAN_TEMP(10,1)<32;16,2>      
+
+ // MedianSwap(v2,v5) - U
+ // MedianSwap(v4,v7) - U
+ // MedianSwap(v2,v5) - V
+ // MedianSwap(v4,v7) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(11,0)<32;16,2>          ubMEDIAN_TEMP(14,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(16,0)<32;16,2>
+ cmp.g.f1.0 (16) null:w          ubMEDIAN_TEMP(11,1)<32;16,2>  ubMEDIAN_TEMP(14,1)<32;16,2>
+ cmp.g.f1.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>  ubMEDIAN_TEMP(16,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubMEDIAN_TEMP(14,0)<32;16,2>               
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,0)<2>     ubMEDIAN_TEMP(16,0)<32;16,2>      
+ (f1.0) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubMEDIAN_TEMP(14,1)<32;16,2>      
+ (f1.1) mov (16) ubMEDIAN_TEMP(13,1)<2>     ubMEDIAN_TEMP(16,1)<32;16,2>      
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(11,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>          ubMEDIAN_TEMP(11,1)<32;16,2>
+
+        mov (16) ubTEMP1(0,0)<1>      ubMEDIAN_TEMP(13,0)<32;16,2>             
+        mov (16) ubTEMP1(0,16)<1>     ubMEDIAN_TEMP(13,1)<32;16,2>             
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(11,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(11,1)<32;16,2>            
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(11,0)<2>     ubTEMP1(0,0)<16;16,1>              
+ (f0.1) mov (16) ubMEDIAN_TEMP(11,1)<2>     ubTEMP1(0,16)<16;16,1>     
+
+ // MedianSwap(v6,v4) - U
+ // MedianSwap(v6,v4) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(15,0)<32;16,2>   ubMEDIAN_TEMP(13,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(15,1)<32;16,2>   ubMEDIAN_TEMP(13,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(15,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(15,1)<32;16,2>            
+
+ // MedianSwap(v4,v2) - U
+ // MedianSwap(v4,v2) - V
+ cmp.g.f0.0 (16) null:w          ubMEDIAN_TEMP(13,0)<32;16,2>          ubMEDIAN_TEMP(11,0)<32;16,2>
+ cmp.g.f0.1 (16) null:w          ubMEDIAN_TEMP(13,1)<32;16,2>          ubMEDIAN_TEMP(11,1)<32;16,2>
+
+ (f0.0) mov (16) ubMEDIAN_TEMP(13,0)<2>        ubMEDIAN_TEMP(11,0)<32;16,2>            
+ (f0.1) mov (16) ubMEDIAN_TEMP(13,1)<2>                ubMEDIAN_TEMP(11,1)<32;16,2>            
+
+// Sobel Value calculation for the current pixel v4
+//          v2 v1 v0
+//           *  *  *     <--- Different field - not used
+//          v5 v4 v3
+//           *  *  *     <--- Different field - not used
+//          v8 v7 v6
+//
+//    Gx = -v0 - 2*v3 - v6 + v2 + 2*v5 + v8
+//    Gy =  v0 + 2*v1 + v2 - v6 - 2*v7 - v8
+//
+//  Sobel = (|Gx| + |Gy|) >> 3
+
+//TODO - Change Later - rT
+add (1) a0.0:uw  a0.0<0;1,0>:uw -128:uw
+
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,64]<16;16,1>:ub                  -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,132]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,0]<16;16,1>:ub           -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,128]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,4]<16;16,1>:ub                   1:w
+// + 2 * v5
+mac (16) wSOBEL_X(0)<1>        r[a0.0,68]<16;16,1>:ub                  2:w
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,96]<16;16,1>:ub                  -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,164]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,32]<16;16,1>:ub                  -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,160]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,36]<16;16,1>:ub                  1:w
+// + 2 * v5
+mac (16) wSOBEL_X(1)<1>        r[a0.0,100]<16;16,1>:ub                 2:w
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,128]<16;16,1>:ub                 -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,196]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,64]<16;16,1>:ub                  -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,192]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,68]<16;16,1>:ub                  1:w
+// + 2 * v5
+mac (16) wSOBEL_X(2)<1>        r[a0.0,132]<16;16,1>:ub                 2:w
+// - 2 * v3
+mul (16) acc0.0<1>:w           r[a0.0,160]<16;16,1>:ub                 -2:w
+// + v8
+mac (16) acc0.0<1>:w           r[a0.0,228]<16;16,1>:ub                 1:w
+// - v0
+mac (16) acc0.0<1>:w           r[a0.0,96]<16;16,1>:ub                  -1:w
+// - v6
+mac (16) acc0.0<1>:w           r[a0.0,224]<16;16,1>:ub                 -1:w
+// + v2
+mac (16) acc0.0<1>:w           r[a0.0,100]<16;16,1>:ub                 1:w
+// + 2 * v5
+mac (16) wSOBEL_X(3)<1>        r[a0.0,164]<16;16,1>:ub                 2:w
+
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,2]<16;16,1>:ub    2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,0]<16;16,1>:ub    1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,132]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,4]<16;16,1>:ub    1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,128]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,130]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(0)<16;16,1>
+
+shr (16) uwSOBEL(0)<1> acc0.0<16;16,1>:uw   3:uw
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,34]<16;16,1>:ub           2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,32]<16;16,1>:ub           1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,164]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,36]<16;16,1>:ub           1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,160]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,162]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(1)<16;16,1>
+
+shr (16) uwSOBEL(1)<1> acc0.0<16;16,1>:uw   3:uw
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,66]<16;16,1>:ub           2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,64]<16;16,1>:ub           1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,196]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,68]<16;16,1>:ub           1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,192]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,194]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(2)<16;16,1>
+
+shr (16) uwSOBEL(2)<1> acc0.0<16;16,1>:uw   3:uw
+// + 2 * v1
+mul (16) acc0.0<1>:w  r[a0.0,98]<16;16,1>:ub           2:w
+// + v0
+mac (16) acc0.0<1>:w  r[a0.0,96]<16;16,1>:ub           1:w
+// - v8
+mac (16) acc0.0<1>:w  r[a0.0,228]<16;16,1>:ub  -1:w
+// + v2
+mac (16) acc0.0<1>:w  r[a0.0,100]<16;16,1>:ub          1:w
+// - v6
+mac (16) acc0.0<1>:w  r[a0.0,224]<16;16,1>:ub  -1:w
+// - 2 * v7
+mac (16) acc0.0<1>:w  r[a0.0,226]<16;16,1>:ub  -2:w
+
+add (16) acc0.0<1>:uw (abs)acc0.0<16;16,1>:w           (abs)wSOBEL_X(3)<16;16,1>
+
+shr (16) uwSOBEL(3)<1> acc0.0<16;16,1>:uw   3:uw
+
+//Mov Median in CURBE_TEMP to free up temp space.
+mov (16)       ubMEDIAN(0,0)<1>        ubMEDIAN_TEMP(4,0)<16;16,1>             
+mov (16)       ubMEDIAN(0,16)<1> ubMEDIAN_TEMP(4,16)<16;16,1>          
+mov (16)       ubMEDIAN(0,32)<1>       ubMEDIAN_TEMP(13,0)<16;16,1>            
+mov (16)       ubMEDIAN(0,48)<1> ubMEDIAN_TEMP(13,16)<16;16,1>         
+
+// Find:
+//      absDiff = abs(ubCurY - ubMedian)
+// Find the difference between pixel and median value.
+
+//Median is interleaved. So difference is also interleaved.
+
+//------------------------------------------------------------------------------------------
+//Process 16 U and 16 V pixels here and rest later.
+// first row - v0,v1,v2
+add (16) wDIFF(0)<1>   r[a0.0,0]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(1)<1>   r[a0.0,2]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(2)<1>   r[a0.0,4]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+
+// second row - v3,v4,v5
+add (16) wDIFF(3)<1>   r[a0.0,64]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(4)<1>   r[a0.0,66]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(5)<1>   r[a0.0,68]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+
+// third row - v6,v7,v8
+add (16) wDIFF(6)<1>   r[a0.0,128]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(7)<1>   r[a0.0,130]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+add (16) wDIFF(8)<1>   r[a0.0,132]<16;16,1>:ub  -ubMEDIAN(0,0)<16;16,1>
+// first row - v0,v1,v2
+add (16) wDIFF(9)<1>   r[a0.0,32]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(10)<1>   r[a0.0,34]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(11)<1>   r[a0.0,36]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+
+// second row - v3,v4,v5
+add (16) wDIFF(12)<1>   r[a0.0,96]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(13)<1>   r[a0.0,98]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(14)<1>   r[a0.0,100]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+
+// third row - v6,v7,v8
+add (16) wDIFF(15)<1>   r[a0.0,160]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(16)<1>   r[a0.0,162]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+add (16) wDIFF(17)<1>   r[a0.0,164]<16;16,1>:ub  -ubMEDIAN(0,16)<16;16,1>
+
+//TODO - Change Later - rT
+add (1) a0.0:uw  a0.0<0;1,0>:uw 64:uw
+
+// Find sum of all absolute differences AND
+// maximum absolute difference for 16 U and 16 V here.
+//First 2 rows of 8x4
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(0)<16;16,1>  (abs)wDIFF(1)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(2)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(3)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(4)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(5)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(6)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(7)<16;16,1>
+       add        (16) uwSOAD(0)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(8)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//------------
+       //DIFF(0-7) is not needed here. Populate it.
+       // first row - v0,v1,v2
+       add (16) wDIFF(0)<1>   r[a0.0,0]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(1)<1>   r[a0.0,2]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(2)<1>   r[a0.0,4]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+
+       // second row - v3,v4,v5
+       add (16) wDIFF(3)<1>   r[a0.0,64]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(4)<1>   r[a0.0,66]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(5)<1>   r[a0.0,68]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+
+       // third row - v6,v7
+       add (16) wDIFF(6)<1>   r[a0.0,128]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+       add (16) wDIFF(7)<1>   r[a0.0,130]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+//------------
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(0)<1> uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+
+//------------
+       //Load v8 - DIFF(8)
+       add (16) wDIFF(8)<1>                    r[a0.0,132]<16;16,1>:ub  -ubMEDIAN(1,0)<16;16,1>
+//------------
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(9)<16;16,1>  (abs)wDIFF(10)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(11)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(12)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(13)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(14)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(15)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(16)<16;16,1>
+       add        (16) uwSOAD(1)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(17)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//------------
+       //DIFF(0-7) is not needed here. Populate it.
+       // first row - v0,v1,v2
+       add (16) wDIFF(9)<1>   r[a0.0,32]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(10)<1>   r[a0.0,34]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(11)<1>   r[a0.0,36]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+
+       // second row - v3,v4,v5
+       add (16) wDIFF(12)<1>   r[a0.0,96]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(13)<1>   r[a0.0,98]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(14)<1>   r[a0.0,100]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+
+       // third row - v6,v7
+       add (16) wDIFF(15)<1>   r[a0.0,160]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+       add (16) wDIFF(16)<1>   r[a0.0,162]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+//------------
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(1)<1> uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+
+//------------
+       //Load v8 - DIFF(8)
+       add (16) wDIFF(17)<1>                           r[a0.0,164]<16;16,1>:ub  -ubMEDIAN(1,16)<16;16,1>
+//------------
+
+//if ((sobel_edge_measure < m_SobelEdgeThreshold) && ((block_max-block_min) < m_LocalDiffThreshold))
+//                                             if (sigma_mb_min > sigma)
+//                                                     sigma_mb_min = sigma;
+
+//NOTE: block_min is always zero as median is one of the value in 3x3 block. So no need o calculate it.
+//             So just do -
+//if ((sobel_edge_measure < m_SobelEdgeThreshold) && ((block_max) < m_LocalDiffThreshold) && ( sigma < sigma_mb_min))
+//                                                     sigma_mb_min = sigma;
+
+//We are processing 32 bytes of U and 32 bytes of V - each of size 8x4.
+//Compare first 8 bytes with max possible (255).
+//Start above condition from second 8 bytes.
+
+//TODO - Change Later - rT
+//     mov (1) pCUR_MIN_SOAD_8x4:uw    1752:uw         //r54.24:ub
+
+//First row of 8x4
+        cmp.l.f0.0     (16) null:uw                    uwSOBEL(0)<16;16,1>         r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(0)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(0)<16;16,1>                      255:uw
+(f0.0)  sel            (16) uwSOBEL(0)<1>   uwSOAD(0)<16;16,1>                 255:uw
+
+//Second row of 8x4
+               cmp.l.f0.0      (16) null:uw                    uwSOBEL(1)<16;16,1>         r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(1)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(1)<16;16,1>                      uwSOBEL(0)<16;16,1>
+(f0.0)  mov            (16) uwSOBEL(0)<1>   uwSOAD(1)<16;16,1>
+
+// Find sum of all absolute differences AND
+// maximum absolute difference for 16 U and 16 V here.
+//Second 2 rows of 8x4
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(0)<16;16,1>  (abs)wDIFF(1)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(2)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(3)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(4)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(5)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(6)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(7)<16;16,1>
+       add        (16) uwSOAD(0)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(8)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(0)<16;16,1>   (abs)wDIFF(1)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(2)<16;16,1>   (abs)wDIFF(3)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(4)<16;16,1>   (abs)wDIFF(5)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(6)<16;16,1>   (abs)wDIFF(7)<16;16,1>
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(0)<1>   uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(8)<16;16,1>
+//Compare 0-1, 2-3, 4-5, 6-7
+cmp.g.f0.0 (16) null:uw         (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+cmp.g.f0.1 (16) null:uw         (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+cmp.g.f1.0 (16) null:uw         (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+cmp.g.f1.1 (16) null:uw         (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//Calculate SAD
+       add        (16) acc0.0<1>:uw     (abs)wDIFF(9)<16;16,1>  (abs)wDIFF(10)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(11)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(12)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(13)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(14)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(15)<16;16,1>
+       add        (16) acc0.0<1>:uw     acc0.0<16;16,1>:uw             (abs)wDIFF(16)<16;16,1>
+       add        (16) uwSOAD(1)<1>     acc0.0<16;16,1>:uw             (abs)wDIFF(17)<16;16,1>
+
+(f0.0) sel (16) uwCURBE_TEMP(0)<1> (abs)wDIFF(9)<16;16,1>   (abs)wDIFF(10)<16;16,1>
+(f0.1) sel (16) uwCURBE_TEMP(1)<1> (abs)wDIFF(11)<16;16,1>   (abs)wDIFF(12)<16;16,1>
+(f1.0) sel (16) uwCURBE_TEMP(2)<1> (abs)wDIFF(13)<16;16,1>   (abs)wDIFF(14)<16;16,1>
+(f1.1) sel (16) uwCURBE_TEMP(3)<1> (abs)wDIFF(15)<16;16,1>   (abs)wDIFF(16)<16;16,1>
+
+//Compare Max(0,1) - Max(2,3), Max(4,5) - Max(6,7)
+cmp.g.f0.0 (16) null:uw      uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+cmp.g.f0.1 (16) null:uw      uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+(f0.0)sel (16) uwCURBE_TEMP(0)<1>  uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(1)<16;16,1>
+(f0.1)sel (16) uwCURBE_TEMP(2)<1>  uwCURBE_TEMP(2)<16;16,1>   uwCURBE_TEMP(3)<16;16,1>
+
+//Compare Max(0,1,2,3) - Max(4,5,6,7)
+cmp.g.f0.0 (16) null:uw                uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+(f0.0)sel  (16) uwCURBE_TEMP(0)<1>     uwCURBE_TEMP(0)<16;16,1>   uwCURBE_TEMP(2)<16;16,1>
+
+//Compare Max(0,1,2,3,4,5,6,7) - 8
+cmp.g.f0.0 (16) null:uw                        uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+(f0.0)sel  (16) uwMAX_ABS_DIFF(1)<1>   uwCURBE_TEMP(0)<16;16,1>   (abs)wDIFF(17)<16;16,1>
+
+//Third row of 8x4
+        cmp.l.f0.0     (16) null:uw                    uwSOBEL(2)<16;16,1>             r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(0)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(0)<16;16,1>                      uwSOBEL(0)<16;16,1>
+(f0.0)  mov            (16) uwSOBEL(0)<1>   uwSOAD(0)<16;16,1>
+
+//Fourth row of 8x4
+               cmp.l.f0.0      (16) null:uw                    uwSOBEL(3)<16;16,1>             r55.30<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwMAX_ABS_DIFF(1)<16;16,1>  r55.28<0;2,1>:ub
+(f0.0)  cmp.l.f0.0     (16) null:uw                    uwSOAD(1)<16;16,1>                      uwSOBEL(0)<16;16,1>
+(f0.0)  mov            (16) uwSOBEL(0)<1>   uwSOAD(1)<16;16,1>
+
+               cmp.l.f0.0      (8) null:uw                     uwSOBEL(0,0)<8;8,1>     uwSOBEL(0,8)<8;8,1>
+(f0.0)  sel            (8) uwSOBEL(0)<1>       uwSOBEL(0,0)<8;8,1>     uwSOBEL(0,8)<8;8,1>
+
+               cmp.l.f0.0      (4) null:uw                     uwSOBEL(0,0)<4;4,1>     uwSOBEL(0,4)<4;4,1>
+(f0.0)  sel            (4) uwSOBEL(0)<1>       uwSOBEL(0,0)<4;4,1>     uwSOBEL(0,4)<4;4,1>
+
+               cmp.l.f0.0      (2) null:uw                                             uwSOBEL(0,0)<2;2,1>  uwSOBEL(0,2)<2;2,1>
+(f0.0)  sel            (2) r[a0.1,0]<1>:uw     uwSOBEL(0,0)<2;2,1>  uwSOBEL(0,2)<2;2,1>
+
+
+
+
+
+
+// End of common.inc
+
+mov (1) ip:ud r7.7<0;1,0>:d
+
+
+.end_code
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PL3_DN_422CP.g4a b/src/shaders/post_processing/gen7/PL3_DN_422CP.g4a
new file mode 100644 (file)
index 0000000..8192108
--- /dev/null
@@ -0,0 +1,544 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//  117    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PL3_DN_422CP
+.code
+
+
+
+// FileName:   DN_PL_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block) for planar format
+
+
+
+// FileName:   DN.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x45E8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(4,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+
+       mov (2)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(4,0)<2;2,1>         // Move denoise history to MRF (4x2)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x10003:ud                                                                      { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x50003:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE |   X  |   X   |  X  |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       //|            X             |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       mov (1)         mubMSGHDR_ENC_STATS(1,0)<1>             ubDNDI_RESP(4,8)<0;1,0>                 { NoDDClr }                             // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,3)<1>             uwDNDI_RESP(4,11)<0;1,0>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,4)<1>             uwDNDI_RESP(4,12)<2;2,1>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,9)<1>             uwDNDI_RESP(4,8)<0;1,0>                 { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,10)<1>    uwDNDI_RESP(4,9)<2;2,1>                 { NoDDChk }                             // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Load_UV_IMC3_16x8.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x8 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Load_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x8 block through DATAPORT
+
+//CHANGE       :  Read extra UV data to convert to 422. -rT
+//we are reading extra data in ALL cases irrespective of whether upsampling is reqd or not later on, to keep things simple.
+
+
+       add (2)         r27.0<1>:d                              r7.0<2;2,1>:w                           r4.4<2;2,1>:w                           // Source Y Block origin
+       asr (2)         r27.0<1>:d                      r27.0<2;2,1>:d          1:w                                             { NoDDClr }     // U/V block origin should be half of Y's
+       mov (1)         r27.2<1>:ud                             0x40007:ud                                              { NoDDChk }     // U/V block width and height (8x5)
+    mov (8)     r36<1>:ud              r27.0<8;8,1>:ud
+    mov (8)     r38<1>:ud              r27.0<8;8,1>:ud
+       send (8)        udDNDI_UV_RESP(0)<1>            r36     0x4     0x2290001:ud
+       send (8)        udDNDI_UV_RESP(2)<1>            r38     0x4     0x2290002:ud
+
+       //Update Header for Save
+       mov (1)         mudMSGHDR_UCOPY(0,2)<1> 0x30007:ud                                                                              //  U block width and height (8x4)
+       mov (1)         mudMSGHDR_VCOPY(0,2)<1> 0x30007:ud                                                                              //  V block width and height (8x4)
+
+
+
+// FileName:    DN_Save_Y_16x8.asm
+// Author:      Vivek Kumar
+// Description: Save one 16x8 blocks of Y channel of DN output for reference
+
+
+mov (8)     mudDN_Y_OUT(0,0)<1>     r0<8;8,1>:ud                                // message header
+mov (2)     mudDN_Y_OUT(0,0)<1>     r7.0<2;2,1>:w                  { NoDDClr }     // X origin
+mov (1)     mudDN_Y_OUT(0,2)<1>     0x7000F:ud    { NoDDChk }     // block width and height (16x8)
+
+//send out data through data port
+send (8)    null<1>:d    mudDN_Y_OUT      0x5    0xA0A8018:ud
+
+
+
+// FileName:   DN_Save_UV_IMC3_16x8.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x8 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Save_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x8 block through DATAPORT
+
+
+//Reuse the header from Load component
+//Header is modified at the end of load - to be usable for save.
+
+
+       mov (8)         mudMSGHDR_UCOPY(1)<1>           udDNDI_UV_RESP(0)<8;8,1>
+       mov (8)         mudMSGHDR_VCOPY(1)<1>           udDNDI_UV_RESP(2)<8;8,1>
+    send (4)    null<1>:d    r36       0x5    0x40A8019:ud
+    send (4)    null<1>:d    r38       0x5    0x40A801A:ud
+
+
+
+// FileName:   DN_Upsample_UV_IMC3_16x8.asm
+// Author:             Tatiya, Rupesh
+// Description:        Upconvert 420 UV to 422
+
+
+
+// FileName:   UVCopy_Upsample_UV_16x8.asm
+// Author:             Tatiya, Rupesh
+// Description:        Convert 42X UV to 422 - to be used for IECP.
+
+
+       avg.sat (16)    uwDNDI_UVCOPY_TEMP(0)           ubDNDI_UV_RESP(0,0)<0;8,1>     ubDNDI_UV_RESP(0,0)<8;8,1>
+       avg.sat (16)    uwDNDI_UVCOPY_TEMP(4)   ubDNDI_UV_RESP(2,0)<0;8,1>     ubDNDI_UV_RESP(2,0)<8;8,1>
+       avg.sat (16)    uwDNDI_UVCOPY_TEMP(1)           ubDNDI_UV_RESP(0,8)<0;8,1>     ubDNDI_UV_RESP(0,8)<8;8,1>
+       avg.sat (16)    uwDNDI_UVCOPY_TEMP(5)   ubDNDI_UV_RESP(2,8)<0;8,1>     ubDNDI_UV_RESP(2,8)<8;8,1>
+       avg.sat (16)    uwDNDI_UVCOPY_TEMP(2)           ubDNDI_UV_RESP(0,16)<0;8,1>     ubDNDI_UV_RESP(0,16)<8;8,1>
+       avg.sat (16)    uwDNDI_UVCOPY_TEMP(6)   ubDNDI_UV_RESP(2,16)<0;8,1>     ubDNDI_UV_RESP(2,16)<8;8,1>
+       avg.sat (16)    uwDNDI_UVCOPY_TEMP(3)           ubDNDI_UV_RESP(0,24)<0;8,1>     ubDNDI_UV_RESP(0,24)<8;8,1>
+       avg.sat (16)    uwDNDI_UVCOPY_TEMP(7)   ubDNDI_UV_RESP(2,24)<0;8,1>     ubDNDI_UV_RESP(2,24)<8;8,1>
+
+       mov             (16)    ubDNDI_RESP(5, 1)<2>    ubDNDI_UVCOPY_TEMP(0,0)<32;16,2>                { NoDDClr }
+       mov             (16)    ubDNDI_RESP(5, 0)<2>            ubDNDI_UVCOPY_TEMP(4,0)<32;16,2>                { NoDDChk }
+       mov             (16)    ubDNDI_RESP(5, 33)<2>   ubDNDI_UVCOPY_TEMP(1,0)<32;16,2>                { NoDDClr }
+       mov             (16)    ubDNDI_RESP(5, 32)<2>           ubDNDI_UVCOPY_TEMP(5,0)<32;16,2>                { NoDDChk }
+       mov             (16)    ubDNDI_RESP(5, 65)<2>   ubDNDI_UVCOPY_TEMP(2,0)<32;16,2>                { NoDDClr }
+       mov             (16)    ubDNDI_RESP(5, 64)<2>           ubDNDI_UVCOPY_TEMP(6,0)<32;16,2>                { NoDDChk }
+       mov             (16)    ubDNDI_RESP(5, 97)<2>   ubDNDI_UVCOPY_TEMP(3,0)<32;16,2>                { NoDDClr }
+       mov             (16)    ubDNDI_RESP(5, 96)<2>           ubDNDI_UVCOPY_TEMP(7,0)<32;16,2>                { NoDDChk }
+
+
+
+// FileName:   DN_Save_422CP_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Save one 16x8 blocks of DN output to the color pipe in 4-2-2 format
+
+
+.declare mubMSGHDR_DN_OUT_2   Base=r36.0      ElementSize=1  Type=ub
+
+
+mov (8)                mudMSGHDR_DN_OUT(0)<1>          r0<8;8,1>:ud                                    // message header
+shl (1)     mdMSGHDR_DN_OUT(0,0)<1>            r7.0<0;1,0>:w     1:w           { NoDDClr }            // X origin * 2 (422 output)
+mov (1)     mdMSGHDR_DN_OUT(0,1)<1>            r7.1<0;1,0>:w                   { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_DN_OUT(0,2)<1>   0x7000F:ud      { NoDDClr, NoDDChk }            // block width and height (16x8)
+
+//M0.3 - 0 - CP Enable, 1 - Area of Interest, 3:2 Message Format(TBD), 4:3 - Ignored, 31:5 CP state pointer
+//Compose area-of-interest bit + color pipe state pointer
+or (1)         mudMSGHDR_DN_OUT(0,3)<1>                r2.4<0;1,0>:ud  r7.26<0;1,0>:b          { NoDDChk }
+
+// First 8 x 8 Block
+       mov (8)         mubMSGHDR_DN_OUT(1)<2>                  ubDNDI_RESP(0,0)<8;8,1>                         { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(1,16)<2>               ubDNDI_RESP(0,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(2)<2>                  ubDNDI_RESP(0,32)<8;8,1>                                { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(2,16)<2>               ubDNDI_RESP(0,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(3)<2>                  ubDNDI_RESP(0,64)<8;8,1>                                { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(3,16)<2>               ubDNDI_RESP(0,80)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(4)<2>                  ubDNDI_RESP(0,96)<8;8,1>                                { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT(4,16)<2>               ubDNDI_RESP(0,112)<8;8,1>                       { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(1,1)<4>    ubDNDI_RESP(5,1)<8;4,2>                 { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(1,17)<4>           ubDNDI_RESP(5,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(1,3)<4>    ubDNDI_RESP(5,0)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(1,19)<4>           ubDNDI_RESP(5,16)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(2,1)<4>    ubDNDI_RESP(5,33)<8;4,2>                        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(2,17)<4>           ubDNDI_RESP(5,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(2,3)<4>    ubDNDI_RESP(5,32)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(2,19)<4>           ubDNDI_RESP(5,48)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(3,1)<4>    ubDNDI_RESP(5,65)<8;4,2>                        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(3,17)<4>           ubDNDI_RESP(5,81)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(3,3)<4>    ubDNDI_RESP(5,64)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(3,19)<4>           ubDNDI_RESP(5,80)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(4,1)<4>    ubDNDI_RESP(5,97)<8;4,2>                        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(4,17)<4>           ubDNDI_RESP(5,113)<8;4,2>               { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT(4,3)<4>    ubDNDI_RESP(5,96)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT(4,19)<4>           ubDNDI_RESP(5,112)<8;4,2>                       { NoDDChk }     // copy line of V directly to memory as optimization
+
+// Second 8 x 8 Block
+mov    (8)     r36.0<1>:ud             r31.0<8;8,1>:ud
+add    (1)     r36.0<1>:ud             r36.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DN_OUT_2(1)<2>                ubDNDI_RESP(0,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(1,16)<2>     ubDNDI_RESP(0,24)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(2)<2>                ubDNDI_RESP(0,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(2,16)<2>     ubDNDI_RESP(0,56)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(3)<2>                ubDNDI_RESP(0,72)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(3,16)<2>     ubDNDI_RESP(0,88)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(4)<2>                ubDNDI_RESP(0,104)<8;8,1>                       { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DN_OUT_2(4,16)<2>     ubDNDI_RESP(0,120)<8;8,1>                       { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(1,1)<4>          ubDNDI_RESP(5,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(1,17)<4>         ubDNDI_RESP(5,25)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(1,3)<4>          ubDNDI_RESP(5,8)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(1,19)<4>         ubDNDI_RESP(5,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(2,1)<4>          ubDNDI_RESP(5,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(2,17)<4>         ubDNDI_RESP(5,57)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(2,3)<4>          ubDNDI_RESP(5,40)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(2,19)<4>         ubDNDI_RESP(5,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(3,1)<4>          ubDNDI_RESP(5,73)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(3,17)<4>         ubDNDI_RESP(5,89)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(3,3)<4>          ubDNDI_RESP(5,72)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(3,19)<4>         ubDNDI_RESP(5,88)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(4,1)<4>          ubDNDI_RESP(5,105)<8;4,2>               { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(4,17)<4>         ubDNDI_RESP(5,121)<8;4,2>               { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DN_OUT_2(4,3)<4>          ubDNDI_RESP(5,104)<8;4,2>                       { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DN_OUT_2(4,19)<4>         ubDNDI_RESP(5,120)<8;4,2>               { NoDDChk }     // copy line of V directly to memory as optimization
+
+//send out data through data port
+send (8)    null<1>:d    r31.0         0x5    0xA0A801B:ud
+send (8)    null<1>:d    r36.0 0x5    0xA0A801B:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PL3_DN_PL3.g4a b/src/shaders/post_processing/gen7/PL3_DN_PL3.g4a
new file mode 100644 (file)
index 0000000..baeb2d7
--- /dev/null
@@ -0,0 +1,425 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   44    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PL3_DN_PL3
+.code
+
+
+
+// FileName:   DN_PL_Core.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block) for planar format
+
+
+
+// FileName:   DN.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DN only case (16x8 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x45E8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(4,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DN_Hist_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DN history data to statistics surface
+
+// Write denoise history to memory
+mov (8)    r27<1>:ud                           r0.0<8;8,1>:ud                                          // message header   
+
+
+       mov (2)    mudMSGHDR_HIST(1)<1>         udDNDI_RESP(4,0)<2;2,1>         // Move denoise history to MRF (4x2)
+
+
+shr (2)    r27.0<1>:ud         r7.0<2;2,1>:w                           2:w                                     // X,Y origin / 4
+add (1)    r27.0<1>:ud         r27.0<0;1,0>:ud                 r1.12<0;1,0>:uw         { NoDDClr }     // Add pitch to X origin
+mov (1)    r27.2<1>:ud         0x10003:ud                                                                      { NoDDChk }     // block width and height
+
+mov (8)                mudMSGHDR_HIST(0)<1>            r27.0<8;8,1>:ud
+send (8)       null<1>:d       r22     0x5             0x40A8021:ud
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x50003:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE |   X  |   X   |  X  |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       //|            X             |           X           |
+       //----------------------------------------------------
+       //|     X      |     SVCM    |           X           |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |           X           |
+       //----------------------------------------------------
+       mov (1)         mubMSGHDR_ENC_STATS(1,0)<1>             ubDNDI_RESP(4,8)<0;1,0>                 { NoDDClr }                             // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,3)<1>             uwDNDI_RESP(4,11)<0;1,0>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,4)<1>             uwDNDI_RESP(4,12)<2;2,1>        { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (1)         muwMSGHDR_ENC_STATS(1,9)<1>             uwDNDI_RESP(4,8)<0;1,0>                 { NoDDClr, NoDDChk }                    // Move encoder statistics to MRF
+       mov (2)         muwMSGHDR_ENC_STATS(1,10)<1>    uwDNDI_RESP(4,9)<2;2,1>                 { NoDDChk }                             // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:   DN_Load_UV_IMC3_16x8.asm 
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x8 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Load_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Read UV for 16x8 block through DATAPORT
+
+//CHANGE       :  Read extra UV data to convert to 422. -rT
+//we are reading extra data in ALL cases irrespective of whether upsampling is reqd or not later on, to keep things simple.
+
+
+       add (2)         r27.0<1>:d                              r7.0<2;2,1>:w                           r4.4<2;2,1>:w                           // Source Y Block origin
+       asr (2)         r27.0<1>:d                      r27.0<2;2,1>:d          1:w                                             { NoDDClr }     // U/V block origin should be half of Y's
+       mov (1)         r27.2<1>:ud                             0x40007:ud                                              { NoDDChk }     // U/V block width and height (8x5)
+    mov (8)     r36<1>:ud              r27.0<8;8,1>:ud
+    mov (8)     r38<1>:ud              r27.0<8;8,1>:ud
+       send (8)        udDNDI_UV_RESP(0)<1>            r36     0x4     0x2290001:ud
+       send (8)        udDNDI_UV_RESP(2)<1>            r38     0x4     0x2290002:ud
+
+       //Update Header for Save
+       mov (1)         mudMSGHDR_UCOPY(0,2)<1> 0x30007:ud                                                                              //  U block width and height (8x4)
+       mov (1)         mudMSGHDR_VCOPY(0,2)<1> 0x30007:ud                                                                              //  V block width and height (8x4)
+
+
+
+// FileName:    DN_Save_Y_16x8.asm
+// Author:      Vivek Kumar
+// Description: Save one 16x8 blocks of Y channel of DN output for reference
+
+
+mov (8)     mudDN_Y_OUT(0,0)<1>     r0<8;8,1>:ud                                // message header
+mov (2)     mudDN_Y_OUT(0,0)<1>     r7.0<2;2,1>:w                  { NoDDClr }     // X origin
+mov (1)     mudDN_Y_OUT(0,2)<1>     0x7000F:ud    { NoDDChk }     // block width and height (16x8)
+
+//send out data through data port
+send (8)    null<1>:d    mudDN_Y_OUT      0x5    0xA0A8018:ud
+
+
+
+// FileName:   DN_Save_UV_IMC3_16x8.asm 
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x8 block through DATAPORT 
+
+
+
+// FileName:   UVCopy_Save_16x8.asm
+// Author:             Vivek Kumar
+// Description:        Save UV for 16x8 block through DATAPORT
+
+
+//Reuse the header from Load component
+//Header is modified at the end of load - to be usable for save.
+
+
+       mov (8)         mudMSGHDR_UCOPY(1)<1>           udDNDI_UV_RESP(0)<8;8,1>
+       mov (8)         mudMSGHDR_VCOPY(1)<1>           udDNDI_UV_RESP(2)<8;8,1>
+    send (4)    null<1>:d    r36       0x5    0x40A8019:ud
+    send (4)    null<1>:d    r38       0x5    0x40A801A:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PL_DI_422CP.g4a b/src/shaders/post_processing/gen7/PL_DI_422CP.g4a
new file mode 100644 (file)
index 0000000..87db22f
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   87    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PL_DI_422CP
+.code
+
+
+
+// FileName:   DI.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DI only case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4AE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:    DI_Save_422CP_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in 422 format to Color Pipe (IECP)
+
+
+.declare mubMSGHDR_DI_OUT1_1  Base=r18.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT1_2  Base=r21.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_1  Base=r24.0      ElementSize=1  Type=ub
+
+
+.declare mubMSGHDR_DI_OUT2_2  Base=r27.0      ElementSize=1  Type=ub
+
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:ud     r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:ud     r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3000F:ud        { NoDDClr, NoDDChk }       // Block width and height (16x8)
+
+//M0.3  - 0 - CP Enable, 1 - Area of Interest, 3:2 Message Format(TBD), 4:3 - Ignored, 31:5 CP state pointer
+//Compose area-of-interest bit + color pipe state pointer
+or (1)  r27.3<1>:ud     r2.4<0;1,0>:ud     r7.26<0;1,0>:b     { NoDDChk }
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r24.0<1>:ud       r27<8;8,1>:ud
+
+
+// Pack 2nd field Y; First 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT1_1(1)<2>                       ubDNDI_RESP(0,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(1,16)<2>            ubDNDI_RESP(0,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2)<2>                       ubDNDI_RESP(0,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_1(2,16)<2>            ubDNDI_RESP(0,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; First 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,1)<4>                 ubDNDI_RESP(2,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,17)<4>        ubDNDI_RESP(2,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,3)<4>         ubDNDI_RESP(2,0)<8;4,2>                 { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(1,19)<4>        ubDNDI_RESP(2,16)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,1)<4>                 ubDNDI_RESP(2,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,17)<4>        ubDNDI_RESP(2,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,3)<4>         ubDNDI_RESP(2,32)<8;4,2>                        { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_1(2,19)<4>        ubDNDI_RESP(2,48)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+
+// Pack 2nd field Y; Second 8x4 block
+mov    (8)     r21.0<1>:ud             r18.0<8;8,1>:ud
+add    (1)     r21.0<1>:ud             r21.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT1_2(1)<2>                       ubDNDI_RESP(0,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(1,16)<2>            ubDNDI_RESP(0,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2)<2>                       ubDNDI_RESP(0,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT1_2(2,16)<2>            ubDNDI_RESP(0,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 2nd field U, V; Second 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,1)<4>                 ubDNDI_RESP(2,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,17)<4>                ubDNDI_RESP(2,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,3)<4>                 ubDNDI_RESP(2,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(1,19)<4>                ubDNDI_RESP(2,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,1)<4>                 ubDNDI_RESP(2,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,17)<4>                ubDNDI_RESP(2,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,3)<4>                 ubDNDI_RESP(2,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT1_2(2,19)<4>                ubDNDI_RESP(2,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r18.0   0x5     0x60A801B:ud
+send (8)    null<1>:d    r21.0   0x5     0x60A801B:ud
+
+// Pack 1st field Y; 1st 8x4 block
+       mov (8)         mubMSGHDR_DI_OUT2_1(1)<2>                       ubDNDI_RESP(4,0)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(1,16)<2>            ubDNDI_RESP(4,16)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2)<2>                       ubDNDI_RESP(4,32)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_1(2,16)<2>            ubDNDI_RESP(4,48)<8;8,1>                        { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U,V; 1st 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,1)<4>                 ubDNDI_RESP(6,1)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,17)<4>        ubDNDI_RESP(6,17)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,3)<4>         ubDNDI_RESP(6,0)<8;4,2>             { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(1,19)<4>        ubDNDI_RESP(6,16)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,1)<4>                 ubDNDI_RESP(6,33)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,17)<4>        ubDNDI_RESP(6,49)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,3)<4>         ubDNDI_RESP(6,32)<8;4,2>                    { NoDDChk }         // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_1(2,19)<4>        ubDNDI_RESP(6,48)<8;4,2>            { NoDDChk }         // copy line of V directly to memory as optimization
+
+// Pack 1st field Y; 2nd 8x4 block
+mov    (8)     r27.0<1>:ud             r24.0<8;8,1>:ud
+add    (1)     r27.0<1>:ud             r27.0<0;1,0>:w          0x10:w
+
+       mov (8)         mubMSGHDR_DI_OUT2_2(1)<2>                       ubDNDI_RESP(4,8)<8;8,1>                 { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(1,16)<2>            ubDNDI_RESP(4,24)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2)<2>                       ubDNDI_RESP(4,40)<8;8,1>                        { NoDDClr }     // copy line of Y directly to memory as optimization
+       mov (8)         mubMSGHDR_DI_OUT2_2(2,16)<2>            ubDNDI_RESP(4,56)<8;8,1>                { NoDDClr, NoDDChk }    // copy line of Y directly to memory as optimization
+
+// Pack 1st field U, V; 2nd 8x4 block
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,1)<4>                 ubDNDI_RESP(6,9)<8;4,2>         { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,17)<4>                ubDNDI_RESP(6,25)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,3)<4>                 ubDNDI_RESP(6,8)<8;4,2>         { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(1,19)<4>                ubDNDI_RESP(6,24)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,1)<4>                 ubDNDI_RESP(6,41)<8;4,2>                { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,17)<4>                ubDNDI_RESP(6,57)<8;4,2>        { NoDDClr, NoDDChk }    // copy line of U directly to memory as optimization
+
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,3)<4>                 ubDNDI_RESP(6,40)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+       mov (4)     mubMSGHDR_DI_OUT2_2(2,19)<4>                ubDNDI_RESP(6,56)<8;4,2>                { NoDDChk }     // copy line of V directly to memory as optimization
+
+send (8)    null<1>:d    r24.0     0x5     0x60A801E:ud
+send (8)    null<1>:d    r27.0     0x5     0x60A801E:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
diff --git a/src/shaders/post_processing/gen7/PL_DI_PA.g4a b/src/shaders/post_processing/gen7/PL_DI_PA.g4a
new file mode 100644 (file)
index 0000000..6f56e0d
--- /dev/null
@@ -0,0 +1,399 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+//   57    // Total instruction count
+//    1    // Total kernel count
+
+.kernel PL_DI_PA
+.code
+
+
+
+// FileName:   DI.asm 
+// Author:             Vivek Kumar
+// Description:        Tasks for DI only case (16x4 block)
+
+
+
+
+// Module name: common.inc
+//
+// Common header file for all Video-Processing kernels
+//
+
+.default_execution_size (16)
+.default_register_type  :ub
+
+.reg_count_total        128
+.reg_count_payload      7
+
+//========== Common constants ==========
+
+
+//========== Macros ==========
+
+
+//Fast Jump, For more details see "Set_Layer_N.asm"
+
+
+//========== Defines ====================
+
+//========== Static Parameters (Common To All) ==========
+//r1
+
+
+//r2
+
+                                    //  e.g.            byte0   byte1  byte2
+                                    // YUYV               0       1      3
+                                    // YVYU               0       3      1
+
+//Color Pipe (IECP) parameters
+
+
+//ByteCopy
+
+
+//r4
+
+                                    //  e.g.              byte0           byte1           byte2
+                                    // YUYV                 0               1               3
+                                    // YVYU                 0               3               1
+
+
+//========== Inline parameters (Common To All) ===========
+
+
+//============== Binding Index Table===========
+//Common between DNDI and DNUV
+
+
+//================= Common Message Descriptor =====
+// Message descriptor for thread spawning
+// Message Descriptors
+//                = 000 0001 (min message len 1 ) 0,0000 (resp len 0   -add later)
+//                  0000,0000,0000
+//                  0001(Spawn a root thread),0001 (Root thread spawn thread)
+//                = 0x02000011
+// Thread Spawner Message Descriptor
+
+
+// Message descriptor for atomic operation add
+// Message Descriptors
+//                = 000 0110 (min message len 6 ) 0,0000 (resp len 0   -add later)
+//                  1(header present)001,10(typed atomic operation)0(return enabled)0(slot group, low 8 bits),0111 (AOP_Add)
+//                  0000,0000 (Binding table index, added later)
+//                = 0x02000011
+
+// Atomic Operation Add Message Descriptor
+
+
+// Message descriptor for dataport media write
+        // Message Descriptors
+                //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)
+                //                  1 (header present 1) 0 1010 (media block write) 000000
+                //                  00000000 (binding table index - set later)
+                //                = 0x020A8000
+
+
+// Message Length defines
+
+
+// Response Length defines
+
+
+// Block Width and Height Size defines
+
+
+// Extended Message Descriptors
+
+
+// Common message descriptors:
+
+
+//===================== Math Function Control ===================================
+
+
+//============ Message Registers ===============
+                             // buf4 starts from r28
+
+
+//#define mMSGHDR_EOT  r43    // Dummy Message Register for EOT
+
+
+.declare    mubMSGPAYLOAD  Base=r30 ElementSize=1 SrcRegion=<16;16,1> Type=ub
+.declare    muwMSGPAYLOAD  Base=r30 ElementSize=2 SrcRegion=<16;16,1> Type=uw
+.declare    mudMSGPAYLOAD  Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=ud
+.declare    mfMSGPAYLOAD   Base=r30 ElementSize=4 SrcRegion=<8;8,1> Type=f
+
+//=================== End of thread instruction ===========================
+
+
+//=====================Pointers Used=====================================
+
+
+//=======================================================================
+
+
+//r9-r17
+// Define temp space for any usages
+
+
+// Common Buffers
+
+
+// temp space for rotation
+
+.declare fROBUF                  Base=r9.0             ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=f
+
+.declare udROBUF               Base=r9.0               ElementSize=4           SrcRegion=<8;8,1>                 DstRegion=<1>         Type=ud
+
+.declare uwROBUF               Base=r9.0               ElementSize=2           SrcRegion=<16;16,1>             DstRegion=<1>           Type=uw
+
+.declare ubROBUF               Base=r9.0               ElementSize=1           SrcRegion=<16;16,1>             DstRegion=<1>           Type=ub
+
+.declare ub4ROBUF      Base=r9.0               ElementSize=1           SrcRegion=<32;8,4>              DstRegion=<4>           Type=ub
+
+
+// End of common.inc
+
+
+// FileName:    DNDI.inc
+// Author:      Vivek Kumar
+// Description: Include file for DN, DI and DNDI
+// Inputs:      DI_ENABLE, DN_ENABLE, DN_PLANAR, DN_PACKED
+
+
+
+
+// End of common.inc
+
+
+//Interface:
+//Static Parameters:
+//r1
+
+
+//====================== Binding table (Explicit To DNDI)=========================================
+
+
+.declare mudMSGHDR_DNDI     Base=r18      ElementSize=4    Type=ud
+.declare mdMSGHDR_DNDI      Base=r18      ElementSize=4    Type=d
+.declare mwMSGHDR_DNDI      Base=r18      ElementSize=2    Type=w
+
+
+.declare mudMSGHDR_STMM     Base=r20      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_HIST     Base=r22      ElementSize=4    Type=ud
+
+
+.declare mudMSGHDR_ENC_STATS Base=r24 ElementSize=4   Type=ud
+.declare muwMSGHDR_ENC_STATS Base=r24 ElementSize=2   Type=uw
+.declare mubMSGHDR_ENC_STATS Base=r24 ElementSize=1   Type=ub
+
+
+.declare mudMSGHDR_DN_OUT   Base=r31.0      ElementSize=4  Type=ud
+.declare mdMSGHDR_DN_OUT    Base=r31.0      ElementSize=4  Type=d
+.declare mubMSGHDR_DN_OUT   Base=r31.0      ElementSize=1  Type=ub
+
+
+.declare mudMSGHDR_UVCOPY   Base=r36      ElementSize=4  Type=ud
+.declare mdMSGHDR_UVCOPY    Base=r36      ElementSize=4  Type=d
+.declare mudMSGHDR_UCOPY    Base=r36       ElementSize=4  Type=ud
+.declare mudMSGHDR_VCOPY    Base=r38       ElementSize=4  Type=ud
+
+
+.declare mudMSGHDR_DI_OUT1  Base=r18.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT1  Base=r18.0      ElementSize=1     Type=ub
+
+
+.declare mudMSGHDR_DI_OUT2  Base=r23.0      ElementSize=4     Type=ud
+.declare mubMSGHDR_DI_OUT2  Base=r23.0      ElementSize=1     Type=ub
+
+//r45
+//Use r45 as message header, so no need to "mov" the data.
+
+.declare mudDN_Y_OUT        Base=r45.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+
+// Message response (Denoised & DI-ed pixels & statistics); Use buffer 5
+.declare udDNDI_RESP        Base=r46.0 ElementSize=4 SrcRegion=<8;8,1>   DstRegion=<1> Type=ud
+.declare uwDNDI_RESP        Base=r46.0 ElementSize=2 SrcRegion=<16;16,1> DstRegion=<1> Type=uw
+.declare ubDNDI_RESP        Base=r46.0 ElementSize=1 SrcRegion=<16;16,1> DstRegion=<1> Type=ub
+
+// Message response (UV Copy); Use buffer 5
+.declare udDNDI_UV_RESP     Base=r58.0 ElementSize=4 SrcRegion=<8;8,1>  DstRegion=<1> Type=ud
+.declare ubDNDI_UV_RESP     Base=r58.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub
+
+//Temp GRFs: For 42X to 422 Conversion
+.declare uwDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=2 SrcRegion=<16;16,1>    DstRegion=<1> Type=uw       //8 GRFs
+.declare ubDNDI_UVCOPY_TEMP Base=r10.0 ElementSize=1 SrcRegion=<16;16,1>    DstRegion=<1> Type=ub       //8 GRFs
+//---------------------------------------------------------------------------
+// Message descriptors
+//---------------------------------------------------------------------------
+// Extended message descriptor
+    // Message descriptor   for sampler read
+    //                    = 000 0010 (message len 2) 00000 (resp len - set later, 12 or 5 or 11)
+    //                      1 (header present 1) 0 11 (SIMD32/64 mode)
+    //                      1000 (message type) 0000 (DI state index)
+    //                      00000000 (binding table index - set later)
+    //                    = 0x040b8000
+
+
+// Attention: The Message Length is The Number of GRFs with Data Only, without the Header
+
+
+//---------------------------------------------------------------------------
+// VDI Return Data format
+//---------------------------------------------------------------------------
+// Defines for DI enabled
+
+
+// Defines for DI disabled
+
+
+
+// FileName:   DNDI_Command.asm 
+// Author:             Vivek Kumar
+// Description:        Sends a message to the VDI to process one DN (16x8) or DNDI (16x4) block
+
+// Prepare the DNDI send command
+mov (8)                mudMSGHDR_DNDI(0)<1>                    r0.0<8;8,1>:ud                                  // message header
+mov (1)                mwMSGHDR_DNDI(1,4)<1>                   r7.0<0;1,0>:w           { NoDDClr }             // horizontal origin    // Do we need to add offset here? -vK
+mov (1)                mwMSGHDR_DNDI(1,12)<1>                  r7.1<0;1,0>:w           { NoDDChk }             // vertical origin              // Can these 2 be combined? - vK
+
+send (8)       udDNDI_RESP(0)<1>       r18     0x2     0x4AE8003:ud
+
+// On Gen6, with VDI walker, use the XY pair returned rather than programmed above
+// VDI_RETURNED_XY is ordered XY in case of walker enables and the same as programmed in case of walker disabled
+mov (2)        r7.0<1>:w     uwDNDI_RESP(9,14)<2;2,1>  // horizontal/Vertial origin in W.14 and W.15    
+
+
+
+// FileName:   DI_STMM_Save.asm 
+// Author:             Vivek Kumar
+// Description:        Saves DI STMM Data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write STMM to memory
+mov (8)     mudMSGHDR_STMM(0)<1>       r0.0<8;8,1>:ud                                                                  // message header   
+mov (8)     mudMSGHDR_STMM(1)<1>       udDNDI_RESP(8,0)                                                // Move STMM to MRF 
+
+shr (1)     mudMSGHDR_STMM(0,0)<1>     r7.0<0;1,0>:w            1:w     { NoDDClr }            // X origin / 2
+mov (1)     mudMSGHDR_STMM(0,1)<1>     r7.1<0;1,0>:w                    { NoDDClr, NoDDChk }   // Y origin
+mov (1)     mudMSGHDR_STMM(0,2)<1>     0x30007:ud           { NoDDChk }                // block width and height (8x4)
+
+send (8)       null<1>:d       r20     0x5             0x40A8021:ud      
+
+
+
+// FileName:   DNDI_Enc_Stats_Save.asm
+// Author:             Vivek Kumar
+// Description:        Saves Encoder Statistics data to statistics surface in case of DI enabled (for 16x4 block)
+
+// Write encoder statistics to memory
+//Currently enable this only on Gen6 validation
+mov (8)                mudMSGHDR_ENC_STATS(1)<1>       0x0:ud                                          // Init payload MRF
+mov (8)                mudMSGHDR_ENC_STATS(0)<1>       r0.0<8;8,1>:ud                          // message header
+
+shr (1)                mudMSGHDR_ENC_STATS(0,0)<1>             r7.0<0;1,0>:w                   1:w     { NoDDClr }                     //enable the flag after testing on si                                   { NoDDClr }     // X origin / 2
+mul (1)                acc0.1<1>:ud                                    r7.1<0;1,0>:w                           3:w                                                                                                                                                                                     // Y origin * 3
+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
+mov (1)                mudMSGHDR_ENC_STATS(0,2)<1>             0x20007:ud                              { NoDDChk }                     //enable the flag after testing on si                                           { NoDDChk } // block width and height (8x3)
+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
+
+
+       //Data block for Encoder Statistics
+       //----------------------------------------------------
+       //|  0  |   1  |   2   |  3  |  4  |  5  |  6  |  7  | Bytes
+       //----------------------------------------------------
+       //| BNE | MCNT | FCNT | TCNT |  X  |  X  |  X  |  X  |
+       //----------------------------------------------------
+       //|   DcTpT    |     SVCM    |   DcBpT   |   DcTpB   |
+       //----------------------------------------------------
+       //|   SHCM     |     STAD    |   DcTcB   |   DcBpB   |
+       //----------------------------------------------------
+       mov (1)         mudMSGHDR_ENC_STATS(1,0)<1>             udDNDI_RESP(9,1)<0;1,0>                 { NoDDClr }                     // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,3)<2>             udDNDI_RESP(9,3)<2;2,1>                 { NoDDClr, NoDDChk }            // Move encoder statistics to MRF
+       mov (2)         mudMSGHDR_ENC_STATS(1,2)<2>             udDNDI_RESP(9,5)<2;2,1>                 { NoDDChk }                     // Move encoder statistics to MRF
+
+
+send (8)   null<1>:d    r24    0x5    0x40A8021:ud
+
+
+
+// FileName:    DI_Save_PA_16x4.asm
+// Author:      Vivek Kumar
+// Description: Save two 16x4 blocks of DI output in Packed format
+
+
+add (4) a0.4<1>:uw   r2.28<4;4,1>:ub   608:w               // Initial Y,U,V offset in YUV422 block; it starts at m20
+
+mov (8) r27.0<1>:ud     r0.0<8;8,1>:ud
+shl (1) r27.0<1>:d      r7.0<0;1,0>:w            1:w  { NoDDClr }          // H. block origin need to be doubled
+mov (1) r27.1<1>:d      r7.1<0;1,0>:w                 { NoDDClr, NoDDChk }       // Block origin
+mov (1) r27.2<1>:ud     0x3001F:ud          { NoDDChk }          // Block width and height (32x8)
+
+//prepare the message headers
+mov (8) r18.0<1>:ud       r27<8;8,1>:ud
+mov (8) r23.0<1>:ud       r27<8;8,1>:ud
+
+// Pack 2nd field Y
+    mov (16)    r[a0.4, 0]<2>      ubDNDI_RESP(0,0)               { NoDDClr }
+    mov (16)    r[a0.4, 32]<2>      ubDNDI_RESP(0,16)               { NoDDClr }
+    mov (16)    r[a0.4, 64]<2>      ubDNDI_RESP(0,32)               { NoDDClr }
+    mov (16)    r[a0.4, 96]<2>      ubDNDI_RESP(0,48)               { NoDDClr }
+// Pack 2nd field U
+    mov (8)     r[a0.5, 0]<4>      ubDNDI_RESP(2,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 32]<4>      ubDNDI_RESP(2,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 64]<4>      ubDNDI_RESP(2,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 96]<4>      ubDNDI_RESP(2,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 2nd field V
+    mov (8)     r[a0.6, 0]<4>      ubDNDI_RESP(2,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 32]<4>      ubDNDI_RESP(2,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 64]<4>      ubDNDI_RESP(2,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 96]<4>      ubDNDI_RESP(2,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+// Pack 1st field Y
+    mov (16)    r[a0.4, 160]<2>    ubDNDI_RESP(4,0)               { NoDDClr }
+    mov (16)    r[a0.4, 192]<2>    ubDNDI_RESP(4,16)               { NoDDClr }
+    mov (16)    r[a0.4, 224]<2>    ubDNDI_RESP(4,32)               { NoDDClr }
+    mov (16)    r[a0.4, 256]<2>    ubDNDI_RESP(4,48)               { NoDDClr }
+// Pack 1st field U
+    mov (8)     r[a0.5, 160]<4>    ubDNDI_RESP(6,1)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 192]<4>    ubDNDI_RESP(6,17)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 224]<4>    ubDNDI_RESP(6,33)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+    mov (8)     r[a0.5, 256]<4>    ubDNDI_RESP(6,49)<16;8,2>   { NoDDClr, NoDDChk }  //U pixels
+// Pack 1st field V
+    mov (8)     r[a0.6, 160]<4>    ubDNDI_RESP(6,0)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 192]<4>    ubDNDI_RESP(6,16)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 224]<4>    ubDNDI_RESP(6,32)<16;8,2>     { NoDDChk }     //Vpixels
+    mov (8)     r[a0.6, 256]<4>    ubDNDI_RESP(6,48)<16;8,2>     { NoDDChk }     //Vpixels
+
+//save the previous frame
+send (8)    null<1>:d    r18.0     0x5     0xA0A801B:ud
+
+//save the current frame
+send (8)    null<1>:d    r23.0     0x5     0xA0A801E:ud
+
+
+
+//End of Thread message
+
+mov (8) r127<1>:ud r0.0<8;8,1>:ud 
+ send (1) null<1>:d r127 0x27 0x02000010
+
+
+.end_code 
+.end_kernel
index 2a73532..05e32f2 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   93    // Total instruction count
 //    1    // Total kernel count
 
index 6d2c1f3..8d1006c 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //  110    // Total instruction count
 //    1    // Total kernel count
 
index 5f872e6..2724033 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   48    // Total instruction count
 //    1    // Total kernel count
 
index 30ffa19..99a2a29 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //  278    // Total instruction count
 //    1    // Total kernel count
 
index edb5754..360caa0 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    7    // Total instruction count
 //    1    // Total kernel count
 
index 9becc9a..0a7a577 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    7    // Total instruction count
 //    1    // Total kernel count
 
index 8efa75d..4bf933e 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    7    // Total instruction count
 //    1    // Total kernel count
 
index 77a8c23..4c31e45 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    7    // Total instruction count
 //    1    // Total kernel count
 
index 41a62a3..d3f07fd 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //    7    // Total instruction count
 //    1    // Total kernel count
 
index 9898040..fef33dc 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   17    // Total instruction count
 //    1    // Total kernel count
 
index d0811d3..a12e5a2 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ *  Copyright 2000-2011 Intel Corporation All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 //   10    // Total instruction count
 //    1    // Total kernel count