[FFmpeg-devel] [PATCH 1/2] ffplay: do not allow wider window than 16383

Marton Balint cus at passwd.hu
Wed May 29 23:38:50 CEST 2013


SDL surface pitch is 16bit, to avoid possible overflows, we limit the window
width to 16383. Fixes ticket #2428.

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 ffplay.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index 80c3091..2b85c14 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1070,7 +1070,7 @@ static int video_open(VideoState *is, int force_set_video_mode, VideoPicture *vp
     if (screen && is->width == screen->w && screen->w == w
        && is->height== screen->h && screen->h == h && !force_set_video_mode)
         return 0;
-    screen = SDL_SetVideoMode(w, h, 0, flags);
+    screen = SDL_SetVideoMode(FFMIN(16383, w), h, 0, flags);
     if (!screen) {
         fprintf(stderr, "SDL: could not set video mode - exiting\n");
         do_exit(is);
@@ -3237,10 +3237,14 @@ static void event_loop(VideoState *cur_stream)
                 }
             break;
         case SDL_VIDEORESIZE:
-                screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,
+                screen = SDL_SetVideoMode(FFMIN(16383, event.resize.w), event.resize.h, 0,
                                           SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);
-                screen_width  = cur_stream->width  = event.resize.w;
-                screen_height = cur_stream->height = event.resize.h;
+                if (!screen) {
+                    fprintf(stderr, "Failed to set video mode\n");
+                    do_exit(cur_stream);
+                }
+                screen_width  = cur_stream->width  = screen->w;
+                screen_height = cur_stream->height = screen->h;
                 cur_stream->force_refresh = 1;
             break;
         case SDL_QUIT:
-- 
1.8.1.4



More information about the ffmpeg-devel mailing list