diff options
author | Marton Balint <cus@passwd.hu> | 2012-09-22 16:42:13 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2012-11-01 15:46:18 +0100 |
commit | 65f6c42a9f12211aff4691ffb17c7cbc77972d87 (patch) | |
tree | 74949541f8f8ce799ebc67fa7e8c240d5f6760ca /ffplay.c | |
parent | 00b70f8d29960096e13da6f273e0d6bda8b83494 (diff) | |
download | ffmpeg-65f6c42a9f12211aff4691ffb17c7cbc77972d87.tar.gz |
ffplay: fill the unused part of the window with black
Should fix ticket #1667.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'ffplay.c')
-rw-r--r-- | ffplay.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -234,6 +234,7 @@ typedef struct VideoState { #if !CONFIG_AVFILTER struct SwsContext *img_convert_ctx; #endif + SDL_Rect last_display_rect; char filename[1024]; int width, height, xleft, ytop; @@ -461,6 +462,42 @@ static inline void fill_rectangle(SDL_Surface *screen, SDL_UpdateRect(screen, x, y, w, h); } +/* draw only the border of a rectangle */ +static void fill_border(int xleft, int ytop, int width, int height, int x, int y, int w, int h, int color, int update) +{ + int w1, w2, h1, h2; + + /* fill the background */ + w1 = x; + if (w1 < 0) + w1 = 0; + w2 = width - (x + w); + if (w2 < 0) + w2 = 0; + h1 = y; + if (h1 < 0) + h1 = 0; + h2 = height - (y + h); + if (h2 < 0) + h2 = 0; + fill_rectangle(screen, + xleft, ytop, + w1, height, + color, update); + fill_rectangle(screen, + xleft + width - w2, ytop, + w2, height, + color, update); + fill_rectangle(screen, + xleft + w1, ytop, + width - w1 - w2, h1, + color, update); + fill_rectangle(screen, + xleft + w1, ytop + height - h2, + width - w1 - w2, h2, + color, update); +} + #define ALPHA_BLEND(a, oldp, newp, s)\ ((((oldp << s) * (255 - (a))) + (newp * (a))) / (255 << s)) @@ -761,6 +798,12 @@ static void video_image_display(VideoState *is) calculate_display_rect(&rect, is->xleft, is->ytop, is->width, is->height, vp); SDL_DisplayYUVOverlay(vp->bmp, &rect); + + 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) { + int bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); + fill_border(is->xleft, is->ytop, is->width, is->height, rect.x, rect.y, rect.w, rect.h, bgcolor, 1); + is->last_display_rect = rect; + } } } |