1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 /* 19 ------------------------------------------------------------------------------ 20 INPUT AND OUTPUT DEFINITIONS 21 22 Inputs: 23 xpred = x-axis coordinate of the block used for prediction (int) 24 ypred = y-axis coordinate of the block used for prediction (int) 25 pp_dec_u = pointer to the post processing semaphore for chrominance 26 (uint8) 27 pstprcTypPrv = pointer the previous frame's post processing type 28 (uint8) 29 dx = horizontal component of the motion vector (int) 30 dy = vertical component of the motion vector (int) 31 mvwidth = number of blocks per row in the luminance VOP (int) 32 height = luminance VOP height in pixels (int) 33 size = total number of pixel in the current luminance VOP (int) 34 mv_loc = flag indicating location of the motion compensated 35 (x,y) position with respect to the luminance MB (int); 36 0 -> inside MB, 1 -> outside MB 37 msk_deblock = flag indicating whether to perform deblocking 38 (msk_deblock = 0) or not (msk_deblock = 1) (uint8) 39 40 Local Stores/Buffers/Pointers Needed: 41 None 42 43 Global Stores/Buffers/Pointers Needed: 44 None 45 46 Outputs: 47 None 48 49 Pointers and Buffers Modified: 50 pp_dec_u contents are the updated semaphore propagation data 51 52 Local Stores Modified: 53 None 54 55 Global Stores Modified: 56 None 57 58 ------------------------------------------------------------------------------ 59 FUNCTION DESCRIPTION 60 61 This functions performs post processing semaphore propagation processing 62 after chrominance prediction in interframe processing mode. 63 64 */ 65 66 67 /*---------------------------------------------------------------------------- 68 ; INCLUDES 69 ----------------------------------------------------------------------------*/ 70 #include "mp4dec_api.h" 71 #include "mp4def.h" 72 73 /*---------------------------------------------------------------------------- 74 ; MACROS 75 ; Define module specific macros here 76 ----------------------------------------------------------------------------*/ 77 78 /*---------------------------------------------------------------------------- 79 ; DEFINES 80 ; Include all pre-processor statements here. Include conditional 81 ; compile variables also. 82 ----------------------------------------------------------------------------*/ 83 84 /*---------------------------------------------------------------------------- 85 ; LOCAL FUNCTION DEFINITIONS 86 ; Function Prototype declaration 87 ----------------------------------------------------------------------------*/ 88 89 /*---------------------------------------------------------------------------- 90 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 91 ; Variable declaration - defined here and used outside this module 92 ----------------------------------------------------------------------------*/ 93 94 /*---------------------------------------------------------------------------- 95 ; EXTERNAL FUNCTION REFERENCES 96 ; Declare functions defined elsewhere and referenced in this module 97 ----------------------------------------------------------------------------*/ 98 99 /*---------------------------------------------------------------------------- 100 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 101 ; Declare variables used in this module but defined elsewhere 102 ----------------------------------------------------------------------------*/ 103 #ifdef PV_POSTPROC_ON 104 #ifdef __cplusplus 105 extern "C" 106 { 107 #endif 108 /*---------------------------------------------------------------------------- 109 ; FUNCTION CODE 110 ----------------------------------------------------------------------------*/ 111 void pp_semaphore_chroma_inter( 112 int xpred, /* i */ 113 int ypred, /* i */ 114 uint8 *pp_dec_u, /* i/o */ 115 uint8 *pstprcTypPrv, /* i */ 116 int dx, /* i */ 117 int dy, /* i */ 118 int mvwidth, /* i */ 119 int height, /* i */ 120 int32 size, /* i */ 121 int mv_loc, /* i */ 122 uint8 msk_deblock /* i */ 123 ) 124 { 125 /*---------------------------------------------------------------------------- 126 ; Define all local variables 127 ----------------------------------------------------------------------------*/ 128 int mmvy, mmvx, nmvy, nmvx; 129 uint8 *pp_prev1, *pp_prev2, *pp_prev3, *pp_prev4; 130 131 /*---------------------------------------------------------------------------- 132 ; Function body here 133 ----------------------------------------------------------------------------*/ 134 135 /* 09/28/2000, modify semaphore propagation to */ 136 /* accommodate smart indexing */ 137 mmvx = xpred >> 4; /* block x coor */ 138 nmvx = mmvx; 139 140 mmvy = ypred >> 4; /* block y coor */ 141 nmvy = mmvy; 142 143 /* Check if MV is outside the frame */ 144 if (mv_loc == 1) 145 { 146 /* Perform boundary check */ 147 if (nmvx < 0) 148 { 149 nmvx = 0; 150 } 151 else if (nmvx > mvwidth - 1) 152 { 153 nmvx = mvwidth - 1; 154 } 155 156 if (nmvy < 0) 157 { 158 nmvy = 0; 159 } 160 else if (nmvy > (height >> 4) - 1) 161 { 162 nmvy = (height >> 4) - 1; 163 } 164 } 165 166 /* Calculate pointer to first chrominance b semaphores in */ 167 /* pstprcTypPrv, i.e., first chrominance b semaphore is in */ 168 /* (pstprcTypPrv + (size>>6)). */ 169 /* Since total number of chrominance blocks per row in a VOP */ 170 /* is half of the total number of luminance blocks per row in a */ 171 /* VOP, we use (mvwidth >> 1) when calculating the row offset. */ 172 pp_prev1 = pstprcTypPrv + (size >> 6) + nmvx + nmvy * (mvwidth >> 1) ; 173 174 /* Check if MV is a multiple of 16 */ 175 /* 1/5/01, make sure it doesn't go out of bound */ 176 if (((dy&0xF) != 0) && (mmvy + 1 < (height >> 4) - 1)) 177 { /* dy is not a multiple of 16 */ 178 179 /* pp_prev3 is the block below pp_prev1 block */ 180 pp_prev3 = pp_prev1 + (mvwidth >> 1); 181 } 182 else 183 { /* dy is a multiple of 16 */ 184 pp_prev3 = pp_prev1; 185 } 186 187 /* 1/5/01, make sure it doesn't go out of bound */ 188 if (((dx&0xF) != 0) && (mmvx + 1 < (mvwidth >> 1) - 1)) 189 { /* dx is not a multiple of 16 */ 190 191 /* pp_prev2 is the block to the right of pp_prev1 block */ 192 pp_prev2 = pp_prev1 + 1; 193 194 /* pp_prev4 is the block to the right of the block */ 195 /* below pp_prev1 block */ 196 pp_prev4 = pp_prev3 + 1; 197 } 198 else 199 { /* dx is a multiple of 16 */ 200 201 pp_prev2 = pp_prev1; 202 pp_prev4 = pp_prev3; 203 } 204 205 /* Advance offset to location of first Chrominance R semaphore in */ 206 /* pstprcTypPrv. Since the number of pixels in a Chrominance VOP */ 207 /* is (number of pixels in Luminance VOP/4), and there are 64 */ 208 /* pixels in an 8x8 Chrominance block, the offset can be */ 209 /* calculated as: */ 210 /* mv_loc = (number of pixels in Luminance VOP/(4*64)) */ 211 /* = size/256 = size>>8 */ 212 mv_loc = (size >> 8); 213 214 /* 11/3/00, change the propagation for deblocking */ 215 if (msk_deblock == 0) 216 { 217 218 /* Deblocking semaphore propagation for Chrominance */ 219 /* b semaphores */ 220 *(pp_dec_u) = 0; 221 222 /* Advance offset to point to Chrominance r semaphores */ 223 pp_dec_u += mv_loc; 224 225 /* Deblocking semaphore propagation for Chrominance */ 226 /* r semaphores */ 227 *(pp_dec_u) = 0; 228 } 229 else 230 { 231 /* Deringing semaphore propagation for Chrominance B block */ 232 if ((*(pp_dec_u)&4) == 0) 233 { 234 *(pp_dec_u) |= ((*(pp_prev1) | *(pp_prev2) | 235 *(pp_prev3) | *(pp_prev4)) & 0x4); 236 } 237 238 /* Advance offset to point to Chrominance r semaphores */ 239 pp_dec_u += mv_loc; 240 pp_prev1 += mv_loc; 241 pp_prev2 += mv_loc; 242 pp_prev3 += mv_loc; 243 pp_prev4 += mv_loc; 244 245 /* Deringing semaphore propagation for Chrominance R */ 246 if ((*(pp_dec_u)&4) == 0) 247 { 248 *(pp_dec_u) |= ((*(pp_prev1) | *(pp_prev2) | 249 *(pp_prev3) | *(pp_prev4)) & 0x4); 250 } 251 } 252 253 /*---------------------------------------------------------------------------- 254 ; Return nothing or data or data pointer 255 ----------------------------------------------------------------------------*/ 256 return; 257 } 258 #ifdef __cplusplus 259 } 260 #endif 261 262 #endif 263