1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
19 ------------------------------------------------------------------------------
20 INPUT AND OUTPUT DEFINITIONS
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
27 pstprcTypPrv = pointer the previous frame's post processing type
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)
40 Local Stores/Buffers/Pointers Needed:
43 Global Stores/Buffers/Pointers Needed:
49 Pointers and Buffers Modified:
50 pp_dec_u contents are the updated semaphore propagation data
52 Local Stores Modified:
55 Global Stores Modified:
58 ------------------------------------------------------------------------------
61 This functions performs post processing semaphore propagation processing
62 after chrominance prediction in interframe processing mode.
67 /*----------------------------------------------------------------------------
69 ----------------------------------------------------------------------------*/
70 #include "mp4dec_api.h"
73 /*----------------------------------------------------------------------------
75 ; Define module specific macros here
76 ----------------------------------------------------------------------------*/
78 /*----------------------------------------------------------------------------
80 ; Include all pre-processor statements here. Include conditional
81 ; compile variables also.
82 ----------------------------------------------------------------------------*/
84 /*----------------------------------------------------------------------------
85 ; LOCAL FUNCTION DEFINITIONS
86 ; Function Prototype declaration
87 ----------------------------------------------------------------------------*/
89 /*----------------------------------------------------------------------------
90 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
91 ; Variable declaration - defined here and used outside this module
92 ----------------------------------------------------------------------------*/
94 /*----------------------------------------------------------------------------
95 ; EXTERNAL FUNCTION REFERENCES
96 ; Declare functions defined elsewhere and referenced in this module
97 ----------------------------------------------------------------------------*/
99 /*----------------------------------------------------------------------------
100 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
101 ; Declare variables used in this module but defined elsewhere
102 ----------------------------------------------------------------------------*/
103 #ifdef PV_POSTPROC_ON
108 /*----------------------------------------------------------------------------
110 ----------------------------------------------------------------------------*/
111 void pp_semaphore_chroma_inter(
114 uint8 *pp_dec_u, /* i/o */
115 uint8 *pstprcTypPrv, /* i */
122 uint8 msk_deblock /* i */
125 /*----------------------------------------------------------------------------
126 ; Define all local variables
127 ----------------------------------------------------------------------------*/
128 int mmvy, mmvx, nmvy, nmvx;
129 uint8 *pp_prev1, *pp_prev2, *pp_prev3, *pp_prev4;
131 /*----------------------------------------------------------------------------
133 ----------------------------------------------------------------------------*/
135 /* 09/28/2000, modify semaphore propagation to */
136 /* accommodate smart indexing */
137 mmvx = xpred >> 4; /* block x coor */
140 mmvy = ypred >> 4; /* block y coor */
143 /* Check if MV is outside the frame */
146 /* Perform boundary check */
151 else if (nmvx > mvwidth - 1)
160 else if (nmvy > (height >> 4) - 1)
162 nmvy = (height >> 4) - 1;
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) ;
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 */
179 /* pp_prev3 is the block below pp_prev1 block */
180 pp_prev3 = pp_prev1 + (mvwidth >> 1);
183 { /* dy is a multiple of 16 */
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 */
191 /* pp_prev2 is the block to the right of pp_prev1 block */
192 pp_prev2 = pp_prev1 + 1;
194 /* pp_prev4 is the block to the right of the block */
195 /* below pp_prev1 block */
196 pp_prev4 = pp_prev3 + 1;
199 { /* dx is a multiple of 16 */
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 */
210 /* mv_loc = (number of pixels in Luminance VOP/(4*64)) */
211 /* = size/256 = size>>8 */
212 mv_loc = (size >> 8);
214 /* 11/3/00, change the propagation for deblocking */
215 if (msk_deblock == 0)
218 /* Deblocking semaphore propagation for Chrominance */
222 /* Advance offset to point to Chrominance r semaphores */
225 /* Deblocking semaphore propagation for Chrominance */
231 /* Deringing semaphore propagation for Chrominance B block */
232 if ((*(pp_dec_u)&4) == 0)
234 *(pp_dec_u) |= ((*(pp_prev1) | *(pp_prev2) |
235 *(pp_prev3) | *(pp_prev4)) & 0x4);
238 /* Advance offset to point to Chrominance r semaphores */
245 /* Deringing semaphore propagation for Chrominance R */
246 if ((*(pp_dec_u)&4) == 0)
248 *(pp_dec_u) |= ((*(pp_prev1) | *(pp_prev2) |
249 *(pp_prev3) | *(pp_prev4)) & 0x4);
253 /*----------------------------------------------------------------------------
254 ; Return nothing or data or data pointer
255 ----------------------------------------------------------------------------*/