Mercurial > mplayer.hg
annotate libmpeg2/motion_comp.c @ 25317:7f3cb5408f28
Fixed VIDIX color bug that was introduced when Radeon VIDIX driver
was synchronized with vidix.sf.net.
The red color was saturating.
Corrected value fixes the issue and restore the color to the level
it used to have before synchronization.
Meaning of the value remains unknow but was retrieved from
register's value of a Radeon 9000 card, so it may need further testing.
Patch by Guillaume Lecerf (foxcore at gmail dot com)
author | ben |
---|---|
date | Mon, 10 Dec 2007 19:27:46 +0000 |
parents | 316732ab2b41 |
children | b65b71ba0e16 |
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 | |
14732
1385ec491ffb
Mark locally modified files as such to comply more closely with GPL 2a.
diego
parents:
13864
diff
changeset
|
22 * |
21526 | 23 * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes. |
18783 | 24 * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/ |
14732
1385ec491ffb
Mark locally modified files as such to comply more closely with GPL 2a.
diego
parents:
13864
diff
changeset
|
25 * $Id$ |
1 | 26 */ |
27 | |
28 #include "config.h" | |
29 | |
30 #include <inttypes.h> | |
31 | |
9852 | 32 #include "mpeg2.h" |
12932 | 33 #include "attributes.h" |
1 | 34 #include "mpeg2_internal.h" |
35 | |
9852 | 36 mpeg2_mc_t mpeg2_mc; |
1 | 37 |
9852 | 38 void mpeg2_mc_init (uint32_t accel) |
1 | 39 { |
19134
1b3b5258a94e
10l, i broke this with my last commit. should be fixed now.
rfelker
parents:
18783
diff
changeset
|
40 #ifdef HAVE_MMX2 |
9852 | 41 if (accel & MPEG2_ACCEL_X86_MMXEXT) |
42 mpeg2_mc = mpeg2_mc_mmxext; | |
19134
1b3b5258a94e
10l, i broke this with my last commit. should be fixed now.
rfelker
parents:
18783
diff
changeset
|
43 else |
1b3b5258a94e
10l, i broke this with my last commit. should be fixed now.
rfelker
parents:
18783
diff
changeset
|
44 #endif |
1b3b5258a94e
10l, i broke this with my last commit. should be fixed now.
rfelker
parents:
18783
diff
changeset
|
45 #ifdef HAVE_3DNOW |
1b3b5258a94e
10l, i broke this with my last commit. should be fixed now.
rfelker
parents:
18783
diff
changeset
|
46 if (accel & MPEG2_ACCEL_X86_3DNOW) |
9852 | 47 mpeg2_mc = mpeg2_mc_3dnow; |
19134
1b3b5258a94e
10l, i broke this with my last commit. should be fixed now.
rfelker
parents:
18783
diff
changeset
|
48 else |
1b3b5258a94e
10l, i broke this with my last commit. should be fixed now.
rfelker
parents:
18783
diff
changeset
|
49 #endif |
1b3b5258a94e
10l, i broke this with my last commit. should be fixed now.
rfelker
parents:
18783
diff
changeset
|
50 #ifdef HAVE_MMX |
1b3b5258a94e
10l, i broke this with my last commit. should be fixed now.
rfelker
parents:
18783
diff
changeset
|
51 if (accel & MPEG2_ACCEL_X86_MMX) |
9852 | 52 mpeg2_mc = mpeg2_mc_mmx; |
53 else | |
54 #endif | |
13196 | 55 #if defined(ARCH_PPC) && defined(HAVE_ALTIVEC) |
9852 | 56 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) |
57 mpeg2_mc = mpeg2_mc_altivec; | |
58 else | |
59 #endif | |
60 #ifdef ARCH_ALPHA | |
61 if (accel & MPEG2_ACCEL_ALPHA) | |
62 mpeg2_mc = mpeg2_mc_alpha; | |
63 else | |
1 | 64 #endif |
13196 | 65 #if defined(ARCH_SPARC) && defined(HAVE_VIS) |
12932 | 66 if (accel & MPEG2_ACCEL_SPARC_VIS) |
67 mpeg2_mc = mpeg2_mc_vis; | |
9852 | 68 else |
1 | 69 #endif |
23236
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
70 #ifdef ARCH_ARM |
23240 | 71 if (1 /*accel & MPEG2_ACCEL_ARM*/) { |
23236
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
72 #ifdef HAVE_IWMMXT |
23240 | 73 if (1 /*accel & MPEG2_ACCEL_ARM_IWMMXT*/) |
23236
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
74 mpeg2_mc = mpeg2_mc_iwmmxt; |
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
75 else |
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
76 #endif |
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
77 mpeg2_mc = mpeg2_mc_arm; |
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
78 } else |
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
79 #endif |
9852 | 80 mpeg2_mc = mpeg2_mc_c; |
1 | 81 } |
82 | |
83 #define avg2(a,b) ((a+b+1)>>1) | |
84 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) | |
85 | |
9852 | 86 #define predict_o(i) (ref[i]) |
1 | 87 #define predict_x(i) (avg2 (ref[i], ref[i+1])) |
88 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i])) | |
9852 | 89 #define predict_xy(i) (avg4 (ref[i], ref[i+1], \ |
90 (ref+stride)[i], (ref+stride)[i+1])) | |
1 | 91 |
92 #define put(predictor,i) dest[i] = predictor (i) | |
93 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i]) | |
94 | |
36 | 95 /* mc function template */ |
1 | 96 |
9852 | 97 #define MC_FUNC(op,xy) \ |
98 static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \ | |
99 const int stride, int height) \ | |
100 { \ | |
101 do { \ | |
102 op (predict_##xy, 0); \ | |
103 op (predict_##xy, 1); \ | |
104 op (predict_##xy, 2); \ | |
105 op (predict_##xy, 3); \ | |
106 op (predict_##xy, 4); \ | |
107 op (predict_##xy, 5); \ | |
108 op (predict_##xy, 6); \ | |
109 op (predict_##xy, 7); \ | |
110 op (predict_##xy, 8); \ | |
111 op (predict_##xy, 9); \ | |
112 op (predict_##xy, 10); \ | |
113 op (predict_##xy, 11); \ | |
114 op (predict_##xy, 12); \ | |
115 op (predict_##xy, 13); \ | |
116 op (predict_##xy, 14); \ | |
117 op (predict_##xy, 15); \ | |
118 ref += stride; \ | |
119 dest += stride; \ | |
120 } while (--height); \ | |
121 } \ | |
122 static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \ | |
123 const int stride, int height) \ | |
124 { \ | |
125 do { \ | |
126 op (predict_##xy, 0); \ | |
127 op (predict_##xy, 1); \ | |
128 op (predict_##xy, 2); \ | |
129 op (predict_##xy, 3); \ | |
130 op (predict_##xy, 4); \ | |
131 op (predict_##xy, 5); \ | |
132 op (predict_##xy, 6); \ | |
133 op (predict_##xy, 7); \ | |
134 ref += stride; \ | |
135 dest += stride; \ | |
136 } while (--height); \ | |
1 | 137 } |
138 | |
36 | 139 /* definitions of the actual mc functions */ |
1 | 140 |
9852 | 141 MC_FUNC (put,o) |
142 MC_FUNC (avg,o) | |
1 | 143 MC_FUNC (put,x) |
144 MC_FUNC (avg,x) | |
145 MC_FUNC (put,y) | |
146 MC_FUNC (avg,y) | |
147 MC_FUNC (put,xy) | |
148 MC_FUNC (avg,xy) | |
149 | |
9852 | 150 MPEG2_MC_EXTERN (c) |