comparison src/video/photon/SDL_phyuv.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents 51038e80ae59
children e27bdcc80744 204be4fc2726
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
34 34
35 #define OVERLAY_STATE_UNINIT 0 35 #define OVERLAY_STATE_UNINIT 0
36 #define OVERLAY_STATE_ACTIVE 1 36 #define OVERLAY_STATE_ACTIVE 1
37 37
38 /* The functions are used to manipulate software video overlays */ 38 /* The functions are used to manipulate software video overlays */
39 static struct private_yuvhwfuncs ph_yuvfuncs = 39 static struct private_yuvhwfuncs ph_yuvfuncs = {
40 {
41 ph_LockYUVOverlay, 40 ph_LockYUVOverlay,
42 ph_UnlockYUVOverlay, 41 ph_UnlockYUVOverlay,
43 ph_DisplayYUVOverlay, 42 ph_DisplayYUVOverlay,
44 ph_FreeYUVOverlay 43 ph_FreeYUVOverlay
45 }; 44 };
46 45
47 int grab_ptrs2(PgVideoChannel_t* channel, FRAMEDATA* Frame0, FRAMEDATA* Frame1) 46 int
47 grab_ptrs2(PgVideoChannel_t * channel, FRAMEDATA * Frame0, FRAMEDATA * Frame1)
48 { 48 {
49 int planes = 0; 49 int planes = 0;
50 50
51 /* Buffers have moved; re-obtain the pointers */ 51 /* Buffers have moved; re-obtain the pointers */
52 Frame0->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane1); 52 Frame0->Y = (unsigned char *) PdGetOffscreenContextPtr(channel->yplane1);
53 Frame1->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane2); 53 Frame1->Y = (unsigned char *) PdGetOffscreenContextPtr(channel->yplane2);
54 Frame0->U = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane1); 54 Frame0->U = (unsigned char *) PdGetOffscreenContextPtr(channel->vplane1);
55 Frame1->U = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane2); 55 Frame1->U = (unsigned char *) PdGetOffscreenContextPtr(channel->vplane2);
56 Frame0->V = (unsigned char *)PdGetOffscreenContextPtr(channel->uplane1); 56 Frame0->V = (unsigned char *) PdGetOffscreenContextPtr(channel->uplane1);
57 Frame1->V = (unsigned char *)PdGetOffscreenContextPtr(channel->uplane2); 57 Frame1->V = (unsigned char *) PdGetOffscreenContextPtr(channel->uplane2);
58 58
59 if (Frame0->Y) 59 if (Frame0->Y)
60 planes++; 60 planes++;
61 61
62 if (Frame0->U) 62 if (Frame0->U)
66 planes++; 66 planes++;
67 67
68 return planes; 68 return planes;
69 } 69 }
70 70
71 SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface* display) 71 SDL_Overlay *
72 ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format,
73 SDL_Surface * display)
72 { 74 {
73 SDL_Overlay* overlay; 75 SDL_Overlay *overlay;
74 struct private_yuvhwdata* hwdata; 76 struct private_yuvhwdata *hwdata;
75 int vidport; 77 int vidport;
76 int rtncode; 78 int rtncode;
77 int planes; 79 int planes;
78 int i=0; 80 int i = 0;
79 PhPoint_t pos; 81 PhPoint_t pos;
80 82
81 /* Create the overlay structure */ 83 /* Create the overlay structure */
82 overlay = SDL_calloc(1, sizeof(SDL_Overlay)); 84 overlay = SDL_calloc(1, sizeof(SDL_Overlay));
83 85
84 if (overlay == NULL) 86 if (overlay == NULL) {
85 {
86 SDL_OutOfMemory(); 87 SDL_OutOfMemory();
87 return NULL; 88 return NULL;
88 } 89 }
89 90
90 /* Fill in the basic members */ 91 /* Fill in the basic members */
91 overlay->format = format; 92 overlay->format = format;
92 overlay->w = width; 93 overlay->w = width;
93 overlay->h = height; 94 overlay->h = height;
94 overlay->hwdata = NULL; 95 overlay->hwdata = NULL;
95 96
96 /* Set up the YUV surface function structure */ 97 /* Set up the YUV surface function structure */
97 overlay->hwfuncs = &ph_yuvfuncs; 98 overlay->hwfuncs = &ph_yuvfuncs;
98 99
99 /* Create the pixel data and lookup tables */ 100 /* Create the pixel data and lookup tables */
100 hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata)); 101 hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata));
101 102
102 if (hwdata == NULL) 103 if (hwdata == NULL) {
103 {
104 SDL_OutOfMemory(); 104 SDL_OutOfMemory();
105 SDL_FreeYUVOverlay(overlay); 105 SDL_FreeYUVOverlay(overlay);
106 return NULL; 106 return NULL;
107 } 107 }
108 108
109 overlay->hwdata = hwdata; 109 overlay->hwdata = hwdata;
110 110
111 PhDCSetCurrent(0); 111 PhDCSetCurrent(0);
112 if (overlay->hwdata->channel == NULL) 112 if (overlay->hwdata->channel == NULL) {
113 { 113 if ((overlay->hwdata->channel =
114 if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER, 0)) == NULL) 114 PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER, 0)) == NULL) {
115 { 115 SDL_SetError
116 SDL_SetError("ph_CreateYUVOverlay(): Create channel failed: %s\n", strerror(errno)); 116 ("ph_CreateYUVOverlay(): Create channel failed: %s\n",
117 strerror(errno));
117 SDL_FreeYUVOverlay(overlay); 118 SDL_FreeYUVOverlay(overlay);
118 return NULL; 119 return NULL;
119 120
120 } 121 }
121 } 122 }
122 123
123 overlay->hwdata->forcedredraw=0; 124 overlay->hwdata->forcedredraw = 0;
124 125
125 PtGetAbsPosition(window, &pos.x, &pos.y); 126 PtGetAbsPosition(window, &pos.x, &pos.y);
126 overlay->hwdata->CurrentWindowPos.x = pos.x; 127 overlay->hwdata->CurrentWindowPos.x = pos.x;
127 overlay->hwdata->CurrentWindowPos.y = pos.y; 128 overlay->hwdata->CurrentWindowPos.y = pos.y;
128 overlay->hwdata->CurrentViewPort.pos.x = 0; 129 overlay->hwdata->CurrentViewPort.pos.x = 0;
129 overlay->hwdata->CurrentViewPort.pos.y = 0; 130 overlay->hwdata->CurrentViewPort.pos.y = 0;
130 overlay->hwdata->CurrentViewPort.size.w = width; 131 overlay->hwdata->CurrentViewPort.size.w = width;
131 overlay->hwdata->CurrentViewPort.size.h = height; 132 overlay->hwdata->CurrentViewPort.size.h = height;
132 overlay->hwdata->State = OVERLAY_STATE_UNINIT; 133 overlay->hwdata->State = OVERLAY_STATE_UNINIT;
133 overlay->hwdata->FrameData0 = (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA)); 134 overlay->hwdata->FrameData0 =
134 overlay->hwdata->FrameData1 = (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA)); 135 (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA));
136 overlay->hwdata->FrameData1 =
137 (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA));
135 138
136 vidport = -1; 139 vidport = -1;
137 i=0; 140 i = 0;
138 141
139 overlay->hwdata->ischromakey=0; 142 overlay->hwdata->ischromakey = 0;
140 143
141 do { 144 do {
142 SDL_memset(&overlay->hwdata->caps, 0x00, sizeof(PgScalerCaps_t)); 145 SDL_memset(&overlay->hwdata->caps, 0x00, sizeof(PgScalerCaps_t));
143 overlay->hwdata->caps.size = sizeof(PgScalerCaps_t); 146 overlay->hwdata->caps.size = sizeof(PgScalerCaps_t);
144 rtncode = PgGetScalerCapabilities(overlay->hwdata->channel, i, &overlay->hwdata->caps); 147 rtncode =
145 if (rtncode==0) 148 PgGetScalerCapabilities(overlay->hwdata->channel, i,
146 { 149 &overlay->hwdata->caps);
147 if (overlay->hwdata->caps.format==format) 150 if (rtncode == 0) {
148 { 151 if (overlay->hwdata->caps.format == format) {
149 if ((overlay->hwdata->caps.flags & Pg_SCALER_CAP_DST_CHROMA_KEY) == Pg_SCALER_CAP_DST_CHROMA_KEY) 152 if ((overlay->hwdata->caps.
150 { 153 flags & Pg_SCALER_CAP_DST_CHROMA_KEY) ==
151 overlay->hwdata->ischromakey=1; 154 Pg_SCALER_CAP_DST_CHROMA_KEY) {
152 } 155 overlay->hwdata->ischromakey = 1;
153 vidport=1; 156 }
154 break; 157 vidport = 1;
158 break;
155 } 159 }
156 } 160 } else {
157 else 161 break;
158 {
159 break;
160 } 162 }
161 i++; 163 i++;
162 } while(1); 164 }
163 165 while (1);
164 166
165 if (vidport == -1) 167
166 { 168 if (vidport == -1) {
167 SDL_SetError("No available video ports for requested format\n"); 169 SDL_SetError("No available video ports for requested format\n");
168 SDL_FreeYUVOverlay(overlay); 170 SDL_FreeYUVOverlay(overlay);
169 return NULL; 171 return NULL;
170 } 172 }
171 173
174 overlay->hwdata->props.size = sizeof(PgScalerProps_t); 176 overlay->hwdata->props.size = sizeof(PgScalerProps_t);
175 overlay->hwdata->props.src_dim.w = width; 177 overlay->hwdata->props.src_dim.w = width;
176 overlay->hwdata->props.src_dim.h = height; 178 overlay->hwdata->props.src_dim.h = height;
177 179
178 /* overlay->hwdata->chromakey = PgGetOverlayChromaColor(); */ 180 /* overlay->hwdata->chromakey = PgGetOverlayChromaColor(); */
179 overlay->hwdata->chromakey = PgRGB(12, 6, 12); /* very dark pink color */ 181 overlay->hwdata->chromakey = PgRGB(12, 6, 12); /* very dark pink color */
180 overlay->hwdata->props.color_key = overlay->hwdata->chromakey; 182 overlay->hwdata->props.color_key = overlay->hwdata->chromakey;
181 183
182 PhAreaToRect(&overlay->hwdata->CurrentViewPort, &overlay->hwdata->props.viewport); 184 PhAreaToRect(&overlay->hwdata->CurrentViewPort,
185 &overlay->hwdata->props.viewport);
183 186
184 overlay->hwdata->props.flags = Pg_SCALER_PROP_DOUBLE_BUFFER; 187 overlay->hwdata->props.flags = Pg_SCALER_PROP_DOUBLE_BUFFER;
185 188
186 if ((overlay->hwdata->ischromakey)&&(overlay->hwdata->chromakey)) 189 if ((overlay->hwdata->ischromakey) && (overlay->hwdata->chromakey)) {
187 {
188 overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE; 190 overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE;
189 overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_SPECIFY_KEY_MASK; 191 overlay->hwdata->props.flags |=
190 } 192 Pg_SCALER_PROP_CHROMA_SPECIFY_KEY_MASK;
191 else 193 } else {
192 {
193 overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE; 194 overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE;
194 } 195 }
195 196
196 rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &overlay->hwdata->props); 197 rtncode =
197 198 PgConfigScalerChannel(overlay->hwdata->channel,
198 switch(rtncode) 199 &overlay->hwdata->props);
199 { 200
200 case -1: SDL_SetError("PgConfigScalerChannel failed\n"); 201 switch (rtncode) {
201 SDL_FreeYUVOverlay(overlay); 202 case -1:
202 return NULL; 203 SDL_SetError("PgConfigScalerChannel failed\n");
203 case 1: 204 SDL_FreeYUVOverlay(overlay);
204 case 0: 205 return NULL;
205 default: 206 case 1:
206 break; 207 case 0:
207 } 208 default:
208 209 break;
209 planes = grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1); 210 }
210 211
211 if(overlay->hwdata->channel->yplane1 != NULL) 212 planes =
213 grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0,
214 overlay->hwdata->FrameData1);
215
216 if (overlay->hwdata->channel->yplane1 != NULL)
212 overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch; 217 overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch;
213 if(overlay->hwdata->channel->vplane1 != NULL) 218 if (overlay->hwdata->channel->vplane1 != NULL)
214 overlay->hwdata->UStride = overlay->hwdata->channel->vplane1->pitch; 219 overlay->hwdata->UStride = overlay->hwdata->channel->vplane1->pitch;
215 if(overlay->hwdata->channel->uplane1 != NULL) 220 if (overlay->hwdata->channel->uplane1 != NULL)
216 overlay->hwdata->VStride = overlay->hwdata->channel->uplane1->pitch; 221 overlay->hwdata->VStride = overlay->hwdata->channel->uplane1->pitch;
217 222
218 /* check for the validness of all planes */ 223 /* check for the validness of all planes */
219 if ((overlay->hwdata->channel->yplane1 == NULL) && 224 if ((overlay->hwdata->channel->yplane1 == NULL) &&
220 (overlay->hwdata->channel->uplane1 == NULL) && 225 (overlay->hwdata->channel->uplane1 == NULL) &&
221 (overlay->hwdata->channel->vplane1 == NULL)) 226 (overlay->hwdata->channel->vplane1 == NULL)) {
222 { 227 SDL_FreeYUVOverlay(overlay);
223 SDL_FreeYUVOverlay(overlay); 228 SDL_SetError("PgConfigScaler() returns all planes equal NULL\n");
224 SDL_SetError("PgConfigScaler() returns all planes equal NULL\n"); 229 return NULL;
225 return NULL;
226 } 230 }
227 /* 231 /*
228 overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel); 232 overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
229 233
230 if (overlay->hwdata->current==0) 234 if (overlay->hwdata->current==0)
243 */ 247 */
244 248
245 /* Find the pitch and offset values for the overlay */ 249 /* Find the pitch and offset values for the overlay */
246 overlay->planes = planes; 250 overlay->planes = planes;
247 overlay->pitches = SDL_calloc(overlay->planes, sizeof(Uint16)); 251 overlay->pitches = SDL_calloc(overlay->planes, sizeof(Uint16));
248 overlay->pixels = SDL_calloc(overlay->planes, sizeof(Uint8*)); 252 overlay->pixels = SDL_calloc(overlay->planes, sizeof(Uint8 *));
249 if (!overlay->pitches || !overlay->pixels) 253 if (!overlay->pitches || !overlay->pixels) {
250 {
251 SDL_OutOfMemory(); 254 SDL_OutOfMemory();
252 SDL_FreeYUVOverlay(overlay); 255 SDL_FreeYUVOverlay(overlay);
253 return(NULL); 256 return (NULL);
254 } 257 }
255 258
256 if (overlay->planes > 0) 259 if (overlay->planes > 0) {
257 {
258 overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch; 260 overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch;
259 overlay->pixels[0] = overlay->hwdata->CurrentFrameData->Y; 261 overlay->pixels[0] = overlay->hwdata->CurrentFrameData->Y;
260 } 262 }
261 if (overlay->planes > 1) 263 if (overlay->planes > 1) {
262 {
263 overlay->pitches[1] = overlay->hwdata->channel->vplane1->pitch; 264 overlay->pitches[1] = overlay->hwdata->channel->vplane1->pitch;
264 overlay->pixels[1] = overlay->hwdata->CurrentFrameData->U; 265 overlay->pixels[1] = overlay->hwdata->CurrentFrameData->U;
265 } 266 }
266 if (overlay->planes > 2) 267 if (overlay->planes > 2) {
267 {
268 overlay->pitches[2] = overlay->hwdata->channel->uplane1->pitch; 268 overlay->pitches[2] = overlay->hwdata->channel->uplane1->pitch;
269 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V; 269 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V;
270 } 270 }
271 271
272 overlay->hwdata->State = OVERLAY_STATE_ACTIVE; 272 overlay->hwdata->State = OVERLAY_STATE_ACTIVE;
273 overlay->hwdata->scaler_on = 0; 273 overlay->hwdata->scaler_on = 0;
274 overlay->hw_overlay = 1; 274 overlay->hw_overlay = 1;
275 275
276 current_overlay=overlay; 276 current_overlay = overlay;
277 277
278 return overlay; 278 return overlay;
279 } 279 }
280 280
281 int ph_LockYUVOverlay(_THIS, SDL_Overlay* overlay) 281 int
282 ph_LockYUVOverlay(_THIS, SDL_Overlay * overlay)
282 { 283 {
283 if (overlay == NULL) 284 if (overlay == NULL) {
284 {
285 return -1; 285 return -1;
286 } 286 }
287 287
288 overlay->hwdata->locked = 1; 288 overlay->hwdata->locked = 1;
289 289
319 overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch; 319 overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch;
320 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V; 320 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V;
321 } 321 }
322 */ 322 */
323 323
324 return(0); 324 return (0);
325 } 325 }
326 326
327 void ph_UnlockYUVOverlay(_THIS, SDL_Overlay* overlay) 327 void
328 ph_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay)
328 { 329 {
329 if (overlay == NULL) 330 if (overlay == NULL) {
330 {
331 return; 331 return;
332 } 332 }
333 333
334 overlay->hwdata->locked = 0; 334 overlay->hwdata->locked = 0;
335 } 335 }
336 336
337 int ph_DisplayYUVOverlay(_THIS, SDL_Overlay* overlay, SDL_Rect* src, SDL_Rect* dst) 337 int
338 ph_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src,
339 SDL_Rect * dst)
338 { 340 {
339 int rtncode; 341 int rtncode;
340 PhPoint_t pos; 342 PhPoint_t pos;
341 SDL_Rect backrect; 343 SDL_Rect backrect;
342 PhRect_t windowextent; 344 PhRect_t windowextent;
343 int winchanged=0; 345 int winchanged = 0;
344 346
345 if ((overlay == NULL) || (overlay->hwdata==NULL)) 347 if ((overlay == NULL) || (overlay->hwdata == NULL)) {
346 {
347 return -1; 348 return -1;
348 } 349 }
349 350
350 if (overlay->hwdata->State == OVERLAY_STATE_UNINIT) 351 if (overlay->hwdata->State == OVERLAY_STATE_UNINIT) {
351 {
352 return -1; 352 return -1;
353 } 353 }
354 354
355 PtGetAbsPosition(window, &pos.x, &pos.y); 355 PtGetAbsPosition(window, &pos.x, &pos.y);
356 if ((pos.x!=overlay->hwdata->CurrentWindowPos.x) || 356 if ((pos.x != overlay->hwdata->CurrentWindowPos.x) ||
357 (pos.y!=overlay->hwdata->CurrentWindowPos.y)) 357 (pos.y != overlay->hwdata->CurrentWindowPos.y)) {
358 { 358 winchanged = 1;
359 winchanged=1; 359 overlay->hwdata->CurrentWindowPos.x = pos.x;
360 overlay->hwdata->CurrentWindowPos.x=pos.x; 360 overlay->hwdata->CurrentWindowPos.y = pos.y;
361 overlay->hwdata->CurrentWindowPos.y=pos.y;
362 } 361 }
363 362
364 /* If CurrentViewPort position/size has been changed, then move/resize the viewport */ 363 /* If CurrentViewPort position/size has been changed, then move/resize the viewport */
365 if ((overlay->hwdata->CurrentViewPort.pos.x != dst->x) || 364 if ((overlay->hwdata->CurrentViewPort.pos.x != dst->x) ||
366 (overlay->hwdata->CurrentViewPort.pos.y != dst->y) || 365 (overlay->hwdata->CurrentViewPort.pos.y != dst->y) ||
367 (overlay->hwdata->CurrentViewPort.size.w != dst->w) || 366 (overlay->hwdata->CurrentViewPort.size.w != dst->w) ||
368 (overlay->hwdata->CurrentViewPort.size.h != dst->h) || 367 (overlay->hwdata->CurrentViewPort.size.h != dst->h) ||
369 (overlay->hwdata->scaler_on==0) || (winchanged==1) || 368 (overlay->hwdata->scaler_on == 0) || (winchanged == 1) ||
370 (overlay->hwdata->forcedredraw==1)) 369 (overlay->hwdata->forcedredraw == 1)) {
371 { 370
372 371 if (overlay->hwdata->ischromakey == 1) {
373 if (overlay->hwdata->ischromakey==1)
374 {
375 /* restore screen behind the overlay/chroma color. */ 372 /* restore screen behind the overlay/chroma color. */
376 backrect.x=overlay->hwdata->CurrentViewPort.pos.x; 373 backrect.x = overlay->hwdata->CurrentViewPort.pos.x;
377 backrect.y=overlay->hwdata->CurrentViewPort.pos.y; 374 backrect.y = overlay->hwdata->CurrentViewPort.pos.y;
378 backrect.w=overlay->hwdata->CurrentViewPort.size.w; 375 backrect.w = overlay->hwdata->CurrentViewPort.size.w;
379 backrect.h=overlay->hwdata->CurrentViewPort.size.h; 376 backrect.h = overlay->hwdata->CurrentViewPort.size.h;
380 this->UpdateRects(this, 1, &backrect); 377 this->UpdateRects(this, 1, &backrect);
381 378
382 /* Draw the new rectangle of the chroma color at the viewport position */ 379 /* Draw the new rectangle of the chroma color at the viewport position */
383 PgSetFillColor(overlay->hwdata->chromakey); 380 PgSetFillColor(overlay->hwdata->chromakey);
384 PgDrawIRect(dst->x, dst->y, dst->x+dst->w-1, dst->y+dst->h-1, Pg_DRAW_FILL); 381 PgDrawIRect(dst->x, dst->y, dst->x + dst->w - 1,
382 dst->y + dst->h - 1, Pg_DRAW_FILL);
385 PgFlush(); 383 PgFlush();
386 } 384 }
387 385
388 overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE; 386 overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE;
389 overlay->hwdata->scaler_on = 1; 387 overlay->hwdata->scaler_on = 1;
390 388
391 PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, PtWidgetRid(window), &windowextent); 389 PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, PtWidgetRid(window),
392 overlay->hwdata->CurrentViewPort.pos.x = pos.x-windowextent.ul.x+dst->x; 390 &windowextent);
393 overlay->hwdata->CurrentViewPort.pos.y = pos.y-windowextent.ul.y+dst->y; 391 overlay->hwdata->CurrentViewPort.pos.x =
392 pos.x - windowextent.ul.x + dst->x;
393 overlay->hwdata->CurrentViewPort.pos.y =
394 pos.y - windowextent.ul.y + dst->y;
394 overlay->hwdata->CurrentViewPort.size.w = dst->w; 395 overlay->hwdata->CurrentViewPort.size.w = dst->w;
395 overlay->hwdata->CurrentViewPort.size.h = dst->h; 396 overlay->hwdata->CurrentViewPort.size.h = dst->h;
396 PhAreaToRect(&overlay->hwdata->CurrentViewPort, &overlay->hwdata->props.viewport); 397 PhAreaToRect(&overlay->hwdata->CurrentViewPort,
398 &overlay->hwdata->props.viewport);
397 overlay->hwdata->CurrentViewPort.pos.x = dst->x; 399 overlay->hwdata->CurrentViewPort.pos.x = dst->x;
398 overlay->hwdata->CurrentViewPort.pos.y = dst->y; 400 overlay->hwdata->CurrentViewPort.pos.y = dst->y;
399 401
400 rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props)); 402 rtncode =
401 403 PgConfigScalerChannel(overlay->hwdata->channel,
402 switch(rtncode) 404 &(overlay->hwdata->props));
403 { 405
404 case -1: 406 switch (rtncode) {
405 SDL_SetError("PgConfigScalerChannel() function failed\n"); 407 case -1:
406 SDL_FreeYUVOverlay(overlay); 408 SDL_SetError("PgConfigScalerChannel() function failed\n");
407 return -1; 409 SDL_FreeYUVOverlay(overlay);
408 case 1: 410 return -1;
409 grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1); 411 case 1:
410 break; 412 grab_ptrs2(overlay->hwdata->channel,
411 case 0: 413 overlay->hwdata->FrameData0,
412 default: 414 overlay->hwdata->FrameData1);
413 break; 415 break;
416 case 0:
417 default:
418 break;
414 } 419 }
415 } 420 }
416 421
417 422
418 /* 423 /*
450 overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch; 455 overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch;
451 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V; 456 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V;
452 } 457 }
453 } 458 }
454 */ 459 */
455 460
456 return 0; 461 return 0;
457 } 462 }
458 463
459 void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) 464 void
465 ph_FreeYUVOverlay(_THIS, SDL_Overlay * overlay)
460 { 466 {
461 SDL_Rect backrect; 467 SDL_Rect backrect;
462 468
463 if (overlay == NULL) 469 if (overlay == NULL) {
464 {
465 return; 470 return;
466 } 471 }
467 472
468 if (overlay->hwdata == NULL) 473 if (overlay->hwdata == NULL) {
469 {
470 return; 474 return;
471 } 475 }
472 476
473 current_overlay=NULL; 477 current_overlay = NULL;
474 478
475 /* restore screen behind the overlay/chroma color. */ 479 /* restore screen behind the overlay/chroma color. */
476 backrect.x=overlay->hwdata->CurrentViewPort.pos.x; 480 backrect.x = overlay->hwdata->CurrentViewPort.pos.x;
477 backrect.y=overlay->hwdata->CurrentViewPort.pos.y; 481 backrect.y = overlay->hwdata->CurrentViewPort.pos.y;
478 backrect.w=overlay->hwdata->CurrentViewPort.size.w; 482 backrect.w = overlay->hwdata->CurrentViewPort.size.w;
479 backrect.h=overlay->hwdata->CurrentViewPort.size.h; 483 backrect.h = overlay->hwdata->CurrentViewPort.size.h;
480 this->UpdateRects(this, 1, &backrect); 484 this->UpdateRects(this, 1, &backrect);
481 485
482 /* it is need for some buggy drivers, that can't hide overlay before */ 486 /* it is need for some buggy drivers, that can't hide overlay before */
483 /* freeing buffer, so we got trash on the srceen */ 487 /* freeing buffer, so we got trash on the srceen */
484 overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_SCALER_ENABLE; 488 overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_SCALER_ENABLE;
485 PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props)); 489 PgConfigScalerChannel(overlay->hwdata->channel,
490 &(overlay->hwdata->props));
486 491
487 overlay->hwdata->scaler_on = 0; 492 overlay->hwdata->scaler_on = 0;
488 overlay->hwdata->State = OVERLAY_STATE_UNINIT; 493 overlay->hwdata->State = OVERLAY_STATE_UNINIT;
489 494
490 if (overlay->hwdata->channel != NULL) 495 if (overlay->hwdata->channel != NULL) {
491 {
492 PgDestroyVideoChannel(overlay->hwdata->channel); 496 PgDestroyVideoChannel(overlay->hwdata->channel);
493 overlay->hwdata->channel = NULL; 497 overlay->hwdata->channel = NULL;
494 return; 498 return;
495 } 499 }
496 500
497 overlay->hwdata->CurrentFrameData = NULL; 501 overlay->hwdata->CurrentFrameData = NULL;
498 502
499 SDL_free(overlay->hwdata->FrameData0); 503 SDL_free(overlay->hwdata->FrameData0);
500 SDL_free(overlay->hwdata->FrameData1); 504 SDL_free(overlay->hwdata->FrameData1);
501 overlay->hwdata->FrameData0 = NULL; 505 overlay->hwdata->FrameData0 = NULL;
502 overlay->hwdata->FrameData1 = NULL; 506 overlay->hwdata->FrameData1 = NULL;
503 SDL_free(overlay->hwdata); 507 SDL_free(overlay->hwdata);
504 } 508 }
509
510 /* vi: set ts=4 sw=4 expandtab: */