[svn] / branches / dev-api-4 / xvidcore / src / motion / gmc.h Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/src/motion/gmc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1077 - (view) (download)

1 : chl 1077 /**************************************************************************
2 :     *
3 :     * XVID MPEG-4 VIDEO CODEC
4 :     * GMC interpolation module
5 :     *
6 :     * This program is free software; you can redistribute it and/or modify
7 :     * it under the terms of the GNU General Public License as published by
8 :     * the Free Software Foundation; either version 2 of the License, or
9 :     * (at your option) any later version.
10 :     *
11 :     * This program is distributed in the hope that it will be useful,
12 :     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 :     * GNU General Public License for more details.
15 :     *
16 :     * You should have received a copy of the GNU General Public License
17 :     * along with this program; if not, write to the Free Software
18 :     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 :     *
20 :     *************************************************************************/
21 :    
22 :     #include "../portab.h"
23 :     #include "../global.h"
24 :    
25 :     /* This is borrowed from decoder.c */
26 :     static __inline int gmc_sanitize(int value, int quarterpel, int fcode)
27 :     {
28 :     int length = 1 << (fcode+4);
29 :    
30 :     // if (quarterpel) value *= 2;
31 :    
32 :     if (value < -length)
33 :     return -length;
34 :     else if (value >= length)
35 :     return length-1;
36 :     else return value;
37 :     }
38 :    
39 :    
40 :     /* And this is borrowed from bitstream.c until we find a common solution */
41 :     static uint32_t __inline
42 :     log2bin(uint32_t value)
43 :     {
44 :     /* Changed by Chenm001 */
45 :     #if !defined(_MSC_VER)
46 :     int n = 0;
47 :    
48 :     while (value) {
49 :     value >>= 1;
50 :     n++;
51 :     }
52 :     return n;
53 :     #else
54 :     __asm {
55 :     bsr eax, value
56 :     inc eax
57 :     }
58 :     #endif
59 :     }
60 :     /* 16*sizeof(int) -> 1 or 2 cachelines */
61 :     /* table lookup might be faster! (still to be benchmarked) */
62 :    
63 :     /*
64 :     static int log2bin_table[16] =
65 :     { 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4};
66 :     */
67 :     /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */
68 :    
69 :    
70 :    
71 :    
72 :     #define RDIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
73 :     #define RSHIFT(a,b) ( (a)>0 ? ((a) + (1<<((b)-1)))>>(b) : ((a) + (1<<((b)-1))-1)>>(b))
74 :    
75 :     #define MLT(i) (((16-(i))<<16) + (i))
76 :     static const uint32_t MTab[16] = {
77 :     MLT( 0), MLT( 1), MLT( 2), MLT( 3), MLT( 4), MLT( 5), MLT( 6), MLT( 7),
78 :     MLT( 8), MLT( 9), MLT(10), MLT(11), MLT(12), MLT(13), MLT(14), MLT(15)
79 :     };
80 :     #undef MLT
81 :    
82 :     //////////////////////////////////////////////////////////
83 :     // Pts = 2 or 3
84 :    
85 :     // Warning! *src is the global frame pointer (that is: adress
86 :     // of pixel 0,0), not the macroblock one.
87 :     // Conversely, *dst is the macroblock top-left adress.
88 :    
89 :     void Predict_16x16_C(const NEW_GMC_DATA * const This,
90 :     uint8_t *dst, const uint8_t *src,
91 :     int dststride, int srcstride, int x, int y, int rounding);
92 :    
93 :     void Predict_8x8_C(const NEW_GMC_DATA * const This,
94 :     uint8_t *uDst, const uint8_t *uSrc,
95 :     uint8_t *vDst, const uint8_t *vSrc,
96 :     int dststride, int srcstride, int x, int y, int rounding);
97 :    
98 :     void get_average_mv_C(NEW_GMC_DATA *Dsp, VECTOR * const mv,
99 :     int x, int y, int qpel);
100 :    
101 :     /* ************************************************************ */
102 :     // simplified version for 1 warp point
103 :    
104 :     void Predict_1pt_16x16_C(const NEW_GMC_DATA * const This,
105 :     uint8_t *Dst, const uint8_t *Src,
106 :     int dststride, int srcstride, int x, int y, int rounding);
107 :    
108 :     void Predict_1pt_8x8_C(const NEW_GMC_DATA * const This,
109 :     uint8_t *uDst, const uint8_t *uSrc,
110 :     uint8_t *vDst, const uint8_t *vSrc,
111 :     int dststride, int srcstride, int x, int y, int rounding);
112 :    
113 :     void get_average_mv_1pt_C(NEW_GMC_DATA *Dsp, VECTOR * const mv,
114 :     int x, int y, int qpel);
115 :    
116 :     /* ************************************************************* */
117 :    
118 :    
119 :     // Warning! It's Accuracy being passed, not 'resolution'!
120 :    
121 :     void generate_GMCparameters( int nb_pts, const int accuracy,
122 :     const WARPPOINTS *const pts,
123 :     const int width, const int height,
124 :     NEW_GMC_DATA *const gmc);
125 :    
126 :     /* ******************************************************************* */
127 :    
128 :    
129 :     void
130 :     generate_GMCimage( const NEW_GMC_DATA *const gmc_data, // [input] precalculated data
131 :     const IMAGE *const pRef, // [input]
132 :     const int mb_width,
133 :     const int mb_height,
134 :     const int stride,
135 :     const int stride2,
136 :     const int fcode, // [input] some parameters...
137 :     const int32_t quarterpel, // [input] for rounding avgMV
138 :     const int reduced_resolution, // [input] ignored
139 :     const int32_t rounding, // [input] for rounding image data
140 :     MACROBLOCK *const pMBs, // [output] average motion vectors
141 :     IMAGE *const pGMC); // [output] full warped image
142 :    

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4