From 404aa1bdcf024a1dbf93daf1101495cc2eb1372c Mon Sep 17 00:00:00 2001 From: ksorim Date: Fri, 22 Mar 2002 07:35:48 +0000 Subject: [PATCH] Fix for OSD when width != pitch git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5261 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_sdl.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/libvo/vo_sdl.c b/libvo/vo_sdl.c index b1379d9efe..94970fd659 100644 --- a/libvo/vo_sdl.c +++ b/libvo/vo_sdl.c @@ -350,55 +350,62 @@ static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_IYUV: - vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->width); + vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0]); break; case IMGFMT_YUY2: - case IMGFMT_YVYU: - vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0),2*priv->width); + case IMGFMT_YVYU: + x0 *= 2; + vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0]); break; case IMGFMT_UYVY: - vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0)+1,2*priv->width); + x0 *= 2; + vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0]); break; default: - if(priv->dblit) + if(priv->dblit) { + x0 *= priv->surface->format->BytesPerPixel; switch(priv->format) { case IMGFMT_RGB15: case IMGFMT_BGR15: - vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+2*(y0*priv->width+x0),2*priv->width); + vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+y0*priv->surface->pitch+x0,priv->surface->pitch); break; case IMGFMT_RGB16: case IMGFMT_BGR16: - vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+2*(y0*priv->width+x0),2*priv->width); + vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+y0*priv->surface->pitch+x0,priv->surface->pitch); break; case IMGFMT_RGB24: case IMGFMT_BGR24: - vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+3*(y0*priv->width+x0),3*priv->width); + vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+y0*priv->surface->pitch+x0,priv->surface->pitch); break; case IMGFMT_RGB32: case IMGFMT_BGR32: - vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+4*(y0*priv->width+x0),4*priv->width); + vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+y0*priv->surface->pitch+x0,priv->surface->pitch); break; } - else - switch(priv->format) { + } + else { + x0 *= priv->rgbsurface->format->BytesPerPixel; + switch(priv->format) { case IMGFMT_RGB15: case IMGFMT_BGR15: - vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+2*(y0*priv->width+x0),2*priv->width); + vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch); break; case IMGFMT_RGB16: case IMGFMT_BGR16: - vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+2*(y0*priv->width+x0),2*priv->width); + vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch); break; case IMGFMT_RGB24: case IMGFMT_BGR24: - vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+3*(y0*priv->width+x0),3*priv->width); + vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch); break; case IMGFMT_RGB32: case IMGFMT_BGR32: - vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+4*(y0*priv->width+x0),4*priv->width); + vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch); break; - } + } + } + } }