Mercurial > mplayer.hg
annotate libmpeg2/motion_comp.c @ 10730:67449e5936f3
fix 10l (computation based on uninitialized data which led to
incorrect field matching) and greatly improve selection logic. the
pullup core should be very accurate now, so try throwing tough samples
at it and report any failures! :)
author | rfelker |
---|---|
date | Sun, 31 Aug 2003 17:46:32 +0000 |
parents | 2c0b6ec77d39 |
children | d0a8810e155c |
rev | line source |
---|---|
1 | 1 /* |
2 * motion_comp.c | |
10303 | 3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> |
9852 | 4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> |
1 | 5 * |
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | |
9852 | 7 * See http://libmpeg2.sourceforge.net/ for updates. |
1 | 8 * |
9 * mpeg2dec is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * mpeg2dec is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
23 | |
24 #include "config.h" | |
25 | |
26 #include <inttypes.h> | |
27 | |
9852 | 28 #include "mpeg2.h" |
1 | 29 #include "mpeg2_internal.h" |
30 | |
9852 | 31 mpeg2_mc_t mpeg2_mc; |
1 | 32 |
9852 | 33 void mpeg2_mc_init (uint32_t accel) |
1 | 34 { |
35 #ifdef ARCH_X86 | |
9852 | 36 if (accel & MPEG2_ACCEL_X86_MMXEXT) |
37 mpeg2_mc = mpeg2_mc_mmxext; | |
38 else if (accel & MPEG2_ACCEL_X86_3DNOW) | |
39 mpeg2_mc = mpeg2_mc_3dnow; | |
40 else if (accel & MPEG2_ACCEL_X86_MMX) | |
41 mpeg2_mc = mpeg2_mc_mmx; | |
42 else | |
43 #endif | |
44 #ifdef ARCH_PPC | |
10269
217eb10b2f2d
libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents:
9852
diff
changeset
|
45 #ifdef HAVE_ALTIVEC |
9852 | 46 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) |
47 mpeg2_mc = mpeg2_mc_altivec; | |
48 else | |
49 #endif | |
10269
217eb10b2f2d
libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents:
9852
diff
changeset
|
50 #endif |
9852 | 51 #ifdef ARCH_ALPHA |
52 if (accel & MPEG2_ACCEL_ALPHA) | |
53 mpeg2_mc = mpeg2_mc_alpha; | |
54 else | |
1 | 55 #endif |
56 #ifdef LIBMPEG2_MLIB | |
9852 | 57 if (accel & MPEG2_ACCEL_MLIB) |
58 mpeg2_mc = mpeg2_mc_mlib; | |
59 else | |
1 | 60 #endif |
9852 | 61 mpeg2_mc = mpeg2_mc_c; |
1 | 62 } |
63 | |
64 #define avg2(a,b) ((a+b+1)>>1) | |
65 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) | |
66 | |
9852 | 67 #define predict_o(i) (ref[i]) |
1 | 68 #define predict_x(i) (avg2 (ref[i], ref[i+1])) |
69 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i])) | |
9852 | 70 #define predict_xy(i) (avg4 (ref[i], ref[i+1], \ |
71 (ref+stride)[i], (ref+stride)[i+1])) | |
1 | 72 |
73 #define put(predictor,i) dest[i] = predictor (i) | |
74 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i]) | |
75 | |
36 | 76 /* mc function template */ |
1 | 77 |
9852 | 78 #define MC_FUNC(op,xy) \ |
79 static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \ | |
80 const int stride, int height) \ | |
81 { \ | |
82 do { \ | |
83 op (predict_##xy, 0); \ | |
84 op (predict_##xy, 1); \ | |
85 op (predict_##xy, 2); \ | |
86 op (predict_##xy, 3); \ | |
87 op (predict_##xy, 4); \ | |
88 op (predict_##xy, 5); \ | |
89 op (predict_##xy, 6); \ | |
90 op (predict_##xy, 7); \ | |
91 op (predict_##xy, 8); \ | |
92 op (predict_##xy, 9); \ | |
93 op (predict_##xy, 10); \ | |
94 op (predict_##xy, 11); \ | |
95 op (predict_##xy, 12); \ | |
96 op (predict_##xy, 13); \ | |
97 op (predict_##xy, 14); \ | |
98 op (predict_##xy, 15); \ | |
99 ref += stride; \ | |
100 dest += stride; \ | |
101 } while (--height); \ | |
102 } \ | |
103 static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \ | |
104 const int stride, int height) \ | |
105 { \ | |
106 do { \ | |
107 op (predict_##xy, 0); \ | |
108 op (predict_##xy, 1); \ | |
109 op (predict_##xy, 2); \ | |
110 op (predict_##xy, 3); \ | |
111 op (predict_##xy, 4); \ | |
112 op (predict_##xy, 5); \ | |
113 op (predict_##xy, 6); \ | |
114 op (predict_##xy, 7); \ | |
115 ref += stride; \ | |
116 dest += stride; \ | |
117 } while (--height); \ | |
1 | 118 } |
119 | |
36 | 120 /* definitions of the actual mc functions */ |
1 | 121 |
9852 | 122 MC_FUNC (put,o) |
123 MC_FUNC (avg,o) | |
1 | 124 MC_FUNC (put,x) |
125 MC_FUNC (avg,x) | |
126 MC_FUNC (put,y) | |
127 MC_FUNC (avg,y) | |
128 MC_FUNC (put,xy) | |
129 MC_FUNC (avg,xy) | |
130 | |
9852 | 131 MPEG2_MC_EXTERN (c) |