From 9cc55070791506113126eb303e4647348813b119 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 10 Jun 2016 02:32:47 +0200 Subject: [PATCH] vo_sdl: fix pixel formats. There were two mistakes: - SDL's RGB565 is always equivalent to ffmpeg's RGB565 (both are packed 16bit native-endian integers in RGB=565 form) - this was wrongly reversed on big endian platforms. - SDL's RGB888 doesn't actually mean RGB24, but XRGB8888 (i.e. 32bit packed integer, top 8 bits unused). - Use RGB0 not RGBA when there is no alpha. --- video/out/vo_sdl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 9d34564587..dd18f6e9c4 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -58,30 +58,27 @@ const struct formatmap_entry formats[] = { {SDL_PIXELFORMAT_UYVY, IMGFMT_UYVY, 0}, //{SDL_PIXELFORMAT_YVYU, IMGFMT_YVYU, 0}, #if BYTE_ORDER == BIG_ENDIAN - {SDL_PIXELFORMAT_RGBX8888, IMGFMT_RGBA, 0}, // has no alpha -> bad for OSD - {SDL_PIXELFORMAT_BGRX8888, IMGFMT_BGRA, 0}, // has no alpha -> bad for OSD + {SDL_PIXELFORMAT_RGB888, IMGFMT_0RGB, 0}, // RGB888 means XRGB8888 + {SDL_PIXELFORMAT_RGBX8888, IMGFMT_RGB0, 0}, // has no alpha -> bad for OSD + {SDL_PIXELFORMAT_BGR888, IMGFMT_0BGR, 0}, // BGR888 means XBGR8888 + {SDL_PIXELFORMAT_BGRX8888, IMGFMT_BGR0, 0}, // has no alpha -> bad for OSD {SDL_PIXELFORMAT_ARGB8888, IMGFMT_ARGB, 1}, // matches SUBBITMAP_RGBA {SDL_PIXELFORMAT_RGBA8888, IMGFMT_RGBA, 1}, {SDL_PIXELFORMAT_ABGR8888, IMGFMT_ABGR, 1}, {SDL_PIXELFORMAT_BGRA8888, IMGFMT_BGRA, 1}, - {SDL_PIXELFORMAT_RGB24, IMGFMT_RGB24, 0}, - {SDL_PIXELFORMAT_BGR24, IMGFMT_BGR24, 0}, - {SDL_PIXELFORMAT_RGB888, IMGFMT_RGB24, 0}, - {SDL_PIXELFORMAT_BGR888, IMGFMT_BGR24, 0}, - {SDL_PIXELFORMAT_BGR565, IMGFMT_RGB565, 0}, #else - {SDL_PIXELFORMAT_RGBX8888, IMGFMT_ABGR, 0}, // has no alpha -> bad for OSD - {SDL_PIXELFORMAT_BGRX8888, IMGFMT_ARGB, 0}, // has no alpha -> bad for OSD + {SDL_PIXELFORMAT_RGB888, IMGFMT_BGR0, 0}, // RGB888 means XRGB8888 + {SDL_PIXELFORMAT_RGBX8888, IMGFMT_0BGR, 0}, // has no alpha -> bad for OSD + {SDL_PIXELFORMAT_BGR888, IMGFMT_RGB0, 0}, // BGR888 means XBGR8888 + {SDL_PIXELFORMAT_BGRX8888, IMGFMT_0RGB, 0}, // has no alpha -> bad for OSD {SDL_PIXELFORMAT_ARGB8888, IMGFMT_BGRA, 1}, // matches SUBBITMAP_RGBA {SDL_PIXELFORMAT_RGBA8888, IMGFMT_ABGR, 1}, {SDL_PIXELFORMAT_ABGR8888, IMGFMT_RGBA, 1}, {SDL_PIXELFORMAT_BGRA8888, IMGFMT_ARGB, 1}, +#endif {SDL_PIXELFORMAT_RGB24, IMGFMT_RGB24, 0}, {SDL_PIXELFORMAT_BGR24, IMGFMT_BGR24, 0}, - {SDL_PIXELFORMAT_RGB888, IMGFMT_BGR24, 0}, - {SDL_PIXELFORMAT_BGR888, IMGFMT_RGB24, 0}, {SDL_PIXELFORMAT_RGB565, IMGFMT_RGB565, 0}, -#endif }; struct keymap_entry {