Rev 4438 | Rev 5372 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4438 | Serge | 1 | |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | #include "winlib/winlib.h" |
||
5021 | Serge | 8 | #include |
4438 | Serge | 9 | #include "fplay.h" |
10 | #include |
||
11 | |||
12 | |||
13 | |||
14 | |||
15 | extern int res_pause_btn_pressed[]; |
||
16 | |||
17 | |||
18 | extern int res_play_btn_pressed[]; |
||
19 | |||
20 | |||
21 | extern volatile int sound_level_0; |
||
22 | extern volatile int sound_level_1; |
||
23 | |||
24 | |||
25 | { |
||
26 | AVPicture picture; |
||
27 | double pts; |
||
28 | volatile int ready; |
||
29 | }vframe_t; |
||
30 | |||
31 | |||
32 | volatile int frames_count = 0; |
||
33 | |||
34 | |||
35 | |||
36 | |||
37 | int dfx = 0; |
||
38 | |||
39 | |||
40 | |||
41 | |||
42 | int height; |
||
43 | |||
44 | |||
45 | AVFrame *Frame; |
||
46 | |||
47 | |||
48 | |||
49 | |||
50 | |||
51 | |||
52 | { |
||
53 | int i; |
||
54 | |||
55 | |||
56 | { |
||
57 | frames[i].pts = 0; |
||
58 | frames[i].ready = 0; |
||
59 | }; |
||
60 | frames_count = 0; |
||
61 | vfx = 0; |
||
62 | dfx = 0; |
||
63 | }; |
||
64 | |||
65 | |||
66 | { |
||
67 | int i; |
||
68 | |||
69 | |||
70 | height = ctx->height; |
||
71 | |||
72 | |||
73 | |||
74 | if ( Frame == NULL ) |
||
75 | { |
||
76 | printf("Cannot alloc video frame\n\r"); |
||
77 | return 0; |
||
78 | }; |
||
79 | |||
80 | |||
81 | { |
||
82 | int ret; |
||
83 | |||
84 | |||
85 | // ctx->width, ctx->height, ctx->pix_fmt ); |
||
86 | |||
87 | |||
88 | ctx->width, ctx->height); |
||
89 | if ( ret != 0 ) |
||
90 | { |
||
91 | printf("Cannot alloc video buffer\n\r"); |
||
92 | return 0; |
||
93 | }; |
||
94 | |||
95 | |||
96 | frames[i].ready = 0; |
||
97 | }; |
||
98 | |||
99 | |||
100 | |||
101 | |||
102 | return 1; |
||
103 | }; |
||
104 | |||
105 | |||
106 | { |
||
107 | AVPacket pkt; |
||
108 | double pts; |
||
109 | int frameFinished; |
||
110 | double current_clock; |
||
111 | |||
112 | |||
113 | return -1; |
||
114 | |||
115 | |||
116 | return 0; |
||
117 | |||
118 | |||
119 | current_clock = -90.0 + get_master_clock(); |
||
120 | |||
121 | |||
122 | Frame->reordered_opaque != AV_NOPTS_VALUE) |
||
123 | pts = Frame->reordered_opaque; |
||
124 | else if(pkt.dts != AV_NOPTS_VALUE) |
||
125 | pts= pkt.dts; |
||
126 | else |
||
127 | pts= 0; |
||
128 | |||
129 | |||
130 | |||
131 | */ |
||
132 | if( 1 /*pts > current_clock*/) |
||
133 | { |
||
134 | frameFinished = 0; |
||
135 | |||
136 | |||
137 | |||
138 | |||
139 | printf("video decoder error\n"); |
||
140 | |||
141 | |||
142 | { |
||
143 | AVPicture *dst_pic; |
||
144 | |||
145 | |||
146 | Frame->reordered_opaque != AV_NOPTS_VALUE) |
||
147 | pts = Frame->reordered_opaque; |
||
148 | else if(pkt.dts != AV_NOPTS_VALUE) |
||
149 | pts= pkt.dts; |
||
150 | else |
||
151 | pts= 0; |
||
152 | |||
153 | |||
154 | // Frame, "best_effort_timestamp"); |
||
155 | |||
156 | |||
157 | // pts = 0; |
||
158 | |||
159 | |||
160 | |||
161 | |||
162 | |||
163 | |||
164 | (const uint8_t**)Frame->data, |
||
165 | Frame->linesize, ctx->pix_fmt, ctx->width, ctx->height); |
||
166 | |||
167 | |||
168 | // printf("pts %f\n", frames[dfx].pts); |
||
169 | |||
170 | |||
171 | |||
172 | |||
173 | dfx&= 3; |
||
174 | frames_count++; |
||
175 | }; |
||
176 | }; |
||
177 | av_free_packet(&pkt); |
||
178 | |||
179 | |||
180 | } |
||
181 | |||
182 | |||
183 | extern volatile enum player_state decoder_state; |
||
184 | extern volatile enum player_state sound_state; |
||
185 | |||
186 | |||
187 | |||
188 | |||
189 | |||
190 | |||
191 | { |
||
192 | window_t *win; |
||
193 | |||
194 | |||
195 | |||
196 | |||
197 | |||
198 | |||
199 | win->panel.play_btn->img_hilite = res_play_btn; |
||
200 | win->panel.play_btn->img_pressed = res_play_btn_pressed; |
||
201 | win->panel.prg->current = rewind_pos; |
||
202 | |||
203 | |||
204 | player_state = STOP; |
||
205 | decoder_state = PLAY_2_STOP; |
||
206 | sound_state = PLAY_2_STOP; |
||
207 | render_draw_client(main_render); |
||
208 | // printf("stop player\n"); |
||
209 | |||
210 | |||
211 | |||
212 | |||
213 | { |
||
214 | window_t *win = (window_t*)ctrl; |
||
215 | static int spc_down = 0; |
||
216 | static int ent_down = 0; |
||
217 | |||
218 | |||
219 | { |
||
220 | case MSG_SIZE: |
||
221 | //printf("MSG_SIZE\n"); |
||
222 | if(main_render) |
||
223 | { |
||
224 | render_adjust_size(main_render, win); |
||
225 | render_draw_client(main_render); |
||
226 | }; |
||
227 | break; |
||
228 | |||
229 | |||
230 | switch((short)arg2) |
||
231 | { |
||
232 | case 0x39: |
||
233 | if(spc_down == 0) |
||
234 | { |
||
235 | spc_down = 1; |
||
236 | send_message(win, MSG_LBTNDOWN, 0, 0); |
||
237 | } |
||
238 | break; |
||
239 | |||
240 | |||
241 | spc_down = 0; |
||
242 | break; |
||
243 | |||
244 | |||
245 | if(ent_down == 0) |
||
246 | { |
||
247 | int screensize; |
||
248 | if(win->win_state == NORMAL) |
||
249 | { |
||
250 | win->saved = win->rc; |
||
251 | win->saved_state = win->win_state; |
||
252 | |||
253 | |||
254 | __asm__ __volatile__( |
||
255 | "int $0x40" |
||
256 | ::"a"(67), "b"(0), "c"(0), |
||
257 | "d"((screensize >> 16)-1),"S"((screensize & 0xFFFF)-1) ); |
||
258 | win->win_state = FULLSCREEN; |
||
259 | window_update_layout(win); |
||
260 | } |
||
261 | else if(win->win_state == FULLSCREEN) |
||
262 | { |
||
263 | __asm__ __volatile__( |
||
264 | "int $0x40" |
||
265 | ::"a"(67), "b"(win->saved.l), "c"(win->saved.t), |
||
266 | "d"(win->saved.r-win->saved.l-1),"S"(win->saved.b-win->saved.t-1)); |
||
267 | win->win_state = win->saved_state; |
||
268 | window_update_layout(win); |
||
269 | // if(win->saved_state == MAXIMIZED) |
||
270 | { |
||
271 | blit_caption(&win->caption); |
||
272 | blit_panel(&win->panel); |
||
273 | } |
||
274 | } |
||
275 | ent_down = 1; |
||
276 | }; |
||
277 | break; |
||
278 | |||
279 | |||
280 | ent_down = 0; |
||
281 | break; |
||
282 | }; |
||
283 | |||
284 | |||
285 | if(main_render) |
||
286 | { |
||
287 | render_draw_client(main_render); |
||
288 | }; |
||
289 | break; |
||
290 | |||
291 | |||
292 | |||
293 | |||
294 | { |
||
295 | win->panel.play_btn->img_default = res_pause_btn; |
||
296 | win->panel.play_btn->img_hilite = res_pause_btn; |
||
297 | win->panel.play_btn->img_pressed = res_pause_btn_pressed; |
||
298 | send_message(&win->panel.play_btn->ctrl, MSG_PAINT, 0, 0); |
||
299 | player_state = PLAY; |
||
300 | sound_state = PAUSE_2_PLAY; |
||
301 | |||
302 | |||
303 | else if(player_state == PLAY) |
||
304 | { |
||
305 | win->panel.play_btn->img_default = res_play_btn; |
||
306 | win->panel.play_btn->img_hilite = res_play_btn; |
||
307 | win->panel.play_btn->img_pressed = res_play_btn_pressed; |
||
308 | send_message(&win->panel.play_btn->ctrl, MSG_PAINT, 0, 0); |
||
309 | player_state = PAUSE; |
||
310 | sound_state = PLAY_2_PAUSE; |
||
311 | } |
||
312 | break; |
||
313 | |||
314 | |||
315 | switch((short)arg1) |
||
316 | { |
||
317 | case ID_PLAY: |
||
318 | if(player_state == PAUSE) |
||
319 | { |
||
320 | win->panel.play_btn->img_default = res_pause_btn; |
||
321 | win->panel.play_btn->img_hilite = res_pause_btn; |
||
322 | win->panel.play_btn->img_pressed = res_pause_btn_pressed; |
||
323 | player_state = PLAY; |
||
324 | sound_state = PAUSE_2_PLAY; |
||
325 | } |
||
326 | else if(player_state == PLAY) |
||
327 | { |
||
328 | win->panel.play_btn->img_default = res_play_btn; |
||
329 | win->panel.play_btn->img_hilite = res_play_btn; |
||
330 | win->panel.play_btn->img_pressed = res_play_btn_pressed; |
||
331 | player_state = PAUSE; |
||
332 | sound_state = PLAY_2_PAUSE; |
||
333 | } |
||
334 | else if(player_state == STOP) |
||
335 | { |
||
336 | win->panel.play_btn->img_default = res_pause_btn; |
||
337 | win->panel.play_btn->img_hilite = res_pause_btn; |
||
338 | win->panel.play_btn->img_pressed = res_pause_btn_pressed; |
||
339 | rewind_pos = 0; |
||
340 | send_message(&win->panel.ctrl, MSG_PAINT, 0, 0); |
||
341 | player_state = PLAY; |
||
342 | decoder_state = PREPARE; |
||
343 | } |
||
344 | break; |
||
345 | |||
346 | |||
347 | player_stop(); |
||
348 | break; |
||
349 | |||
350 | |||
351 | if(player_state != REWIND) |
||
352 | { |
||
353 | progress_t *prg = (progress_t*)arg2; |
||
354 | |||
355 | |||
356 | |||
357 | |||
358 | player_state = REWIND; |
||
359 | decoder_state = REWIND; |
||
360 | sound_state = PLAY_2_STOP; |
||
361 | if(rewind_pos < prg->current) |
||
362 | { |
||
363 | prg->current = rewind_pos; |
||
364 | rewind_pos = -rewind_pos; |
||
365 | } |
||
366 | else |
||
367 | prg->current = rewind_pos; |
||
368 | |||
369 | |||
370 | win->panel.play_btn->img_hilite = res_pause_btn; |
||
371 | win->panel.play_btn->img_pressed = res_pause_btn_pressed; |
||
372 | send_message(&prg->ctrl, MSG_PAINT, 0, 0); |
||
373 | }; |
||
374 | break; |
||
375 | |||
376 | |||
377 | { |
||
378 | slider_t *sld = (slider_t*)arg2; |
||
379 | int peak; |
||
380 | int level; |
||
381 | |||
382 | |||
383 | // level = (log2(peak+16384)*10000.0)/15 - 10000; |
||
384 | level = peak; |
||
385 | |||
386 | |||
387 | set_audio_volume(level, level); |
||
388 | send_message(&sld->ctrl, MSG_PAINT, 0, 0); |
||
389 | win->panel.lvl->vol = level; |
||
390 | } |
||
391 | |||
392 | |||
393 | break; |
||
394 | } |
||
395 | break; |
||
396 | |||
397 | |||
398 | def_window_proc(ctrl,msg,arg1,arg2); |
||
399 | }; |
||
400 | return 0; |
||
401 | }; |
||
402 | |||
403 | |||
404 | |||
405 | |||
406 | extern queue_t q_audio; |
||
407 | |||
408 | |||
409 | { |
||
410 | progress_t *prg = main_render->win->panel.prg; |
||
411 | level_t *lvl = main_render->win->panel.lvl; |
||
412 | |||
413 | |||
414 | double fdelay; /* milliseconds */ |
||
415 | |||
416 | |||
417 | |||
418 | |||
419 | { |
||
420 | render->win->win_command = WIN_CLOSED; |
||
421 | return; |
||
422 | } |
||
423 | else if((player_state == PAUSE) || (player_state == REWIND)) |
||
424 | { |
||
425 | delay(1); |
||
426 | return; |
||
427 | } |
||
428 | else if (decoder_state == STOP && frames_count == 0 && |
||
429 | player_state != STOP) |
||
430 | { |
||
431 | player_stop(); |
||
432 | } |
||
433 | else if(player_state != PLAY) |
||
434 | { |
||
435 | delay(1); |
||
436 | return; |
||
437 | }; |
||
438 | |||
439 | |||
440 | |||
441 | if(frames[vfx].ready == 1 ) |
||
442 | { |
||
443 | int sys_time; |
||
444 | |||
445 | |||
446 | fdelay = (frames[vfx].pts - ctime); |
||
447 | |||
448 | |||
449 | // frames[vfx].pts, ctime, fdelay); |
||
450 | |||
451 | |||
452 | { |
||
453 | delay((int)fdelay/10); |
||
454 | // return; |
||
455 | }; |
||
456 | #if 0 |
||
457 | ctime = get_master_clock(); |
||
458 | fdelay = (frames[vfx].pts - ctime); |
||
459 | |||
460 | |||
461 | // { |
||
462 | // yield(); |
||
463 | // ctime = get_master_clock(); |
||
464 | // fdelay = (frames[vfx].pts - ctime); |
||
465 | // } |
||
466 | |||
467 | |||
468 | |||
469 | |||
470 | // printf("systime %d pts %f time %f delay %f\n", |
||
471 | // sys_time*10, frames[vfx].pts, ctime, fdelay); |
||
472 | |||
473 | |||
474 | frames[vfx].pts, ctime, fdelay); |
||
475 | printf("video cache %d audio cache %d\n", q_video.size/1024, q_audio.size/1024); |
||
476 | #endif |
||
477 | |||
478 | |||
479 | if(main_render->win->win_state != FULLSCREEN) |
||
480 | { |
||
481 | prg->current = frames[vfx].pts*1000; |
||
482 | // printf("current %f\n", prg->current); |
||
483 | lvl->current = vfx & 1 ? sound_level_1 : sound_level_0; |
||
484 | |||
485 | |||
486 | |||
487 | |||
488 | send_message(&lvl->ctrl, MSG_PAINT, 0, 0); |
||
489 | } |
||
490 | |||
491 | |||
492 | frames[vfx].ready = 0; |
||
493 | vfx++; |
||
494 | vfx&= 3; |
||
495 | } |
||
496 | else delay(1); |
||
497 | |||
498 | |||
499 | |||
500 | |||
501 | { |
||
502 | ctime = get_master_clock(); |
||
503 | fdelay = (frames[vfx].pts - ctime); |
||
504 | |||
505 | |||
506 | // frames[vfx].pts, ctime, fdelay); |
||
507 | |||
508 | |||
509 | { |
||
510 | int next_vfx; |
||
511 | fdelay = 0; |
||
512 | next_vfx = (vfx+1) & 3; |
||
513 | if( frames[next_vfx].ready == 1 ) |
||
514 | { |
||
515 | if(frames[next_vfx].pts <= ctime) |
||
516 | { |
||
517 | frames[vfx].ready = 0; // skip this frame |
||
518 | vfx++; |
||
519 | vfx&= 3; |
||
520 | } |
||
521 | else |
||
522 | { |
||
523 | if( (frames[next_vfx].pts - ctime) < |
||
524 | ( ctime - frames[vfx].pts) ) |
||
525 | { |
||
526 | frames[vfx].ready = 0; // skip this frame |
||
527 | vfx++; |
||
528 | vfx&= 3; |
||
529 | fdelay = (frames[next_vfx].pts - ctime); |
||
530 | } |
||
531 | } |
||
532 | }; |
||
533 | }; |
||
534 | |||
535 | |||
536 | { |
||
537 | int val = fdelay; |
||
538 | printf("pts %f time %f delay %d\n", |
||
539 | frames[vfx].pts, ctime, val); |
||
540 | delay(val/10); |
||
541 | }; |
||
542 | |||
543 | |||
544 | fdelay = (frames[vfx].pts - ctime); |
||
545 | |||
546 | |||
547 | frames[vfx].pts, ctime, fdelay); |
||
548 | |||
549 | |||
550 | main_render->win->panel.prg->current = frames[vfx].pts; |
||
551 | // send_message(&render->win->panel.prg->ctrl, MSG_PAINT, 0, 0); |
||
552 | frames[vfx].ready = 0; |
||
553 | vfx++; |
||
554 | vfx&= 3; |
||
555 | } |
||
556 | else yield(); |
||
557 | #endif |
||
558 | |||
559 | |||
560 | |||
561 | |||
562 | |||
563 | |||
564 | |||
565 | { |
||
566 | AVCodecContext *ctx = param; |
||
567 | window_t *MainWindow; |
||
568 | |||
569 | |||
570 | |||
571 | |||
572 | 10,10,width,height+CAPTION_HEIGHT+PANEL_HEIGHT,MainWindowProc); |
||
573 | |||
574 | |||
575 | // printf("MainWindow %x\n", MainWindow); |
||
576 | |||
577 | |||
578 | |||
579 | |||
580 | |||
581 | |||
582 | if( main_render == NULL) |
||
583 | { |
||
584 | printf("Cannot create render\n\r"); |
||
585 | return 0; |
||
586 | }; |
||
587 | |||
588 | |||
589 | player_state = PLAY; |
||
590 | |||
591 | |||
592 | |||
593 | |||
594 | fini_winlib(); |
||
595 | |||
596 | |||
597 | return 0; |
||
598 | }; |
||
599 | |||
600 | |||
601 | |||
602 | void draw_sw_picture(render_t *render, AVPicture *picture); |
||
603 | |||
604 | |||
605 | { |
||
606 | render_t *render; |
||
607 | |||
608 | |||
609 | uint32_t s, sw, sh; |
||
610 | uint8_t state; |
||
611 | |||
612 | |||
613 | |||
614 | |||
615 | memset(render, 0, sizeof(render_t)); |
||
616 | |||
617 | |||
618 | |||
619 | |||
620 | render->ctx_height = ctx->height; |
||
621 | render->ctx_format = ctx->pix_fmt; |
||
622 | |||
623 | |||
624 | render->caps = init_pixlib(flags); |
||
625 | mutex_unlock(&driver_lock); |
||
626 | |||
627 | |||
628 | bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; |
||
629 | |||
630 | |||
631 | // right, bottom); |
||
632 | |||
633 | |||
634 | |||
635 | |||
636 | draw_h = right*render->ctx_height/render->ctx_width; |
||
637 | |||
638 | |||
639 | { |
||
640 | draw_w = right; |
||
641 | draw_h = right*render->ctx_height/render->ctx_width; |
||
642 | }; |
||
643 | |||
644 | |||
645 | { |
||
646 | draw_h = bottom; |
||
647 | draw_w = bottom*render->ctx_width/render->ctx_height; |
||
648 | }; |
||
649 | |||
650 | |||
651 | render->win_height = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; |
||
652 | |||
653 | |||
654 | |||
655 | |||
656 | |||
657 | { |
||
658 | render->bitmap[0].width = draw_w; |
||
659 | render->bitmap[0].height = draw_h; |
||
660 | |||
661 | |||
662 | { |
||
663 | free(render); |
||
664 | return NULL; |
||
665 | } |
||
666 | render->draw = draw_sw_picture; |
||
667 | } |
||
668 | else |
||
669 | { |
||
670 | int width, height, flags; |
||
671 | int i; |
||
672 | |||
673 | |||
674 | { |
||
675 | sna_create_mask(); |
||
676 | |||
677 | |||
678 | height = render->ctx_height; |
||
679 | flags = HW_TEX_BLIT; |
||
680 | } |
||
681 | else |
||
682 | { |
||
683 | width = draw_w; |
||
684 | height = draw_h;; |
||
685 | flags = HW_BIT_BLIT; |
||
686 | } |
||
687 | |||
688 | |||
689 | { |
||
690 | render->bitmap[i].width = width; |
||
691 | render->bitmap[i].height = height; |
||
692 | render->bitmap[i].flags = flags; |
||
693 | |||
694 | |||
695 | { |
||
696 | player_state = CLOSED; |
||
697 | free(render); |
||
698 | return NULL; |
||
699 | }; |
||
700 | } |
||
701 | |||
702 | |||
703 | render->target = 0; |
||
704 | render->draw = draw_hw_picture; |
||
705 | }; |
||
706 | |||
707 | |||
708 | |||
709 | render->caps & HW_TEX_BLIT ? "hw_tex_blit": |
||
710 | render->caps & HW_BIT_BLIT ? "hw_bit_blit":"software", |
||
711 | render->ctx_width, render->ctx_height, |
||
712 | draw_w, draw_h); |
||
713 | |||
714 | |||
715 | // printf("create hardware decoder context\n"); |
||
716 | |||
717 | |||
718 | }; |
||
719 | |||
720 | |||
721 | { |
||
722 | |||
723 | |||
724 | |||
725 | |||
726 | destroy_bitmap(&render->bitmap[1]); |
||
727 | |||
728 | |||
729 | }; |
||
730 | |||
731 | |||
732 | { |
||
733 | int i; |
||
734 | |||
735 | |||
736 | render->rcvideo.l = 0; |
||
737 | render->rcvideo.t = 0; |
||
738 | render->rcvideo.r = width; |
||
739 | render->rcvideo.b = height; |
||
740 | |||
741 | |||
742 | |||
743 | |||
744 | { |
||
745 | int yoffs; |
||
746 | yoffs = (render->win_height-height)/2; |
||
747 | if(yoffs) |
||
748 | { |
||
749 | render->rctop.t = 0; |
||
750 | render->rctop.b = yoffs; |
||
751 | render->rcvideo.t = yoffs; |
||
752 | render->layout |= HAS_TOP; |
||
753 | } |
||
754 | |||
755 | |||
756 | if(yoffs) |
||
757 | { |
||
758 | render->rcbottom.t = render->rcvideo.t+render->rcvideo.b; |
||
759 | render->rcbottom.b = yoffs; |
||
760 | render->layout |= HAS_BOTTOM; |
||
761 | } |
||
762 | } |
||
763 | |||
764 | |||
765 | { |
||
766 | int xoffs; |
||
767 | xoffs = (render->win_width-width)/2; |
||
768 | if(xoffs) |
||
769 | { |
||
770 | render->rcleft.r = xoffs; |
||
771 | render->rcvideo.l = xoffs; |
||
772 | render->layout |= HAS_LEFT; |
||
773 | } |
||
774 | xoffs = render->win_width-(render->rcvideo.l+render->rcvideo.r); |
||
775 | if(xoffs) |
||
776 | { |
||
777 | render->rcright.l = render->rcvideo.l+render->rcvideo.r; |
||
778 | render->rcright.r = xoffs; |
||
779 | render->layout |= HAS_RIGHT; |
||
780 | } |
||
781 | }; |
||
782 | }; |
||
783 | |||
784 | |||
785 | { |
||
786 | uint32_t right, bottom, new_w, new_h; |
||
787 | uint32_t s, sw, sh; |
||
788 | uint8_t state; |
||
789 | |||
790 | |||
791 | bottom = win->h; |
||
792 | |||
793 | |||
794 | bottom-= CAPTION_HEIGHT+PANEL_HEIGHT; |
||
795 | |||
796 | |||
797 | // right, bottom); |
||
798 | |||
799 | |||
800 | |||
801 | |||
802 | return; |
||
803 | |||
804 | |||
805 | return; |
||
806 | |||
807 | |||
808 | bottom == render->win_height) |
||
809 | return; |
||
810 | |||
811 | |||
812 | |||
813 | |||
814 | new_h = right*render->ctx_height/render->ctx_width; |
||
815 | |||
816 | |||
817 | { |
||
818 | new_w = right; |
||
819 | new_h = right*render->ctx_height/render->ctx_width; |
||
820 | }; |
||
821 | if(new_h > bottom) |
||
822 | { |
||
823 | new_h = bottom; |
||
824 | new_w = bottom*render->ctx_width/render->ctx_height; |
||
825 | }; |
||
826 | |||
827 | |||
828 | render->win_height = bottom; |
||
829 | render_set_size(render, new_w, new_h); |
||
830 | |||
831 | |||
832 | return; |
||
833 | |||
834 | |||
835 | render->bitmap[0].height = new_h; |
||
836 | resize_bitmap(&render->bitmap[0]); |
||
837 | |||
838 | |||
839 | { |
||
840 | render->bitmap[1].width = new_w; |
||
841 | render->bitmap[1].height = new_h; |
||
842 | resize_bitmap(&render->bitmap[1]); |
||
843 | }; |
||
844 | return; |
||
845 | }; |
||
846 | |||
847 | |||
848 | { |
||
849 | int dst_width, dst_height; |
||
850 | bitmap_t *bitmap; |
||
851 | uint8_t *data[4]; |
||
852 | int linesize[4]; |
||
853 | int ret; |
||
854 | |||
855 | |||
856 | render->win->win_state == ROLLED) |
||
857 | return; |
||
858 | |||
859 | |||
860 | { |
||
861 | dst_width = render->ctx_width; |
||
862 | dst_height = render->ctx_height; |
||
863 | } |
||
864 | else |
||
865 | { |
||
866 | dst_width = render->rcvideo.r; |
||
867 | dst_height = render->rcvideo.b; |
||
868 | }; |
||
869 | |||
870 | |||
871 | render->ctx_width, render->ctx_height, render->ctx_format, |
||
872 | dst_width, dst_height, PIX_FMT_BGRA, |
||
873 | SWS_FAST_BILINEAR, NULL, NULL, NULL); |
||
874 | if(cvt_ctx == NULL) |
||
875 | { |
||
876 | printf("Cannot initialize the conversion context!\n"); |
||
877 | return ; |
||
878 | }; |
||
879 | |||
880 | |||
881 | |||
882 | |||
883 | if( ret != 0) |
||
884 | { |
||
885 | printf("Cannot lock bitmap!\n"); |
||
886 | return ; |
||
887 | } |
||
888 | |||
889 | |||
890 | data[0] = bitmap->data; |
||
891 | data[1] = bitmap->data+1; |
||
892 | data[2] = bitmap->data+2; |
||
893 | data[3] = bitmap->data+3; |
||
894 | |||
895 | |||
896 | linesize[1] = bitmap->pitch; |
||
897 | linesize[2] = bitmap->pitch; |
||
898 | linesize[3] = bitmap->pitch; |
||
899 | |||
900 | |||
901 | picture->linesize, 0, render->ctx_height, data, linesize); |
||
902 | // printf("sws_scale\n"); |
||
903 | |||
904 | |||
905 | |||
906 | { |
||
907 | |||
908 | |||
909 | fplay_blit_bitmap(bitmap,render->rcvideo.l,render->rcvideo.t, |
||
910 | render->rcvideo.r, render->rcvideo.b); |
||
911 | else |
||
912 | fplay_blit_bitmap(bitmap, render->rcvideo.l, |
||
913 | CAPTION_HEIGHT+render->rcvideo.t, |
||
914 | render->rcvideo.r, render->rcvideo.b); |
||
915 | } |
||
916 | else |
||
917 | { |
||
918 | if(render->win->win_state == FULLSCREEN) |
||
919 | blit_bitmap(bitmap,render->rcvideo.l,render->rcvideo.t, |
||
920 | render->rcvideo.r, render->rcvideo.b, 0,0); |
||
921 | else |
||
922 | blit_bitmap(bitmap, render->rcvideo.l, |
||
923 | CAPTION_HEIGHT+render->rcvideo.t, |
||
924 | render->rcvideo.r, render->rcvideo.b, 0, 0); |
||
925 | }; |
||
926 | |||
927 | |||
928 | render->target++; |
||
929 | render->target&= 1; |
||
930 | } |
||
931 | |||
932 | |||
933 | { |
||
934 | uint8_t *data[4]; |
||
935 | int linesize[4]; |
||
936 | |||
937 | |||
938 | render->win->win_state == ROLLED) |
||
939 | return; |
||
940 | |||
941 | |||
942 | render->ctx_width, render->ctx_height, |
||
943 | render->ctx_format, |
||
944 | render->rcvideo.r, render->rcvideo.b, |
||
945 | PIX_FMT_BGRA, SWS_FAST_BILINEAR, NULL, NULL, NULL); |
||
946 | if(cvt_ctx == NULL) |
||
947 | { |
||
948 | printf("Cannot initialize the conversion context!\n"); |
||
949 | return ; |
||
950 | } |
||
951 | |||
952 | |||
953 | |||
954 | |||
955 | data[1] = render->bitmap[0].data+1; |
||
956 | data[2] = render->bitmap[0].data+2; |
||
957 | data[3] = render->bitmap[0].data+3; |
||
958 | |||
959 | |||
960 | linesize[1] = render->bitmap[0].pitch; |
||
961 | linesize[2] = render->bitmap[0].pitch; |
||
962 | linesize[3] = render->bitmap[0].pitch; |
||
963 | |||
964 | |||
965 | picture->linesize, 0, render->ctx_height, data, linesize); |
||
966 | |||
967 | |||
968 | fplay_blit_bitmap(&render->bitmap[0],render->rcvideo.l,render->rcvideo.t, |
||
969 | render->rcvideo.r, render->rcvideo.b); |
||
970 | else |
||
971 | fplay_blit_bitmap(&render->bitmap[0], render->rcvideo.l, |
||
972 | CAPTION_HEIGHT+render->rcvideo.t, |
||
973 | render->rcvideo.r, render->rcvideo.b); |
||
974 | |||
975 | |||
976 | } |
||
977 | |||
978 | |||
979 | { |
||
980 | int y; |
||
981 | |||
982 | |||
983 | render->win_state == ROLLED ) |
||
984 | return; |
||
985 | if(render->win_state == FULLSCREEN) |
||
986 | y = 0; |
||
987 | else |
||
988 | y = CAPTION_HEIGHT; |
||
989 | |||
990 | |||
991 | { |
||
992 | if(frames[vfx].ready == 1 ) |
||
993 | main_render->draw(main_render, &frames[vfx].picture); |
||
994 | else |
||
995 | draw_bar(0, y, render->win_width, |
||
996 | render->rcvideo.b, 0); |
||
997 | } |
||
998 | else if( player_state == STOP ) |
||
999 | { |
||
1000 | draw_bar(0,y, render->win_width, |
||
1001 | render->rcvideo.b, 0); |
||
1002 | }; |
||
1003 | |||
1004 | |||
1005 | draw_bar(0, y, render->win_width, |
||
1006 | render->rctop.b, 0); |
||
1007 | if(render->layout & HAS_LEFT) |
||
1008 | draw_bar(0, render->rcvideo.t+y, render->rcleft.r, |
||
1009 | render->rcvideo.b, 0); |
||
1010 | if(render->layout & HAS_RIGHT) |
||
1011 | draw_bar(render->rcright.l, render->rcvideo.t+y, |
||
1012 | render->rcright.r, render->rcvideo.b, 0); |
||
1013 | if(render->layout & HAS_BOTTOM) |
||
1014 | draw_bar(0, render->rcbottom.t+y, |
||
1015 | render->win_width, render->rcbottom.b, 0); |
||
1016 | }> |
||
1017 | >=>>>>=>>> |
||
1018 |