Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Decode Intra_8x8 macroblock
  3.  * Copyright © <2010>, Intel Corporation.
  4.  *
  5.  * Permission is hereby granted, free of charge, to any person obtaining a
  6.  * copy of this software and associated documentation files (the
  7.  * "Software"), to deal in the Software without restriction, including
  8.  * without limitation the rights to use, copy, modify, merge, publish,
  9.  * distribute, sub license, and/or sell copies of the Software, and to
  10.  * permit persons to whom the Software is furnished to do so, subject to
  11.  * the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice (including the
  14.  * next paragraph) shall be included in all copies or substantial portions
  15.  * of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  20.  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
  21.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24.  *
  25.  * This file was originally licensed under the following license
  26.  *
  27.  *  Licensed under the Apache License, Version 2.0 (the "License");
  28.  *  you may not use this file except in compliance with the License.
  29.  *  You may obtain a copy of the License at
  30.  *
  31.  *      http://www.apache.org/licenses/LICENSE-2.0
  32.  *
  33.  *  Unless required by applicable law or agreed to in writing, software
  34.  *  distributed under the License is distributed on an "AS IS" BASIS,
  35.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  36.  *  See the License for the specific language governing permissions and
  37.  *  limitations under the License.
  38.  *
  39.  */
  40. // Kernel name: Intra_8x8.asm
  41. //
  42. // Decoding of Intra_8x8 macroblock
  43. //
  44. //  $Revision: 12 $
  45. //  $Date: 10/18/06 4:10p $
  46. //
  47.  
  48. // ----------------------------------------------------
  49. //  Main: Intra_8x8
  50. // ----------------------------------------------------
  51.  
  52. #define INTRA_8X8
  53.  
  54. .kernel Intra_8x8
  55. INTRA_8x8:
  56.  
  57. #ifdef _DEBUG
  58. // WA for FULSIM so we'll know which kernel is being debugged
  59. mov (1) acc0:ud 0x01aa55a5:ud
  60. #endif
  61.  
  62. #include "SetupForHWMC.asm"
  63.  
  64. #define         REG_INTRA_PRED_AVAIL    REG_INTRA_TEMP_4
  65. #define         INTRA_PRED_AVAIL                REG_INTRA_TEMP_4.4
  66.  
  67. // Offset where 8x8 predicted data blocks are stored
  68. #define PREDBLK0        0*GRFWIB
  69. #define PREDBLK1        4*GRFWIB
  70. #define PREDBLK2        8*GRFWIB
  71. #define PREDBLK3        12*GRFWIB
  72.  
  73. #ifdef SW_SCOREBOARD
  74.  
  75. // Update "E" flag with "F" flag information
  76.         mov (1) REG_INTRA_TEMP_0<1>:w   REG_INTRA_PRED_AVAIL_FLAG_WORD<0;1,0>:w         // Store original Intra_Pred_Avail_Flag
  77.         and.nz.f0.0 (1) NULLREG REG_MBAFF_PIC   MBAFF_PIC       // Is current MBAFF picture
  78.         and.z.f0.1 (1) NULLREG  REG_INTRA_PRED_AVAIL_FLAG       INTRA_PRED_LEFT_TH_AVAIL_FLAG   // Is "A" not available?
  79.         (f0.0) and.z.f0.0 (1) NULLREG   REG_FIELD_MACROBLOCK_FLAG       FIELD_MACROBLOCK_FLAG   // Is current frame MB?
  80.         (f0.1) and.nz.f0.1 (1) NULLREG  REG_INTRA_PRED_8X8_BLK2_AVAIL_FLAG      INTRA_PRED_8X8_BLK2_AVAIL_FLAG  // Is "F" flag set?
  81.         (f0.0.allv) or (1)      REG_INTRA_PRED_AVAIL_FLAG_WORD<1>:w     REG_INTRA_PRED_AVAIL_FLAG_WORD<0;1,0>:w INTRA_PRED_LEFT_BH_AVAIL_FLAG   // Set "E" to 1 if all conditions meet
  82.  
  83.    CALL(scoreboard_start_intra,1)
  84.         mov (1) REG_INTRA_PRED_AVAIL_FLAG_WORD<1>:w     REG_INTRA_TEMP_0<0;1,0>:w               // Restore original Intra_Pred_Avail_Flag
  85. #endif
  86.  
  87. #ifdef SW_SCOREBOARD    
  88.         wait    n0:ud           //      Now wait for scoreboard to response
  89. #endif
  90.  
  91. //
  92. //  Decode Y blocks
  93. //
  94. //      Load reference data from neighboring macroblocks
  95.    CALL(load_Intra_Ref_Y,1)
  96.  
  97.         mov     (1)     PERROR<1>:w     ERRBUF*GRFWIB:w                 // Pointer to macroblock error data
  98.         mov     (1)     PDECBUF_UD<1>:ud        0x00010001*PREDBUF*GRFWIB+0x00100000:ud // Pointers to predicted data
  99.         shr (2) REG_INTRA_PRED_AVAIL<1>:w       REG_INTRA_PRED_AVAIL_FLAG_BYTE<0;1,0>:ub        0x40:v
  100.        
  101. #if 1
  102.         mov (4) REF_LEFT_D(0,0)<1>      0:ud            // This is to make validation easier. Without it, DRAM mismatch occurs.
  103. #endif
  104.  
  105. //      Intra predict Intra_8x8 luma blocks
  106. //
  107. //      Sub-macroblock 0 *****************
  108.         mov     (16)    REF_TOP_W(0)<1> REG_INTRA_REF_TOP<16;16,1>:w            // Copy entire top reference data
  109.         and.nz.f0.0 (8) NULLREG         REG_INTRA_PRED_AVAIL_FLAG       INTRA_PRED_UP_LEFT_AVAIL_FLAG   // Is "D" available?
  110.         (-f0.0) mov (1) REF_TOP(0,-1)<1>        INTRA_REF_TOP(0)REGION(1,0)             // p[-1,-1] = p[0,-1]
  111.  
  112.         mov     (8)             REF_LEFT(0,2)<1>        INTRA_REF_LEFT(0)       // Left reference data, (leave 2 for reference filtering)
  113.         (-f0.0) mov (1)         REF_LEFT(0,1)<1>        INTRA_REF_LEFT(0)REGION(1,0)                    // p[-1,-1]=p[-1,0]
  114.         (f0.0.any2h)  mov (2)           REF_LEFT(0,0)<1>        INTRA_REF_TOP(0,-1)REGION(1,0)  // p'[-1,y] (y=0,1) = p[-1,-1]
  115.         and.nz.f0.1 (1) NULLREG         REG_INTRA_PRED_AVAIL_FLAG       INTRA_PRED_UP_AVAIL_FLAG        // Is "B" available?
  116.         (f0.1) mov      (1)             REF_LEFT(0,0)<1>        INTRA_REF_TOP(0,0)REGION(1,0)   // p[0,-1] for left filtering
  117.         and.nz.f0.1 (1) NULLREG         REG_INTRA_PRED_AVAIL_FLAG       INTRA_PRED_LEFT_TH_AVAIL_FLAG   // Is "A" available?
  118.         (-f0.1) mov     (1)             REF_LEFT(0,2)<1>        INTRA_REF_TOP(0,-1)REGION(1,0)  // p'[-1,2] = p[-1,-1]
  119.  
  120.         and     (1)             PRED_MODE<1>:w  INTRA_PRED_MODE(0)REGION(1,0)   0x0F:w          // Intra pred mode for current block
  121.         mov (1)         INTRA_PRED_AVAIL<1>:w   REG_INTRA_PRED_AVAIL<0;1,0>:w           // Top/Left neighbor available flags
  122.         CALL(intra_Pred_8x8_Y,1)
  123.     add (1)             PERROR<1>:w     PERROR<0;1,0>:w 0x0080:w        // Pointers to next error block
  124.  
  125. //      Sub-macroblock 1 *****************
  126.         mov     (16)    REF_TOP0(0)<1>  INTRA_REF_TOP(0,4)      // Top reference data
  127.         and.nz.f0.1 (8) NULLREG         REG_INTRA_PRED_AVAIL_FLAG       INTRA_PRED_UP_RIGHT_AVAIL_FLAG  // Is "C" available?
  128.         (f0.1.any8h)  mov (8)   REF_TOP(0,8)<1> INTRA_REF_TOP(0,16)<8;8,1>              // Take data from "C"
  129.         (-f0.1.any8h) mov (8)   REF_TOP(0,8)<1> INTRA_REF_TOP(0,15)REGION(1,0)  // Repeat last pixel from "B"
  130.  
  131.         mov     (4)             REF_LEFT(0,2)<1>        DEC_Y(0,14)<16;1,0>             // Left reference data (top half) (leave 2 for reference filtering)
  132.         mov     (4)             REF_LEFT(0,6)<1>        DEC_Y(2,14)<16;1,0>             // Left reference data (bottom half)
  133.         mov     (2)             REF_LEFT(0,0)<1>        INTRA_REF_TOP(0,7)REGION(1,0)           // p'[-1,y] (y=0,1) = p[-1,-1]
  134.         and.nz.f0.1 (1) NULLREG         REG_INTRA_PRED_AVAIL_FLAG       INTRA_PRED_UP_AVAIL_FLAG        // Is "B" available?
  135.         (f0.1)  mov     (1)             REF_LEFT(0,0)<1>        INTRA_REF_TOP(0,8)REGION(1,0)   // p[-1,-1] for left filtering
  136.         (-f0.1) mov     (1)             REF_LEFT(0,1)<1>        DEC_Y(0,14)REGION(1,0)  // p[-1,-1] = p[-1,0]
  137.  
  138.         shr     (1)             PRED_MODE<1>:w  INTRA_PRED_MODE(0)REGION(1,0)   4:w             // Intra pred mode for current block
  139.         add     (2)             PPREDBUF_Y<1>:w PPREDBUF_Y<2;2,1>:w     4*GRFWIB:w                      // Pointer to predicted sub-macroblock 1
  140.         or (1)          INTRA_PRED_AVAIL<1>:w   REG_INTRA_PRED_AVAIL<0;1,0>:w   1:w             // Left neighbor is available
  141.         CALL(intra_Pred_8x8_Y,1)
  142.     add (1)             PERROR<1>:w     PERROR<0;1,0>:w 0x0080:w        // Pointers to next error block
  143.  
  144. //      Pack constructed data from word-aligned to byte-aligned format and interlace Y0 and Y1(every two Y rows)
  145. //      to speed up save_8x8_Y module later
  146. //      PPREDBUF_Y now points to sub-macroblock Y1
  147.         mov (32)        r[PPREDBUF_Y,-PREDBLK1]<1>:ub           DEC_Y(0)<32;16,2> {Compr}       // First 4 Y0 rows
  148.         mov (32)        r[PPREDBUF_Y,0-PREDBLK1+32]<1>:ub       DEC_Y(4)<32;16,2> {Compr}       // First 4 Y1 rows
  149.         mov (32)        r[PPREDBUF_Y,0-PREDBLK1+64]<1>:ub       DEC_Y(2)<32;16,2> {Compr}       // Second 4 Y0 rows
  150.         mov (32)        r[PPREDBUF_Y,0-PREDBLK1+96]<1>:ub       DEC_Y(6)<32;16,2> {Compr}       // Second 4 Y1 rows
  151.  
  152. //      Sub-macroblock 2 *****************
  153. //      Intra_8x8 special available flag handling
  154.         and.nz.f0.0 (1) NULLREG REG_MBAFF_PIC   MBAFF_PIC       // Is current MBAFF picture
  155.         and.z.f0.1 (1) NULLREG  REG_INTRA_PRED_AVAIL_FLAG       INTRA_PRED_LEFT_TH_AVAIL_FLAG   // Is "A" not available?
  156.         (f0.0) and.z.f0.0 (1) NULLREG   REG_FIELD_MACROBLOCK_FLAG       FIELD_MACROBLOCK_FLAG   // Is current frame MB?
  157.         (f0.1) and.nz.f0.1 (1) NULLREG  REG_INTRA_PRED_8X8_BLK2_AVAIL_FLAG      INTRA_PRED_8X8_BLK2_AVAIL_FLAG  // Is special intra_8x8 available flag set?
  158.         (f0.0.allv) mov (1)     REF_TOP(0,-1)<1>        INTRA_REF_LEFT0(0,31)REGION(1,0)        // Top-left reference data
  159.         (f0.0.allv) jmpi (1)    INTRA_8x8_BLK2
  160. //      Done intra_8x8 special available flag handling
  161.  
  162.         and.nz.f0.0 (8) NULLREG REG_INTRA_PRED_AVAIL_FLAG       INTRA_PRED_LEFT_TH_AVAIL_FLAG   // Is top-half "A" available?
  163.         (f0.0.any4h) mov (4)    REF_TOP0(0)<1>          INTRA_REF_LEFT0(0,28)REGION(4,1)        // Top-left reference data
  164.         (-f0.0) mov (1) REF_TOP(0,-1)<1>        DEC_Y(2,24)REGION(1,0)  // p[-1,-1] = p[0,-1]
  165. INTRA_8x8_BLK2:
  166.         mov     (8)             REF_TOP(0)<1>           DEC_Y(2,24)REGION(8,1)          // Top reference data
  167.         mov     (8)             REF_TOP(0,8)<1>         DEC_Y(3,24)REGION(8,1)          // Top reference data
  168.  
  169.         mov     (8)             REF_LEFT(0,2)<1>        INTRA_REF_LEFT(1)                       // Left reference data,  (leave 2 for reference filtering)
  170.         mov (1)         REF_LEFT(0,0)<1>        DEC_Y(2,24)REGION(1,0)          // p'[-1,0] = p[0,-1] since "B" is always available
  171.         (f0.0) mov      (1)     REF_LEFT(0,1)<1>        INTRA_REF_LEFT(0,28)REGION(1,0) // p[-1,1] = p[-1,-1] if top-half "A" available
  172.         (-f0.0) mov (1) REF_LEFT(0,1)<1>        INTRA_REF_LEFT(1)REGION(1,0)    // p[-1,1] = p[-1,0]
  173.         and.nz.f0.1 (1) NULLREG REG_INTRA_PRED_AVAIL_FLAG       INTRA_PRED_LEFT_BH_AVAIL_FLAG   // Is bottom-half "A" available?
  174.         (-f0.1) mov     (1)     REF_LEFT(0,2)<1>        INTRA_REF_LEFT(0,28)REGION(1,0) // p'[-1,2] = p[-1,-1]
  175.  
  176.         and     (1)             PRED_MODE<1>:w                  INTRA_PRED_MODE(0,1)REGION(1,0) 0x0F:// Intra pred mode for current block
  177.         or (1)          INTRA_PRED_AVAIL<1>:w   REG_INTRA_PRED_AVAIL.1<0;1,0>:w 2:w             // Top neighbor is available
  178.         CALL(intra_Pred_8x8_Y,1)
  179.     add (1)             PERROR<1>:w     PERROR<0;1,0>:w 0x0080:w        // Pointers to next error block
  180.  
  181. //      Sub-macroblock 3 *****************
  182.         mov     (4)             REF_TOP0(0)<1>          DEC_Y(2,28)REGION(4,1)          // Top-left reference data
  183.         mov     (8)             REF_TOP(0)<1>           DEC_Y(3,24)REGION(8,1)          // Top reference data
  184.         mov     (16)    REF_TOP(0,8)<1>         DEC_Y(3,31)REGION(1,0)          // Top-right reference data
  185.  
  186.         mov (4)         REF_LEFT(0,2)<1>        DEC_Y(4,14)<16;1,0>             // Left reference data (top half) (leave 2 for reference filtering)
  187.         mov (4)         REF_LEFT(0,6)<1>        DEC_Y(6,14)<16;1,0>             // Left reference data (bottom half)
  188.         mov (1)         REF_LEFT(0,0)<1>        DEC_Y(3,24)REGION(1,0)  // p[-1,0] = p[0,-1]
  189.         mov (1)         REF_LEFT(0,1)<1>        DEC_Y(2,31)REGION(1,0)  // p[-1,1] = p[-1,-1]
  190.  
  191.         shr     (1)             PRED_MODE<1>:w  INTRA_PRED_MODE(0,1)REGION(1,0) 4:w             // Intra pred mode for current block
  192.         add     (2)             PPREDBUF_Y<1>:w PPREDBUF_Y<2;2,1>:w     4*GRFWIB:w      // Pointer to predicted sub-macroblock 3
  193.         or (1)          INTRA_PRED_AVAIL<1>:w   REG_INTRA_PRED_AVAIL<0;1,0>:w   3:w             // Top and Left neighbor are available
  194.         CALL(intra_Pred_8x8_Y,1)
  195.  
  196. //      Pack constructed data from word-aligned to byte-aligned format
  197. //      to speed up save_8x8_Y module later
  198. //      PPREDBUF_Y now points to sub-macroblock Y1
  199.         mov (32)        r[PPREDBUF_Y,-PREDBLK1]<1>:ub           DEC_Y(4)<32;16,2> {Compr}       // First 4 Y2 rows
  200.         mov (32)        r[PPREDBUF_Y,0-PREDBLK1+32]<1>:ub       DEC_Y(8)<32;16,2> {Compr}       // First 4 Y3 rows
  201.         mov (32)        r[PPREDBUF_Y,0-PREDBLK1+64]<1>:ub       DEC_Y(6)<32;16,2> {Compr}       // Second 4 Y2 rows
  202.         mov (32)        r[PPREDBUF_Y,0-PREDBLK1+96]<1>:ub       DEC_Y(10)<32;16,2> {Compr}      // Second 4 Y3 rows
  203.  
  204. //      All 4 sub-macroblock (containing 4 intra_8x8 blocks) have be constructed
  205. //      Save constructed Y picture
  206.         CALL(save_8x8_Y,1)              // Save Intra_8x8 predicted luma data.
  207. //
  208. //  Decode U/V blocks
  209. //
  210. //      Note: The decoding for chroma blocks will be the same for all intra prediction mode
  211. //
  212.         CALL(decode_Chroma_Intra,1)
  213.  
  214. #ifdef SW_SCOREBOARD
  215.     #include "scoreboard_update.asm"
  216. #endif
  217.  
  218. // Terminate the thread
  219. //
  220.     #include "EndIntraThread.asm"
  221.  
  222. // End of Intra_8x8
  223.