| 1 |
/* |
| 2 |
* Copyright © 2008 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 <[email protected]> |
| 25 |
* Zhang Hua jun <[email protected]> |
| 26 |
* Xing Dong sheng <[email protected]> |
| 27 |
* |
| 28 |
*/ |
| 29 |
|
| 30 |
/* shader for forward and backward predict mc |
| 31 |
*/ |
| 32 |
/* (x', y') = (x, y) + (motion_vector1.x >> 1, motion_vector1.y >> 1) |
| 33 |
/* (x'', y'') = (x, y) + (motion_vector2.x >> 1, motion_vector2.y >> 1) |
| 34 |
/* f(x, y) = (motion_forward(x`, y`) + motion_backward(x'', y'') + 1) / 2 */ |
| 35 |
|
| 36 |
//Save payload |
| 37 |
mov (8) g76.0<1>UD g1.0<8,8,1>UD {align1}; |
| 38 |
//mov (8) g77.0<1>UD g2.0<8,8,1>UD {align1}; |
| 39 |
include(`block_clear.g4i') |
| 40 |
|
| 41 |
mov (8) g115.0<1>UD g1.0<8,8,1>UD {align1}; |
| 42 |
mov (1) g1.8<1>UD 0x0070007UD {align1}; |
| 43 |
mov (8) g2.0<1>UD g1.0<8,8,1>UD {align1}; |
| 44 |
/* Y */ |
| 45 |
//Forward |
| 46 |
asr (2) g1.14<1>W g115.14<2,2,1>W 1W {align1}; |
| 47 |
add (2) g2.0<1>UD g115.0<2,2,1>UD g1.14<2,2,1>W {align1}; |
| 48 |
define(`input_surface', `4') |
| 49 |
define(`mv1', `g115.14') |
| 50 |
define(`mv2', `g115.16') |
| 51 |
include(`motion_frame_y.g4i') |
| 52 |
mov (16) g52.0<1>UD g28.0<16,16,1>UD {align1 compr}; |
| 53 |
mov (16) g54.0<1>UD g30.0<16,16,1>UD {align1 compr}; |
| 54 |
mov (16) g56.0<1>UD g32.0<16,16,1>UD {align1 compr}; |
| 55 |
mov (16) g58.0<1>UD g34.0<16,16,1>UD {align1 compr}; |
| 56 |
mov (16) g60.0<1>UD g36.0<16,16,1>UD {align1 compr}; |
| 57 |
mov (16) g62.0<1>UD g38.0<16,16,1>UD {align1 compr}; |
| 58 |
mov (16) g64.0<1>UD g40.0<16,16,1>UD {align1 compr}; |
| 59 |
mov (16) g66.0<1>UD g42.0<16,16,1>UD {align1 compr}; |
| 60 |
//Backward |
| 61 |
asr (2) g1.14<1>W g115.18<2,2,1>W 1W {align1}; |
| 62 |
add (2) g2.0<1>UD g115.0<2,2,1>UD g1.14<2,2,1>W {align1}; |
| 63 |
define(`input_surface', `7') |
| 64 |
define(`mv1', `g115.18') |
| 65 |
define(`mv2', `g115.20') |
| 66 |
include(`motion_frame_y.g4i') |
| 67 |
|
| 68 |
//Average |
| 69 |
avg.sat (16) g28.0<1>UW g28.0<16,16,1>UW g52.0<16,16,1>UW {align1}; |
| 70 |
avg.sat (16) g29.0<1>UW g29.0<16,16,1>UW g53.0<16,16,1>UW {align1}; |
| 71 |
avg.sat (16) g30.0<1>UW g30.0<16,16,1>UW g54.0<16,16,1>UW {align1}; |
| 72 |
avg.sat (16) g31.0<1>UW g31.0<16,16,1>UW g55.0<16,16,1>UW {align1}; |
| 73 |
avg.sat (16) g32.0<1>UW g32.0<16,16,1>UW g56.0<16,16,1>UW {align1}; |
| 74 |
avg.sat (16) g33.0<1>UW g33.0<16,16,1>UW g57.0<16,16,1>UW {align1}; |
| 75 |
avg.sat (16) g34.0<1>UW g34.0<16,16,1>UW g58.0<16,16,1>UW {align1}; |
| 76 |
avg.sat (16) g35.0<1>UW g35.0<16,16,1>UW g59.0<16,16,1>UW {align1}; |
| 77 |
avg.sat (16) g36.0<1>UW g36.0<16,16,1>UW g60.0<16,16,1>UW {align1}; |
| 78 |
avg.sat (16) g37.0<1>UW g37.0<16,16,1>UW g61.0<16,16,1>UW {align1}; |
| 79 |
avg.sat (16) g38.0<1>UW g38.0<16,16,1>UW g62.0<16,16,1>UW {align1}; |
| 80 |
avg.sat (16) g39.0<1>UW g39.0<16,16,1>UW g63.0<16,16,1>UW {align1}; |
| 81 |
avg.sat (16) g40.0<1>UW g40.0<16,16,1>UW g64.0<16,16,1>UW {align1}; |
| 82 |
avg.sat (16) g41.0<1>UW g41.0<16,16,1>UW g65.0<16,16,1>UW {align1}; |
| 83 |
avg.sat (16) g42.0<1>UW g42.0<16,16,1>UW g66.0<16,16,1>UW {align1}; |
| 84 |
avg.sat (16) g43.0<1>UW g43.0<16,16,1>UW g67.0<16,16,1>UW {align1}; |
| 85 |
|
| 86 |
/* UV */ |
| 87 |
//Forward |
| 88 |
shr (2) g1.0<1>UD g115.0<2,2,1>UD 1UD {align1}; |
| 89 |
asr (2) g115.14<1>W g115.14<2,2,1>W 1W {align1}; |
| 90 |
asr (2) g1.14<1>W g115.14<2,2,1>W 1W {align1}; |
| 91 |
add (2) g2.0<1>UD g1.0<2,2,1>UD g1.14<2,2,1>W {align1}; |
| 92 |
|
| 93 |
define(`input_surface1', `5') |
| 94 |
define(`input_surface2', `6') |
| 95 |
define(`mv1', `g115.14') |
| 96 |
define(`mv2', `g115.16') |
| 97 |
mov (1) g2.8<1>UD 0x007000fUD {align1}; |
| 98 |
include(`motion_frame_uv.g4i') |
| 99 |
mov (16) g122.0<1>UB g44.0<16,16,2>UB {align1}; |
| 100 |
mov (16) g122.16<1>UB g45.0<16,16,2>UB {align1}; |
| 101 |
mov (16) g123.0<1>UB g46.0<16,16,2>UB {align1}; |
| 102 |
mov (16) g123.16<1>UB g47.0<16,16,2>UB {align1}; |
| 103 |
mov (16) g124.0<1>UB g48.0<16,16,2>UB {align1}; |
| 104 |
mov (16) g124.16<1>UB g49.0<16,16,2>UB {align1}; |
| 105 |
mov (16) g125.0<1>UB g50.0<16,16,2>UB {align1}; |
| 106 |
mov (16) g125.16<1>UB g51.0<16,16,2>UB {align1}; |
| 107 |
//Backward |
| 108 |
asr (2) g115.18<1>W g115.18<2,2,1>W 1W {align1}; |
| 109 |
asr (2) g1.14<1>W g115.18<2,2,1>W 1W {align1}; |
| 110 |
add (2) g2.0<1>UD g1.0<2,2,1>UD g1.14<2,2,1>W {align1}; |
| 111 |
define(`input_surface1', `8') |
| 112 |
define(`input_surface2', `9') |
| 113 |
define(`mv1', `g115.18') |
| 114 |
define(`mv2', `g115.20') |
| 115 |
mov (1) g2.8<1>UD 0x007000fUD {align1}; |
| 116 |
include(`motion_frame_uv.g4i') |
| 117 |
|
| 118 |
//Average |
| 119 |
avg.sat (16) g44.0<1>UW g44.0<16,16,1>UW g122.0<16,16,1>UB {align1}; |
| 120 |
avg.sat (16) g45.0<1>UW g45.0<16,16,1>UW g122.16<16,16,1>UB {align1}; |
| 121 |
avg.sat (16) g46.0<1>UW g46.0<16,16,1>UW g123.0<16,16,1>UB {align1}; |
| 122 |
avg.sat (16) g47.0<1>UW g47.0<16,16,1>UW g123.16<16,16,1>UB {align1}; |
| 123 |
avg.sat (16) g48.0<1>UW g48.0<16,16,1>UW g124.0<16,16,1>UB {align1}; |
| 124 |
avg.sat (16) g49.0<1>UW g49.0<16,16,1>UW g124.16<16,16,1>UB {align1}; |
| 125 |
avg.sat (16) g50.0<1>UW g50.0<16,16,1>UW g125.0<16,16,1>UB {align1}; |
| 126 |
avg.sat (16) g51.0<1>UW g51.0<16,16,1>UW g125.16<16,16,1>UB {align1}; |
| 127 |
|
| 128 |
include(`addidct.g4i') |
| 129 |
|
| 130 |
send (16) 0 acc0<1>UW g0<8,8,1>UW |
| 131 |
thread_spawner(0, 0, 0) mlen 1 rlen 0 { align1 EOT}; |