Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright © <2010>, 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
  6.  * "Software"), to deal in the Software without restriction, including
  7.  * without limitation the rights to use, copy, modify, merge, publish,
  8.  * distribute, sub license, and/or sell copies of the Software, and to
  9.  * permit persons to whom the Software is furnished to do so, subject to
  10.  * the following conditions:
  11.  *
  12.  * The above copyright notice and this permission notice (including the
  13.  * next paragraph) shall be included in all copies or substantial portions
  14.  * of the Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  19.  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
  20.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  21.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  22.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23.  *
  24.  * This file was originally licensed under the following license
  25.  *
  26.  *  Licensed under the Apache License, Version 2.0 (the "License");
  27.  *  you may not use this file except in compliance with the License.
  28.  *  You may obtain a copy of the License at
  29.  *
  30.  *      http://www.apache.org/licenses/LICENSE-2.0
  31.  *
  32.  *  Unless required by applicable law or agreed to in writing, software
  33.  *  distributed under the License is distributed on an "AS IS" BASIS,
  34.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  35.  *  See the License for the specific language governing permissions and
  36.  *  limitations under the License.
  37.  *
  38.  */
  39. ////////// AVC ILDB filter horizontal Y ///////////////////////////////////////////////////////
  40. //
  41. //      This filter code prepares the src data and control data for ILDB filtering on all horizontal edges of Y.
  42. //
  43. //      It sssumes the data for horizontal de-blocking is already transposed.  
  44. //
  45. //              Luma:
  46. //
  47. //              +-------+-------+-------+-------+               H0  Edge
  48. //              |               |               |               |               |
  49. //              |               |               |               |               |
  50. //              |               |               |               |               |
  51. //              +-------+-------+-------+-------+               H1 Edge
  52. //              |               |               |               |               |
  53. //              |               |               |               |               |
  54. //              |               |               |               |               |
  55. //              +-------+-------+-------+-------+               H2      Edge
  56. //              |               |               |               |               |
  57. //              |               |               |               |               |
  58. //              |               |               |               |               |
  59. //              +-------+-------+-------+-------+               H3 Edge
  60. //              |               |               |               |               |
  61. //              |               |               |               |               |
  62. //              |               |               |               |               |
  63. //              +-------+-------+-------+-------+
  64. //
  65. /////////////////////////////////////////////////////////////////////////////
  66.  
  67. #if defined(_DEBUG)
  68.         mov             (1)             EntrySignatureC:w                       0xBBBB:w
  69. #endif 
  70.        
  71.  
  72. //========== Luma deblocking ==========
  73.  
  74.  
  75. //---------- Deblock Y external top edge (H0)  ----------      
  76.  
  77.         // Bypass deblocking if it is the top edge of the picture.  
  78.         and.z.f0.0  (1) null:w          r[ECM_AddrReg, BitFlags]:ub             FilterTopMbEdgeFlag:w           // Check for FilterTopMbEdgeFlag
  79.  
  80. //      and.z.f0.1 (1)  null:uw         r[ECM_AddrReg, wEdgeCntlMapA_ExtTopHorz0]:uw            0xFFFF:uw       // MaskA = 0?
  81.  
  82.         // Get (alpha >> 2) + 2
  83.         shr (1) alpha2:w                r[ECM_AddrReg, bAlphaTop0_Y]:ub         2:w                     // alpha >> 2
  84.  
  85.         //      p3 = Prev MB Y row 0 = r[P_AddrReg, 0]<16;16,1>
  86.         //      p2 = Prev MB Y row 1 = r[P_AddrReg, 16]<16;16,1>
  87.         //      p1 = Prev MB Y row 2 = r[P_AddrReg, 32]<16;16,1>
  88.         //      p0 = Prev MB Y row 3 = r[P_AddrReg, 48]<16;16,1>
  89.         //      q0 = Cur MB Y row 0  = r[Q_AddrReg, 0]<16;16,1>
  90.         //      q1 = Cur MB Y row 1  = r[Q_AddrReg, 16]<16;16,1>
  91.         //      q2 = Cur MB Y row 2  = r[Q_AddrReg, 32]<16;16,1>
  92.         //      q3 = Cur MB Y row 3  = r[Q_AddrReg, 48]<16;16,1>
  93. //      mov (1) P_AddrReg:w             PREV_MB_Y_BASE:w                { NoDDClr }
  94.         mov (1) P_AddrReg:w             TOP_MB_Y_BASE:w         { NoDDClr }
  95.         mov (1) Q_AddrReg:w             SRC_MB_Y_BASE:w         { NoDDChk }
  96.        
  97.         // Get horizontal border edge control data
  98.         // alpha = bAlphaTop0_Y
  99.         // beta = bBetaTop0_Y
  100.         mov     (2)     alpha<1>:w      r[ECM_AddrReg, bAlphaTop0_Y]<2;2,1>:ub                  { NoDDClr }             // 2 channels for alpha and beta
  101.        
  102.         mov (2) MaskA<1>:uw     r[ECM_AddrReg, wEdgeCntlMapA_ExtTopHorz0]<2;2,1>:uw             { NoDDClr, NoDDChk }
  103.  
  104.         // tc0 has bTc0_h03_0_Y | bTc0_h02_0_Y | bTc0_h01_0_Y | bTc0_h00_0_Y
  105.         mov (4) tc0<1>:ub       r[ECM_AddrReg, bTc0_h00_0_Y]<4;4,1>:ub                  { NoDDChk }
  106.  
  107. //    (f0.0)    jmpi    BYPASS_EXT_TOP_EDGE_Y  
  108. //      (f0.0.anyv)      jmpi   BYPASS_EXT_TOP_EDGE_Y
  109.        
  110.         add (1) alpha2:w                alpha2:w                2:w                                                             // alpha2 = (alpha >> 2) + 2  
  111.                
  112. //      CALL(FILTER_Y, 1)
  113.         PRED_CALL(-f0.0, FILTER_Y, 1)
  114.  
  115. //BYPASS_EXT_TOP_EDGE_Y:
  116. //------------------------------------------------------------------
  117.         // Same alpha, alpha2, beta and MaskB for all internal edges
  118.  
  119.         // Get (alpha >> 2) + 2
  120.         shr (1) alpha2:w                r[ECM_AddrReg, bAlphaInternal_Y]:ub             2:w                     // alpha >> 2
  121.  
  122.         // alpha = bAlphaInternal_Y
  123.         // beta = bBetaInternal_Y
  124.         mov     (2)     alpha<1>:w      r[ECM_AddrReg, bAlphaInternal_Y]<2;2,1>:ub              { NoDDClr }
  125.  
  126.         // Set MaskB = 0 for all 3 int edges, so it always uses bS < 4 algorithm.
  127.         mov (1) MaskB:uw        0:w                                                                     { NoDDChk }
  128.  
  129.         add (1) alpha2:w                alpha2:w                2:w                                                             // alpha2 = (alpha >> 2) + 2  
  130.                
  131.  
  132. //---------- Deblock Y internal top edge (H1)  ----------
  133.  
  134.         // Bypass deblocking if FilterInternal4x4EdgesFlag = 0  
  135.         and.z.f0.0 (1) null:w   r[ECM_AddrReg, BitFlags]:ub             FilterInternal4x4EdgesFlag:w            // Check for FilterInternal4x4EdgesFlag
  136.  
  137.         //      p3 = Cur MB Y row 0 = r[P_AddrReg, 0]<16;16,1>
  138.         //      p2 = Cur MB Y row 1 = r[P_AddrReg, 16]<16;16,1>
  139.         //      p1 = Cur MB Y row 2 = r[P_AddrReg, 32]<16;16,1>
  140.         //      p0 = Cur MB Y row 3 = r[P_AddrReg, 48]<16;16,1>
  141.         //      q0 = Cur MB Y row 4 = r[Q_AddrReg, 0]<16;16,1>
  142.         //      q1 = Cur MB Y row 5 = r[Q_AddrReg, 16]<16;16,1>
  143.         //      q2 = Cur MB Y row 6 = r[Q_AddrReg, 32]<16;16,1>
  144.         //      q3 = Cur MB Y row 7 = r[Q_AddrReg, 48]<16;16,1>
  145.         mov (1) P_AddrReg:w             SRC_MB_Y_BASE:w                                 { NoDDClr }
  146.         mov (1) Q_AddrReg:w             4*Y_ROW_WIDTH+SRC_MB_Y_BASE:w   { NoDDChk }
  147.  
  148.         mov (1) MaskA:uw        r[ECM_AddrReg, wEdgeCntlMap_IntTopHorz]:uw              { NoDDClr }
  149.        
  150.         // tc0 has bTc0_h13_Y + bTc0_h12_Y + bTc0_h11_Y + bTc0_h10_Y           
  151.         mov (4) tc0<1>:ub       r[ECM_AddrReg, bTc0_h10_Y]<4;4,1>:ub                    { NoDDChk }
  152.  
  153. //    (f0.0)    jmpi    BYPASS_4x4_DEBLOCK_H
  154. //      (f0.0.anyv)      jmpi   BYPASS_4x4_DEBLOCK_H
  155.  
  156. //      CALL(FILTER_Y, 1)
  157.         PRED_CALL(-f0.0, FILTER_Y, 1)
  158.  
  159. //BYPASS_4x4_DEBLOCK_H:
  160. //------------------------------------------------------------------
  161.  
  162.  
  163. //---------- Deblock Y internal mid horizontal edge (H2) ----------
  164.  
  165.         // Bypass deblocking if FilterInternal8x8EdgesFlag = 0  
  166.         and.z.f0.0 (1) null:w   r[ECM_AddrReg, BitFlags]:ub             FilterInternal8x8EdgesFlag:w            // Check for FilterInternal4x4EdgesFlag
  167.  
  168. //      and.z.f0.1 (1)  null:uw         r[ECM_AddrReg, wEdgeCntlMap_IntMidHorz]:uw              0xFFFF:uw       // MaskA = 0?
  169.  
  170.         //      p3 = Cur MB Y row 4  = r[P_AddrReg, 0]<16;16,1>
  171.         //      p2 = Cur MB Y row 5  = r[P_AddrReg, 16]<16;16,1>
  172.         //      p1 = Cur MB Y row 6  = r[P_AddrReg, 32]<16;16,1>
  173.         //      p0 = Cur MB Y row 7  = r[P_AddrReg, 48]<16;16,1>
  174.         //      q0 = Cur MB Y row 8  = r[Q_AddrReg, 0]<16;16,1>
  175.         //      q1 = Cur MB Y row 9  = r[Q_AddrReg, 16]<16;16,1>
  176.         //      q2 = Cur MB Y row 10 = r[Q_AddrReg, 32]<16;16,1>
  177.         //      q3 = Cur MB Y row 11 = r[Q_AddrReg, 48]<16;16,1>
  178.         mov (1) P_AddrReg:w             4*Y_ROW_WIDTH+SRC_MB_Y_BASE:w      { NoDDClr }
  179.         mov (1) Q_AddrReg:w             8*Y_ROW_WIDTH+SRC_MB_Y_BASE:w      { NoDDChk }
  180.  
  181.         mov (1) MaskA:uw        r[ECM_AddrReg, wEdgeCntlMap_IntMidHorz]:uw      { NoDDClr }
  182. //      mov (1) MaskB:uw        0:w                                             // Set MaskB = 0, so it always uses bS < 4 algorithm.
  183.  
  184.         // tc0 has bTc0_h23_Y + bTc0_h22_Y + bTc0_h21_Y + bTc0_h20_Y           
  185.         mov (4) tc0<1>:ub       r[ECM_AddrReg, bTc0_h20_Y]<4;4,1>:ub                    { NoDDChk }
  186.  
  187. //    (f0.0)    jmpi    BYPASS_8x8_DEBLOCK_H
  188. //      (f0.0.anyv)      jmpi   BYPASS_8x8_DEBLOCK_H
  189.    
  190. //      CALL(FILTER_Y, 1)
  191.         PRED_CALL(-f0.0, FILTER_Y, 1)
  192.  
  193. //BYPASS_8x8_DEBLOCK_H:
  194. //-----------------------------------------------
  195.  
  196.  
  197. //---------- Deblock Y internal bottom edge (H3) ----------      
  198.  
  199.         // Bypass deblocking if FilterInternal4x4EdgesFlag = 0  
  200.         and.z.f0.0 (1) null:w   r[ECM_AddrReg, BitFlags]:ub             FilterInternal4x4EdgesFlag:w            // Check for FilterInternal4x4EdgesFlag
  201.  
  202. //      and.z.f0.1 (1)  null:uw         r[ECM_AddrReg, wEdgeCntlMap_IntBotHorz]:uw              0xFFFF:uw       // MaskA = 0?
  203.  
  204.         //      p3 = Cur MB Y row 8  = r[P_AddrReg, 0]<16;16,1>
  205.         //      p2 = Cur MB Y row 9  = r[P_AddrReg, 16]<16;16,1>
  206.         //      p1 = Cur MB Y row 10 = r[P_AddrReg, 32]<16;16,1>
  207.         //      p0 = Cur MB Y row 11 = r[P_AddrReg, 48]<16;16,1>
  208.         //      q0 = Cur MB Y row 12 = r[Q_AddrReg, 0]<16;16,1>
  209.         //      q1 = Cur MB Y row 13 = r[Q_AddrReg, 16]<16;16,1>
  210.         //      q2 = Cur MB Y row 14 = r[Q_AddrReg, 32]<16;16,1>
  211.         //      q3 = Cur MB Y row 15 = r[Q_AddrReg, 48]<16;16,1>
  212.         mov (1) P_AddrReg:w             8*Y_ROW_WIDTH+SRC_MB_Y_BASE:w           { NoDDClr }
  213.         mov (1) Q_AddrReg:w             12*Y_ROW_WIDTH+SRC_MB_Y_BASE:w      { NoDDChk }
  214.  
  215.        
  216.         mov (1) MaskA:uw        r[ECM_AddrReg, wEdgeCntlMap_IntBotHorz]:uw      { NoDDClr }
  217. //      mov (1) MaskB:uw        0:w                                             // Set MaskB = 0, so it always uses bS < 4 algorithm.
  218.  
  219.         // tc0 has bTc0_h33_Y + bTc0_h32_Y + bTc0_h31_Y + bTc0_h30_Y        
  220.         mov (4) tc0<1>:ub       r[ECM_AddrReg, bTc0_h30_Y]<4;4,1>:ub                    { NoDDChk }
  221.  
  222. //    (f0.0)    jmpi    BYPASS_4x4_DEBLOCK_H2
  223. //      (f0.0.anyv)      jmpi   BYPASS_4x4_DEBLOCK_H2
  224.    
  225. //      CALL(FILTER_Y, 1)
  226.         PRED_CALL(-f0.0, FILTER_Y, 1)
  227.  
  228. //BYPASS_4x4_DEBLOCK_H2:
  229. //-----------------------------------------------
  230.