From 0ca415447d33c75469724e16aba6385fd80691db Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 5 Dec 2008 15:36:54 +0000 Subject: Add support for YCBCR MESA texture format to vo_gl. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28093 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_gl.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libvo/vo_gl.c') diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index fc7951d39f..736d9f6ae7 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; @@ -833,6 +834,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 +861,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}, @@ -883,6 +887,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; -- cgit v1.2.3 From 173e7ebc35f2a042f7422fa4350206895e7faa02 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 5 Dec 2008 15:50:24 +0000 Subject: Add some forgotten documentation for gl suboptions git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28094 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_gl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libvo/vo_gl.c') diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 736d9f6ae7..452a086b38 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -914,6 +914,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" @@ -943,9 +945,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" " as lscale but for chroma (2x slower with little visible effect).\n" + " filter-strength=\n" + " set the effect strength for some lscale/cscale filters\n" " customprog=\n" " use a custom YUV conversion program\n" " customtex=\n" @@ -956,6 +961,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; } -- cgit v1.2.3 From e7d53f6d86eee73e0f48ad1032dfd67acd884a73 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 5 Dec 2008 20:50:43 +0000 Subject: Simplify, do not duplicate buffer size calculation git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28098 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_gl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libvo/vo_gl.c') diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 452a086b38..0bcd5c363a 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -698,9 +698,9 @@ static uint32_t get_image(mp_image_t *mpi) { 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; + BufferData(GL_PIXEL_UNPACK_BUFFER, gl_buffersize, + NULL, GL_DYNAMIC_DRAW); } if (!gl_bufferptr) gl_bufferptr = MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); -- cgit v1.2.3 From 7fd346bc71d8bf204c5fddd2ad532e7adb4794b9 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 5 Dec 2008 20:56:49 +0000 Subject: Avoid one more duplicated logic. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28099 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_gl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libvo/vo_gl.c') diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 0bcd5c363a..74142d5039 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -681,6 +681,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" @@ -697,8 +698,9 @@ static uint32_t get_image(mp_image_t *mpi) { 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) { - gl_buffersize = mpi->stride[0] * mpi->height; + needed_size = mpi->stride[0] * mpi->height; + if (needed_size > gl_buffersize) { + gl_buffersize = needed_size; BufferData(GL_PIXEL_UNPACK_BUFFER, gl_buffersize, NULL, GL_DYNAMIC_DRAW); } -- cgit v1.2.3 From b6e113841c96daf383c5a9dfa8b406a1d5ab11f0 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 5 Dec 2008 22:16:45 +0000 Subject: Add experimental support for glXAllocateMemoryMESA git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28101 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_gl.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'libvo/vo_gl.c') diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 74142d5039..e5fd57daae 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -85,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; @@ -97,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; @@ -389,6 +392,9 @@ 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; + if (mesa_bufferptr) + FreeMemoryMESA(mDisplay, mScreen, mesa_bufferptr); + mesa_bufferptr = NULL; err_shown = 0; } @@ -694,11 +700,23 @@ static uint32_t get_image(mp_image_t *mpi) { mpi->width = texture_width; mpi->height = texture_height; } + mpi->stride[0] = mpi->width * mpi->bpp / 8; + 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); - mpi->stride[0] = mpi->width * mpi->bpp / 8; - needed_size = mpi->stride[0] * mpi->height; if (needed_size > gl_buffersize) { gl_buffersize = needed_size; BufferData(GL_PIXEL_UNPACK_BUFFER, gl_buffersize, @@ -708,6 +726,7 @@ static uint32_t get_image(mp_image_t *mpi) { 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" @@ -772,7 +791,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]; @@ -782,10 +801,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) { @@ -807,7 +827,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(); @@ -872,6 +892,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}, @@ -898,6 +919,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; -- cgit v1.2.3 From a86076ac44279ef6b60b9d90dbf81ad4adfddebb Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 5 Dec 2008 22:35:24 +0000 Subject: Fix indentation git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28102 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_gl.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'libvo/vo_gl.c') diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index e5fd57daae..ba60ea8bff 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -714,18 +714,18 @@ static uint32_t get_image(mp_image_t *mpi) { #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_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 (!mpi->planes[0]) { if (!err_shown) -- cgit v1.2.3 From c6ef66231818b90c75f84b9407730647c93f040c Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 5 Dec 2008 23:35:32 +0000 Subject: 10l, add forgotten a #ifndef GL_WIN32, fixes win32 builds. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28103 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_gl.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libvo/vo_gl.c') diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index ba60ea8bff..21d310e170 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -392,8 +392,10 @@ 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; } -- cgit v1.2.3