diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-05-10 12:21:37 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-05-10 12:21:37 +0000 |
commit | f30961d414f93ae82e1d2f7778abf15136017852 (patch) | |
tree | 8fe79ecccc79cb4a1280123ee034afb31a450c85 | |
parent | 00b1ac02e2f6dcde812bf5a33c73a91323e898b2 (diff) | |
download | mpv-f30961d414f93ae82e1d2f7778abf15136017852.tar.bz2 mpv-f30961d414f93ae82e1d2f7778abf15136017852.tar.xz |
Add force-pbo suboption for faster OpenGL output.
Based on a patch by Sven Gothel sgothel-jausoftcom.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26713 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libvo/vo_gl.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index e538ca6b36..88210b1223 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -16,6 +16,7 @@ #ifdef HAVE_NEW_GUI #include "gui/interface.h" #endif +#include "fastmemcpy.h" #include "libass/ass.h" #include "libass/ass_mp.h" @@ -81,6 +82,7 @@ static uint32_t image_height; static uint32_t image_format; static int many_fmts; static int ati_hack; +static int force_pbo; static int use_glFinish; static int swap_interval; static GLenum gl_target; @@ -707,10 +709,24 @@ static uint32_t get_image(mp_image_t *mpi) { static uint32_t draw_image(mp_image_t *mpi) { int slice = slice_height; - int stride[3] = {mpi->stride[0], mpi->stride[1], mpi->stride[2]}; - unsigned char *planes[3] = {mpi->planes[0], mpi->planes[1], mpi->planes[2]}; + int stride[3]; + unsigned char *planes[3]; + mp_image_t mpi2 = *mpi; if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) return VO_TRUE; + mpi2.flags = 0; mpi2.type = MP_IMGTYPE_TEMP; + mpi2.width = mpi2.w; mpi2.height = mpi2.h; + if (force_pbo && !(mpi->flags & MP_IMGFLAG_DIRECT) && !gl_bufferptr && get_image(&mpi2) == VO_TRUE) { + int bpp = mpi->imgfmt == IMGFMT_YV12 ? 1 : mpi->bpp; + memcpy_pic(mpi2.planes[0], mpi->planes[0], mpi->w * bpp, mpi->h, mpi2.stride[0], mpi->stride[0]); + if (mpi->imgfmt == IMGFMT_YV12) { + memcpy_pic(mpi2.planes[1], mpi->planes[1], mpi->w >> 1, mpi->h >> 1, mpi2.stride[1], mpi->stride[1]); + memcpy_pic(mpi2.planes[2], mpi->planes[2], mpi->w >> 1, mpi->h >> 1, mpi2.stride[2], mpi->stride[2]); + } + mpi = &mpi2; + } + 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) { intptr_t base = (intptr_t)planes[0]; @@ -793,6 +809,7 @@ static opt_t subopts[] = { {"lscale", OPT_ARG_INT, &lscale, (opt_test_f)int_non_neg}, {"cscale", OPT_ARG_INT, &cscale, (opt_test_f)int_non_neg}, {"ati-hack", OPT_ARG_BOOL, &ati_hack, NULL}, + {"force-pbo", OPT_ARG_BOOL, &force_pbo, NULL}, {"glfinish", OPT_ARG_BOOL, &use_glFinish, NULL}, {"swapinterval", OPT_ARG_INT, &swap_interval,NULL}, {"customprog", OPT_ARG_MSTRZ,&custom_prog, NULL}, @@ -816,6 +833,7 @@ static int preinit(const char *arg) use_rectangle = 0; use_glFinish = 0; ati_hack = 0; + force_pbo = 0; swap_interval = 1; slice_height = 0; custom_prog = NULL; @@ -842,6 +860,8 @@ static int preinit(const char *arg) " 2: use texture_non_power_of_two\n" " ati-hack\n" " Workaround ATI bug with PBOs\n" + " force-pbo\n" + " Force use of PBO even if this involves an extra memcpy\n" " glfinish\n" " Call glFinish() before swapping buffers\n" " swapinterval=<n>\n" |