1/*
2 * Copyright © 2009 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Author:
24 *    Zou Nan hai <nanhai.zou@intel.com>
25 *    Yan Li <li.l.yan@intel.com>
26 *    Liu Xi bin<xibin.liu@intel.com>
27 */
28/* GRF allocation:
29   g1~g30: constant buffer
30           g1~g2:intra IQ matrix
31           g3~g4:non intra IQ matrix
32           g5~g20:IDCT table
33   g31:    thread payload 
34   g58~g81:reference data
35   g82:    thread payload backup
36   g83~g106:IDCT data
37   g115:   message descriptor for reading reference data   */
38mov (8) g82.0<1>UD g31.0<8,8,1>UD {align1};
39mov(2) g31.0<1>UD g82.12<2,2,1>UW {align1};
40mov (1) g126.8<1>UD ip {align1};
41mov (1) ip g21.0<1,1,1>UD {align1};
42
43/*field 0 of Y*/
44asr (2) g31.14<1>W g82.20<2,2,1>W 1W {align1};
45shl (1) g31.16<1>W g31.16<1,1,1>W 1W {align1};
46add (2) g115.0<1>UD g31.0<2,2,1>UD g31.14<2,2,1>W {align1};
47and (1) g115.4<1>UD g115.4<1,1,1>UD 0xFFFFFFFEUD {align1};
48and.nz (1) null g82.2<1,1,1>UW 0x2000UW {align1};
49(f0) add (1) g115.4<1>UD g115.4<1,1,1>UD 1UD {align1};
50define(`surface',`7')
51define(`mv1',`g82.20')
52define(`mv2',`g82.22')
53include(`motion_field_y.g4i')
54mov (8) g58.0<1>UD g32.0<8,8,1>UD {align1};
55mov (8) g60.0<1>UD g33.0<8,8,1>UD {align1};
56mov (8) g62.0<1>UD g34.0<8,8,1>UD {align1};
57mov (8) g64.0<1>UD g35.0<8,8,1>UD {align1};
58mov (8) g66.0<1>UD g36.0<8,8,1>UD {align1};
59mov (8) g68.0<1>UD g37.0<8,8,1>UD {align1};
60mov (8) g70.0<1>UD g38.0<8,8,1>UD {align1};
61mov (8) g72.0<1>UD g39.0<8,8,1>UD {align1};
62
63/*field 1 of Y*/
64asr (2) g31.14<1>W g82.28<2,2,1>W 1W {align1};
65shl (1) g31.16<1>W g31.16<1,1,1>W 1W {align1};
66add (2) g115.0<1>UD g31.0<2,2,1>UD g31.14<2,2,1>W {align1};
67and (1) g115.4<1>UD g115.4<1,1,1>UD 0xFFFFFFFEUD {align1};
68and.nz (1) null g82.2<1,1,1>UW 0x8000UW {align1};
69(f0) add (1) g115.4<1>UD g115.4<1,1,1>UD 1UD {align1};
70define(`surface',`7')
71define(`mv1',`g82.28')
72define(`mv2',`g82.30')
73include(`motion_field_y.g4i')
74mov (8) g59.0<1>UD g32.0<8,8,1>UD {align1};
75mov (8) g61.0<1>UD g33.0<8,8,1>UD {align1};
76mov (8) g63.0<1>UD g34.0<8,8,1>UD {align1};
77mov (8) g65.0<1>UD g35.0<8,8,1>UD {align1};
78mov (8) g67.0<1>UD g36.0<8,8,1>UD {align1};
79mov (8) g69.0<1>UD g37.0<8,8,1>UD {align1};
80mov (8) g71.0<1>UD g38.0<8,8,1>UD {align1};
81mov (8) g73.0<1>UD g39.0<8,8,1>UD {align1};
82
83/*field 0 of UV*/
84shr (2) g31.0<1>UD g31.0<2,2,1>UD 1UD {align1};
85asr (2) g82.20<1>W g82.20<2,2,1>W 1W {align1};
86asr (2) g31.14<1>W g82.20<2,2,1>W 1W {align1};
87shl (1) g31.16<1>W g31.16<1,1,1>W 1W {align1};
88add (2) g115.0<1>UD g31.0<2,2,1>UD g31.14<2,2,1>W {align1};
89and.nz (1) null g82.2<1,1,1>UW 0x2000UW {align1};
90(f0) add (1) g115.4<1>UD g115.4<1,1,1>UD 1UD {align1};
91define(`surface_u', `8')
92define(`surface_v', `9')
93define(`mv1',`g82.20')
94define(`mv2',`g82.22')
95include(`motion_field_uv.g4i')
96mov (8) g74.0<1>UW g32.0<8,8,1>UW {align1};
97mov (8) g75.0<1>UW g33.0<8,8,1>UW {align1};
98mov (8) g76.0<1>UW g34.0<8,8,1>UW {align1};
99mov (8) g77.0<1>UW g35.0<8,8,1>UW {align1};
100mov (8) g78.0<1>UW g36.0<8,8,1>UW {align1};
101mov (8) g79.0<1>UW g37.0<8,8,1>UW {align1};
102mov (8) g80.0<1>UW g38.0<8,8,1>UW {align1};
103mov (8) g81.0<1>UW g39.0<8,8,1>UW {align1};
104
105/*field 1 of UV*/
106asr (2) g82.28<1>W g82.28<2,2,1>W 1W {align1};
107asr (2) g31.14<1>W g82.28<2,2,1>W 1W {align1};
108shl (1) g31.16<1>W g31.16<1,1,1>W 1W {align1};
109add (2) g115.0<1>UD g31.0<2,2,1>UD g31.14<2,2,1>W {align1};
110and.nz (1) null g82.2<1,1,1>UW 0x8000UW {align1};
111(f0) add (1) g115.4<1>UD g115.4<1,1,1>UD 1UD {align1};
112define(`mv1',`g82.28')
113define(`mv2',`g82.30')
114include(`motion_field_uv.g4i')
115mov (8) g74.16<1>UW g32.0<8,8,1>UW {align1};
116mov (8) g75.16<1>UW g33.0<8,8,1>UW {align1};
117mov (8) g76.16<1>UW g34.0<8,8,1>UW {align1};
118mov (8) g77.16<1>UW g35.0<8,8,1>UW {align1};
119mov (8) g78.16<1>UW g36.0<8,8,1>UW {align1};
120mov (8) g79.16<1>UW g37.0<8,8,1>UW {align1};
121mov (8) g80.16<1>UW g38.0<8,8,1>UW {align1};
122mov (8) g81.16<1>UW g39.0<8,8,1>UW {align1};
123
124include(`addidct.g4i')
125send (16) 0 acc0<1>UW g0<8,8,1>UW 
126	thread_spawner(0, 0, 0) mlen 1 rlen 0 { align1 EOT};
127