1 /*****************************************************************************
2 *
3 * XVID MPEG-4 VIDEO CODEC
4 * - GMC interpolation module header -
5 *
6 * Copyright(C) 2002-2003 Pascal Massimino <skal@planet-d.net>
7 *
8 * This program is free software ; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation ; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY ; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program ; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * $Id: gmc.h 1985 2011-05-18 09:02:35Z Isibaar $
23 *
24 ****************************************************************************/
25
26 #include "../portab.h"
27 #include "../global.h"
28
29 /* *************************************************************
30 * will initialize internal pointers
31 */
32
33 void init_GMC(const unsigned int cpu_flags);
34
35 /* *************************************************************
36 * Warning! It's Accuracy being passed, not 'resolution'!
37 */
38
39 void generate_GMCparameters(int nb_pts, const int accuracy,
40 const WARPPOINTS *const pts,
41 const int width, const int height,
42 NEW_GMC_DATA *const gmc);
43
44 /* *******************************************************************
45 */
46
47 void
48 generate_GMCimage( const NEW_GMC_DATA *const gmc_data, /* [input] precalculated data */
49 const IMAGE *const pRef, /* [input] */
50 const int mb_width,
51 const int mb_height,
52 const int stride,
53 const int stride2,
54 const int fcode, /* [input] some parameters... */
55 const int32_t quarterpel, /* [input] for rounding avgMV */
56 const int reduced_resolution, /* [input] ignored */
57 const int32_t rounding, /* [input] for rounding image data */
58 MACROBLOCK *const pMBs, /* [output] average motion vectors */
59 IMAGE *const pGMC); /* [output] full warped image */
60
61 /* *************************************************************
62 * utils
63 */
64
65 /* This is borrowed from decoder.c */
66 static __inline int
gmc_sanitize(int value,int quarterpel,int fcode)67 gmc_sanitize(int value, int quarterpel, int fcode)
68 {
69 int length = 1 << (fcode+4);
70
71 #if 0
72 if (quarterpel) value *= 2;
73 #endif
74
75 if (value < -length)
76 return -length;
77 else if (value >= length)
78 return length-1;
79 else return value;
80 }
81
82 /* *************************************************************/
83