Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11yuv.c @ 1361:19418e4422cb
New configure-based build system. Still work in progress, but much improved
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 16 Feb 2006 10:11:48 +0000 |
parents | c71e05b4dc2e |
children | d910939febfa |
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 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
25 #include "SDL_config.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
26 |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
27 #if SDL_VIDEO_DRIVER_X11_XV |
0 | 28 |
29 #include <X11/Xlib.h> | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
30 #ifndef NO_SHARED_MEMORY |
0 | 31 #include <sys/ipc.h> |
32 #include <sys/shm.h> | |
33 #include <X11/extensions/XShm.h> | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
34 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
35 #include "../Xext/extensions/Xvlib.h" |
0 | 36 |
37 #include "SDL_x11yuv_c.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
38 #include "../SDL_yuvfuncs.h" |
0 | 39 |
40 #define XFREE86_REFRESH_HACK | |
41 #ifdef XFREE86_REFRESH_HACK | |
42 #include "SDL_x11image_c.h" | |
43 #endif | |
44 | |
45 /* Workaround when pitch != width */ | |
46 #define PITCH_WORKAROUND | |
47 | |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
48 /* 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
|
49 /*#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
|
50 |
0 | 51 /* The functions used to manipulate software video overlays */ |
52 static struct private_yuvhwfuncs x11_yuvfuncs = { | |
53 X11_LockYUVOverlay, | |
54 X11_UnlockYUVOverlay, | |
55 X11_DisplayYUVOverlay, | |
56 X11_FreeYUVOverlay | |
57 }; | |
58 | |
59 struct private_yuvhwdata { | |
60 int port; | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
61 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
62 int yuv_use_mitshm; |
0 | 63 XShmSegmentInfo yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
64 #endif |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
65 SDL_NAME(XvImage) *image; |
0 | 66 }; |
67 | |
68 | |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
69 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
|
70 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
71 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
72 /* Shared memory error handler routine */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
73 static int shm_error; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
74 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
|
75 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
76 if ( e->error_code == BadAccess ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
77 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
78 return(0); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
79 } else |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
80 return(X_handler(d,e)); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
81 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
82 #endif /* !NO_SHARED_MEMORY */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
83 |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
84 static int xv_error; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
85 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
|
86 { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
87 if ( e->error_code == BadMatch ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
88 xv_error = True; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
89 return(0); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
90 } else |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
91 return(X_handler(d,e)); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
92 } |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
93 |
0 | 94 SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) |
95 { | |
96 SDL_Overlay *overlay; | |
97 struct private_yuvhwdata *hwdata; | |
98 int xv_port; | |
1196
b81f54c3963f
Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
99 unsigned int i, j, k; |
b81f54c3963f
Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
100 unsigned int adaptors; |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
101 SDL_NAME(XvAdaptorInfo) *ainfo; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
102 int bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
103 #ifndef NO_SHARED_MEMORY |
0 | 104 XShmSegmentInfo *yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
105 #endif |
0 | 106 |
107 /* Look for the XVideo extension with a valid port for this format */ | |
108 xv_port = -1; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
109 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
|
110 (Success == SDL_NAME(XvQueryAdaptors)(GFX_Display, |
0 | 111 RootWindow(GFX_Display, SDL_Screen), |
112 &adaptors, &ainfo)) ) { | |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
113 #ifdef USE_LAST_ADAPTOR |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
114 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
|
115 #else |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
116 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
|
117 #endif /* USE_LAST_ADAPTOR */ |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
118 { |
0 | 119 /* Check to see if the visual can be used */ |
120 if ( BUGGY_XFREE86(<=, 4001) ) { | |
121 int visual_ok = 0; | |
122 for ( j=0; j<ainfo[i].num_formats; ++j ) { | |
123 if ( ainfo[i].formats[j].visual_id == | |
124 SDL_Visual->visualid ) { | |
125 visual_ok = 1; | |
126 break; | |
127 } | |
128 } | |
129 if ( ! visual_ok ) { | |
130 continue; | |
131 } | |
132 } | |
133 if ( (ainfo[i].type & XvInputMask) && | |
134 (ainfo[i].type & XvImageMask) ) { | |
135 int num_formats; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
136 SDL_NAME(XvImageFormatValues) *formats; |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
137 formats = SDL_NAME(XvListImageFormats)(GFX_Display, |
0 | 138 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
|
139 #ifdef USE_LAST_ADAPTOR |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
140 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
|
141 #else |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
142 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
|
143 #endif /* USE_LAST_ADAPTOR */ |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
144 { |
0 | 145 if ( (Uint32)formats[j].id == format ) { |
146 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
|
147 if ( Success == SDL_NAME(XvGrabPort)(GFX_Display, ainfo[i].base_id+k, CurrentTime) ) { |
0 | 148 xv_port = ainfo[i].base_id+k; |
149 break; | |
150 } | |
151 } | |
152 } | |
153 } | |
410
365f57b7c4ac
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
409
diff
changeset
|
154 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
|
155 pXFree(formats); |
410
365f57b7c4ac
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
409
diff
changeset
|
156 } |
0 | 157 } |
158 } | |
409
1c3cf7231cd4
Fixed memory leaks in YUV code
Sam Lantinga <slouken@libsdl.org>
parents:
341
diff
changeset
|
159 SDL_NAME(XvFreeAdaptorInfo)(ainfo); |
0 | 160 } |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
161 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
162 /* 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
|
163 switch (format) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
164 /* 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
|
165 case SDL_YUY2_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
166 case SDL_UYVY_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
167 case SDL_YVYU_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
168 bpp = 2; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
169 break; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
170 default: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
171 bpp = 1; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
172 break; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
173 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
174 |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
175 #if 0 |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
176 /* |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
177 * !!! FIXME: |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
178 * "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
|
179 * 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
|
180 * 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
|
181 * |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
182 * 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
|
183 * 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
|
184 * more closely... --ryan. |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
185 */ |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
186 for ( i=0; i < adaptors; ++i ) { |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
187 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
|
188 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
|
189 } |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
190 Xfree(ainfo); |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
191 #endif |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
192 |
0 | 193 if ( xv_port == -1 ) { |
194 SDL_SetError("No available video ports for requested format"); | |
195 return(NULL); | |
196 } | |
197 | |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
198 /* 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
|
199 { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
200 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
|
201 unsigned int i; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
202 |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
203 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
|
204 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
|
205 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
|
206 Atom a; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
207 |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
208 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
|
209 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
|
210 if ( a != None ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
211 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
|
212 pXSync(GFX_Display, True); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
213 if ( ! xv_error ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
214 break; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
215 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
216 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
217 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
218 pXSetErrorHandler(X_handler); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
219 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
|
220 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
221 |
0 | 222 /* Create the overlay structure */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
223 overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); |
0 | 224 if ( overlay == NULL ) { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
225 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); |
0 | 226 SDL_OutOfMemory(); |
227 return(NULL); | |
228 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
229 SDL_memset(overlay, 0, (sizeof *overlay)); |
0 | 230 |
231 /* Fill in the basic members */ | |
232 overlay->format = format; | |
233 overlay->w = width; | |
234 overlay->h = height; | |
235 | |
236 /* Set up the YUV surface function structure */ | |
237 overlay->hwfuncs = &x11_yuvfuncs; | |
238 overlay->hw_overlay = 1; | |
239 | |
240 /* 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
|
241 hwdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *hwdata); |
0 | 242 overlay->hwdata = hwdata; |
243 if ( hwdata == NULL ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
244 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); |
0 | 245 SDL_OutOfMemory(); |
246 SDL_FreeYUVOverlay(overlay); | |
247 return(NULL); | |
248 } | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
249 hwdata->port = xv_port; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
250 #ifndef NO_SHARED_MEMORY |
0 | 251 yuvshm = &hwdata->yuvshm; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
252 SDL_memset(yuvshm, 0, sizeof(*yuvshm)); |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
253 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
|
254 0, width, height, yuvshm); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
255 #ifdef PITCH_WORKAROUND |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
256 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
|
257 /* 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
|
258 pXFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
259 width = hwdata->image->pitches[0] / bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
260 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
|
261 0, width, height, yuvshm); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
262 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
263 #endif /* PITCH_WORKAROUND */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
264 hwdata->yuv_use_mitshm = (hwdata->image != NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
265 if ( hwdata->yuv_use_mitshm ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
266 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
|
267 IPC_CREAT | 0777); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
268 if ( yuvshm->shmid >= 0 ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
269 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
|
270 yuvshm->readOnly = False; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
271 if ( yuvshm->shmaddr != (char *)-1 ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
272 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
|
273 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
|
274 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
|
275 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
|
276 pXSetErrorHandler(X_handler); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
277 if ( shm_error ) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
278 shmdt(yuvshm->shmaddr); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
279 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
280 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
281 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
282 shmctl(yuvshm->shmid, IPC_RMID, NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
283 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
284 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
285 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
286 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
|
287 pXFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
288 hwdata->yuv_use_mitshm = 0; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
289 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
290 hwdata->image->data = yuvshm->shmaddr; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
291 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
292 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
293 if ( !hwdata->yuv_use_mitshm ) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
294 #endif /* NO_SHARED_MEMORY */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
295 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
296 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
|
297 0, width, height); |
0 | 298 |
299 #ifdef PITCH_WORKAROUND | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
300 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
|
301 /* 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
|
302 pXFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
303 width = hwdata->image->pitches[0] / bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
304 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
|
305 0, width, height); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
306 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
307 #endif /* PITCH_WORKAROUND */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
308 if ( hwdata->image == NULL ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
309 SDL_SetError("Couldn't create XVideo image"); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
310 SDL_FreeYUVOverlay(overlay); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
311 return(NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
312 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
313 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
|
314 if ( hwdata->image->data == NULL ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
315 SDL_OutOfMemory(); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
316 SDL_FreeYUVOverlay(overlay); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
317 return(NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
318 } |
0 | 319 } |
320 | |
321 /* Find the pitch and offset values for the overlay */ | |
322 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
|
323 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
|
324 overlay->pixels = (Uint8 **)SDL_malloc(overlay->planes * sizeof(Uint8 *)); |
0 | 325 if ( !overlay->pitches || !overlay->pixels ) { |
326 SDL_OutOfMemory(); | |
327 SDL_FreeYUVOverlay(overlay); | |
328 return(NULL); | |
329 } | |
330 for ( i=0; i<overlay->planes; ++i ) { | |
331 overlay->pitches[i] = hwdata->image->pitches[i]; | |
332 overlay->pixels[i] = (Uint8 *)hwdata->image->data + | |
333 hwdata->image->offsets[i]; | |
334 } | |
335 | |
336 #ifdef XFREE86_REFRESH_HACK | |
337 /* Work around an XFree86 X server bug (?) | |
338 We can't perform normal updates in windows that have video | |
339 being output to them. See SDL_x11image.c for more details. | |
340 */ | |
341 X11_DisableAutoRefresh(this); | |
342 #endif | |
343 | |
344 /* We're all done.. */ | |
345 return(overlay); | |
346 } | |
347 | |
348 int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay) | |
349 { | |
350 return(0); | |
351 } | |
352 | |
353 void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) | |
354 { | |
355 return; | |
356 } | |
357 | |
358 int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect) | |
359 { | |
360 struct private_yuvhwdata *hwdata; | |
361 | |
362 hwdata = overlay->hwdata; | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
363 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
364 if ( hwdata->yuv_use_mitshm ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
365 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
0 | 366 hwdata->image, 0, 0, overlay->w, overlay->h, |
367 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
|
368 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
369 else |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
370 #endif |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
371 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
372 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
|
373 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
|
374 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
|
375 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
950
diff
changeset
|
376 pXSync(GFX_Display, False); |
0 | 377 return(0); |
378 } | |
379 | |
380 void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) | |
381 { | |
382 struct private_yuvhwdata *hwdata; | |
383 | |
384 hwdata = overlay->hwdata; | |
385 if ( hwdata ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
386 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
|
387 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
388 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
|
389 pXShmDetach(GFX_Display, &hwdata->yuvshm); |
0 | 390 shmdt(hwdata->yuvshm.shmaddr); |
391 } | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
392 #endif |
0 | 393 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
|
394 pXFree(hwdata->image); |
0 | 395 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
396 SDL_free(hwdata); |
0 | 397 } |
398 if ( overlay->pitches ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
399 SDL_free(overlay->pitches); |
0 | 400 overlay->pitches = NULL; |
401 } | |
402 if ( overlay->pixels ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
403 SDL_free(overlay->pixels); |
0 | 404 overlay->pixels = NULL; |
405 } | |
406 #ifdef XFREE86_REFRESH_HACK | |
407 X11_EnableAutoRefresh(this); | |
408 #endif | |
409 } | |
410 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
411 #endif /* SDL_VIDEO_DRIVER_X11_XV */ |