| 1 |
/* |
| 2 |
* All Video Processing kernels |
| 3 |
* Copyright © <2010>, Intel Corporation. |
| 4 |
* |
| 5 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 6 |
* copy of this software and associated documentation files (the |
| 7 |
* "Software"), to deal in the Software without restriction, including |
| 8 |
* without limitation the rights to use, copy, modify, merge, publish, |
| 9 |
* distribute, sub license, and/or sell copies of the Software, and to |
| 10 |
* permit persons to whom the Software is furnished to do so, subject to |
| 11 |
* the following conditions: |
| 12 |
* |
| 13 |
* The above copyright notice and this permission notice (including the |
| 14 |
* next paragraph) shall be included in all copies or substantial portions |
| 15 |
* of the Software. |
| 16 |
* |
| 17 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 18 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
| 20 |
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR |
| 21 |
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 |
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 |
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 |
* |
| 25 |
* This file was originally licensed under the following license |
| 26 |
* |
| 27 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 28 |
* you may not use this file except in compliance with the License. |
| 29 |
* You may obtain a copy of the License at |
| 30 |
* |
| 31 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 32 |
* |
| 33 |
* Unless required by applicable law or agreed to in writing, software |
| 34 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 35 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 36 |
* See the License for the specific language governing permissions and |
| 37 |
* limitations under the License. |
| 38 |
* |
| 39 |
*/ |
| 40 |
|
| 41 |
|
| 42 |
// Module name: PL8x4_Save_NV12.asm |
| 43 |
// |
| 44 |
// Save entire current planar frame data block of size 16x8 |
| 45 |
//--------------------------------------------------------------- |
| 46 |
// Symbols needed to be defined before including this module |
| 47 |
// |
| 48 |
// DWORD_ALIGNED_DEST: only if DEST_Y, DEST_U, DEST_V data are DWord aligned |
| 49 |
// ORIX: |
| 50 |
//--------------------------------------------------------------- |
| 51 |
|
| 52 |
#include "PL8x4_Save_NV12.inc" |
| 53 |
|
| 54 |
mov (8) mMSGHDR<1>:ud rMSGSRC<8;8,1>:ud |
| 55 |
|
| 56 |
#if !defined(SAVE_UV_ONLY) |
| 57 |
// Save current planar frame Y block data (16x8) ------------------------------- |
| 58 |
|
| 59 |
mov (2) mMSGHDR.0<1>:d wORIX<2;2,1>:w // Block origin |
| 60 |
mov (1) mMSGHDR.2<1>:ud nDPW_BLOCK_SIZE_Y:ud // Block width and height (16x8) |
| 61 |
#endif |
| 62 |
|
| 63 |
//Use the mask to determine which pixels shouldn't be over-written |
| 64 |
and (1) acc0<1>:ud udBLOCK_MASK<0;1,0>:ud 0x00FFFFFF:ud |
| 65 |
cmp.ge.f0.0 (1) dNULLREG acc0<0;1,0>:ud 0x00FFFFFF:ud //Check if all pixels in the block need to be modified |
| 66 |
(f0.0) jmpi WritePlanarToDataPort |
| 67 |
|
| 68 |
//If mask is not all 1's, then load the entire 16x8 block |
| 69 |
//so that only those bytes may be modified that need to be (using the mask) |
| 70 |
send (8) udSRC_Y(0)<1> mMSGHDR udDUMMY_NULL nDATAPORT_READ nDPMR_MSGDSC+nDPR_MSG_SIZE_Y+nBI_DESTINATION_Y:ud //16x8 |
| 71 |
|
| 72 |
asr (1) rMSGSRC.1<1>:ud wORIY<0;1,0>:w 1:w { NoDDClr } // U/V block origin should be half of Y's |
| 73 |
mov (1) rMSGSRC.2<1>:ud nDPW_BLOCK_SIZE_UV:ud { NoDDChk } // Block width and height (16x4) |
| 74 |
mov (8) mMSGHDR<1>:ud rMSGSRC<8;8,1>:ud //move message desrcptor to the message header |
| 75 |
send (8) udSRC_U(0)<1> mMSGHDR udDUMMY_NULL nDATAPORT_READ nDPMR_MSGDSC+nDPR_MSG_SIZE_UV+nBI_DESTINATION_UV:ud |
| 76 |
|
| 77 |
//Restore the origin information |
| 78 |
mov (2) rMSGSRC.0<1>:ud wORIX<2;2,1>:w // Block origin |
| 79 |
mov (1) rMSGSRC.2<1>:ud nDPW_BLOCK_SIZE_Y:ud // Block width and height (16x8) |
| 80 |
mov (8) mMSGHDR<1>:ud rMSGSRC<8;8,1>:ud //move message desrcptor to the message header |
| 81 |
|
| 82 |
//Merge the data |
| 83 |
mov (1) f0.1:uw ubBLOCK_MASK_V:ub //Load the mask on flag reg |
| 84 |
(f0.1) mov (8) rMASK_TEMP<1>:uw uwBLOCK_MASK_H:uw |
| 85 |
(-f0.1) mov (8) rMASK_TEMP<1>:uw 0:uw |
| 86 |
|
| 87 |
//convert the mask from 16bits to 8bits by selecting every other bit |
| 88 |
mov (1) udMASK_TEMP1(0,0)<1> 0x00040001:ud |
| 89 |
mov (1) udMASK_TEMP1(0,1)<1> 0x00400010:ud |
| 90 |
mov (1) udMASK_TEMP1(0,2)<1> 0x04000100:ud |
| 91 |
mov (1) udMASK_TEMP1(0,3)<1> 0x40001000:ud |
| 92 |
|
| 93 |
//merge the loaded block with the current block |
| 94 |
$for(0,0; <nY_NUM_OF_ROWS; 2,1) { |
| 95 |
mov (1) f0.1:uw uwMASK_TEMP(0, %1)<0;1,0> |
| 96 |
(-f0.1) mov (16) ubDEST_Y(0,%1*32)<2> ubSRC_Y(0,%1*16) |
| 97 |
|
| 98 |
and.nz.f0.1 (8) wNULLREG uwMASK_TEMP(0,%1)<0;1,0> uwMASK_TEMP1(0,0) //change the mask by selecting every other bit |
| 99 |
(-f0.1) mov (8) ubDEST_U(0, %2*16)<2> ub2SRC_U(0, %1*8)<16;8,2> |
| 100 |
(-f0.1) mov (8) ubDEST_V(0, %2*16)<2> ub2SRC_U(0, %1*8+1)<16;8,2> |
| 101 |
|
| 102 |
mov (1) f0.1:uw uwMASK_TEMP(0,1+%1)<0;1,0> |
| 103 |
(-f0.1) mov (16) ubDEST_Y(0, (1+%1)*32)<2> ubSRC_Y(0, (1+%1)*16) |
| 104 |
|
| 105 |
} |
| 106 |
|
| 107 |
WritePlanarToDataPort: |
| 108 |
#if !defined(SAVE_UV_ONLY) |
| 109 |
$for(0,0; <nY_NUM_OF_ROWS; 2,1) { |
| 110 |
mov (16) mubMSGPAYLOAD(%2,0)<1> ub2DEST_Y(%1)REGION(16,2) |
| 111 |
mov (16) mubMSGPAYLOAD(%2,16)<1> ub2DEST_Y(%1+1)REGION(16,2) |
| 112 |
} |
| 113 |
send (8) dNULLREG mMSGHDR udDUMMY_NULL nDATAPORT_WRITE nDPMW_MSGDSC+nDPW_MSG_SIZE_Y+nBI_DESTINATION_Y:ud |
| 114 |
#endif |
| 115 |
|
| 116 |
//** Save 8x4 packed U and V ----------------------------------------------------- |
| 117 |
// we could write directly wORIX to mMSGHDR and then execute asr on it, that way we could |
| 118 |
// avoid using rMSGSRC as a buffer and have one command less in code, but it is unknown whether |
| 119 |
//it is possible to do asr on mMSGHDR so we use rMSGSRC. |
| 120 |
mov (2) rMSGSRC.0<1>:d wORIX<2;2,1>:w // Block origin |
| 121 |
asr (1) rMSGSRC.1<1>:d rMSGSRC.1<0;1,0>:d 1:w // U/V block origin should be half of Y's |
| 122 |
mov (1) rMSGSRC.2<1>:ud nDPW_BLOCK_SIZE_UV:ud // U/V block width and height (16x4) |
| 123 |
mov (8) mMSGHDR<1>:ud rMSGSRC<8;8,1>:ud |
| 124 |
|
| 125 |
$for(0,0; <nY_NUM_OF_ROWS;4,1) { |
| 126 |
mov (16) mubMSGPAYLOAD(%2,0)<2> ub2DEST_U(%2)REGION(16,2) |
| 127 |
mov (16) mubMSGPAYLOAD(%2,1)<2> ub2DEST_V(%2)REGION(16,2) |
| 128 |
} |
| 129 |
send (8) dNULLREG mMSGHDR udDUMMY_NULL nDATAPORT_WRITE nDPMW_MSGDSC+nDPW_MSG_SIZE_UV+nBI_DESTINATION_UV:ud |
| 130 |
|
| 131 |
// End of PL8x4_Save_NV12 |
| 132 |
|