[FFmpeg-cvslog] ffplay: fill the unused part of the window with black
Marton Balint
git at videolan.org
Thu Nov 1 22:15:36 CET 2012
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Sep 22 16:42:13 2012 +0200| [65f6c42a9f12211aff4691ffb17c7cbc77972d87] | committer: Marton Balint
ffplay: fill the unused part of the window with black
Should fix ticket #1667.
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=65f6c42a9f12211aff4691ffb17c7cbc77972d87
---
ffplay.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/ffplay.c b/ffplay.c
index 07d7836..90c18f4 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -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;
+ }
}
}
More information about the ffmpeg-cvslog
mailing list