From 527a0ef4d6619884a29de87f6ad51e85e8405032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Thu, 26 Aug 2010 16:55:42 +0000 Subject: [PATCH] Hopefully fixed videos on non-32bpp displays. --- hch/CVideoHandler.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hch/CVideoHandler.cpp b/hch/CVideoHandler.cpp index 82e9af68f..944a8a1ba 100644 --- a/hch/CVideoHandler.cpp +++ b/hch/CVideoHandler.cpp @@ -732,9 +732,18 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay) codecContext->pix_fmt, codecContext->width, codecContext->height, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL); } else { + PixelFormat screenFormat = PIX_FMT_NONE; + switch(screen->format->BytesPerPixel) + { + case 2: screenFormat = PIX_FMT_RGB565; break; + case 3: screenFormat = PIX_FMT_RGB24; break; + case 4: screenFormat = PIX_FMT_RGB32; break; + default: return false; + } + sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt, codecContext->width, codecContext->height, - PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL); + screenFormat, SWS_BICUBIC, NULL, NULL, NULL); } if (sws == NULL)