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 LDB filter vertical Mbaff UV ///////////////////////////////////////////////////////
  40. //
  41. //      This filter code prepares the src data and control data for ILDB filtering on all vertical edges of UV.
  42. //
  43. //      It sssumes the data for vertical de-blocking is already transposed.  
  44. //
  45. //              Chroma:
  46. //
  47. //              +-------+-------+
  48. //              |               |               |
  49. //              |               |               |
  50. //              |               |               |
  51. //              +-------+-------+
  52. //              |               |               |
  53. //              |               |               |
  54. //              |               |               |
  55. //              +-------+-------+
  56. //
  57. //              V0              V1             
  58. //              Edge    Edge   
  59. //
  60. /////////////////////////////////////////////////////////////////////////////
  61.  
  62. #if defined(_DEBUG)
  63.         mov             (1)             EntrySignatureC:w                       0xBBBC:w
  64. #endif 
  65.  
  66. //=============== Chroma deblocking ================
  67.  
  68. //---------- Deblock U external left edge ----------
  69.  
  70.         and.z.f0.0  (1) null:w          r[ECM_AddrReg, BitFlags]:ub             FilterLeftMbEdgeFlag:w          // Check for FilterLeftMbEdgeFlag
  71.  
  72.         cmp.z.f0.1      (1)     null:w  VertEdgePattern:uw              LEFT_FIELD_CUR_FRAME:w
  73.  
  74.         // Get Luma maskA and maskB    
  75.         shr (16)        TempRow0(0)<1>          r[ECM_AddrReg, wEdgeCntlMapA_ExtLeftVert0]<0;1,0>:uw            RRampW(0)
  76.         shr (16)        TempRow1(0)<1>          r[ECM_AddrReg, wEdgeCntlMapB_ExtLeftVert0]<0;1,0>:uw            RRampW(0)
  77.        
  78.     (f0.0)      jmpi    BYPASS_V0_UV    // Do not deblock Left ext edge
  79.  
  80.         cmp.z.f0.0      (1)     null:w  VertEdgePattern:uw              LEFT_FRAME_CUR_FIELD:w
  81.  
  82.         (-f0.1) jmpi V0_U_NEXT1 // Jump if not LEFT_FIELD_CUR_FRAME
  83.  
  84.         //----- For LEFT_FIELD_CUR_FRAME
  85.        
  86.         // Extract UV MaskA and MaskB from every other 2 bits of Y masks
  87.         and.nz.f0.0 (8) null:w                  TempRow0(0)<4;2,1>              1:w
  88.         and.nz.f0.1 (8) null:w                  TempRow1(0)<4;2,1>              1:w
  89.  
  90.         // For FieldModeLeftMbFlag=1 && FieldModeCurrentMbFlag=0
  91.         mov     (4)     Mbaff_ALPHA(0,0)<2>             r[ECM_AddrReg, bAlphaLeft0_Cb]<0;1,0>:ub        { NoDDClr }
  92.         mov     (4)     Mbaff_ALPHA(0,1)<2>             r[ECM_AddrReg, bAlphaLeft1_Cb]<0;1,0>:ub        { NoDDChk }
  93.         mov     (4)     Mbaff_BETA(0,0)<2>              r[ECM_AddrReg, bBetaLeft0_Cb]<0;1,0>:ub         { NoDDClr }
  94.         mov     (4)     Mbaff_BETA(0,1)<2>              r[ECM_AddrReg, bBetaLeft1_Cb]<0;1,0>:ub         { NoDDChk }
  95.         mov (4) Mbaff_TC0(0,0)<2>               r[ECM_AddrReg, bTc0_v00_0_Cb]<4;4,1>:ub         { NoDDClr }
  96.         mov (4) Mbaff_TC0(0,1)<2>               r[ECM_AddrReg, bTc0_v00_1_Cb]<4;4,1>:ub         { NoDDChk }
  97.  
  98.         jmpi    V0_U_NEXT3
  99.  
  100. V0_U_NEXT1:
  101.        
  102.         (-f0.0) jmpi V0_U_NEXT2                 // Jump if not LEFT_FRAME_CUR_FIELD
  103.        
  104.         //----- For LEFT_FRAME_CUR_FIELD
  105.                
  106.         // Extract UV MaskA and MaskB from every other bit of Y masks
  107.         and.nz.f0.0 (8) null:w                  TempRow0(0)<16;8,2>             1:w
  108.         and.nz.f0.1 (8) null:w                  TempRow1(0)<16;8,2>             1:w
  109.  
  110.         // For FieldModeLeftMbFlag=0 && FieldModeCurrentMbFlag=1
  111.         mov     (4)     Mbaff_ALPHA(0,0)<1>             r[ECM_AddrReg, bAlphaLeft0_Cb]<0;1,0>:ub        { NoDDClr }
  112.         mov     (4)     Mbaff_ALPHA(0,4)<1>             r[ECM_AddrReg, bAlphaLeft1_Cb]<0;1,0>:ub        { NoDDChk }
  113.         mov     (4)     Mbaff_BETA(0,0)<1>              r[ECM_AddrReg, bBetaLeft0_Cb]<0;1,0>:ub         { NoDDClr }
  114.         mov     (4)     Mbaff_BETA(0,4)<1>              r[ECM_AddrReg, bBetaLeft1_Cb]<0;1,0>:ub         { NoDDChk }
  115.         mov (4) Mbaff_TC0(0,0)<1>               r[ECM_AddrReg, bTc0_v00_0_Cb]<4;4,1>:ub         { NoDDClr }
  116.         mov (4) Mbaff_TC0(0,4)<1>               r[ECM_AddrReg, bTc0_v00_1_Cb]<4;4,1>:ub         { NoDDChk }
  117.  
  118.         jmpi    V0_U_NEXT3
  119.        
  120. V0_U_NEXT2:
  121.  
  122.         // Extract UV MaskA and MaskB from every other bit of Y masks
  123.         and.nz.f0.0 (8) null:w                  TempRow0(0)<16;8,2>             1:w
  124.         and.nz.f0.1 (8) null:w                  TempRow1(0)<16;8,2>             1:w
  125.        
  126.         // Both are frames or fields
  127.         mov     (8) Mbaff_ALPHA(0,0)<1>         r[ECM_AddrReg, bAlphaLeft0_Cb]<0;1,0>:ub
  128.         mov     (8) Mbaff_BETA(0,0)<1>          r[ECM_AddrReg, bBetaLeft0_Cb]<0;1,0>:ub
  129.         mov (8) Mbaff_TC0(0,0)<1>               r[ECM_AddrReg, bTc0_v00_0_Cb]<1;2,0>:ub
  130.  
  131. V0_U_NEXT3:    
  132.  
  133.         //      p1 = Prev MB U row 0
  134.         //      p0 = Prev MB U row 1
  135.         //      q0 = Cur MB U row 0
  136.         //      q1 = Cur MB U row 1
  137.         mov (1) P_AddrReg:w             PREV_MB_U_BASE:w        { NoDDClr }
  138.         mov (1) Q_AddrReg:w             SRC_MB_U_BASE:w         { NoDDChk }
  139.  
  140.         // Store UV MaskA and MaskB
  141.         mov (2)         MaskA<1>:uw                     f0.0<2;2,1>:uw
  142.  
  143.         CALL(FILTER_UV_MBAFF, 1)       
  144. //-----------------------------------------------
  145.  
  146. //---------- Deblock V external left edge ----------
  147.  
  148.         // No change to MaskA and MaskB
  149.  
  150.         cmp.z.f0.0      (4)     null:w  VertEdgePattern:uw              LEFT_FIELD_CUR_FRAME:w
  151.         cmp.z.f0.1      (4)     null:w  VertEdgePattern:uw              LEFT_FRAME_CUR_FIELD:w
  152.  
  153.         // both are frame or field
  154.         mov     (8) Mbaff_ALPHA(0,0)<1>         r[ECM_AddrReg, bAlphaLeft0_Cr]<0;1,0>:ub
  155.         mov     (8) Mbaff_BETA(0,0)<1>          r[ECM_AddrReg, bBetaLeft0_Cr]<0;1,0>:ub
  156.         mov (8) Mbaff_TC0(0,0)<1>               r[ECM_AddrReg, bTc0_v00_0_Cr]<1;2,0>:ub
  157.                                
  158.         //      p1 = Prev MB V row 0
  159.         //      p0 = Prev MB V row 1
  160.         //      q0 = Cur MB V row 0
  161.         //      q1 = Cur MB V row 1
  162.         mov (1) P_AddrReg:w             PREV_MB_V_BASE:w        { NoDDClr }
  163.         mov (1) Q_AddrReg:w             SRC_MB_V_BASE:w         { NoDDChk }
  164.                                
  165.         // For FieldModeLeftMbFlag=1 && FieldModeCurrentMbFlag=0
  166.         (f0.0) mov (4)  Mbaff_ALPHA(0,0)<2>             r[ECM_AddrReg, bAlphaLeft0_Cr]<0;1,0>:ub        { NoDDClr }
  167.         (f0.0) mov (4)  Mbaff_ALPHA(0,1)<2>             r[ECM_AddrReg, bAlphaLeft1_Cr]<0;1,0>:ub        { NoDDChk }    
  168.         (f0.0) mov (4)  Mbaff_BETA(0,0)<2>              r[ECM_AddrReg, bBetaLeft0_Cr]<0;1,0>:ub         { NoDDClr }
  169.         (f0.0) mov (4)  Mbaff_BETA(0,1)<2>              r[ECM_AddrReg, bBetaLeft1_Cr]<0;1,0>:ub         { NoDDChk }
  170.         (f0.0) mov (4)  Mbaff_TC0(0,0)<2>               r[ECM_AddrReg, bTc0_v00_0_Cr]<4;4,1>:ub         { NoDDClr }
  171.         (f0.0) mov (4)  Mbaff_TC0(0,1)<2>               r[ECM_AddrReg, bTc0_v00_1_Cr]<4;4,1>:ub         { NoDDChk }
  172.  
  173.         // For FieldModeLeftMbFlag=0 && FieldModeCurrentMbFlag=1
  174.         (f0.1) mov (4)  Mbaff_ALPHA(0,0)<1>             r[ECM_AddrReg, bAlphaLeft0_Cr]<0;1,0>:ub        { NoDDClr }
  175.         (f0.1) mov (4)  Mbaff_ALPHA(0,4)<1>             r[ECM_AddrReg, bAlphaLeft1_Cr]<0;1,0>:ub        { NoDDChk }
  176.         (f0.1) mov (4)  Mbaff_BETA(0,0)<1>              r[ECM_AddrReg, bBetaLeft0_Cr]<0;1,0>:ub         { NoDDClr }
  177.         (f0.1) mov (4)  Mbaff_BETA(0,4)<1>              r[ECM_AddrReg, bBetaLeft1_Cr]<0;1,0>:ub         { NoDDChk }
  178.         (f0.1) mov (4)  Mbaff_TC0(0,0)<1>               r[ECM_AddrReg, bTc0_v00_0_Cr]<4;4,1>:ub         { NoDDClr }
  179.         (f0.1) mov (4)  Mbaff_TC0(0,4)<1>               r[ECM_AddrReg, bTc0_v00_1_Cr]<4;4,1>:ub         { NoDDChk }
  180.  
  181.         // Set UV MaskA and MaskB
  182.         mov (2)         f0.0<1>:uw              MaskA<2;2,1>:uw
  183.  
  184.         CALL(FILTER_UV_MBAFF, 1)       
  185. //-----------------------------------------------
  186.  
  187. BYPASS_V0_UV:
  188.         // Set EdgeCntlMap2 = 0, so it always uses bS < 4 algorithm.
  189.         // Same alpha and beta for all internal vert and horiz edges
  190.  
  191. //---------- Deblock U internal vert middle edge ----------
  192.  
  193.         //***** Need to take every other bit to form U or V maskA
  194.         shr (16) TempRow0(0)<1>                 r[ECM_AddrReg, wEdgeCntlMap_IntMidVert]<0;1,0>:uw               RRampW(0)
  195.  
  196.         //      p1 = Cur MB U row 2
  197.         //      p0 = Cur MB U row 3
  198.         //      q0 = Cur MB U row 4
  199.         //      q1 = Cur MB U row 5
  200.         mov (1) P_AddrReg:w             4*UV_ROW_WIDTH+SRC_MB_U_BASE:w          { NoDDClr }             // Skip 2 U rows and 2 V rows
  201.         mov (1) Q_AddrReg:w             8*UV_ROW_WIDTH+SRC_MB_U_BASE:w          { NoDDChk }
  202.  
  203.         mov     (8) Mbaff_ALPHA(0,0)<1>         r[ECM_AddrReg, bAlphaInternal_Cb]<0;1,0>:ub
  204.         mov     (8) Mbaff_BETA(0,0)<1>          r[ECM_AddrReg, bBetaInternal_Cb]<0;1,0>:ub
  205.         mov (8) Mbaff_TC0(0,0)<1>               r[ECM_AddrReg, bTc0_v02_Cb]<1;2,0>:ub
  206.  
  207.         and.nz.f0.0 (8) null:w                  TempRow0(0)<16;8,2>             1:w
  208.  
  209.         // Store MaskA and MaskB
  210.         mov (1) f0.1:uw         0:w                    
  211.         mov (1) MaskB:uw        0:w                     { NoDDClr }
  212.         mov (1) MaskA:uw        f0.0:uw         { NoDDChk }
  213.  
  214.         CALL(FILTER_UV_MBAFF, 1)       
  215.        
  216. //-----------------------------------------------
  217.  
  218.  
  219. //---------- Deblock V internal vert middle edge ----------
  220.  
  221.         //      P1 = Cur MB V row 2
  222.         //      P0 = Cur MB V row 3
  223.         //      Q0 = Cur MB V row 4
  224.         //      Q1 = Cur MB V row 5
  225.         mov (1) P_AddrReg:w             4*UV_ROW_WIDTH+SRC_MB_V_BASE:w          { NoDDClr }             // Skip 2 U rows and 2 V rows
  226.         mov (1) Q_AddrReg:w             8*UV_ROW_WIDTH+SRC_MB_V_BASE:w          { NoDDChk }
  227.  
  228.         // Put MaskA into f0.0
  229.         // Put MaskB into f0.1
  230.         mov (2) f0.0<1>:uw              MaskA<2;2,1>:uw
  231.  
  232.         mov     (8) Mbaff_ALPHA(0,0)<1>         r[ECM_AddrReg, bAlphaInternal_Cr]<0;1,0>:ub
  233.         mov     (8) Mbaff_BETA(0,0)<1>          r[ECM_AddrReg, bBetaInternal_Cr]<0;1,0>:ub
  234.         mov (8) Mbaff_TC0(0,0)<1>               r[ECM_AddrReg, bTc0_v02_Cr]<1;2,0>:ub
  235.  
  236.         CALL(FILTER_UV_MBAFF, 1)       
  237.  
  238. //-----------------------------------------------
  239.  
  240.