annotate libvo/osd.c @ 9351:8ec4d4563bc4

10l
author pontscho
date Sat, 08 Feb 2003 21:54:57 +0000
parents 5074aa8fae5a
children 14c8c762c2b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
1 // Generic alpha renderers for all YUV modes and RGB depths.
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
2 // These are "reference implementations", should be optimized later (MMX, etc)
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
3 // Templating Code from Michael Niedermayer (michaelni@gmx.at) is under GPL
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
4
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
5 //#define FAST_OSD
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
6 //#define FAST_OSD_TABLE
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
7
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
8 #include "config.h"
622
6737025afed0 to be sure in that header is okey
arpi_esp
parents: 326
diff changeset
9 #include "osd.h"
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
10 #include "mp_msg.h"
2833
1b6c207c0410 Enable MMX stuff
nick
parents: 2823
diff changeset
11 //#define ENABLE_PROFILE
1b6c207c0410 Enable MMX stuff
nick
parents: 2823
diff changeset
12 #include "../my_profile.h"
2846
ab51228bf3cf p2/p3 bgr32 version (20%faster)
michael
parents: 2843
diff changeset
13 #include <inttypes.h>
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
14 #include "../cpudetect.h"
4245
27cb0e43de32 mangling in libvo
atmos4
parents: 3153
diff changeset
15 #include "../mangle.h"
2846
ab51228bf3cf p2/p3 bgr32 version (20%faster)
michael
parents: 2843
diff changeset
16
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
17 extern int verbose; // defined in mplayer.c
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
18
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
19 #ifdef ARCH_X86
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
20 #define CAN_COMPILE_X86_ASM
2846
ab51228bf3cf p2/p3 bgr32 version (20%faster)
michael
parents: 2843
diff changeset
21 #endif
622
6737025afed0 to be sure in that header is okey
arpi_esp
parents: 326
diff changeset
22
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
23 #ifdef CAN_COMPILE_X86_ASM
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
24 static const uint64_t bFF __attribute__((aligned(8))) = 0xFFFFFFFFFFFFFFFFULL;
2839
03ccbb72e2e9 Cloning 32 stuff to 24
nick
parents: 2835
diff changeset
25 static const unsigned long long mask24lh __attribute__((aligned(8))) = 0xFFFF000000000000ULL;
03ccbb72e2e9 Cloning 32 stuff to 24
nick
parents: 2835
diff changeset
26 static const unsigned long long mask24hl __attribute__((aligned(8))) = 0x0000FFFFFFFFFFFFULL;
03ccbb72e2e9 Cloning 32 stuff to 24
nick
parents: 2835
diff changeset
27 #endif
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
28
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
29 //Note: we have C, X86-nommx, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
30 //Plain C versions
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
31 #if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
32 #define COMPILE_C
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
33 #endif
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
34
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
35 #ifdef CAN_COMPILE_X86_ASM
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
36
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
37 #if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
38 #define COMPILE_MMX
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
39 #endif
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
40
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
41 #if defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
42 #define COMPILE_MMX2
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
43 #endif
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
44
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
45 #if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
46 #define COMPILE_3DNOW
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
47 #endif
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
48 #endif //CAN_COMPILE_X86_ASM
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
49
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
50 #undef HAVE_MMX
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
51 #undef HAVE_MMX2
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
52 #undef HAVE_3DNOW
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
53 #undef ARCH_X86
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
54
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
55 #ifdef COMPILE_C
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
56 #undef HAVE_MMX
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
57 #undef HAVE_MMX2
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
58 #undef HAVE_3DNOW
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
59 #undef ARCH_X86
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
60 #define RENAME(a) a ## _C
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
61 #include "osd_template.c"
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
62 #endif
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
63
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
64 #ifdef CAN_COMPILE_X86_ASM
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
65
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
66 //X86 noMMX versions
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
67 #ifdef COMPILE_C
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
68 #undef RENAME
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
69 #undef HAVE_MMX
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
70 #undef HAVE_MMX2
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
71 #undef HAVE_3DNOW
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
72 #define ARCH_X86
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
73 #define RENAME(a) a ## _X86
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
74 #include "osd_template.c"
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
75 #endif
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
76
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
77 //MMX versions
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
78 #ifdef COMPILE_MMX
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
79 #undef RENAME
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
80 #define HAVE_MMX
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
81 #undef HAVE_MMX2
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
82 #undef HAVE_3DNOW
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
83 #define ARCH_X86
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
84 #define RENAME(a) a ## _MMX
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
85 #include "osd_template.c"
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
86 #endif
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
87
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
88 //MMX2 versions
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
89 #ifdef COMPILE_MMX2
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
90 #undef RENAME
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
91 #define HAVE_MMX
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
92 #define HAVE_MMX2
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
93 #undef HAVE_3DNOW
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
94 #define ARCH_X86
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
95 #define RENAME(a) a ## _MMX2
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
96 #include "osd_template.c"
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
97 #endif
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
98
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
99 //3DNOW versions
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
100 #ifdef COMPILE_3DNOW
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
101 #undef RENAME
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
102 #define HAVE_MMX
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
103 #undef HAVE_MMX2
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
104 #define HAVE_3DNOW
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
105 #define ARCH_X86
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
106 #define RENAME(a) a ## _3DNow
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
107 #include "osd_template.c"
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
108 #endif
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
109
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
110 #endif //CAN_COMPILE_X86_ASM
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
111
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
112 void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
113 #ifdef RUNTIME_CPUDETECT
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
114 #ifdef CAN_COMPILE_X86_ASM
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
115 // ordered per speed fasterst first
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
116 if(gCpuCaps.hasMMX2)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
117 vo_draw_alpha_yv12_MMX2(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
118 else if(gCpuCaps.has3DNow)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
119 vo_draw_alpha_yv12_3DNow(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
120 else if(gCpuCaps.hasMMX)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
121 vo_draw_alpha_yv12_MMX(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
122 else
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
123 vo_draw_alpha_yv12_X86(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
124 #else
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
125 vo_draw_alpha_yv12_C(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
126 #endif
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
127 #else //RUNTIME_CPUDETECT
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
128 #ifdef HAVE_MMX2
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
129 vo_draw_alpha_yv12_MMX2(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
130 #elif defined (HAVE_3DNOW)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
131 vo_draw_alpha_yv12_3DNow(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
132 #elif defined (HAVE_MMX)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
133 vo_draw_alpha_yv12_MMX(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
134 #elif defined (ARCH_X86)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
135 vo_draw_alpha_yv12_X86(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
136 #else
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
137 vo_draw_alpha_yv12_C(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
138 #endif
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
139 #endif //!RUNTIME_CPUDETECT
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
140 }
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
141
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
142 void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
143 #ifdef RUNTIME_CPUDETECT
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
144 #ifdef CAN_COMPILE_X86_ASM
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
145 // ordered per speed fasterst first
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
146 if(gCpuCaps.hasMMX2)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
147 vo_draw_alpha_yuy2_MMX2(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
148 else if(gCpuCaps.has3DNow)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
149 vo_draw_alpha_yuy2_3DNow(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
150 else if(gCpuCaps.hasMMX)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
151 vo_draw_alpha_yuy2_MMX(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
152 else
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
153 vo_draw_alpha_yuy2_X86(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
154 #else
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
155 vo_draw_alpha_yuy2_C(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
156 #endif
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
157 #else //RUNTIME_CPUDETECT
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
158 #ifdef HAVE_MMX2
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
159 vo_draw_alpha_yuy2_MMX2(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
160 #elif defined (HAVE_3DNOW)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
161 vo_draw_alpha_yuy2_3DNow(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
162 #elif defined (HAVE_MMX)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
163 vo_draw_alpha_yuy2_MMX(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
164 #elif defined (ARCH_X86)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
165 vo_draw_alpha_yuy2_X86(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
166 #else
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
167 vo_draw_alpha_yuy2_C(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
168 #endif
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
169 #endif //!RUNTIME_CPUDETECT
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
170 }
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
171
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
172 void vo_draw_alpha_rgb24(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
173 #ifdef RUNTIME_CPUDETECT
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
174 #ifdef CAN_COMPILE_X86_ASM
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
175 // ordered per speed fasterst first
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
176 if(gCpuCaps.hasMMX2)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
177 vo_draw_alpha_rgb24_MMX2(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
178 else if(gCpuCaps.has3DNow)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
179 vo_draw_alpha_rgb24_3DNow(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
180 else if(gCpuCaps.hasMMX)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
181 vo_draw_alpha_rgb24_MMX(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
182 else
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
183 vo_draw_alpha_rgb24_X86(w, h, src, srca, srcstride, dstbase, dststride);
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
184 #else
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
185 vo_draw_alpha_rgb24_C(w, h, src, srca, srcstride, dstbase, dststride);
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
186 #endif
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
187 #else //RUNTIME_CPUDETECT
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
188 #ifdef HAVE_MMX2
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
189 vo_draw_alpha_rgb24_MMX2(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
190 #elif defined (HAVE_3DNOW)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
191 vo_draw_alpha_rgb24_3DNow(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
192 #elif defined (HAVE_MMX)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
193 vo_draw_alpha_rgb24_MMX(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
194 #elif defined (ARCH_X86)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
195 vo_draw_alpha_rgb24_X86(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
196 #else
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
197 vo_draw_alpha_rgb24_C(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
198 #endif
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
199 #endif //!RUNTIME_CPUDETECT
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
200 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
201
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
202 void vo_draw_alpha_rgb32(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
203 #ifdef RUNTIME_CPUDETECT
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
204 #ifdef CAN_COMPILE_X86_ASM
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
205 // ordered per speed fasterst first
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
206 if(gCpuCaps.hasMMX2)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
207 vo_draw_alpha_rgb32_MMX2(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
208 else if(gCpuCaps.has3DNow)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
209 vo_draw_alpha_rgb32_3DNow(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
210 else if(gCpuCaps.hasMMX)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
211 vo_draw_alpha_rgb32_MMX(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
212 else
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
213 vo_draw_alpha_rgb32_X86(w, h, src, srca, srcstride, dstbase, dststride);
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
214 #else
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
215 vo_draw_alpha_rgb32_C(w, h, src, srca, srcstride, dstbase, dststride);
2846
ab51228bf3cf p2/p3 bgr32 version (20%faster)
michael
parents: 2843
diff changeset
216 #endif
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
217 #else //RUNTIME_CPUDETECT
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
218 #ifdef HAVE_MMX2
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
219 vo_draw_alpha_rgb32_MMX2(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
220 #elif defined (HAVE_3DNOW)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
221 vo_draw_alpha_rgb32_3DNow(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
222 #elif defined (HAVE_MMX)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
223 vo_draw_alpha_rgb32_MMX(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
224 #elif defined (ARCH_X86)
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
225 vo_draw_alpha_rgb32_X86(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
226 #else
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
227 vo_draw_alpha_rgb32_C(w, h, src, srca, srcstride, dstbase, dststride);
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
228 #endif
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
229 #endif //!RUNTIME_CPUDETECT
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
230 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
231
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
232 #ifdef FAST_OSD_TABLE
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
233 static unsigned short fast_osd_15bpp_table[256];
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
234 static unsigned short fast_osd_16bpp_table[256];
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
235 #endif
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
236
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
237 void vo_draw_alpha_init(){
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
238 #ifdef FAST_OSD_TABLE
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
239 int i;
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
240 for(i=0;i<256;i++){
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
241 fast_osd_15bpp_table[i]=((i>>3)<<10)|((i>>3)<<5)|(i>>3);
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
242 fast_osd_16bpp_table[i]=((i>>3)<<11)|((i>>2)<<5)|(i>>3);
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
243 }
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
244 #endif
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
245 //FIXME the optimized stuff is a lie for 15/16bpp as they arent optimized yet
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
246 if(verbose)
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
247 {
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
248 #ifdef RUNTIME_CPUDETECT
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
249 #ifdef CAN_COMPILE_X86_ASM
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
250 // ordered per speed fasterst first
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
251 if(gCpuCaps.hasMMX2)
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
252 mp_msg(MSGT_OSD,MSGL_INFO,"Using MMX (with tiny bit MMX2) Optimized OnScreenDisplay\n");
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
253 else if(gCpuCaps.has3DNow)
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
254 mp_msg(MSGT_OSD,MSGL_INFO,"Using MMX (with tiny bit 3DNow) Optimized OnScreenDisplay\n");
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
255 else if(gCpuCaps.hasMMX)
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
256 mp_msg(MSGT_OSD,MSGL_INFO,"Using MMX Optimized OnScreenDisplay\n");
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
257 else
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
258 mp_msg(MSGT_OSD,MSGL_INFO,"Using X86 Optimized OnScreenDisplay\n");
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
259 #else
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
260 mp_msg(MSGT_OSD,MSGL_INFO,"Using Unoptimized OnScreenDisplay\n");
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
261 #endif
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
262 #else //RUNTIME_CPUDETECT
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
263 #ifdef HAVE_MMX2
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
264 mp_msg(MSGT_OSD,MSGL_INFO,"Using MMX (with tiny bit MMX2) Optimized OnScreenDisplay\n");
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
265 #elif defined (HAVE_3DNOW)
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
266 mp_msg(MSGT_OSD,MSGL_INFO,"Using MMX (with tiny bit 3DNow) Optimized OnScreenDisplay\n");
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
267 #elif defined (HAVE_MMX)
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
268 mp_msg(MSGT_OSD,MSGL_INFO,"Using MMX Optimized OnScreenDisplay\n");
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
269 #elif defined (ARCH_X86)
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
270 mp_msg(MSGT_OSD,MSGL_INFO,"Using X86 Optimized OnScreenDisplay\n");
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
271 #else
5935
5074aa8fae5a printf to mp_msg
albeu
parents: 4245
diff changeset
272 mp_msg(MSGT_OSD,MSGL_INFO,"Using Unoptimized OnScreenDisplay\n");
3153
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
273 #endif
5b8db331d0c1 optional runtime cpu detect
michael
parents: 3142
diff changeset
274 #endif //!RUNTIME_CPUDETECT
3142
0f6cce3a8059 runtime cpu detection
michael
parents: 2850
diff changeset
275 }
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
276 }
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
277
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
278 void vo_draw_alpha_rgb15(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
279 int y;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
280 for(y=0;y<h;y++){
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
281 register unsigned short *dst = (unsigned short*) dstbase;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
282 register int x;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
283 for(x=0;x<w;x++){
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
284 if(srca[x]){
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
285 #ifdef FAST_OSD
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
286 #ifdef FAST_OSD_TABLE
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
287 dst[x]=fast_osd_15bpp_table[src[x]];
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
288 #else
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
289 register unsigned int a=src[x]>>3;
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
290 dst[x]=(a<<10)|(a<<5)|a;
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
291 #endif
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
292 #else
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
293 unsigned char r=dst[x]&0x1F;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
294 unsigned char g=(dst[x]>>5)&0x1F;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
295 unsigned char b=(dst[x]>>10)&0x1F;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
296 r=(((r*srca[x])>>5)+src[x])>>3;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
297 g=(((g*srca[x])>>5)+src[x])>>3;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
298 b=(((b*srca[x])>>5)+src[x])>>3;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
299 dst[x]=(b<<10)|(g<<5)|r;
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
300 #endif
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
301 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
302 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
303 src+=srcstride;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
304 srca+=srcstride;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
305 dstbase+=dststride;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
306 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
307 return;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
308 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
309
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
310 void vo_draw_alpha_rgb16(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
311 int y;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
312 for(y=0;y<h;y++){
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
313 register unsigned short *dst = (unsigned short*) dstbase;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
314 register int x;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
315 for(x=0;x<w;x++){
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
316 if(srca[x]){
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
317 #ifdef FAST_OSD
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
318 #ifdef FAST_OSD_TABLE
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
319 dst[x]=fast_osd_16bpp_table[src[x]];
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
320 #else
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
321 dst[x]=((src[x]>>3)<<11)|((src[x]>>2)<<5)|(src[x]>>3);
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
322 #endif
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
323 #else
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
324 unsigned char r=dst[x]&0x1F;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
325 unsigned char g=(dst[x]>>5)&0x3F;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
326 unsigned char b=(dst[x]>>11)&0x1F;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
327 r=(((r*srca[x])>>5)+src[x])>>3;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
328 g=(((g*srca[x])>>6)+src[x])>>2;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
329 b=(((b*srca[x])>>5)+src[x])>>3;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
330 dst[x]=(b<<11)|(g<<5)|r;
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 622
diff changeset
331 #endif
326
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
332 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
333 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
334 src+=srcstride;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
335 srca+=srcstride;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
336 dstbase+=dststride;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
337 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
338 return;
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
339 }
f6b5c2dbc88e OSD alpha renderers moved to osd.c
arpi_esp
parents:
diff changeset
340