Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright © <2010>, Intel Corporation.
  3.  *
  4.  * This program is licensed under the terms and conditions of the
  5.  * Eclipse Public License (EPL), version 1.0.  The full text of the EPL is at
  6.  * http://www.opensource.org/licenses/eclipse-1.0.php.
  7.  *
  8.  */
  9. #if !defined(__AVC_ILDB_CHROMA_CORE__)  // Make sure this file is only included once
  10. #define __AVC_ILDB_CHROMA_CORE__
  11.  
  12. ////////// AVC ILDB Chroma Core /////////////////////////////////////////////////////////////////////////////////
  13. //
  14. //      This core performs AVC U or V ILDB filtering on one horizontal edge (8 pixels) of a MB.
  15. //      If data is transposed, it can also de-block a vertical edge.
  16. //
  17. //      Bafore calling this subroutine, caller needs to set the following parameters.
  18. //
  19. //      - EdgeCntlMap1                          //      Edge control map A
  20. //      - EdgeCntlMap2                          //      Edge control map B
  21. //      - P_AddrReg                                     //      Src and dest address register for P pixels
  22. //      - Q_AddrReg                                     //      Src and dest address register for Q pixels      
  23. //      - alpha                                         //  alpha corresponding to the edge to be filtered
  24. //      - beta                                          //  beta corresponding to the edge to be filtered
  25. //      - tc0                                           //      tc0  corresponding to the edge to be filtered
  26. //
  27. //      U or V:
  28. //      +----+----+----+----+
  29. //      | P1 | p0 | q0 | q1 |
  30. //      +----+----+----+----+
  31. //
  32. //      p1 = r[P_AddrReg, 0]<16;8,2>
  33. //      p0 = r[P_AddrReg, 16]<16;8,2>
  34. //      q0 = r[Q_AddrReg, 0]<16;8,2>  
  35. //      q1 = r[Q_AddrReg, 16]<16;8,2>
  36. //
  37. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  38.  
  39. // The region is both src and dest
  40. // P0-P3 and Q0-Q3 should be only used if they have not been modified to new values  
  41. #undef  P1
  42. #undef  P0
  43. #undef  Q0
  44. #undef  Q1
  45.  
  46. #define P1              r[P_AddrReg,  0]<16;8,2>:ub
  47. #define P0              r[P_AddrReg, 16]<16;8,2>:ub
  48. #define Q0              r[Q_AddrReg,  0]<16;8,2>:ub
  49. #define Q1              r[Q_AddrReg, 16]<16;8,2>:ub
  50.  
  51. // New region as dest
  52. #undef  NewP0
  53. #undef  NewQ0
  54.  
  55. #define NewP0   r[P_AddrReg, 16]<2>:ub
  56. #define NewQ0   r[Q_AddrReg,  0]<2>:ub
  57.  
  58. // Filter one chroma edge
  59. FILTER_UV:
  60.  
  61. #if defined(_DEBUG)
  62.         mov             (1)             EntrySignatureC:w                       0x1112:w
  63. #endif
  64.         //---------- Derive filterSampleflag in AVC spec, equition (8-469) ----------
  65.         // bS is in MaskA
  66.  
  67.         // Src copy of the p1, p0, q0, q1
  68. //      mov (8) p1(0)<1>                r[P_AddrReg, 0]<16;8,2>:ub
  69. //      mov (8) p0(0)<1>                r[P_AddrReg, 16]<16;8,2>:ub
  70. //      mov (8) q0(0)<1>                r[Q_AddrReg, 0]<16;8,2>:ub
  71. //      mov (8) q1(0)<1>                r[Q_AddrReg, 16]<16;8,2>:ub
  72.  
  73. //      mov (1) f0.0:uw         MaskA:uw
  74.  
  75.         add (8) q0_p0(0)<1>                     Q0              -P0                             // q0-p0
  76.         add (8) TempRow0(0)<1>          P1              -P0                             // p1-p0
  77.         add (8) TempRow1(0)<1>          Q1              -Q0                             // q1-q0
  78.  
  79.         // Build FilterSampleFlag
  80.         // abs(q0-p0) < alpha
  81.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)q0_p0(0)                   alpha:w
  82.         // abs(p1-p0) < Beta
  83.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)TempRow0(0)                beta:w
  84.         // abs(q1-q0) < Beta
  85.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)TempRow1(0)                beta:w
  86.  
  87.         //-----------------------------------------------------------------------------------------
  88.  
  89.         // if
  90.     (f0.0)      if      (8)             UV_ENDIF1
  91.                 // For channels whose edge control map1 = 1 ---> perform de-blocking
  92.  
  93. //              mov (1)         f0.1:w          MaskB:w         {NoMask}                // Now check for which algorithm to apply
  94.  
  95.                 (f0.1)  if      (8)             UV_ELSE2
  96.  
  97.                         // For channels whose edge control map2 = 1 ---> bS = 4 algorithm
  98.                         // p0' = (2*p1 + p0 + q1 + 2) >> 2
  99.                         // q0' = (2*q1 + q0 + p1 + 2) >> 2
  100.  
  101.                         // Optimized version:
  102.                         // A = (p1 + q1 + 2)
  103.                         // p0' = (p0 + p1 + A) >> 2
  104.                         // q0' = (q0 + q1 + A) >> 2
  105.                         //------------------------------------------------------------------------------------
  106.                        
  107.                         // p0' = (2*p1 + p0 + q1 + 2) >> 2
  108.                         add (8) acc0<1>:w               Q1                              2:w
  109.                         mac (8) acc0<1>:w               P1                              2:w
  110.                         add (8) acc0<1>:w               acc0<8;8,1>:w   P0
  111.                         shr.sat (8)     TempRow0B(0)<2>         acc0<8;8,1>:w           2:w
  112.                        
  113.                         // q0' = (2*q1 + q0 + p1 + 2) >> 2
  114.                         add (8) acc0<1>:w               P1                              2:w
  115.                         mac (8) acc0<1>:w               Q1                              2:w
  116.                         add (8) acc0<1>:w               acc0<8;8,1>:w   Q0
  117.                         shr.sat (8)     TempRow1B(0)<2>         acc0<8;8,1>:w           2:w
  118.  
  119.                         mov (8) NewP0           TempRow0B(0)                                    // p0'
  120.                         mov (8) NewQ0           TempRow1B(0)                                    // q0'
  121.                        
  122.                        
  123. UV_ELSE2:
  124.                 else    (8)             UV_ENDIF2
  125.                         // For channels whose edge control map2 = 0 ---> bS < 4 algorithm
  126.                        
  127.                         // Expand tc0   (tc0 has 4 bytes)
  128. //                      mov (8) tc0_exp(0)<1>   tc0<1;2,0>:ub   {NoMask}                                // tc0_exp = tc0, each tc0 is duplicated 2 times for 2 adjcent pixels  
  129.                         mov (8) acc0<1>:w       tc0<1;2,0>:ub   {NoMask}                                // tc0_exp = tc0, each tc0 is duplicated 2 times for 2 adjcent pixels  
  130.                        
  131.                         // tc_exp = tc0_exp + 1
  132. //                      add (8) tc_exp(0)<1>    tc0_exp(0)              1:w
  133.                         add (8) tc_exp(0)<1>    acc0<8;8,1>:w           1:w
  134.  
  135.                         // delta = Clip3(-tc, tc, ((((q0 - p0)<<2) + (p1-q1) + 4) >> 3))
  136.                         // 4 * (q0-p0) + p1 - q1 + 4
  137.                         add (8) acc0<1>:w               P1                      4:w
  138.                         mac (8) acc0<1>:w               q0_p0(0)        4:w    
  139.                         add (8) acc0<1>:w               acc0<8;8,1>:w           -Q1
  140.                         shr (8) TempRow0(0)<1>  acc0<8;8,1>:w           3:w
  141.  
  142.                         // tc clip
  143.                         cmp.g.f0.0      (8) null:w              TempRow0(0)             tc_exp(0)                               // Clip if > tc0
  144.                         cmp.l.f0.1      (8) null:w              TempRow0(0)             -tc_exp(0)                              // Clip if < -tc0
  145.                        
  146.                         (f0.0) mov (8) TempRow0(0)<1>                           tc_exp(0)
  147.                         (f0.1) mov (8) TempRow0(0)<1>                           -tc_exp(0)
  148.                        
  149.                         // p0' = Clip1(p0 + delta) = Clip3(0, 0xFF, p0 + delta)
  150.                         add.sat (8)     TempRow1B(0)<2>         P0                      TempRow0(0)                             // p0+delta
  151.                
  152.                         // q0' = Clip1(q0 - delta) = Clip3(0, 0xFF, q0 - delta)
  153.                         add.sat (8)     TempRow0B(0)<2>         Q0                      -TempRow0(0)                    // q0-delta
  154.  
  155.                         mov (8) NewP0                           TempRow1B(0)                    // p0'
  156.                         mov (8) NewQ0                           TempRow0B(0)                    // q0'
  157.  
  158.                 endif
  159. UV_ENDIF2:
  160. UV_ENDIF1:
  161.         endif
  162.  
  163. RETURN
  164.  
  165. #endif  // !defined(__AVC_ILDB_CHROMA_CORE__)
  166.