[MPlayer-cvslog] r35144 - in trunk/libvo: video_out.h vo_dga.c vo_fbdev.c vo_fbdev2.c vo_gl2.c vo_sdl.c vo_x11.c vo_xv.c
reimar
subversion at mplayerhq.hu
Sun Sep 2 23:51:42 CEST 2012
Author: reimar
Date: Sun Sep 2 23:51:42 2012
New Revision: 35144
Log:
Avoid some code duplication related to drawing the OSD.
This also fixes some bugs in sdl and xv when drawing
OSD on uyvy frames.
Modified:
trunk/libvo/video_out.h
trunk/libvo/vo_dga.c
trunk/libvo/vo_fbdev.c
trunk/libvo/vo_fbdev2.c
trunk/libvo/vo_gl2.c
trunk/libvo/vo_sdl.c
trunk/libvo/vo_x11.c
trunk/libvo/vo_xv.c
Modified: trunk/libvo/video_out.h
==============================================================================
--- trunk/libvo/video_out.h Sun Sep 2 23:17:03 2012 (r35143)
+++ trunk/libvo/video_out.h Sun Sep 2 23:51:42 2012 (r35144)
@@ -279,6 +279,14 @@ void calc_src_dst_rects(int src_width, i
struct vo_rect *borders, const struct vo_rect *crop);
void vo_mouse_movement(int posx, int posy);
+static inline int pixel_stride(unsigned fmt) {
+ if (IMGFMT_IS_RGB(fmt))
+ return (IMGFMT_RGB_DEPTH(fmt) + 7) / 8;
+ if (IMGFMT_IS_BGR(fmt))
+ return (IMGFMT_BGR_DEPTH(fmt) + 7) / 8;
+ return IMGFMT_IS_YUVP16(fmt) ? 2 : 1;
+}
+
static inline int aspect_scaling(void)
{
return vo_fs;
Modified: trunk/libvo/vo_dga.c
==============================================================================
--- trunk/libvo/vo_dga.c Sun Sep 2 23:17:03 2012 (r35143)
+++ trunk/libvo/vo_dga.c Sun Sep 2 23:51:42 2012 (r35144)
@@ -245,31 +245,15 @@ static void draw_alpha(int x0, int y0, i
char *d;
unsigned int offset;
int buffer_stride;
+ int bpp = pixel_stride(vo_dga_src_format);
+ vo_draw_alpha_func draw = vo_get_draw_alpha(vo_dga_src_format);
offset = vo_dga_width * y0 + x0;
- buffer_stride = vo_dga_width;
+ buffer_stride = vo_dga_width * bpp;
d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
+ d += bpp * offset;
- switch (HW_MODE.vdm_mplayer_depth)
- {
-
- case 32:
- vo_draw_alpha_rgb32(w, h, src, srca, stride, d + 4 * offset,
- 4 * buffer_stride);
- break;
- case 24:
- vo_draw_alpha_rgb24(w, h, src, srca, stride, d + 3 * offset,
- 3 * buffer_stride);
- break;
- case 15:
- vo_draw_alpha_rgb15(w, h, src, srca, stride, d + 2 * offset,
- 2 * buffer_stride);
- break;
- case 16:
- vo_draw_alpha_rgb16(w, h, src, srca, stride, d + 2 * offset,
- 2 * buffer_stride);
- break;
- }
+ if (draw) draw(w, h, src, srca, stride, d, buffer_stride);
}
Modified: trunk/libvo/vo_fbdev.c
==============================================================================
--- trunk/libvo/vo_fbdev.c Sun Sep 2 23:17:03 2012 (r35143)
+++ trunk/libvo/vo_fbdev.c Sun Sep 2 23:51:42 2012 (r35144)
@@ -848,25 +848,7 @@ static int config(uint32_t width, uint32
mp_msg(MSGT_VO, MSGL_WARN, "requested %d bpp, got %d bpp!!!\n",
fb_bpp_we_want, fb_bpp);
- switch (fb_bpp) {
- case 32:
- draw_alpha_p = vo_draw_alpha_rgb32;
- break;
- case 24:
- draw_alpha_p = vo_draw_alpha_rgb24;
- break;
- case 16:
- draw_alpha_p = vo_draw_alpha_rgb16;
- break;
- case 15:
- draw_alpha_p = vo_draw_alpha_rgb15;
- break;
- case 12:
- draw_alpha_p = vo_draw_alpha_rgb12;
- break;
- default:
- return 1;
- }
+ draw_alpha_p = vo_get_draw_alpha(format);
fb_xres = fb_vinfo.xres;
fb_yres = fb_vinfo.yres;
Modified: trunk/libvo/vo_fbdev2.c
==============================================================================
--- trunk/libvo/vo_fbdev2.c Sun Sep 2 23:17:03 2012 (r35143)
+++ trunk/libvo/vo_fbdev2.c Sun Sep 2 23:51:42 2012 (r35144)
@@ -229,14 +229,7 @@ static int config(uint32_t width, uint32
return 1;
}
- switch (fb_bpp) {
- case 32: draw_alpha_p = vo_draw_alpha_rgb32; break;
- case 24: draw_alpha_p = vo_draw_alpha_rgb24; break;
- case 16: draw_alpha_p = vo_draw_alpha_rgb16; break;
- case 15: draw_alpha_p = vo_draw_alpha_rgb15; break;
- case 12: draw_alpha_p = vo_draw_alpha_rgb12; break;
- default: return 1;
- }
+ draw_alpha_p = vo_get_draw_alpha(format);
if (vo_config_count == 0) {
if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
Modified: trunk/libvo/vo_gl2.c
==============================================================================
--- trunk/libvo/vo_gl2.c Sun Sep 2 23:17:03 2012 (r35143)
+++ trunk/libvo/vo_gl2.c Sun Sep 2 23:51:42 2012 (r35144)
@@ -89,9 +89,6 @@ static int use_yuv;
static int is_yuv;
static int use_glFinish;
-static void (*draw_alpha_fnc)
- (int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride);
-
/* The squares that are tiled to make up the game screen polygon */
@@ -456,23 +453,11 @@ static void resize(int x,int y){
glLoadIdentity();
}
-static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
- vo_draw_alpha_rgb32(w,h,src,srca,stride,ImageData+4*(y0*image_width+x0),4*image_width);
-}
-
-static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
- vo_draw_alpha_rgb24(w,h,src,srca,stride,ImageData+3*(y0*image_width+x0),3*image_width);
-}
-
-static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
- vo_draw_alpha_rgb16(w,h,src,srca,stride,ImageData+2*(y0*image_width+x0),2*image_width);
-}
-
-static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
- vo_draw_alpha_rgb15(w,h,src,srca,stride,ImageData+2*(y0*image_width+x0),2*image_width);
-}
-
-static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
+static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
+ int bpp = pixel_stride(image_format);
+ vo_draw_alpha_func draw = vo_get_draw_alpha(image_format);
+ if (!draw) return;
+ draw(w,h,src,srca,stride,ImageData+bpp*(y0*image_width+x0),bpp*image_width);
}
#ifdef CONFIG_GL_WIN32
@@ -665,19 +650,6 @@ config(uint32_t width, uint32_t height,
image_bytes=(image_bpp+7)/8;
- draw_alpha_fnc=draw_alpha_null;
-
- switch(image_bpp) {
- case 15:
- draw_alpha_fnc=draw_alpha_15; break;
- case 16:
- draw_alpha_fnc=draw_alpha_16; break;
- case 24:
- draw_alpha_fnc=draw_alpha_24; break;
- case 32:
- draw_alpha_fnc=draw_alpha_32; break;
- }
-
if (initGl(vo_dwidth, vo_dheight) == -1)
return -1;
@@ -730,7 +702,7 @@ static void check_events(void)
static void draw_osd(void)
{
if (ImageData)
- vo_draw_text(image_width,image_height,draw_alpha_fnc);
+ vo_draw_text(image_width,image_height,draw_alpha);
}
static void
Modified: trunk/libvo/vo_sdl.c
==============================================================================
--- trunk/libvo/vo_sdl.c Sun Sep 2 23:17:03 2012 (r35143)
+++ trunk/libvo/vo_sdl.c Sun Sep 2 23:51:42 2012 (r35144)
@@ -233,6 +233,8 @@ static void expand_rect(SDL_Rect* rect,
static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
struct sdl_priv_s *priv = &sdl_priv;
+ vo_draw_alpha_func draw = vo_get_draw_alpha(priv->format);
+ if (!draw) return;
if(priv->osd_has_changed) {
/* OSD did change. Store a bounding box of everything drawn into the OSD */
@@ -268,67 +270,25 @@ static void draw_alpha(int x0,int y0, in
return;
}
+ x0 *= pixel_stride(priv->format);
switch(priv->format) {
- 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->overlay->pitches[0]);
- break;
case IMGFMT_YUY2:
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:
- 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]);
+ case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+ draw(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) {
- 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)+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)+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)+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)+y0*priv->surface->pitch+x0,priv->surface->pitch);
- break;
- }
+ draw(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+y0*priv->surface->pitch+x0,priv->surface->pitch);
}
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)+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)+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)+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)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch);
- break;
+ draw(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch);
}
}
-
- }
}
Modified: trunk/libvo/vo_x11.c
==============================================================================
--- trunk/libvo/vo_x11.c Sun Sep 2 23:17:03 2012 (r35143)
+++ trunk/libvo/vo_x11.c Sun Sep 2 23:51:42 2012 (r35144)
@@ -66,9 +66,7 @@ static const vo_info_t info = {
const LIBVO_EXTERN(x11)
/* private prototypes */
-static void (*draw_alpha_fnc) (int x0, int y0, int w, int h,
- unsigned char *src, unsigned char *srca,
- int stride);
+vo_draw_alpha_func draw_alpha_func;
/* local data */
static unsigned char *ImageData;
@@ -110,42 +108,13 @@ static void check_events(void)
flip_page();
}
-static void draw_alpha_32(int x0, int y0, int w, int h, unsigned char *src,
- unsigned char *srca, int stride)
-{
- vo_draw_alpha_rgb32(w, h, src, srca, stride,
- ImageData + 4 * (y0 * image_width + x0),
- 4 * image_width);
-}
-
-static void draw_alpha_24(int x0, int y0, int w, int h, unsigned char *src,
- unsigned char *srca, int stride)
-{
- vo_draw_alpha_rgb24(w, h, src, srca, stride,
- ImageData + 3 * (y0 * image_width + x0),
- 3 * image_width);
-}
-
-static void draw_alpha_16(int x0, int y0, int w, int h, unsigned char *src,
- unsigned char *srca, int stride)
-{
- vo_draw_alpha_rgb16(w, h, src, srca, stride,
- ImageData + 2 * (y0 * image_width + x0),
- 2 * image_width);
-}
-
-static void draw_alpha_15(int x0, int y0, int w, int h, unsigned char *src,
- unsigned char *srca, int stride)
-{
- vo_draw_alpha_rgb15(w, h, src, srca, stride,
- ImageData + 2 * (y0 * image_width + x0),
- 2 * image_width);
-}
-
-static void draw_alpha_null(int x0, int y0, int w, int h,
- unsigned char *src, unsigned char *srca,
- int stride)
+static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
+ unsigned char *srca, int stride)
{
+ int bpp = pixel_stride(out_format);
+ draw_alpha_func(w, h, src, srca, stride,
+ ImageData + bpp * (y0 * image_width + x0),
+ bpp * image_width);
}
static struct SwsContext *swsContext = NULL;
@@ -406,24 +375,9 @@ static int config(uint32_t width, uint32
return -1;
}
out_format = fmte->mpfmt;
- switch ((bpp = myximage->bits_per_pixel))
- {
- case 24:
- draw_alpha_fnc = draw_alpha_24;
- break;
- case 32:
- draw_alpha_fnc = draw_alpha_32;
- break;
- case 15:
- case 16:
- if (depth == 15)
- draw_alpha_fnc = draw_alpha_15;
- else
- draw_alpha_fnc = draw_alpha_16;
- break;
- default:
- draw_alpha_fnc = draw_alpha_null;
- }
+ draw_alpha_func = vo_get_draw_alpha(out_format);
+
+ bpp = myximage->bits_per_pixel;
out_offset = 0;
// We can easily "emulate" non-native RGB32 and BGR32
if (out_format == (IMGFMT_BGR32 | 128) || out_format == (IMGFMT_RGB32 | 128)) {
@@ -482,7 +436,8 @@ static void Display_Image(XImage * myxim
static void draw_osd(void)
{
- vo_draw_text(image_width, image_height, draw_alpha_fnc);
+ if (draw_alpha_func)
+ vo_draw_text(image_width, image_height, draw_alpha);
}
static void flip_page(void)
Modified: trunk/libvo/vo_xv.c
==============================================================================
--- trunk/libvo/vo_xv.c Sun Sep 2 23:17:03 2012 (r35143)
+++ trunk/libvo/vo_xv.c Sun Sep 2 23:51:42 2012 (r35144)
@@ -107,9 +107,7 @@ static struct vo_rect src_rect;
static struct vo_rect dst_rect;
static uint32_t max_width = 0, max_height = 0; // zero means: not set
-static void (*draw_alpha_fnc) (int x0, int y0, int w, int h,
- unsigned char *src, unsigned char *srca,
- int stride);
+vo_draw_alpha_func draw_alpha_func;
static void fixup_osd_position(int *x0, int *y0, int *w, int *h)
{
@@ -120,48 +118,20 @@ static void fixup_osd_position(int *x0,
*y0 = FFMIN(*y0, image_height - *h);
}
-static void draw_alpha_yv12(int x0, int y0, int w, int h,
+static void draw_alpha(int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
+ if (!draw_alpha_func) return;
fixup_osd_position(&x0, &y0, &w, &h);
- vo_draw_alpha_yv12(w, h, src, srca, stride,
+ x0 *= pixel_stride(xv_format);
+ draw_alpha_func(w, h, src, srca, stride,
xvimage[current_buf]->data +
xvimage[current_buf]->offsets[0] +
xvimage[current_buf]->pitches[0] * y0 + x0,
xvimage[current_buf]->pitches[0]);
}
-static void draw_alpha_yuy2(int x0, int y0, int w, int h,
- unsigned char *src, unsigned char *srca,
- int stride)
-{
- fixup_osd_position(&x0, &y0, &w, &h);
- vo_draw_alpha_yuy2(w, h, src, srca, stride,
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y0 + 2 * x0,
- xvimage[current_buf]->pitches[0]);
-}
-
-static void draw_alpha_uyvy(int x0, int y0, int w, int h,
- unsigned char *src, unsigned char *srca,
- int stride)
-{
- fixup_osd_position(&x0, &y0, &w, &h);
- vo_draw_alpha_yuy2(w, h, src, srca, stride,
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y0 + 2 * x0 + 1,
- xvimage[current_buf]->pitches[0]);
-}
-
-static void draw_alpha_null(int x0, int y0, int w, int h,
- unsigned char *src, unsigned char *srca,
- int stride)
-{
-}
-
static void deallocate_xvimage(int foo);
@@ -268,23 +238,7 @@ static int config(uint32_t width, uint32
mp_msg(MSGT_VO, MSGL_V, "using Xvideo port %d for hw scaling\n",
xv_port);
- switch (xv_format)
- {
- case IMGFMT_YV12:
- case IMGFMT_I420:
- case IMGFMT_IYUV:
- draw_alpha_fnc = draw_alpha_yv12;
- break;
- case IMGFMT_YUY2:
- case IMGFMT_YVYU:
- draw_alpha_fnc = draw_alpha_yuy2;
- break;
- case IMGFMT_UYVY:
- draw_alpha_fnc = draw_alpha_uyvy;
- break;
- default:
- draw_alpha_fnc = draw_alpha_null;
- }
+ draw_alpha_func = vo_get_draw_alpha(xv_format);
if (vo_config_count)
for (current_buf = 0; current_buf < num_buffers; ++current_buf)
@@ -407,7 +361,7 @@ static void draw_osd(void)
{
vo_draw_text(image_width -
image_width * vo_panscan_x / (vo_dwidth + vo_panscan_x),
- image_height, draw_alpha_fnc);
+ image_height, draw_alpha);
}
static void flip_page(void)
More information about the MPlayer-cvslog
mailing list