Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11yuv.c @ 1338:604d73db6802
Removed uses of stdlib.h and string.h
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 09:29:18 +0000 |
parents | 3692456e7b0f |
children | c71e05b4dc2e |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
182
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 /* This is the XFree86 Xv extension implementation of YUV video overlays */ | |
24 | |
25 #ifdef XFREE86_XV | |
26 | |
27 #include <X11/Xlib.h> | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
28 #ifndef NO_SHARED_MEMORY |
0 | 29 #include <sys/ipc.h> |
30 #include <sys/shm.h> | |
31 #include <X11/extensions/XShm.h> | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
32 #endif |
1306
0c105755b110
Changed references to XFree86 to Xext to match change in directory structure.
Ryan C. Gordon <icculus@icculus.org>
parents:
1196
diff
changeset
|
33 #include <Xext/extensions/Xvlib.h> |
0 | 34 |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
35 #include "SDL_stdlib.h" |
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
36 #include "SDL_string.h" |
0 | 37 #include "SDL_error.h" |
38 #include "SDL_video.h" | |
39 #include "SDL_x11yuv_c.h" | |
40 #include "SDL_yuvfuncs.h" | |
41 | |
42 #define XFREE86_REFRESH_HACK | |
43 #ifdef XFREE86_REFRESH_HACK | |
44 #include "SDL_x11image_c.h" | |
45 #endif | |
46 | |
47 /* Workaround when pitch != width */ | |
48 #define PITCH_WORKAROUND | |
49 | |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
50 /* Fix for the NVidia GeForce 2 - use the last available adaptor */ |
341
6ca967a46bf1
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
51 /*#define USE_LAST_ADAPTOR*/ /* Apparently the NVidia drivers are fixed */ |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
52 |
0 | 53 /* The functions used to manipulate software video overlays */ |
54 static struct private_yuvhwfuncs x11_yuvfuncs = { | |
55 X11_LockYUVOverlay, | |
56 X11_UnlockYUVOverlay, | |
57 X11_DisplayYUVOverlay, | |
58 X11_FreeYUVOverlay | |
59 }; | |
60 | |
61 struct private_yuvhwdata { | |
62 int port; | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
63 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
64 int yuv_use_mitshm; |
0 | 65 XShmSegmentInfo yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
66 #endif |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
67 SDL_NAME(XvImage) *image; |
0 | 68 }; |
69 | |
70 | |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
71 static int (*X_handler)(Display *, XErrorEvent *) = NULL; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
72 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
73 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
74 /* Shared memory error handler routine */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
75 static int shm_error; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
76 static int shm_errhandler(Display *d, XErrorEvent *e) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
77 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
78 if ( e->error_code == BadAccess ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
79 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
80 return(0); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
81 } else |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
82 return(X_handler(d,e)); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
83 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
84 #endif /* !NO_SHARED_MEMORY */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
85 |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
86 static int xv_error; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
87 static int xv_errhandler(Display *d, XErrorEvent *e) |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
88 { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
89 if ( e->error_code == BadMatch ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
90 xv_error = True; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
91 return(0); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
92 } else |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
93 return(X_handler(d,e)); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
94 } |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
95 |
0 | 96 SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) |
97 { | |
98 SDL_Overlay *overlay; | |
99 struct private_yuvhwdata *hwdata; | |
100 int xv_port; | |
1196
b81f54c3963f
Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
101 unsigned int i, j, k; |
b81f54c3963f
Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
102 unsigned int adaptors; |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
103 SDL_NAME(XvAdaptorInfo) *ainfo; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
104 int bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
105 #ifndef NO_SHARED_MEMORY |
0 | 106 XShmSegmentInfo *yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
107 #endif |
0 | 108 |
109 /* Look for the XVideo extension with a valid port for this format */ | |
110 xv_port = -1; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
111 if ( (Success == SDL_NAME(XvQueryExtension)(GFX_Display, &j, &j, &j, &j, &j)) && |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
112 (Success == SDL_NAME(XvQueryAdaptors)(GFX_Display, |
0 | 113 RootWindow(GFX_Display, SDL_Screen), |
114 &adaptors, &ainfo)) ) { | |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
115 #ifdef USE_LAST_ADAPTOR |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
116 for ( i=0; i < adaptors; ++i ) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
117 #else |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
118 for ( i=0; (i < adaptors) && (xv_port == -1); ++i ) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
119 #endif /* USE_LAST_ADAPTOR */ |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
120 { |
0 | 121 /* Check to see if the visual can be used */ |
122 if ( BUGGY_XFREE86(<=, 4001) ) { | |
123 int visual_ok = 0; | |
124 for ( j=0; j<ainfo[i].num_formats; ++j ) { | |
125 if ( ainfo[i].formats[j].visual_id == | |
126 SDL_Visual->visualid ) { | |
127 visual_ok = 1; | |
128 break; | |
129 } | |
130 } | |
131 if ( ! visual_ok ) { | |
132 continue; | |
133 } | |
134 } | |
135 if ( (ainfo[i].type & XvInputMask) && | |
136 (ainfo[i].type & XvImageMask) ) { | |
137 int num_formats; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
138 SDL_NAME(XvImageFormatValues) *formats; |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
139 formats = SDL_NAME(XvListImageFormats)(GFX_Display, |
0 | 140 ainfo[i].base_id, &num_formats); |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
141 #ifdef USE_LAST_ADAPTOR |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
142 for ( j=0; j < num_formats; ++j ) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
143 #else |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
144 for ( j=0; (j < num_formats) && (xv_port == -1); ++j ) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
145 #endif /* USE_LAST_ADAPTOR */ |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
146 { |
0 | 147 if ( (Uint32)formats[j].id == format ) { |
148 for ( k=0; k < ainfo[i].num_ports; ++k ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
149 if ( Success == SDL_NAME(XvGrabPort)(GFX_Display, ainfo[i].base_id+k, CurrentTime) ) { |
0 | 150 xv_port = ainfo[i].base_id+k; |
151 break; | |
152 } | |
153 } | |
154 } | |
155 } | |
410
365f57b7c4ac
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
409
diff
changeset
|
156 if ( formats ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
157 pXFree(formats); |
410
365f57b7c4ac
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
409
diff
changeset
|
158 } |
0 | 159 } |
160 } | |
409
1c3cf7231cd4
Fixed memory leaks in YUV code
Sam Lantinga <slouken@libsdl.org>
parents:
341
diff
changeset
|
161 SDL_NAME(XvFreeAdaptorInfo)(ainfo); |
0 | 162 } |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
163 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
164 /* Precalculate the bpp for the pitch workaround below */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
165 switch (format) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
166 /* Add any other cases we need to support... */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
167 case SDL_YUY2_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
168 case SDL_UYVY_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
169 case SDL_YVYU_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
170 bpp = 2; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
171 break; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
172 default: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
173 bpp = 1; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
174 break; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
175 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
176 |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
177 #if 0 |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
178 /* |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
179 * !!! FIXME: |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
180 * "Here are some diffs for X11 and yuv. Note that the last part 2nd |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
181 * diff should probably be a new call to XvQueryAdaptorFree with ainfo |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
182 * and the number of adaptors, instead of the loop through like I did." |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
183 * |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
184 * ACHTUNG: This is broken! It looks like XvFreeAdaptorInfo does this |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
185 * for you, so we end up with a double-free. I need to look at this |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
186 * more closely... --ryan. |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
187 */ |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
188 for ( i=0; i < adaptors; ++i ) { |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
189 if (ainfo[i].name != NULL) Xfree(ainfo[i].name); |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
190 if (ainfo[i].formats != NULL) Xfree(ainfo[i].formats); |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
191 } |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
192 Xfree(ainfo); |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
193 #endif |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
194 |
0 | 195 if ( xv_port == -1 ) { |
196 SDL_SetError("No available video ports for requested format"); | |
197 return(NULL); | |
198 } | |
199 | |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
200 /* Enable auto-painting of the overlay colorkey */ |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
201 { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
202 static const char *attr[] = { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" }; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
203 unsigned int i; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
204 |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
205 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
206 X_handler = pXSetErrorHandler(xv_errhandler); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
207 for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
208 Atom a; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
209 |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
210 xv_error = False; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
211 a = pXInternAtom(GFX_Display, attr[i], True); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
212 if ( a != None ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
213 SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
214 pXSync(GFX_Display, True); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
215 if ( ! xv_error ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
216 break; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
217 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
218 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
219 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
220 pXSetErrorHandler(X_handler); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
221 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
222 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
223 |
0 | 224 /* Create the overlay structure */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
225 overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); |
0 | 226 if ( overlay == NULL ) { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
227 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); |
0 | 228 SDL_OutOfMemory(); |
229 return(NULL); | |
230 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
231 SDL_memset(overlay, 0, (sizeof *overlay)); |
0 | 232 |
233 /* Fill in the basic members */ | |
234 overlay->format = format; | |
235 overlay->w = width; | |
236 overlay->h = height; | |
237 | |
238 /* Set up the YUV surface function structure */ | |
239 overlay->hwfuncs = &x11_yuvfuncs; | |
240 overlay->hw_overlay = 1; | |
241 | |
242 /* Create the pixel data and lookup tables */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
243 hwdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *hwdata); |
0 | 244 overlay->hwdata = hwdata; |
245 if ( hwdata == NULL ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
246 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); |
0 | 247 SDL_OutOfMemory(); |
248 SDL_FreeYUVOverlay(overlay); | |
249 return(NULL); | |
250 } | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
251 hwdata->port = xv_port; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
252 #ifndef NO_SHARED_MEMORY |
0 | 253 yuvshm = &hwdata->yuvshm; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
254 SDL_memset(yuvshm, 0, sizeof(*yuvshm)); |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
255 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
256 0, width, height, yuvshm); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
257 #ifdef PITCH_WORKAROUND |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
258 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
259 /* Ajust overlay width according to pitch */ |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
260 pXFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
261 width = hwdata->image->pitches[0] / bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
262 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
263 0, width, height, yuvshm); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
264 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
265 #endif /* PITCH_WORKAROUND */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
266 hwdata->yuv_use_mitshm = (hwdata->image != NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
267 if ( hwdata->yuv_use_mitshm ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
268 yuvshm->shmid = shmget(IPC_PRIVATE, hwdata->image->data_size, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
269 IPC_CREAT | 0777); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
270 if ( yuvshm->shmid >= 0 ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
271 yuvshm->shmaddr = (char *)shmat(yuvshm->shmid, 0, 0); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
272 yuvshm->readOnly = False; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
273 if ( yuvshm->shmaddr != (char *)-1 ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
274 shm_error = False; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
275 X_handler = pXSetErrorHandler(shm_errhandler); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
276 pXShmAttach(GFX_Display, yuvshm); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
277 pXSync(GFX_Display, True); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
278 pXSetErrorHandler(X_handler); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
279 if ( shm_error ) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
280 shmdt(yuvshm->shmaddr); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
281 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
282 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
283 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
284 shmctl(yuvshm->shmid, IPC_RMID, NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
285 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
286 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
287 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
288 if ( shm_error ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
289 pXFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
290 hwdata->yuv_use_mitshm = 0; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
291 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
292 hwdata->image->data = yuvshm->shmaddr; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
293 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
294 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
295 if ( !hwdata->yuv_use_mitshm ) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
296 #endif /* NO_SHARED_MEMORY */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
297 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
298 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
299 0, width, height); |
0 | 300 |
301 #ifdef PITCH_WORKAROUND | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
302 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
303 /* Ajust overlay width according to pitch */ |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
304 pXFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
305 width = hwdata->image->pitches[0] / bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
306 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
307 0, width, height); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
308 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
309 #endif /* PITCH_WORKAROUND */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
310 if ( hwdata->image == NULL ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
311 SDL_SetError("Couldn't create XVideo image"); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
312 SDL_FreeYUVOverlay(overlay); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
313 return(NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
314 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
315 hwdata->image->data = SDL_malloc(hwdata->image->data_size); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
316 if ( hwdata->image->data == NULL ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
317 SDL_OutOfMemory(); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
318 SDL_FreeYUVOverlay(overlay); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
319 return(NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
320 } |
0 | 321 } |
322 | |
323 /* Find the pitch and offset values for the overlay */ | |
324 overlay->planes = hwdata->image->num_planes; | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
325 overlay->pitches = (Uint16 *)SDL_malloc(overlay->planes * sizeof(Uint16)); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
326 overlay->pixels = (Uint8 **)SDL_malloc(overlay->planes * sizeof(Uint8 *)); |
0 | 327 if ( !overlay->pitches || !overlay->pixels ) { |
328 SDL_OutOfMemory(); | |
329 SDL_FreeYUVOverlay(overlay); | |
330 return(NULL); | |
331 } | |
332 for ( i=0; i<overlay->planes; ++i ) { | |
333 overlay->pitches[i] = hwdata->image->pitches[i]; | |
334 overlay->pixels[i] = (Uint8 *)hwdata->image->data + | |
335 hwdata->image->offsets[i]; | |
336 } | |
337 | |
338 #ifdef XFREE86_REFRESH_HACK | |
339 /* Work around an XFree86 X server bug (?) | |
340 We can't perform normal updates in windows that have video | |
341 being output to them. See SDL_x11image.c for more details. | |
342 */ | |
343 X11_DisableAutoRefresh(this); | |
344 #endif | |
345 | |
346 /* We're all done.. */ | |
347 return(overlay); | |
348 } | |
349 | |
350 int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay) | |
351 { | |
352 return(0); | |
353 } | |
354 | |
355 void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) | |
356 { | |
357 return; | |
358 } | |
359 | |
360 int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect) | |
361 { | |
362 struct private_yuvhwdata *hwdata; | |
363 | |
364 hwdata = overlay->hwdata; | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
365 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
366 if ( hwdata->yuv_use_mitshm ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
367 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
0 | 368 hwdata->image, 0, 0, overlay->w, overlay->h, |
369 dstrect->x, dstrect->y, dstrect->w, dstrect->h, False); | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
370 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
371 else |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
372 #endif |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
373 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
374 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
375 hwdata->image, 0, 0, overlay->w, overlay->h, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
376 dstrect->x, dstrect->y, dstrect->w, dstrect->h); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
377 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
378 pXSync(GFX_Display, False); |
0 | 379 return(0); |
380 } | |
381 | |
382 void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) | |
383 { | |
384 struct private_yuvhwdata *hwdata; | |
385 | |
386 hwdata = overlay->hwdata; | |
387 if ( hwdata ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
388 SDL_NAME(XvUngrabPort)(GFX_Display, hwdata->port, CurrentTime); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
389 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
390 if ( hwdata->yuv_use_mitshm ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
391 pXShmDetach(GFX_Display, &hwdata->yuvshm); |
0 | 392 shmdt(hwdata->yuvshm.shmaddr); |
393 } | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
394 #endif |
0 | 395 if ( hwdata->image ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
396 pXFree(hwdata->image); |
0 | 397 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
398 SDL_free(hwdata); |
0 | 399 } |
400 if ( overlay->pitches ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
401 SDL_free(overlay->pitches); |
0 | 402 overlay->pitches = NULL; |
403 } | |
404 if ( overlay->pixels ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
405 SDL_free(overlay->pixels); |
0 | 406 overlay->pixels = NULL; |
407 } | |
408 #ifdef XFREE86_REFRESH_HACK | |
409 X11_EnableAutoRefresh(this); | |
410 #endif | |
411 } | |
412 | |
413 #endif /* XFREE86_XV */ |