diff --git a/ffplay.c b/ffplay.c
index c6cf880..90c18f4 100644
|
a
|
b
|
typedef struct VideoState { |
| 234 | 234 | #if !CONFIG_AVFILTER |
| 235 | 235 | struct SwsContext *img_convert_ctx; |
| 236 | 236 | #endif |
| | 237 | SDL_Rect last_display_rect; |
| 237 | 238 | |
| 238 | 239 | char filename[1024]; |
| 239 | 240 | int width, height, xleft, ytop; |
| … |
… |
static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *seria |
| 449 | 450 | } |
| 450 | 451 | |
| 451 | 452 | static inline void fill_rectangle(SDL_Surface *screen, |
| 452 | | int x, int y, int w, int h, int color) |
| | 453 | int x, int y, int w, int h, int color, int update) |
| 453 | 454 | { |
| 454 | 455 | SDL_Rect rect; |
| 455 | 456 | rect.x = x; |
| … |
… |
static inline void fill_rectangle(SDL_Surface *screen, |
| 457 | 458 | rect.w = w; |
| 458 | 459 | rect.h = h; |
| 459 | 460 | SDL_FillRect(screen, &rect, color); |
| | 461 | if (update && w > 0 && h > 0) |
| | 462 | SDL_UpdateRect(screen, x, y, w, h); |
| | 463 | } |
| | 464 | |
| | 465 | /* draw only the border of a rectangle */ |
| | 466 | static void fill_border(int xleft, int ytop, int width, int height, int x, int y, int w, int h, int color, int update) |
| | 467 | { |
| | 468 | int w1, w2, h1, h2; |
| | 469 | |
| | 470 | /* fill the background */ |
| | 471 | w1 = x; |
| | 472 | if (w1 < 0) |
| | 473 | w1 = 0; |
| | 474 | w2 = width - (x + w); |
| | 475 | if (w2 < 0) |
| | 476 | w2 = 0; |
| | 477 | h1 = y; |
| | 478 | if (h1 < 0) |
| | 479 | h1 = 0; |
| | 480 | h2 = height - (y + h); |
| | 481 | if (h2 < 0) |
| | 482 | h2 = 0; |
| | 483 | fill_rectangle(screen, |
| | 484 | xleft, ytop, |
| | 485 | w1, height, |
| | 486 | color, update); |
| | 487 | fill_rectangle(screen, |
| | 488 | xleft + width - w2, ytop, |
| | 489 | w2, height, |
| | 490 | color, update); |
| | 491 | fill_rectangle(screen, |
| | 492 | xleft + w1, ytop, |
| | 493 | width - w1 - w2, h1, |
| | 494 | color, update); |
| | 495 | fill_rectangle(screen, |
| | 496 | xleft + w1, ytop + height - h2, |
| | 497 | width - w1 - w2, h2, |
| | 498 | color, update); |
| 460 | 499 | } |
| 461 | 500 | |
| 462 | 501 | #define ALPHA_BLEND(a, oldp, newp, s)\ |
| … |
… |
static void video_image_display(VideoState *is) |
| 759 | 798 | calculate_display_rect(&rect, is->xleft, is->ytop, is->width, is->height, vp); |
| 760 | 799 | |
| 761 | 800 | SDL_DisplayYUVOverlay(vp->bmp, &rect); |
| | 801 | |
| | 802 | if (rect.x != is->last_display_rect.x || rect.y != is->last_display_rect.y || rect.w != is->last_display_rect.w || rect.h != is->last_display_rect.h || is->force_refresh) { |
| | 803 | int bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); |
| | 804 | fill_border(is->xleft, is->ytop, is->width, is->height, rect.x, rect.y, rect.w, rect.h, bgcolor, 1); |
| | 805 | is->last_display_rect = rect; |
| | 806 | } |
| 762 | 807 | } |
| 763 | 808 | } |
| 764 | 809 | |
| … |
… |
static void video_audio_display(VideoState *s) |
| 824 | 869 | if (s->show_mode == SHOW_MODE_WAVES) { |
| 825 | 870 | fill_rectangle(screen, |
| 826 | 871 | s->xleft, s->ytop, s->width, s->height, |
| 827 | | bgcolor); |
| | 872 | bgcolor, 0); |
| 828 | 873 | |
| 829 | 874 | fgcolor = SDL_MapRGB(screen->format, 0xff, 0xff, 0xff); |
| 830 | 875 | |
| … |
… |
static void video_audio_display(VideoState *s) |
| 845 | 890 | } |
| 846 | 891 | fill_rectangle(screen, |
| 847 | 892 | s->xleft + x, ys, 1, y, |
| 848 | | fgcolor); |
| | 893 | fgcolor, 0); |
| 849 | 894 | i += channels; |
| 850 | 895 | if (i >= SAMPLE_ARRAY_SIZE) |
| 851 | 896 | i -= SAMPLE_ARRAY_SIZE; |
| … |
… |
static void video_audio_display(VideoState *s) |
| 858 | 903 | y = s->ytop + ch * h; |
| 859 | 904 | fill_rectangle(screen, |
| 860 | 905 | s->xleft, y, s->width, 1, |
| 861 | | fgcolor); |
| | 906 | fgcolor, 0); |
| 862 | 907 | } |
| 863 | 908 | SDL_UpdateRect(screen, s->xleft, s->ytop, s->width, s->height); |
| 864 | 909 | } else { |
| … |
… |
static void video_audio_display(VideoState *s) |
| 896 | 941 | |
| 897 | 942 | fill_rectangle(screen, |
| 898 | 943 | s->xpos, s->height-y, 1, 1, |
| 899 | | fgcolor); |
| | 944 | fgcolor, 0); |
| 900 | 945 | } |
| 901 | 946 | } |
| 902 | 947 | SDL_UpdateRect(screen, s->xpos, s->ytop, 1, s->height); |
| … |
… |
static void toggle_audio_display(VideoState *is) |
| 2828 | 2873 | is->show_mode = (is->show_mode + 1) % SHOW_MODE_NB; |
| 2829 | 2874 | fill_rectangle(screen, |
| 2830 | 2875 | is->xleft, is->ytop, is->width, is->height, |
| 2831 | | bgcolor); |
| 2832 | | SDL_UpdateRect(screen, is->xleft, is->ytop, is->width, is->height); |
| | 2876 | bgcolor, 1); |
| 2833 | 2877 | } |
| 2834 | 2878 | |
| 2835 | 2879 | /* handle an event sent by the GUI */ |