[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 1085 - (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 : syskin 1085 value >>= 1;
50 :     n++;
51 : chl 1077 }
52 :     return n;
53 :     #else
54 :     __asm {
55 : syskin 1085 bsr eax, value
56 :     inc eax
57 : chl 1077 }
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 : syskin 1085 /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */
68 : chl 1077
69 :     #define RDIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
70 :     #define RSHIFT(a,b) ( (a)>0 ? ((a) + (1<<((b)-1)))>>(b) : ((a) + (1<<((b)-1))-1)>>(b))
71 :    
72 :     #define MLT(i) (((16-(i))<<16) + (i))
73 :     static const uint32_t MTab[16] = {
74 :     MLT( 0), MLT( 1), MLT( 2), MLT( 3), MLT( 4), MLT( 5), MLT( 6), MLT( 7),
75 :     MLT( 8), MLT( 9), MLT(10), MLT(11), MLT(12), MLT(13), MLT(14), MLT(15)
76 :     };
77 :     #undef MLT
78 :    
79 :     //////////////////////////////////////////////////////////
80 :     // Pts = 2 or 3
81 :    
82 :     // Warning! *src is the global frame pointer (that is: adress
83 :     // of pixel 0,0), not the macroblock one.
84 :     // Conversely, *dst is the macroblock top-left adress.
85 :    
86 :     void Predict_16x16_C(const NEW_GMC_DATA * const This,
87 : syskin 1085 uint8_t *dst, const uint8_t *src,
88 :     int dststride, int srcstride, int x, int y, int rounding);
89 : chl 1077
90 :     void Predict_8x8_C(const NEW_GMC_DATA * const This,
91 : syskin 1085 uint8_t *uDst, const uint8_t *uSrc,
92 :     uint8_t *vDst, const uint8_t *vSrc,
93 :     int dststride, int srcstride, int x, int y, int rounding);
94 : chl 1077
95 : syskin 1085 void get_average_mv_C(const NEW_GMC_DATA * const Dsp, VECTOR * const mv,
96 :     int x, int y, int qpel);
97 : chl 1077
98 :     /* ************************************************************ */
99 :     // simplified version for 1 warp point
100 :    
101 :     void Predict_1pt_16x16_C(const NEW_GMC_DATA * const This,
102 : syskin 1085 uint8_t *Dst, const uint8_t *Src,
103 :     int dststride, int srcstride, int x, int y, int rounding);
104 : chl 1077
105 :     void Predict_1pt_8x8_C(const NEW_GMC_DATA * const This,
106 : syskin 1085 uint8_t *uDst, const uint8_t *uSrc,
107 :     uint8_t *vDst, const uint8_t *vSrc,
108 :     int dststride, int srcstride, int x, int y, int rounding);
109 : chl 1077
110 : syskin 1085 void get_average_mv_1pt_C(const NEW_GMC_DATA * const Dsp, VECTOR * const mv,
111 :     int x, int y, int qpel);
112 : chl 1077
113 :     /* ************************************************************* */
114 :    
115 :    
116 :     // Warning! It's Accuracy being passed, not 'resolution'!
117 :    
118 : syskin 1085 void generate_GMCparameters(int nb_pts, const int accuracy,
119 :     const WARPPOINTS *const pts,
120 :     const int width, const int height,
121 :     NEW_GMC_DATA *const gmc);
122 : chl 1077
123 :     /* ******************************************************************* */
124 :    
125 :    
126 :     void
127 :     generate_GMCimage( const NEW_GMC_DATA *const gmc_data, // [input] precalculated data
128 :     const IMAGE *const pRef, // [input]
129 :     const int mb_width,
130 :     const int mb_height,
131 :     const int stride,
132 :     const int stride2,
133 :     const int fcode, // [input] some parameters...
134 :     const int32_t quarterpel, // [input] for rounding avgMV
135 :     const int reduced_resolution, // [input] ignored
136 :     const int32_t rounding, // [input] for rounding image data
137 :     MACROBLOCK *const pMBs, // [output] average motion vectors
138 :     IMAGE *const pGMC); // [output] full warped image
139 :    

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