Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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. //---------- RGB_Scaling.asm ----------
  42. #include "Scaling.inc"
  43.  
  44.         // Build 16 elements ramp in float32 and normalized it
  45. //      mov (8)         SAMPLER_RAMP(0)<1>              0x76543210:v
  46. //      add     (8)             SAMPLER_RAMP(1)<1>              SAMPLER_RAMP(0) 8.0:f
  47. mov (4) SAMPLER_RAMP(0)<1> 0x48403000:vf                //3, 2, 1, 0 in float vector
  48. mov (4) SAMPLER_RAMP(0,4)<1> 0x5C585450:vf      //7, 6, 5, 4 in float vector
  49. add     (8)             SAMPLER_RAMP(1)<1>              SAMPLER_RAMP(0) 8.0:f
  50.  
  51. //Module: PrepareScaleCoord.asm
  52.  
  53.         // Setup for sampler msg hdr
  54.     mov (2)             rMSGSRC.0<1>:ud                 0:ud                                            { NoDDClr }     // Unused fields
  55.     mov (1)             rMSGSRC.2<1>:ud                 0:ud                                            { NoDDChk }     // Write and offset
  56.  
  57.         // Calculate 16 v based on the step Y and vertical origin
  58.         mov     (16)    mfMSGPAYLOAD(2)<1>              fSRC_VID_V_ORI<0;1,0>:f
  59.         mov     (16)    SCALE_COORD_Y<1>:f              fSRC_VID_V_ORI<0;1,0>:f
  60.  
  61.         // Calculate 16 u based on the step X and hori origin
  62. //      line (16)       mfMSGPAYLOAD(0)<1>              SCALE_STEP_X<0;1,0>:f           SAMPLER_RAMP(0)         // Assign to mrf directly
  63.         mov     (16)    acc0:f                                                  fSRC_VID_H_ORI<0;1,0>:f                                                                                 { Compr }
  64.         mac     (16)    mfMSGPAYLOAD(0)<1>      fVIDEO_STEP_X<0;1,0>:f  SAMPLER_RAMP(0)                 { Compr }                      
  65.  
  66.         //Setup the constants for line instruction
  67.         mov     (1)             SCALE_LINE_P255<1>:f            255.0:f                         { NoDDClr }     //{ NoDDClr, NoDDChk }
  68.         mov     (1)             SCALE_LINE_P0_5<1>:f            0.5:f                           { NoDDChk }
  69.  
  70.        
  71. //------------------------------------------------------------------------------
  72.  
  73. $for (0; <nY_NUM_OF_ROWS; 1) {
  74.  
  75.         // Read 16 sampled pixels and store them in float32 in 8 GRFs in the order of BGRA (VYUA).
  76.   mov (8)       MSGHDR_SCALE.0:ud      rMSGSRC.0<8;8,1>:ud    // Copy msg header and payload mirrors to MRFs
  77.         send (16)       SCALE_RESPONSE_YW(0)<1>         MSGHDR_SCALE    udDUMMY_NULL    nSMPL_ENGINE SMPLR_MSG_DSC+nSI_SRC_SIMD16_RGB+nBI_CURRENT_SRC_RGB
  78.  
  79.         // Calculate 16 v for next line
  80.         add (16)        mfMSGPAYLOAD(2)<1>              SCALE_COORD_Y<8;8,1>:f          fVIDEO_STEP_Y<0;1,0>:f  // Assign to mrf directly
  81.         add (16)        SCALE_COORD_Y<1>:f              SCALE_COORD_Y<8;8,1>:f          fVIDEO_STEP_Y<0;1,0>:f  // Assign to mrf directly
  82.  
  83.         // Scale back to [0, 255], convert f to ud
  84.         line (16)       acc0:f          SCALE_LINE_P255<0;1,0>:f        SCALE_RESPONSE_YF(0)    { Compr }                       // Process B, V
  85.         mov  (16) SCALE_RESPONSE_YD(0)<1>       acc0:f                                                                                                          { Compr }
  86.  
  87.         line (16)       acc0:f          SCALE_LINE_P255<0;1,0>:f        SCALE_RESPONSE_YF(2)    { Compr }                       // Process B, V
  88.         mov  (16) SCALE_RESPONSE_YD(2)<1>       acc0:f                                                                                                          { Compr }
  89.  
  90.         line (16)       acc0:f          SCALE_LINE_P255<0;1,0>:f        SCALE_RESPONSE_YF(4)    { Compr }                       // Process B, V
  91.         mov  (16) SCALE_RESPONSE_YD(4)<1>       acc0:f                                                                                                          { Compr }
  92.  
  93. //#if defined(SAVE_ARGB)        //Only needed if Alpha value is written to the destination
  94.         line (16)       acc0:f          SCALE_LINE_P255<0;1,0>:f        SCALE_RESPONSE_YF(6)    { Compr }                       // Process B, V
  95.         mov  (16) SCALE_RESPONSE_YD(6)<1>       acc0:f                                                                                                          { Compr }
  96. //#endif
  97.  
  98.         mov      (16)   DEST_R(%1)<1>                           SCALE_RESPONSE_YB(0)                                                                                    //possible error due to truncation - vK
  99.         mov      (16)   DEST_G(%1)<1>                           SCALE_RESPONSE_YB(2)                                                                                    //possible error due to truncation - vK
  100.         mov      (16)   DEST_B(%1)<1>                           SCALE_RESPONSE_YB(4)                                                                                    //possible error due to truncation - vK
  101.         mov      (16)   DEST_A(%1)<1>                           SCALE_RESPONSE_YB(6)                                                                                    //possible error due to truncation - vK
  102. }
  103.