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.  * Authors:
  40.  *    Halley Zhao <halley.zhao@intel.com>
  41.  */
  42.  
  43. // Module name: YUVX_Save_RGBX_Fix.asm
  44. //----------------------------------------------------------------
  45.  
  46. #include "RGBX_Load_16x8.inc"
  47.  
  48. #if (0)
  49.     #define nTEMP0          34        // transformation coefficient
  50.     #define nTEMP1          35        // one row of R (first half register is used)
  51.     #define nTEMP2          36        // one row of G (first half register is used)
  52.     #define nTEMP3          37        // one row of B (first half register is used)
  53.     #define nTEMP4          38        // mul and add
  54.     #define nTEMP5          39        // mul and add
  55.     #define nTEMP6          40        // mul and add
  56.     #define nTEMP7          41        // mul and add
  57.     #define nTEMP8          42        // sum of mul
  58.     #define nTEMP10         44        
  59.     #define nTEMP10         44        // split ub pixel to word width 1st quarter
  60.     #define nTEMP12         46        // split ub pixel to word width 2nd quarter
  61.     #define nTEMP14         48        // split ub pixel to word width 3rd quarter
  62.     #define nTEMP16         50        // split ub pixel to word width 4th quarter
  63.     #define nTEMP17         51
  64.     #define nTEMP18         52
  65.    
  66.     #define nTEMP24         58        // temp using for repeat U/V in NV12_Load_8x4.asm
  67. #endif
  68.  
  69. #define ONE_ROW_DEBUG                      0
  70.  
  71. #if (ONE_ROW_DEBUG)
  72.     #define ROW_NUM                        0
  73.     #define DBG_ROWNUM_BASE                1
  74.     CHANNEL_2                              2
  75. #else
  76.     #define ROW_NUM                        %1
  77.     $for(0; <nY_NUM_OF_ROWS; 1) {
  78. #endif    
  79.     // C = Y' - 16          D = U - 128         E = V - 128
  80.    add (16)     REG2(r,nTEMP10,0)<1>:w           ubDEST_RGBX(0,ROW_NUM*64   )<0;16,1>           bYUV_OFF<0;4,1>:b
  81.    add (16)     REG2(r,nTEMP12,0)<1>:w           ubDEST_RGBX(0,ROW_NUM*64+16)<0;16,1>           bYUV_OFF<0;4,1>:b
  82.    add (16)     REG2(r,nTEMP14,0)<1>:w           ubDEST_RGBX(0,ROW_NUM*64+32)<0;16,1>           bYUV_OFF<0;4,1>:b
  83.    add (16)     REG2(r,nTEMP16,0)<1>:w           ubDEST_RGBX(0,ROW_NUM*64+48)<0;16,1>           bYUV_OFF<0;4,1>:b
  84.  
  85. #if (ONE_ROW_DEBUG)
  86.    mov (16) ubDEST_RGBX(0,(DBG_ROWNUM_BASE)*64   )<1>  REG2(r,nTEMP10, 0)<0;16,2>:ub
  87.    mov (16) ubDEST_RGBX(0,(DBG_ROWNUM_BASE)*64+16)<1>  REG2(r,nTEMP12, 0)<0;16,2>:ub
  88.    mov (16) ubDEST_RGBX(0,(DBG_ROWNUM_BASE)*64+32)<1>  REG2(r,nTEMP14, 0)<0;16,2>:ub
  89.    mov (16) ubDEST_RGBX(0,(DBG_ROWNUM_BASE)*64+48)<1>  REG2(r,nTEMP16, 0)<0;16,2>:ub
  90. #endif
  91.    
  92.    // |Y|U|V|X|==>|R|G|B|X|  
  93.    // ###### do one row for R
  94.    // #### mul and add
  95.    mul.sat (16)  REG2(r, nTEMP4, 0)<1>:w      REG2(r,nTEMP10,0)<0;16,1>:w        wYUV_to_RGB_CH2_Coef_Fix<0;4,1>:w
  96.    mul.sat (16)  REG2(r, nTEMP5, 0)<1>:w      REG2(r,nTEMP12,0)<0;16,1>:w        wYUV_to_RGB_CH2_Coef_Fix<0;4,1>:w
  97.    mul.sat (16)  REG2(r, nTEMP6, 0)<1>:w      REG2(r,nTEMP14,0)<0;16,1>:w        wYUV_to_RGB_CH2_Coef_Fix<0;4,1>:w
  98.    mul.sat (16)  REG2(r, nTEMP7, 0)<1>:w      REG2(r,nTEMP16,0)<0;16,1>:w        wYUV_to_RGB_CH2_Coef_Fix<0;4,1>:w
  99.  
  100.  #if (ONE_ROW_DEBUG)
  101.    mov (8) ubDEST_RGBX(0,(DBG_ROWNUM_BASE+1)*64+CHANNEL_2   )<4>  bYUV_to_RGB_CH2_Coef_Fix<0;8,1>:ub
  102.    mov (8) ubDEST_RGBX(0,(DBG_ROWNUM_BASE+1)*64+CHANNEL_2+32)<4>  bYUV_to_RGB_CH2_Coef_Fix<0;8,1>:ub
  103.  
  104.    mov (8) ubDEST_RGBX(0,(DBG_ROWNUM_BASE+2)*64+CHANNEL_2   )<4>  REG2(r,nTEMP4, 0)<0;8,1>:ub
  105.    mov (8) ubDEST_RGBX(0,(DBG_ROWNUM_BASE+2)*64+CHANNEL_2+32)<4>  REG2(r,nTEMP4, 8)<0;8,1>:ub
  106.  #endif
  107.  
  108.    add.sat (4)   REG2(r, nTEMP4, 0)<4>:uw      REG2(r, nTEMP4, 0)<0;4,4>:w      REG2(r, nTEMP4, 1)<0;4,4>:w      
  109.    add.sat (4)   REG2(r, nTEMP5, 0)<4>:uw      REG2(r, nTEMP5, 0)<0;4,4>:w      REG2(r, nTEMP5, 1)<0;4,4>:w      
  110.    add.sat (4)   REG2(r, nTEMP6, 0)<4>:uw      REG2(r, nTEMP6, 0)<0;4,4>:w      REG2(r, nTEMP6, 1)<0;4,4>:w      
  111.    add.sat (4)   REG2(r, nTEMP7, 0)<4>:uw      REG2(r, nTEMP7, 0)<0;4,4>:w      REG2(r, nTEMP7, 1)<0;4,4>:w      
  112.    add.sat (4)   REG2(r, nTEMP4, 0)<4>:uw      REG2(r, nTEMP4, 0)<0;4,4>:uw      REG2(r, nTEMP4, 2)<0;4,4>:w      
  113.    add.sat (4)   REG2(r, nTEMP5, 0)<4>:uw      REG2(r, nTEMP5, 0)<0;4,4>:uw      REG2(r, nTEMP5, 2)<0;4,4>:w      
  114.    add.sat (4)   REG2(r, nTEMP6, 0)<4>:uw      REG2(r, nTEMP6, 0)<0;4,4>:uw      REG2(r, nTEMP6, 2)<0;4,4>:w      
  115.    add.sat (4)   REG2(r, nTEMP7, 0)<4>:uw      REG2(r, nTEMP7, 0)<0;4,4>:uw      REG2(r, nTEMP7, 2)<0;4,4>:w      
  116.  
  117.    // ####  write one row of R to rnTEMP1
  118.    mov (4)  REG2(r, nTEMP8,  0)<1>:uw    REG2(r, nTEMP4, 0)<0; 4, 4>:uw
  119.    mov (4)  REG2(r, nTEMP8,  4)<1>:uw    REG2(r, nTEMP5, 0)<0; 4, 4>:uw
  120.    mov (4)  REG2(r, nTEMP8,  8)<1>:uw    REG2(r, nTEMP6, 0)<0; 4, 4>:uw
  121.    mov (4)  REG2(r, nTEMP8, 12)<1>:uw    REG2(r, nTEMP7, 0)<0; 4, 4>:uw
  122.  
  123.  #if (ONE_ROW_DEBUG)
  124.    mov (8) ubDEST_RGBX(0,(DBG_ROWNUM_BASE+3)*64+CHANNEL_2   )<4>  REG2(r,nTEMP8, 0)<0;8,1>:ub
  125.    mov (8) ubDEST_RGBX(0,(DBG_ROWNUM_BASE+3)*64+CHANNEL_2+32)<4>  REG2(r,nTEMP8, 8)<0;8,1>:ub
  126.  #endif    
  127.  
  128.    add.sat (16) REG2(r, nTEMP8,  0)<1>:uw    REG2(r, nTEMP8, 0)<0; 16, 1>:uw    0x80:uw
  129.    shl.sat (16) REG2(r, nTEMP8,  0)<1>:uw    REG2(r, nTEMP8, 0)<0; 16, 1>:uw    1:w
  130.    mov (16) REG2(r, nTEMP1,  0)<1>:ub   REG2(r, nTEMP8, 1)<0; 16, 2>:ub
  131.    
  132.  #if (ONE_ROW_DEBUG)
  133.    mov (8) ubDEST_RGBX(0,(DBG_ROWNUM_BASE+4)*64+CHANNEL_2   )<4>  REG2(r,nTEMP8, 0)<0;8,1>:ub
  134.    mov (8) ubDEST_RGBX(0,(DBG_ROWNUM_BASE+4)*64+CHANNEL_2+32)<4>  REG2(r,nTEMP8, 8)<0;8,1>:ub
  135.  #endif    
  136.    // ###### do one row for G
  137.    // #### mul and add
  138.    mul.sat (16)  REG2(r, nTEMP4, 0)<1>:w      REG2(r,nTEMP10,0)<0;16,1>:w        wYUV_to_RGB_CH1_Coef_Fix<0;4,1>:w
  139.    mul.sat (16)  REG2(r, nTEMP5, 0)<1>:w      REG2(r,nTEMP12,0)<0;16,1>:w        wYUV_to_RGB_CH1_Coef_Fix<0;4,1>:w
  140.    mul.sat (16)  REG2(r, nTEMP6, 0)<1>:w      REG2(r,nTEMP14,0)<0;16,1>:w        wYUV_to_RGB_CH1_Coef_Fix<0;4,1>:w
  141.    mul.sat (16)  REG2(r, nTEMP7, 0)<1>:w      REG2(r,nTEMP16,0)<0;16,1>:w        wYUV_to_RGB_CH1_Coef_Fix<0;4,1>:w
  142.  
  143.    add.sat (4)   REG2(r, nTEMP4, 0)<4>:uw      REG2(r, nTEMP4, 0)<0;4,4>:w      REG2(r, nTEMP4, 1)<0;4,4>:w      
  144.    add.sat (4)   REG2(r, nTEMP5, 0)<4>:uw      REG2(r, nTEMP5, 0)<0;4,4>:w      REG2(r, nTEMP5, 1)<0;4,4>:w      
  145.    add.sat (4)   REG2(r, nTEMP6, 0)<4>:uw      REG2(r, nTEMP6, 0)<0;4,4>:w      REG2(r, nTEMP6, 1)<0;4,4>:w      
  146.    add.sat (4)   REG2(r, nTEMP7, 0)<4>:uw      REG2(r, nTEMP7, 0)<0;4,4>:w      REG2(r, nTEMP7, 1)<0;4,4>:w      
  147.    add.sat (4)   REG2(r, nTEMP4, 0)<4>:uw      REG2(r, nTEMP4, 0)<0;4,4>:uw      REG2(r, nTEMP4, 2)<0;4,4>:w      
  148.    add.sat (4)   REG2(r, nTEMP5, 0)<4>:uw      REG2(r, nTEMP5, 0)<0;4,4>:uw      REG2(r, nTEMP5, 2)<0;4,4>:w      
  149.    add.sat (4)   REG2(r, nTEMP6, 0)<4>:uw      REG2(r, nTEMP6, 0)<0;4,4>:uw      REG2(r, nTEMP6, 2)<0;4,4>:w      
  150.    add.sat (4)   REG2(r, nTEMP7, 0)<4>:uw      REG2(r, nTEMP7, 0)<0;4,4>:uw      REG2(r, nTEMP7, 2)<0;4,4>:w      
  151.  
  152.    // ####  write one row of G to rnTEMP2
  153.    mov (4)  REG2(r, nTEMP8,  0)<1>:uw    REG2(r, nTEMP4, 0)<0; 4, 4>:uw
  154.    mov (4)  REG2(r, nTEMP8,  4)<1>:uw    REG2(r, nTEMP5, 0)<0; 4, 4>:uw
  155.    mov (4)  REG2(r, nTEMP8,  8)<1>:uw    REG2(r, nTEMP6, 0)<0; 4, 4>:uw
  156.    mov (4)  REG2(r, nTEMP8, 12)<1>:uw    REG2(r, nTEMP7, 0)<0; 4, 4>:uw
  157.    
  158.    add (16) REG2(r, nTEMP8,  0)<1>:uw    REG2(r, nTEMP8, 0)<0; 16, 1>:uw    0x80:uw // saturation
  159.    shl.sat (16) REG2(r, nTEMP8,  0)<1>:uw    REG2(r, nTEMP8, 0)<0; 16, 1>:uw    1:w
  160.    mov (16) REG2(r, nTEMP2,  0)<1>:ub   REG2(r, nTEMP8, 1)<0; 16, 2>:ub
  161.  
  162.    // ###### do one row for B
  163.    // #### mul and add
  164.    mul.sat (16)  REG2(r, nTEMP4, 0)<1>:w      REG2(r,nTEMP10,0)<0;16,1>:w        wYUV_to_RGB_CH0_Coef_Fix<0;4,1>:w
  165.    mul.sat (16)  REG2(r, nTEMP5, 0)<1>:w      REG2(r,nTEMP12,0)<0;16,1>:w        wYUV_to_RGB_CH0_Coef_Fix<0;4,1>:w
  166.    mul.sat (16)  REG2(r, nTEMP6, 0)<1>:w      REG2(r,nTEMP14,0)<0;16,1>:w        wYUV_to_RGB_CH0_Coef_Fix<0;4,1>:w
  167.    mul.sat (16)  REG2(r, nTEMP7, 0)<1>:w      REG2(r,nTEMP16,0)<0;16,1>:w        wYUV_to_RGB_CH0_Coef_Fix<0;4,1>:w
  168.  
  169.    // I had reduced the following add because U coef is zero for B; but in order to support BGR/RGB at the same time, I have to add it back.
  170.    add.sat (4)   REG2(r, nTEMP4, 0)<4>:uw      REG2(r, nTEMP4, 0)<0;4,4>:w      REG2(r, nTEMP4, 1)<0;4,4>:w      
  171.    add.sat (4)   REG2(r, nTEMP5, 0)<4>:uw      REG2(r, nTEMP5, 0)<0;4,4>:w      REG2(r, nTEMP5, 1)<0;4,4>:w      
  172.    add.sat (4)   REG2(r, nTEMP6, 0)<4>:uw      REG2(r, nTEMP6, 0)<0;4,4>:w      REG2(r, nTEMP6, 1)<0;4,4>:w      
  173.    add.sat (4)   REG2(r, nTEMP7, 0)<4>:uw      REG2(r, nTEMP7, 0)<0;4,4>:w      REG2(r, nTEMP7, 1)<0;4,4>:w      
  174.    add.sat (4)   REG2(r, nTEMP4, 0)<4>:uw      REG2(r, nTEMP4, 0)<0;4,4>:uw      REG2(r, nTEMP4, 2)<0;4,4>:w      
  175.    add.sat (4)   REG2(r, nTEMP5, 0)<4>:uw      REG2(r, nTEMP5, 0)<0;4,4>:uw      REG2(r, nTEMP5, 2)<0;4,4>:w      
  176.    add.sat (4)   REG2(r, nTEMP6, 0)<4>:uw      REG2(r, nTEMP6, 0)<0;4,4>:uw      REG2(r, nTEMP6, 2)<0;4,4>:w      
  177.    add.sat (4)   REG2(r, nTEMP7, 0)<4>:uw      REG2(r, nTEMP7, 0)<0;4,4>:uw      REG2(r, nTEMP7, 2)<0;4,4>:w      
  178.  
  179.    // ####  write one row of B to rnTEMP3
  180.    mov (4)  REG2(r, nTEMP8,  0)<1>:uw    REG2(r, nTEMP4, 0)<0; 4, 4>:uw
  181.    mov (4)  REG2(r, nTEMP8,  4)<1>:uw    REG2(r, nTEMP5, 0)<0; 4, 4>:uw
  182.    mov (4)  REG2(r, nTEMP8,  8)<1>:uw    REG2(r, nTEMP6, 0)<0; 4, 4>:uw
  183.    mov (4)  REG2(r, nTEMP8, 12)<1>:uw    REG2(r, nTEMP7, 0)<0; 4, 4>:uw
  184.  
  185.    add.sat (16) REG2(r, nTEMP8,  0)<1>:uw    REG2(r, nTEMP8, 0)<0; 16, 1>:uw    0x80:uw // saturation
  186.    shl.sat (16) REG2(r, nTEMP8,  0)<1>:uw    REG2(r, nTEMP8, 0)<0; 16, 1>:uw    1:w
  187.    mov (16) REG2(r, nTEMP3,  0)<1>:ub   REG2(r, nTEMP8, 1)<0; 16, 2>:ub
  188.  
  189.    // B
  190.    mov (8) ubDEST_RGBX(0,ROW_NUM*64   )<4>  REG2(r,nTEMP3, 0)<0;8,1>:ub
  191.    mov (8) ubDEST_RGBX(0,ROW_NUM*64+32)<4>  REG2(r,nTEMP3, 8)<0;8,1>:ub
  192.    // G
  193.    mov (8) ubDEST_RGBX(0,ROW_NUM*64+1   )<4>  REG2(r,nTEMP2, 0)<0;8,1>:ub
  194.    mov (8) ubDEST_RGBX(0,ROW_NUM*64+1+32)<4>  REG2(r,nTEMP2, 8)<0;8,1>:ub
  195.    // R
  196.    mov (8) ubDEST_RGBX(0,ROW_NUM*64+2   )<4>  REG2(r,nTEMP1, 0)<0;8,1>:ub
  197.    mov (8) ubDEST_RGBX(0,ROW_NUM*64+2+32)<4>  REG2(r,nTEMP1, 8)<0;8,1>:ub
  198. #if (!ONE_ROW_DEBUG)    
  199.    }
  200. #endif
  201.