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. #if !defined(__AVC_ILDB_LUMA_CORE_MBAFF__)      // Make sure this file is only included once
  40. #define __AVC_ILDB_LUMA_CORE_MBAFF__
  41.  
  42. ////////// AVC ILDB Luma Core Mbaff /////////////////////////////////////////////////////////////////////////////////
  43. //
  44. //      This core performs AVC LUMA ILDB filtering on one horizontal edge (16 pixels) of a MB.  
  45. //      If data is transposed, it can also de-block a vertical edge.
  46. //
  47. //      Bafore calling this subroutine, caller needs to set the following parameters.
  48. //
  49. //      - EdgeCntlMap1                          //      Edge control map A
  50. //      - EdgeCntlMap2                          //      Edge control map B
  51. //      - P_AddrReg                                     //      Src and dest address register for P pixels
  52. //      - Q_AddrReg                                     //      Src and dest address register for Q pixels      
  53. //      - alpha                                         //  alpha corresponding to the edge to be filtered
  54. //      - beta                                          //  beta corresponding to the edge to be filtered
  55. //      - tc0                                           //      tc0  corresponding to the edge to be filtered
  56. //
  57. //
  58. //      +----+----+----+----+----+----+----+----+
  59. //      | p3 | p2 | P1 | p0 | q0 | q1 | q2 | q3 |
  60. //      +----+----+----+----+----+----+----+----+
  61. //
  62. //      p3 = r[P_AddrReg, 0]<16;16,1>  
  63. //      p2 = r[P_AddrReg, 16]<16;16,1>
  64. //      p1 = r[P_AddrReg, 32]<16;16,1>
  65. //      p0 = r[P_AddrReg, 48]<16;16,1>
  66. //      q0 = r[Q_AddrReg, 0]<16;16,1>  
  67. //      q1 = r[Q_AddrReg, 16]<16;16,1>
  68. //      q2 = r[Q_AddrReg, 32]<16;16,1>
  69. //      q3 = r[Q_AddrReg, 48]<16;16,1>
  70. //
  71. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  72.  
  73. // The region is both src and dest
  74. // P0-P3 and Q0-Q3 should be only used if they have not been modified to new values  
  75. #undef  P3
  76. #undef  P2
  77. #undef  P1
  78. #undef  P0
  79. #undef  Q0
  80. #undef  Q1
  81. #undef  Q2
  82. #undef  Q3
  83.  
  84. #define P3              r[P_AddrReg,  0]<16;16,1>:ub
  85. #define P2              r[P_AddrReg, 16]<16;16,1>:ub
  86. #define P1              r[P_AddrReg, 32]<16;16,1>:ub
  87. #define P0              r[P_AddrReg, 48]<16;16,1>:ub
  88. #define Q0              r[Q_AddrReg,  0]<16;16,1>:ub
  89. #define Q1              r[Q_AddrReg, 16]<16;16,1>:ub
  90. #define Q2              r[Q_AddrReg, 32]<16;16,1>:ub
  91. #define Q3              r[Q_AddrReg, 48]<16;16,1>:ub
  92.  
  93. // New region as dest
  94. #undef  NewP2
  95. #undef  NewP1
  96. #undef  NewP0
  97. #undef  NewQ0
  98. #undef  NewQ1
  99. #undef  NewQ2
  100.  
  101. #define NewP2   r[P_AddrReg, 16]<1>:ub
  102. #define NewP1   r[P_AddrReg, 32]<1>:ub
  103. #define NewP0   r[P_AddrReg, 48]<1>:ub
  104. #define NewQ0   r[Q_AddrReg,  0]<1>:ub
  105. #define NewQ1   r[Q_AddrReg, 16]<1>:ub
  106. #define NewQ2   r[Q_AddrReg, 32]<1>:ub
  107.  
  108.  
  109.  
  110. // Filter one luma edge - mbaff
  111. FILTER_Y_MBAFF:
  112.  
  113. #if defined(_DEBUG)
  114.         mov             (1)             EntrySignatureC:w                       0x1111:w
  115. #endif
  116.         //---------- Derive filterSampleflag in AVC spec, equition (8-469) ----------
  117.         // bS is in MaskA
  118.  
  119.         // Src copy of the p3, p2, p1, p0, q0, q1, q2, q3
  120. //      mov (16) p0123_W(0)<1>          r[P_AddrReg]<16;16,1>:uw
  121. //      mov (16) p0123_W(1)<1>          r[P_AddrReg, 32]<16;16,1>:uw
  122. //      mov (16) q0123_W(0)<1>          r[Q_AddrReg]<16;16,1>:uw
  123. //      mov (16) q0123_W(1)<1>          r[Q_AddrReg, 32]<16;16,1>:uw
  124.  
  125.         // Move MaskA and MaskB to flag regs
  126.         mov (2) f0.0<1>:uw              MaskA<2;2,1>:uw
  127.  
  128.         add (16) q0_p0(0)<1>            Q0                      -P0                             // q0-p0
  129.         add (16) TempRow0(0)<1>         P1                      -P0                             // p1-p0
  130.         add (16) TempRow1(0)<1>         Q1                      -Q0                             // q1-q0
  131.  
  132.         // abs(q0-p0) < alpha
  133.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)q0_p0(0)           Mbaff_ALPHA(0)
  134.         // abs(p1-p0) < Beta
  135.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)TempRow0(0)        Mbaff_BETA(0)
  136.         // abs(q1-q0) < Beta
  137.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)TempRow1(0)        Mbaff_BETA(0)
  138.  
  139.         //-----------------------------------------------------------------------------------------
  140.  
  141.     (f0.0)      if      (16)            MBAFF_Y_ENDIF1
  142.                 // For channels whose edge control map1 = 1 ---> perform de-blocking
  143.  
  144. //              mov (1)         f0.1:uw         MaskB:uw        {NoMask}                // Now check for which algorithm to apply
  145.  
  146.                 // (abs)ap = |p2-p0|
  147.                 add (16) ap(0)<1>               P2              -P0
  148.  
  149.                 // (abs)aq = |q2-q0|
  150.                 add (16) aq(0)<1>               Q2              -Q0
  151.  
  152.                 // Make a copy of unmodified p0 and p1 for use in q0'and q1' calculation
  153.                 mov (16) p0123_W(1)<1>          r[P_AddrReg, 32]<16;16,1>:uw            {NoMask}
  154.                        
  155.                 (f0.1)  if      (16)            MBAFF_Y_ELSE2
  156.  
  157.                         // For channels whose edge control map2 = 1 ---> bS = 4 algorithm
  158.  
  159.                         // Compute q0', q1' and q2'
  160.                         //-----------------------------------------------------------------------------
  161.                         // bS = 4 Algorithm :                  
  162.                         //
  163.                         // gama = |p0-q0| < ((alpha >> 2) + 2)
  164.                         // deltap = (ap<beta) && gama;                  // deep filter flag
  165.                         //      if (deltap) {
  166.                         //              p0' = (        p2 +2*p1 +2*p0 +2*q0 + q1 + 4) >> 3;
  167.                         //              p1' = (        p2 +  p1 +  p0 +  q0      + 2) >> 2;
  168.                         //              p2' = (2*p3 +3*p2 +  p1 +  p0 +  q0      + 4) >> 3;
  169.                         //      } else {  
  170.                         //              p0' = (            2*p1 +  p0 +  q1      + 2) >> 2;
  171.                         //      }
  172.                         //-----------------------------------------------------------------------------
  173.  
  174.                         // gama = |p0-q0| < ((alpha >> 2) + 2) = |p0-q0| < alpha2  
  175.                         cmp.l.f0.1 (16) null:w  (abs)q0_p0(0)   Mbaff_ALPHA2(0)
  176.  
  177.                         // Common P01 = p0 + p1
  178.                         add (16)        P0_plus_P1(0)<1>        P0                      P1     
  179.  
  180.                         // Common Q01 = q0 + q1
  181.                         add (16)        Q0_plus_Q1(0)<1>        Q0                      Q1
  182.  
  183.                         mov (1) f0.0:uw                 f0.1:uw                                         {NoMask}
  184.  
  185.                         // deltap = ((abs)ap < beta) && gama
  186.                         (f0.1) cmp.l.f0.1 (16) null:w   (abs)ap(0)              Mbaff_BETA(0)                                                   // (abs)ap < beta ?
  187.  
  188.                         // deltaq = ((abs)aq < beta) && gama
  189.                         (f0.0) cmp.l.f0.0 (16) null:w   (abs)aq(0)              Mbaff_BETA(0)                                                   // (abs)aq < beta ?
  190.  
  191.  
  192.                         (f0.1)  if      (16)            MBAFF_Y_ELSE3                   // for channels its deltap = true
  193.        
  194.                         add (16)        P2_plus_P3(0)<1>        P2              P3
  195.                        
  196.                         // A =  p1 + p0 + q0 = P01 + q0
  197.                         add (16)        A(0)<1>                 P0_plus_P1(0)           Q0                                                      // A =  P01 + q0
  198.  
  199.                         // Now acc0 = A
  200.  
  201.                         // B =  p2 + p1 + p0 + q0 + 4 = p2 + A + 4
  202.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w               4:w                                                             // p2 + 4
  203.                         add (16)        BB(0)<1>                        acc0.0<16;16,1>:w               P2                                      // B = p2 + A + 4
  204.  
  205.                         // Now acc0 = B
  206.  
  207.                         // p2' = (2*p3 +3*p2 + A + 4) >> 3 = (2*(p3+p2) + B) >> 3
  208.                         mac (16)        acc0.0<1>:w             P2_plus_P3(0)           2:w            
  209.                         shr.sat (16) TempRow3B(0)<2>    acc0.0<16;16,1>:w               3:w
  210.  
  211.                         // p1' = (p2 + A + 2) >> 2 = (B - 2) >> 2
  212.                         add (16)        acc0.0<1>:w             BB(0)                   -2:w
  213.                         shr.sat (16) TempRow1B(0)<2>    acc0.0<16;16,1>:w               2:w
  214.        
  215.                         // p0' = (p2 +2*A + q1 + 4) >> 3 = (B + A + q1) >> 3
  216.                         add (16)        acc0.0<1>:w             Q1                              A(0)                                                    // B + A
  217.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w               BB(0)                                                   // B + A + q1
  218.                         shr.sat (16) TempRow0B(0)<2>    acc0.0<16;16,1>:w               3:w                                                             // (B + A + q1) >> 3
  219.  
  220.                         mov (16)        NewP2           TempRow3B(0)                                            // p2'
  221.                         mov (16)        NewP1           TempRow1B(0)                                            // p1'                 
  222.                         mov (16)        NewP0           TempRow0B(0)                                            // p0'
  223.  
  224. MBAFF_Y_ELSE3:
  225.                         else (16)               MBAFF_Y_ENDIF3          // for channels its deltap = false
  226.  
  227.                         // p0' = (2*p1 + p0 + q1 + 2) >> 2 =  (p1 + P01 + q1 + 2) >> 2
  228.                         add (16)        acc0.0<1>:w             P1                      P0_plus_P1(0)                   // p1 + P01 (TempRow1(0) = P01)
  229.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w       Q1                             
  230.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w       2:w                     // p1 + P01 + q1 + 2
  231.  
  232.                         shr.sat (16) TempRow0B(0)<2>    acc0.0<16;16,1>:w               2:w     // >> 2
  233.                         mov (16)        NewP0           TempRow0B(0)                                            // p0'
  234.  
  235.                         endif
  236.  
  237. MBAFF_Y_ENDIF3:
  238.                         // Compute q0', q1' and q2'
  239.                         //-----------------------------------------------------------------------------
  240.                         // bS = 4 Algorithm (cont):                    
  241.                         //
  242.                         //      deltaq = (aq<beta) && gama;             // deep filter flag
  243.                         //      if (deltaq) {
  244.                         //              q0' = (        q2 +2*q1 +2*q0 +2*p0 + p1 + 4) >> 3;
  245.                         //              q1' = (        q2 +  q1 +  q0 +  p0      + 2) >> 2;
  246.                         //              q2' = (2*q3 +3*q2 +  q1 +  q0 +  p0      + 4) >> 3;
  247.                         //      } else {
  248.                         //              q0' = (            2*q1 +  q0 +  p1      + 2) >> 2;
  249.                         //      }
  250.                        
  251.                         (f0.0)  if      (16)            MBAFF_Y_ELSE4                   // for channels its deltaq = true
  252.                        
  253.                         add (16)        Q2_plus_Q3(0)<1>        Q2                      Q3
  254.  
  255.                         // A =  q1 + q0 + p0 = Q01 + p0
  256.                         add (16)        A(0)<1>                 Q0_plus_Q1(0)           p0(0)                                                   // A =  q1+q0 + p0
  257.  
  258.                         // B =  q2 + q1 + q0 + p0 + 4 = q2 + A + 4
  259.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w               4:w                                                     // q2 + 4
  260.                         add (16)        BB(0)<1>                        acc0.0<16;16,1>:w               Q2                                                              // B = q2 + A + 4
  261.                        
  262.                         // Acc0 = B
  263.  
  264.                         // q2' = (2*q3 +3*q2 + A + 4) >> 3 = (2*(q3+q2) + B) >> 3
  265.                         mac (16)        acc0.0<1>:w             Q2_plus_Q3(0)   2:w
  266.                         shr.sat (16) TempRow3B(0)<2>    acc0.0<16;16,1>:w               3:w
  267.  
  268.                         // q1' = (q2 + A + 2) >> 2 = (B - 2) >> 2
  269.                         add (16)        acc0.0<1>:w             BB(0)                   -2:w
  270.                         shr.sat (16) TempRow1B(0)<2>    acc0.0<16;16,1>:w       2:w
  271.                        
  272.                         // q0' = (q2 +2*A + p1 + 4) >> 3 = (B + A + p1) >> 3
  273.                         add (16)        acc0.0<1>:w             p1(0)                                   A(0)
  274.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w               BB(0)
  275.                         shr.sat (16) TempRow0B(0)<2>    acc0.0<16;16,1>:w       3:w
  276.                        
  277.                         mov (16)        NewQ2           TempRow3B(0)                                            // q2'
  278.                         mov (16)        NewQ1           TempRow1B(0)                                            // q1'
  279.                         mov (16)        NewQ0           TempRow0B(0)                                            // q0'
  280.  
  281. MBAFF_Y_ELSE4:
  282.                         else (16)               MBAFF_Y_ENDIF4          // for channels its deltaq = false
  283.  
  284.                         // q0' = (2*q1 + q0 + p1 + 2) >> 2 =  (q1 + Q01 + p1 + 2) >> 2
  285.                         // Use original p1 values in p1(0)
  286.                         add (16)        acc0.0<1>:w             p1(0)                   Q0_plus_Q1(0)                   // p1 + P01 (TempRow1(0) = P01)
  287.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w       Q1                             
  288.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w       2:w                     // p1 + P01 + q1 + 2
  289.  
  290.                         shr.sat (16)    TempRow0B(0)<2>         acc0.0<16;16,1>:w               2:w                                                             // >> 2
  291.                         mov (16)        NewQ0           TempRow0B(0)                                            // q0'
  292.  
  293.                         endif
  294. MBAFF_Y_ENDIF4:
  295.  
  296.                        
  297.                         // Done with bS = 4 algorithm
  298.                        
  299. MBAFF_Y_ELSE2:
  300.                 else    (16)            MBAFF_Y_ENDIF2
  301.                         // For channels whose edge control map2 = 0 ---> bS < 4 algorithm
  302.  
  303.                         //-----------------------------------------------------------------------------
  304.                         // bS < 4 Algorithm :
  305.                         // tc = tc0 + (|p2-p0|<Beta ? 1 : 0) + (|q2-q0|<Beta ? 1 : 0)
  306.                         // delta = Clip3(-tc, tc, ((((q0-p0)<<2) + (p1-q1) + 4) >> 3))
  307.                         // p0' = Clip1(p0 + delta) = Clip3(0, 0xFF, p0 + delta)
  308.                         // q0' = Clip1(q0 - delta) = Clip3(0, 0xFF, q0 - delta)
  309.                         // if (|p2-p0|<Beta)
  310.                         //              p1' = p1 + Clip3(-tc0, tc0, (p2 + ((p0+q0+1)>>1) - (p1<<1)) >> 1 )
  311.                         // if (|q2-q0|<Beta)
  312.                         //              q1' = q1 + Clip3(-tc0, tc0, (q2 + ((p0+q0+1)>>1) - (q1<<1)) >> 1 )
  313.                         //-----------------------------------------------------------------------------
  314.                        
  315.                         mov (16)        tc_exp(0)<1>            Mbaff_TC0(0)                                                            // tc = tc0_exp first
  316.                        
  317.                         cmp.l.f0.0 (16) null:w          (abs)ap(0)                      Mbaff_BETA(0)                           // |p2-p0|<Beta ?
  318.                         cmp.l.f0.1 (16) null:w          (abs)aq(0)                      Mbaff_BETA(0)                           // |q2-q0|<Beta ?
  319.                                
  320.                         //--- Use free cycles here ---
  321.                         // delta = Clip3(-tc, tc, ((((q0-p0)<<2) + (p1-q1) + 4) >> 3))
  322.                         // 4 * (q0-p0) + p1 - q1 + 4
  323.                         add (16) acc0<1>:w              P1                      4:w                                                     // p1 + 4
  324.                         mac (16) acc0<1>:w              q0_p0(0)        4:w                                                     // 4 * (q0-p0) + p1 + 4
  325.                         add (16) acc0<1>:w              acc0<16;16,1>:w         -Q1                                     // 4 * (q0-p0) + p1 - q1 + 4
  326.                         shr (16) TempRow0(0)<1> acc0<16;16,1>:w         3:w
  327.                                                
  328.                         // Continue on getting tc_exp
  329.                         (f0.0) add (16) tc_exp(0)<1>    tc_exp(0)       1:w                                                     // tc0_exp + (|p2-p0|<Beta ? 1 : 0)
  330.                         mov (2) CTemp1_W<1>:w           f0.0<2;2,1>:w                   {NoMask}                                        // Save |p2-p0|<Beta flag                      
  331.                         (f0.1) add (16) tc_exp(0)<1>    tc_exp(0)       1:w                                                     // tc_exp = tc0_exp + (|p2-p0|<Beta ? 1 : 0) + (|q2-q0|<Beta ? 1 : 0)
  332.                                
  333.                         // Continue on cliping tc to get delta
  334.                         cmp.g.f0.0      (16) null:w             TempRow0(0)             tc_exp(0)                                       // Clip if delta' > tc
  335.                         cmp.l.f0.1      (16) null:w             TempRow0(0)             -tc_exp(0)                                      // Clip if delta' < -tc
  336.  
  337.                         //--- Use free cycles here ---
  338.                         // common = (p0+q0+1) >> 1        --->  TempRow2(0)
  339.                         // Same as avg of p0 and q0
  340.                         avg (16) TempRow2(0)<1>         P0                      Q0
  341.  
  342.                         // Continue on cliping tc to get delta
  343.                         (f0.0) mov (16) TempRow0(0)<1>                          tc_exp(0)
  344.                         (f0.1) mov (16) TempRow0(0)<1>                          -tc_exp(0)
  345.  
  346.                         //--- Use free cycles here ---
  347.                         mov (2) f0.0<1>:w               CTemp1_W<2;2,1>:w       {NoMask}                        // CTemp1_W = (|p2-p0|<Beta)
  348.                                                                                                                                                         // CTemp2_W = (|q2-q0|<Beta)           
  349.  
  350.                         // p0' = Clip1(p0 + delta) = Clip3(0, 0xFF, p0 + delta)
  351.                         // q0' = Clip1(q0 - delta) = Clip3(0, 0xFF, q0 - delta)
  352.                         add.sat (16) TempRow1B(0)<2>            P0                      TempRow0(0)                                     // p0+delta
  353.                         add.sat (16) TempRow0B(0)<2>            Q0                      -TempRow0(0)                            // q0-delta
  354.                        
  355.                         mov (16) NewP0          TempRow1B(0)                                    // p0'
  356.                         mov (16) NewQ0          TempRow0B(0)                                    // q0'
  357.  
  358.                         //-----------------------------------------------------------------------
  359.  
  360.                         // Now compute p1' and q1'
  361.  
  362.                         // if (|p2-p0|<Beta)
  363.                         (f0.0)  if      (16)            MBAFF_Y_ENDIF6
  364.  
  365.                         // p1' = p1 + Clip3(-tc0, tc0, adj)
  366.                         // adj = (p2 + common - (p1<<1)) >> 1 = (p2 + common - (p1*2)) >> 1
  367.                         add (16) acc0<1>:w      P2              TempRow2(0)                                                     // TempRow2(0) = common = (p0+q0+1) >> 1
  368.                         mac (16) acc0<1>:w      P1              -2:w
  369.                         shr (16) TempRow1(0)<1>         acc0<16;16,1>:w         1:w
  370.  
  371.                         // tc clip to get tc_adj
  372.                         cmp.g.f0.0      (16) null:w             TempRow1(0)             Mbaff_TC0(0)                                    // Clip if delta' > tc
  373.                         cmp.l.f0.1      (16) null:w             TempRow1(0)             -Mbaff_TC0(0)                                   // Clip if delta' < -tc
  374.                        
  375.                         (f0.0) mov (16) TempRow1(0)<1>                          Mbaff_TC0(0)
  376.                         (f0.1) mov (16) TempRow1(0)<1>                          -Mbaff_TC0(0)
  377.  
  378.                         //--- Use free cycles here ---
  379.                         mov (1) f0.1:w          CTemp2_W:w                              {NoMask}                        // CTemp2_W = (|q2-q0|<Beta)
  380.  
  381.                         // p1' = p1 + tc_adj
  382.                         add.sat (16) TempRow1B(0)<2>            P1                      TempRow1(0)                                     // p1+tc_adj
  383.                         mov (16) NewP1                  TempRow1B(0)                            // p1'
  384.                         //------------------------------------------------------------------------
  385.  
  386. MBAFF_Y_ENDIF6:
  387.                         endif
  388.                        
  389.                         // if (|q2-q0|<Beta)
  390.                         (f0.1)  if      (16)            MBAFF_Y_ENDIF7
  391.  
  392.                         // q1' = q1 + Clip3(-tc0, tc0, adj)
  393.                         // adj = (q2 + common - (q1<<1)) >> 1
  394.                         // same as q2 + common - (q1 * 2)
  395.                         add (16) acc0<1>:w      Q2              TempRow2(0)
  396.                         mac (16) acc0<1>:w      Q1              -2:w
  397.                         shr (16) TempRow1(0)<1>         acc0<16;16,1>:w         1:w    
  398.                                        
  399.                         // tc clip to get tc_adj
  400.                         cmp.g.f0.0      (16) null:w             TempRow1(0)             Mbaff_TC0(0)                                    // Clip if delta' > tc
  401.                         cmp.l.f0.1      (16) null:w             TempRow1(0)             -Mbaff_TC0(0)                                   // Clip if delta' < -tc
  402.  
  403.                         (f0.0) mov (16) TempRow1(0)<1>                          Mbaff_TC0(0)
  404.                         (f0.1) mov (16) TempRow1(0)<1>                          -Mbaff_TC0(0)
  405.                        
  406.                         // q1' = q1 + tc_adj
  407.                         add.sat (16) TempRow1B(0)<2>            Q1                      TempRow1(0)                                     // q1+tc_adj
  408.                         mov (16) NewQ1                  TempRow1B(0)                            // q1'
  409.                        
  410.                         //------------------------------------------------------------------------                     
  411. MBAFF_Y_ENDIF7:
  412.                         endif
  413.  
  414.                 endif
  415. MBAFF_Y_ENDIF2:
  416. MBAFF_Y_ENDIF1:
  417.         endif
  418.  
  419. RETURN
  420.  
  421. #endif  // !defined(__AVC_ILDB_LUMA_CORE_MBAFF__)
  422.