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. ////////// AVC ILDB Chroma Core Mbaff /////////////////////////////////////////////////////////////////////////////////
  10. //
  11. //      This core performs AVC U or V ILDB filtering on one horizontal edge (8 pixels) of a MB.
  12. //      If data is transposed, it can also de-block a vertical edge.
  13. //
  14. //      Bafore calling this subroutine, caller needs to set the following parameters.
  15. //
  16. //      - EdgeCntlMap1                          //      Edge control map A
  17. //      - EdgeCntlMap2                          //      Edge control map B
  18. //      - P_AddrReg                                     //      Src and dest address register for P pixels
  19. //      - Q_AddrReg                                     //      Src and dest address register for Q pixels      
  20. //      - alpha                                         //  alpha corresponding to the edge to be filtered
  21. //      - beta                                          //  beta corresponding to the edge to be filtered
  22. //      - tc0                                           //      tc0  corresponding to the edge to be filtered
  23. //
  24. //      U or V:
  25. //      +----+----+----+----+
  26. //      | P1 | p0 | q0 | q1 |
  27. //      +----+----+----+----+
  28. //
  29. //      p1 = r[P_AddrReg, 0]<16;8,2>
  30. //      p0 = r[P_AddrReg, 16]<16;8,2>
  31. //      q0 = r[Q_AddrReg, 0]<16;8,2>  
  32. //      q1 = r[Q_AddrReg, 16]<16;8,2>
  33. //
  34. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  35.  
  36. // The region is both src and dest
  37. // P0-P3 and Q0-Q3 should be only used if they have not been modified to new values  
  38. #undef  P1
  39. #undef  P0
  40. #undef  Q0
  41. #undef  Q1
  42.  
  43. #define P1              r[P_AddrReg,  0]<16;8,2>:ub
  44. #define P0              r[P_AddrReg, 16]<16;8,2>:ub
  45. #define Q0              r[Q_AddrReg,  0]<16;8,2>:ub
  46. #define Q1              r[Q_AddrReg, 16]<16;8,2>:ub
  47.  
  48. // New region as dest
  49. #undef  NewP0
  50. #undef  NewQ0
  51.  
  52. #define NewP0   r[P_AddrReg, 16]<2>:ub
  53. #define NewQ0   r[Q_AddrReg,  0]<2>:ub
  54.  
  55. // Filter one chroma edge - mbaff
  56. FILTER_UV_MBAFF:
  57.  
  58. #if defined(_DEBUG)
  59.         mov             (1)             EntrySignatureC:w                       0x1112:w
  60. #endif
  61.         //---------- Derive filterSampleflag in AVC spec, equition (8-469) ----------
  62.  
  63.         //===== Assume f0.0 contains MaskA when entering this routine
  64. //      mov (1) f0.0:uw         MaskA:uw
  65.  
  66.         add (8) q0_p0(0)<1>                     Q0              -P0                             // q0-p0
  67.         add (8) TempRow0(0)<1>          P1              -P0                             // p1-p0
  68.         add (8) TempRow1(0)<1>          Q1              -Q0                             // q1-q0
  69.  
  70.         // Build FilterSampleFlag
  71.         // abs(q0-p0) < alpha
  72.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)q0_p0(0)                   Mbaff_ALPHA(0)
  73.         // abs(p1-p0) < Beta
  74.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)TempRow0(0)                Mbaff_BETA(0)
  75.         // abs(q1-q0) < Beta
  76.         (f0.0) cmp.l.f0.0 (16) null:w           (abs)TempRow1(0)                Mbaff_BETA(0)
  77.  
  78.         //-----------------------------------------------------------------------------------------
  79.  
  80.         // if
  81.     (f0.0)      if      (8)             MBAFF_UV_ENDIF1
  82.                 // For channels whose edge control map1 = 1 ---> perform de-blocking
  83.  
  84. //              mov (1)         f0.1:w          MaskB:w         {NoMask}                // Now check for which algorithm to apply
  85.  
  86.                 (f0.1)  if      (8)             MBAFF_UV_ELSE2
  87.  
  88.                         // For channels whose edge control map2 = 1 ---> bS = 4 algorithm
  89.                         // p0' = (2*p1 + P0 + q1 + 2) >> 2
  90.                         // q0' = (2*q1 + q0 + p1 + 2) >> 2
  91.                         //------------------------------------------------------------------------------------
  92.  
  93.                         // p0' = (2*p1 + p0 + q1 + 2) >> 2
  94.                         add (8) acc0<1>:w               Q1                              2:w
  95.                         mac (8) acc0<1>:w               P1                              2:w
  96.                         add (8) acc0<1>:w               acc0<8;8,1>:w   P0
  97.                         shr.sat (8)     TempRow0B(0)<2>         acc0<8;8,1>:w           2:w
  98.  
  99.                         // q0' = (2*q1 + q0 + p1 + 2) >> 2
  100.                         add (8) acc0<1>:w               P1                              2:w
  101.                         mac (8) acc0<1>:w               Q1                              2:w
  102.                         add (8) acc0<1>:w               acc0<8;8,1>:w   Q0
  103.                         shr.sat (8)     TempRow1B(0)<2>         acc0<8;8,1>:w           2:w
  104.  
  105.                         mov (8) NewP0           TempRow0B(0)                                    // p0'
  106.                         mov (8) NewQ0           TempRow1B(0)                                    // q0'
  107.                        
  108. MBAFF_UV_ELSE2:
  109.                 else    (8)             MBAFF_UV_ENDIF2
  110.                         // For channels whose edge control map2 = 0 ---> bS < 4 algorithm
  111.                        
  112.                         // tc_exp = tc0_exp + 1
  113.                         add (8) tc_exp(0)<1>    Mbaff_TC0(0)            1:w
  114.  
  115.                         // delta = Clip3(-tc, tc, ((((q0 - p0)<<2) + (p1-q1) + 4) >> 3))
  116.                         // 4 * (q0-p0) + p1 - q1 + 4
  117.                         add (8) acc0<1>:w               P1                      4:w
  118.                         mac (8) acc0<1>:w               q0_p0(0)        4:w    
  119.                         add (8) acc0<1>:w               acc0<8;8,1>:w           -Q1
  120.                         shr (8) TempRow0(0)<1>  acc0<8;8,1>:w           3:w
  121.  
  122.                         // tc clip
  123.                         cmp.g.f0.0      (8) null:w              TempRow0(0)             tc_exp(0)                               // Clip if > tc0
  124.                         cmp.l.f0.1      (8) null:w              TempRow0(0)             -tc_exp(0)                              // Clip if < -tc0
  125.                        
  126.                         (f0.0) mov (8) TempRow0(0)<1>                           tc_exp(0)
  127.                         (f0.1) mov (8) TempRow0(0)<1>                           -tc_exp(0)
  128.                        
  129.                         // p0' = Clip1(p0 + delta) = Clip3(0, 0xFF, p0 + delta)
  130.                         add.sat (8)     TempRow1B(0)<2>         P0                      TempRow0(0)                             // p0+delta
  131.                
  132.                         // q0' = Clip1(q0 - delta) = Clip3(0, 0xFF, q0 - delta)
  133.                         add.sat (8)     TempRow0B(0)<2>         Q0                      -TempRow0(0)                    // q0-delta
  134.  
  135.                         mov (8) NewP0                           TempRow1B(0)                    // p0'
  136.                         mov (8) NewQ0                           TempRow0B(0)                    // q0'
  137.  
  138.                 endif
  139. MBAFF_UV_ENDIF2:
  140. MBAFF_UV_ENDIF1:
  141.         endif
  142.  
  143. RETURN
  144.  
  145.  
  146.  
  147.