comparison src/video/photon/SDL_phyuv.c @ 370:ba72f259bc88

Date: Sat, 18 May 2002 17:40:53 +0300 From: Mike Gorchak <mike@malva.ua> Subject: New QNX patches - Added more error check to avoid SEGFAULTS; - Fixed bug in update function for SDL_HWSURFACE. BTW: update is much faster than before. - Added checks for SDL_HWSURFACE flag, chosen bpp must be equal to desktop bpp for SDL_HWSURFACE. - Fixed overlay bug, no more SEGFAULTS.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 May 2002 19:54:01 +0000
parents f6ffac90895c
children bce7171e7a85
comparison
equal deleted inserted replaced
369:e405cf8bf580 370:ba72f259bc88
27 27
28 /* This is the QNX Realtime Platform version for SDL YUV video overlays */ 28 /* This is the QNX Realtime Platform version for SDL YUV video overlays */
29 29
30 #include <stdlib.h> 30 #include <stdlib.h>
31 #include <string.h> 31 #include <string.h>
32 //#include <ncurses.h> //only for bool
33 #ifndef bool 32 #ifndef bool
34 #define bool char 33 #define bool char
35 #define TRUE 1 34 #define TRUE 1
36 #define FALSE 0 35 #define FALSE 0
37 #endif 36 #endif
102 XvImage *image; 101 XvImage *image;
103 FRAMEDATA *CurrentFrameData; 102 FRAMEDATA *CurrentFrameData;
104 FRAMEDATA *FrameData0; 103 FRAMEDATA *FrameData0;
105 FRAMEDATA *FrameData1; 104 FRAMEDATA *FrameData1;
106 PgScalerProps_t props; 105 PgScalerProps_t props;
107 PgScalerCaps_t caps; 106 PgScalerCaps_t caps;
108 PgVideoChannel_t *channel; 107 PgVideoChannel_t *channel;
109 SDL_Rect CurrentWindow; 108 SDL_Rect CurrentWindow;
110 long format; 109 long format;
111 int screen_width; 110 int screen_width;
112 int screen_height ; 111 int screen_height ;
140 Frame0->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane1); 139 Frame0->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane1);
141 Frame1->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane2); 140 Frame1->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane2);
142 141
143 } 142 }
144 143
145 SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) 144 SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
146 { 145 {
147 SDL_Overlay *overlay; 146 SDL_Overlay *overlay;
148 struct private_yuvhwdata *hwdata; 147 struct private_yuvhwdata *hwdata;
149 int xv_port; 148 int xv_port;
150 int rtncode; 149 int rtncode;
160 int entries, select, highest; 159 int entries, select, highest;
161 160
162 PhDCSetCurrent(0); //Need to set draw context to window esp. if we we in Offscreeen mode 161 PhDCSetCurrent(0); //Need to set draw context to window esp. if we we in Offscreeen mode
163 162
164 /* Create the overlay structure */ 163 /* Create the overlay structure */
165 overlay = (SDL_Overlay *)malloc(sizeof *overlay); 164 overlay = (SDL_Overlay *)malloc(sizeof(SDL_Overlay));
165 memset(overlay, 0x00, sizeof(SDL_Overlay));
166 if ( overlay == NULL ) { 166 if ( overlay == NULL ) {
167 SDL_OutOfMemory(); 167 SDL_OutOfMemory();
168 return(NULL); 168 return(NULL);
169 } 169 }
170 memset(overlay, 0, (sizeof *overlay)); 170 memset(overlay, 0, (sizeof *overlay));
176 176
177 /* Set up the YUV surface function structure */ 177 /* Set up the YUV surface function structure */
178 overlay->hwfuncs = &ph_yuvfuncs; 178 overlay->hwfuncs = &ph_yuvfuncs;
179 179
180 /* Create the pixel data and lookup tables */ 180 /* Create the pixel data and lookup tables */
181 hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata); 181 hwdata = (struct private_yuvhwdata *)malloc(sizeof(struct private_yuvhwdata));
182 memset(hwdata, 0x00, sizeof(struct private_yuvhwdata));
182 overlay->hwdata = hwdata; 183 overlay->hwdata = hwdata;
183 if ( hwdata == NULL ) { 184 if ( hwdata == NULL ) {
184 SDL_OutOfMemory(); 185 SDL_OutOfMemory();
185 SDL_FreeYUVOverlay(overlay); 186 SDL_FreeYUVOverlay(overlay);
186 return(NULL); 187 return(NULL);
187 } 188 }
188 189
189 if (overlay->hwdata->channel == NULL) 190 if (overlay->hwdata->channel == NULL)
190 { 191 {
191 192 if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER,0)) == NULL)
192 193 {
193 if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER,0)) == NULL) 194 SDL_SetError("ph_CreateYUVOverlay(): Create channel failed: %s\n", strerror( errno ));
194 { 195 free(overlay->hwdata);
195 SDL_SetError("Create channel failed:%s\n", strerror( errno )); 196 free(overlay);
196 free(overlay->hwdata); 197 return (NULL);
197 free(overlay); 198 }
198 return(NULL); 199 }
199 } 200
200 #if 0 201 overlay->hwdata->CurrentWindow.x = 0;
201 overlay->hwdata->caps.size = sizeof (overlay->hwdata->caps); 202 overlay->hwdata->CurrentWindow.y = 0;
202 PgGetScalerCapabilities(overlay->hwdata->channel, 0, &(overlay->hwdata->caps)); 203 overlay->hwdata->CurrentWindow.w = 320;
203 if (overlay->hwdata->caps.flags & Pg_SCALER_CAP_DOUBLE_BUFFER) 204 overlay->hwdata->CurrentWindow.h = 240;
204 overlay->hwdata->props.flags |= Pg_SCALER_PROP_DOUBLE_BUFFER; 205
205 #endif 206 overlay->hwdata->State = OVERLAY_STATE_UNINIT;
206 } 207
207 208 overlay->hwdata->screen_bpp = 2;
208 overlay->hwdata->CurrentWindow.x = 0; 209 overlay->hwdata->scaler_on = FALSE;
209 overlay->hwdata->CurrentWindow.y = 0; 210 overlay->hwdata->screen_width = 1024;
210 overlay->hwdata->CurrentWindow.w = 320; 211 overlay->hwdata->screen_height = 768;
211 overlay->hwdata->CurrentWindow.h = 240; 212
212 213 overlay->hwdata->FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
213 214 overlay->hwdata->FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
214 215
215 overlay->hwdata->State = OVERLAY_STATE_UNINIT; 216 overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
216
217 overlay->hwdata->screen_bpp = 2;
218 overlay->hwdata->scaler_on = FALSE;
219
220 overlay->hwdata->screen_width = 1024;
221 overlay->hwdata->screen_height = 768;
222
223 overlay->hwdata->FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
224 overlay->hwdata->FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
225
226 overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
227
228 217
229 //Note you really don't need to do this for SDL as you are given a format, but this is a good example 218 //Note you really don't need to do this for SDL as you are given a format, but this is a good example
230 219
231 xv_port = -1; 220 xv_port = -1;
232 i=0; 221 i=0;
233 222
234 while(PgGetScalerCapabilities(overlay->hwdata->channel, i++, &(overlay->hwdata->caps)) == 0) 223 while(PgGetScalerCapabilities(overlay->hwdata->channel, i++, &(overlay->hwdata->caps)) == 0)
235 { 224 {
236
237 if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_YV12) //in SDL 225 if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_YV12) //in SDL
238 { 226 {
239 227
240 Priority[i-1] = 0; 228 Priority[i-1] = 0;
241 Type[i-1] = Pg_VIDEO_FORMAT_YV12; 229 Type[i-1] = Pg_VIDEO_FORMAT_YV12;