Mercurial > mplayer.hg
diff gui/win32/skinload.c @ 32028:9e6fdede8ece
gui: remove direct usage of rgb2rgb interface, use swscale instead
author | ramiro |
---|---|
date | Thu, 09 Sep 2010 14:52:37 +0000 |
parents | 9ba6d4487292 |
children | 8fa2f43cb760 |
line wrap: on
line diff
--- a/gui/win32/skinload.c Thu Sep 09 14:50:51 2010 +0000 +++ b/gui/win32/skinload.c Thu Sep 09 14:52:37 2010 +0000 @@ -28,8 +28,8 @@ #include "mp_msg.h" #include "cpudetect.h" -#include "libswscale/rgb2rgb.h" #include "libswscale/swscale.h" +#include "libavcore/imgutils.h" #include "gui.h" #include "gui/bitmap.h" @@ -104,13 +104,6 @@ return NULL; } -static inline int get_sws_cpuflags(void) -{ - return (gCpuCaps.hasMMX ? SWS_CPU_CAPS_MMX : 0) | - (gCpuCaps.hasMMX2 ? SWS_CPU_CAPS_MMX2 : 0) | - (gCpuCaps.has3DNow ? SWS_CPU_CAPS_3DNOW : 0); -} - /* reads a complete image as is into image buffer */ static image *pngRead(skin_t *skin, unsigned char *fname) { @@ -163,10 +156,22 @@ if (skin->desktopbpp == 32) bf->data = bmp.Image; else { + const uint8_t *src[4] = { bmp.Image, NULL, NULL, NULL}; + int src_stride[4] = { 4 * bmp.Width, 0, 0, 0 }; + uint8_t *dst[4] = { NULL, NULL, NULL, NULL }; + int dst_stride[4]; + enum PixelFormat out_pix_fmt; + struct SwsContext *sws; + if (skin->desktopbpp == 16) out_pix_fmt = PIX_FMT_RGB555; + else if (skin->desktopbpp == 24) out_pix_fmt = PIX_FMT_RGB24; + av_image_fill_linesizes(dst_stride, out_pix_fmt, bmp.Width); + sws = sws_getContext(bmp.Width, bmp.Height, PIX_FMT_RGB32, + bmp.Width, bmp.Height, out_pix_fmt, + SWS_POINT, NULL, NULL, NULL); bf->data = malloc(bf->size); - rgb32tobgr32(bmp.Image, bmp.Image, bmp.ImageSize); - if(skin->desktopbpp == 16) rgb32tobgr15(bmp.Image, bf->data, bmp.ImageSize); - else if(skin->desktopbpp == 24) rgb32tobgr24(bmp.Image, bf->data, bmp.ImageSize); + dst[0] = bf->data; + sws_scale(sws, src, src_stride, 0, bmp.Height, dst, dst_stride); + sws_freeContext(sws); free(bmp.Image); } return bf; @@ -620,8 +625,6 @@ char *desc = calloc(1, MAX_LINESIZE); window* mywindow = NULL; - /* init swscaler */ - sws_rgb2rgb_init(get_sws_cpuflags()); /* setup funcs */ skin->freeskin = freeskin; skin->pngRead = pngRead;