Rev 3248 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3248 | Rev 3292 | ||
---|---|---|---|
Line 66... | Line 66... | ||
66 | 66 | ||
Line 67... | Line 67... | ||
67 | width = ctx->width; |
67 | width = ctx->width; |
68 | height = ctx->height; |
68 | height = ctx->height; |
Line 69... | Line -... | ||
69 | - | ||
70 | printf("w = %d h = %d\n\r", ctx->width, ctx->height); |
- | |
71 | - | ||
72 | // __asm__ __volatile__("int3"); |
- | |
73 | - | ||
74 | main_render = create_render(ctx->width, ctx->height, |
- | |
75 | ctx->pix_fmt, HW_BIT_BLIT|HW_TEX_BLIT); |
- | |
76 | if( main_render == NULL) |
- | |
77 | { |
- | |
78 | printf("Cannot create render\n\r"); |
- | |
79 | return 0; |
- | |
Line 80... | Line 69... | ||
80 | }; |
69 | |
81 | 70 | ||
82 | Frame = avcodec_alloc_frame(); |
71 | Frame = avcodec_alloc_frame(); |
83 | if ( Frame == NULL ) |
72 | if ( Frame == NULL ) |
Line 227... | Line 216... | ||
227 | switch(msg) |
216 | switch(msg) |
228 | { |
217 | { |
229 | case MSG_SIZE: |
218 | case MSG_SIZE: |
230 | //printf("MSG_SIZE\n"); |
219 | //printf("MSG_SIZE\n"); |
- | 220 | if(main_render) |
|
- | 221 | { |
|
231 | render_adjust_size(main_render, win); |
222 | render_adjust_size(main_render, win); |
- | 223 | render_draw_client(main_render); |
|
- | 224 | }; |
|
232 | break; |
225 | break; |
Line 233... | Line 226... | ||
233 | 226 | ||
234 | case MSG_DRAW_CLIENT: |
227 | case MSG_DRAW_CLIENT: |
235 | render_draw_client(main_render); |
228 | render_draw_client(main_render); |
Line 492... | Line 485... | ||
492 | extern char *movie_file; |
485 | extern char *movie_file; |
Line 493... | Line 486... | ||
493 | 486 | ||
494 | int video_thread(void *param) |
487 | int video_thread(void *param) |
- | 488 | { |
|
495 | { |
489 | AVCodecContext *ctx = param; |
Line 496... | Line 490... | ||
496 | window_t *MainWindow; |
490 | window_t *MainWindow; |
Line 497... | Line 491... | ||
497 | 491 | ||
498 | init_winlib(); |
492 | init_winlib(); |
Line 499... | Line 493... | ||
499 | 493 | ||
500 | MainWindow = create_window(movie_file,0, |
494 | MainWindow = create_window(movie_file,0, |
Line 501... | Line -... | ||
501 | 10,10,width,height+CAPTION_HEIGHT+PANEL_HEIGHT,MainWindowProc); |
- | |
502 | - | ||
503 | MainWindow->panel.prg->max = stream_duration; |
495 | 10,10,width,height+CAPTION_HEIGHT+PANEL_HEIGHT,MainWindowProc); |
Line -... | Line 496... | ||
- | 496 | ||
- | 497 | MainWindow->panel.prg->max = stream_duration; |
|
- | 498 | // printf("MainWindow %x\n", MainWindow); |
|
- | 499 | ||
- | 500 | show_window(MainWindow, NORMAL); |
|
- | 501 | ||
- | 502 | // __asm__ __volatile__("int3"); |
|
- | 503 | ||
- | 504 | main_render = create_render(MainWindow, ctx, HW_BIT_BLIT|HW_TEX_BLIT); |
|
504 | // printf("MainWindow %x\n", MainWindow); |
505 | if( main_render == NULL) |
505 | 506 | { |
|
Line 506... | Line 507... | ||
506 | main_render->win = MainWindow; |
507 | printf("Cannot create render\n\r"); |
Line -... | Line 508... | ||
- | 508 | return 0; |
|
507 | 509 | }; |
|
Line 508... | Line 510... | ||
508 | show_window(MainWindow, NORMAL); |
510 | |
509 | 511 | render_draw_client(main_render); |
|
510 | render_draw_client(main_render); |
512 | player_state = PLAY; |
Line 511... | Line 513... | ||
511 | player_state = PLAY; |
513 | |
512 | 514 | run_render(MainWindow, main_render); |
|
Line 513... | Line 515... | ||
513 | run_render(MainWindow, main_render); |
515 | |
514 | - | ||
515 | fini_winlib(); |
516 | destroy_render(main_render); |
516 | 517 | fini_winlib(); |
|
Line -... | Line 518... | ||
- | 518 | ||
- | 519 | player_state = CLOSED; |
|
- | 520 | return 0; |
|
- | 521 | }; |
|
517 | player_state = CLOSED; |
522 | |
Line 518... | Line 523... | ||
518 | return 0; |
523 | |
519 | }; |
524 | void draw_hw_picture(render_t *render, AVPicture *picture); |
Line -... | Line 525... | ||
- | 525 | void draw_sw_picture(render_t *render, AVPicture *picture); |
|
- | 526 | ||
520 | 527 | render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags) |
|
521 | 528 | { |
|
522 | void draw_hw_picture(render_t *render, AVPicture *picture); |
529 | render_t *render; |
Line 523... | Line 530... | ||
523 | void draw_sw_picture(render_t *render, AVPicture *picture); |
530 | |
524 | 531 | uint32_t right, bottom, draw_w, draw_h; |
|
525 | render_t *create_render(uint32_t width, uint32_t height, |
532 | uint32_t s, sw, sh; |
Line -... | Line 533... | ||
- | 533 | uint8_t state; |
|
- | 534 | ||
- | 535 | // __asm__ __volatile__("int3"); |
|
- | 536 | ||
- | 537 | render = (render_t*)malloc(sizeof(render_t)); |
|
- | 538 | memset(render, 0, sizeof(render_t)); |
|
- | 539 | ||
- | 540 | render->win = win; |
|
- | 541 | ||
- | 542 | render->ctx_width = ctx->width; |
|
- | 543 | render->ctx_height = ctx->height; |
|
- | 544 | render->ctx_format = ctx->pix_fmt; |
|
- | 545 | ||
- | 546 | mutex_lock(&driver_lock); |
|
- | 547 | render->caps = init_pixlib(flags); |
|
- | 548 | mutex_unlock(&driver_lock); |
|
- | 549 | ||
- | 550 | right = win->w; |
|
- | 551 | bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; |
|
- | 552 | ||
- | 553 | // printf("window width %d height %d\n", |
|
- | 554 | // right, bottom); |
|
- | 555 | ||
- | 556 | render->win_state = win->win_state; |
|
- | 557 | ||
- | 558 | draw_w = bottom*render->ctx_width/render->ctx_height; |
|
- | 559 | draw_h = right*render->ctx_height/render->ctx_width; |
|
- | 560 | ||
- | 561 | if(draw_w > right) |
|
526 | uint32_t ctx_format, uint32_t flags) |
562 | { |
527 | { |
563 | draw_w = right; |
- | 564 | draw_h = right*render->ctx_height/render->ctx_width; |
|
- | 565 | }; |
|
- | 566 | ||
528 | render_t *render; |
567 | if(draw_h > bottom) |
- | 568 | { |
|
- | 569 | draw_h = bottom; |
|
- | 570 | draw_w = bottom*render->ctx_width/render->ctx_height; |
|
- | 571 | }; |
|
529 | 572 | ||
530 | // __asm__ __volatile__("int3"); |
573 | render->win_width = win->w; |
531 | 574 | render->win_height = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; |
|
532 | render = (render_t*)malloc(sizeof(render_t)); |
575 | |
- | 576 | render_set_size(render, draw_w, draw_h); |
|
- | 577 | ||
- | 578 | ||
- | 579 | if(render->caps==0) |
|
- | 580 | { |
|
- | 581 | render->bitmap[0].width = draw_w; |
|
- | 582 | render->bitmap[0].height = draw_h; |
|
- | 583 | ||
- | 584 | if( create_bitmap(&render->bitmap[0]) != 0 ) |
|
- | 585 | { |
|
- | 586 | free(render); |
|
- | 587 | return NULL; |
|
- | 588 | } |
|
- | 589 | render->draw = draw_sw_picture; |
|
- | 590 | } |
|
- | 591 | else |
|
- | 592 | { |
|
- | 593 | int width, height, flags; |
|
- | 594 | int i; |
|
- | 595 | ||
- | 596 | if(render->caps & HW_TEX_BLIT) |
|
- | 597 | { |
|
- | 598 | sna_create_mask(); |
|
- | 599 | ||
- | 600 | width = render->ctx_width; |
|
- | 601 | height = render->ctx_height; |
|
- | 602 | flags = HW_TEX_BLIT; |
|
- | 603 | } |
|
- | 604 | else |
|
- | 605 | { |
|
- | 606 | width = draw_w; |
|
- | 607 | height = draw_h;; |
|
- | 608 | flags = HW_BIT_BLIT; |
|
533 | memset(render, 0, sizeof(render_t)); |
609 | } |
534 | 610 | ||
535 | render->ctx_width = width; |
611 | for( i=0; i < 2; i++) |
Line -... | Line 612... | ||
- | 612 | { |
|
- | 613 | render->bitmap[i].width = width; |
|
- | 614 | render->bitmap[i].height = height; |
|
536 | render->ctx_height = height; |
615 | render->bitmap[i].flags = flags; |
- | 616 | ||
537 | render->ctx_format = ctx_format; |
617 | if( create_bitmap(&render->bitmap[i]) != 0 ) |
538 | 618 | { |
|
Line -... | Line 619... | ||
- | 619 | player_state = CLOSED; |
|
- | 620 | free(render); |
|
- | 621 | return NULL; |
|
- | 622 | }; |
|
- | 623 | } |
|
- | 624 | ||
- | 625 | render->state = INIT; |
|
- | 626 | render->target = 0; |
|
- | 627 | render->draw = draw_hw_picture; |
|
- | 628 | }; |
|
- | 629 | ||
539 | mutex_lock(&driver_lock); |
630 | printf("FPlay %s render engine: context %dx%d picture %dx%d\n", |
540 | render->caps = init_pixlib(flags); |
631 | render->caps==0 ? "software":"hardware", |
541 | mutex_unlock(&driver_lock); |
632 | render->ctx_width, render->ctx_height, |
Line 542... | Line 633... | ||
542 | 633 | draw_w, draw_h); |
|
543 | if(render->caps==0) |
634 | |
Line 605... | Line 696... | ||
605 | render->rcright.r = xoffs; |
696 | render->rcright.r = xoffs; |
606 | render->layout |= HAS_RIGHT; |
697 | render->layout |= HAS_RIGHT; |
607 | } |
698 | } |
608 | }; |
699 | }; |
609 | 700 | }; |
|
610 | if(render->state == EMPTY) |
- | |
611 | { |
- | |
612 | if(render->caps & HW_TEX_BLIT) |
- | |
613 | { |
- | |
614 | for( i=0; i < 4; i++) |
- | |
615 | { |
- | |
616 | render->bitmap[i].width = render->ctx_width; |
- | |
617 | render->bitmap[i].height = render->ctx_height; |
- | |
618 | render->bitmap[i].flags = HW_TEX_BLIT; |
- | |
619 | - | ||
620 | if( create_bitmap(&render->bitmap[i]) != 0 ) |
- | |
621 | { |
- | |
622 | player_state = CLOSED; |
- | |
623 | /* |
- | |
624 | * Epic fail. Need exit_thread() here |
- | |
625 | * |
- | |
626 | */ |
- | |
627 | return 0; |
- | |
628 | }; |
- | |
629 | } |
- | |
630 | } |
- | |
631 | else |
- | |
632 | { |
- | |
633 | render->bitmap[0].width = width; |
- | |
634 | render->bitmap[0].height = height; |
- | |
635 | render->bitmap[0].flags = HW_BIT_BLIT; |
- | |
636 | - | ||
637 | if( create_bitmap(&render->bitmap[0]) != 0 ) |
- | |
638 | return 0; |
- | |
639 | }; |
- | |
640 | render->state = INIT; |
- | |
641 | return 0; |
- | |
642 | }; |
- | |
643 | - | ||
644 | if(render->caps & HW_TEX_BLIT) /* hw scaler */ |
- | |
645 | return 0; |
- | |
646 | - | ||
647 | render->bitmap[0].width = width; |
- | |
648 | render->bitmap[0].height = height; |
- | |
649 | resize_bitmap(&render->bitmap[0]); |
- | |
650 | - | ||
651 | return 0; |
- | |
652 | }; |
- | |
653 | 701 | ||
Line 654... | Line 702... | ||
654 | void render_adjust_size(render_t *render, window_t *win) |
702 | void render_adjust_size(render_t *render, window_t *win) |
655 | { |
703 | { |
656 | uint32_t right, bottom, new_w, new_h; |
704 | uint32_t right, bottom, new_w, new_h; |
Line 691... | Line 739... | ||
691 | 739 | ||
Line 692... | Line 740... | ||
692 | render->win_width = win->w; |
740 | render->win_width = win->w; |
693 | render->win_height = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; |
741 | render->win_height = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; |
694 | render_set_size(render, new_w, new_h); |
742 | render_set_size(render, new_w, new_h); |
- | 743 | ||
- | 744 | if(render->caps & HW_TEX_BLIT) /* hw scaler */ |
|
- | 745 | return; |
|
- | 746 | ||
- | 747 | render->bitmap[0].width = new_w; |
|
- | 748 | render->bitmap[0].height = new_h; |
|
- | 749 | resize_bitmap(&render->bitmap[0]); |
|
- | 750 | ||
- | 751 | if(render->caps & HW_BIT_BLIT) /* hw blitter */ |
|
- | 752 | { |
|
- | 753 | render->bitmap[1].width = new_w; |
|
- | 754 | render->bitmap[1].height = new_h; |
|
- | 755 | resize_bitmap(&render->bitmap[1]); |
|
- | 756 | }; |
|
- | 757 | return; |
|
695 | }; |
758 | }; |
Line 696... | Line 759... | ||
696 | 759 | ||
697 | void draw_hw_picture(render_t *render, AVPicture *picture) |
760 | void draw_hw_picture(render_t *render, AVPicture *picture) |
698 | { |
761 | { |
699 | int dst_width, dst_height; |
762 | int dst_width, dst_height; |
700 | bitmap_t *bitmap; |
763 | bitmap_t *bitmap; |
701 | uint8_t *data[4]; |
764 | uint8_t *data[4]; |
702 | int linesize[4]; |
765 | int linesize[4]; |
Line 703... | Line 766... | ||
703 | int ret; |
766 | int ret; |
704 | 767 | ||
705 | if(render->win_state == MINIMIZED || |
768 | if(render->win->win_state == MINIMIZED || |
Line 706... | Line 769... | ||
706 | render->win_state == ROLLED) |
769 | render->win->win_state == ROLLED) |
707 | return; |
770 | return; |
708 | 771 | ||
Line 758... | Line 821... | ||
758 | render->last_bitmap = bitmap; |
821 | render->last_bitmap = bitmap; |
759 | // printf("blit_bitmap\n"); |
822 | // printf("blit_bitmap\n"); |
Line 760... | Line 823... | ||
760 | 823 | ||
761 | 824 | ||
762 | // render->target++; |
825 | render->target++; |
Line 763... | Line 826... | ||
763 | // render->target&= 3; |
826 | render->target&= 1; |
764 | } |
827 | } |
765 | 828 | ||
766 | void draw_sw_picture(render_t *render, AVPicture *picture) |
829 | void draw_sw_picture(render_t *render, AVPicture *picture) |
Line 767... | Line 830... | ||
767 | { |
830 | { |
768 | uint8_t *data[4]; |
831 | uint8_t *data[4]; |
769 | int linesize[4]; |
832 | int linesize[4]; |
Line 770... | Line 833... | ||
770 | 833 | ||
771 | if(render->win_state == MINIMIZED || |
834 | if(render->win->win_state == MINIMIZED || |
772 | render->win_state == ROLLED) |
835 | render->win->win_state == ROLLED) |
Line 782... | Line 845... | ||
782 | printf("Cannot initialize the conversion context!\n"); |
845 | printf("Cannot initialize the conversion context!\n"); |
783 | return ; |
846 | return ; |
784 | } |
847 | } |
785 | 848 | ||
Line -... | Line 849... | ||
- | 849 | lock_bitmap(&render->bitmap[0]); |
|
- | 850 | ||
786 | data[0] = render->bitmap[0].data; |
851 | data[0] = render->bitmap[0].data; |
787 | data[1] = render->bitmap[0].data+1; |
852 | data[1] = render->bitmap[0].data+1; |
788 | data[2] = render->bitmap[0].data+2; |
853 | data[2] = render->bitmap[0].data+2; |
789 | data[3] = render->bitmap[0].data+3; |
854 | data[3] = render->bitmap[0].data+3; |