diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2008-12-06 02:16:51 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2008-12-06 02:16:51 +0200 |
commit | cb3dc68691f4d01426c7abdd9e7bc16f8d461a9f (patch) | |
tree | 66106f966a36721c37c1e22221e85110cbefa255 /libvo | |
parent | 8c144171bb80dd3d1f7161b97675e78cad00bc65 (diff) | |
parent | c6ef66231818b90c75f84b9407730647c93f040c (diff) | |
download | mpv-cb3dc68691f4d01426c7abdd9e7bc16f8d461a9f.tar.bz2 mpv-cb3dc68691f4d01426c7abdd9e7bc16f8d461a9f.tar.xz |
Merge svn changes up to r28103
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/gl_common.c | 13 | ||||
-rw-r--r-- | libvo/gl_common.h | 11 | ||||
-rw-r--r-- | libvo/vo_gl.c | 68 | ||||
-rw-r--r-- | libvo/x11_common.c | 7 |
4 files changed, 84 insertions, 15 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c index 0df3e2e74a..7ed22bd8e2 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -78,6 +78,8 @@ void (APIENTRY *ProgramEnvParameter4f)(GLenum, GLuint, GLfloat, GLfloat, int (APIENTRY *SwapInterval)(int); void (APIENTRY *TexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +void* (APIENTRY *AllocateMemoryMESA)(void *, int, size_t, float, float, float); +void (APIENTRY *FreeMemoryMESA)(void *, int, void *); /** \} */ // end of glextfunctions group //! \defgroup glgeneral OpenGL general helper functions @@ -213,6 +215,13 @@ int glFindFormat(uint32_t fmt, int *bpp, GLint *gl_texfmt, *gl_format = GL_LUMINANCE; *gl_type = GL_UNSIGNED_BYTE; break; + case IMGFMT_UYVY: + case IMGFMT_YUY2: + *gl_texfmt = GL_YCBCR_MESA; + *bpp = 16; + *gl_format = GL_YCBCR_MESA; + *gl_type = fmt == IMGFMT_UYVY ? GL_UNSIGNED_SHORT_8_8 : GL_UNSIGNED_SHORT_8_8_REV; + break; #if 0 // we do not support palettized formats, although the format the // swscale produces works @@ -306,6 +315,8 @@ static const extfunc_desc_t extfuncs[] = { {&ProgramEnvParameter4f, "_program", {"glProgramEnvParameter4fARB", NULL}}, {&SwapInterval, "_swap_control", {"glXSwapInterval", "glXSwapIntervalEXT", "glXSwapIntervalSGI", "wglSwapInterval", "wglSwapIntervalEXT", "wglSwapIntervalSGI", NULL}}, {&TexImage3D, NULL, {"glTexImage3D", NULL}}, + {&AllocateMemoryMESA, "GLX_MESA_allocate_memory", {"glXAllocateMemoryMESA", NULL}}, + {&FreeMemoryMESA, "GLX_MESA_allocate_memory", {"glXFreeMemoryMESA", NULL}}, {NULL} }; @@ -485,6 +496,8 @@ int glFmt2bpp(GLenum format, GLenum type) { case GL_LUMINANCE: case GL_ALPHA: return component_size; + case GL_YCBCR_MESA: + return 2; case GL_RGB: case GL_BGR: return 3 * component_size; diff --git a/libvo/gl_common.h b/libvo/gl_common.h index fbcd49db88..2fcb8568ad 100644 --- a/libvo/gl_common.h +++ b/libvo/gl_common.h @@ -210,6 +210,15 @@ #ifndef GL_UNSIGNED_SHORT_1_5_5_5_REV #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 #endif +#ifndef GL_UNSIGNED_SHORT_8_8 +#define GL_UNSIGNED_SHORT_8_8 0x85BA +#endif +#ifndef GL_UNSIGNED_SHORT_8_8_REV +#define GL_UNSIGNED_SHORT_8_8_REV 0x85BB +#endif +#ifndef GL_YCBCR_MESA +#define GL_YCBCR_MESA 0x8757 +#endif #ifndef GL_RGB32F #define GL_RGB32F 0x8815 #endif @@ -375,5 +384,7 @@ extern void (APIENTRY *ProgramEnvParameter4f)(GLenum, GLuint, GLfloat, GLfloat, extern int (APIENTRY *SwapInterval)(int); extern void (APIENTRY *TexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +extern void* (APIENTRY *AllocateMemoryMESA)(void *, int, size_t, float, float, float); +extern void (APIENTRY *FreeMemoryMESA)(void *, int, void *); #endif /* MPLAYER_GL_COMMON_H */ diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 792376c8bb..a9a2690756 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -71,6 +71,7 @@ static int eosdtexCnt; static int osd_color; static int use_aspect; +static int use_ycbcr; static int use_yuv; static int lscale; static int cscale; @@ -84,6 +85,7 @@ static uint32_t image_format; static int many_fmts; static int ati_hack; static int force_pbo; +static int mesa_buffer; static int use_glFinish; static int swap_interval; static GLenum gl_target; @@ -96,6 +98,8 @@ static int gl_buffersize; static int gl_buffersize_uv; static void *gl_bufferptr; static void *gl_bufferptr_uv[2]; +static int mesa_buffersize; +static void *mesa_bufferptr; static GLuint fragprog; static GLuint default_texs[22]; static char *custom_prog; @@ -388,6 +392,11 @@ static void uninitGl(void) { DeleteBuffers(2, gl_buffer_uv); gl_buffer_uv[0] = gl_buffer_uv[1] = 0; gl_buffersize_uv = 0; gl_bufferptr_uv[0] = gl_bufferptr_uv[1] = 0; +#ifndef GL_WIN32 + if (mesa_bufferptr) + FreeMemoryMESA(mDisplay, mScreen, mesa_bufferptr); +#endif + mesa_bufferptr = NULL; err_shown = 0; } @@ -680,6 +689,7 @@ static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) } static uint32_t get_image(mp_image_t *mpi) { + int needed_size; if (!GenBuffers || !BindBuffer || !BufferData || !MapBuffer) { if (!err_shown) mp_msg(MSGT_VO, MSGL_ERR, "[gl] extensions missing for dr\n" @@ -692,19 +702,33 @@ static uint32_t get_image(mp_image_t *mpi) { mpi->width = texture_width; mpi->height = texture_height; } - if (!gl_buffer) - GenBuffers(1, &gl_buffer); - BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer); mpi->stride[0] = mpi->width * mpi->bpp / 8; - if (mpi->stride[0] * mpi->height > gl_buffersize) { - BufferData(GL_PIXEL_UNPACK_BUFFER, mpi->stride[0] * mpi->height, - NULL, GL_DYNAMIC_DRAW); - gl_buffersize = mpi->stride[0] * mpi->height; + needed_size = mpi->stride[0] * mpi->height; + if (mesa_buffer) { +#ifndef GL_WIN32 + if (mesa_bufferptr && needed_size > mesa_buffersize) { + FreeMemoryMESA(mDisplay, mScreen, mesa_bufferptr); + mesa_bufferptr = NULL; + } + if (!mesa_bufferptr) + mesa_bufferptr = AllocateMemoryMESA(mDisplay, mScreen, needed_size, 0, 0, 0); + mesa_buffersize = needed_size; +#endif + mpi->planes[0] = mesa_bufferptr; + } else { + if (!gl_buffer) + GenBuffers(1, &gl_buffer); + BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer); + if (needed_size > gl_buffersize) { + gl_buffersize = needed_size; + BufferData(GL_PIXEL_UNPACK_BUFFER, gl_buffersize, + NULL, GL_DYNAMIC_DRAW); + } + if (!gl_bufferptr) + gl_bufferptr = MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + mpi->planes[0] = gl_bufferptr; + BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); } - if (!gl_bufferptr) - gl_bufferptr = MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); - mpi->planes[0] = gl_bufferptr; - BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); if (!mpi->planes[0]) { if (!err_shown) mp_msg(MSGT_VO, MSGL_ERR, "[gl] could not acquire buffer for dr\n" @@ -769,7 +793,7 @@ static uint32_t draw_image(mp_image_t *mpi) { stride[0] = mpi->stride[0]; stride[1] = mpi->stride[1]; stride[2] = mpi->stride[2]; planes[0] = mpi->planes[0]; planes[1] = mpi->planes[1]; planes[2] = mpi->planes[2]; mpi_flipped = stride[0] < 0; - if (mpi->flags & MP_IMGFLAG_DIRECT) { + if (!mesa_buffer && mpi->flags & MP_IMGFLAG_DIRECT) { intptr_t base = (intptr_t)planes[0]; if (mpi_flipped) base += (mpi->h - 1) * stride[0]; @@ -779,10 +803,11 @@ static uint32_t draw_image(mp_image_t *mpi) { BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer); UnmapBuffer(GL_PIXEL_UNPACK_BUFFER); gl_bufferptr = NULL; - slice = 0; // always "upload" full texture if (!(mpi->flags & MP_IMGFLAG_COMMON_PLANE)) planes[0] = planes[1] = planes[2] = NULL; } + if (mpi->flags & MP_IMGFLAG_DIRECT) + slice = 0; // always "upload" full texture glUploadTex(gl_target, gl_format, gl_type, planes[0], stride[0], mpi->x, mpi->y, w, h, slice); if (mpi->imgfmt == IMGFMT_YV12) { @@ -804,7 +829,7 @@ static uint32_t draw_image(mp_image_t *mpi) { mpi->x / 2, mpi->y / 2, w / 2, h / 2, slice); ActiveTexture(GL_TEXTURE0); } - if (mpi->flags & MP_IMGFLAG_DIRECT) + if (!mesa_buffer && mpi->flags & MP_IMGFLAG_DIRECT) BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); skip_upload: if (vo_doublebuffering) do_render(); @@ -833,6 +858,8 @@ query_format(uint32_t format) // ideally MPlayer should be fixed instead not to use Y800 when it has the choice if (!use_yuv && (format == IMGFMT_Y8 || format == IMGFMT_Y800)) return 0; + if (!use_ycbcr && (format == IMGFMT_UYVY || format == IMGFMT_YUY2)) + return 0; if (many_fmts && glFindFormat(format, NULL, NULL, NULL, NULL)) return caps; @@ -858,6 +885,7 @@ static opt_t subopts[] = { {"osd", OPT_ARG_BOOL, &use_osd, NULL}, {"scaled-osd", OPT_ARG_BOOL, &scaled_osd, NULL}, {"aspect", OPT_ARG_BOOL, &use_aspect, NULL}, + {"ycbcr", OPT_ARG_BOOL, &use_ycbcr, NULL}, {"slice-height", OPT_ARG_INT, &slice_height, (opt_test_f)int_non_neg}, {"rectangle", OPT_ARG_INT, &use_rectangle,(opt_test_f)int_non_neg}, {"yuv", OPT_ARG_INT, &use_yuv, (opt_test_f)int_non_neg}, @@ -866,6 +894,7 @@ static opt_t subopts[] = { {"filter-strength", OPT_ARG_FLOAT, &filter_strength, NULL}, {"ati-hack", OPT_ARG_BOOL, &ati_hack, NULL}, {"force-pbo", OPT_ARG_BOOL, &force_pbo, NULL}, + {"mesa-buffer", OPT_ARG_BOOL, &mesa_buffer, NULL}, {"glfinish", OPT_ARG_BOOL, &use_glFinish, NULL}, {"swapinterval", OPT_ARG_INT, &swap_interval,NULL}, {"customprog", OPT_ARG_MSTRZ,&custom_prog, NULL}, @@ -883,6 +912,7 @@ static int preinit(const char *arg) use_osd = 1; scaled_osd = 0; use_aspect = 1; + use_ycbcr = 0; use_yuv = 0; lscale = 0; cscale = 0; @@ -891,6 +921,7 @@ static int preinit(const char *arg) use_glFinish = 0; ati_hack = 0; force_pbo = 0; + mesa_buffer = 0; swap_interval = 1; slice_height = 0; custom_prog = NULL; @@ -909,6 +940,8 @@ static int preinit(const char *arg) " Slice size for texture transfer, 0 for whole image\n" " noosd\n" " Do not use OpenGL OSD code\n" + " scaled-osd\n" + " Render OSD at movie resolution and scale it\n" " noaspect\n" " Do not do aspect scaling\n" " rectangle=<0,1,2>\n" @@ -938,9 +971,12 @@ static int preinit(const char *arg) " 1: use improved bicubic scaling for luma.\n" " 2: use cubic in X, linear in Y direction scaling for luma.\n" " 3: as 1 but without using a lookup texture.\n" - " 4: experimental unsharp masking.\n" + " 4: experimental unsharp masking (sharpening).\n" + " 5: experimental unsharp masking (sharpening) with larger radius.\n" " cscale=<n>\n" " as lscale but for chroma (2x slower with little visible effect).\n" + " filter-strength=<value>\n" + " set the effect strength for some lscale/cscale filters\n" " customprog=<filename>\n" " use a custom YUV conversion program\n" " customtex=<filename>\n" @@ -951,6 +987,8 @@ static int preinit(const char *arg) " use texture_rectangle for customtex texture\n" " osdcolor=<0xAARRGGBB>\n" " use the given color for the OSD\n" + " ycbcr\n" + " also try to use the GL_MESA_ycbcr_texture extension\n" "\n" ); return -1; } diff --git a/libvo/x11_common.c b/libvo/x11_common.c index 25bed4389a..2dc594419a 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -1165,6 +1165,13 @@ void vo_x11_sizehint(struct vo *vo, int x, int y, int width, int height, int max x11->vo_hint.flags |= PMinSize; x11->vo_hint.min_width = x11->vo_hint.min_height = 4; + // Set the base size. A window manager might display the window + // size to the user relative to this. + // Setting these to width/height might be nice, but e.g. fluxbox can't handle it. + x11->vo_hint.flags |= PBaseSize; + x11->vo_hint.base_width = 0 /*width*/; + x11->vo_hint.base_height = 0 /*height*/; + x11->vo_hint.flags |= PWinGravity; x11->vo_hint.win_gravity = StaticGravity; XSetWMNormalHints(x11->display, x11->window, &x11->vo_hint); |