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__)    // Make sure this file is only included once
  40. #define __AVC_ILDB_LUMA_CORE__
  41.  
  42. ////////// AVC ILDB Luma Core /////////////////////////////////////////////////////////////////////////////////
  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. // Filter one luma edge
  109. FILTER_Y:
  110.  
  111. #if defined(_DEBUG)
  112.         mov             (1)             EntrySignatureC:w                       0x1111:w
  113. #endif
  114.         //---------- Derive filterSampleflag in AVC spec, equition (8-469) ----------
  115.         // bS is in MaskA
  116.  
  117.         // Src copy of the p3, p2, p1, p0, q0, q1, q2, q3
  118. //      mov (16) p0123_W(0)<1>          r[P_AddrReg]<16;16,1>:uw
  119. //      mov (16) p0123_W(1)<1>          r[P_AddrReg, 32]<16;16,1>:uw
  120. //      mov (16) q0123_W(0)<1>          r[Q_AddrReg]<16;16,1>:uw
  121. //      mov (16) q0123_W(1)<1>          r[Q_AddrReg, 32]<16;16,1>:uw
  122.  
  123.         mov (2) f0.0<1>:uw              MaskA<2;2,1>:uw
  124.  
  125.         add (16) q0_p0(0)<1>            Q0              -P0                             // q0-p0
  126.         add (16) TempRow0(0)<1>         P1              -P0                             // p1-p0
  127.         add (16) TempRow1(0)<1>         Q1              -Q0                             // q1-q0
  128.  
  129.         // Build FilterSampleFlag
  130.         // abs(q0-p0) < alpha
  131.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)q0_p0(0)                   alpha:w
  132.         // abs(p1-p0) < Beta
  133.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)TempRow0(0)                beta:w
  134.         // abs(q1-q0) < Beta
  135.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)TempRow1(0)                beta:w
  136.  
  137.         //-----------------------------------------------------------------------------------------
  138.  
  139.     (f0.0)      if      (16)            Y_ENDIF1
  140.                 // For channels whose edge control map1 = 1 ---> perform de-blocking
  141.  
  142. //              mov (1)         f0.1:uw         MaskB:uw        {NoMask}                // Now check for which algorithm to apply
  143.  
  144.                 // (abs)ap = |p2-p0|
  145.                 add (16) ap(0)<1>               P2              -P0             // ap = p2-p0
  146.                 // (abs)aq = |q2-q0|
  147.                 add (16) aq(0)<1>               Q2              -Q0             // aq = q2-q0
  148.  
  149.                 // Make a copy of unmodified p0 and p1 for use in q0'and q1' calculation
  150.                 mov (16) p0123_W(1)<1>          r[P_AddrReg, 32]<16;16,1>:uw            {NoMask}
  151.  
  152.                 (f0.1)  if      (16)            Y_ELSE2
  153.  
  154.                         // For channels whose edge control map2 = 1 ---> bS = 4 algorithm
  155.  
  156.                         // Compute q0', q1' and q2'
  157.                         //-----------------------------------------------------------------------------
  158.                         // bS = 4 Algorithm :                  
  159.                         //
  160.                         // gama = |p0-q0| < ((alpha >> 2) + 2)
  161.                         // deltap = (ap<beta) && gama;                  // deep filter flag
  162.                         //      if (deltap) {
  163.                         //              p0' = (        p2 +2*p1 +2*p0 +2*q0 + q1 + 4) >> 3;
  164.                         //              p1' = (        p2 +  p1 +  p0 +  q0      + 2) >> 2;
  165.                         //              p2' = (2*p3 +3*p2 +  p1 +  p0 +  q0      + 4) >> 3;
  166.                         //      } else {  
  167.                         //              p0' = (            2*p1 +  p0 +  q1      + 2) >> 2;
  168.                         //      }
  169.                         //-----------------------------------------------------------------------------
  170.  
  171.                         // gama = |p0-q0| < ((alpha >> 2) + 2) = |p0-q0| < alpha2  
  172.                         cmp.l.f0.1 (16) null:w  (abs)q0_p0(0)   alpha2:w
  173.  
  174.                         // Common P01 = p0 + p1
  175.                         add (16)        P0_plus_P1(0)<1>        P0                      P1     
  176.  
  177.                         // Common Q01 = q0 + q1
  178.                         add (16)        Q0_plus_Q1(0)<1>        Q0                      Q1
  179.  
  180. //                      mov (1) CTemp1_W:w              f0.1:uw                                         {NoMask}
  181.                         mov (1) f0.0:uw                 f0.1:uw                                         {NoMask}
  182.        
  183.                         // deltap = ((abs)ap < beta) && gama
  184.                         (f0.1) cmp.l.f0.1 (16) null:w   (abs)ap(0)              beta<0;1,0>:w                                                   // (abs)ap < beta ?
  185.  
  186.                         // deltaq = ((abs)aq < beta) && gama
  187.                         (f0.0) cmp.l.f0.0 (16) null:w   (abs)aq(0)              beta<0;1,0>:w                                                   // (abs)aq < beta ?
  188.  
  189.  
  190. //                      mov (1) CTemp1_W:w              f0.0:uw                                         {NoMask}                                        // gama = |p0-q0| < ((alpha >> 2) + 2) for each channel
  191. //                      and (1)         f0.1:w          f0.1:uw         CTemp1_W:w              {NoMask}                                        // deltap = (ap<beta) && gama
  192.  
  193.  
  194.                         (f0.1)  if      (16)            Y_ELSE3                 // for channels its deltap = true
  195.  
  196.                         add (16)        P2_plus_P3(0)<1>        P2              P3
  197.                        
  198.                         // A =  (p1 + p0) + q0 = P01 + q0
  199.                         add (16)        A(0)<1>                 P0_plus_P1(0)           Q0                                                      // A =  P01 + q0
  200.  
  201.                         // Now acc0 = A
  202.  
  203.                         // B =  p2 + (p1 + p0 + q0) + 4 = p2 + A + 4
  204. //                      add (16)        acc0.0<1>:w             P2                              4:w                                                             // p2 + 4
  205. //                      add (16)        BB(0)<1>                        acc0.0<16;16,1>:w               A(0)                                    // B = p2 + A + 4
  206.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w               4:w                                                             // p2 + 4
  207.                         add (16)        BB(0)<1>                        acc0.0<16;16,1>:w               P2                                      // B = p2 + A + 4
  208.                        
  209.                         // Now acc0 = B
  210.  
  211.                         // p2' = (2*p3 +3*p2 + A + 4) >> 3 = (2*(p3+p2) + B) >> 3
  212. //                      mov     (16)    acc0.0<1>:w             BB(0)
  213.                         mac (16)        acc0.0<1>:w             P2_plus_P3(0)           2:w            
  214.                         shr.sat (16) TempRow3B(0)<2>    acc0.0<16;16,1>:w               3:w
  215.                        
  216.                         // p1' = (p2 + A + 2) >> 2 = (B - 2) >> 2
  217.                         add (16)        acc0.0<1>:w             BB(0)                   -2:w
  218.                         shr.sat (16) TempRow1B(0)<2>    acc0.0<16;16,1>:w               2:w
  219.        
  220.                         // p0' = (p2 +2*A + q1 + 4) >> 3 = (B + A + q1) >> 3
  221.                         add (16)        acc0.0<1>:w             Q1                              A(0)                                                    // B + A
  222.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w               BB(0)                                                   // B + A + q1
  223.                         shr.sat (16) TempRow0B(0)<2>    acc0.0<16;16,1>:w               3:w                                                             // (B + A + q1) >> 3
  224.  
  225.                         // p2' = (2*p3 +3*p2 + A + 4) >> 3 = (2*(p3+p2) + B) >> 3
  226. //                      mov     (16)    acc0.0<1>:w             BB(0)
  227. //                      mac (16)        acc0.0<1>:w             P2_plus_P3(0)           2:w            
  228. //                      shr.sat (16) TempRow3B(0)<2>    acc0.0<16;16,1>:w               3:w
  229.  
  230.                         mov (16)        NewP2           TempRow3B(0)                                            // p2'
  231.                         mov (16)        NewP1           TempRow1B(0)                                            // p1'                 
  232.                         mov (16)        NewP0           TempRow0B(0)                                            // p0'
  233.  
  234. Y_ELSE3:
  235.                         else (16)               Y_ENDIF3                // for channels its deltap = false
  236.  
  237.                         // p0' = (2*p1 + p0 + q1 + 2) >> 2 =  (p1 + P01 + q1 + 2) >> 2
  238.                         add (16)        acc0.0<1>:w             P1                      P0_plus_P1(0)                   // p1 + P01 (TempRow1(0) = P01)
  239.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w       Q1                             
  240.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w       2:w                     // p1 + P01 + q1 + 2
  241.  
  242.                         shr.sat (16) TempRow0B(0)<2>    acc0.0<16;16,1>:w               2:w     // >> 2
  243.                         mov (16)        NewP0           TempRow0B(0)                                            // p0'
  244.  
  245.                         endif
  246. Y_ENDIF3:
  247.                         // Compute q0', q1' and q2'
  248.                         //-----------------------------------------------------------------------------
  249.                         // bS = 4 Algorithm (cont):                    
  250.                         //
  251.                         //      deltaq = (aq<beta) && gama;             // deep filter flag
  252.                         //      if (deltaq) {
  253.                         //              q0' = (        q2 +2*q1 +2*q0 +2*p0 + p1 + 4) >> 3;
  254.                         //              q1' = (        q2 +  q1 +  q0 +  p0      + 2) >> 2;
  255.                         //              q2' = (2*q3 +3*q2 +  q1 +  q0 +  p0      + 4) >> 3;
  256.                         //      } else {
  257.                         //              q0' = (            2*q1 +  q0 +  p1      + 2) >> 2;
  258.                         //      }
  259.                        
  260.                         // deltaq = ((abs)aq < beta) && gama
  261. //                      cmp.l.f0.1 (16) null:w  (abs)aq(0)              beta<0;1,0>:w                                                   // (abs)aq < beta ?
  262.  
  263.                         // Common Q01 = q0 + q1
  264. //                      add (16)        Q0_plus_Q1(0)<1>        Q0                      Q1
  265.                        
  266. //                      and (1)         f0.1:w          f0.1:uw         CTemp1_W:w              {NoMask}                                // deltaq = ((abs)ap < beta) && gama
  267.  
  268.                         (f0.0)  if      (16)            Y_ELSE4                 // for channels its deltaq = true
  269.                        
  270.                         add (16)        Q2_plus_Q3(0)<1>        Q2                      Q3
  271.  
  272.                         // A =  (q1 + q0) + p0 = Q01 + p0
  273.                         add (16)        A(0)<1>                 Q0_plus_Q1(0)           p0(0)                                                   // A =  q1+q0 + p0
  274.  
  275.                         // Acc0 = A
  276.  
  277.                         // B =  q2 + q1 + q0 + p0 + 4 = q2 + A + 4
  278.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w               4:w                                                     // q2 + 4
  279.                         add (16)        BB(0)<1>                        acc0.0<16;16,1>:w               Q2                                                              // B = q2 + A + 4
  280.  
  281.                         // Acc0 = B
  282.                        
  283.                         // q2' = (2*q3 +3*q2 + A + 4) >> 3 = (2*(q3+q2) + B) >> 3
  284. //                      mov (16)        acc0.0<1>:w             BB(0)  
  285.                         mac (16)        acc0.0<1>:w             Q2_plus_Q3(0)   2:w
  286.                         shr.sat (16) TempRow3B(0)<2>    acc0.0<16;16,1>:w               3:w
  287.  
  288.                         // q1' = (q2 + A + 2) >> 2 = (B - 2) >> 2
  289.                         add (16)        acc0.0<1>:w             BB(0)                   -2:w
  290.                         shr.sat (16) TempRow1B(0)<2>    acc0.0<16;16,1>:w       2:w
  291.                        
  292.                         // q0' = (q2 +2*A + p1 + 4) >> 3 = (B + A + p1) >> 3
  293.                         add (16)        acc0.0<1>:w             p1(0)                                   A(0)
  294.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w               BB(0)
  295.                         shr.sat (16) TempRow0B(0)<2>    acc0.0<16;16,1>:w       3:w
  296.                        
  297.                         mov (16)        NewQ2           TempRow3B(0)                                            // q2'
  298.                         mov (16)        NewQ1           TempRow1B(0)                                            // q1'
  299.                         mov (16)        NewQ0           TempRow0B(0)                                            // q0'
  300.  
  301. Y_ELSE4:
  302.                         else (16)               Y_ENDIF4                // for channels its deltaq = false
  303.  
  304.                         // q0' = (2*q1 + q0 + p1 + 2) >> 2 =  (q1 + Q01 + p1 + 2) >> 2
  305.                         // Use original p1 values in p1(0)
  306.                         add (16)        acc0.0<1>:w             p1(0)                   Q0_plus_Q1(0)                   // p1 + P01 (TempRow1(0) = P01)
  307.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w       Q1                             
  308.                         add (16)        acc0.0<1>:w             acc0.0<16;16,1>:w       2:w                     // p1 + P01 + q1 + 2
  309.  
  310.                         shr.sat (16)    TempRow0B(0)<2>         acc0.0<16;16,1>:w               2:w                                                             // >> 2
  311.                         mov (16)        NewQ0           TempRow0B(0)                                            // q0'
  312.  
  313.                         endif
  314. Y_ENDIF4:
  315.  
  316.                        
  317.                         // Done with bS = 4 algorithm
  318.                        
  319. Y_ELSE2:
  320.                 else    (16)            Y_ENDIF2
  321.                         // For channels whose edge control map2 = 0 ---> bS < 4 algorithm
  322.  
  323.                         //-----------------------------------------------------------------------------
  324.                         // bS < 4 Algorithm :
  325.                         // tc = tc0 + (|p2-p0|<Beta ? 1 : 0) + (|q2-q0|<Beta ? 1 : 0)
  326.                         // delta = Clip3(-tc, tc, ((((q0-p0)<<2) + (p1-q1) + 4) >> 3))
  327.                         // p0' = Clip1(p0 + delta) = Clip3(0, 0xFF, p0 + delta)
  328.                         // q0' = Clip1(q0 - delta) = Clip3(0, 0xFF, q0 - delta)
  329.                         // if (|p2-p0|<Beta)
  330.                         //              p1' = p1 + Clip3(-tc0, tc0, (p2 + ((p0+q0+1)>>1) - (p1<<1)) >> 1 )
  331.                         // if (|q2-q0|<Beta)
  332.                         //              q1' = q1 + Clip3(-tc0, tc0, (q2 + ((p0+q0+1)>>1) - (q1<<1)) >> 1 )
  333.                         //-----------------------------------------------------------------------------
  334.                        
  335.                         // Expand tc0
  336.                         mov (16)        tc_exp(0)<1>    tc0<1;4,0>:ub   {NoMask}
  337.                         mov (16)        tc0_exp(0)<1>   tc0<1;4,0>:ub   {NoMask}                                        // tc0_exp = tc0, each tc0 is duplicated 4 times for 4 adjcent 4 pixels
  338.                                                
  339.                         // tc_exp = tc0_exp + (|p2-p0|<Beta ? 1 : 0) + (|q2-q0|<Beta ? 1 : 0)                  
  340. //                      mov (16)        tc_exp(0)<1>            tc0_exp(0)                                                                      // tc = tc0_exp first
  341.                        
  342.  
  343.                         cmp.l.f0.0 (16) null:w          (abs)ap(0)                      beta:w                                          // |p2-p0|< Beta ? ---> (abs)ap < Beta ?
  344.                         cmp.l.f0.1 (16) null:w          (abs)aq(0)                      beta:w                                          // |q2-q0|< Beta ? ---> (abs)aq < Beta ?
  345.                        
  346.                         //--- Use free cycles here ---
  347.                         // delta = Clip3(-tc, tc, ((((q0-p0)<<2) + (p1-q1) + 4) >> 3))
  348.                         // 4 * (q0-p0) + p1 - q1 + 4
  349.                         add (16) acc0<1>:w              P1                      4:w                                                     // p1 + 4
  350.                         mac (16) acc0<1>:w              q0_p0(0)        4:w                                                     // 4 * (q0-p0) + p1 + 4
  351.                         add (16) acc0<1>:w              acc0<16;16,1>:w         -Q1                                     // 4 * (q0-p0) + p1 - q1 + 4
  352.                         shr (16) TempRow0(0)<1> acc0<16;16,1>:w         3:w
  353.                                                
  354.                         // Continue on getting tc_exp
  355.                         (f0.0) add (16) tc_exp(0)<1>    tc_exp(0)       1:w                                                     // tc0_exp + (|p2-p0|<Beta ? 1 : 0)
  356.                         mov (2) CTemp1_W<1>:w           f0.0<2;2,1>:w                   {NoMask}                                        // Save |p2-p0|<Beta flag                      
  357.                         (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)
  358.                        
  359.  
  360.                         // Continue on cliping tc to get delta
  361.                         cmp.g.f0.0      (16) null:w             TempRow0(0)             tc_exp(0)                                       // Clip if delta' > tc
  362.                         cmp.l.f0.1      (16) null:w             TempRow0(0)             -tc_exp(0)                                      // Clip if delta' < -tc
  363.  
  364.                         //--- Use free cycles here ---
  365.                         // common = (p0+q0+1) >> 1        --->  TempRow2(0)
  366.                         // Same as avg of p0 and q0
  367.                         avg (16) TempRow2(0)<1>         P0                      Q0
  368.  
  369.                         // Continue on cliping tc to get delta
  370.                         (f0.0) mov (16) TempRow0(0)<1>                          tc_exp(0)
  371.                         (f0.1) mov (16) TempRow0(0)<1>                          -tc_exp(0)
  372.  
  373.                         //--- Use free cycles here ---
  374.                         mov (2) f0.0<1>:w               CTemp1_W<2;2,1>:w       {NoMask}                        // CTemp1_W = (|p2-p0|<Beta)
  375.                                                                                                                                                         // CTemp2_W = (|q2-q0|<Beta)           
  376.                         //-----------------------------------------------------------------------
  377.  
  378.                         // p0' = Clip1(p0 + delta) = Clip3(0, 0xFF, p0 + delta)
  379.                         // q0' = Clip1(q0 - delta) = Clip3(0, 0xFF, q0 - delta)
  380.                         add.sat (16) TempRow1B(0)<2>            P0                      TempRow0(0)                                     // p0+delta
  381.                         add.sat (16) TempRow0B(0)<2>            Q0                      -TempRow0(0)                            // q0-delta
  382.                         mov (16) NewP0          TempRow1B(0)                                    // p0'
  383.                         mov (16) NewQ0          TempRow0B(0)                                    // q0'
  384.                         //-----------------------------------------------------------------------
  385.  
  386.                         // Now compute p1' and q1'
  387.  
  388.                         // if (|p2-p0|<Beta)
  389. //                      mov (1) f0.0:w          CTemp1_W:w                              {NoMask}                        // CTemp1_W = (|p2-p0|<Beta)
  390.                         (f0.0)  if      (16)            Y_ENDIF6
  391.                
  392.                         // p1' = p1 + Clip3(-tc0, tc0, adj)
  393.                         // adj = (p2 + common - (p1<<1)) >> 1 = (p2 + common - (p1*2)) >> 1
  394.                         add (16) acc0<1>:w      P2              TempRow2(0)                                                     // TempRow2(0) = common = (p0+q0+1) >> 1
  395.                         mac (16) acc0<1>:w      P1              -2:w
  396.                         shr (16) TempRow1(0)<1>         acc0<16;16,1>:w         1:w
  397.  
  398.                         // tc clip to get tc_adj
  399.                         cmp.g.f0.0      (16) null:w             TempRow1(0)             tc0_exp(0)                                      // Clip if delta' > tc
  400.                         cmp.l.f0.1      (16) null:w             TempRow1(0)             -tc0_exp(0)                                     // Clip if delta' < -tc
  401.                        
  402.                         (f0.0) mov (16) TempRow1(0)<1>                          tc0_exp(0)
  403.                         (f0.1) mov (16) TempRow1(0)<1>                          -tc0_exp(0)
  404.  
  405.                         //--- Use free cycles here ---
  406.                         mov (1) f0.1:w          CTemp2_W:w                              {NoMask}                        // CTemp2_W = (|q2-q0|<Beta)
  407.  
  408.                         // p1' = p1 + tc_adj
  409.                         add.sat (16) TempRow1B(0)<2>            P1                      TempRow1(0)                                     // p1+tc_adj
  410.                         mov (16) NewP1                  TempRow1B(0)                            // p1'
  411.  
  412.                         //------------------------------------------------------------------------
  413. Y_ENDIF6:
  414.                         endif
  415.                        
  416.                         // if (|q2-q0|<Beta)
  417. //                      mov (1) f0.1:w          CTemp2_W:w                              {NoMask}                        // CTemp2_W = (|q2-q0|<Beta)
  418.                         (f0.1)  if      (16)            Y_ENDIF7
  419.                                        
  420.                         // q1' = q1 + Clip3(-tc0, tc0, adj)
  421.                         // adj = (q2 + common - (q1<<1)) >> 1
  422.                         // same as q2 + common - (q1 * 2)
  423.                         add (16) acc0<1>:w      Q2              TempRow2(0)
  424.                         mac (16) acc0<1>:w      Q1              -2:w
  425.                         shr (16) TempRow1(0)<1>         acc0<16;16,1>:w         1:w    
  426.  
  427.                         // tc clip to get tc_adj
  428.                         cmp.g.f0.0      (16) null:w             TempRow1(0)             tc0_exp(0)                                      // Clip if delta' > tc
  429.                         cmp.l.f0.1      (16) null:w             TempRow1(0)             -tc0_exp(0)                                     // Clip if delta' < -tc
  430.  
  431.                         (f0.0) mov (16) TempRow1(0)<1>                          tc0_exp(0)
  432.                         (f0.1) mov (16) TempRow1(0)<1>                          -tc0_exp(0)
  433.  
  434.                         // q1' = q1 + tc_adj
  435.                         add.sat (16) TempRow1B(0)<2>            Q1                      TempRow1(0)                                     // q1+tc_adj
  436.                         mov (16) NewQ1                  TempRow1B(0)                            // q1'
  437.  
  438.                         //------------------------------------------------------------------------                     
  439. Y_ENDIF7:
  440.                         endif
  441.  
  442.                 endif
  443. Y_ENDIF2:
  444. Y_ENDIF1:
  445.         endif
  446.  
  447. RETURN
  448.  
  449. #endif  // !defined(__AVC_ILDB_LUMA_CORE__)
  450.