motion_comp.h revision 3306cfee3bf38ab207a0504e49c2d492bb73ffbf
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#ifndef motion_comp_h
19#define motion_comp_h
20
21/*----------------------------------------------------------------------------
22; INCLUDES
23----------------------------------------------------------------------------*/
24#include "mp4dec_lib.h"
25
26/*----------------------------------------------------------------------------
27; MACROS
28; Define module specific macros here
29----------------------------------------------------------------------------*/
30
31/*----------------------------------------------------------------------------
32; DEFINES
33; Include all pre-processor statements here.
34----------------------------------------------------------------------------*/
35/* CBP Mask defines used in chrominance prediction */
36#define CBP_MASK_CHROMA_BLK4    0x2
37#define CBP_MASK_CHROMA_BLK5    0x1
38
39/* CBP Mask defines used in luminance prediction (MODE_INTER4V) */
40#define CBP_MASK_BLK0_MODE_INTER4V  0x20
41#define CBP_MASK_BLK1_MODE_INTER4V  0x10
42#define CBP_MASK_BLK2_MODE_INTER4V  0x08
43#define CBP_MASK_BLK3_MODE_INTER4V  0x04
44
45/* CBP Mask defines used in luminance prediction (MODE_INTER or MODE_INTER_Q) */
46#define CBP_MASK_MB_MODE_INTER  0x3c
47
48/*----------------------------------------------------------------------------
49; EXTERNAL VARIABLES REFERENCES
50; Declare variables used in this module but defined elsewhere
51----------------------------------------------------------------------------*/
52#ifdef __cplusplus
53extern "C"
54{
55#endif
56
57#define CLIP_RESULT(x)      if(x & -256){x = 0xFF & (~(x>>31));}
58#define ADD_AND_CLIP1(x)    x += (pred_word&0xFF); CLIP_RESULT(x);
59#define ADD_AND_CLIP2(x)    x += ((pred_word>>8)&0xFF); CLIP_RESULT(x);
60#define ADD_AND_CLIP3(x)    x += ((pred_word>>16)&0xFF); CLIP_RESULT(x);
61#define ADD_AND_CLIP4(x)    x += ((pred_word>>24)&0xFF); CLIP_RESULT(x);
62
63#define ADD_AND_CLIP(x,y)    {  x9 = ~(x>>8); \
64                            if(x9!=-1){ \
65                                x9 = ((uint32)x9)>>24; \
66                                y = x9|(y<<8); \
67                            } \
68                            else \
69                            {    \
70                                y =  x|(y<<8); \
71                            } \
72                            }
73
74
75    static int (*const GetPredAdvBTable[2][2])(uint8*, uint8*, int, int) =
76    {
77        {&GetPredAdvancedBy0x0, &GetPredAdvancedBy0x1},
78        {&GetPredAdvancedBy1x0, &GetPredAdvancedBy1x1}
79    };
80
81    /*----------------------------------------------------------------------------
82    ; SIMPLE TYPEDEF'S
83    ----------------------------------------------------------------------------*/
84
85    /*----------------------------------------------------------------------------
86    ; ENUMERATED TYPEDEF'S
87    ----------------------------------------------------------------------------*/
88
89    /*----------------------------------------------------------------------------
90    ; STRUCTURES TYPEDEF'S
91    ----------------------------------------------------------------------------*/
92
93    /*----------------------------------------------------------------------------
94    ; GLOBAL FUNCTION DEFINITIONS
95    ; Function Prototype declaration
96    ----------------------------------------------------------------------------*/
97
98    /*----------------------------------------------------------------------------
99    ; END
100    ----------------------------------------------------------------------------*/
101#endif
102
103#ifdef __cplusplus
104}
105#endif
106
107
108
109