Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * All Video Processing kernels
  3.  * Copyright © <2010>, Intel Corporation.
  4.  *
  5.  * This program is licensed under the terms and conditions of the
  6.  * Eclipse Public License (EPL), version 1.0.  The full text of the EPL is at
  7.  * http://www.opensource.org/licenses/eclipse-1.0.php.
  8.  *
  9.  */
  10.  
  11.  
  12. // Module name: PL8x4_Save_NV12.asm
  13. //
  14. // Save entire current planar frame data block of size 16x8
  15. //---------------------------------------------------------------
  16. //  Symbols needed to be defined before including this module
  17. //
  18. //      DWORD_ALIGNED_DEST:     only if DEST_Y, DEST_U, DEST_V data are DWord aligned
  19. //      ORIX:
  20. //---------------------------------------------------------------
  21.  
  22. #include "PL8x4_Save_NV12.inc"
  23.  
  24.     mov  (8) mMSGHDR<1>:ud      rMSGSRC<8;8,1>:ud
  25.  
  26. #if !defined(SAVE_UV_ONLY)
  27. // Save current planar frame Y block data (16x8) -------------------------------
  28.  
  29.     mov  (2) mMSGHDR.0<1>:d     wORIX<2;2,1>:w          // Block origin
  30.     mov  (1) mMSGHDR.2<1>:ud    nDPW_BLOCK_SIZE_Y:ud    // Block width and height (16x8)
  31. #endif
  32.  
  33. //Use the mask to determine which pixels shouldn't be over-written
  34.         and     (1)             acc0<1>:ud              udBLOCK_MASK<0;1,0>:ud          0x00FFFFFF:ud
  35.         cmp.ge.f0.0     (1)             dNULLREG                acc0<0;1,0>:ud          0x00FFFFFF:ud   //Check if all pixels in the block need to be modified
  36.         (f0.0)  jmpi WritePlanarToDataPort
  37.  
  38. //If mask is not all 1's, then load the entire 16x8 block
  39. //so that only those bytes may be modified that need to be (using the mask)    
  40.   send (8)      udSRC_Y(0)<1>   mMSGHDR udDUMMY_NULL nDATAPORT_READ     nDPMR_MSGDSC+nDPR_MSG_SIZE_Y+nBI_DESTINATION_Y:ud               //16x8  
  41.    
  42.   asr  (1)      rMSGSRC.1<1>:ud wORIY<0;1,0>:w  1:w     { NoDDClr }     // U/V block origin should be half of Y's
  43.   mov  (1)      rMSGSRC.2<1>:ud nDPW_BLOCK_SIZE_UV:ud           { NoDDChk }     // Block width and height (16x4)
  44.   mov (8)  mMSGHDR<1>:ud       rMSGSRC<8;8,1>:ud //move message desrcptor to the message header
  45.   send (8)      udSRC_U(0)<1>   mMSGHDR udDUMMY_NULL nDATAPORT_READ nDPMR_MSGDSC+nDPR_MSG_SIZE_UV+nBI_DESTINATION_UV:ud                                                            
  46.        
  47. //Restore the origin information
  48.   mov (2)       rMSGSRC.0<1>:ud wORIX<2;2,1>:w          // Block origin
  49.   mov (1)       rMSGSRC.2<1>:ud nDPW_BLOCK_SIZE_Y:ud            // Block width and height (16x8)
  50.   mov (8) mMSGHDR<1>:ud       rMSGSRC<8;8,1>:ud //move message desrcptor to the message header 
  51.        
  52. //Merge the data
  53.         mov  (1)        f0.1:uw                 ubBLOCK_MASK_V:ub                       //Load the mask on flag reg
  54.         (f0.1)  mov     (8)     rMASK_TEMP<1>:uw        uwBLOCK_MASK_H:uw
  55.         (-f0.1) mov     (8)     rMASK_TEMP<1>:uw        0:uw  
  56.    
  57. //convert the mask from 16bits to 8bits by selecting every other bit
  58.         mov (1) udMASK_TEMP1(0,0)<1> 0x00040001:ud
  59.         mov (1) udMASK_TEMP1(0,1)<1> 0x00400010:ud
  60.         mov (1) udMASK_TEMP1(0,2)<1> 0x04000100:ud
  61.         mov (1) udMASK_TEMP1(0,3)<1> 0x40001000:ud
  62.  
  63. //merge the loaded block with the current block
  64.   $for(0,0; <nY_NUM_OF_ROWS; 2,1) {
  65.         mov     (1)     f0.1:uw         uwMASK_TEMP(0, %1)<0;1,0>
  66.                 (-f0.1) mov  (16)       ubDEST_Y(0,%1*32)<2>            ubSRC_Y(0,%1*16)               
  67.  
  68.           and.nz.f0.1 (8) wNULLREG uwMASK_TEMP(0,%1)<0;1,0> uwMASK_TEMP1(0,0) //change the mask by selecting every other bit
  69.                 (-f0.1) mov  (8)        ubDEST_U(0, %2*16)<2>           ub2SRC_U(0, %1*8)<16;8,2>
  70.                 (-f0.1) mov  (8)        ubDEST_V(0, %2*16)<2>           ub2SRC_U(0, %1*8+1)<16;8,2>
  71.                
  72.                 mov     (1)     f0.1:uw         uwMASK_TEMP(0,1+%1)<0;1,0>
  73.                 (-f0.1) mov  (16)       ubDEST_Y(0, (1+%1)*32)<2>       ubSRC_Y(0, (1+%1)*16)          
  74.  
  75.   }      
  76.  
  77. WritePlanarToDataPort:
  78. #if !defined(SAVE_UV_ONLY)
  79.     $for(0,0; <nY_NUM_OF_ROWS; 2,1) {
  80.             mov (16) mubMSGPAYLOAD(%2,0)<1>     ub2DEST_Y(%1)REGION(16,2)
  81.             mov (16) mubMSGPAYLOAD(%2,16)<1>    ub2DEST_Y(%1+1)REGION(16,2)
  82.     }
  83.     send (8)    dNULLREG    mMSGHDR   udDUMMY_NULL    nDATAPORT_WRITE    nDPMW_MSGDSC+nDPW_MSG_SIZE_Y+nBI_DESTINATION_Y:ud
  84. #endif
  85.    
  86. //** Save  8x4 packed U and V -----------------------------------------------------
  87. // we could write directly wORIX to mMSGHDR and then execute asr on it, that way we could
  88. // avoid using rMSGSRC as a buffer and have one command less in code, but it is unknown whether
  89. //it is possible to do asr on mMSGHDR so we use rMSGSRC.
  90.     mov (2)  rMSGSRC.0<1>:d    wORIX<2;2,1>:w             // Block origin
  91.     asr (1)  rMSGSRC.1<1>:d    rMSGSRC.1<0;1,0>:d    1:w  // U/V block origin should be half of Y's
  92.     mov (1)  rMSGSRC.2<1>:ud   nDPW_BLOCK_SIZE_UV:ud      // U/V block width and height (16x4)
  93.     mov (8)  mMSGHDR<1>:ud     rMSGSRC<8;8,1>:ud
  94.  
  95.     $for(0,0; <nY_NUM_OF_ROWS;4,1) {
  96.         mov (16) mubMSGPAYLOAD(%2,0)<2>     ub2DEST_U(%2)REGION(16,2)
  97.         mov (16) mubMSGPAYLOAD(%2,1)<2>     ub2DEST_V(%2)REGION(16,2)
  98.     }
  99.     send (8)    dNULLREG    mMSGHDR    udDUMMY_NULL    nDATAPORT_WRITE    nDPMW_MSGDSC+nDPW_MSG_SIZE_UV+nBI_DESTINATION_UV:ud
  100.  
  101. // End of PL8x4_Save_NV12  
  102.  
  103.